{
	"$schema": "http://json-schema.org/draft-07/schema#",
	"$id": "https://raw.githubusercontent.com/qlik-oss/schemas/refs/heads/main/qtcp/task.sourceselection.schema.json",
	"title": "Task SourceSelection Configuration",
	"description": "Schema for task sourceSelection configuration",
	"type": "object",
	"properties": {
		"modifiedByAi": { "$ref": "#/$defs/ModifiedByAi" },
		"sourceConnection": {
			"type": "string",
			"description": "Source connection ID for landing tasks"
		},
		"rootDirectoryPath": {
			"type": "string",
			"description": "Root directory path for replicate landing tasks"
		},
		"includePatterns": {
			"type": "array",
			"description": "List of tables/views patterns to include from the source",
			"items": {
				"type": "object",
				"description": "Include pattern item",
				"properties": {
					"sourceProject": {
						"type": "string",
						"description": "source project (for cross-project datasets)"
					},
					"sourceTask": {
						"type": "string",
						"description": "source task",
						"examples": ["landing_cdc"]
					},
					"tablePattern": {
						"type": "string",
						"description": "Pattern for table names",
						"examples": ["%customers"]
					},
					"schemaPattern": {
						"type": "string",
						"description": "Pattern for schema names",
						"examples": ["%", "dbo"]
					},
					"type": {
						"type": "string",
						"description": "Type of data object (TABLE and View are used for a database source, RELOAD and CDC are for web application)",
						"enum": ["NONE", "TABLE", "VIEW", "TABLE_AND_VIEW", "RELOAD", "CDC"],
						"default": "TABLE"
					}
				},
				"required": ["tablePattern"],
				"additionalProperties": false
			},
			"examples": [
				[
					{
						"tablePattern": "%customers",
						"schemaPattern": "dbo",
						"type": "TABLE"
					}
				]
			]
		},
		"excludePatterns": {
			"type": "array",
			"description": "List of tables/views patterns to exclude from the source",
			"items": {
				"type": "object",
				"description": "Exclude pattern item",
				"properties": {
					"tablePattern": {
						"type": "string",
						"description": "Pattern for table names",
						"examples": ["%customers"]
					},
					"schemaPattern": {
						"type": "string",
						"description": "Pattern for schema names",
						"examples": ["%", "dbo"]
					},
					"type": {
						"type": "string",
						"description": "Type of data object",
						"enum": ["TABLE", "VIEW"],
						"default": "TABLE"
					}
				},
				"required": ["type", "tablePattern"],
				"additionalProperties": false
			},
			"examples": [
				[
					{
						"tablePattern": "%customers",
						"schemaPattern": "dbo",
						"type": "TABLE"
					}
				]
			]
		},
		"explicitlySelected": {
			"type": "array",
			"description": "List of explicitly selected tables/views",
			"items": {
				"type": "object",
				"description": "Explicitly selected item",
				"properties": {
					"sourceProject": {
						"type": "string",
						"description": "source project (for cross-project datasets)"
					},
					"sourceTask": {
						"type": "string",
						"description": "source task",
						"examples": ["landing_cdc"]
					},
					"name": {
						"type": "string",
						"description": "Name of the table or view",
						"examples": ["Employees", "Categories"]
					},
					"schema": {
						"type": "string",
						"description": "Schema name",
						"examples": ["dbo"]
					},
					"type": {
						"type": "string",
						"description": "Type of data object (TABLE is for datasets that support CDC, VIEW is for full load only datasets)",
						"enum": ["NONE", "CONNECTOR", "TABLE", "VIEW", "TABLE_AND_VIEW", "PRECOG", "DIRECTORY"],
						"default": "TABLE"
					},
					"sourceTableId": {
						"type": "string",
						"description": "Table identifier, to be used from other tasks",
						"examples": ["$replicate$dbo_employees"]
					},
					"database": {
						"type": "string",
						"description": "Database name. valid for registered data tasks"
					},
					"outputDatasetName": {
						"type": "string",
						"description": "output dataset name. valid for streaming landing tasks"
					}
				},
				"required": [],
				"additionalProperties": false
			},
			"examples": [
				[
					{
						"name": "Employees",
						"schema": "dbo",
						"type": "TABLE",
						"sourceTableId": "$replicate$dbo_employees"
					}
				]
			]
		}
	},
	"required": [],
	"$defs": {
		"ModifiedByAi": {
			"type": "object",
			"description": "Metadata describing the latest AI modification",
			"required": ["lastUpdated", "model"],
			"properties": {
				"lastUpdated": { "type": "string", "format": "date-time", "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{3}Z$", "description": "UTC timestamp of the latest AI modification" },
				"model": { "type": "string", "minLength": 1, "description": "AI model that made the latest modification" }
			},
			"additionalProperties": false
		}
	},
	"additionalProperties": false
}
