{
  "allOf": [
    {
      "$ref": "#/definitions/IDateRange"
    },
    {
      "type": "object",
      "properties": {
        "id": {
          "type": "number"
        },
        "safeName": {
          "type": "string"
        },
        "loadingOverrides": {
          "description": "Server-side loading overrides for components reading product template\nentries with a date window. Each part is independent and falls back to the\ntemplate's own configuration when unset; sent as the loadingType /\nstartAttribute / stopAttribute query params.",
          "$ref": "#/definitions/ITemplateLoadingOverrides"
        },
        "loadConf": {
          "type": "object",
          "properties": {
            "type": {
              "const": "Time",
              "type": "string"
            },
            "lead": {
              "type": "number"
            },
            "lag": {
              "type": "number"
            },
            "leadUnit": {
              "$ref": "#/definitions/DweenTimeUnit"
            },
            "lagUnit": {
              "$ref": "#/definitions/DweenTimeUnit"
            },
            "alignUnit": {
              "enum": [
                "CALENDAR_445",
                "DAYS",
                "HALFHOUR",
                "HOURS",
                "MILLIS",
                "MINUTES",
                "MONTHS",
                "SECONDS",
                "WEEKS",
                "YEARS"
              ],
              "type": "string"
            },
            "truncateStartUnit": {
              "description": "Snaps the *computed window start* down to this unit's boundary, after the lag has been\nsubtracted. Distinct from `alignUnit`, which truncates the reference time and so lands on the\nwindow's end: a 48-hour lag off an hour-aligned \"now\" starts mid-day, and `DAYS` here pulls it\nback to local midnight. Widens the window rather than shifting it. Default none/null.",
              "enum": [
                "DAYS",
                "HALFHOUR",
                "HOURS",
                "MILLIS",
                "MINUTES",
                "MONTHS",
                "SECONDS",
                "WEEKS",
                "YEARS"
              ],
              "type": "string"
            }
          },
          "required": ["alignUnit", "lag", "lagUnit", "leadUnit"]
        },
        "referenceTime": {
          "type": "string"
        },
        "batchLabelColumn": {
          "description": "Attribute whose value labels the X tick for a batch.",
          "type": "string"
        },
        "batchTimeColumn": {
          "description": "Temporal attribute the batches are ordered by, and the footer range is taken from.",
          "type": "string"
        },
        "groupingColumn": {
          "description": "Attribute offering the \"compare by product / variety / recipe\" filter pills.",
          "type": "string"
        },
        "quantityColumn": {
          "description": "Numeric attribute the per-quantity toggle divides by.",
          "type": "string"
        },
        "quantityUnit": {
          "description": "Unit of `quantityColumn`, e.g. \"t\", used to label normalised axes.",
          "type": "string"
        },
        "groups": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "title": {
                "type": "string"
              },
              "indicators": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "referenceName": {
                      "description": "Product-template attribute reference name. Must be LONG or DOUBLE.",
                      "type": "string"
                    },
                    "displayName": {
                      "description": "Overrides the attribute's own display name in the legend and pills.",
                      "type": "string"
                    },
                    "unit": {
                      "description": "Groups indicators onto shared y-axes, and labels the axis.",
                      "type": "string"
                    },
                    "traceType": {
                      "$ref": "#/definitions/BatchTraceType"
                    },
                    "color": {
                      "type": "string"
                    },
                    "target": {
                      "description": "Editor-entered, so constant across batches: renders as a flat reference line.",
                      "type": "number"
                    },
                    "specMin": {
                      "type": "number"
                    },
                    "specMax": {
                      "type": "number"
                    },
                    "decimalPlaces": {
                      "type": "number"
                    },
                    "selectedByDefault": {
                      "type": "boolean"
                    }
                  },
                  "required": ["referenceName", "traceType"]
                }
              }
            },
            "required": ["indicators", "title"]
          }
        },
        "batchCountOptions": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "defaultBatchCount": {
          "type": "number"
        },
        "filter": {
          "type": "string"
        },
        "hideLegend": {
          "type": "boolean"
        },
        "height": {
          "type": "number"
        },
        "width": {
          "type": "number"
        }
      },
      "required": [
        "batchLabelColumn",
        "batchTimeColumn",
        "groups",
        "id",
        "loadConf",
        "safeName"
      ]
    }
  ],
  "definitions": {
    "IDateRange": {
      "type": "object",
      "properties": {
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "instantFrom": {
          "$ref": "#/definitions/JSJoda.Instant"
        },
        "instantTo": {
          "$ref": "#/definitions/JSJoda.Instant"
        }
      }
    },
    "JSJoda.Instant": {
      "type": "object"
    },
    "ITemplateLoadingOverrides": {
      "description": "Server-side loading overrides for components reading product template\nentries with a date window. Each part is independent and falls back to the\ntemplate's own configuration when unset; sent as the loadingType /\nstartAttribute / stopAttribute query params.",
      "type": "object",
      "properties": {
        "loadingType": {
          "enum": [
            "EVERYTHING",
            "FIXED_PERIOD",
            "OVERLAP",
            "OVERLAP_OPEN_ENDED",
            "RANGE"
          ],
          "type": "string"
        },
        "startAttribute": {
          "description": "Temporal (DATETIME/INSTANT) attribute the window's start filters by.",
          "type": "string"
        },
        "stopAttribute": {
          "description": "Temporal (DATETIME/INSTANT) attribute the window's end filters by.",
          "type": "string"
        }
      }
    },
    "DweenTimeUnit": {
      "enum": [
        "DAYS",
        "HALFHOUR",
        "HOURS",
        "MILLIS",
        "MINUTES",
        "MONTHS",
        "SECONDS",
        "WEEKS",
        "YEARS"
      ],
      "type": "string"
    },
    "BatchTraceType": {
      "enum": ["BAR", "LINE"],
      "type": "string"
    }
  },
  "$schema": "http://json-schema.org/draft-07/schema#"
}
