{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://schema.nfh.global/EnergyResourceCommon/v1.0",
  "title": "EnergyResourceCommon",
  "description": "Canonical base schemas shared by all typed EnergyResource kinds. Contains EnergyResourceCommon (structural envelope: id, type, subResources, parentResources, attributes) and EnergyResourceCommonAttributes (attributes bag base: make, model, maxExportKw, maxImportKw, ratedPowerKw, telemetryProvider, commissioningDate, location).",
  "$defs": {
    "EnergyResourceCommonAttributes": {
      "$anchor": "EnergyResourceCommonAttributes",
      "type": "object",
      "additionalProperties": true,
      "description": "Dimensioning and provenance fields shared by all resource kinds. Inherited inside each kind's attributes bag via allOf. No field is required at this level.",
      "properties": {
        "make": { "type": "string", "description": "Manufacturer (free text)." },
        "model": { "type": "string", "description": "Model (free text)." },
        "ratedPowerKw": { "type": "number", "minimum": 0, "description": "Manufacturer-rated peak power in kW. Kept for backward compatibility. Prefer maxExportKw." },
        "maxExportKw": { "type": "number", "minimum": 0, "description": "Maximum power injected to the grid (generates / discharges), kW. Always ≥0. CIM: GeneratingUnit.maxOperatingP / PowerElectronicsConnection.maxP (injection)." },
        "maxImportKw": { "type": "number", "minimum": 0, "description": "Maximum power drawn from the grid (absorbs / charges), kW. Always ≥0. CIM: PowerElectronicsConnection.maxP (absorption)." },
        "telemetryProvider": { "type": "string", "description": "Vendor API / data source identifier for telemetry." },
        "commissioningDate": { "type": "string", "format": "date-time", "description": "ISO 8601 date-time the asset was commissioned." },
        "location": { "$ref": "https://schema.nfh.global/Location/v2.0/schema.json#/$defs/Location", "description": "Physical location of this asset." }
      }
    },
    "EnergyResourceCommon": {
      "$anchor": "EnergyResourceCommon",
      "type": "object",
      "additionalProperties": true,
      "description": "Structural envelope inherited by every typed EnergyResource kind via allOf. Defines id, type, topology (subResources, parentResources), and the attributes bag.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Stable identifier for this resource. For METER resources the meter serial number is conventional.",
          "example": "did:web:bescom.karnataka.gov.in:assets:meter:MET-001"
        },
        "type": {
          "type": "string",
          "description": "Asset class discriminator. Constrained to a kind-specific enum or const in each typed kind schema."
        },
        "subResources": {
          "type": "array",
          "description": "Topology — child resources. Each item is a bare id string or an inline EnergyResource object.",
          "items": {
            "oneOf": [
              { "type": "string", "minLength": 1 },
              { "$ref": "https://schema.nfh.global/EnergyResource/v2.0/attributes.yaml#/components/schemas/EnergyResource" }
            ]
          }
        },
        "parentResources": {
          "type": "array",
          "description": "Upward topology — ids of parent resources. String references only.",
          "items": { "type": "string", "minLength": 1 }
        },
        "attributes": {
          "type": "object",
          "additionalProperties": true,
          "description": "Attribute bag. Inherits EnergyResourceCommonAttributes via allOf plus kind-specific fields.",
          "allOf": [
            { "$ref": "#/$defs/EnergyResourceCommonAttributes" }
          ]
        }
      }
    }
  }
}
