{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/getmyluna-app/json-schema/getmyluna-app-patterns-response-schema.json",
  "title": "PatternsResponse",
  "description": "Everything the dashboard renders. Solid-food blocks are empty until `flags.solids_started` is true.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/getmyluna-app-openapi.json#/components/schemas/PatternsResponse",
  "properties": {
    "patterns": {
      "additionalProperties": true,
      "type": "object",
      "title": "Patterns"
    },
    "daily_totals": {
      "items": {
        "additionalProperties": true,
        "type": "object"
      },
      "type": "array",
      "title": "Daily Totals"
    },
    "today": {
      "items": {
        "$ref": "#/$defs/Event"
      },
      "type": "array",
      "title": "Today"
    },
    "nutrients_7d": {
      "additionalProperties": true,
      "type": "object",
      "title": "Nutrients 7D"
    },
    "nutrients_today": {
      "additionalProperties": true,
      "type": "object",
      "title": "Nutrients Today"
    },
    "nutrient_targets": {
      "additionalProperties": true,
      "type": "object",
      "title": "Nutrient Targets"
    },
    "allergens_today": {
      "additionalProperties": true,
      "type": "object",
      "title": "Allergens Today"
    },
    "allergen_grid": {
      "additionalProperties": true,
      "type": "object",
      "title": "Allergen Grid"
    },
    "baby_name": {
      "type": "string",
      "title": "Baby Name"
    },
    "dob": {
      "type": "string",
      "title": "Dob",
      "description": "YYYY-MM-DD, or empty while the family is expecting."
    },
    "age_months": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "title": "Age Months"
    },
    "age_display": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Age Display"
    },
    "flags": {
      "additionalProperties": true,
      "type": "object",
      "title": "Flags"
    },
    "expecting": {
      "anyOf": [
        {
          "$ref": "#/$defs/Expecting"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "type": "object",
  "required": [
    "patterns",
    "daily_totals",
    "today",
    "nutrients_7d",
    "nutrients_today",
    "nutrient_targets",
    "allergens_today",
    "allergen_grid",
    "baby_name",
    "dob",
    "age_months",
    "age_display",
    "flags"
  ],
  "$defs": {
    "Event": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id",
          "description": "8-hex-char id, unique within the family."
        },
        "ts": {
          "type": "string",
          "title": "Ts",
          "description": "ISO 8601 local timestamp."
        },
        "type": {
          "type": "string",
          "enum": [
            "milk",
            "sleep",
            "wake",
            "nappy",
            "poop",
            "solid",
            "note",
            "supplement",
            "weight",
            "length"
          ],
          "title": "Type"
        },
        "author": {
          "type": "string",
          "title": "Author",
          "description": "Who logged it: the caregiver's first name, or `Family admin` / `Partner` until they've set one (`app`/`agent` for non-human). Never an email or username.",
          "default": "app"
        },
        "author_name": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Author Name",
          "description": "Same as `author` (display name)."
        },
        "author_is_me": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ],
          "title": "Author Is Me",
          "description": "Web session/token only: true when the current caregiver logged it."
        },
        "ml": {
          "anyOf": [
            {
              "type": "integer",
              "maximum": 500.0,
              "minimum": 0.0
            },
            {
              "type": "null"
            }
          ],
          "title": "Ml",
          "description": "`milk` only: millilitres (0 for a breastfeed)."
        },
        "kind": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Kind",
          "description": "`nappy`: wet|dirty|both|dry. `supplement`: vitd|iron|multivitamin."
        },
        "foods": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Foods",
          "description": "`solid` only: what was eaten."
        },
        "meal_type": {
          "anyOf": [
            {
              "type": "string",
              "enum": [
                "meal",
                "snack"
              ]
            },
            {
              "type": "null"
            }
          ],
          "title": "Meal Type",
          "description": "`solid` only."
        },
        "kg": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Kg",
          "description": "`weight` only."
        },
        "cm": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "title": "Cm",
          "description": "`length` only."
        },
        "ug": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Ug",
          "description": "`supplement` only: micrograms."
        },
        "note": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 300
            },
            {
              "type": "null"
            }
          ],
          "title": "Note"
        },
        "reactions": {
          "anyOf": [
            {
              "items": {
                "additionalProperties": true,
                "type": "object"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reactions",
          "description": "Emoji reactions from caregivers: `emoji`, `ts`, `user` (display name), `mine`."
        }
      },
      "type": "object",
      "required": [
        "id",
        "ts",
        "type"
      ],
      "title": "Event",
      "description": "One logged event. Fields beyond `id`/`ts`/`type`/`author` depend on `type`."
    },
    "Expecting": {
      "properties": {
        "due_date": {
          "type": "string",
          "title": "Due Date"
        },
        "days_until_due": {
          "type": "integer",
          "title": "Days Until Due",
          "description": "0 once the due date arrives."
        },
        "due_date_reached": {
          "type": "boolean",
          "title": "Due Date Reached"
        },
        "days_overdue": {
          "type": "integer",
          "title": "Days Overdue",
          "description": "Days since the due date while the birth isn't confirmed yet (0 before it). The family stays expecting until a caregiver confirms the arrival.",
          "default": 0
        }
      },
      "type": "object",
      "required": [
        "due_date",
        "days_until_due",
        "due_date_reached"
      ],
      "title": "Expecting",
      "description": "Set while the baby isn't born yet: there is no age and no age-based target."
    }
  }
}