{
    "$schema": "https://json-schema.org/draft-07/schema",
    "id": "https://diskuv.com/dk/schema/dk-rule-response-1.0.json",
    "title": "Schema for the response of a rule function to build system commands",
    "type": "object",
    "properties": {
        "declareoutput": {
            "description": "The response to the build system command 'queryreturn' describing the value that would be returned from the rule function without actually performing any work.",
            "type": "object",
            "properties": {
                "$schema": {
                    "description": "The dk build system schema for responses from rule functions. Used by VS Code for auto-completions, but otherwise ignored.",
                    "type": "string",
                    "default": "https://github.com/diskuv/dk/raw/refs/heads/V2_5/etc/jsonschema/dk-rule-response.json"
                },
                "return_objects": {
                    "description": "The objects that will be returned from the rule function.",
                    "type": "object",
                    "properties": {
                        "id": {
                            "description": "The MODULE@VERSION of the form that will be returned from the rule function. The MODULE@VERSION form may be defined in a sibling [values].",
                            "type": "string"
                        },
                        "slots": {
                            "description": "The object slots created by the form.",
                            "type": "array",
                            "items": {
                                "type": "string"
                            }
                        },
                        "execution_slot": {
                            "description": "The slot that will be used for execution when the rule is executed. Use slot wildcards like `Release.execution_abi` for cross-platform.",
                            "type": "string"
                         }
                    },
                    "required": [
                        "id",
                        "slots",
                        "execution_slot"
                    ]
                },
                "return_asset": {
                    "description": "The asset value that will be returned from the rule function.",
                    "type": "object",
                    "properties": {
                        "id": {
                            "description": "The MODULE@VERSION that will be returned from the rule function. The MODULE@VERSION may come from a sibling [values].",
                            "type": "string"
                        },
                        "path": {
                            "description": "The path of the asset to return.",
                            "type": "string"
                        }
                    },
                    "required": [
                        "id",
                        "path"
                    ]
                },
                "input_bundles": {
                    "description": "Static bundle inputs that the rule depends on.",
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "description": "The MODULE@VERSION bundle dependency of the rule.",
                                "type": "string"
                            }
                        },
                        "required": [
                            "id"
                        ]
                    }
                },
                "input_assets": {
                    "description": "Static asset inputs that the rule depends on.",
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "description": "The MODULE@VERSION asset dependency of the rule.",
                                "type": "string"
                            },
                            "path": {
                                "description": "The asset path dependency of the rule.",
                                "type": "string"
                            }
                        },
                        "required": [
                            "id",
                            "path"
                        ]
                    }
                },
                "input_objects": {
                    "description": "Static object inputs that the rule depends on.",
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "description": "The MODULE@VERSION form dependency of the rule.",
                                "type": "string"
                            },
                            "slots": {
                                "description": "The object slots published by the dependency.",
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "execution_slot": {
                                "description": "The slot that will be used for execution when the rule is executed. Use slot wildcards like `Release.execution_abi` for cross-platform.",
                                "type": "string"
                             }
                        },
                        "required": [
                            "id",
                            "slots",
                            "execution_slot"
                        ]
                    }
                }
            },
            "oneOf": [
                {
                    "required": [
                        "return_objects"
                    ]
                },
                {
                    "required": [
                        "return_asset"
                    ]
                }
            ]
        },
        "submit": {
            "description": "The response to the build system command 'submit'. First the values in the [valuejson] field will be added to the valuestore. Then the [expressions] will be evaluated. Finally the [andthen] logic is performed.",
            "type": "object",
            "properties": {
                "$schema": {
                    "description": "The dk build system schema for responses from rule functions. Used by VS Code for auto-completions, but otherwise ignored.",
                    "type": "string",
                    "default": "https://github.com/diskuv/dk/raw/refs/heads/V2_5/etc/jsonschema/dk-rule-response.json"
                },
                "values": {
                    "type": "object",
                    "description": "Values to be added to the valuestore and to the task graph. The `forms[].function` field may be written as `forms[].function_` to avoid conflicts with the Lua `function` keyword.",
                    "$schema": "https://github.com/diskuv/dk/raw/refs/heads/V2_5/etc/jsonschema/dk-values.json"
                },
                "expressions": {
                    "type": "object",
                    "description": "Expressions to be added to [request.continued] after [values] is added to the valuestore and task graph. Expressions can be literal strings, variable references and/or subshells.",
                    "properties": {
                        "files": {
                            "type": "object",
                            "description": "Expressions that should be evaluated as file paths.",
                            "additionalProperties": {
                                "type": "string"
                            }
                        },
                        "directories": {
                            "type": "object",
                            "description": "Expressions that should be evaluated as directory paths.",
                            "additionalProperties": {
                                "type": "string"
                            }
                        },
                        "strings": {
                            "type": "object",
                            "description": "Expressions that should be evaluated as strings. This is rarely the right choice for subshells.",
                            "additionalProperties": {
                                "type": "string"
                            }
                        },
                        "additionalProperties": false
                    }
                },
                "commands": {
                    "type": "array",
                    "description": "Value shell commands like `run-function ...`.",
                    "items": {
                        "type": "array",
                        "description": "Value shell words for a single value shell command",
                        "items": {
                            "type": "string"
                        }
                    }
                },
                "continue_": {
                    "type": "object",
                    "description": "Logic to be performed after the [values] have been added and the [expressions] evaluated. Either continue to the next state by specifying [continue_] or return a value by not specifying a [continue_].",
                    "properties": {
                        "state": {
                            "description": "The state to transition to.",
                            "type": "string"
                        },
                        "passthrough": {
                            "description": "Properties to pass through to the next state in its [request.continued] parameter.",
                            "type": "object"
                        }
                    },
                    "required": [
                        "state"
                    ]
                }
            },
            "additionalProperties": false
        }
    }
}
