{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://schema.yext.com/config/streams/streams-endpoint",
  "$version": "3",
  "type": "object",
  "title": "Streams Endpoint",
  "properties": {
    "$id": {
      "type": "string",
      "minLength": 1,
      "maxLength": 64
    },
    "$schema": {
      "const": "https://schema.yext.com/config/streams/streams-endpoint/v3"
    },
    "name": {
      "type": "string",
      "description": "The name of the streams endpoint."
    },
    "stream": {
      "type": "object",
      "description": "Properties required to configure the data stream for this endpoint.",
      "properties": {
        "source": {
          "type": "string",
          "enum": [
            "knowledgeGraph",
            "reviews",
            "reviewsAgg"
          ],
          "description": "The source of data to stream."
        },
        "fields": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The subset of fields and projections from the source data that should be streamed."
        },
        "filter": {
          "anyOf": [
            {
              "$ref": "#/definitions/filters/kg"
            },
            {
              "$ref": "#/definitions/filters/publishers"
            }
          ]
        },
        "transform": {
          "type": "object",
          "properties": {
            "expandOptionFields": {
              "type": "array",
              "description": "The option fields that need to be expanded to include the display fields, numeric values, and selected boolean.",
              "items": {
                "type": "string",
                "description": "The option field name"
              }
            },
            "replaceOptionValuesWithDisplayNames": {
              "type": "array",
              "description": "The option fields that need to be replaced with their display names.",
              "items": {
                "type": "string",
                "description": "The option field name"
              }
            }
          },
          "description": "The transforms that need to be applied to documents before they are produced."
        },
        "localization": {
          "type": "object",
          "properties": {
            "locales": {
              "type": "array",
              "description": "The list of additional locales to include in the endpoint.",
              "items": {
                "type": "string",
                "description": "Valid BCP-47 locale identifiers."
              }
            },
            "excludePrimary": {
              "type": "boolean",
              "default": false,
              "description": "Determines whether primary profiles should be excluded from the endpoint."
            }
          },
          "additionalProperties": false
        },
        "compatibilityFlags": {
          "type": "object",
          "properties": {
            "lowercasePublisher": {
              "type": "boolean",
              "default": false,
              "description": "Determines whether the publisher fields should be transformed to lowercase"
            }
          },
          "additionalProperties": false
        },
        "includeCertifiedFacts": {
          "type": "boolean",
          "default": false,
          "description": "Determines whether Certified-Fact credentials should be generated for this endpoint."
        }
      }
    },
    "fieldIndexes": {
      "type": "array",
      "description": "The field indexes for this endpoint.",
      "items": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string",
            "description": "The name of the field to be indexed."
          }
        },
        "required": [
          "field"
        ],
        "additionalProperties": false
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "$id",
    "$schema",
    "stream"
  ],
  "definitions": {
    "filters": {
      "kg": {
        "type": "object",
        "properties": {
          "entityIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Entity IDs to allow."
          },
          "entityTypes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Entity type IDs to allow."
          },
          "savedFilterIds": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "IDs of the saved filters to apply on entities."
          }
        },
        "description": "Filter configuration for knowledgeGraph.",
        "additionalProperties": false
      },
      "publishers": {
        "type": "object",
        "properties": {
          "publishers": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Publisher IDs to allow."
          }
        },
        "additionalProperties": false
      }
    }
  }
}
