{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fuzkk.uz/schemas/ocm/fuzkk-ocm-asset-v1.schema.json",
  "title": "FUZKK OCM Asset v1",
  "type": "object",
  "required": [
    "schema",
    "messageId",
    "source",
    "exportedAt",
    "data"
  ],
  "properties": {
    "schema": {
      "const": "fuzkk.ocm.asset.v1"
    },
    "messageId": {
      "type": "string",
      "minLength": 1
    },
    "source": {
      "$ref": "#/$defs/source"
    },
    "exportedAt": {
      "type": "string",
      "format": "date-time"
    },
    "data": {
      "type": "object",
      "required": [
        "asset"
      ],
      "properties": {
        "asset": {
          "$ref": "#/$defs/asset"
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true,
  "$defs": {
    "source": {
      "type": "object",
      "required": [
        "system",
        "instance"
      ],
      "properties": {
        "system": {
          "type": "string",
          "minLength": 1
        },
        "instance": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": true
    },
    "samplingPoint": {
      "type": "object",
      "required": [
        "externalId"
      ],
      "properties": {
        "externalId": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string"
        },
        "fluidSystem": {
          "type": "string"
        },
        "tag": {
          "type": "string"
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "fluidSpecId": {
          "type": "string"
        },
        "baselineProfile": {
          "type": "string"
        },
        "currentBatch": {
          "type": "string"
        },
        "hoursSinceChange": {
          "type": [
            "number",
            "null"
          ]
        },
        "sampleIntervalDays": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1
        },
        "autoStartWorkflowDefinitionId": {
          "type": "string"
        },
        "autoStartWorkflowVersion": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1
        },
        "integrationProfileId": {
          "type": "string"
        },
        "autoStartEnabled": {
          "type": "boolean"
        },
        "monitoringRequirement": {
          "enum": [
            "required",
            "not_required",
            "pending_review"
          ]
        },
        "monitoringExemptionReason": {
          "type": "string"
        },
        "monitoringMode": {
          "enum": [
            "running",
            "event_driven"
          ]
        },
        "monitoringWorkflowDefinitionId": {
          "type": "string"
        },
        "monitoringWorkflowVersion": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1
        }
      },
      "additionalProperties": true
    },
    "component": {
      "type": "object",
      "required": [
        "externalId"
      ],
      "properties": {
        "externalId": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "samplingPoints": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/samplingPoint"
          }
        }
      },
      "additionalProperties": true
    },
    "asset": {
      "type": "object",
      "required": [
        "externalId"
      ],
      "properties": {
        "externalId": {
          "type": "string",
          "minLength": 1
        },
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "site": {
          "type": [
            "object",
            "null"
          ]
        },
        "manufacturer": {
          "type": [
            "string",
            "null"
          ]
        },
        "model": {
          "type": [
            "string",
            "null"
          ]
        },
        "serialNumber": {
          "type": [
            "string",
            "null"
          ]
        },
        "meters": {
          "type": [
            "object",
            "null"
          ]
        },
        "components": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/component"
          }
        },
        "enterpriseExternalId": {
          "type": "string"
        },
        "enterpriseName": {
          "type": "string"
        },
        "lifecycleState": {
          "enum": [
            "operational",
            "conserved"
          ]
        },
        "conservationReason": {
          "type": "string"
        },
        "conservedAtUtc": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time"
        },
        "reactivationReviewRequired": {
          "type": "boolean"
        }
      },
      "additionalProperties": true
    }
  }
}
