{
  "$id": "/schemas/workout-export-v1.schema.json",
  "title": "Workout — export json_v1 (1.0.0)",
  "description": "Portabilidade (LGPD art. 18, V): todos os dados do titular. Ids internos não saem; `ref` liga seções dentro do arquivo.",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "schemaVersion": {
      "type": "string",
      "const": "1.0.0"
    },
    "exportedAt": {
      "$ref": "#/$defs/Timestamp"
    },
    "generator": {
      "type": "object",
      "properties": {
        "app": {
          "type": "string",
          "const": "workout"
        },
        "version": {
          "type": "string"
        }
      },
      "required": ["app", "version"],
      "additionalProperties": false
    },
    "subject": {
      "type": "object",
      "properties": {
        "ref": {
          "$ref": "#/$defs/Ref"
        },
        "locale": {
          "type": "string"
        },
        "timezone": {
          "type": "string"
        },
        "units": {
          "type": "string"
        }
      },
      "required": ["ref", "locale", "timezone", "units"],
      "additionalProperties": false
    },
    "sections": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "profile": {
      "type": "object",
      "properties": {
        "displayName": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "email": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "birthDate": {
          "anyOf": [
            {
              "$ref": "#/$defs/Date"
            },
            {
              "type": "null"
            }
          ]
        },
        "biologicalSex": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "locale": {
          "type": "string"
        },
        "timezone": {
          "type": "string"
        },
        "settings": {
          "type": "object",
          "propertyNames": {
            "type": "string"
          },
          "additionalProperties": {}
        }
      },
      "required": ["displayName", "email", "birthDate", "biologicalSex", "locale", "timezone", "settings"],
      "additionalProperties": false
    },
    "exercisesCustom": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "clientRef": {
            "$ref": "#/$defs/Ref"
          },
          "name": {
            "type": "string"
          },
          "measureType": {
            "type": "string"
          },
          "isUnilateral": {
            "type": "boolean"
          },
          "defaultRestSeconds": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "muscles": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "role": {
                  "type": "string"
                }
              },
              "required": ["name", "role"],
              "additionalProperties": false
            }
          },
          "equipment": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "clientRef",
          "name",
          "measureType",
          "isUnilateral",
          "defaultRestSeconds",
          "muscles",
          "equipment"
        ],
        "additionalProperties": false
      }
    },
    "programs": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ref": {
            "$ref": "#/$defs/Ref"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "goal": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "status": {
            "type": "string"
          },
          "validFrom": {
            "anyOf": [
              {
                "$ref": "#/$defs/Date"
              },
              {
                "type": "null"
              }
            ]
          },
          "validUntil": {
            "anyOf": [
              {
                "$ref": "#/$defs/Date"
              },
              {
                "type": "null"
              }
            ]
          },
          "renewedFromRef": {
            "anyOf": [
              {
                "$ref": "#/$defs/Ref"
              },
              {
                "type": "null"
              }
            ]
          },
          "versions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "number": {
                  "type": "number"
                },
                "status": {
                  "type": "string"
                },
                "changeKind": {
                  "type": "string"
                },
                "publishedAt": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/Timestamp"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "prescribedBy": {
                  "anyOf": [
                    {
                      "$ref": "#/$defs/PersonSnapshot"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "days": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "ref": {
                        "$ref": "#/$defs/Ref"
                      },
                      "position": {
                        "type": "number"
                      },
                      "label": {
                        "type": "string"
                      },
                      "name": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "weekday": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "notes": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "exercises": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "slotKey": {
                              "type": "string",
                              "format": "uuid",
                              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                            },
                            "position": {
                              "type": "number"
                            },
                            "exercise": {
                              "$ref": "#/$defs/ExerciseRef"
                            },
                            "supersetGroup": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "restSeconds": {
                              "anyOf": [
                                {
                                  "type": "number"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "tempo": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "notes": {
                              "anyOf": [
                                {
                                  "type": "string"
                                },
                                {
                                  "type": "null"
                                }
                              ]
                            },
                            "sets": {
                              "type": "array",
                              "items": {
                                "$ref": "#/$defs/ProgramSet"
                              }
                            }
                          },
                          "required": [
                            "slotKey",
                            "position",
                            "exercise",
                            "supersetGroup",
                            "restSeconds",
                            "tempo",
                            "notes",
                            "sets"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": ["ref", "position", "label", "name", "weekday", "notes", "exercises"],
                    "additionalProperties": false
                  }
                }
              },
              "required": ["number", "status", "changeKind", "publishedAt", "prescribedBy", "days"],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "ref",
          "name",
          "description",
          "goal",
          "status",
          "validFrom",
          "validUntil",
          "renewedFromRef",
          "versions"
        ],
        "additionalProperties": false
      }
    },
    "sessions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ref": {
            "$ref": "#/$defs/Ref"
          },
          "kind": {
            "type": "string"
          },
          "programRef": {
            "anyOf": [
              {
                "$ref": "#/$defs/Ref"
              },
              {
                "type": "null"
              }
            ]
          },
          "programDayRef": {
            "anyOf": [
              {
                "$ref": "#/$defs/Ref"
              },
              {
                "type": "null"
              }
            ]
          },
          "source": {
            "type": "string",
            "enum": ["app", "import"]
          },
          "title": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "startedAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "finishedAt": {
            "anyOf": [
              {
                "$ref": "#/$defs/Timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "finishReason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "rating": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "sessionRpe": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "bodyweightKg": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "summary": {
            "type": "object",
            "properties": {
              "durationSec": {
                "anyOf": [
                  {
                    "type": "number"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "volumeKg": {
                "type": "number"
              },
              "setCount": {
                "type": "number"
              },
              "reps": {
                "type": "number"
              }
            },
            "required": ["durationSec", "volumeKg", "setCount", "reps"],
            "additionalProperties": false
          },
          "exercises": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "slotKey": {
                  "type": "string",
                  "format": "uuid",
                  "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
                },
                "position": {
                  "type": "number"
                },
                "exercise": {
                  "$ref": "#/$defs/ExerciseRef"
                },
                "supersetGroup": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "notes": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "sets": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "position": {
                        "type": "number"
                      },
                      "setType": {
                        "type": "string"
                      },
                      "measureType": {
                        "type": "string"
                      },
                      "weightKg": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "weightInput": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "weightUnit": {
                        "type": "string"
                      },
                      "reps": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "rpe": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "rir": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "durationSec": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "distanceM": {
                        "anyOf": [
                          {
                            "type": "number"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "completedAt": {
                        "anyOf": [
                          {
                            "$ref": "#/$defs/Timestamp"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "notes": {
                        "anyOf": [
                          {
                            "type": "string"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      }
                    },
                    "required": [
                      "position",
                      "setType",
                      "measureType",
                      "weightKg",
                      "weightInput",
                      "weightUnit",
                      "reps",
                      "rpe",
                      "rir",
                      "durationSec",
                      "distanceM",
                      "completedAt",
                      "notes"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": ["slotKey", "position", "exercise", "supersetGroup", "notes", "sets"],
              "additionalProperties": false
            }
          },
          "comments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "authorNameSnapshot": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "body": {
                  "type": "string"
                },
                "createdAt": {
                  "$ref": "#/$defs/Timestamp"
                }
              },
              "required": ["authorNameSnapshot", "body", "createdAt"],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "ref",
          "kind",
          "programRef",
          "programDayRef",
          "source",
          "title",
          "startedAt",
          "finishedAt",
          "finishReason",
          "notes",
          "rating",
          "sessionRpe",
          "bodyweightKg",
          "summary",
          "exercises",
          "comments"
        ],
        "additionalProperties": false
      }
    },
    "personalRecords": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "exercise": {
            "$ref": "#/$defs/ExerciseRef"
          },
          "type": {
            "type": "string"
          },
          "value": {
            "type": "number"
          },
          "weightKg": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "reps": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "achievedAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "isCurrent": {
            "type": "boolean"
          },
          "sessionRef": {
            "anyOf": [
              {
                "$ref": "#/$defs/Ref"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "exercise",
          "type",
          "value",
          "weightKg",
          "reps",
          "achievedAt",
          "isCurrent",
          "sessionRef"
        ],
        "additionalProperties": false
      }
    },
    "measurements": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "measuredAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "metric": {
            "type": "string"
          },
          "value": {
            "type": "number"
          },
          "source": {
            "type": "string"
          },
          "assessmentRef": {
            "anyOf": [
              {
                "$ref": "#/$defs/Ref"
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": ["measuredAt", "metric", "value", "source", "assessmentRef", "notes"],
        "additionalProperties": false
      }
    },
    "assessments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ref": {
            "$ref": "#/$defs/Ref"
          },
          "kind": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "assessedAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "finalizedAt": {
            "anyOf": [
              {
                "$ref": "#/$defs/Timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "nextDueOn": {
            "anyOf": [
              {
                "$ref": "#/$defs/Date"
              },
              {
                "type": "null"
              }
            ]
          },
          "assessedBy": {
            "$ref": "#/$defs/PersonSnapshot"
          },
          "bodyFatPct": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "notes": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "anamnesis": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          },
          "skinfolds": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          },
          "bioimpedance": {
            "anyOf": [
              {
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {}
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "ref",
          "kind",
          "status",
          "assessedAt",
          "finalizedAt",
          "nextDueOn",
          "assessedBy",
          "bodyFatPct",
          "notes",
          "anamnesis",
          "skinfolds",
          "bioimpedance"
        ],
        "additionalProperties": false
      }
    },
    "health": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "injuries": {
              "type": "array",
              "items": {}
            },
            "restrictions": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "conditions": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "medications": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "emergencyContact": {
              "type": "object",
              "properties": {
                "name": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "phone": {
                  "anyOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": ["name", "phone"],
              "additionalProperties": false
            },
            "notes": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            },
            "updatedAt": {
              "$ref": "#/$defs/Timestamp"
            }
          },
          "required": [
            "injuries",
            "restrictions",
            "conditions",
            "medications",
            "emergencyContact",
            "notes",
            "updatedAt"
          ],
          "additionalProperties": false
        },
        {
          "type": "null"
        }
      ]
    },
    "photos": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "takenAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "pose": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "contentType": {
            "type": "string"
          },
          "width": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "height": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ]
          },
          "sha256": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "assessmentRef": {
            "anyOf": [
              {
                "$ref": "#/$defs/Ref"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": ["takenAt", "pose", "contentType", "width", "height", "sha256", "assessmentRef"],
        "additionalProperties": false
      },
      "description": "só os metadados; os arquivos das fotos não vão no JSON"
    },
    "checkins": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "occurredAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "gym": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  }
                },
                "required": ["name"],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "method": {
            "type": "string"
          },
          "sessionRef": {
            "anyOf": [
              {
                "$ref": "#/$defs/Ref"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": ["occurredAt", "gym", "method", "sessionRef"],
        "additionalProperties": false
      }
    },
    "exerciseMappings": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "source": {
            "type": "string"
          },
          "externalName": {
            "type": "string"
          },
          "exercise": {
            "$ref": "#/$defs/ExerciseRef"
          }
        },
        "required": ["source", "externalName", "exercise"],
        "additionalProperties": false
      }
    },
    "programProgress": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "programRef": {
            "anyOf": [
              {
                "$ref": "#/$defs/Ref"
              },
              {
                "type": "null"
              }
            ]
          },
          "slotKey": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
          },
          "exercise": {
            "$ref": "#/$defs/ExerciseRef"
          },
          "lastSets": {},
          "suggestedSets": {},
          "lastPerformedAt": {
            "anyOf": [
              {
                "$ref": "#/$defs/Timestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": ["programRef", "slotKey", "exercise", "lastSets", "suggestedSets", "lastPerformedAt"],
        "additionalProperties": false
      }
    },
    "consents": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "grantedAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "revokedAt": {
            "anyOf": [
              {
                "$ref": "#/$defs/Timestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": ["type", "version", "grantedAt", "revokedAt"],
        "additionalProperties": false
      }
    },
    "grants": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "grantee": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string"
              },
              "nameSnapshot": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "cref": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": ["type", "nameSnapshot", "cref"],
            "additionalProperties": false
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grantedAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "expiresAt": {
            "anyOf": [
              {
                "$ref": "#/$defs/Timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "revokedAt": {
            "anyOf": [
              {
                "$ref": "#/$defs/Timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "revokeReason": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "consentVersion": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "sensitiveConsentAt": {
            "anyOf": [
              {
                "$ref": "#/$defs/Timestamp"
              },
              {
                "type": "null"
              }
            ]
          },
          "historyFrom": {
            "anyOf": [
              {
                "$ref": "#/$defs/Timestamp"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "grantee",
          "scopes",
          "grantedAt",
          "expiresAt",
          "revokedAt",
          "revokeReason",
          "consentVersion",
          "sensitiveConsentAt",
          "historyFrom"
        ],
        "additionalProperties": false
      }
    },
    "accessLog": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "occurredAt": {
            "$ref": "#/$defs/Timestamp"
          },
          "actor": {
            "type": "object",
            "properties": {
              "nameSnapshot": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "via": {
                "type": "string"
              },
              "gymNameSnapshot": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              }
            },
            "required": ["nameSnapshot", "via", "gymNameSnapshot"],
            "additionalProperties": false
          },
          "scope": {
            "type": "string"
          },
          "action": {
            "type": "string"
          },
          "resourceType": {
            "type": "string"
          }
        },
        "required": ["occurredAt", "actor", "scope", "action", "resourceType"],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "schemaVersion",
    "exportedAt",
    "generator",
    "subject",
    "sections",
    "profile",
    "exercisesCustom",
    "programs",
    "sessions",
    "personalRecords",
    "measurements",
    "assessments",
    "health",
    "photos",
    "checkins",
    "exerciseMappings",
    "programProgress",
    "consents",
    "grants",
    "accessLog"
  ],
  "additionalProperties": false,
  "$defs": {
    "Timestamp": {
      "type": "string",
      "description": "ISO 8601, UTC"
    },
    "Ref": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
      "description": "referência local a este arquivo; não é o id interno"
    },
    "Date": {
      "type": "string",
      "description": "YYYY-MM-DD"
    },
    "PersonSnapshot": {
      "type": "object",
      "properties": {
        "nameSnapshot": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "cref": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": ["nameSnapshot", "cref"],
      "additionalProperties": false
    },
    "ExerciseRef": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "wger"
            },
            "wgerUuid": {
              "type": "string",
              "format": "uuid",
              "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
            },
            "name": {
              "type": "string"
            }
          },
          "required": ["kind", "wgerUuid", "name"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "custom"
            },
            "clientRef": {
              "$ref": "#/$defs/Ref"
            },
            "name": {
              "type": "string"
            }
          },
          "required": ["kind", "clientRef", "name"],
          "additionalProperties": false,
          "description": "definição em exercisesCustom"
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "type": "string",
              "const": "snapshot"
            },
            "name": {
              "type": "string"
            },
            "measureType": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ]
            }
          },
          "required": ["kind", "name", "measureType"],
          "additionalProperties": false,
          "description": "exercício de terceiro: vai só o nome, não a definição"
        }
      ]
    },
    "ProgramSet": {
      "type": "object",
      "properties": {
        "position": {
          "type": "number"
        },
        "setType": {
          "type": "string"
        },
        "targetRepsMin": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "targetRepsMax": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "targetWeightKg": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "targetWeightPct1rm": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "targetRpe": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "targetRir": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "targetDurationSec": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "targetDistanceM": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "restSecondsOverride": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "position",
        "setType",
        "targetRepsMin",
        "targetRepsMax",
        "targetWeightKg",
        "targetWeightPct1rm",
        "targetRpe",
        "targetRir",
        "targetDurationSec",
        "targetDistanceM",
        "restSecondsOverride"
      ],
      "additionalProperties": false
    }
  }
}
