{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://canpuff.org/schemas/v1/terpene.json",
  "title": "CanPUFF terpene v1",
  "type": "object",
  "properties": {
    "type": {
      "const": "terpene"
    },
    "version": {
      "const": 1
    },
    "id": {
      "$ref": "#/$defs/uuid"
    },
    "created": {
      "$ref": "#/$defs/timestamp"
    },
    "updated": {
      "$ref": "#/$defs/timestamp"
    },
    "ext": {
      "$ref": "#/$defs/ext"
    },
    "name": {
      "type": "string",
      "minLength": 1
    },
    "aroma": {
      "type": "string"
    },
    "commonEffects": {
      "type": "string"
    },
    "boilingPointC": {
      "type": "number"
    },
    "notes": {
      "type": "string"
    }
  },
  "required": [
    "type",
    "version",
    "id",
    "name"
  ],
  "$defs": {
    "uuid": {
      "type": "string",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    },
    "timestamp": {
      "type": "string",
      "format": "date-time",
      "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$",
      "description": "RFC 3339 with UTC offset (Z acceptable)"
    },
    "dateish": {
      "type": "string",
      "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])(T([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(\\.\\d+)?(Z|[+-]([01]\\d|2[0-3]):[0-5]\\d))?$",
      "description": "YYYY-MM-DD or RFC 3339 timestamp"
    },
    "hashref": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "grams": {
      "type": "number",
      "minimum": 0,
      "description": "grams, max 4 decimal places"
    },
    "percent": {
      "type": "number",
      "minimum": 0,
      "maximum": 100,
      "description": "percent by weight, max 2 decimal places"
    },
    "money": {
      "type": "number",
      "minimum": 0,
      "description": "max 2 decimal places"
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "rating5": {
      "type": "integer",
      "minimum": 0,
      "maximum": 5,
      "description": "0 = unrated"
    },
    "ext": {
      "type": "object",
      "propertyNames": {
        "pattern": "^[a-z0-9-]+$"
      },
      "additionalProperties": {
        "type": "object"
      }
    }
  }
}
