{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"$id": "https://matters-that-matter.app/schema/v1/action.json",
	"title": "Action note properties",
	"description": "The properties of an Action note in Matters that Matter: one unit of work, shown as one card on the board. The note's file name is the Action's title and its body holds the details and checklist. Only the mtm- properties listed here belong to an Action; any property without the mtm- prefix is allowed and left alone. A note needs only mtm-kind to be an Action, but a tool that creates one should also set mtm-type, mtm-status and mtm-matter, as the plugin does. Statuses and types are IDs from the plugin's settings (data.json; see settings.json), never labels. This schema describes what a tool should write; Matters that Matter reads more than it allows (older forms and values written by hand) and never rewrites them on its own. Later versions of the plugin may add mtm- properties; the file at this address is updated to list them, and a change that would refuse what was valid before gets a new address (v2).",
	"type": "object",
	"required": [
		"mtm-kind"
	],
	"properties": {
		"mtm-kind": {
			"description": "Marks the note as an Action. Notes are recognised by this property, never by their folder.",
			"const": "action"
		},
		"mtm-type": {
			"description": "The Action type's ID from settings (call, message, write and so on). It sets the card's colour and icon. When absent, the default type applies; an ID that is not in settings also falls back to the default type and shows a badge until it is fixed.",
			"type": "string",
			"minLength": 1
		},
		"mtm-status": {
			"description": "The status's ID from settings: the board column the Action sits in. When absent, the backlog status applies; an ID that is not in settings also falls back to it and shows a badge. Whether an Action is done is decided by the status's category (closed), not by its ID.",
			"type": "string",
			"minLength": 1
		},
		"mtm-matter": {
			"description": "The Matter the Action belongs to, as a link to the Matter note: a wikilink in quotes, such as \"[[Kitchen renovation]]\", in the shortest form that is unambiguous in the vault. When absent, the Action is in the Inbox; a link that does not lead to a Matter note also puts it in the Inbox, with a badge.",
			"$ref": "#/$defs/link"
		},
		"mtm-start": {
			"description": "When work on the Action starts: YYYY-MM-DD for a whole day, or YYYY-MM-DDTHH:mm for a time (24-hour clock, local time, no seconds or time zone). Optional. On its own it marks a single day on the calendar and the timeline. Matters that Matter also reads a time with seconds (which Obsidian's date picker writes) and a space before the time, but a tool should write one of these two forms.",
			"$ref": "#/$defs/dateOrDateTime"
		},
		"mtm-due": {
			"description": "When the Action is due: YYYY-MM-DD for a whole day, or YYYY-MM-DDTHH:mm for a time (24-hour clock, local time, no seconds or time zone). Optional. A whole-day Action is overdue from the next day; a timed one once its time has passed. Done Actions are never overdue. Matters that Matter also reads a time with seconds (which Obsidian's date picker writes) and a space before the time, but a tool should write one of these two forms.",
			"$ref": "#/$defs/dateOrDateTime"
		},
		"mtm-priority": {
			"description": "1 for high, 2 for medium, 3 for low. Leave it out for no priority.",
			"type": "integer",
			"enum": [
				1,
				2,
				3
			]
		},
		"mtm-waiting-on": {
			"description": "The person the Action is waiting on, as a link to their note in quotes, such as \"[[Marco Rossi]]\". Whoever sets it also adds the same link to mtm-people and sets mtm-waiting-since to today; whoever removes it also removes mtm-waiting-since.",
			"$ref": "#/$defs/link"
		},
		"mtm-people": {
			"description": "The people involved in the Action: a list of links to their notes, each in quotes. Always a list, even with one person.",
			"type": "array",
			"items": {
				"$ref": "#/$defs/link"
			}
		},
		"mtm-waiting-since": {
			"description": "The day mtm-waiting-on was set or last changed to another person, as YYYY-MM-DD. Set it to today when you set or change mtm-waiting-on, and remove it when you remove mtm-waiting-on. Never fill it in for older Actions that lack it. The plugin ignores it while mtm-waiting-on is absent.",
			"$ref": "#/$defs/date"
		},
		"mtm-completed": {
			"description": "The day the Action was done, as YYYY-MM-DD. Set it to today when the Action moves from a status that is not closed into a closed one, if it is not already set; remove it when the Action moves out of a closed status. Moving between two closed statuses leaves it as it is. Never fill it in for done Actions that lack it.",
			"$ref": "#/$defs/date"
		},
		"mtm-order": {
			"description": "The Action's position within its board cell, lower first, on boards and lists ordered by hand. Written by Matters that Matter; other tools never need to set it, and should remove it when they move the Action to another status or Matter, as the plugin does.",
			"type": "number"
		},
		"mtm-sample": {
			"description": "Marks the note as sample content, so that \"Remove sample content\" can find it. Other tools should not set it.",
			"type": "boolean"
		}
	},
	"dependentRequired": {
		"mtm-waiting-since": [
			"mtm-waiting-on"
		]
	},
	"patternProperties": {
		"^(?![Mm][Tt][Mm]-)": true
	},
	"additionalProperties": false,
	"$defs": {
		"date": {
			"description": "A real calendar day, as YYYY-MM-DD.",
			"type": "string",
			"pattern": "^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])$"
		},
		"dateOrDateTime": {
			"description": "A real calendar day as YYYY-MM-DD, or a day and time as YYYY-MM-DDTHH:mm.",
			"type": "string",
			"pattern": "^[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12][0-9]|3[01])(?:T(?:[01][0-9]|2[0-3]):[0-5][0-9])?$"
		},
		"link": {
			"description": "A wikilink to a note, such as [[Note name]], [[Folder/Note name]] or [[Note name|shown text]], with an optional #heading. Written in quotes in the note's properties, because YAML reads an unquoted [[…]] as a list.",
			"type": "string",
			"pattern": "^\\[\\[[^\\[\\]|#^]*[^\\s\\[\\]|#^][^\\[\\]|#^]*(?:#[^\\[\\]|]+)?(?:\\|[^\\[\\]]+)?\\]\\]$"
		}
	}
}
