{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "google-data-studio-connector-schema.json",
  "title": "Looker Studio Community Connector",
  "description": "Defines the structure and interface for a Looker Studio Community Connector built with Google Apps Script. Community Connectors enable direct connections from Looker Studio to any internet-accessible data source by implementing getAuthType, getConfig, getSchema, and getData functions.",
  "type": "object",
  "properties": {
    "authType": {
      "$ref": "#/$defs/AuthTypeResponse"
    },
    "config": {
      "$ref": "#/$defs/ConfigResponse"
    },
    "schema": {
      "$ref": "#/$defs/SchemaResponse"
    },
    "data": {
      "$ref": "#/$defs/DataResponse"
    }
  },
  "$defs": {
    "AuthTypeResponse": {
      "type": "object",
      "description": "Response from getAuthType() specifying the authentication method used by the connector.",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "The authentication type used by the connector.",
          "enum": [
            "NONE",
            "OAUTH2",
            "KEY",
            "USER_PASS",
            "USER_TOKEN",
            "PATH_USER_PASS",
            "PATH_KEY"
          ]
        },
        "helpUrl": {
          "type": "string",
          "description": "Optional documentation URL. Available for USER_TOKEN, USER_PASS, KEY, PATH_USER_PASS, and PATH_KEY auth types.",
          "format": "uri"
        }
      },
      "additionalProperties": false
    },
    "ConfigResponse": {
      "type": "object",
      "description": "Response from getConfig() defining user-configurable options for the connector.",
      "properties": {
        "configParams": {
          "type": "array",
          "description": "Array of configuration parameters presented to the user.",
          "items": {
            "$ref": "#/$defs/ConfigParam"
          }
        },
        "dateRangeRequired": {
          "type": "boolean",
          "description": "Whether date range filtering applies to this connector."
        },
        "isSteppedConfig": {
          "type": "boolean",
          "description": "Whether to prompt users step-by-step for configuration values."
        }
      },
      "additionalProperties": false
    },
    "ConfigParam": {
      "type": "object",
      "description": "A single configuration parameter for the connector.",
      "required": [
        "type",
        "name"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "The type of configuration control to display.",
          "enum": [
            "TEXTINPUT",
            "TEXTAREA",
            "SELECT_SINGLE",
            "SELECT_MULTIPLE",
            "CHECKBOX",
            "INFO"
          ]
        },
        "name": {
          "type": "string",
          "description": "Unique field identifier. Must be alphanumeric with no spaces.",
          "pattern": "^[a-zA-Z0-9_]+$"
        },
        "displayName": {
          "type": "string",
          "description": "Label text displayed in the configuration UI."
        },
        "helpText": {
          "type": "string",
          "description": "Additional guidance text shown to the user."
        },
        "placeholder": {
          "type": "string",
          "description": "Hint text displayed in the input field. Only applicable for TEXTINPUT and TEXTAREA types."
        },
        "isDynamic": {
          "type": "boolean",
          "description": "Whether this field dynamically populates based on other configuration values."
        },
        "parameterControl": {
          "type": "object",
          "description": "Control settings for parameter override behavior.",
          "properties": {
            "allowOverride": {
              "type": "boolean",
              "description": "Whether this parameter can be overridden in reports."
            }
          },
          "additionalProperties": false
        },
        "options": {
          "type": "array",
          "description": "Available options for SELECT_SINGLE and SELECT_MULTIPLE types.",
          "items": {
            "type": "object",
            "properties": {
              "label": {
                "type": "string",
                "description": "Display label for the option."
              },
              "value": {
                "type": "string",
                "description": "Value submitted when the option is selected."
              }
            },
            "required": [
              "label",
              "value"
            ],
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "SchemaResponse": {
      "type": "object",
      "description": "Response from getSchema() defining the data structure of the connector.",
      "properties": {
        "schema": {
          "type": "array",
          "description": "Array of field definitions describing the connector's data structure.",
          "items": {
            "$ref": "#/$defs/Field"
          }
        }
      },
      "required": [
        "schema"
      ],
      "additionalProperties": false
    },
    "Field": {
      "type": "object",
      "description": "A field definition describing a column in the connector's data schema.",
      "required": [
        "name",
        "dataType"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "Unique identifier for the field."
        },
        "label": {
          "type": "string",
          "description": "Display name shown in the Looker Studio UI."
        },
        "description": {
          "type": "string",
          "description": "Plain text description of the field."
        },
        "dataType": {
          "type": "string",
          "description": "The data type of the field values.",
          "enum": [
            "STRING",
            "NUMBER",
            "BOOLEAN"
          ]
        },
        "isHidden": {
          "type": "boolean",
          "description": "Whether the field is hidden from users. Formula fields cannot be hidden."
        },
        "group": {
          "type": "string",
          "description": "Field grouping category for organizational purposes."
        },
        "formula": {
          "type": "string",
          "description": "Calculated field definition formula."
        },
        "isDefault": {
          "type": "boolean",
          "description": "Whether this is a default dimension or metric."
        },
        "defaultAggregationType": {
          "type": "string",
          "description": "Default aggregation applied to the field.",
          "enum": [
            "AVG",
            "COUNT",
            "COUNT_DISTINCT",
            "MAX",
            "MIN",
            "SUM",
            "NONE",
            "AUTO"
          ]
        },
        "semantics": {
          "$ref": "#/$defs/FieldSemantics"
        }
      },
      "additionalProperties": false
    },
    "FieldSemantics": {
      "type": "object",
      "description": "Semantic type information for a field, defining how Looker Studio interprets and displays the data.",
      "properties": {
        "conceptType": {
          "type": "string",
          "description": "Whether the field is a dimension or metric.",
          "enum": [
            "DIMENSION",
            "METRIC"
          ]
        },
        "semanticType": {
          "type": "string",
          "description": "The semantic type controlling display formatting and behavior.",
          "enum": [
            "YEAR",
            "YEAR_QUARTER",
            "YEAR_MONTH",
            "YEAR_WEEK",
            "YEAR_MONTH_DAY",
            "YEAR_MONTH_DAY_HOUR",
            "YEAR_MONTH_DAY_SECOND",
            "QUARTER",
            "MONTH",
            "WEEK",
            "MONTH_DAY",
            "DAY_OF_WEEK",
            "DAY",
            "HOUR",
            "MINUTE",
            "COUNTRY",
            "COUNTRY_CODE",
            "CONTINENT",
            "CONTINENT_CODE",
            "SUB_CONTINENT",
            "SUB_CONTINENT_CODE",
            "REGION",
            "REGION_CODE",
            "CITY",
            "CITY_CODE",
            "METRO_CODE",
            "LATITUDE_LONGITUDE",
            "NUMBER",
            "PERCENT",
            "TEXT",
            "BOOLEAN",
            "URL",
            "HYPERLINK",
            "IMAGE",
            "IMAGELINK",
            "CURRENCY_AED",
            "CURRENCY_ALL",
            "CURRENCY_ARS",
            "CURRENCY_AUD",
            "CURRENCY_BDT",
            "CURRENCY_BGN",
            "CURRENCY_BOB",
            "CURRENCY_BRL",
            "CURRENCY_CAD",
            "CURRENCY_CDF",
            "CURRENCY_CHF",
            "CURRENCY_CLP",
            "CURRENCY_CNY",
            "CURRENCY_COP",
            "CURRENCY_CRC",
            "CURRENCY_CZK",
            "CURRENCY_DKK",
            "CURRENCY_DOP",
            "CURRENCY_EGP",
            "CURRENCY_ETB",
            "CURRENCY_EUR",
            "CURRENCY_GBP",
            "CURRENCY_HKD",
            "CURRENCY_HRK",
            "CURRENCY_HUF",
            "CURRENCY_IDR",
            "CURRENCY_ILS",
            "CURRENCY_INR",
            "CURRENCY_IRR",
            "CURRENCY_ISK",
            "CURRENCY_JMD",
            "CURRENCY_JPY",
            "CURRENCY_KRW",
            "CURRENCY_LKR",
            "CURRENCY_LTL",
            "CURRENCY_MNT",
            "CURRENCY_MVR",
            "CURRENCY_MXN",
            "CURRENCY_MYR",
            "CURRENCY_NGN",
            "CURRENCY_NOK",
            "CURRENCY_NZD",
            "CURRENCY_PAB",
            "CURRENCY_PEN",
            "CURRENCY_PHP",
            "CURRENCY_PKR",
            "CURRENCY_PLN",
            "CURRENCY_RON",
            "CURRENCY_RSD",
            "CURRENCY_RUB",
            "CURRENCY_SAR",
            "CURRENCY_SEK",
            "CURRENCY_SGD",
            "CURRENCY_THB",
            "CURRENCY_TRY",
            "CURRENCY_TWD",
            "CURRENCY_TZS",
            "CURRENCY_UAH",
            "CURRENCY_USD",
            "CURRENCY_UYU",
            "CURRENCY_VEF",
            "CURRENCY_VND",
            "CURRENCY_ZAR"
          ]
        },
        "semanticGroup": {
          "type": "string",
          "description": "Suggested grouping for the semantic type.",
          "enum": [
            "NUMERIC",
            "DATETIME",
            "GEO",
            "CURRENCY"
          ]
        },
        "isReaggregatable": {
          "type": "boolean",
          "description": "Whether the field supports re-aggregation in Looker Studio."
        }
      },
      "additionalProperties": false
    },
    "DataResponse": {
      "type": "object",
      "description": "Response from getData() containing tabular data matching the request parameters.",
      "required": [
        "schema",
        "rows"
      ],
      "properties": {
        "schema": {
          "type": "array",
          "description": "Array of field objects describing the returned data columns.",
          "items": {
            "type": "object",
            "required": [
              "name",
              "dataType"
            ],
            "properties": {
              "name": {
                "type": "string",
                "description": "Field identifier matching the requested field name."
              },
              "dataType": {
                "type": "string",
                "description": "Data type of the field.",
                "enum": [
                  "STRING",
                  "NUMBER",
                  "BOOLEAN"
                ]
              }
            },
            "additionalProperties": false
          }
        },
        "rows": {
          "type": "array",
          "description": "Array of data rows. Maximum 1 million rows per response.",
          "items": {
            "type": "object",
            "properties": {
              "values": {
                "type": "array",
                "description": "Array of values corresponding to the schema fields.",
                "items": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "boolean"
                    }
                  ]
                }
              }
            },
            "required": [
              "values"
            ],
            "additionalProperties": false
          }
        },
        "filtersApplied": {
          "type": "boolean",
          "description": "Whether all requested filters were successfully applied."
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
