{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openssom.org/schema/vocabulary-mapping.json",
  "title": "SSOM Vocabulary Mapping",
  "description": "A statement that a term used by one source means a registered term, with the evidence for it, how it was produced, whether it has been accepted, and by which decision.",
  "type": "object",
  "required": [
    "mapping_id",
    "ssom_version",
    "term_kind",
    "local_term",
    "target",
    "method",
    "evidence_refs",
    "confidence",
    "mapping_status",
    "comparability_scope",
    "mapping_package_id",
    "mapping_version",
    "valid_from",
    "provenance"
  ],
  "properties": {
    "mapping_id": {
      "type": "string",
      "pattern": "^urn:ssom:vocabulary-mapping:"
    },
    "ssom_version": {
      "type": "string"
    },
    "term_kind": {
      "type": "string",
      "enum": [
        "asset_class",
        "equipment_model",
        "signal_metric",
        "quantity_kind",
        "unit",
        "state",
        "attribute"
      ]
    },
    "local_term": {
      "type": "object",
      "required": [
        "scope",
        "value"
      ],
      "properties": {
        "scope": {
          "type": "object",
          "required": [
            "scope_type",
            "scope_value"
          ],
          "properties": {
            "scope_type": {
              "type": "string",
              "enum": [
                "company",
                "source_system",
                "vendor_product"
              ]
            },
            "scope_value": {
              "type": "string"
            }
          },
          "additionalProperties": false
        },
        "value": {
          "type": "string",
          "minLength": 1,
          "description": "The term exactly as the source uses it."
        },
        "record_refs": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The local records that carry the term."
        }
      },
      "additionalProperties": false
    },
    "target": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "target_state",
            "registry_id",
            "registry_version",
            "code"
          ],
          "properties": {
            "target_state": {
              "const": "registered_term"
            },
            "registry_id": {
              "type": "string"
            },
            "registry_version": {
              "type": "string"
            },
            "code": {
              "type": "string"
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": [
            "target_state",
            "proposed_code"
          ],
          "properties": {
            "target_state": {
              "const": "proposed_new_term"
            },
            "proposed_code": {
              "type": "string"
            },
            "proposed_registry_id": {
              "type": "string"
            },
            "external_references": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "scheme",
                  "identifier"
                ],
                "properties": {
                  "scheme": {
                    "type": "string"
                  },
                  "identifier": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              }
            }
          },
          "additionalProperties": false
        },
        {
          "type": "object",
          "required": [
            "target_state"
          ],
          "properties": {
            "target_state": {
              "const": "not_determined"
            }
          },
          "additionalProperties": false
        }
      ]
    },
    "mapping_relation": {
      "type": "string",
      "enum": [
        "exact",
        "close",
        "broader",
        "narrower"
      ],
      "description": "`narrower` means the local term is narrower than the registered term."
    },
    "method": {
      "type": "string",
      "enum": [
        "rule",
        "machine_suggestion",
        "person"
      ]
    },
    "rule_ref": {
      "type": "object",
      "required": [
        "rule_id",
        "rule_version"
      ],
      "properties": {
        "rule_id": {
          "type": "string"
        },
        "rule_version": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "value_transform": {
      "type": "object",
      "required": [
        "scale",
        "offset",
        "unit",
        "quantity_kind"
      ],
      "properties": {
        "scale": {
          "type": "number"
        },
        "offset": {
          "type": "number"
        },
        "unit": {
          "$ref": "common.json#/$defs/unitReference"
        },
        "quantity_kind": {
          "$ref": "common.json#/$defs/quantityKind"
        }
      },
      "additionalProperties": false,
      "description": "How a raw source value becomes a value in a governed unit: value * scale + offset."
    },
    "evidence_refs": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string"
      }
    },
    "confidence": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "mapping_status": {
      "type": "string",
      "enum": [
        "proposed",
        "accepted",
        "rejected",
        "superseded",
        "withdrawn"
      ]
    },
    "comparability_scope": {
      "type": "string",
      "enum": [
        "none",
        "within_company",
        "across_companies"
      ]
    },
    "decision_ref": {
      "type": "string",
      "pattern": "^urn:ssom:decision:"
    },
    "mapping_package_id": {
      "type": "string"
    },
    "mapping_version": {
      "type": "string"
    },
    "valid_from": {
      "type": "string",
      "format": "date-time",
      "description": "The event time from which readings may be read under this mapping. This is not the time the mapping was decided."
    },
    "valid_to": {
      "type": "string",
      "format": "date-time"
    },
    "supersedes_ref": {
      "type": "string",
      "pattern": "^urn:ssom:vocabulary-mapping:"
    },
    "superseded_by_ref": {
      "type": "string",
      "pattern": "^urn:ssom:vocabulary-mapping:"
    },
    "provenance": {
      "$ref": "common.json#/$defs/provenance"
    },
    "extensions": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": false
}
