{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://raw.githubusercontent.com/kern0x1b/penstock-release/main/docs/schema/penstock.schema.json",
  "title": "Penstock project configuration",
  "description": "Configuration for Penstock. A file in a subfolder overrides the one above it, penstock.local.yaml overrides the file beside it, the active profile overrides both, and PENSTOCK_* environment variables have the last word.",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "engine": {
      "description": "Which engine the diagrams target. Decides the palette, the properties panel and what deploy does.",
      "type": "string",
      "enum": [
        "classic",
        "camunda-7",
        "camunda-8",
        "operaton",
        "cib-seven"
      ]
    },
    "scriptType": {
      "description": "Default language for script tasks. Camunda 7, Operaton and CIB seven only.",
      "type": "string",
      "enum": [
        "none",
        "groovy",
        "javascript"
      ]
    },
    "elementTemplates": {
      "description": "Folders and files to read Camunda element templates from, relative to the project root. .camunda/element-templates next to a diagram or in any folder above it is read without being listed.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "linked": {
      "description": "Other repositories that belong to this project, relative to its root: the workers, delegates and diagrams in them count as part of it. A path that is not checked out is skipped.",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "lint": {
      "description": "Which bpmnlint rules the check and penstock lint apply. Without it, .bpmnlintrc in the project root, or bpmnlint:recommended when there is none.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "configPath": {
          "description": "Path to the .bpmnlintrc to use, relative to the project root.",
          "type": "string"
        },
        "clientBundlePath": {
          "description": "A bundle of rules from bpmnlint plugins for the editor, built with bpmnlint-pack-config. Needed only when .bpmnlintrc uses a plugin; the command line reads plugins from node_modules.",
          "type": "string"
        }
      }
    },
    "conventions": {
      "description": "Rules the editor applies while modelling, so a team does not have to remember them.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "ids": {
          "description": "How technical ids are derived from what an element is called.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "fromName": {
              "description": "Rewrite the id when the name changes.",
              "type": "boolean"
            },
            "pattern": {
              "description": "The shape of the id. {Type} is the element type, {Name} the label in PascalCase.",
              "type": "string",
              "default": "{Type}_{Name}"
            }
          }
        },
        "defaults": {
          "description": "Attributes to set on a newly created element, keyed by its BPMN type — \"bpmn:ServiceTask\", \"bpmn:DataInput\".",
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "boolean",
                "number"
              ]
            }
          }
        }
      }
    },
    "tests": {
      "description": "Where `penstock junit` writes the tests it generates. By default each diagram gets them in its own module - the nearest folder with a Gradle or Maven build - in the language and package that module already uses.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "language": {
          "description": "The language of the tests. By default Kotlin if the module has Kotlin sources, otherwise Java.",
          "type": "string",
          "enum": [
            "java",
            "kotlin"
          ]
        },
        "out": {
          "description": "The source folder the tests go to, relative to the project root. By default src/test/java or src/test/kotlin of the module.",
          "type": "string"
        },
        "package": {
          "description": "The package of the tests. By default the package of the Spring Boot application, or the one all sources share, followed by .process.",
          "type": "string"
        }
      }
    },
    "hooks": {
      "description": "Commands to run around a stage. They run in the project root with PENSTOCK_FILES and PENSTOCK_PROFILE set; a non-zero exit from a \"pre\" hook stops the stage.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "preCheck": {
          "description": "Before check runs.",
          "type": "string"
        },
        "postCheck": {
          "description": "After check runs, whatever it found.",
          "type": "string"
        },
        "preLayout": {
          "description": "Before layout runs.",
          "type": "string"
        },
        "postLayout": {
          "description": "After layout has written its result.",
          "type": "string"
        },
        "preDeploy": {
          "description": "Before anything is sent. Stops the deployment if it fails.",
          "type": "string"
        },
        "postDeploy": {
          "description": "After a successful deployment — a notification, a tag, a release note.",
          "type": "string"
        }
      }
    },
    "deployment": {
      "description": "Where deploy sends the diagram. One target; a profile overrides it for another environment. Secrets are referenced with ${VAR}, never written here.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "url": {
          "description": "Where to deploy. The engine decides what this address means: the Camunda 7 REST API (http://localhost:8080/engine-rest) or the Camunda 8 Zeebe REST gateway.",
          "type": "string"
        },
        "name": {
          "description": "Deployment name shown in the engine.",
          "type": "string"
        },
        "tenantId": {
          "description": "Tenant to deploy to. Empty means the default tenant.",
          "type": "string"
        },
        "source": {
          "description": "Deployment source recorded by the engine.",
          "type": "string"
        },
        "changedOnly": {
          "description": "Leave out what the engine already has unchanged. On unless set to false.",
          "type": "boolean"
        },
        "forTests": {
          "description": "This engine is for tests: Penstock may deploy test builds and answer jobs on it when it runs test cases.",
          "type": "boolean"
        },
        "activationTime": {
          "description": "ISO timestamp the deployment becomes active.",
          "type": "string"
        },
        "auth": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "type": {
              "description": "How to authenticate against the engine. The password or client secret comes from the IDE password safe, or from PENSTOCK_PASSWORD and PENSTOCK_CLIENT_SECRET on the command line.",
              "type": "string",
              "enum": [
                "none",
                "basic",
                "oauth"
              ]
            },
            "username": {
              "description": "Basic auth user. The password lives in the IDE password safe.",
              "type": "string"
            },
            "clientId": {
              "description": "OAuth client id. The secret lives in the IDE password safe.",
              "type": "string"
            },
            "tokenUrl": {
              "description": "OAuth token endpoint.",
              "type": "string"
            },
            "audience": {
              "description": "OAuth audience.",
              "type": "string"
            }
          }
        }
      }
    },
    "profile": {
      "description": "Profile to apply. PENSTOCK_PROFILE overrides this.",
      "type": "string"
    },
    "profiles": {
      "description": "Named overrides, applied on top of the settings above when the profile is active.",
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/settings"
      }
    }
  },
  "$defs": {
    "settings": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "engine": {
          "description": "Which engine the diagrams target. Decides the palette, the properties panel and what deploy does.",
          "type": "string",
          "enum": [
            "classic",
            "camunda-7",
            "camunda-8",
            "operaton",
            "cib-seven"
          ]
        },
        "scriptType": {
          "description": "Default language for script tasks. Camunda 7, Operaton and CIB seven only.",
          "type": "string",
          "enum": [
            "none",
            "groovy",
            "javascript"
          ]
        },
        "elementTemplates": {
          "description": "Folders and files to read Camunda element templates from, relative to the project root. .camunda/element-templates next to a diagram or in any folder above it is read without being listed.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "linked": {
          "description": "Other repositories that belong to this project, relative to its root: the workers, delegates and diagrams in them count as part of it. A path that is not checked out is skipped.",
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "lint": {
          "description": "Which bpmnlint rules the check and penstock lint apply. Without it, .bpmnlintrc in the project root, or bpmnlint:recommended when there is none.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "configPath": {
              "description": "Path to the .bpmnlintrc to use, relative to the project root.",
              "type": "string"
            },
            "clientBundlePath": {
              "description": "A bundle of rules from bpmnlint plugins for the editor, built with bpmnlint-pack-config. Needed only when .bpmnlintrc uses a plugin; the command line reads plugins from node_modules.",
              "type": "string"
            }
          }
        },
        "conventions": {
          "description": "Rules the editor applies while modelling, so a team does not have to remember them.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "ids": {
              "description": "How technical ids are derived from what an element is called.",
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "fromName": {
                  "description": "Rewrite the id when the name changes.",
                  "type": "boolean"
                },
                "pattern": {
                  "description": "The shape of the id. {Type} is the element type, {Name} the label in PascalCase.",
                  "type": "string",
                  "default": "{Type}_{Name}"
                }
              }
            },
            "defaults": {
              "description": "Attributes to set on a newly created element, keyed by its BPMN type — \"bpmn:ServiceTask\", \"bpmn:DataInput\".",
              "type": "object",
              "additionalProperties": {
                "type": "object",
                "additionalProperties": {
                  "type": [
                    "string",
                    "boolean",
                    "number"
                  ]
                }
              }
            }
          }
        },
        "tests": {
          "description": "Where `penstock junit` writes the tests it generates. By default each diagram gets them in its own module - the nearest folder with a Gradle or Maven build - in the language and package that module already uses.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "language": {
              "description": "The language of the tests. By default Kotlin if the module has Kotlin sources, otherwise Java.",
              "type": "string",
              "enum": [
                "java",
                "kotlin"
              ]
            },
            "out": {
              "description": "The source folder the tests go to, relative to the project root. By default src/test/java or src/test/kotlin of the module.",
              "type": "string"
            },
            "package": {
              "description": "The package of the tests. By default the package of the Spring Boot application, or the one all sources share, followed by .process.",
              "type": "string"
            }
          }
        },
        "hooks": {
          "description": "Commands to run around a stage. They run in the project root with PENSTOCK_FILES and PENSTOCK_PROFILE set; a non-zero exit from a \"pre\" hook stops the stage.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "preCheck": {
              "description": "Before check runs.",
              "type": "string"
            },
            "postCheck": {
              "description": "After check runs, whatever it found.",
              "type": "string"
            },
            "preLayout": {
              "description": "Before layout runs.",
              "type": "string"
            },
            "postLayout": {
              "description": "After layout has written its result.",
              "type": "string"
            },
            "preDeploy": {
              "description": "Before anything is sent. Stops the deployment if it fails.",
              "type": "string"
            },
            "postDeploy": {
              "description": "After a successful deployment — a notification, a tag, a release note.",
              "type": "string"
            }
          }
        },
        "deployment": {
          "description": "Where deploy sends the diagram. One target; a profile overrides it for another environment. Secrets are referenced with ${VAR}, never written here.",
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "url": {
              "description": "Where to deploy. The engine decides what this address means: the Camunda 7 REST API (http://localhost:8080/engine-rest) or the Camunda 8 Zeebe REST gateway.",
              "type": "string"
            },
            "name": {
              "description": "Deployment name shown in the engine.",
              "type": "string"
            },
            "tenantId": {
              "description": "Tenant to deploy to. Empty means the default tenant.",
              "type": "string"
            },
            "source": {
              "description": "Deployment source recorded by the engine.",
              "type": "string"
            },
            "changedOnly": {
              "description": "Leave out what the engine already has unchanged. On unless set to false.",
              "type": "boolean"
            },
            "forTests": {
              "description": "This engine is for tests: Penstock may deploy test builds and answer jobs on it when it runs test cases.",
              "type": "boolean"
            },
            "activationTime": {
              "description": "ISO timestamp the deployment becomes active.",
              "type": "string"
            },
            "auth": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "type": {
                  "description": "How to authenticate against the engine. The password or client secret comes from the IDE password safe, or from PENSTOCK_PASSWORD and PENSTOCK_CLIENT_SECRET on the command line.",
                  "type": "string",
                  "enum": [
                    "none",
                    "basic",
                    "oauth"
                  ]
                },
                "username": {
                  "description": "Basic auth user. The password lives in the IDE password safe.",
                  "type": "string"
                },
                "clientId": {
                  "description": "OAuth client id. The secret lives in the IDE password safe.",
                  "type": "string"
                },
                "tokenUrl": {
                  "description": "OAuth token endpoint.",
                  "type": "string"
                },
                "audience": {
                  "description": "OAuth audience.",
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
