{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/railhook-io/json-schema/railhook-io-transform-preview-response-schema.json",
  "title": "TransformPreviewResponse",
  "description": "What the transformation produced, and what it said while producing it",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/railhook-io-openapi.yml#/components/schemas/TransformPreviewResponse",
  "type": "object",
  "properties": {
    "outputPayload": {
      "type": "string",
      "description": "The body that would be sent, pretty-printed. Null when the run failed or the script cancelled the delivery."
    },
    "outputHeaders": {
      "type": "string",
      "description": "The headers that would be sent, as a JSON object: the ones you supplied, with anything the script set merged over them"
    },
    "success": {
      "type": "boolean",
      "description": "Whether the run produced a payload"
    },
    "errors": {
      "type": "array",
      "description": "What went wrong, in the order it went wrong",
      "items": {
        "type": "string"
      }
    },
    "kind": {
      "type": "string",
      "description": "The language that actually ran",
      "enum": [
        "TEMPLATE",
        "JAVASCRIPT"
      ]
    },
    "console": {
      "type": "array",
      "description": "Everything the script logged, oldest first. Always empty for a template, which has no console.",
      "items": {
        "$ref": "#/$defs/ConsoleLine"
      }
    },
    "consoleTruncated": {
      "type": "boolean",
      "description": "True when the script logged more lines than the deployment keeps"
    },
    "cancelled": {
      "type": "boolean",
      "description": "True when the script asked for the delivery to be dropped"
    },
    "cancelReason": {
      "type": "string",
      "description": "Why the script cancelled, as the script stated it"
    },
    "durationMs": {
      "type": "integer",
      "format": "int64",
      "description": "Wall clock spent inside the script, in milliseconds"
    },
    "errorLine": {
      "type": "integer",
      "format": "int32",
      "description": "The line in the script the failure came from, 1-based, or null when the failure has no location"
    },
    "errorReason": {
      "type": "string",
      "description": "Why the run produced nothing, as a value rather than as prose: SYNTAX, CONTRACT, RUNTIME, TIMEOUT, MEMORY, OUTPUT_TOO_LARGE, SOURCE_TOO_LARGE or UNAVAILABLE. Null when the run succeeded. A client shows its own wording for these; `errors` carries the engine's, in English.",
      "enum": [
        "SYNTAX",
        "CONTRACT",
        "RUNTIME",
        "TIMEOUT",
        "MEMORY",
        "OUTPUT_TOO_LARGE",
        "SOURCE_TOO_LARGE",
        "UNAVAILABLE"
      ]
    }
  },
  "$defs": {
    "ConsoleLine": {
      "type": "object",
      "description": "One console.* call a script made",
      "properties": {
        "level": {
          "type": "string",
          "description": "log, info, warn, error or debug"
        },
        "message": {
          "type": "string",
          "description": "The arguments, already formatted"
        }
      }
    }
  }
}