{
  "title": "hub.submission.1",
  "description": "Defines a version 1 submission message payload",
  "type": "object",
  "properties": {
    "message": {
      "type": "object",
      "properties": {
        "version": {
          "type": "integer",
          "exclusiveMinimum": 0,
          "description": "Payload version; if omitted, treated as 1"
        },
        "id": {
          "type": "string",
          "format": "uuid",
          "description": "Unique message id (e.g. for correlating responses via relatedId)"
        },
        "relatedId": {
          "type": "string",
          "format": "uuid",
          "description": "Id of a message this message responds to or relates to, when applicable"
        },
        "applicationId": {
          "type": "string",
          "description": "Publishing module application id"
        },
        "dateTime": {
          "type": "string",
          "format": "date-time",
          "description": "Message timestamp (ISO 8601, UTC)"
        }
      },
      "required": [
        "id",
        "applicationId",
        "dateTime"
      ]
    },
    "submission": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique submission id for this revision"
        },
        "revision": {
          "type": "number",
          "description": "Revision number, typically major.minor (e.g. 1.0)"
        },
        "entityReference": {
          "type": "string",
          "description": "Reference/id of the supervised entity this submission belongs to"
        },
        "reportingDate": {
          "type": "string",
          "format": "date",
          "description": "Reporting end date (yyyy-MM-dd); omit if not applicable"
        },
        "status": {
          "type": "string",
          "description": "Submission lifecycle or processing status (e.g. Submitted)"
        },
        "modules": {
          "type": "array",
          "uniqueItems": true,
          "description": "Modules (forms/templates) that apply; items must be unique within the array",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Module id (e.g. corep_le_ind)"
              },
              "version": {
                "type": "string",
                "description": "Module version (ideally major.minor)"
              },
              "dataCollection": {
                "type": "object",
                "description": "Optional data-collection grouping for this module entry",
                "properties": {
                  "id": {
                    "type": "string",
                    "description": "Data collection id (e.g. std-eu-ebaxbrl)"
                  },
                  "version": {
                    "type": "string",
                    "description": "Data collection version when applicable"
                  }
                },
                "required": [
                  "id"
                ]
              }
            },
            "required": [
              "id",
              "version"
            ]
          }
        },
        "tags": {
          "type": "array",
          "uniqueItems": true,
          "description": "Optional qualifying tags (e.g. periodicity); omit or empty if none",
          "items": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "Tag identifier (e.g. Periodicity)"
              },
              "optionId": {
                "type": "string",
                "description": "Selected option for the tag (e.g. Annual)"
              }
            },
            "required": [
              "id",
              "optionId"
            ]
          }
        },
        "files": {
          "type": "array",
          "description": "Optional file references (data, schema, mapping, etc.); omit or empty if none",
          "items": {
            "type": "object",
            "properties": {
              "module": {
                "type": "object",
                "description": "Module this file belongs to (id and version)",
                "properties": {
                  "id": {
                    "type": "string"
                  },
                  "version": {
                    "type": "string"
                  }
                },
                "required": [
                  "id",
                  "version"
                ]
              },
              "type": {
                "type": "string",
                "description": "File kind relative to the submission (e.g. data, data-schema, data-mapping, other)"
              },
              "uri": {
                "type": "string",
                "description": "URI to the file (platform storage s3/gs, https, or file scheme)"
              }
            },
            "required": [
              "module",
              "type",
              "uri"
            ]
          }
        }
      },
      "required": [
        "id",
        "revision",
        "entityReference",
        "status",
        "modules"
      ]
    }
  },
  "required": [
    "message",
    "submission"
  ]
}
