/** * String function schemas using JSON Schema */ import { createParameter, createFunctionSchema, createLibrarySchema } from './utils.js' // Create string function schemas using the helper utilities export const stringFunctionSchemas = { UPPER: createFunctionSchema( 'UPPER', 'Converts a string to uppercase', 'string', [createParameter('str', { type: 'string', description: 'The string to convert' })], { type: 'string', description: 'The uppercase string' }, { examples: ['UPPER("hello") // "HELLO"', 'UPPER("World") // "WORLD"'], } ), LOWER: createFunctionSchema( 'LOWER', 'Converts a string to lowercase', 'string', [createParameter('str', { type: 'string', description: 'The string to convert' })], { type: 'string', description: 'The lowercase string' }, { examples: ['LOWER("HELLO") // "hello"', 'LOWER("World") // "world"'], } ), SUBSTR: createFunctionSchema( 'SUBSTR', 'Extracts a substring from a string', 'string', [ createParameter('str', { type: 'string', description: 'The string to extract from' }), createParameter('start', { type: 'number', description: 'The starting index' }), createParameter('end', { type: 'number', description: 'The ending index (optional)' }, false), ], { type: 'string', description: 'The extracted substring' }, { examples: ['SUBSTR("hello", 1, 3) // "el"', 'SUBSTR("world", 2) // "rld"'], } ), SPLIT: createFunctionSchema( 'SPLIT', 'Splits a string into an array of substrings', 'string', [ createParameter('str', { type: 'string', description: 'The string to split' }), createParameter('separator', { type: 'string', description: 'The separator to use for splitting' }), ], { type: 'array', description: 'An array of substrings' }, { examples: ['SPLIT("a,b,c", ",") // ["a", "b", "c"]', 'SPLIT("hello world", " ") // ["hello", "world"]'], } ), REPLACE: createFunctionSchema( 'REPLACE', 'Replaces the first occurrence of a substring with another string', 'string', [ createParameter('str', { type: 'string', description: 'The string to search in' }), createParameter('oldStr', { type: 'string', description: 'The substring to replace' }), createParameter('newStr', { type: 'string', description: 'The replacement string' }), ], { type: 'string', description: 'The string with the first occurrence replaced' }, { examples: [ 'REPLACE("hello world", "world", "there") // "hello there"', 'REPLACE("foo bar foo", "foo", "baz") // "baz bar foo"', ], } ), CAPITALIZE: createFunctionSchema( 'CAPITALIZE', 'Capitalizes the first letter of a string', 'string', [createParameter('str', { type: 'string', description: 'The string to capitalize' })], { type: 'string', description: 'The capitalized string' }, { examples: ['CAPITALIZE("hello") // "Hello"', 'CAPITALIZE("world") // "World"'], } ), TITLE_CASE: createFunctionSchema( 'TITLE_CASE', 'Converts a string to title case', 'string', [createParameter('str', { type: 'string', description: 'The string to convert' })], { type: 'string', description: 'The title-cased string' }, { examples: ['TITLE_CASE("hello world") // "Hello World"', 'TITLE_CASE("this is a test") // "This Is A Test"'], } ), CAMEL_CASE: createFunctionSchema( 'CAMEL_CASE', 'Converts a string to camel case', 'string', [createParameter('str', { type: 'string', description: 'The string to convert' })], { type: 'string', description: 'The camel-cased string' }, { examples: ['CAMEL_CASE("hello world") // "helloWorld"', 'CAMEL_CASE("this is a test") // "thisIsATest"'], } ), PASCAL_CASE: createFunctionSchema( 'PASCAL_CASE', 'Converts a string to Pascal case', 'string', [createParameter('str', { type: 'string', description: 'The string to convert' })], { type: 'string', description: 'The Pascal-cased string' }, { examples: ['PASCAL_CASE("hello world") // "HelloWorld"', 'PASCAL_CASE("this is a test") // "ThisIsATest"'], } ), SNAKE_CASE: createFunctionSchema( 'SNAKE_CASE', 'Converts a string to snake case', 'string', [createParameter('str', { type: 'string', description: 'The string to convert' })], { type: 'string', description: 'The snake-cased string' }, { examples: ['SNAKE_CASE("hello world") // "hello_world"', 'SNAKE_CASE("this is a test") // "this_is_a_test"'], } ), KEBAB_CASE: createFunctionSchema( 'KEBAB_CASE', 'Converts a string to kebab case', 'string', [createParameter('str', { type: 'string', description: 'The string to convert' })], { type: 'string', description: 'The kebab-cased string' }, { examples: ['KEBAB_CASE("hello world") // "hello-world"', 'KEBAB_CASE("this is a test") // "this-is-a-test"'], } ), PAD: createFunctionSchema( 'PAD', 'Pads a string to a specified length with another string', 'string', [ createParameter('str', { type: 'string', description: 'The string to pad' }), createParameter('targetLength', { type: 'number', description: 'The target length' }), createParameter('padString', { type: 'string', description: 'The string to pad with (optional)' }, false), ], { type: 'string', description: 'The padded string' }, { examples: ['PAD("hello", 10) // " hello"', 'PAD("5", 3, "0") // "005"'], } ), PAD_START: createFunctionSchema( 'PAD_START', 'Pads a string from the start with another string', 'string', [ createParameter('str', { type: 'string', description: 'The string to pad' }), createParameter('targetLength', { type: 'number', description: 'The target length' }), createParameter('padString', { type: 'string', description: 'The string to pad with (optional)' }, false), ], { type: 'string', description: 'The padded string' }, { examples: ['PAD_START("hello", 10) // " hello"', 'PAD_START("5", 3, "0") // "005"'], } ), PAD_END: createFunctionSchema( 'PAD_END', 'Pads a string from the end with another string', 'string', [ createParameter('str', { type: 'string', description: 'The string to pad' }), createParameter('targetLength', { type: 'number', description: 'The target length' }), createParameter('padString', { type: 'string', description: 'The string to pad with (optional)' }, false), ], { type: 'string', description: 'The padded string' }, { examples: ['PAD_END("hello", 10) // "hello "', 'PAD_END("5", 3, "0") // "500"'], } ), REPEAT: createFunctionSchema( 'REPEAT', 'Repeats a string a specified number of times', 'string', [ createParameter('str', { type: 'string', description: 'The string to repeat' }), createParameter('count', { type: 'number', description: 'The number of times to repeat the string' }), ], { type: 'string', description: 'The repeated string' }, { examples: ['REPEAT("hello", 3) // "hellohellohello"', 'REPEAT("abc", 2) // "abcabc"'], } ), TRUNCATE: createFunctionSchema( 'TRUNCATE', 'Truncates a string to a specified length', 'string', [ createParameter('str', { type: 'string', description: 'The string to truncate' }), createParameter('length', { type: 'number', description: 'The length to truncate to' }), ], { type: 'string', description: 'The truncated string' }, { examples: ['TRUNCATE("hello world", 5) // "hello"', 'TRUNCATE("abc", 10) // "abc"'], } ), STARTS_WITH: createFunctionSchema( 'STARTS_WITH', 'Checks if a string starts with a specified substring', 'string', [ createParameter('str', { type: 'string', description: 'The string to check' }), createParameter('substring', { type: 'string', description: 'The substring to check for' }), ], { type: 'boolean', description: 'True if the string starts with the substring, false otherwise' }, { examples: ['STARTS_WITH("hello", "he") // true', 'STARTS_WITH("hello", "hi") // false'], } ), ENDS_WITH: createFunctionSchema( 'ENDS_WITH', 'Checks if a string ends with a specified substring', 'string', [ createParameter('str', { type: 'string', description: 'The string to check' }), createParameter('substring', { type: 'string', description: 'The substring to check for' }), ], { type: 'boolean', description: 'True if the string ends with the substring, false otherwise' }, { examples: ['ENDS_WITH("hello", "lo") // true', 'ENDS_WITH("hello", "hi") // false'], } ), REPLACE_ALL: createFunctionSchema( 'REPLACE_ALL', 'Replaces all occurrences of a substring with another string', 'string', [ createParameter('str', { type: 'string', description: 'The string to search in' }), createParameter('oldStr', { type: 'string', description: 'The substring to replace' }), createParameter('newStr', { type: 'string', description: 'The replacement string' }), ], { type: 'string', description: 'The string with all occurrences replaced' }, { examples: [ 'REPLACE_ALL("hello world world", "world", "there") // "hello there there"', 'REPLACE_ALL("foo bar foo", "foo", "baz") // "baz bar baz"', ], } ), TRIM: createFunctionSchema( 'TRIM', 'Removes whitespace from both ends of a string', 'string', [createParameter('str', { type: 'string', description: 'The string to trim' })], { type: 'string', description: 'The trimmed string' }, { examples: ['TRIM(" hello ") // "hello"', 'TRIM("\\n\\tworld\\n") // "world"'], } ), TRIM_START: createFunctionSchema( 'TRIM_START', 'Removes whitespace from the start of a string', 'string', [createParameter('str', { type: 'string', description: 'The string to trim' })], { type: 'string', description: 'The trimmed string' }, { examples: ['TRIM_START(" hello ") // "hello "', 'TRIM_START("\\n\\tworld") // "world"'], } ), TRIM_END: createFunctionSchema( 'TRIM_END', 'Removes whitespace from the end of a string', 'string', [createParameter('str', { type: 'string', description: 'The string to trim' })], { type: 'string', description: 'The trimmed string' }, { examples: ['TRIM_END(" hello ") // " hello"', 'TRIM_END("world\\n\\t") // "world"'], } ), SLUG: createFunctionSchema( 'SLUG', 'Converts a string to a URL-friendly slug', 'string', [createParameter('str', { type: 'string', description: 'The string to convert' })], { type: 'string', description: 'The URL-friendly slug' }, { examples: ['SLUG("Hello World!") // "hello-world"', 'SLUG("This is a test") // "this-is-a-test"'], } ), ESCAPE_HTML: createFunctionSchema( 'ESCAPE_HTML', 'Escapes HTML special characters in a string', 'string', [createParameter('str', { type: 'string', description: 'The string to escape' })], { type: 'string', description: 'The escaped string' }, { examples: [ 'ESCAPE_HTML("