{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/metatype-configuration/latest.json",
  "title": "Metatype configuration file schema",
  "x-lintel": {
    "source": "https://raw.githubusercontent.com/metatypedev/metatype/main/tools/schema/metatype.json",
    "sourceSha256": "18904bb00dfb8adcd37503a68fcb8c4c83b35f18eac898083f6f031e5e4455a9",
    "fileMatch": [
      "metatype.yml",
      "metatype.yaml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "typegates": {
      "type": "object",
      "description": "Configuration for typegate nodes. See: <https://metatype.dev/docs/reference/meta-cli/configuration-file#typegate-configuration>.",
      "additionalProperties": {
        "type": "object",
        "description": "Individual typegate node configuration.",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "The base URL of the typegate server, example: <http://localhost:7890>."
          },
          "prefix": {
            "type": "string",
            "description": "A prefix for typegraphs."
          },
          "username": {
            "type": "string",
            "description": "Administrator username for the typegate."
          },
          "password": {
            "type": "string",
            "description": "Administrator password for the typegate."
          },
          "env": {
            "type": "object",
            "description": "Environment variables for the typegate.",
            "additionalProperties": {
              "type": "string"
            }
          },
          "secrets": {
            "type": "object",
            "description": "Secrets used for configuring runtimes within the typegraphs. See: <https://metatype.dev/docs/reference/meta-cli/configuration-file#named-secrets>.",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          }
        },
        "additionalProperties": false
      }
    },
    "typegraphs": {
      "type": "object",
      "properties": {
        "python": {
          "$ref": "#/$defs/typegraphLoaderConfig",
          "description": "Configuration for Python typegraphs."
        },
        "javascript": {
          "$ref": "#/$defs/typegraphLoaderConfig",
          "description": "Configuration for JavaScript typegraphs."
        },
        "typescript": {
          "$ref": "#/$defs/typegraphLoaderConfig",
          "description": "Configuration for TypeScript typegraphs."
        },
        "materializers": {
          "type": "object",
          "properties": {
            "prisma": {
              "type": "object",
              "properties": {
                "migrations_path": {
                  "type": "string",
                  "description": "The directory for storing Prisma migration files."
                }
              },
              "description": "Prisma materializer configuration.",
              "additionalProperties": false
            }
          },
          "description": "Materializer configurations for typegraphs.",
          "additionalProperties": false
        }
      },
      "description": "Typegraph deployment configurations. See: <https://metatype.dev/docs/reference/typegraph>.",
      "additionalProperties": false
    },
    "metagen": {
      "type": "object",
      "properties": {
        "targets": {
          "type": "object",
          "description": "Code generation target configurations.",
          "additionalProperties": {
            "type": "array",
            "items": {
              "$ref": "#/$defs/generatorConfig"
            }
          }
        }
      },
      "description": "Metagen configurations. See: <https://metatype.dev/docs/reference/metagen>.",
      "additionalProperties": false
    }
  },
  "$defs": {
    "path": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      ]
    },
    "typegraphLoaderConfig": {
      "type": "object",
      "description": "Configuration for loading typegraph files.",
      "properties": {
        "include": {
          "$ref": "#/$defs/path",
          "description": "A pattern or array of patterns to include."
        },
        "exclude": {
          "$ref": "#/$defs/path",
          "description": "A pattern or array of patterns to exclude."
        }
      },
      "additionalProperties": false
    },
    "generatorConfigBase": {
      "type": "object",
      "properties": {
        "typegraph_name": {
          "type": "string",
          "description": "The name of the typegraph."
        },
        "typegraph_path": {
          "type": "string",
          "description": "The target typegraph file path."
        },
        "path": {
          "type": "string",
          "description": "The directory for the generated files."
        },
        "template_dir": {
          "type": "string",
          "description": "The directory containing template files."
        }
      }
    },
    "rustGeneratorConfigBase": {
      "type": "object",
      "properties": {
        "skip_cargo_toml": {
          "type": "boolean",
          "description": "Whether to skip generating the `Cargo.toml` file."
        },
        "skip_lib_rs": {
          "type": "boolean",
          "description": "Whether to skip generating the `lib.rs` file."
        },
        "crate_name": {
          "type": "string",
          "description": "Generated crate name."
        }
      }
    },
    "clientTsGeneratorConfig": {
      "type": "object",
      "properties": {
        "generator": {
          "const": "client_ts",
          "description": "See: <https://metatype.dev/docs/reference/metagen#client_ts>."
        }
      }
    },
    "clientPyGeneratorConfig": {
      "type": "object",
      "properties": {
        "generator": {
          "const": "client_py",
          "description": "See: <https://metatype.dev/docs/reference/metagen#client_py>."
        }
      }
    },
    "clientRsGeneratorConfig": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "generator": {
              "const": "client_rs",
              "description": "See: <https://metatype.dev/docs/reference/metagen#client_rs>."
            }
          }
        },
        {
          "$ref": "#/$defs/rustGeneratorConfigBase"
        }
      ]
    },
    "fdkTsGeneratorConfig": {
      "type": "object",
      "properties": {
        "generator": {
          "const": "fdk_ts",
          "description": "See: <https://metatype.dev/docs/reference/metagen#fdk_ts>."
        },
        "stubbed_runtimes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "exclude_client": {
          "type": "boolean",
          "description": "Whether to generate metagen client code."
        }
      }
    },
    "fdkPyGeneratorConfig": {
      "type": "object",
      "properties": {
        "generator": {
          "const": "fdk_py",
          "description": "See: <https://metatype.dev/docs/reference/metagen#fdk_py>."
        },
        "exclude_client": {
          "type": "boolean",
          "description": "Whether to generate metagen client code."
        }
      }
    },
    "fdkRsGeneratorConfig": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "generator": {
              "const": "fdk_rs",
              "description": "See: <https://metatype.dev/docs/reference/metagen#fdk_rs>."
            },
            "stubbed_runtimes": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "exclude_client": {
              "type": "boolean",
              "description": "Whether to generate metagen client code."
            }
          }
        },
        {
          "$ref": "#/$defs/rustGeneratorConfigBase"
        }
      ]
    },
    "fdkSubGeneratorConfig": {
      "type": "object",
      "properties": {
        "generator": {
          "const": "fdk_substantial"
        }
      }
    },
    "generatorConfig": {
      "allOf": [
        {
          "$ref": "#/$defs/generatorConfigBase"
        },
        {
          "oneOf": [
            {
              "$ref": "#/$defs/clientTsGeneratorConfig"
            },
            {
              "$ref": "#/$defs/clientPyGeneratorConfig"
            },
            {
              "$ref": "#/$defs/clientRsGeneratorConfig"
            },
            {
              "$ref": "#/$defs/fdkTsGeneratorConfig"
            },
            {
              "$ref": "#/$defs/fdkPyGeneratorConfig"
            },
            {
              "$ref": "#/$defs/fdkRsGeneratorConfig"
            },
            {
              "$ref": "#/$defs/fdkSubGeneratorConfig"
            }
          ]
        }
      ]
    }
  },
  "additionalProperties": false
}
