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:
@@ -6,6 +6,7 @@ export type NodeParamsType =
|
||||
| 'asyncOptions'
|
||||
| 'options'
|
||||
| 'multiOptions'
|
||||
| 'datagrid'
|
||||
| 'string'
|
||||
| 'number'
|
||||
| 'boolean'
|
||||
@@ -60,6 +61,7 @@ export interface INodeParams {
|
||||
description?: string
|
||||
warning?: string
|
||||
options?: Array<INodeOptionsValue>
|
||||
datagrid?: Array<ICommonObject>
|
||||
credentialNames?: Array<string>
|
||||
optional?: boolean | INodeDisplay
|
||||
step?: number
|
||||
|
||||
@@ -3,6 +3,7 @@ import { load } from 'cheerio'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { JSDOM } from 'jsdom'
|
||||
import { z } from 'zod'
|
||||
import { DataSource } from 'typeorm'
|
||||
import { ICommonObject, IDatabaseEntity, IMessage, INodeData } from './Interface'
|
||||
import { AES, enc } from 'crypto-js'
|
||||
@@ -546,3 +547,30 @@ export const convertChatHistoryToText = (chatHistory: IMessage[] = []): string =
|
||||
})
|
||||
.join('\n')
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert schema to zod schema
|
||||
* @param {string} schema
|
||||
* @returns {ICommonObject}
|
||||
*/
|
||||
export const convertSchemaToZod = (schema: string) => {
|
||||
try {
|
||||
const parsedSchema = JSON.parse(schema)
|
||||
const zodObj: ICommonObject = {}
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user