{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/assetlab-ca/json-schema/assetlab-ca-infrastructure-asset-schema.json",
  "title": "InfrastructureAsset",
  "description": "An infrastructure feature — segment (LineString) or node (Point). Geometry is\nreturned as GeoJSON in EPSG:4326. `length_m`, `slope_pct`, and `risk_score`\nare computed server-side.\n",
  "x-generated": "2026-11-01",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/assetlab-ca-openapi.yaml#/components/schemas/InfrastructureAsset",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "tenant_id": {
      "type": "string"
    },
    "network_id": {
      "type": "string",
      "format": "uuid"
    },
    "feature_type": {
      "type": "string",
      "enum": [
        "segment",
        "node"
      ]
    },
    "geometry": {
      "$ref": "#/$defs/GeoJsonGeometry"
    },
    "length_m": {
      "type": [
        "number",
        "null"
      ],
      "description": "Server-computed for segments"
    },
    "name": {
      "type": [
        "string",
        "null"
      ]
    },
    "feature_code": {
      "type": [
        "string",
        "null"
      ],
      "description": "Human-readable Feature ID, unique per tenant"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "external_ids": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true
    },
    "from_street": {
      "type": [
        "string",
        "null"
      ]
    },
    "to_street": {
      "type": [
        "string",
        "null"
      ]
    },
    "image_url": {
      "type": [
        "string",
        "null"
      ]
    },
    "qr_code": {
      "type": [
        "string",
        "null"
      ]
    },
    "from_feature_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "to_feature_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "flow_direction": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "with_geometry",
        "against_geometry"
      ]
    },
    "split_from_feature_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "asset_type_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "manufacturer_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "system_class_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "system_group_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "system_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "model": {
      "type": [
        "string",
        "null"
      ]
    },
    "serial_number": {
      "type": [
        "string",
        "null"
      ]
    },
    "site_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "building_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "location_id": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "status_id": {
      "type": [
        "string",
        "null"
      ]
    },
    "condition_score": {
      "type": [
        "number",
        "null"
      ]
    },
    "last_maintenance_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "risk_factor": {
      "type": [
        "string",
        "null"
      ]
    },
    "consequence_of_failure_score": {
      "type": [
        "number",
        "null"
      ]
    },
    "likelihood_of_failure_score": {
      "type": [
        "number",
        "null"
      ]
    },
    "risk_score": {
      "type": [
        "number",
        "null"
      ],
      "description": "Server-computed"
    },
    "safety_impact": {
      "type": [
        "string",
        "null"
      ]
    },
    "service_impact": {
      "type": [
        "string",
        "null"
      ]
    },
    "environmental_impact": {
      "type": [
        "string",
        "null"
      ]
    },
    "financial_impact": {
      "type": [
        "number",
        "null"
      ],
      "description": "Estimated cost of a failure. Money in the organization's currency - GET /v1/organization-settings for currency_code"
    },
    "regulatory_impact": {
      "type": [
        "string",
        "null"
      ]
    },
    "reputation_impact": {
      "type": [
        "string",
        "null"
      ]
    },
    "purchase_cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "Money in the organization's currency - GET /v1/organization-settings for currency_code"
    },
    "purchase_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "install_date": {
      "type": [
        "string",
        "null"
      ],
      "format": "date"
    },
    "expected_lifetime_years": {
      "type": [
        "number",
        "null"
      ]
    },
    "salvage_value": {
      "type": [
        "number",
        "null"
      ],
      "description": "Money in the organization's currency - GET /v1/organization-settings for currency_code"
    },
    "salvage_value_percentage": {
      "type": [
        "number",
        "null"
      ]
    },
    "quantity": {
      "type": [
        "number",
        "null"
      ]
    },
    "unit_of_measure": {
      "type": [
        "string",
        "null"
      ]
    },
    "unit_replacement_value": {
      "type": [
        "number",
        "null"
      ],
      "description": "Money in the organization's currency - GET /v1/organization-settings for currency_code"
    },
    "purchase_cost_calculation_method": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "manual",
        "calculated_sqft",
        "calculated_unit"
      ]
    },
    "material": {
      "type": [
        "string",
        "null"
      ]
    },
    "diameter_mm": {
      "type": [
        "number",
        "null"
      ]
    },
    "width_m": {
      "type": [
        "number",
        "null"
      ]
    },
    "lanes": {
      "type": [
        "integer",
        "null"
      ]
    },
    "road_class": {
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1,
      "maximum": 6,
      "description": "O. Reg. 239/02 road class. Classes 1-2 are arterial, 3-4 collector, 5-6 local."
    },
    "depth_m": {
      "type": [
        "number",
        "null"
      ]
    },
    "from_invert_m": {
      "type": [
        "number",
        "null"
      ]
    },
    "to_invert_m": {
      "type": [
        "number",
        "null"
      ]
    },
    "slope_pct": {
      "type": [
        "number",
        "null"
      ],
      "description": "Server-computed for segments"
    },
    "positional_accuracy_class": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "survey_grade",
        "mapping_grade",
        "sketch",
        "unknown"
      ]
    },
    "data_source": {
      "type": [
        "string",
        "null"
      ]
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "deleted_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    }
  },
  "$defs": {
    "GeoJsonGeometry": {
      "oneOf": [
        {
          "$ref": "#/$defs/GeoJsonPoint"
        },
        {
          "$ref": "#/$defs/GeoJsonLineString"
        }
      ]
    },
    "GeoJsonLineString": {
      "type": "object",
      "required": [
        "type",
        "coordinates"
      ],
      "description": "GeoJSON LineString in EPSG:4326. Each coordinate is [longitude, latitude]; minimum 2 points.",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "LineString"
          ]
        },
        "coordinates": {
          "type": "array",
          "minItems": 2,
          "items": {
            "type": "array",
            "minItems": 2,
            "maxItems": 2,
            "items": {
              "type": "number"
            }
          }
        }
      }
    },
    "GeoJsonPoint": {
      "type": "object",
      "required": [
        "type",
        "coordinates"
      ],
      "description": "GeoJSON Point in EPSG:4326. Coordinates are [longitude, latitude].",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "Point"
          ]
        },
        "coordinates": {
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": {
            "type": "number"
          }
        }
      }
    }
  }
}