{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://extensions.shopifycdn.com/shopifycloud/schemas/v1/intent.json",
  "title": "Intent Schema",
  "description": "Defines the input and output data structures for an intent. Describes the shape of the `value` and `data` parameters for `intents.invoke({ value, data })`, and the expected structure of the intent's success response.",
  "type": "object",
  "additionalProperties": false,
  "required": ["inputSchema"],
  "properties": {
    "value": {
      "$ref": "#/$defs/valueSchema"
    },
    "inputSchema": {
      "$ref": "#/$defs/inputSchema"
    },
    "outputSchema": {
      "$ref": "#/$defs/outputSchema"
    }
  },
  "$defs": {
    "mapTo": {
      "title": "Map To",
      "description": "Specifies how this field's value is transported when constructing the intent request.",
      "type": "string",
      "enum": ["param", "form_data", "query_param", "hash"]
    },

    "fieldName": {
      "title": "Field Name",
      "description": "The target field name at the destination specified by `mapTo`. If omitted, the property key from the schema is used.",
      "type": "string"
    },

    "valueSchema": {
      "title": "Value Schema",
      "description": "A JSON Schema definition (of any type) describing the primary identifier for the resource being acted on by the intent. Defines the expected shape of the `value` parameter in `intents.invoke({ value: … })`. Supports optional `mapTo` and `fieldName` custom keywords to control how the value is mapped in the intent request.",
      "type": "object",
      "properties": {
        "mapTo": { "$ref": "#/$defs/mapTo" },
        "fieldName": { "$ref": "#/$defs/fieldName" }
      }
    },

    "inputSchema": {
      "title": "Input Schema",
      "description": "A JSON Schema of type `object` describing the additional input data for the intent. Defines the expected shape of the `data` parameter in `intents.invoke({ data: { … } })`. Each property is a JSON Schema definition that supports optional `mapTo` and `fieldName` custom keywords to control how each field is mapped in the intent request.",
      "type": "object",
      "properties": {
        "$ref": {
          "type": "string",
          "description": "A reference to the schema for this intent's resource type.",
          "pattern": "/application/[a-z-]+\\.json$"
        },
        "type": {
          "const": "object",
          "description": "Must be `object`. The input schema always describes a JSON object."
        },
        "properties": {
          "type": "object",
          "description": "Defines the individual fields of the intent's input data.",
          "additionalProperties": {
            "type": "object",
            "properties": {
              "mapTo": { "$ref": "#/$defs/mapTo" },
              "fieldName": { "$ref": "#/$defs/fieldName" }
            }
          }
        }
      },
      "required": ["$ref", "type"]
    },
    "outputSchema": {
      "title": "Output Schema",
      "description": "A JSON Schema of type `object` describing the data returned in the `data` property of the intent's success response.",
      "type": "object",
      "properties": {
        "type": {
          "const": "object",
          "description": "Must be `object`. The output schema always describes a JSON object."
        },
        "properties": {
          "type": "object",
          "description": "Defines the fields included in the intent's success response data.",
          "additionalProperties": {
            "type": "object"
          }
        }
      },
      "required": ["type"]
    }
  }
}
