ruvector/studio/components/interfaces/Database/Functions/Functions.utils.ts
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

52 lines
1.6 KiB
TypeScript

import { isEmpty } from 'lodash'
/**
* convert argument_types = "a integer, b integer"
* to args = {value: [{name:'a', type:'integer'}, {name:'b', type:'integer'}]}
*/
export function convertArgumentTypes(value: string) {
const items = value?.split(',').map((item) => item.trim())
if (isEmpty(value) || !items || items.length === 0) return { value: [] }
const temp = items
.map((x) => {
const regex = /(\w+)\s+([\w\[\]]+)(?:\s+DEFAULT\s+(.*))?/i
const match = x.match(regex)
if (match) {
const [, name, type, defaultValue] = match
let parsedDefaultValue = defaultValue ? defaultValue.trim() : undefined
if (
['timestamp', 'time', 'timetz', 'timestamptz'].includes(type.toLowerCase()) &&
parsedDefaultValue
) {
parsedDefaultValue = `'${parsedDefaultValue}'`
}
return { name, type, defaultValue: parsedDefaultValue }
} else {
console.error('Error while trying to parse function arguments', x)
return null
}
})
.filter(Boolean) as { name: string; type: string; defaultValue?: string }[]
return { value: temp }
}
/**
* convert config_params = {search_path: "auth, public"}
* to {value: [{name: 'search_path', value: 'auth, public'}]}
*/
export function convertConfigParams(value: Record<string, string> | null | undefined) {
const temp = []
if (value) {
for (var key in value) {
temp.push({ name: key, value: value[key] })
}
}
return { value: temp }
}
export function hasWhitespace(value: string) {
return /\s/.test(value)
}