{
	"$id": "collection.json",
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"type": "object",
	"required": ["schema"],
	"unevaluatedProperties": false,
	"properties": {
		"schema": {
			"$ref": "#/$defs/schema"
		},
		"filters": {
			"type": "array",
			"items": {
				"$ref": "#/$defs/condition"
			}
		},
		"pagination": {
			"$ref": "#/$defs/pagination"
		},
		"meta": {
			"type": "object"
		}
	},
	"allOf": [
		{
			"if": {
				"properties": {
					"schema": {
						"const": "activity-type"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/activityTypeOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "athlete"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/athleteOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "datasheet-entry"
					}
				}
			},
			"then": {
				"properties": {
					"context": {
						"$ref": "#/$defs/datasheetOrUriReference"
					},
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/datasheetEntryOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "equipment"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/equipmentOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "exercise"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/exerciseOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "label"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/labelOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "logbook-entry"
					}
				}
			},
			"then": {
				"properties": {
					"context": {
						"$ref": "#/$defs/logbookOrUriReference"
					},
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/logbookEntryOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "program"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/programOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "relative-intensity-unit"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/relativeIntensityUnitOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "relative-repeat-unit"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/relativeRepeatUnitOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "relative-resistance-unit"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/relativeResistanceUnitOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "session"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/sessionOrUriReference"
						}
					}
				}
			}
		},
		{
			"if": {
				"properties": {
					"schema": {
						"const": "workout"
					}
				}
			},
			"then": {
				"properties": {
					"items": {
						"type": "array",
						"items": {
							"$ref": "#/$defs/workoutOrUriReference"
						}
					}
				}
			}
		}
	],
	"$defs": {
		"activityTypeOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/activity-type.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"athleteOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/athlete.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"condition": {
			"type": "object",
			"required": ["columnName", "operator", "value"],
			"unevaluatedProperties": false,
			"properties": {
				"columnName": {
					"type": "string",
					"pattern": "^[a-z]{1}[a-zA-Z0-9]+$"
				},
				"operator": {
					"enum": ["=", "!=", "<", "<=", ">", ">=", "*=", "^=", "$="]
				},
				"value": {
					"type": ["string", "number", "boolean"]
				},
				"meta": {
					"type": "object"
				}
			}
		},
		"datasheetEntryOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/datasheet-entry.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"datasheetOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/datasheet.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"equipmentOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/equipment.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"exerciseOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/exercise.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"labelOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/label.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"logbookEntryOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/logbook-entry.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"logbookOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/logbook.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"pagination": {
			"type": "object",
			"required": ["limit", "offset", "total"],
			"unevaluatedProperties": false,
			"properties": {
				"limit": {
					"type": "integer",
					"minimum": 0
				},
				"offset": {
					"type": "integer",
					"minimum": 0
				},
				"total": {
					"type": "integer",
					"minimum": 0
				}
			}
		},
		"programOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/program.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"relativeIntensityUnitOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/relative-intensity-unit.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"relativeRepeatUnitOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/relative-repeat-unit.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"relativeResistanceUnitOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/relative-resistance-unit.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"schema": {
			"enum": ["activity-type", "athlete", "datasheet-entry", "equipment", "exercise", "label", "logbook-entry", "program", "relative-intensity-unit", "relative-repeat-unit", "relative-resistance-unit", "session", "workout"]
		},
		"sessionOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/session.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		},
		"uriReference": {
			"type": "string",
			"format": "uri-reference"
		},
		"workoutOrUriReference": {
			"anyOf": [
				{
					"$ref": "https://graph.movelapse.com/1.0/schemas/workout.json"
				},
				{
					"$ref": "#/$defs/uriReference"
				}
			]
		}
	}
}