{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://blaze-monorepo.dev/schemas/project",
    "type": "object",
    "title": "Project",
    "description": "A project configuration within a Blaze workspace",
    "properties": {
        "targets": {
            "patternProperties": {
                "^[a-zA-Z0-9_\\-/]+$": {
                    "properties": {
                        "executor": {
                            "oneOf": [
                                {
                                    "type": "string",
                                    "minLength": 1,
                                    "description": "Executor URL."
                                },
                                {
                                    "description": "Standard executor configuration.",
                                    "properties": {
                                        "url": {
                                            "type": "string",
                                            "enum": [
                                                "std:noop",
                                                "std:commands",
                                                "std:exec"
                                            ]
                                        }
                                    },
                                    "required": [
                                        "url"
                                    ],
                                    "type": "object",
                                    "additionalProperties": false
                                },
                                {
                                    "description": "Local filesystem executor configuration",
                                    "properties": {
                                        "url": {
                                            "type": "string",
                                            "description": "URL containing the path to the executor files.",
                                            "pattern": "^file://.+$"
                                        },
                                        "rebuild": {
                                            "enum": [
                                                "Always",
                                                "OnChanges"
                                            ],
                                            "description": "When should Blaze rebuild the executor from source.",
                                            "default": "OnChanges"
                                        },
                                        "kind": {
                                            "enum": [
                                                "Rust",
                                                "Node"
                                            ],
                                            "description": "Executor kind, if Blaze cannot infer it."
                                        },
                                        "watch": {
                                            "type": "array",
                                            "description": "What files should be watched for changes when rebuild strategy is set to \"OnChanges\"",
                                            "items": {
                                                "oneOf": [
                                                    {
                                                        "type": "string",
                                                        "minLength": 1,
                                                        "description": "Pattern to use when matching files."
                                                    },
                                                    {
                                                        "description": "A pattern based file changes matcher.",
                                                        "properties": {
                                                            "pattern": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "Pattern to use when matching files."
                                                            },
                                                            "exclude": {
                                                                "type": "array",
                                                                "items": {
                                                                    "type": "string",
                                                                    "minLength": 1
                                                                },
                                                                "description": "An array of patterns to use when excluding matched files.",
                                                                "default": []
                                                            },
                                                            "root": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "Match files from a specific directory."
                                                            },
                                                            "behavior": {
                                                                "enum": [
                                                                    "Mixed",
                                                                    "Timestamps",
                                                                    "Hash"
                                                                ],
                                                                "description": "Defines the change detection strategy for this matcher.",
                                                                "default": "Mixed"
                                                            }
                                                        },
                                                        "required": [
                                                            "pattern"
                                                        ],
                                                        "type": "object",
                                                        "additionalProperties": false
                                                    }
                                                ]
                                            }
                                        }
                                    },
                                    "required": [
                                        "url"
                                    ],
                                    "type": "object",
                                    "additionalProperties": false
                                },
                                {
                                    "properties": {
                                        "url": {
                                            "description": "Git repository HTTP URL",
                                            "type": "string",
                                            "pattern": "^https?://.+$"
                                        },
                                        "format": {
                                            "description": "Tells Blaze that the HTTP resource is a Git repository.",
                                            "const": "Git"
                                        },
                                        "authentication": {
                                            "properties": {
                                                "username": {
                                                    "type": "string",
                                                    "minLength": 1
                                                },
                                                "password": {
                                                    "type": "string",
                                                    "minLength": 1
                                                }
                                            },
                                            "type": "object",
                                            "additionalProperties": false,
                                            "description": "Authentication to use when cloning over HTTP."
                                        },
                                        "insecure": {
                                            "description": "Disable SSL/TLS certificate verification. Only for debugging purpose.",
                                            "type": "boolean",
                                            "default": false
                                        },
                                        "headers": {
                                            "type": "object",
                                            "description": "Extra HTTP headers for the request.",
                                            "patternProperties": {
                                                "^.+$": {
                                                    "type": "string",
                                                    "minLength": 1
                                                }
                                            },
                                            "default": {}
                                        },
                                        "path": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Path to the executor within the repository. Defaults to the repository root directory if not provided."
                                        },
                                        "branch": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Checkout a specific branch."
                                        },
                                        "rev": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Checkout using a specific revision string (typically a commit hash)."
                                        },
                                        "tag": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Checkout a specific tag."
                                        },
                                        "kind": {
                                            "enum": [
                                                "Rust",
                                                "Node"
                                            ],
                                            "description": "Specify executor type if Blaze cannot infer it."
                                        },
                                        "pull": {
                                            "type": "boolean",
                                            "description": "Always pull last changes from remote.",
                                            "default": false
                                        }
                                    },
                                    "required": [
                                        "url",
                                        "format"
                                    ],
                                    "type": "object",
                                    "additionalProperties": false
                                },
                                {
                                    "properties": {
                                        "url": {
                                            "type": "string",
                                            "description": "Git repository SSH URL",
                                            "pattern": "^ssh://.+$"
                                        },
                                        "authentication": {
                                            "description": "Authentication to use when connecting to the SSH server.",
                                            "oneOf": [
                                                {
                                                    "description": "Username/password authentication.",
                                                    "properties": {
                                                        "username": {
                                                            "type": "string",
                                                            "minLength": 1
                                                        },
                                                        "password": {
                                                            "type": "string",
                                                            "minLength": 1
                                                        }
                                                    },
                                                    "required": [
                                                        "password"
                                                    ],
                                                    "type": "object",
                                                    "additionalProperties": false
                                                },
                                                {
                                                    "description": "Private key authentication.",
                                                    "properties": {
                                                        "key": {
                                                            "type": "string",
                                                            "minLength": 1
                                                        },
                                                        "passphrase": {
                                                            "type": "string",
                                                            "minLength": 1
                                                        },
                                                        "username": {
                                                            "type": "string",
                                                            "minLength": 1
                                                        }
                                                    },
                                                    "required": [
                                                        "key"
                                                    ],
                                                    "type": "object",
                                                    "additionalProperties": false
                                                }
                                            ]
                                        },
                                        "path": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Path to the executor within the repository. Defaults to the repository root directory if not provided."
                                        },
                                        "branch": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Checkout a specific branch."
                                        },
                                        "rev": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Checkout using a specific revision string (typically a commit hash)."
                                        },
                                        "tag": {
                                            "type": "string",
                                            "minLength": 1,
                                            "description": "Checkout a specific tag."
                                        },
                                        "kind": {
                                            "enum": [
                                                "Rust",
                                                "Node"
                                            ],
                                            "description": "Specify executor type if Blaze cannot infer it."
                                        },
                                        "pull": {
                                            "type": "boolean",
                                            "description": "Always pull last changes from remote.",
                                            "default": false
                                        },
                                        "insecure": {
                                            "description": "Disable SSH server public key verification. Only for debugging purpose.",
                                            "type": "boolean",
                                            "default": false
                                        },
                                        "fingerprints": {
                                            "description": "An array of trusted SSH server fingerprints to use when validating.",
                                            "type": "array",
                                            "items": {
                                                "type": "string",
                                                "pattern": "^(MD5|SHA1|SHA256):.+$"
                                            }
                                        }
                                    },
                                    "type": "object",
                                    "additionalProperties": false
                                }
                            ],
                            "description": "The executor to use for this target."
                        },
                        "options": {
                            "description": "Options for the executor."
                        },
                        "cache": {
                            "description": "A target cache configuration object.",
                            "properties": {
                                "invalidateWhen": {
                                    "properties": {
                                        "inputChanges": {
                                            "type": "array",
                                            "description": "An array of input file changes matchers. Cache will invalidated if any of these matchers detect some file changes.",
                                            "items": {
                                                "oneOf": [
                                                    {
                                                        "type": "string",
                                                        "minLength": 1,
                                                        "description": "Pattern to use when matching files."
                                                    },
                                                    {
                                                        "description": "A pattern based file changes matcher.",
                                                        "properties": {
                                                            "pattern": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "Pattern to use when matching files."
                                                            },
                                                            "exclude": {
                                                                "type": "array",
                                                                "items": {
                                                                    "type": "string",
                                                                    "minLength": 1
                                                                },
                                                                "description": "An array of patterns to use when excluding matched files.",
                                                                "default": []
                                                            },
                                                            "root": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "Match files from a specific directory."
                                                            },
                                                            "behavior": {
                                                                "enum": [
                                                                    "Mixed",
                                                                    "Timestamps",
                                                                    "Hash"
                                                                ],
                                                                "description": "Defines the change detection strategy for this matcher.",
                                                                "default": "Mixed"
                                                            }
                                                        },
                                                        "required": [
                                                            "pattern"
                                                        ],
                                                        "type": "object",
                                                        "additionalProperties": false
                                                    }
                                                ]
                                            },
                                            "uniqueItems": true
                                        },
                                        "outputChanges": {
                                            "type": "array",
                                            "description": "An array of output file changes matchers. Cache will invalidated if any of these matchers detect some file changes.",
                                            "items": {
                                                "oneOf": [
                                                    {
                                                        "type": "string",
                                                        "minLength": 1,
                                                        "description": "Pattern to use when matching files."
                                                    },
                                                    {
                                                        "description": "A pattern based file changes matcher.",
                                                        "properties": {
                                                            "pattern": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "Pattern to use when matching files."
                                                            },
                                                            "exclude": {
                                                                "type": "array",
                                                                "items": {
                                                                    "type": "string",
                                                                    "minLength": 1
                                                                },
                                                                "description": "An array of patterns to use when excluding matched files.",
                                                                "default": []
                                                            },
                                                            "root": {
                                                                "type": "string",
                                                                "minLength": 1,
                                                                "description": "Match files from a specific directory."
                                                            },
                                                            "behavior": {
                                                                "enum": [
                                                                    "Mixed",
                                                                    "Timestamps",
                                                                    "Hash"
                                                                ],
                                                                "description": "Defines the change detection strategy for this matcher.",
                                                                "default": "Mixed"
                                                            }
                                                        },
                                                        "required": [
                                                            "pattern"
                                                        ],
                                                        "type": "object",
                                                        "additionalProperties": false
                                                    }
                                                ]
                                            },
                                            "uniqueItems": true
                                        },
                                        "filesMissing": {
                                            "type": "array",
                                            "description": "An array of file paths. Cache will be invalidated when any of these files is missing.",
                                            "items": {
                                                "type": "string",
                                                "minLength": 1
                                            },
                                            "uniqueItems": true
                                        },
                                        "commandFails": {
                                            "description": "A command configuration object. Cache will be invalidated if the command fails.",
                                            "properties": {
                                                "program": {
                                                    "description": "The name of the program to launch.",
                                                    "type": "string",
                                                    "minLength": 1
                                                },
                                                "arguments": {
                                                    "type": "array",
                                                    "description": "An list of arguments for the program.",
                                                    "default": [],
                                                    "items": {
                                                        "type": "string",
                                                        "minLength": 1
                                                    }
                                                },
                                                "environment": {
                                                    "type": "object",
                                                    "description": "Custom environment variables for the process.",
                                                    "default": {},
                                                    "patternProperties": {
                                                        "^.+$": {
                                                            "type": "string"
                                                        }
                                                    }
                                                },
                                                "verbose": {
                                                    "description": "Should command output be displayed ?",
                                                    "default": false,
                                                    "type": "boolean"
                                                },
                                                "cwd": {
                                                    "type": "string",
                                                    "minLength": 1
                                                }
                                            },
                                            "required": [
                                                "program"
                                            ],
                                            "type": "object",
                                            "additionalProperties": false
                                        },
                                        "expired": {
                                            "description": "A TTL configuration object. Cache will be invalidated after the given duration.",
                                            "properties": {
                                                "unit": {
                                                    "description": "The time unit to use.",
                                                    "enum": [
                                                        "Milliseconds",
                                                        "Seconds",
                                                        "Minutes",
                                                        "Hours",
                                                        "Days"
                                                    ]
                                                },
                                                "amount": {
                                                    "description": "The cache TTL value to use.",
                                                    "type": "integer",
                                                    "minimum": 1
                                                }
                                            },
                                            "required": [
                                                "unit",
                                                "amount"
                                            ],
                                            "type": "object",
                                            "additionalProperties": false
                                        }
                                    },
                                    "type": "object",
                                    "additionalProperties": false
                                }
                            },
                            "type": "object",
                            "additionalProperties": false
                        },
                        "dependencies": {
                            "type": "array",
                            "items": {
                                "oneOf": [
                                    {
                                        "description": "The name of any target within the project",
                                        "type": "string",
                                        "minLength": 1
                                    },
                                    {
                                        "properties": {
                                            "target": {
                                                "type": "string",
                                                "minLength": 1
                                            },
                                            "projects": {
                                                "oneOf": [
                                                    {
                                                        "description": "Select all projects in the workspace.",
                                                        "const": "All"
                                                    },
                                                    {
                                                        "type": "array",
                                                        "description": "A list of project names to select.",
                                                        "items": {
                                                            "type": "string",
                                                            "pattern": "^[a-zA-Z0-9_\\-/]+$"
                                                        },
                                                        "uniqueItems": true
                                                    },
                                                    {
                                                        "properties": {
                                                            "tags": {
                                                                "type": "array",
                                                                "items": {
                                                                    "type": "string",
                                                                    "minLength": 1
                                                                },
                                                                "minItems": 1,
                                                                "uniqueItems": true
                                                            }
                                                        },
                                                        "type": "object",
                                                        "additionalProperties": false
                                                    },
                                                    {
                                                        "properties": {
                                                            "include": {
                                                                "type": "array",
                                                                "items": {
                                                                    "description": "An inclusion pattern to be used when selecting projects. Any project which name matches the pattern will be included in the selection.",
                                                                    "type": "string",
                                                                    "minLength": 1
                                                                },
                                                                "uniqueItems": true,
                                                                "minItems": 1
                                                            },
                                                            "exclude": {
                                                                "type": "array",
                                                                "items": {
                                                                    "description": "An exclusion pattern (regular expression) to be used when selecting projects. Any project matching the pattern will be excluded from the selection.",
                                                                    "type": "string",
                                                                    "minLength": 1
                                                                },
                                                                "uniqueItems": true
                                                            }
                                                        },
                                                        "required": [
                                                            "include"
                                                        ],
                                                        "type": "object",
                                                        "additionalProperties": false
                                                    }
                                                ]
                                            },
                                            "optional": {
                                                "description": "If set to true, target will be executed even if this dependency is not fullfilled.",
                                                "type": "boolean"
                                            },
                                            "cachePropagation": {
                                                "description": "Defines how cache invalidations are propagated to this target's cache state.",
                                                "oneOf": [
                                                    {
                                                        "const": "Always",
                                                        "description": "Always propagate cache for this dependency."
                                                    },
                                                    {
                                                        "const": "Never",
                                                        "description": "Never propagate cache for this dependency."
                                                    }
                                                ]
                                            }
                                        },
                                        "required": [
                                            "target"
                                        ],
                                        "type": "object",
                                        "additionalProperties": false
                                    }
                                ]
                            },
                            "uniqueItems": true,
                            "description": "Dependencies that should be met before executing this target.",
                            "default": []
                        },
                        "description": {
                            "type": "string",
                            "minLength": 1,
                            "description": "A description for this target. Useful for when describing the project."
                        },
                        "stateless": {
                            "type": "boolean",
                            "description": "Can the target run concurrently (in multiple Blaze processes) ?",
                            "default": false
                        }
                    },
                    "type": "object",
                    "additionalProperties": false
                }
            },
            "type": "object",
            "additionalProperties": false
        }
    },
    "required": [
        "targets"
    ],
    "$defs": {}
}