{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://retirementwealth.com.au/api/v2/schema/series.json",
  "title": "Series of external observations",
  "description": "The shape of registry/series.json: dated observations of statistical series published by someone else (the Australian Bureau of Statistics' price indexes, population estimates and retirement survey estimates, the Department of Social Services' count of Age Pension recipients and the Reserve Bank of Australia's cash rate target), kept apart from the figures in figures.json. A quarterly series has one observation per quarter: an index series (unit index_number, with a reference base and the movements the publisher prints) or a count series (unit persons). A financial_year series has one observation for each financial year a survey was run (the ABS retirement survey, every two years), a count in persons. An irregular series has one per change, each dated. A quarter's value that a later release revised keeps the earlier value in revisions, with the release it came from. scripts/validate-registry.mjs checks the file against this schema and then runs the checks a schema cannot express: for a quarterly series, consecutive quarters and, where the publisher prints movements, the movement between each pair of index numbers against the percentage change it printed; for an irregular series, dates strictly increasing and each change equal to the difference between the values; for both, sourced and dated observations and the fields its frequency needs; and against the base branch, that no observation is removed and no value changes without a revision. See docs/series.md.",
  "type": "object",
  "required": [
    "note",
    "last_reviewed",
    "series"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "note": {
      "$ref": "#/$defs/text"
    },
    "last_reviewed": {
      "$ref": "#/$defs/date"
    },
    "series": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/$defs/series"
      }
    }
  },
  "$defs": {
    "date": {
      "description": "A calendar date, YYYY-MM-DD.",
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    },
    "quarter": {
      "description": "A calendar quarter, YYYY-Qn: 2026-Q2 is April to June 2026, which the publisher calls the June 2026 quarter.",
      "type": "string",
      "pattern": "^[0-9]{4}-Q[1-4]$"
    },
    "financial_year": {
      "description": "An Australian financial year, YYYY-YY: 2024-25 is July 2024 to June 2025. The validator requires the second year to follow the first.",
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}$"
    },
    "id": {
      "description": "A permanent identifier in snake_case. Never reused or changed once published.",
      "type": "string",
      "pattern": "^[a-z0-9]+(_[a-z0-9]+)*$"
    },
    "text": {
      "type": "string",
      "minLength": 1
    },
    "https_url": {
      "type": "string",
      "pattern": "^https://"
    },
    "source": {
      "description": "The publisher's release or page the current values were read from, in the shape the figures registry uses for a source.",
      "type": "object",
      "required": [
        "title",
        "publisher",
        "url",
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "title": {
          "$ref": "#/$defs/text"
        },
        "publisher": {
          "$ref": "#/$defs/text"
        },
        "url": {
          "$ref": "#/$defs/https_url"
        },
        "type": {
          "enum": [
            "primary"
          ]
        }
      }
    },
    "licence": {
      "description": "The licence or terms under which the publisher permits reuse, where its statement was seen, and the attribution wording the publisher asks for. kind is creative_commons for a Creative Commons Attribution licence and publisher_terms for a publisher's own terms of use that permit reuse with attribution; the validator requires conditions for publisher_terms.",
      "type": "object",
      "required": [
        "kind",
        "name",
        "short_name",
        "url",
        "statement",
        "statement_url",
        "mark",
        "attribution_format",
        "attribution_format_url",
        "attribution",
        "checked_on"
      ],
      "additionalProperties": false,
      "properties": {
        "kind": {
          "enum": [
            "creative_commons",
            "publisher_terms"
          ]
        },
        "name": {
          "$ref": "#/$defs/text"
        },
        "short_name": {
          "$ref": "#/$defs/text"
        },
        "url": {
          "$ref": "#/$defs/https_url"
        },
        "statement": {
          "description": "The licence statement or the permission as the publisher's site gives it.",
          "$ref": "#/$defs/text"
        },
        "statement_url": {
          "$ref": "#/$defs/https_url"
        },
        "mark": {
          "description": "Where the licence mark or the link to the terms was seen on each page used.",
          "$ref": "#/$defs/text"
        },
        "attribution_format": {
          "description": "The citation or attribution format the publisher asks for, as published.",
          "$ref": "#/$defs/text"
        },
        "attribution_format_url": {
          "$ref": "#/$defs/https_url"
        },
        "attribution": {
          "description": "That format filled in for this series: the attribution to show wherever the series is used.",
          "$ref": "#/$defs/text"
        },
        "conditions": {
          "description": "For publisher_terms: the conditions the publisher's terms attach to the permission, in plain words, so that every use of the series can be checked against them.",
          "$ref": "#/$defs/text"
        },
        "checked_on": {
          "$ref": "#/$defs/date"
        }
      }
    },
    "table": {
      "description": "The published table (a time series workbook) the values were read from or checked against.",
      "type": "object",
      "required": [
        "title",
        "file",
        "sheet",
        "url",
        "columns"
      ],
      "additionalProperties": false,
      "properties": {
        "title": {
          "$ref": "#/$defs/text"
        },
        "file": {
          "$ref": "#/$defs/text"
        },
        "sheet": {
          "$ref": "#/$defs/text"
        },
        "url": {
          "$ref": "#/$defs/https_url"
        },
        "columns": {
          "description": "Which columns hold the values and the changes, by series ID, and anything else needed to read the table.",
          "$ref": "#/$defs/text"
        }
      }
    },
    "api": {
      "description": "The request to the publisher's data API that returns the same values. A quarterly series needs it.",
      "type": "object",
      "required": [
        "url",
        "dataflow",
        "key",
        "key_meaning",
        "format"
      ],
      "additionalProperties": false,
      "properties": {
        "url": {
          "$ref": "#/$defs/https_url"
        },
        "dataflow": {
          "$ref": "#/$defs/text"
        },
        "key": {
          "$ref": "#/$defs/text"
        },
        "key_meaning": {
          "$ref": "#/$defs/text"
        },
        "movement_url": {
          "description": "The request for the published percentage changes. Needed where the publisher prints movements.",
          "$ref": "#/$defs/https_url"
        },
        "format": {
          "$ref": "#/$defs/text"
        }
      }
    },
    "page": {
      "description": "The publisher's web page the values were read from, and how its table is laid out. An irregular series needs this or an API.",
      "type": "object",
      "required": [
        "url",
        "format"
      ],
      "additionalProperties": false,
      "properties": {
        "url": {
          "$ref": "#/$defs/https_url"
        },
        "format": {
          "$ref": "#/$defs/text"
        }
      }
    },
    "dataset": {
      "description": "A publisher's open data set with one file for each period (the Department of Social Services' quarterly demographics on data.gov.au): the data set's page, the request to the portal's API that lists its files, and how the file for a period is named and read. A quarterly series needs this or an API.",
      "type": "object",
      "required": [
        "url",
        "api_url",
        "format"
      ],
      "additionalProperties": false,
      "properties": {
        "url": {
          "$ref": "#/$defs/https_url"
        },
        "api_url": {
          "$ref": "#/$defs/https_url"
        },
        "format": {
          "$ref": "#/$defs/text"
        }
      }
    },
    "retrieval": {
      "description": "Where the values are read from: the published table, and the API, page or data set a new observation is read from. A quarterly series needs api or dataset; an irregular series page or api; a financial_year survey series has its table alone (the ABS publishes the survey's tables as files on the release page, with no Data API dataflow).",
      "type": "object",
      "required": [
        "table"
      ],
      "additionalProperties": false,
      "properties": {
        "table": {
          "$ref": "#/$defs/table"
        },
        "api": {
          "$ref": "#/$defs/api"
        },
        "page": {
          "$ref": "#/$defs/page"
        },
        "dataset": {
          "$ref": "#/$defs/dataset"
        }
      }
    },
    "release_calendar": {
      "description": "The publisher's page that lists future releases or decision dates, and when it was last read.",
      "type": "object",
      "required": [
        "url",
        "checked_on"
      ],
      "additionalProperties": false,
      "properties": {
        "url": {
          "$ref": "#/$defs/https_url"
        },
        "checked_on": {
          "$ref": "#/$defs/date"
        }
      }
    },
    "next_release": {
      "description": "The next release or decision that can add an observation: its title and date from the publisher's calendar, and for a quarterly or financial_year series the period it adds. estimated is true where the publisher gives no calendar or no date and the date follows its pattern of earlier releases (the DSS data set; the ABS retirement survey); the pages say so.",
      "type": "object",
      "required": [
        "title",
        "date"
      ],
      "additionalProperties": false,
      "properties": {
        "period": {
          "anyOf": [
            {
              "$ref": "#/$defs/quarter"
            },
            {
              "$ref": "#/$defs/financial_year"
            }
          ]
        },
        "title": {
          "$ref": "#/$defs/text"
        },
        "date": {
          "$ref": "#/$defs/date"
        },
        "estimated": {
          "type": "boolean"
        }
      }
    },
    "latest_decision": {
      "description": "Irregular series only: the publisher's latest decision or announcement, whether or not it changed the value, so a reader can see the value was confirmed on that date. When it changed the value it is also the last observation's release.",
      "type": "object",
      "required": [
        "date",
        "value",
        "change",
        "title",
        "url"
      ],
      "additionalProperties": false,
      "properties": {
        "date": {
          "$ref": "#/$defs/date"
        },
        "value": {
          "type": "number"
        },
        "change": {
          "type": "number"
        },
        "title": {
          "$ref": "#/$defs/text"
        },
        "url": {
          "$ref": "#/$defs/https_url"
        }
      }
    },
    "release": {
      "description": "The publisher's release, statement or decision an observation was read from.",
      "type": "object",
      "required": [
        "title",
        "date",
        "url"
      ],
      "additionalProperties": false,
      "properties": {
        "title": {
          "$ref": "#/$defs/text"
        },
        "date": {
          "$ref": "#/$defs/date"
        },
        "url": {
          "$ref": "#/$defs/https_url"
        }
      }
    },
    "revision": {
      "description": "An earlier published value of the same quarter, kept when a later release revised it: the value, the release (the vintage) it came from, when it was read, and the date this file replaced it with the later value.",
      "type": "object",
      "required": [
        "value",
        "release",
        "retrieved_on",
        "replaced_on"
      ],
      "additionalProperties": false,
      "properties": {
        "value": {
          "type": "number"
        },
        "release": {
          "$ref": "#/$defs/release"
        },
        "retrieved_on": {
          "$ref": "#/$defs/date"
        },
        "replaced_on": {
          "$ref": "#/$defs/date"
        }
      }
    },
    "quarterly_observation": {
      "description": "One quarter's value as published, with where it was read from and when. change_pct is the percentage change from the previous quarter as the publisher prints it, to one decimal place; a series whose publisher prints no movements (movements_published false) has none. status is the publisher's revision status for the quarter where it gives one (the ABS marks population estimates preliminary, revised or final); as_at is the date the count is as at where the publisher gives one; revisions keeps each earlier published value of the quarter, oldest first, with the release it came from.",
      "type": "object",
      "required": [
        "period",
        "value",
        "source_url",
        "retrieved_on",
        "release"
      ],
      "additionalProperties": false,
      "properties": {
        "period": {
          "$ref": "#/$defs/quarter"
        },
        "value": {
          "type": "number"
        },
        "change_pct": {
          "type": "number"
        },
        "source_url": {
          "$ref": "#/$defs/https_url"
        },
        "retrieved_on": {
          "$ref": "#/$defs/date"
        },
        "release": {
          "$ref": "#/$defs/release"
        },
        "status": {
          "enum": [
            "preliminary",
            "revised",
            "final"
          ]
        },
        "as_at": {
          "$ref": "#/$defs/date"
        },
        "revisions": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/revision"
          }
        }
      }
    },
    "financial_year_observation": {
      "description": "One survey's estimate for a financial year, as published, with where it was read from and when: period (the survey's reference period), value (in the series' unit, persons), rse (the publisher's relative standard error for the estimate, per cent, as published), and, where the series says so, year_of_retirement (the calendar year the estimate is for in the publisher's table). revisions keeps each earlier published value, as for a quarterly observation.",
      "type": "object",
      "required": [
        "period",
        "value",
        "source_url",
        "retrieved_on",
        "release"
      ],
      "additionalProperties": false,
      "properties": {
        "period": {
          "$ref": "#/$defs/financial_year"
        },
        "value": {
          "type": "number"
        },
        "rse": {
          "type": "number",
          "minimum": 0
        },
        "year_of_retirement": {
          "type": "integer",
          "minimum": 1900
        },
        "source_url": {
          "$ref": "#/$defs/https_url"
        },
        "retrieved_on": {
          "$ref": "#/$defs/date"
        },
        "release": {
          "$ref": "#/$defs/release"
        },
        "revisions": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/revision"
          }
        }
      }
    },
    "dated_observation": {
      "description": "One change in an irregular series: the new value from the date it took effect, the change from the value before it in the series' unit as the publisher prints it, where it was read from and when, and the publisher's decision or statement it came from.",
      "type": "object",
      "required": [
        "date",
        "value",
        "change",
        "source_url",
        "retrieved_on",
        "release"
      ],
      "additionalProperties": false,
      "properties": {
        "date": {
          "$ref": "#/$defs/date"
        },
        "value": {
          "type": "number"
        },
        "change": {
          "type": "number"
        },
        "source_url": {
          "$ref": "#/$defs/https_url"
        },
        "retrieved_on": {
          "$ref": "#/$defs/date"
        },
        "release": {
          "$ref": "#/$defs/release"
        }
      }
    },
    "observation": {
      "description": "A quarterly observation (period, and change_pct where the publisher prints movements), a financial-year one (period as YYYY-YY) or a dated one (date, change). The validator requires every observation of a series to match its frequency.",
      "anyOf": [
        {
          "$ref": "#/$defs/quarterly_observation"
        },
        {
          "$ref": "#/$defs/financial_year_observation"
        },
        {
          "$ref": "#/$defs/dated_observation"
        }
      ]
    },
    "series": {
      "type": "object",
      "required": [
        "id",
        "label",
        "title",
        "publisher",
        "publication",
        "licence",
        "source",
        "frequency",
        "unit",
        "decimals",
        "from",
        "retrieval",
        "release_calendar",
        "next_release",
        "notes",
        "observations"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "$ref": "#/$defs/id"
        },
        "label": {
          "description": "A short name for a control or a column, such as CPI.",
          "$ref": "#/$defs/text"
        },
        "title": {
          "description": "The series in full, as the publisher describes it.",
          "$ref": "#/$defs/text"
        },
        "publisher": {
          "$ref": "#/$defs/text"
        },
        "publication": {
          "description": "The publisher's release series or page, such as Consumer Price Index, Australia.",
          "$ref": "#/$defs/text"
        },
        "catalogue_number": {
          "description": "The publisher's catalogue or table number. A quarterly index series needs it.",
          "$ref": "#/$defs/text"
        },
        "licence": {
          "$ref": "#/$defs/licence"
        },
        "source": {
          "$ref": "#/$defs/source"
        },
        "series_id": {
          "description": "The publisher's identifier for the value series. A quarterly index series needs it.",
          "$ref": "#/$defs/text"
        },
        "movement_series_id": {
          "description": "The publisher's identifier for the change series. A quarterly index series needs it.",
          "$ref": "#/$defs/text"
        },
        "movements_published": {
          "description": "Quarterly and financial_year series: whether the publisher prints a percentage change from the previous observation beside each value. Absent means it does (the ABS index series). When false, observations carry no change_pct and the validator does not check movements (the count series: DSS and the ABS publish no quarterly movements for them; the ABS prints no movement between its retirement surveys).",
          "type": "boolean"
        },
        "aggregation": {
          "description": "A series whose values are a sum of components the publisher prints (the population at an age and over, summed from the ABS single-year-of-age estimates): the rule, so the sum can be worked out again from the publisher's table or API. Nothing else in a series is worked out here.",
          "type": "object",
          "required": [
            "method",
            "of",
            "components"
          ],
          "additionalProperties": false,
          "properties": {
            "method": {
              "enum": [
                "sum"
              ]
            },
            "of": {
              "description": "What is summed, in plain words.",
              "$ref": "#/$defs/text"
            },
            "components": {
              "description": "The publisher's identifiers or codes of the components summed.",
              "$ref": "#/$defs/text"
            }
          }
        },
        "reference_base": {
          "description": "Index series: the period in which the index equals 100, as the publisher states it. A quarterly index series needs it.",
          "$ref": "#/$defs/text"
        },
        "reference_base_source_url": {
          "$ref": "#/$defs/https_url"
        },
        "reference_base_from": {
          "description": "The first quarter published on the current reference base, where the publisher re-referenced the series.",
          "$ref": "#/$defs/quarter"
        },
        "methodology_url": {
          "description": "The publisher's methodology page for the release the values come from.",
          "$ref": "#/$defs/https_url"
        },
        "frequency": {
          "description": "quarterly: one observation per quarter. financial_year: one observation for each financial year the publisher's survey was run (not every year: the ABS retirement survey is two-yearly). irregular: one observation per change, each dated.",
          "enum": [
            "quarterly",
            "financial_year",
            "irregular"
          ]
        },
        "unit": {
          "description": "index_number: a quarterly index series. persons: a count of people (quarterly or financial_year). percent: the irregular cash rate target.",
          "enum": [
            "index_number",
            "persons",
            "percent"
          ]
        },
        "decimals": {
          "description": "How many decimal places the publisher prints the values to.",
          "type": "integer",
          "minimum": 0
        },
        "from": {
          "description": "The first quarter, financial year or date recorded. Equals the first observation's period or date.",
          "anyOf": [
            {
              "$ref": "#/$defs/quarter"
            },
            {
              "$ref": "#/$defs/financial_year"
            },
            {
              "$ref": "#/$defs/date"
            }
          ]
        },
        "retrieval": {
          "$ref": "#/$defs/retrieval"
        },
        "release_calendar": {
          "$ref": "#/$defs/release_calendar"
        },
        "next_release": {
          "$ref": "#/$defs/next_release"
        },
        "latest_decision": {
          "$ref": "#/$defs/latest_decision"
        },
        "notes": {
          "$ref": "#/$defs/text"
        },
        "observations": {
          "type": "array",
          "minItems": 2,
          "items": {
            "$ref": "#/$defs/observation"
          }
        }
      }
    }
  }
}
