/**
 * MySQL Node - Version 2
 * Get, add and update data in MySQL
 */


export interface MySqlV2Params {
  resource?: unknown;
/**
 * Operation
 * @displayOptions.show { resource: ["database"] }
 * @default insert
 */
    operation?: 'deleteTable' | 'executeQuery' | 'insert' | 'upsert' | 'select' | 'update';
/**
 * The table you want to work on
 * @displayOptions.hide { operation: ["executeQuery"] }
 * @default {"mode":"list","value":""}
 */
    table?: { __rl: true; mode: 'list' | 'name'; value: string; cachedResultName?: string };
/**
 * Command
 * @displayOptions.show { resource: ["database"], operation: ["deleteTable"] }
 * @displayOptions.hide { table: [""] }
 * @default truncate
 */
    deleteCommand?: 'truncate' | 'delete' | 'drop' | Expression<string>;
/**
 * If not set, all rows will be selected
 * @displayOptions.show { deleteCommand: ["delete"], resource: ["database"], operation: ["deleteTable"] }
 * @displayOptions.hide { table: [""] }
 * @default {}
 */
    where?: {
        /** Values
     */
    values?: Array<{
      /** Choose from the list, or specify an ID using an &lt;a href="https://docs.n8n.io/code/expressions/" target="_blank"&gt;expression&lt;/a&gt;
       */
      column?: string | Expression<string>;
      /** The operator to check the column against. When using 'LIKE' operator percent sign ( %) matches zero or more characters, underscore ( _ ) matches any single character.
       * @default equal
       */
      condition?: 'equal' | '!=' | 'LIKE' | '>' | '<' | '>=' | '<=' | 'IS NULL' | 'IS NOT NULL' | Expression<string>;
      /** Value
       * @displayOptions.hide { condition: ["IS NULL", "IS NOT NULL"] }
       */
      value?: string | Expression<string> | PlaceholderValue;
    }>;
  };
/**
 * How to combine the conditions defined in "Select Rows": AND requires all conditions to be true, OR requires at least one condition to be true
 * @displayOptions.show { deleteCommand: ["delete"], resource: ["database"], operation: ["deleteTable"] }
 * @displayOptions.hide { table: [""] }
 * @default AND
 */
    combineConditions?: 'AND' | 'OR' | Expression<string>;
/**
 * Options
 * @displayOptions.show { resource: ["database"], operation: ["deleteTable"] }
 * @displayOptions.hide { table: [""] }
 * @default {}
 */
    options?: {
    /** Number of milliseconds reserved for connecting to the database
     * @default 30
     */
    connectionTimeoutMillis?: number | Expression<number>;
    /** Maximum amount of connections to the database, setting high value can lead to performance issues and potential database crashes
     * @default 10
     */
    connectionLimit?: number | Expression<number>;
    /** The way queries should be sent to the database
     * @default single
     */
    queryBatching?: 'single' | 'independently' | 'transaction';
    /** Comma-separated list of the values you want to use as query parameters. You can drag the values from the input panel on the left. &lt;a href="https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.mysql/" target="_blank"&gt;More info&lt;/a&gt;
     * @hint Comma-separated list of values: reference them in your query as $1, $2, $3…
     * @displayOptions.show { /operation: ["executeQuery"] }
     */
    queryReplacement?: string | Expression<string> | PlaceholderValue;
    /** Choose from the list, or specify IDs using an &lt;a href="https://docs.n8n.io/code/expressions/" target="_blank"&gt;expression&lt;/a&gt;
     * @displayOptions.show { /operation: ["select"] }
     * @default []
     */
    outputColumns?: string[];
    /** Output Large-Format Numbers As
     * @hint Applies to NUMERIC and BIGINT columns only
     * @displayOptions.show { /operation: ["select", "executeQuery"] }
     * @default text
     */
    largeNumbersOutput?: 'numbers' | 'text' | Expression<string>;
    /** Whether to output DECIMAL types as numbers instead of strings
     * @displayOptions.show { /operation: ["select", "executeQuery"] }
     * @default false
     */
    decimalNumbers?: boolean | Expression<boolean>;
    /** Ignore any ignorable errors that occur while executing the INSERT statement
     * @displayOptions.show { /operation: ["insert"] }
     * @default LOW_PRIORITY
     */
    priority?: 'LOW_PRIORITY' | 'HIGH_PRIORITY' | Expression<string>;
    /** Whether to replace empty strings with NULL in input, could be useful when data come from spreadsheet
     * @displayOptions.show { /operation: ["insert", "update", "upsert", "executeQuery"] }
     * @default false
     */
    replaceEmptyStrings?: boolean | Expression<boolean>;
    /** Whether to remove these duplicate rows
     * @displayOptions.show { /operation: ["select"] }
     * @default false
     */
    selectDistinct?: boolean | Expression<boolean>;
    /** Whether to show in output details of the ofexecuted query for each statement, or just confirmation of success
     * @default false
     */
    detailedOutput?: boolean | Expression<boolean>;
    /** Whether to skip the row and do not throw error if a unique constraint or exclusion constraint is violated
     * @displayOptions.show { /operation: ["insert"] }
     * @default false
     */
    skipOnConflict?: boolean | Expression<boolean>;
  };
/**
 * The SQL query to execute. You can use n8n expressions and $1, $2, $3, etc to refer to the 'Query Parameters' set in options below.
 * @hint Consider using query parameters to prevent SQL injection attacks. Add them in the options below
 * @displayOptions.show { resource: ["database"], operation: ["executeQuery"] }
 */
    query?: string;
/**
 * Whether to map node input properties and the table data automatically or manually
 * @displayOptions.show { resource: ["database"], operation: ["insert"] }
 * @displayOptions.hide { table: [""] }
 * @default autoMapInputData
 */
    dataMode?: 'autoMapInputData' | 'defineBelow' | Expression<string>;
/**
 * Values to Send
 * @displayOptions.show { dataMode: ["defineBelow"], resource: ["database"], operation: ["insert"] }
 * @displayOptions.hide { table: [""] }
 * @default {}
 */
    valuesToSend?: {
        /** Values
     */
    values?: Array<{
      /** Choose from the list, or specify an ID using an &lt;a href="https://docs.n8n.io/code/expressions/" target="_blank"&gt;expression&lt;/a&gt;
       * @default []
       */
      column?: string | Expression<string>;
      /** Value
       */
      value?: string | Expression<string> | PlaceholderValue;
    }>;
  };
/**
 * Whether to return all results or only up to a given limit
 * @displayOptions.show { resource: ["database"], operation: ["select"] }
 * @displayOptions.hide { table: [""] }
 * @default false
 */
    returnAll?: boolean | Expression<boolean>;
/**
 * Max number of results to return
 * @displayOptions.show { returnAll: [false], resource: ["database"], operation: ["select"] }
 * @displayOptions.hide { table: [""] }
 * @default 50
 */
    limit?: number | Expression<number>;
/**
 * Sort
 * @displayOptions.show { resource: ["database"], operation: ["select"] }
 * @displayOptions.hide { table: [""] }
 * @default {}
 */
    sort?: {
        /** Values
     */
    values?: Array<{
      /** Choose from the list, or specify an ID using an &lt;a href="https://docs.n8n.io/code/expressions/" target="_blank"&gt;expression&lt;/a&gt;
       */
      column?: string | Expression<string>;
      /** Direction
       * @default ASC
       */
      direction?: 'ASC' | 'DESC' | Expression<string>;
    }>;
  };
/**
 * Choose from the list, or specify an ID using an &lt;a href="https://docs.n8n.io/code/expressions/" target="_blank"&gt;expression&lt;/a&gt;
 * @hint Used to find the correct row to update. Doesn't get changed.
 * @displayOptions.show { resource: ["database"], operation: ["update"] }
 * @displayOptions.hide { table: [""] }
 */
    columnToMatchOn?: string | Expression<string>;
/**
 * Rows with a value in the specified "Column to Match On" that corresponds to the value in this field will be updated
 * @displayOptions.show { dataMode: ["defineBelow"], resource: ["database"], operation: ["update"] }
 * @displayOptions.hide { table: [""] }
 */
    valueToMatchOn?: string | Expression<string> | PlaceholderValue;
}

export interface MySqlV2Credentials {
  mySql: CredentialReference;
}

interface MySqlV2NodeBase {
  type: 'n8n-nodes-base.mySql';
  version: 2;
  credentials?: MySqlV2Credentials;
}

export type MySqlV2ParamsNode = MySqlV2NodeBase & {
  config: NodeConfig<MySqlV2Params>;
};

export type MySqlV2Node = MySqlV2ParamsNode;