import { gql } from 'graphql-tag'

export const typeDefs = gql`
  scalar DateTime
  scalar JSON

  type Query {
    # Health check
    health: HealthStatus

    # Resources
    resources(filter: ResourceFilter): [Resource!]!
    resource(id: ID!): Resource

    # Sites
    sites: [Site!]!
    site(id: ID!): Site

    # Regions
    regions: [Region!]!
    region(id: ID!): Region
    regionByCode(code: String!): Region

    # Resource Inventory
    resourceInventory(filter: ResourceInventoryFilter): [ResourceInventoryItem!]!
    resourceInventoryItem(id: ID!): ResourceInventoryItem

    # Resource Graph
    resourceGraph(query: ResourceGraphQuery): ResourceGraph!
    resourceDependencies(resourceId: ID!, maxDepth: Int): [ResourceGraphNode!]!
    resourceDependents(resourceId: ID!, maxDepth: Int): [ResourceGraphNode!]!
    resourcePath(sourceResourceId: ID!, targetResourceId: ID!, maxDepth: Int): [ResourceGraphEdge!]!
    resourcesByProvider(provider: ResourceProvider!): [ResourceGraphNode!]!
    resourcesByRegion(region: String!): [ResourceGraphNode!]!
    resourcesByTags(tags: [String!]!): [ResourceGraphNode!]!

    # Policies
    policies(filter: PolicyFilter): [Policy!]!
    policy(id: ID!): Policy!
    policyViolations(filter: PolicyViolationFilter): [PolicyViolation!]!

    # Metrics
    metrics(resourceId: ID!, metricType: MetricType!, timeRange: TimeRange!): Metrics!
    
    # Well-Architected Framework
    pillars: [Pillar!]!
    pillar(code: PillarCode!): Pillar
    findings(filter: FindingFilter): [Finding!]!
    risks(resourceId: ID): [Risk!]!
    
    # Cultural Context
    culturalContext(regionId: ID!): CulturalContext

    # Users
    me: User
    users: [User!]!
    user(id: ID!): User

    # API Keys
    apiKeys: [ApiKey!]!
    apiKey(id: ID!): ApiKey

    # Test Environments
    testEnvironments: [TestEnvironment!]!
    testEnvironment(id: ID!): TestEnvironment

    # Tenants (Sovereign, Superior to Azure)
    tenants: [Tenant!]!
    tenant(id: ID!): Tenant
    tenantByDomain(domain: String!): Tenant
    myTenant: Tenant
    tenantUsage(tenantId: ID!, timeRange: TimeRange!): UsageReport!

    # Billing (Superior to Azure Cost Management)
    usage(tenantId: ID!, timeRange: TimeRange!, granularity: Granularity!): UsageReport!
    usageByResource(tenantId: ID!, resourceId: ID!): ResourceUsage!
    costBreakdown(tenantId: ID!, groupBy: [String!]!): CostBreakdown!
    invoice(tenantId: ID!, invoiceId: ID!): Invoice!
    invoices(tenantId: ID!, filter: InvoiceFilter!): [Invoice!]!
    costForecast(tenantId: ID!, timeframe: String!, confidence: Float!): CostForecast!
    costOptimization(tenantId: ID!): [OptimizationRecommendation!]!
    optimizationRecommendations(tenantId: ID): [OptimizationRecommendation!]!
    billingAlerts(tenantId: ID!): [BillingAlert!]!
    budgets(tenantId: ID!): [Budget!]!

    # Omada Infrastructure
    omadaSites: [OmadaSite!]!
    omadaSite(id: ID!): OmadaSite
    omadaAccessPoints(siteId: ID!): [OmadaAccessPoint!]!
    omadaAccessPoint(id: ID!): OmadaAccessPoint
    omadaClients(siteId: ID!): [OmadaClient!]!
    omadaClient(mac: String!): OmadaClient
    omadaSsids(siteId: ID!): [OmadaSsid!]!

    # Marketplace Catalog
    publishers: [Publisher!]!
    publisher(id: ID!): Publisher
    products(filter: ProductFilter): [Product!]!
    product(id: ID!): Product
    productBySlug(slug: String!): Product
    productReviews(productId: ID!): [ProductReview!]!

    # Templates
    templates(filter: TemplateFilter): [Template!]!
    template(id: ID!): Template
    templateBySlug(slug: String!, version: String): Template

    # Deployments
    deployments(filter: DeploymentFilter): [Deployment!]!
    deployment(id: ID!): Deployment
    deploymentLogs(deploymentId: ID!, limit: Int): [DeploymentLog!]!

    # Blockchain Networks
    blockchainNetworks: [BlockchainNetwork!]!
    blockchainNetwork(id: ID!): BlockchainNetwork
    blockchainNodes(networkId: ID!): [BlockchainNode!]!

    # PoP Mappings
    popMappings: [PoPMapping!]!
    popMapping(popId: String!): PoPMapping

    # Sovereignty Zones
    sovereigntyZones: [SovereigntyZone!]!
    sovereigntyZone(id: ID!): SovereigntyZone

    # Well-Architected Framework
    industryControls(industry: IndustryType!): [IndustryControl!]!
    wafAssessment(resourceId: ID!, industry: IndustryType!): WAFAssessment

    # Community Forum
    forumCategories: [ForumCategory!]!
    forumCategory(id: ID!): ForumCategory
    forumPosts(filter: ForumPostFilter!): [ForumPost!]!
    forumPost(id: ID!): ForumPost
    forumReplies(postId: ID!): [ForumReply!]!

    # API Marketplace
    apiMarketplaceListings(filter: APIMarketplaceFilter): [APIMarketplaceListing!]!
    apiMarketplaceListing(id: ID!): APIMarketplaceListing
    myAPISubscriptions: [APISubscription!]!

    # Analytics
    analyticsRevenue(timeRange: TimeRange!): AnalyticsRevenue!
    analyticsUsers(timeRange: TimeRange!): AnalyticsUsers!
    analyticsAPIUsage(timeRange: TimeRange!): AnalyticsAPIUsage!
    analyticsGrowth: AnalyticsGrowth!

    # Infrastructure Documentation
    countries(filter: CountryFilter): [Country!]!
    country(name: String!): Country
    networkTopologies(filter: TopologyFilter): [NetworkTopology!]!
    networkTopology(id: ID!): NetworkTopology
    complianceRequirements(filter: ComplianceFilter): [ComplianceRequirement!]!
    complianceRequirement(country: String!): ComplianceRequirement
    deploymentMilestones(filter: MilestoneFilter): [DeploymentMilestone!]!
    deploymentMilestone(id: ID!): DeploymentMilestone
    costEstimates(filter: CostEstimateFilter): [CostEstimate!]!
    costEstimate(region: String!, entity: String!, category: CostCategory!): CostEstimate
    infrastructureSummary: InfrastructureSummary!
  }

  type Mutation {
    # Authentication
    login(email: String!, password: String!): AuthPayload!
    logout: Boolean!
    
    # Two-Factor Authentication
    setup2FA: Setup2FAResult!
    verify2FA(code: String!, secret: String!): Verify2FAResult!
    enable2FA(code: String!, secret: String!): Boolean!
    disable2FA: Boolean!

    # API Keys
    createApiKey(input: CreateApiKeyInput!): CreateApiKeyResult!
    updateApiKey(id: ID!, input: UpdateApiKeyInput!): ApiKey!
    revokeApiKey(id: ID!): Boolean!

    # Test Environments
    createTestEnvironment(input: CreateTestEnvironmentInput!): TestEnvironment!
    updateTestEnvironment(id: ID!, input: UpdateTestEnvironmentInput!): TestEnvironment!
    startTestEnvironment(id: ID!): TestEnvironment!
    stopTestEnvironment(id: ID!): TestEnvironment!
    deleteTestEnvironment(id: ID!): Boolean!

    # Resources
    createResource(input: CreateResourceInput!): Resource!
    updateResource(id: ID!, input: UpdateResourceInput!): Resource!
    deleteResource(id: ID!): Boolean!

    # Resource Inventory
    createResourceInventoryItem(input: CreateResourceInventoryInput!): ResourceInventoryItem!
    updateResourceInventoryItem(id: ID!, input: UpdateResourceInventoryInput!): ResourceInventoryItem!
    deleteResourceInventoryItem(id: ID!): Boolean!
    syncResourceInventory(provider: String!, resources: [CreateResourceInventoryInput!]!): SyncResult!

    # Resource Graph
    createResourceRelationship(
      sourceResourceId: ID!
      targetResourceId: ID!
      relationshipType: String!
      metadata: JSON
    ): ResourceRelationship!
    deleteResourceRelationship(id: ID!): Boolean!

    # Policies
    createPolicy(input: CreatePolicyInput!): Policy!
    updatePolicy(id: ID!, input: UpdatePolicyInput!): Policy!
    deletePolicy(id: ID!): Boolean!
    evaluatePolicy(policyId: ID!, resourceId: ID!): PolicyEvaluation!
    evaluateAllPolicies(resourceId: ID): EvaluationResult!
    resolveViolation(violationId: ID!): Boolean!

    # Users
    createUser(input: CreateUserInput!): User!
    updateUser(id: ID!, input: UpdateUserInput!): User!
    deleteUser(id: ID!): Boolean!

    # Tenants (Sovereign, Superior to Azure)
    createTenant(input: CreateTenantInput!): Tenant!
    updateTenant(id: ID!, input: UpdateTenantInput!): Tenant!
    deleteTenant(id: ID!): Boolean!
    suspendTenant(id: ID!, reason: String!): Boolean!
    activateTenant(id: ID!): Boolean!
    addUserToTenant(tenantId: ID!, userId: ID!, role: TenantRole!, permissions: JSON): Boolean!
    removeUserFromTenant(tenantId: ID!, userId: ID!): Boolean!
    updateTenantQuotas(tenantId: ID!, quotas: TenantQuotasInput!): Tenant!
    shareResourceAcrossTenants(resourceId: ID!, targetTenants: [ID!]!): Boolean!
    checkQuota(tenantId: ID!, resourceRequest: ResourceRequestInput!): QuotaCheckResult!

    # Billing (Superior to Azure Cost Management)
    setBudget(tenantId: ID!, budget: BudgetInput!): Budget!
    updateBudget(id: ID!, input: BudgetInput!): Budget!
    deleteBudget(id: ID!): Boolean!
    createBillingAlert(tenantId: ID!, alert: BillingAlertInput!): BillingAlert!
    updateBillingAlert(id: ID!, input: BillingAlertInput!): BillingAlert!
    deleteBillingAlert(id: ID!): Boolean!

    # Anomaly Detection
    detectAnomalies(config: AnomalyDetectionConfig!): [Anomaly!]!
    detectAnomaliesForAllResources(metricTypes: [String!]): [Anomaly!]!

    # Predictive Analytics
    predictUsage(config: PredictiveConfig!): Prediction!
    predictCost(resourceId: ID!, timeframe: String!): Prediction!
    predictCapacity(resourceId: ID!, metricType: String!, timeframe: String!): Prediction!
    predictFailure(resourceId: ID!, timeframe: String): Prediction

    # Marketplace Catalog
    createPublisher(input: CreatePublisherInput!): Publisher!
    createProduct(input: CreateProductInput!): Product!
    updateProduct(id: ID!, input: UpdateProductInput!): Product!
    createProductVersion(input: CreateProductVersionInput!): ProductVersion!
    createPricingModel(input: CreatePricingModelInput!): PricingModel!
    createProductReview(input: CreateProductReviewInput!): ProductReview!

    # Templates
    createTemplate(input: CreateTemplateInput!): Template!
    updateTemplate(id: ID!, input: UpdateTemplateInput!): Template!
    createTemplateVersion(input: CreateTemplateVersionInput!): TemplateVersion!

    # Deployments
    createDeployment(input: CreateDeploymentInput!): Deployment!
    deleteDeployment(id: ID!): Boolean!

    # Blockchain Networks
    createBlockchainNetwork(input: CreateBlockchainNetworkInput!): BlockchainNetwork!
    createBlockchainNode(networkId: ID!, input: CreateBlockchainNodeInput!): BlockchainNode!

    # PoP Mappings
    mapPoPToRegion(popLocation: PoPLocationInput!): PoPMapping!

    # Sovereignty Zones
    createSovereigntyZone(input: CreateSovereigntyZoneInput!): SovereigntyZone!
    createDataResidencyRule(input: CreateDataResidencyRuleInput!): DataResidencyRule!

    # Well-Architected Framework
    assessResourceWAF(resourceId: ID!, industry: IndustryType!): WAFAssessment!

    # Community Forum
    createForumPost(input: CreateForumPostInput!): ForumPost!
    updateForumPost(id: ID!, input: UpdateForumPostInput!): ForumPost!
    deleteForumPost(id: ID!): Boolean!
    createForumReply(input: CreateForumReplyInput!): ForumReply!
    updateForumReply(id: ID!, input: UpdateForumReplyInput!): ForumReply!
    deleteForumReply(id: ID!): Boolean!

    # API Marketplace
    createAPIMarketplaceListing(input: CreateAPIMarketplaceListingInput!): APIMarketplaceListing!
    updateAPIMarketplaceListing(id: ID!, input: UpdateAPIMarketplaceListingInput!): APIMarketplaceListing!
    deleteAPIMarketplaceListing(id: ID!): Boolean!
    subscribeToAPI(listingId: ID!): APISubscription!
    unsubscribeFromAPI(subscriptionId: ID!): Boolean!

    # Infrastructure Documentation Mutations
    updateNetworkTopology(id: ID!, input: UpdateTopologyInput!): NetworkTopology!
    createDeploymentMilestone(input: CreateMilestoneInput!): DeploymentMilestone!
    updateDeploymentMilestone(id: ID!, input: UpdateMilestoneInput!): DeploymentMilestone!
    deleteDeploymentMilestone(id: ID!): Boolean!
    updateComplianceRequirement(country: String!, input: UpdateComplianceInput!): ComplianceRequirement!
    updateCostEstimate(region: String!, entity: String!, category: CostCategory!, input: UpdateCostEstimateInput!): CostEstimate!
  }

  type Subscription {
    resourceUpdated(id: ID!): Resource!
    resourceCreated: Resource!
    resourceDeleted(id: ID!): ID!
  }

  type HealthStatus {
    status: String!
    timestamp: DateTime!
    version: String!
  }

  type Resource {
    id: ID!
    name: String!
    type: ResourceType!
    status: ResourceStatus!
    site: Site!
    metadata: JSON
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type Site {
    id: ID!
    name: String!
    region: String!
    status: SiteStatus!
    resources: [Resource!]!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type User {
    id: ID!
    email: String!
    name: String!
    role: UserRole!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type AuthPayload {
    token: String!
    user: User!
  }

  enum ResourceType {
    VM
    CONTAINER
    STORAGE
    NETWORK
  }

  enum ResourceStatus {
    PENDING
    PROVISIONING
    RUNNING
    STOPPED
    ERROR
    DELETING
  }

  enum SiteStatus {
    ACTIVE
    INACTIVE
    MAINTENANCE
  }

  enum UserRole {
    ADMIN
    USER
    VIEWER
  }

  enum ResourceProvider {
    PROXMOX
    KUBERNETES
    CLOUDFLARE
    CEPH
    MINIO
    AWS
    AZURE
    GCP
    OMADA
  }

  type ResourceInventoryItem {
    id: ID!
    resourceType: String!
    provider: ResourceProvider!
    providerId: String!
    providerResourceId: String
    name: String!
    region: String
    site: Site
    metadata: JSON
    tags: [String!]!
    discoveredAt: DateTime!
    lastSyncedAt: DateTime!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type SyncResult {
    synced: Int!
    provider: String!
  }

  input ResourceInventoryFilter {
    provider: ResourceProvider
    resourceType: String
    region: String
    siteId: ID
    tags: [String!]
  }

  input CreateResourceInventoryInput {
    resourceType: String!
    provider: ResourceProvider!
    providerId: String!
    providerResourceId: String
    name: String!
    region: String
    siteId: ID
    metadata: JSON
    tags: [String!]
  }

  input UpdateResourceInventoryInput {
    name: String
    region: String
    siteId: ID
    metadata: JSON
    tags: [String!]
  }

  type ResourceGraph {
    nodes: [ResourceGraphNode!]!
    edges: [ResourceGraphEdge!]!
  }

  type ResourceGraphNode {
    id: ID!
    resourceType: String!
    provider: ResourceProvider!
    name: String!
    region: String
    metadata: JSON
  }

  type ResourceGraphEdge {
    id: ID!
    source: ID!
    target: ID!
    relationshipType: String!
    metadata: JSON
  }

  type ResourceRelationship {
    id: ID!
    sourceResourceId: ID!
    targetResourceId: ID!
    relationshipType: String!
    metadata: JSON
    createdAt: DateTime!
  }

  input ResourceGraphQuery {
    provider: ResourceProvider
    resourceType: String
    region: String
    siteId: ID
    relationshipType: String
    maxDepth: Int
  }

  enum PolicyType {
    TAGGING
    COMPLIANCE
    SECURITY
    COST_OPTIMIZATION
  }

  enum PolicySeverity {
    LOW
    MEDIUM
    HIGH
    CRITICAL
  }

  enum ViolationStatus {
    OPEN
    ACKNOWLEDGED
    RESOLVED
    SUPPRESSED
  }

  type Policy {
    id: ID!
    name: String!
    description: String
    policyType: PolicyType!
    enabled: Boolean!
    severity: PolicySeverity!
    rule: JSON!
    scope: JSON!
    metadata: JSON!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type PolicyEvaluation {
    id: ID!
    policyId: ID!
    resourceId: ID!
    status: String!
    findings: [JSON!]!
    evaluatedAt: DateTime!
  }

  type PolicyViolation {
    id: ID!
    policyId: ID!
    resourceId: ID!
    severity: PolicySeverity!
    message: String!
    remediation: String
    status: ViolationStatus!
    createdAt: DateTime!
    resolvedAt: DateTime
    resolvedBy: ID
  }

  type EvaluationResult {
    evaluated: Int!
  }

  input PolicyFilter {
    policyType: PolicyType
    enabled: Boolean
  }

  input PolicyViolationFilter {
    policyId: ID
    resourceId: ID
    status: ViolationStatus
    severity: PolicySeverity
  }

  input CreatePolicyInput {
    name: String!
    description: String
    policyType: PolicyType!
    enabled: Boolean
    severity: PolicySeverity
    rule: JSON!
    scope: JSON
    metadata: JSON
  }

  input UpdatePolicyInput {
    name: String
    description: String
    enabled: Boolean
    severity: PolicySeverity
    rule: JSON
    scope: JSON
    metadata: JSON
  }

  input ResourceFilter {
    type: ResourceType
    status: ResourceStatus
    siteId: ID
  }

  input CreateResourceInput {
    name: String!
    type: ResourceType!
    siteId: ID!
    metadata: JSON
  }

  input UpdateResourceInput {
    name: String
    metadata: JSON
  }

  input CreateUserInput {
    email: String!
    name: String!
    password: String!
    role: UserRole
  }

  input UpdateUserInput {
    name: String
    role: UserRole
  }

  # Regions
  type Region {
    id: ID!
    name: String!
    code: String!
    country: String
    coordinates: Coordinates
    sites: [Site!]!
    createdAt: DateTime!
    updatedAt: DateTime!
    metadata: JSON
  }

  type Coordinates {
    latitude: Float!
    longitude: Float!
  }


  # Metrics
  type Metrics {
    resource: ResourceInventoryItem!
    metricType: MetricType!
    values: [MetricValue!]!
    timeRange: TimeRange!
  }

  enum MetricType {
    CPU_USAGE
    MEMORY_USAGE
    NETWORK_THROUGHPUT
    NETWORK_LATENCY
    STORAGE_IOPS
    REQUEST_RATE
    ERROR_RATE
    COST
    HEALTH_SCORE
  }

  type MetricValue {
    timestamp: DateTime!
    value: Float!
    labels: JSON
  }

  type TimeRange {
    start: DateTime!
    end: DateTime!
  }

  enum HealthStatus {
    HEALTHY
    DEGRADED
    UNHEALTHY
    UNKNOWN
  }

  # Well-Architected Framework
  enum PillarCode {
    SECURITY
    RELIABILITY
    COST_OPTIMIZATION
    PERFORMANCE_EFFICIENCY
    OPERATIONAL_EXCELLENCE
    SUSTAINABILITY
  }

  type Pillar {
    id: ID!
    code: PillarCode!
    name: String!
    description: String
    controls: [Control!]!
  }

  type Control {
    id: ID!
    code: String!
    name: String!
    description: String
    pillar: Pillar!
    findings: [Finding!]!
  }

  enum FindingStatus {
    PASS
    FAIL
    WARNING
    INFO
    NOT_APPLICABLE
  }

  enum Severity {
    CRITICAL
    HIGH
    MEDIUM
    LOW
    INFO
  }

  type Finding {
    id: ID!
    control: Control!
    resource: ResourceInventoryItem!
    status: FindingStatus!
    severity: Severity!
    title: String!
    description: String
    recommendation: String
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type Risk {
    id: ID!
    resource: ResourceInventoryItem!
    pillar: Pillar
    severity: Severity!
    title: String!
    description: String
    mitigation: String
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  input FindingFilter {
    controlId: ID
    resourceId: ID
    status: FindingStatus
    severity: Severity
  }

  # Cultural Context
  type CulturalContext {
    region: Region!
    language: String
    timezone: String
    culturalNorms: JSON
    complianceRequirements: [ComplianceRequirement!]!
    dataResidency: DataResidency
  }

  type ComplianceRequirement {
    framework: String!
    requirements: [String!]!
  }

  type DataResidency {
    region: Region!
    requirements: [String!]!
    compliance: [ComplianceRequirement!]!
  }

  # Anomaly Detection
  type Anomaly {
    id: ID!
    resourceId: ID!
    metricType: String!
    severity: String!
    anomalyType: String!
    value: Float!
    expectedValue: Float
    deviation: Float!
    timestamp: DateTime!
    description: String!
    recommendation: String
  }

  input AnomalyDetectionConfig {
    resourceId: ID!
    metricType: String!
    threshold: Float
    windowSize: Int
    sensitivity: String
  }

  # Predictive Analytics
  type Prediction {
    id: ID!
    resourceId: ID!
    metricType: String!
    predictionType: String!
    currentValue: Float!
    predictedValue: Float!
    confidence: Int!
    timeframe: String!
    timestamp: DateTime!
    trend: String!
    recommendation: String
  }

  input PredictiveConfig {
    resourceId: ID!
    metricType: String!
    timeframe: String!
    predictionType: String!
  }

  # ============================================================================
  # TENANTS (Sovereign, Superior to Azure)
  # ============================================================================

  type Tenant {
    id: ID!
    name: String!
    domain: String
    billingAccountId: String!
    status: TenantStatus!
    tier: TenantTier!
    quotaLimits: TenantQuotas!
    users: [User!]!
    resources: [Resource!]!
    usage: UsageMetrics!
    createdAt: DateTime!
    updatedAt: DateTime!
    metadata: JSON
  }

  enum TenantStatus {
    ACTIVE
    SUSPENDED
    DELETED
    PENDING_ACTIVATION
  }

  enum TenantTier {
    FREE
    STANDARD
    ENTERPRISE
    SOVEREIGN
  }

  enum TenantRole {
    TENANT_OWNER
    TENANT_ADMIN
    TENANT_USER
    TENANT_VIEWER
    TENANT_BILLING_ADMIN
  }

  type TenantQuotas {
    compute: ComputeQuota!
    storage: StorageQuota!
    network: NetworkQuota!
    custom: JSON
  }

  type ComputeQuota {
    vcpu: Int
    memory: Int
    instances: Int
  }

  type StorageQuota {
    total: Int
    perInstance: Int
  }

  type NetworkQuota {
    bandwidth: Int
    egress: Int
  }

  type UsageMetrics {
    current: UsageCurrent!
    forecast: UsageForecast!
    history: [UsageSnapshot!]!
  }

  type UsageCurrent {
    compute: Float!
    storage: Float!
    network: Float!
    total: Float!
    currency: String!
  }

  type UsageForecast {
    predicted: Float!
    confidence: Float!
    timeframe: String!
  }

  type UsageSnapshot {
    timestamp: DateTime!
    compute: Float!
    storage: Float!
    network: Float!
    total: Float!
  }

  input CreateTenantInput {
    name: String!
    domain: String
    tier: TenantTier
    metadata: JSON
    quotaLimits: TenantQuotasInput
  }

  input UpdateTenantInput {
    name: String
    domain: String
    status: TenantStatus
    tier: TenantTier
    metadata: JSON
    quotaLimits: TenantQuotasInput
  }

  input TenantQuotasInput {
    compute: ComputeQuotaInput
    storage: StorageQuotaInput
    network: NetworkQuotaInput
    custom: JSON
  }

  input ComputeQuotaInput {
    vcpu: Int
    memory: Int
    instances: Int
  }

  input StorageQuotaInput {
    total: Int
    perInstance: Int
  }

  input NetworkQuotaInput {
    bandwidth: Int
    egress: Int
  }

  input ResourceRequestInput {
    compute: ComputeRequestInput
    storage: StorageRequestInput
    network: NetworkRequestInput
  }

  input ComputeRequestInput {
    vcpu: Int
    memory: Int
    instances: Int
  }

  input StorageRequestInput {
    size: Int
  }

  input NetworkRequestInput {
    bandwidth: Int
  }

  type QuotaCheckResult {
    allowed: Boolean!
    exceeded: [String!]!
    current: QuotaUsage!
    limits: TenantQuotas!
  }

  type QuotaUsage {
    compute: ComputeQuota!
    storage: StorageQuota!
    network: NetworkQuota!
  }

  # ============================================================================
  # BILLING (Superior to Azure Cost Management)
  # ============================================================================

  enum Granularity {
    SECOND
    MINUTE
    HOUR
    DAY
  }

  type UsageReport {
    tenantId: ID!
    timeRange: TimeRange!
    granularity: Granularity!
    totalCost: Float!
    currency: String!
    byResource: [ResourceUsage!]!
    byMetric: [MetricUsage!]!
    breakdown: CostBreakdown!
  }

  type ResourceUsage {
    resourceId: ID!
    resourceName: String!
    resourceType: String!
    cost: Float!
    quantity: Float!
    unit: String!
  }

  type MetricUsage {
    metricType: String!
    cost: Float!
    quantity: Float!
    unit: String!
  }

  type CostBreakdown {
    total: Float!
    byResource: [ResourceCost!]!
    byService: [ServiceCost!]!
    byRegion: [RegionCost!]!
    allocations: [CostAllocation!]!
  }

  type ResourceCost {
    resourceId: ID!
    resourceName: String!
    cost: Float!
    percentage: Float!
  }

  type ServiceCost {
    service: String!
    cost: Float!
    percentage: Float!
  }

  type RegionCost {
    region: String!
    cost: Float!
    percentage: Float!
  }

  type CostAllocation {
    key: String!
    value: String!
    cost: Float!
    percentage: Float!
  }

  type Invoice {
    id: ID!
    tenantId: ID!
    invoiceNumber: String!
    billingPeriodStart: DateTime!
    billingPeriodEnd: DateTime!
    subtotal: Float!
    tax: Float!
    total: Float!
    currency: String!
    status: InvoiceStatus!
    dueDate: DateTime
    paidAt: DateTime
    lineItems: [InvoiceLineItem!]!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum InvoiceStatus {
    DRAFT
    PENDING
    PAID
    OVERDUE
    CANCELLED
  }

  type InvoiceLineItem {
    id: ID!
    description: String!
    quantity: Float!
    unitPrice: Float!
    total: Float!
    resourceId: ID
  }

  input InvoiceFilter {
    status: InvoiceStatus
    startDate: DateTime
    endDate: DateTime
  }

  type CostForecast {
    tenantId: ID!
    timeframe: String!
    currentCost: Float!
    predictedCost: Float!
    confidence: Float!
    trend: String!
    recommendations: [String!]!
  }

  type OptimizationRecommendation {
    id: ID!
    type: String!
    title: String!
    description: String!
    potentialSavings: Float!
    impact: String!
    effort: String!
  }

  type BillingAlert {
    id: ID!
    tenantId: ID!
    name: String!
    alertType: BillingAlertType!
    threshold: Float
    condition: JSON!
    enabled: Boolean!
    lastTriggeredAt: DateTime
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum BillingAlertType {
    BUDGET
    THRESHOLD
    ANOMALY
    FORECAST
  }

  input BillingAlertInput {
    name: String!
    alertType: BillingAlertType!
    threshold: Float
    condition: JSON!
    notificationChannels: [String!]
    enabled: Boolean
  }

  type Budget {
    id: ID!
    tenantId: ID!
    name: String!
    amount: Float!
    currency: String!
    period: BudgetPeriod!
    startDate: DateTime!
    endDate: DateTime
    alertThresholds: [Float!]!
    filters: JSON!
    currentSpend: Float!
    remaining: Float!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum BudgetPeriod {
    DAILY
    WEEKLY
    MONTHLY
    QUARTERLY
    YEARLY
  }

  input BudgetInput {
    name: String!
    amount: Float!
    currency: String
    period: BudgetPeriod!
    startDate: DateTime!
    endDate: DateTime
    alertThresholds: [Float!]
    filters: JSON
  }

  # ============================================================================
  # OMADA INFRASTRUCTURE
  # ============================================================================

  type OmadaSite {
    id: ID!
    name: String!
    timezone: String!
    description: String
    accessPoints: [OmadaAccessPoint!]!
    clients: [OmadaClient!]!
    ssids: [OmadaSsid!]!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type OmadaAccessPoint {
    id: ID!
    name: String!
    siteId: ID!
    site: OmadaSite!
    macAddress: String!
    model: String
    firmwareVersion: String
    status: OmadaDeviceStatus!
    location: String
    radioConfig: JSON
    connectedClients: Int!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type OmadaClient {
    id: ID!
    macAddress: String!
    siteId: ID!
    site: OmadaSite!
    name: String
    ipAddress: String
    connectedAp: OmadaAccessPoint
    signalStrength: Int
    connectedAt: DateTime
    lastSeen: DateTime!
  }

  type OmadaSsid {
    id: ID!
    name: String!
    siteId: ID!
    site: OmadaSite!
    security: OmadaSecurityType!
    enabled: Boolean!
    vlan: Int
    radios: [String!]!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum OmadaDeviceStatus {
    ONLINE
    OFFLINE
    UNKNOWN
    PROVISIONING
  }

  enum OmadaSecurityType {
    OPEN
    WPA2
    WPA3
  }

  # ============================================================================
  # MARKETPLACE CATALOG
  # ============================================================================

  type Publisher {
    id: ID!
    name: String!
    displayName: String!
    description: String
    websiteUrl: String
    logoUrl: String
    verified: Boolean!
    metadata: JSON!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type Product {
    id: ID!
    name: String!
    slug: String!
    category: ProductCategory!
    description: String
    shortDescription: String
    publisher: Publisher!
    status: ProductStatus!
    featured: Boolean!
    iconUrl: String
    documentationUrl: String
    supportUrl: String
    metadata: JSON!
    tags: [String!]!
    versions: [ProductVersion!]!
    pricing: PricingModel
    averageRating: Float
    reviewCount: Int
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum ProductCategory {
    COMPUTE
    NETWORK_INFRA
    BLOCKCHAIN_STACK
    BLOCKCHAIN_TOOLS
    FINANCIAL_MESSAGING
    INTERNET_REGISTRY
    AI_LLM_AGENT
  }

  enum ProductStatus {
    DRAFT
    PUBLISHED
    ARCHIVED
    DEPRECATED
  }

  type ProductVersion {
    id: ID!
    productId: ID!
    version: String!
    changelog: String
    templateId: ID
    status: ProductVersionStatus!
    isLatest: Boolean!
    releasedAt: DateTime
    metadata: JSON!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum ProductVersionStatus {
    DRAFT
    PUBLISHED
    DEPRECATED
  }

  type PricingModel {
    id: ID!
    productId: ID!
    productVersionId: ID
    pricingType: PricingType!
    basePrice: Float
    currency: String!
    billingPeriod: BillingPeriod
    usageRates: JSON
    metadata: JSON!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum PricingType {
    FREE
    ONE_TIME
    SUBSCRIPTION
    USAGE_BASED
    HYBRID
  }

  enum BillingPeriod {
    HOURLY
    DAILY
    MONTHLY
    YEARLY
  }

  type ProductReview {
    id: ID!
    productId: ID!
    userId: ID!
    rating: Int!
    title: String
    reviewText: String
    verifiedPurchase: Boolean!
    helpfulCount: Int!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  input ProductFilter {
    category: ProductCategory
    status: ProductStatus
    publisherId: ID
    tags: [String!]
    featured: Boolean
    search: String
    limit: Int
    offset: Int
  }

  input CreatePublisherInput {
    name: String!
    displayName: String!
    description: String
    websiteUrl: String
    logoUrl: String
    metadata: JSON
  }

  input CreateProductInput {
    name: String!
    slug: String!
    category: ProductCategory!
    description: String
    shortDescription: String
    publisherId: ID!
    status: ProductStatus
    featured: Boolean
    iconUrl: String
    documentationUrl: String
    supportUrl: String
    metadata: JSON
    tags: [String!]
  }

  input UpdateProductInput {
    name: String
    description: String
    shortDescription: String
    status: ProductStatus
    featured: Boolean
    iconUrl: String
    documentationUrl: String
    supportUrl: String
    metadata: JSON
    tags: [String!]
  }

  input CreateProductVersionInput {
    productId: ID!
    version: String!
    changelog: String
    templateId: ID
    status: ProductVersionStatus
    releasedAt: DateTime
    metadata: JSON
  }

  input CreatePricingModelInput {
    productId: ID!
    productVersionId: ID
    pricingType: PricingType!
    basePrice: Float
    currency: String
    billingPeriod: BillingPeriod
    usageRates: JSON
    metadata: JSON
  }

  input CreateProductReviewInput {
    productId: ID!
    rating: Int!
    title: String
    reviewText: String
    verifiedPurchase: Boolean
  }

  # ============================================================================
  # TEMPLATES
  # ============================================================================

  type Template {
    id: ID!
    name: String!
    slug: String!
    description: String
    templateType: TemplateType!
    version: String!
    content: String!
    parameters: JSON!
    outputs: JSON!
    metadata: JSON!
    status: TemplateStatus!
    createdBy: ID
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum TemplateType {
    TERRAFORM
    HELM
    ANSIBLE
    PTF
    KUBERNETES
  }

  enum TemplateStatus {
    DRAFT
    PUBLISHED
    DEPRECATED
  }

  type TemplateVersion {
    id: ID!
    templateId: ID!
    version: String!
    content: String!
    parameters: JSON!
    outputs: JSON!
    changelog: String
    isLatest: Boolean!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  input TemplateFilter {
    templateType: TemplateType
    status: TemplateStatus
    search: String
    limit: Int
    offset: Int
  }

  input CreateTemplateInput {
    name: String!
    slug: String!
    description: String
    templateType: TemplateType!
    version: String!
    content: String!
    parameters: JSON
    outputs: JSON
    metadata: JSON
    status: TemplateStatus
  }

  input UpdateTemplateInput {
    name: String
    description: String
    content: String
    parameters: JSON
    outputs: JSON
    metadata: JSON
    status: TemplateStatus
  }

  input CreateTemplateVersionInput {
    templateId: ID!
    version: String!
    content: String!
    parameters: JSON
    outputs: JSON
    changelog: String
  }

  # ============================================================================
  # DEPLOYMENTS
  # ============================================================================

  type Deployment {
    id: ID!
    name: String!
    productId: ID
    productVersionId: ID
    templateId: ID
    templateVersionId: ID
    tenantId: ID!
    region: String
    status: DeploymentStatus!
    deploymentType: DeploymentType!
    parameters: JSON!
    renderedContent: String
    terraformState: JSON
    outputs: JSON!
    errorMessage: String
    createdBy: ID
    startedAt: DateTime
    completedAt: DateTime
    createdAt: DateTime!
    updatedAt: DateTime!
    logs: [DeploymentLog!]!
  }

  enum DeploymentStatus {
    PENDING
    PROVISIONING
    DEPLOYING
    RUNNING
    UPDATING
    STOPPED
    FAILED
    DELETING
    DELETED
  }

  enum DeploymentType {
    TERRAFORM
    HELM
    ANSIBLE
    KUBERNETES
    HYBRID
  }

  type DeploymentLog {
    id: ID!
    deploymentId: ID!
    level: LogLevel!
    message: String!
    metadata: JSON!
    createdAt: DateTime!
  }

  enum LogLevel {
    DEBUG
    INFO
    WARN
    ERROR
  }

  input DeploymentFilter {
    status: DeploymentStatus
    region: String
    limit: Int
    offset: Int
  }

  input CreateDeploymentInput {
    name: String!
    productId: ID
    productVersionId: ID
    templateId: ID
    templateVersionId: ID
    region: String
    deploymentType: DeploymentType!
    parameters: JSON!
    tags: JSON
  }

  # ============================================================================
  # BLOCKCHAIN NETWORKS
  # ============================================================================

  type BlockchainNetwork {
    id: ID!
    name: String!
    framework: BlockchainFramework!
    deploymentId: ID
    networkId: String
    status: String!
    configuration: JSON!
    metadata: JSON!
    nodes: [BlockchainNode!]!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum BlockchainFramework {
    HYPERLEDGER_FABRIC
    HYPERLEDGER_BESU
    HYPERLEDGER_INDY
    HYPERLEDGER_FIREFLY
    CACTI
  }

  type BlockchainNode {
    id: ID!
    networkId: ID!
    name: String!
    role: BlockchainNodeRole!
    nodeType: String
    endpointUrl: String
    rpcEndpoint: String
    grpcEndpoint: String
    websocketEndpoint: String
    status: String!
    configuration: JSON!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum BlockchainNodeRole {
    PEER
    ORDERER
    VALIDATOR
    ENDORSER
    CA
    IDENTITY_NODE
    FIREFLY_NODE
    CACTI_NODE
  }

  input CreateBlockchainNetworkInput {
    name: String!
    framework: BlockchainFramework!
    region: String
    configuration: BlockchainNetworkConfiguration!
  }

  input BlockchainNetworkConfiguration {
    nodeRoles: [BlockchainNodeRoleConfig!]!
    ledgerStorage: String
    consensus: String
    permissioning: JSON
  }

  input BlockchainNodeRoleConfig {
    role: BlockchainNodeRole!
    count: Int!
  }

  input CreateBlockchainNodeInput {
    name: String!
    role: BlockchainNodeRole!
    nodeType: String
    configuration: JSON
  }

  # ============================================================================
  # POP MAPPINGS & TUNNELS
  # ============================================================================

  type PoPMapping {
    id: ID!
    popId: String!
    popLocation: PoPLocation!
    primaryDatacenterId: ID!
    regionId: ID!
    tunnelConfigurations: [TunnelConfiguration!]!
    routingRules: RoutingRules!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type PoPLocation {
    city: String!
    country: String!
    coordinates: Coordinates!
    popId: String!
  }

  type Coordinates {
    lat: Float!
    lng: Float!
  }

  type TunnelConfiguration {
    tunnelId: String!
    popId: String!
    targetDatacenterId: ID!
    tunnelType: TunnelType!
    healthStatus: TunnelHealthStatus!
    endpoint: String
    healthCheck: HealthCheckConfig
  }

  enum TunnelType {
    PRIMARY
    BACKUP
    LOAD_BALANCED
  }

  enum TunnelHealthStatus {
    HEALTHY
    DEGRADED
    DOWN
  }

  type HealthCheckConfig {
    endpoint: String!
    interval: Int!
    timeout: Int!
    failureThreshold: Int!
  }

  type RoutingRules {
    latencyThreshold: Int!
    failoverThreshold: Int!
    loadBalancing: LoadBalancingAlgorithm!
    failoverEnabled: Boolean!
  }

  enum LoadBalancingAlgorithm {
    ROUND_ROBIN
    LEAST_CONNECTIONS
    GEOGRAPHIC
  }

  input PoPLocationInput {
    city: String!
    country: String!
    coordinates: CoordinatesInput!
    popId: String!
  }

  input CoordinatesInput {
    lat: Float!
    lng: Float!
  }

  # ============================================================================
  # SOVEREIGNTY ZONES & FEDERATION
  # ============================================================================

  type SovereigntyZone {
    id: ID!
    name: String!
    country: String!
    region: String!
    regulatoryFrameworks: [String!]!
    dataResidency: DataResidencyConfig!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  type DataResidencyConfig {
    required: Boolean!
    allowedRegions: [String!]!
    prohibitedRegions: [String!]!
  }

  type DataResidencyRule {
    id: ID!
    dataType: String!
    sourceRegion: String!
    allowedRegions: [String!]!
    prohibitedRegions: [String!]!
    encryptionRequired: Boolean!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  input CreateSovereigntyZoneInput {
    name: String!
    country: String!
    region: String!
    regulatoryFrameworks: [String!]
    dataResidency: DataResidencyConfigInput!
  }

  input DataResidencyConfigInput {
    required: Boolean!
    allowedRegions: [String!]!
    prohibitedRegions: [String!]!
  }

  input CreateDataResidencyRuleInput {
    dataType: String!
    sourceRegion: String!
    allowedRegions: [String!]!
    prohibitedRegions: [String!]!
    encryptionRequired: Boolean!
  }

  # ============================================================================
  # WELL-ARCHITECTED FRAMEWORK & INDUSTRY
  # ============================================================================

  type IndustryControl {
    id: ID!
    industry: IndustryType!
    pillar: String!
    controlCode: String!
    name: String!
    description: String
    complianceFrameworks: [String!]!
    requirements: [String!]!
  }

  enum IndustryType {
    FINANCIAL
    TELECOMMUNICATIONS
    HEALTHCARE
    GOVERNMENT
    MANUFACTURING
    RETAIL
    EDUCATION
  }

  type WAFAssessment {
    id: ID!
    resourceId: ID!
    industry: IndustryType!
    pillarScores: JSON!
    findings: [WAFFinding!]!
    risks: [WAFRisk!]!
    recommendations: [WAFRecommendation!]!
    assessedAt: DateTime!
  }

  type WAFFinding {
    id: ID!
    controlId: ID!
    resourceId: ID!
    status: FindingStatus!
    severity: Severity!
    message: String!
    recommendation: String!
  }

  enum FindingStatus {
    PASS
    FAIL
    WARNING
  }

  type WAFRisk {
    id: ID!
    resourceId: ID!
    pillar: String!
    severity: Severity!
    title: String!
    description: String!
    mitigation: String!
  }

  type WAFRecommendation {
    id: ID!
    resourceId: ID!
    pillar: String!
    priority: Priority!
    title: String!
    description: String!
    impact: String!
    effort: Effort!
  }

  enum Priority {
    LOW
    MEDIUM
    HIGH
  }

  enum Effort {
    LOW
    MEDIUM
    HIGH
  }

  # ============================================================================
  # TEST ENVIRONMENTS
  # ============================================================================

  type TestEnvironment {
    id: ID!
    name: String!
    userId: ID!
    tenantId: ID
    region: String!
    status: TestEnvironmentStatus!
    resources: TestEnvironmentResources!
    expiresAt: DateTime
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum TestEnvironmentStatus {
    RUNNING
    STOPPED
    PROVISIONING
    ERROR
    DELETING
  }

  type TestEnvironmentResources {
    vms: Int!
    storage: String!
    network: String!
  }

  input CreateTestEnvironmentInput {
    name: String!
    region: String!
    resources: TestEnvironmentResourcesInput
    expiresAt: DateTime
  }

  input UpdateTestEnvironmentInput {
    name: String
    region: String
    resources: TestEnvironmentResourcesInput
    expiresAt: DateTime
  }

  input TestEnvironmentResourcesInput {
    vms: Int
    storage: String
    network: String
  }

  # ============================================================================
  # COMMUNITY FORUM
  # ============================================================================

  type ForumCategory {
    id: ID!
    name: String!
    description: String
    slug: String!
    postCount: Int!
    lastPostAt: DateTime
    createdAt: DateTime!
  }

  type ForumPost {
    id: ID!
    categoryId: ID!
    category: ForumCategory!
    authorId: ID!
    author: User!
    title: String!
    content: String!
    views: Int!
    replyCount: Int!
    isPinned: Boolean!
    isLocked: Boolean!
    lastReplyAt: DateTime
    createdAt: DateTime!
    updatedAt: DateTime!
    replies: [ForumReply!]!
  }

  type ForumReply {
    id: ID!
    postId: ID!
    post: ForumPost!
    authorId: ID!
    author: User!
    content: String!
    isSolution: Boolean!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  input ForumPostFilter {
    categoryId: ID
    authorId: ID
    search: String
    limit: Int
    offset: Int
  }

  input CreateForumPostInput {
    categoryId: ID!
    title: String!
    content: String!
  }

  input UpdateForumPostInput {
    title: String
    content: String
  }

  input CreateForumReplyInput {
    postId: ID!
    content: String!
  }

  input UpdateForumReplyInput {
    content: String!
  }

  # ============================================================================
  # API MARKETPLACE
  # ============================================================================

  type APIMarketplaceListing {
    id: ID!
    name: String!
    description: String!
    provider: String!
    endpoint: String!
    documentationUrl: String
    category: APICategory!
    pricing: APIPricing!
    rating: Float!
    reviewCount: Int!
    requestCount: Int!
    status: APIListingStatus!
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum APICategory {
    PAYMENT
    MESSAGING
    DATA
    AUTHENTICATION
    ANALYTICS
    STORAGE
    COMPUTE
    OTHER
  }

  type APIPricing {
    model: APIPricingModel!
    basePrice: Float
    perRequestPrice: Float
    freeTier: APIFreeTier
  }

  enum APIPricingModel {
    FREE
    PAY_PER_USE
    SUBSCRIPTION
    TIERED
  }

  type APIFreeTier {
    requestsPerMonth: Int!
    features: [String!]!
  }

  enum APIListingStatus {
    ACTIVE
    INACTIVE
    PENDING
    DEPRECATED
  }

  type APISubscription {
    id: ID!
    listingId: ID!
    listing: APIMarketplaceListing!
    userId: ID!
    status: APISubscriptionStatus!
    apiKey: String
    createdAt: DateTime!
    updatedAt: DateTime!
  }

  enum APISubscriptionStatus {
    ACTIVE
    SUSPENDED
    CANCELLED
  }

  input APIMarketplaceFilter {
    category: APICategory
    search: String
    status: APIListingStatus
    limit: Int
    offset: Int
  }

  input CreateAPIMarketplaceListingInput {
    name: String!
    description: String!
    provider: String!
    endpoint: String!
    documentationUrl: String
    category: APICategory!
    pricing: APIPricingInput!
  }

  input APIPricingInput {
    model: APIPricingModel!
    basePrice: Float
    perRequestPrice: Float
    freeTier: APIFreeTierInput
  }

  input APIFreeTierInput {
    requestsPerMonth: Int!
    features: [String!]!
  }

  input UpdateAPIMarketplaceListingInput {
    name: String
    description: String
    status: APIListingStatus
    pricing: APIPricingInput
  }

  # ============================================================================
  # ANALYTICS
  # ============================================================================

  type AnalyticsRevenue {
    total: Float!
    currency: String!
    byPeriod: [AnalyticsPeriod!]!
    byService: [AnalyticsServiceRevenue!]!
    growth: Float!
  }

  type AnalyticsPeriod {
    period: String!
    revenue: Float!
  }

  type AnalyticsServiceRevenue {
    service: String!
    revenue: Float!
    percentage: Float!
  }

  type AnalyticsUsers {
    total: Int!
    active: Int!
    new: Int!
    byPeriod: [AnalyticsUserPeriod!]!
    growth: Float!
  }

  type AnalyticsUserPeriod {
    period: String!
    count: Int!
  }

  type AnalyticsAPIUsage {
    totalRequests: Int!
    byEndpoint: [AnalyticsEndpointUsage!]!
    byPeriod: [AnalyticsPeriodUsage!]!
    errorRate: Float!
  }

  type AnalyticsEndpointUsage {
    endpoint: String!
    requests: Int!
    errors: Int!
  }

  type AnalyticsPeriodUsage {
    period: String!
    requests: Int!
    errors: Int!
  }

  type AnalyticsGrowth {
    revenue: Float!
    users: Float!
    apiUsage: Float!
    period: String!
  }

  # ============================================================================
  # INFRASTRUCTURE DOCUMENTATION
  # ============================================================================

  type Country {
    name: String!
    region: String!
    relationshipType: String!
    priority: String!
    cloudflareCoverage: Boolean!
    networkInfrastructurePriority: String!
    notes: String
    coordinates: Coordinates
  }

  type NetworkTopology {
    id: ID!
    nodes: [TopologyNode!]!
    edges: [TopologyEdge!]!
    region: String!
    entity: String!
    lastUpdated: DateTime!
  }

  type TopologyNode {
    id: ID!
    type: String!
    label: String!
    region: String!
    entity: String!
    position: NodePosition!
    metadata: JSON!
  }

  type NodePosition {
    x: Float!
    y: Float!
  }

  type TopologyEdge {
    id: ID!
    source: String!
    target: String!
    type: String!
    metadata: JSON!
  }

  type ComplianceRequirement {
    country: String!
    region: String!
    frameworks: [String!]!
    status: String!
    requirements: [String!]!
    lastAuditDate: DateTime
    notes: String
  }

  type DeploymentMilestone {
    id: ID!
    title: String!
    region: String!
    entity: String!
    priority: String!
    startDate: DateTime!
    endDate: DateTime!
    status: String!
    dependencies: [String!]
    cost: Float
    description: String
  }

  type CostEstimate {
    region: String!
    entity: String!
    category: String!
    monthly: Float!
    annual: Float!
    breakdown: CostBreakdown!
    currency: String
    lastUpdated: DateTime
  }

  type CostBreakdown {
    compute: Float
    storage: Float
    network: Float
    licenses: Float
    personnel: Float
  }

  type InfrastructureSummary {
    totalCountries: Int!
    totalRegions: Int!
    totalCost: Float!
    deploymentProgress: DeploymentProgress!
  }

  type DeploymentProgress {
    planned: Int!
    inProgress: Int!
    complete: Int!
    blocked: Int!
  }

  input CountryFilter {
    region: String
    priority: String
    relationshipType: String
  }

  input TopologyFilter {
    region: String
    entity: String
  }

  input ComplianceFilter {
    country: String
    region: String
    status: String
    framework: String
  }

  input MilestoneFilter {
    region: String
    entity: String
    priority: String
    status: String
  }

  input CostEstimateFilter {
    region: String
    entity: String
    category: String
  }

  input UpdateTopologyInput {
    nodes: [TopologyNodeInput!]
    edges: [TopologyEdgeInput!]
  }

  input TopologyNodeInput {
    id: ID!
    type: String!
    label: String!
    region: String!
    entity: String!
    position: NodePositionInput!
    metadata: JSON
  }

  input NodePositionInput {
    x: Float!
    y: Float!
  }

  input TopologyEdgeInput {
    id: ID!
    source: String!
    target: String!
    type: String!
    metadata: JSON
  }

  input CreateMilestoneInput {
    title: String!
    region: String!
    entity: String!
    priority: String!
    startDate: DateTime!
    endDate: DateTime!
    status: String
    dependencies: [String!]
    cost: Float
    description: String
  }

  input UpdateMilestoneInput {
    title: String
    region: String
    entity: String
    priority: String
    startDate: DateTime
    endDate: DateTime
    status: String
    dependencies: [String!]
    cost: Float
    description: String
  }

  input UpdateComplianceInput {
    frameworks: [String!]
    status: String
    requirements: [String!]
    lastAuditDate: DateTime
    notes: String
  }

  input UpdateCostEstimateInput {
    monthly: Float
    annual: Float
    breakdown: CostBreakdownInput
    currency: String
  }

  input CostBreakdownInput {
    compute: Float
    storage: Float
    network: Float
    licenses: Float
    personnel: Float
  }
`

