/**
 * Creates a [WhereClause](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-sql-WhereClause.html) expression that adheres to standardized SQL expressions.
 * SQL expression is a combination of one or more values, operators and SQL functions that
 * results in to a value.
 *
 * @since 4.14
 * @see [Standardized SQL functions in ArcGIS Online](https://doc.arcgis.com/en/arcgis-online/reference/sql-agol.htm)
 */
import type WhereClause from "./sql/WhereClause.js";
import type FieldsIndex from "../layers/support/FieldsIndex.js";

/**
 * Parses the given where clause string and returns an instance of [WhereClause](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-sql-WhereClause.html) when resolved.
 * The `WhereClause` object can be used repeatedly against different features, to test if they individually meet the condition.
 * The parser does not parse a whole SQL statement (ie. `SELECT X… WHERE…`). It only parses the expression after the
 * `where` token.
 *
 * @param clause - The SQL where clause expression.
 * @param fieldsIndex - The [fields index](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#fieldsIndex)
 * of the layer. The fields index is used to match the fields found in the where clause against the service, to fix casing for example.
 * @returns Parses a string where clause and returns a promise that resolves to
 * an object with the [WhereClause](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-sql-WhereClause.html) specification.
 * @example
 * sql.parseWhereClause("POPULATION > 100000", layer.fieldsIndex)
 * .then(function(clause){
 *   let testResult = clause.testFeature(
 *     new Graphic({
 *       attributes: {
 *         POPULATION: 300000
 *       }
 *     })
 *   );
 *   console.log(testResult); // prints true
 * });
 * @example
 * sql.parseWhereClause(
 *   "START_TIME BETWEEN TIMESTAMP '2023-01-01 00:00:00' AND TIMESTAMP '2023-12-31 23:59:59'",
 *   layer.fieldsIndex
 * )
 * .then(function(clause){
 *   const utcDate = Date.UTC(2023, 0, 1, 0, 0, 0);
 *   let testResult = clause.testFeature(
 *     new Graphic({
 *       attributes: {
 *         START_TIME: utcDate
 *       }
 *     })
 *   );
 *   console.log(testResult); // true
 * });
 */
export function parseWhereClause(clause: string, fieldsIndex: FieldsIndex | null | undefined): Promise<WhereClause>;

/**
 * Builds an SQL IN clause for the given field and list of values. Returns null if no values are provided.
 *
 * @param fieldName - The name of the field on the table.
 * @param values - The value of the field.
 */
export function sqlIn(fieldName: string, values: (string | number)[]): string | null | undefined;