{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/grepr/json-schema/grepr-template-schema.json",
  "title": "Template",
  "description": "A reusable template for generating a subgraph of a Grepr job graph using Javascript. Templates allow users to define parameterized pipeline components that can be instantiated with specific configuration.",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/grepr-openapi.json#/components/schemas/Template",
  "properties": {
    "builtIn": {
      "description": "Read-only property indicating whether this template is a built-in, non-editable template.",
      "readOnly": true,
      "type": "boolean"
    },
    "description": {
      "description": "Description of the template.",
      "type": "string"
    },
    "draftOutputs": {
      "default": [],
      "description": "List of additional outputs that will be added to the graph when running in draft mode.",
      "items": {
        "$ref": "#/$defs/TemplateDraftOutput"
      },
      "type": "array"
    },
    "id": {
      "description": "Unique identifier for the template.",
      "type": "string"
    },
    "inputSchema": {
      "additionalProperties": {
        "description": "JSONSchema (https://json-schema.org/draft/2020-12) for validating the inputs to the template. Make sure you make this validation forwards/backwards compatible to ensure that the template version can be upgraded and rolled back.",
        "type": "object"
      },
      "default": {},
      "description": "JSONSchema (https://json-schema.org/draft/2020-12) for validating the inputs to the template. Make sure you make this validation forwards/backwards compatible to ensure that the template version can be upgraded and rolled back.",
      "type": "object"
    },
    "inputs": {
      "additionalProperties": {
        "description": "Map of input names used in a parent subgraph that uses a TemplateOperation to their internal connections within the subgraph. Can be missing if there are no inputs to the subgraph",
        "type": "string"
      },
      "default": {},
      "description": "Map of input names used in a parent subgraph that uses a TemplateOperation to their internal connections within the subgraph. Can be missing if there are no inputs to the subgraph",
      "type": "object"
    },
    "isLatest": {
      "default": true,
      "type": "boolean",
      "writeOnly": true
    },
    "latest": {
      "type": "boolean"
    },
    "name": {
      "description": "Name of the template.",
      "type": "string"
    },
    "organizationId": {
      "description": "Organization ID to which the template belongs. This is null for built-in templates.",
      "type": "string"
    },
    "outputs": {
      "additionalProperties": {
        "description": "Map of output names used in a parent subgraph that uses a TemplateOperation to their internal connections within the subgraph. Can be missing if there are no outputs from the subgraph",
        "type": "string"
      },
      "default": {},
      "description": "Map of output names used in a parent subgraph that uses a TemplateOperation to their internal connections within the subgraph. Can be missing if there are no outputs from the subgraph",
      "type": "object"
    },
    "sourceHash": {
      "description": "SHA-256 hash of template source and all dependencies (utils, types, build config, package versions). Used to track when template dependencies change and avoid unnecessary updates.",
      "type": "string"
    },
    "teamIds": {
      "default": [],
      "description": "Set of team IDs that can use this template.",
      "items": {
        "description": "Set of team IDs that can use this template.",
        "type": "string"
      },
      "type": "array",
      "uniqueItems": true
    },
    "template": {
      "description": "A javascript string that generates the JSON for the job subgraph. It will receive as input a User object and the inputs provided via the operation when it is getting resolved into a subgraph.",
      "type": "string"
    },
    "version": {
      "description": "Version of the template.",
      "format": "int32",
      "type": "integer"
    }
  },
  "required": [
    "name",
    "template",
    "version"
  ],
  "type": "object",
  "x-type": {
    "type": "job-template"
  },
  "$defs": {
    "TemplateDraftOutput": {
      "description": "Describes an additional output that will be added to the job graph when running a template in draft mode.",
      "properties": {
        "name": {
          "description": "Name of the draft output.",
          "type": "string"
        },
        "tagKey": {
          "description": "Tag key that will be added to the draft output.",
          "type": "string"
        },
        "tagValue": {
          "description": "Tag value that will be added to the draft output.",
          "type": "string"
        }
      },
      "type": "object"
    }
  }
}