Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

38.9 KB
Raw Blame
export const AP_FUNCTIONS: ApFunction[] = [
    {
        name: 'combine',
        category: 'text',
        description: 'Joins two or more values into one piece of text.',
        syntax: 'combine(text1; text2; separator)',
        example: 'combine( John ; Smith ; " " )',
        exampleResult: 'John Smith',
        minArgs: 2,
        maxArgs: 3,
        argTypes: ['string', 'string', 'string'],
        returnType: 'string',
    },
    {
        name: 'uppercase',
        category: 'text',
        description: 'Changes all characters to uppercase.',
        syntax: 'uppercase(text)',
        example: 'uppercase( acme inc )',
        exampleResult: 'ACME INC',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'lowercase',
        category: 'text',
        description: 'Changes all characters to lowercase.',
        syntax: 'lowercase(text)',
        example: 'lowercase( [email protected] )',
        exampleResult: '[email protected]',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'titlecase',
        category: 'text',
        description: 'Capitalizes the first letter of every word.',
        syntax: 'titlecase(text)',
        example: 'titlecase( john smith )',
        exampleResult: 'John Smith',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'trim',
        category: 'text',
        description: 'Removes space characters at the start and end.',
        syntax: 'trim(text)',
        example: 'trim(  Hello World  )',
        exampleResult: 'Hello World',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'prefix',
        category: 'text',
        description: 'Adds text before a value.',
        syntax: 'prefix(text; value)',
        example: 'prefix( 10042 ; ORD- )',
        exampleResult: 'ORD-10042',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'string'],
        returnType: 'string',
    },
    {
        name: 'suffix',
        category: 'text',
        description: 'Adds text after a value.',
        syntax: 'suffix(text; value)',
        example: 'suffix( Acme ;  Ltd. )',
        exampleResult: 'Acme Ltd.',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'string'],
        returnType: 'string',
    },
    {
        name: 'replace',
        category: 'text',
        description: 'Finds a word or character and swaps it for another.',
        syntax: 'replace(text; find; with)',
        example: 'replace( first_name ; "_"; " " )',
        exampleResult: 'first name',
        minArgs: 3,
        maxArgs: 3,
        argTypes: ['string', 'string', 'string'],
        returnType: 'string',
    },
    {
        name: 'remove',
        category: 'text',
        description: 'Deletes every occurrence of a character or word.',
        syntax: 'remove(text; value)',
        example: 'remove( 004-420-712 ; "-" )',
        exampleResult: '004420712',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'string'],
        returnType: 'string',
    },
    {
        name: 'first_n',
        category: 'text',
        description: 'Returns only the first N characters.',
        syntax: 'first_n(text; n)',
        example: 'first_n( Jonathan ; 3 )',
        exampleResult: 'Jon',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'number'],
        returnType: 'string',
    },
    {
        name: 'last_n',
        category: 'text',
        description: 'Returns only the last N characters.',
        syntax: 'last_n(text; n)',
        example: 'last_n( ACC-7890 ; 4 )',
        exampleResult: '7890',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'number'],
        returnType: 'string',
    },
    {
        name: 'truncate',
        category: 'text',
        description: 'Cuts text to N characters and adds \'...\' at the end.',
        syntax: 'truncate(text; n)',
        example: 'truncate( Annual Revenue Report ; 14 )',
        exampleResult: 'Annual Revenue...',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'number'],
        returnType: 'string',
    },
    {
        name: 'split',
        category: 'text',
        description: 'Breaks text into parts and returns one of them.',
        syntax: 'split(text; separator; index)',
        example: 'split( John Smith ; " "; 0 )',
        exampleResult: 'John',
        minArgs: 3,
        maxArgs: 3,
        argTypes: ['string', 'string', 'number'],
        returnType: 'string',
    },
    {
        name: 'extract_between',
        category: 'text',
        description: 'Returns the text sitting between two markers.',
        syntax: 'extract_between(text; start; end)',
        example: 'extract_between( Status [urgent] ; "["; "]" )',
        exampleResult: 'urgent',
        minArgs: 3,
        maxArgs: 3,
        argTypes: ['string', 'string', 'string'],
        returnType: 'string',
    },
    {
        name: 'extract_email',
        category: 'text',
        description: 'Finds and returns the first email address in a text.',
        syntax: 'extract_email(text)',
        example: 'extract_email( Contact [email protected] for help )',
        exampleResult: '[email protected]',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'extract_url',
        category: 'text',
        description: 'Finds and returns the first URL in a text.',
        syntax: 'extract_url(text)',
        example: 'extract_url( Visit https://acme.com today )',
        exampleResult: 'https://acme.com',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'length',
        category: 'text',
        description: 'Counts how many characters are in the text.',
        syntax: 'length(text)',
        example: 'length( Hello World )',
        exampleResult: '11',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'number',
    },
    {
        name: 'contains',
        category: 'text',
        description: 'Checks if the text has a specific word or character in it.',
        syntax: 'contains(text; value)',
        example: 'contains( bug, urgent, backend ; urgent )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'string'],
        returnType: 'boolean',
    },
    {
        name: 'starts_with',
        category: 'text',
        description: 'Checks if the text begins with a specific value.',
        syntax: 'starts_with(text; value)',
        example: 'starts_with( [email protected] ; info@ )',
        exampleResult: 'FALSE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'string'],
        returnType: 'boolean',
    },
    {
        name: 'ends_with',
        category: 'text',
        description: 'Checks if the text ends with a specific value.',
        syntax: 'ends_with(text; value)',
        example: 'ends_with( report.pdf ; .pdf )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'string'],
        returnType: 'boolean',
    },
    {
        name: 'remove_spaces',
        category: 'text',
        description: 'Removes all extra spaces and line breaks inside the text.',
        syntax: 'remove_spaces(text)',
        example: 'remove_spaces( hello   world )',
        exampleResult: 'hello world',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'word_count',
        category: 'text',
        description: 'Counts how many words are in the text.',
        syntax: 'word_count(text)',
        example: 'word_count( The quick brown fox )',
        exampleResult: '4',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'number',
    },
    {
        name: 'pad_left',
        category: 'text',
        description: 'Pads text on the left with a character so it reaches a set length.',
        syntax: 'pad_left(text; length; char)',
        example: 'pad_left( 42 ; 5 ; "0" )',
        exampleResult: '00042',
        minArgs: 2,
        maxArgs: 3,
        argTypes: ['string', 'number', 'string'],
        returnType: 'string',
    },
    {
        name: 'pad_right',
        category: 'text',
        description: 'Pads text on the right with a character so it reaches a set length.',
        syntax: 'pad_right(text; length; char)',
        example: 'pad_right( 42 ; 5 ; "0" )',
        exampleResult: '42000',
        minArgs: 2,
        maxArgs: 3,
        argTypes: ['string', 'number', 'string'],
        returnType: 'string',
    },
    {
        name: 'repeat',
        category: 'text',
        description: 'Repeats text a given number of times.',
        syntax: 'repeat(text; count)',
        example: 'repeat( ab ; 3 )',
        exampleResult: 'ababab',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'number'],
        returnType: 'string',
    },
    {
        name: 'reverse',
        category: 'text',
        description: 'Reverses the order of characters in the text.',
        syntax: 'reverse(text)',
        example: 'reverse( hello )',
        exampleResult: 'olleh',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'slug',
        category: 'text',
        description: 'Turns text into a URL-friendly slug (lowercase, dashes between words).',
        syntax: 'slug(text)',
        example: 'slug( Hello World! )',
        exampleResult: 'hello-world',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['string'],
        returnType: 'string',
    },
    {
        name: 'add',
        category: 'number',
        description: 'Adds two numbers together.',
        syntax: 'add(num1; num2)',
        example: 'add( 49.99 ; 5.00 )',
        exampleResult: '54.99',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'subtract',
        category: 'number',
        description: 'Takes the second number away from the first.',
        syntax: 'subtract(num1; num2)',
        example: 'subtract( 100.00 ; 10.50 )',
        exampleResult: '89.5',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'multiply',
        category: 'number',
        description: 'Multiplies two numbers together.',
        syntax: 'multiply(num1; num2)',
        example: 'multiply( 3 ; 49.99 )',
        exampleResult: '149.97',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'divide',
        category: 'number',
        description: 'Divides the first number by the second.',
        syntax: 'divide(num1; num2)',
        example: 'divide( 4999 ; 100 )',
        exampleResult: '49.99',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'round',
        category: 'number',
        description: 'Rounds a number to a set number of decimal places.',
        syntax: 'round(number; decimals)',
        example: 'round( 49.9871 ; 2 )',
        exampleResult: '49.99',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'round_up',
        category: 'number',
        description: 'Always rounds up to the next whole number.',
        syntax: 'round_up(number)',
        example: 'round_up( 7.1 )',
        exampleResult: '8',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['number'],
        returnType: 'number',
    },
    {
        name: 'round_down',
        category: 'number',
        description: 'Always rounds down to the previous whole number.',
        syntax: 'round_down(number)',
        example: 'round_down( 7.9 )',
        exampleResult: '7',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['number'],
        returnType: 'number',
    },
    {
        name: 'absolute',
        category: 'number',
        description: 'Returns the positive version of a number, removing any minus sign.',
        syntax: 'absolute(number)',
        example: 'absolute( -42.00 )',
        exampleResult: '42',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['number'],
        returnType: 'number',
    },
    {
        name: 'percentage',
        category: 'number',
        description: 'Calculates what percentage the value is of the total.',
        syntax: 'percentage(value; total)',
        example: 'percentage( 75 ; 100 )',
        exampleResult: '75%',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'format_number',
        category: 'number',
        description: 'Adds thousand separators so large numbers are easier to read.',
        syntax: 'format_number(number; decimals)',
        example: 'format_number( 1250000 ; 2 )',
        exampleResult: '1,250,000.00',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'string',
    },
    {
        name: 'format_currency',
        category: 'number',
        description: 'Adds a currency symbol and formats the number.',
        syntax: 'format_currency(number; symbol)',
        example: 'format_currency( 49.99 ; "$" )',
        exampleResult: '$49.99',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'string'],
        returnType: 'string',
    },
    {
        name: 'cents_to_dollars',
        category: 'number',
        description: 'Converts a value stored in cents into dollars.',
        syntax: 'cents_to_dollars(number)',
        example: 'cents_to_dollars( 4999 )',
        exampleResult: '$49.99',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['number'],
        returnType: 'string',
    },
    {
        name: 'min',
        category: 'number',
        description: 'Returns the smaller of two numbers.',
        syntax: 'min(num1; num2)',
        example: 'min( 87 ; 100 )',
        exampleResult: '87',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'max',
        category: 'number',
        description: 'Returns the larger of two numbers.',
        syntax: 'max(num1; num2)',
        example: 'max( -5 ; 0 )',
        exampleResult: '0',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'to_number',
        category: 'number',
        description: 'Converts a text value into a number you can calculate with.',
        syntax: 'to_number(text)',
        example: 'to_number( 1990 )',
        exampleResult: '1990',
        minArgs: 1,
        maxArgs: 1,
        argTypes: [['string', 'number', 'boolean']],
        returnType: 'number',
    },
    {
        name: 'random',
        category: 'number',
        description: 'Returns a random decimal number between 0 (included) and 1 (excluded).',
        syntax: 'random()',
        example: 'random()',
        exampleResult: '0.4827',
        minArgs: 0,
        maxArgs: 0,
        argTypes: [],
        returnType: 'number',
    },
    {
        name: 'random_int',
        category: 'number',
        description: 'Returns a random whole number between two values (both included).',
        syntax: 'random_int(min; max)',
        example: 'random_int( 1 ; 100 )',
        exampleResult: '57',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'power',
        category: 'number',
        description: 'Raises a number to the power of another number.',
        syntax: 'power(base; exponent)',
        example: 'power( 2 ; 10 )',
        exampleResult: '1024',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'sqrt',
        category: 'number',
        description: 'Returns the square root of a number.',
        syntax: 'sqrt(number)',
        example: 'sqrt( 144 )',
        exampleResult: '12',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['number'],
        returnType: 'number',
    },
    {
        name: 'modulo',
        category: 'number',
        description: 'Returns the remainder left over after dividing one number by another.',
        syntax: 'modulo(num1; num2)',
        example: 'modulo( 10 ; 3 )',
        exampleResult: '1',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['number', 'number'],
        returnType: 'number',
    },
    {
        name: 'clamp',
        category: 'number',
        description: 'Keeps a number between a minimum and a maximum.',
        syntax: 'clamp(number; min; max)',
        example: 'clamp( 150 ; 0 ; 100 )',
        exampleResult: '100',
        minArgs: 3,
        maxArgs: 3,
        argTypes: ['number', 'number', 'number'],
        returnType: 'number',
    },
    {
        name: 'sign',
        category: 'number',
        description: 'Returns -1 if the number is negative, 1 if positive, and 0 if zero.',
        syntax: 'sign(number)',
        example: 'sign( -42 )',
        exampleResult: '-1',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['number'],
        returnType: 'number',
    },
    {
        name: 'format_date',
        category: 'date',
        description: 'Changes how a date looks using a format you pick.',
        syntax: 'format_date(date; format)',
        example: 'format_date( 2025-01-15 ; MMM DD, YYYY )',
        exampleResult: 'Jan 15, 2025',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'string'],
        returnType: 'string',
    },
    {
        name: 'format_date_long',
        category: 'date',
        description: 'Shows the full date written out in plain language.',
        syntax: 'format_date_long(date)',
        example: 'format_date_long( 2025-01-15 )',
        exampleResult: 'Friday, January 15, 2025',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'string',
    },
    {
        name: 'format_time',
        category: 'date',
        description: 'Pulls the time out of a date and formats it.',
        syntax: 'format_time(date; format)',
        example: 'format_time( 2025-01-15T14:30:00Z ; h:mm A )',
        exampleResult: '2:30 PM',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'string'],
        returnType: 'string',
    },
    {
        name: 'relative_time',
        category: 'date',
        description: 'Shows how long ago or how far away a date is.',
        syntax: 'relative_time(date)',
        example: 'relative_time( 2025-01-12 )',
        exampleResult: '3 days ago',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'string',
    },
    {
        name: 'add_days',
        category: 'date',
        description: 'Adds a number of days to a date.',
        syntax: 'add_days(date; n)',
        example: 'add_days( 2025-01-15 ; 30 )',
        exampleResult: 'Feb 14, 2025',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'number'],
        returnType: 'date',
    },
    {
        name: 'subtract_days',
        category: 'date',
        description: 'Goes back a number of days from a date.',
        syntax: 'subtract_days(date; n)',
        example: 'subtract_days( 2025-01-15 ; 7 )',
        exampleResult: 'Jan 08, 2025',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'number'],
        returnType: 'date',
    },
    {
        name: 'add_hours',
        category: 'date',
        description: 'Adds a number of hours to a date and time.',
        syntax: 'add_hours(date; n)',
        example: 'add_hours( 2025-01-15T14:30:00Z ; 2 )',
        exampleResult: '2025-01-15T16:30:00Z',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'number'],
        returnType: 'date',
    },
    {
        name: 'days_between',
        category: 'date',
        description: 'Counts how many days are between two dates.',
        syntax: 'days_between(date1; date2)',
        example: 'days_between( 2025-01-01 ; 2025-01-15 )',
        exampleResult: '14',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'date'],
        returnType: 'number',
    },
    {
        name: 'get_day',
        category: 'date',
        description: 'Returns the day number from a date (1–31).',
        syntax: 'get_day(date)',
        example: 'get_day( 2025-01-15 )',
        exampleResult: '15',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'number',
    },
    {
        name: 'get_month',
        category: 'date',
        description: 'Returns the month from a date.',
        syntax: 'get_month(date)',
        example: 'get_month( 2025-01-15 )',
        exampleResult: 'January',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'string',
    },
    {
        name: 'get_year',
        category: 'date',
        description: 'Returns the year from a date.',
        syntax: 'get_year(date)',
        example: 'get_year( 2025-01-15 )',
        exampleResult: '2025',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'number',
    },
    {
        name: 'get_day_of_week',
        category: 'date',
        description: 'Returns the name of the day of the week.',
        syntax: 'get_day_of_week(date)',
        example: 'get_day_of_week( 2025-01-15 )',
        exampleResult: 'Wednesday',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'string',
    },
    {
        name: 'start_of_month',
        category: 'date',
        description: 'Returns the first day of the same month.',
        syntax: 'start_of_month(date)',
        example: 'start_of_month( 2025-01-15 )',
        exampleResult: 'Jan 01, 2025',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'date',
    },
    {
        name: 'end_of_month',
        category: 'date',
        description: 'Returns the last day of the same month.',
        syntax: 'end_of_month(date)',
        example: 'end_of_month( 2025-01-15 )',
        exampleResult: 'Jan 31, 2025',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'date',
    },
    {
        name: 'convert_timezone',
        category: 'date',
        description: 'Converts a date and time from one timezone to another.',
        syntax: 'convert_timezone(date; timezone)',
        example: 'convert_timezone( 2025-01-15T14:30:00Z ; America/New_York )',
        exampleResult: 'Jan 15, 9:30 AM EST',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'string'],
        returnType: 'string',
    },
    {
        name: 'now',
        category: 'date',
        description: 'Returns the current date and time at the moment the flow runs.',
        syntax: 'now()',
        example: 'now()',
        exampleResult: '2025-01-15T14:30:00Z',
        minArgs: 0,
        maxArgs: 0,
        argTypes: [],
        returnType: 'date',
    },
    {
        name: 'today',
        category: 'date',
        description: 'Returns today\'s date with no time attached.',
        syntax: 'today()',
        example: 'today()',
        exampleResult: '2025-01-15',
        minArgs: 0,
        maxArgs: 0,
        argTypes: [],
        returnType: 'date',
    },
    {
        name: 'to_date',
        category: 'date',
        description: 'Turns a text value into a proper date the flow can work with.',
        syntax: 'to_date(text)',
        example: 'to_date( January 15, 2025 )',
        exampleResult: '2025-01-15T00:00:00Z',
        minArgs: 1,
        maxArgs: 1,
        argTypes: [['string', 'date']],
        returnType: 'date',
    },
    {
        name: 'add_minutes',
        category: 'date',
        description: 'Adds a number of minutes to a date and time.',
        syntax: 'add_minutes(date; n)',
        example: 'add_minutes( 2025-01-15T14:30:00Z ; 15 )',
        exampleResult: '2025-01-15T14:45:00Z',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'number'],
        returnType: 'date',
    },
    {
        name: 'hours_between',
        category: 'date',
        description: 'Counts how many hours are between two dates.',
        syntax: 'hours_between(date1; date2)',
        example: 'hours_between( 2025-01-15T09:00:00Z ; 2025-01-15T17:30:00Z )',
        exampleResult: '8',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'date'],
        returnType: 'number',
    },
    {
        name: 'start_of_day',
        category: 'date',
        description: 'Returns the date at midnight (the start of that day).',
        syntax: 'start_of_day(date)',
        example: 'start_of_day( 2025-01-15T14:30:00Z )',
        exampleResult: '2025-01-15T00:00:00Z',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'date',
    },
    {
        name: 'end_of_day',
        category: 'date',
        description: 'Returns the date at one moment before midnight (the end of that day).',
        syntax: 'end_of_day(date)',
        example: 'end_of_day( 2025-01-15T14:30:00Z )',
        exampleResult: '2025-01-15T23:59:59Z',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['date'],
        returnType: 'date',
    },
    {
        name: 'is_before',
        category: 'date',
        description: 'Checks if the first date is before the second date.',
        syntax: 'is_before(date1; date2)',
        example: 'is_before( 2025-01-01 ; 2025-02-01 )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'date'],
        returnType: 'boolean',
    },
    {
        name: 'is_after',
        category: 'date',
        description: 'Checks if the first date is after the second date.',
        syntax: 'is_after(date1; date2)',
        example: 'is_after( 2025-02-01 ; 2025-01-01 )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'date'],
        returnType: 'boolean',
    },
    {
        name: 'is_same_day',
        category: 'date',
        description: 'Checks if two dates land on the same calendar day, ignoring the time.',
        syntax: 'is_same_day(date1; date2)',
        example: 'is_same_day( 2025-01-15T09:00:00Z ; 2025-01-15T21:00:00Z )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['date', 'date'],
        returnType: 'boolean',
    },
    {
        name: 'filter_list',
        category: 'list',
        description: 'Keeps only the items where a field matches a value.',
        syntax: 'filter_list(list; field; value)',
        example: 'filter_list( tickets ; status; open )',
        exampleResult: '[3 of 10 items]',
        minArgs: 3,
        maxArgs: 3,
        argTypes: ['list', 'string', ['string', 'number', 'boolean']],
        returnType: 'list',
    },
    {
        name: 'sort_list',
        category: 'list',
        description: 'Sorts a list from highest to lowest, or A to Z, by a field.',
        syntax: 'sort_list(list; field; order)',
        example: 'sort_list( orders ; amount; desc )',
        exampleResult: '[sorted: 500, 200, 50]',
        minArgs: 3,
        maxArgs: 3,
        argTypes: ['list', 'string', 'string'],
        returnType: 'list',
    },
    {
        name: 'pluck',
        category: 'list',
        description: 'Picks one field out of every item in a list.',
        syntax: 'pluck(list; field)',
        example: 'pluck( users ; email )',
        exampleResult: '[[email protected], [email protected]]',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', 'string'],
        returnType: 'list',
    },
    {
        name: 'join_list',
        category: 'list',
        description: 'Turns a list into a single piece of text with a separator.',
        syntax: 'join_list(list; separator)',
        example: 'join_list( [bug;urgent;backend] ; ", " )',
        exampleResult: 'bug, urgent, backend',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', 'string'],
        returnType: 'string',
    },
    {
        name: 'first_item',
        category: 'list',
        description: 'Returns the first item in a list.',
        syntax: 'first_item(list)',
        example: 'first_item( [apple;banana;cherry] )',
        exampleResult: 'apple',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['list'],
        returnType: ['string', 'number', 'boolean', 'list'],
    },
    {
        name: 'last_item',
        category: 'list',
        description: 'Returns the last item in a list.',
        syntax: 'last_item(list)',
        example: 'last_item( [apple;banana;cherry] )',
        exampleResult: 'cherry',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['list'],
        returnType: ['string', 'number', 'boolean'],
    },
    {
        name: 'item_at',
        category: 'list',
        description: 'Returns the item at a specific position in a list.',
        syntax: 'item_at(list; index)',
        example: 'item_at( [apple;banana;cherry] ; 1 )',
        exampleResult: 'banana',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', 'number'],
        returnType: ['string', 'number', 'boolean', 'list'],
    },
    {
        name: 'count',
        category: 'list',
        description: 'Counts how many items are in a list.',
        syntax: 'count(list)',
        example: 'count( [bug;urgent;backend] )',
        exampleResult: '3',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['list'],
        returnType: 'number',
    },
    {
        name: 'sum',
        category: 'list',
        description: 'Adds up a number field across all items in a list.',
        syntax: 'sum(list; field)',
        example: 'sum( orders ; amount )',
        exampleResult: '4820.5',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', 'string'],
        returnType: 'number',
    },
    {
        name: 'average',
        category: 'list',
        description: 'Calculates the average of a number field across all items.',
        syntax: 'average(list; field)',
        example: 'average( scores ; value )',
        exampleResult: '82.4',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', 'string'],
        returnType: 'number',
    },
    {
        name: 'max_in_list',
        category: 'list',
        description: 'Finds the highest value of a field across all items.',
        syntax: 'max_in_list(list; field)',
        example: 'max_in_list( orders ; amount )',
        exampleResult: '1200',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', 'string'],
        returnType: 'number',
    },
    {
        name: 'min_in_list',
        category: 'list',
        description: 'Finds the lowest value of a field across all items.',
        syntax: 'min_in_list(list; field)',
        example: 'min_in_list( orders ; amount )',
        exampleResult: '9.99',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', 'string'],
        returnType: 'number',
    },
    {
        name: 'deduplicate',
        category: 'list',
        description: 'Removes items that have the same value in a field.',
        syntax: 'deduplicate(list; field)',
        example: 'deduplicate( leads ; email )',
        exampleResult: '[7 of 10 items]',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', 'string'],
        returnType: 'list',
    },
    {
        name: 'flatten',
        category: 'list',
        description: 'Turns a list of lists into one flat list.',
        syntax: 'flatten(list)',
        example: 'flatten( [[a;b];[c;d]] )',
        exampleResult: '[a,b,c,d]',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['list'],
        returnType: 'list',
    },
    {
        name: 'split_text_to_list',
        category: 'list',
        description: 'Turns a comma-separated text into a list of items.',
        syntax: 'split_text_to_list(text; separator)',
        example: 'split_text_to_list( bug,urgent,backend ; "," )',
        exampleResult: '[bug,urgent,backend]',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['string', 'string'],
        returnType: 'list',
    },
    {
        name: 'reverse_list',
        category: 'list',
        description: 'Reverses the order of items in a list.',
        syntax: 'reverse_list(list)',
        example: 'reverse_list( [a;b;c] )',
        exampleResult: '[c,b,a]',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['list'],
        returnType: 'list',
    },
    {
        name: 'contains_item',
        category: 'list',
        description: 'Checks if a list contains a specific value.',
        syntax: 'contains_item(list; value)',
        example: 'contains_item( [bug;urgent;backend] ; urgent )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['list', ['string', 'number', 'boolean']],
        returnType: 'boolean',
    },
    {
        name: 'if',
        category: 'logic',
        description: 'Returns one value if something is true, and another if it\'s not.',
        syntax: 'if(condition; true_value; false_value)',
        example: 'if( 1500 > 1000; High value; Standard )',
        exampleResult: 'High value',
        minArgs: 3,
        maxArgs: 3,
        argTypes: ['boolean', ['string', 'number', 'boolean', 'date', 'list'], ['string', 'number', 'boolean', 'date', 'list']],
        returnType: ['string', 'number', 'boolean', 'date', 'list'],
    },
    {
        name: 'if_empty',
        category: 'logic',
        description: 'Uses a fallback value if the field is empty.',
        syntax: 'if_empty(value; fallback)',
        example: 'if_empty( "" ; No name )',
        exampleResult: 'No name',
        minArgs: 2,
        maxArgs: 2,
        argTypes: [['string', 'number', 'boolean', 'date', 'list'], 'string'],
        returnType: ['string', 'number', 'boolean'],
    },
    {
        name: 'if_null',
        category: 'logic',
        description: 'Uses a fallback value if the field has no value at all.',
        syntax: 'if_null(value; fallback)',
        example: 'if_null( null ; N/A )',
        exampleResult: 'N/A',
        minArgs: 2,
        maxArgs: 2,
        argTypes: [['string', 'number', 'boolean', 'date', 'list'], 'string'],
        returnType: ['string', 'number', 'boolean'],
    },
    {
        name: 'switch',
        category: 'logic',
        description: 'Maps a value to another — like a lookup table written inline.',
        syntax: 'switch(value; key1; result1; key2; result2; ...)',
        example: 'switch( US ; US;North America; DE;Europe )',
        exampleResult: 'North America',
        minArgs: 3,
        maxArgs: -1,
        argTypes: [['string', 'number', 'boolean'], ['string', 'number', 'boolean'], ['string', 'number', 'boolean']],
        returnType: ['string', 'number', 'boolean'],
    },
    {
        name: 'is_empty',
        category: 'logic',
        description: 'Checks if a field has no value.',
        syntax: 'is_empty(value)',
        example: 'is_empty( "" )',
        exampleResult: 'TRUE',
        minArgs: 1,
        maxArgs: 1,
        argTypes: [['string', 'number', 'boolean', 'date', 'list']],
        returnType: 'boolean',
    },
    {
        name: 'is_not_empty',
        category: 'logic',
        description: 'Checks if a field has any value in it.',
        syntax: 'is_not_empty(value)',
        example: 'is_not_empty( [email protected] )',
        exampleResult: 'TRUE',
        minArgs: 1,
        maxArgs: 1,
        argTypes: [['string', 'number', 'boolean', 'date', 'list']],
        returnType: 'boolean',
    },
    {
        name: 'is_equal',
        category: 'logic',
        description: 'Checks if two values are exactly the same.',
        syntax: 'is_equal(value1; value2)',
        example: 'is_equal( active ; active )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: [['string', 'number', 'boolean'], ['string', 'number', 'boolean']],
        returnType: 'boolean',
    },
    {
        name: 'and',
        category: 'logic',
        description: 'Returns true only if both conditions are true at the same time.',
        syntax: 'and(condition1; condition2)',
        example: 'and( 25 >= 18; US = US )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['boolean', 'boolean'],
        returnType: 'boolean',
    },
    {
        name: 'or',
        category: 'logic',
        description: 'Returns true if at least one of the conditions is true.',
        syntax: 'or(condition1; condition2)',
        example: 'or( standard = vip; 600 > 500 )',
        exampleResult: 'TRUE',
        minArgs: 2,
        maxArgs: 2,
        argTypes: ['boolean', 'boolean'],
        returnType: 'boolean',
    },
    {
        name: 'not',
        category: 'logic',
        description: 'Flips a true to false, or a false to true.',
        syntax: 'not(condition)',
        example: 'not( is_empty( [email protected] ) )',
        exampleResult: 'TRUE',
        minArgs: 1,
        maxArgs: 1,
        argTypes: ['boolean'],
        returnType: 'boolean',
    },
    {
        name: 'coalesce',
        category: 'logic',
        description: 'Returns the first field that has a value, skipping any empty ones.',
        syntax: 'coalesce(value1; value2; value3; ...)',
        example: 'coalesce( "" ; John ; User )',
        exampleResult: 'John',
        minArgs: 2,
        maxArgs: -1,
        argTypes: [['string', 'number', 'boolean']],
        returnType: ['string', 'number', 'boolean'],
    },
    {
        name: 'is_number',
        category: 'logic',
        description: 'Checks if the value is a number (text that looks numeric returns false).',
        syntax: 'is_number(value)',
        example: 'is_number( 42 )',
        exampleResult: 'TRUE',
        minArgs: 1,
        maxArgs: 1,
        argTypes: [['string', 'number', 'boolean', 'date', 'list']],
        returnType: 'boolean',
    },
    {
        name: 'is_list',
        category: 'logic',
        description: 'Checks if the value is a list.',
        syntax: 'is_list(value)',
        example: 'is_list( [a;b;c] )',
        exampleResult: 'TRUE',
        minArgs: 1,
        maxArgs: 1,
        argTypes: [['string', 'number', 'boolean', 'date', 'list']],
        returnType: 'boolean',
    },
]

export type ApFunctionBaseType = 'string' | 'number' | 'boolean' | 'date' | 'list'
export type ApFunctionArgType = ApFunctionBaseType | ApFunctionBaseType[]

export type ApFunctionDeprecation = {
    replacement?: string
    removeAfter: string
}

export type ApFunctionArgCompatibility = {
    defaultArgs?: unknown[]
}

export type ApFunction = {
    name: string
    category: 'text' | 'number' | 'date' | 'list' | 'logic'
    description: string
    syntax: string
    example: string
    exampleResult: string
    minArgs: number
    maxArgs: number
    argTypes: ApFunctionArgType[]
    returnType: ApFunctionArgType
    deprecated?: ApFunctionDeprecation
    argCompatibility?: ApFunctionArgCompatibility
}