{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$ref": "#/definitions/SchemaApiItem",
  "definitions": {
    "SchemaApiItem": {
      "anyOf": [
        {
          "$ref": "#/definitions/ArcadeApiItem"
        },
        {
          "$ref": "#/definitions/SqlApiItem"
        }
      ],
      "description": "Union of API items that can be used in any sdk schema"
    },
    "ArcadeApiItem": {
      "$ref": "#/definitions/BaseSchemaApiItem<ArcadeApiFunction,ArcadeApiConstant>",
      "description": "Arcade Api Item can be either a constant, a function, or an array of functions"
    },
    "BaseSchemaApiItem<ArcadeApiFunction,ArcadeApiConstant>": {
      "anyOf": [
        {
          "$ref": "#/definitions/ArcadeApiFunction"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ArcadeApiFunction"
          }
        },
        {
          "$ref": "#/definitions/ArcadeApiConstant"
        }
      ],
      "description": "Definition for a constant or a function. An Api Item can be either a constant, a function, or an array of functions"
    },
    "ArcadeApiFunction": {
      "$ref": "#/definitions/BaseSchemaApiFunction<ArcadeBundleType,ArcadeProfileType,ArcadeValueType>",
      "description": "Definition for Arcade Api function"
    },
    "BaseSchemaApiFunction<ArcadeBundleType,ArcadeProfileType,ArcadeValueType>": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the function or constant. Must start with a capital letter.",
          "pattern": "^[A-Z]+[a-zA-Z0-9.]*$"
        },
        "description": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "A nice description for the constant or function. It can leverage Github Flavored Markdown formatting."
        },
        "sinceVersion": {
          "type": "string",
          "description": "Version string. Format x.y.",
          "pattern": "^1\\.\\d+$"
        },
        "disableDocumentation": {
          "type": "boolean",
          "description": "Indicates if the item should not be documented."
        },
        "profiles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ArcadeProfileType"
          },
          "description": "The profiles the constant or the function belongs to."
        },
        "bundle": {
          "$ref": "#/definitions/ArcadeBundleType",
          "description": "The bundle the constant or the function belongs to."
        },
        "image": {
          "type": "string",
          "description": "The relative path to an image to illustate the constant or the function."
        },
        "snippet": {
          "type": "string",
          "description": "The code that will be injected in the classic editor. Must start with a capital letter and match the name of the funtion or constant.",
          "pattern": "^[A-Z]+.*$"
        },
        "examples": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaExample"
          },
          "description": "The collection of examples"
        },
        "resourceLinks": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaResourceLink"
          },
          "description": "A collection of links to resources"
        },
        "isConstant": {
          "type": "boolean",
          "description": "For function this property is optional and always false."
        },
        "parameters": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaProperty<ArcadeValueType>"
          },
          "description": "The set of function parameters."
        },
        "returnValue": {
          "$ref": "#/definitions/SchemaReturnValue<ArcadeValueType>",
          "description": "The type of data returned by the function."
        }
      },
      "additionalProperties": false,
      "required": [
        "bundle",
        "description",
        "name",
        "snippet"
      ],
      "description": "Describes an Api Function."
    },
    "ArcadeProfileType": {
      "type": "string",
      "enum": [
        "Attribute Rule Calculation",
        "Attribute Rules",
        "Dashboard Data",
        "Field Calculation",
        "Form Calculation",
        "GeoAnalytics",
        "Popups",
        "Tasks",
        "Velocity"
      ],
      "description": "The profile names this definition belongs to"
    },
    "ArcadeBundleType": {
      "type": "string",
      "enum": [
        "ai",
        "core",
        "data-access",
        "database",
        "geometry",
        "knowledge-graph",
        "portal-access",
        "track"
      ],
      "description": "Supported function bundles"
    },
    "SchemaExample": {
      "type": "object",
      "properties": {
        "description": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "A description for the example."
        },
        "code": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "Either a single line string or an array of strings."
        }
      },
      "required": [
        "code"
      ],
      "additionalProperties": false,
      "description": "Describes an example"
    },
    "SchemaResourceLink": {
      "type": "object",
      "properties": {
        "linkText": {
          "type": "string",
          "description": "The text used to describe the resource link."
        },
        "url": {
          "type": "string",
          "description": "The url to the resource."
        }
      },
      "required": [
        "linkText",
        "url"
      ],
      "additionalProperties": false,
      "description": "Describes a link to additional resources"
    },
    "SchemaProperty<ArcadeValueType>": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the property.",
          "pattern": "^([a-z]+[a-zA-Z0-9_]*|\\[.*\\])$"
        },
        "type": {
          "anyOf": [
            {
              "$ref": "#/definitions/ArcadeValueType"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/definitions/ArcadeValueType"
              }
            }
          ],
          "description": "The data type of the property value. If the property supports more than one type then use an array."
        },
        "description": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "The description for the property."
        },
        "optional": {
          "type": "boolean",
          "description": "Indicates if the property is optional."
        },
        "properties": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaProperty<ArcadeValueType>"
          },
          "description": "The properties if the type is Dictionary."
        }
      },
      "required": [
        "name",
        "type",
        "description"
      ],
      "additionalProperties": false,
      "description": "Describes the properties for the type Property"
    },
    "ArcadeValueType": {
      "type": "string",
      "enum": [
        "Any",
        "Array<Any>",
        "Array<Attachment>",
        "Array<Boolean>",
        "Array<Date>",
        "Array<DateOnly>",
        "Array<Dictionary>",
        "Array<Extent>",
        "Array<Feature>",
        "Array<Geometry>",
        "Array<KnowledgeGraph>",
        "Array<Multipoint>",
        "Array<Number>",
        "Array<Number|Text>",
        "Array<Point>",
        "Array<Polygon>",
        "Array<Polyline>",
        "Array<Portal>",
        "Array<Text>",
        "Array<Time>",
        "Attachment",
        "Boolean",
        "Date",
        "DateOnly",
        "Dictionary",
        "Extent",
        "Feature",
        "FeatureSet",
        "FeatureSetCollection",
        "Function",
        "Geometry",
        "KnowledgeGraph",
        "Multipoint",
        "Null",
        "Number",
        "Pixel",
        "Point",
        "Polygon",
        "Polyline",
        "Portal",
        "Text",
        "Time",
        "Voxel"
      ]
    },
    "SchemaReturnValue<ArcadeValueType>": {
      "anyOf": [
        {
          "$ref": "#/definitions/SchemaReturnDefinition<ArcadeValueType>"
        },
        {
          "$ref": "#/definitions/ArcadeValueType"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ArcadeValueType"
          }
        }
      ]
    },
    "SchemaReturnDefinition<ArcadeValueType>": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/ArcadeValueType",
          "description": "The data type of the value returned."
        },
        "description": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "A description for for the value returned."
        },
        "properties": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaProperty<ArcadeValueType>"
          },
          "description": "The properties if the type returned is a Dictionary"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "description": "Describes the type fo data returned by a function."
    },
    "ArcadeApiConstant": {
      "$ref": "#/definitions/BaseSchemaApiConstant<ArcadeBundleType,ArcadeProfileType>",
      "description": "Definition for Arcade Api constant"
    },
    "BaseSchemaApiConstant<ArcadeBundleType,ArcadeProfileType>": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the function or constant. Must start with a capital letter.",
          "pattern": "^[A-Z]+[a-zA-Z0-9.]*$"
        },
        "description": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "A nice description for the constant or function. It can leverage Github Flavored Markdown formatting."
        },
        "sinceVersion": {
          "type": "string",
          "description": "Version string. Format x.y.",
          "pattern": "^1\\.\\d+$"
        },
        "disableDocumentation": {
          "type": "boolean",
          "description": "Indicates if the item should not be documented."
        },
        "profiles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/ArcadeProfileType"
          },
          "description": "The profiles the constant or the function belongs to."
        },
        "bundle": {
          "$ref": "#/definitions/ArcadeBundleType",
          "description": "The bundle the constant or the function belongs to."
        },
        "image": {
          "type": "string",
          "description": "The relative path to an image to illustate the constant or the function."
        },
        "snippet": {
          "type": "string",
          "description": "The code that will be injected in the classic editor. Must start with a capital letter and match the name of the funtion or constant.",
          "pattern": "^[A-Z]+.*$"
        },
        "examples": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaExample"
          },
          "description": "The collection of examples"
        },
        "resourceLinks": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaResourceLink"
          },
          "description": "A collection of links to resources"
        },
        "isConstant": {
          "type": "boolean",
          "const": true,
          "description": "For constant, the property is mandatory and always true"
        }
      },
      "required": [
        "bundle",
        "description",
        "isConstant",
        "name",
        "snippet"
      ],
      "additionalProperties": false,
      "description": "Describes an Api Constant"
    },
    "SqlApiItem": {
      "$ref": "#/definitions/BaseSchemaApiItem<SqlApiFunction>",
      "description": "Narrowed api item type for sql. Sql does not have constants so all sql items are \"functions\"."
    },
    "BaseSchemaApiItem<SqlApiFunction>": {
      "anyOf": [
        {
          "$ref": "#/definitions/SqlApiFunction"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SqlApiFunction"
          }
        }
      ],
      "description": "Definition for a constant or a function. An Api Item can be either a constant, a function, or an array of functions"
    },
    "SqlApiFunction": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the function or constant. Must start with a capital letter.",
          "pattern": "^[A-Z]+[a-zA-Z0-9.]*$"
        },
        "isSpecialRegister": {
          "type": "boolean",
          "description": "SQL functions may be \"special registers\" that are not called like regular functions. For example, CURRENT_DATE is a special register. These functions are not called with parentheses or arguments."
        },
        "keywords": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "The name of the keyword."
              },
              "description": {
                "type": "string",
                "description": "The description for the keyword."
              },
              "position": {
                "type": "number",
                "description": "(optional) position of the keyword in the function signature, default is to interlace with parameters"
              }
            },
            "required": [
              "name",
              "description"
            ],
            "additionalProperties": false,
            "description": "Describes a keyword used in a function"
          },
          "description": "The set of keywords that are used in the function."
        },
        "description": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "A nice description for the constant or function. It can leverage Github Flavored Markdown formatting."
        },
        "sinceVersion": {
          "type": "string",
          "description": "Version string. Format x.y.",
          "pattern": "^1\\.\\d+$"
        },
        "disableDocumentation": {
          "type": "boolean",
          "description": "Indicates if the item should not be documented."
        },
        "profiles": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SqlProfileType"
          },
          "description": "The profiles the constant or the function belongs to."
        },
        "bundle": {
          "$ref": "#/definitions/SqlBundleType",
          "description": "The bundle the constant or the function belongs to."
        },
        "image": {
          "type": "string",
          "description": "The relative path to an image to illustate the constant or the function."
        },
        "snippet": {
          "type": "string",
          "description": "The code that will be injected in the classic editor. Must start with a capital letter and match the name of the funtion or constant.",
          "pattern": "^[A-Z]+.*$"
        },
        "examples": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaExample"
          },
          "description": "The collection of examples"
        },
        "resourceLinks": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaResourceLink"
          },
          "description": "A collection of links to resources"
        },
        "isConstant": {
          "type": "boolean",
          "description": "For function this property is optional and always false."
        },
        "parameters": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaProperty<SqlValueType>"
          },
          "description": "The set of function parameters."
        },
        "returnValue": {
          "$ref": "#/definitions/SchemaReturnValue<SqlValueType>",
          "description": "The type of data returned by the function."
        }
      },
      "required": [
        "bundle",
        "description",
        "name",
        "snippet"
      ],
      "description": "Narrowed api function type for sql"
    },
    "SqlProfileType": {
      "type": "string",
      "const": "Field Calculation",
      "description": "Supported sql profile names"
    },
    "SqlBundleType": {
      "type": "string",
      "enum": [
        "date",
        "numeric",
        "string"
      ],
      "description": "Supported function bundles"
    },
    "SchemaProperty<SqlValueType>": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the property.",
          "pattern": "^([a-z]+[a-zA-Z0-9_]*|\\[.*\\])$"
        },
        "type": {
          "anyOf": [
            {
              "$ref": "#/definitions/SqlValueType"
            },
            {
              "type": "array",
              "items": {
                "$ref": "#/definitions/SqlValueType"
              }
            }
          ],
          "description": "The data type of the property value. If the property supports more than one type then use an array."
        },
        "description": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "The description for the property."
        },
        "optional": {
          "type": "boolean",
          "description": "Indicates if the property is optional."
        },
        "properties": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaProperty<SqlValueType>"
          },
          "description": "The properties if the type is Dictionary."
        }
      },
      "required": [
        "name",
        "type",
        "description"
      ],
      "additionalProperties": false,
      "description": "Describes the properties for the type Property"
    },
    "SqlValueType": {
      "type": "string",
      "enum": [
        "Datetime",
        "Number",
        "String"
      ]
    },
    "SchemaReturnValue<SqlValueType>": {
      "anyOf": [
        {
          "$ref": "#/definitions/SchemaReturnDefinition<SqlValueType>"
        },
        {
          "$ref": "#/definitions/SqlValueType"
        },
        {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SqlValueType"
          }
        }
      ]
    },
    "SchemaReturnDefinition<SqlValueType>": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/SqlValueType",
          "description": "The data type of the value returned."
        },
        "description": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            {
              "type": "string"
            }
          ],
          "description": "A description for for the value returned."
        },
        "properties": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/SchemaProperty<SqlValueType>"
          },
          "description": "The properties if the type returned is a Dictionary"
        }
      },
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "description": "Describes the type fo data returned by a function."
    }
  }
}