mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
add datagrid field type
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { ICommonObject, IDatabaseEntity, INode, INodeData, INodeOptionsValue, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { convertSchemaToZod, getBaseClasses } from '../../../src/utils'
|
||||
import { DynamicStructuredTool } from './core'
|
||||
import { z } from 'zod'
|
||||
import { DataSource } from 'typeorm'
|
||||
@@ -87,26 +87,4 @@ class CustomTool_Tools implements INode {
|
||||
}
|
||||
}
|
||||
|
||||
const convertSchemaToZod = (schema: string) => {
|
||||
try {
|
||||
const parsedSchema = JSON.parse(schema)
|
||||
const zodObj: any = {}
|
||||
for (const sch of parsedSchema) {
|
||||
if (sch.type === 'string') {
|
||||
if (sch.required) z.string({ required_error: `${sch.property} required` }).describe(sch.description)
|
||||
zodObj[sch.property] = z.string().describe(sch.description)
|
||||
} else if (sch.type === 'number') {
|
||||
if (sch.required) z.number({ required_error: `${sch.property} required` }).describe(sch.description)
|
||||
zodObj[sch.property] = z.number().describe(sch.description)
|
||||
} else if (sch.type === 'boolean') {
|
||||
if (sch.required) z.boolean({ required_error: `${sch.property} required` }).describe(sch.description)
|
||||
zodObj[sch.property] = z.boolean().describe(sch.description)
|
||||
}
|
||||
}
|
||||
return zodObj
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { nodeClass: CustomTool_Tools }
|
||||
|
||||
Reference in New Issue
Block a user