diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-config.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-config.tsx index 71cff8fe95..b61579ada2 100644 --- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-config.tsx +++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-config.tsx @@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next' import Button from '@/app/components/base/button' import VisualEditor from './visual-editor' import SchemaEditor from './schema-editor' -import { getValidationErrorMessage, jsonToSchema, validateSchemaAgainstDraft7 } from '../../utils' +import { jsonToSchema } from '../../utils' import { MittProvider, VisualEditorContextProvider } from './visual-editor/context' import ErrorMessage from './error-message' @@ -59,15 +59,15 @@ const JsonSchemaConfig: FC = ({ try { const schema = JSON.parse(json) setParseError(null) - const ajvError = validateSchemaAgainstDraft7(schema) - if (ajvError.length > 0) { - setValidationError(getValidationErrorMessage(ajvError)) - return - } - else { - setJsonSchema(schema) - setValidationError('') - } + // const ajvError = validateSchemaAgainstDraft7(schema) + // if (ajvError.length > 0) { + // setValidationError(getValidationErrorMessage(ajvError)) + // return + // } + // else { + setJsonSchema(schema) + setValidationError('') + // } } catch (error) { setValidationError('') @@ -117,15 +117,15 @@ const JsonSchemaConfig: FC = ({ try { schema = JSON.parse(json) setParseError(null) - const ajvError = validateSchemaAgainstDraft7(schema) - if (ajvError.length > 0) { - setValidationError(getValidationErrorMessage(ajvError)) - return - } - else { - setJsonSchema(schema) - setValidationError('') - } + // const ajvError = validateSchemaAgainstDraft7(schema) + // if (ajvError.length > 0) { + // setValidationError(getValidationErrorMessage(ajvError)) + // return + // } + // else { + setJsonSchema(schema) + setValidationError('') + // } } catch (error) { setValidationError('') diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/generated-result.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/generated-result.tsx index 56a174c176..2c96702450 100644 --- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/generated-result.tsx +++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-generator/generated-result.tsx @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next' import Button from '@/app/components/base/button' import CodeEditor from '../code-editor' import ErrorMessage from '../error-message' -import { getValidationErrorMessage, validateSchemaAgainstDraft7 } from '../../../utils' +// import { getValidationErrorMessage, validateSchemaAgainstDraft7 } from '../../../utils' type GeneratedResultProps = { schema: SchemaRoot @@ -44,14 +44,14 @@ const GeneratedResult: FC = ({ const jsonSchema = useMemo(() => formatJSON(schema), [schema]) const handleApply = useCallback(() => { - const ajvError = validateSchemaAgainstDraft7(schema) - if (ajvError.length > 0) { - setValidationError(getValidationErrorMessage(ajvError)) - } - else { - onApply() - setValidationError('') - } + // const ajvError = validateSchemaAgainstDraft7(schema) + // if (ajvError.length > 0) { + // setValidationError(getValidationErrorMessage(ajvError)) + // } + // else { + onApply() + setValidationError('') + // } }, [schema, onApply]) return ( diff --git a/web/app/components/workflow/nodes/llm/utils.ts b/web/app/components/workflow/nodes/llm/utils.ts index 16a8943e93..0daa3c4476 100644 --- a/web/app/components/workflow/nodes/llm/utils.ts +++ b/web/app/components/workflow/nodes/llm/utils.ts @@ -1,8 +1,8 @@ import { ArrayType, Type } from './types' import type { ArrayItems, Field, LLMNodeType } from './types' -import Ajv, { type ErrorObject } from 'ajv' -import draft7MetaSchema from 'ajv/dist/refs/json-schema-draft-07.json' -import produce from 'immer' +// import Ajv, { type ErrorObject } from 'ajv' +// import draft7MetaSchema from 'ajv/dist/refs/json-schema-draft-07.json' +// import produce from 'immer' export const checkNodeValid = (payload: LLMNodeType) => { return true @@ -83,29 +83,29 @@ export const findPropertyWithPath = (target: any, path: string[]) => { return current } -const ajv = new Ajv({ - allErrors: true, - verbose: true, - validateSchema: true, - meta: false, -}) -ajv.addMetaSchema(draft7MetaSchema) +// const ajv = new Ajv({ +// allErrors: true, +// verbose: true, +// validateSchema: true, +// meta: false, +// }) +// ajv.addMetaSchema(draft7MetaSchema) -export const validateSchemaAgainstDraft7 = (schemaToValidate: any) => { - const schema = produce(schemaToValidate, (draft: any) => { - // Make sure the schema has the $schema property for draft-07 - if (!draft.$schema) - draft.$schema = 'http://json-schema.org/draft-07/schema#' - }) +// export const validateSchemaAgainstDraft7 = (schemaToValidate: any) => { +// const schema = produce(schemaToValidate, (draft: any) => { +// // Make sure the schema has the $schema property for draft-07 +// if (!draft.$schema) +// draft.$schema = 'http://json-schema.org/draft-07/schema#' +// }) - const valid = ajv.validateSchema(schema) +// const valid = ajv.validateSchema(schema) - return valid ? [] : ajv.errors || [] -} +// return valid ? [] : ajv.errors || [] +// } -export const getValidationErrorMessage = (errors: ErrorObject[]) => { - const message = errors.map((error) => { - return `Error: ${error.instancePath} ${error.message} Details: ${JSON.stringify(error.params)}` - }).join('; ') - return message -} +// export const getValidationErrorMessage = (errors: ErrorObject[]) => { +// const message = errors.map((error) => { +// return `Error: ${error.instancePath} ${error.message} Details: ${JSON.stringify(error.params)}` +// }).join('; ') +// return message +// } diff --git a/web/package.json b/web/package.json index e76d38813e..2a55c558cf 100644 --- a/web/package.json +++ b/web/package.json @@ -54,7 +54,6 @@ "@tailwindcss/typography": "^0.5.15", "@tanstack/react-query": "^5.60.5", "@tanstack/react-query-devtools": "^5.60.5", - "ajv": "^8.17.1", "ahooks": "^3.8.4", "class-variance-authority": "^0.7.0", "classnames": "^2.5.1", @@ -133,10 +132,10 @@ }, "devDependencies": { "@antfu/eslint-config": "^4.1.1", - "@eslint/js": "^9.20.0", "@chromatic-com/storybook": "^3.1.0", "@eslint-react/eslint-plugin": "^1.15.0", "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.20.0", "@faker-js/faker": "^9.0.3", "@next/eslint-plugin-next": "^15.2.3", "@rgrove/parse-xml": "^4.1.0", @@ -175,11 +174,11 @@ "code-inspector-plugin": "^0.18.1", "cross-env": "^7.0.3", "eslint": "^9.20.1", + "eslint-config-next": "^15.0.0", "eslint-plugin-react-hooks": "^5.1.0", "eslint-plugin-react-refresh": "^0.4.19", "eslint-plugin-storybook": "^0.11.2", "eslint-plugin-tailwindcss": "^3.18.0", - "eslint-config-next": "^15.0.0", "husky": "^9.1.6", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml index 9c4bc51460..eb31f688d8 100644 --- a/web/pnpm-lock.yaml +++ b/web/pnpm-lock.yaml @@ -103,9 +103,6 @@ importers: ahooks: specifier: ^3.8.4 version: 3.8.4(react@19.0.0) - ajv: - specifier: ^8.17.1 - version: 8.17.1 class-variance-authority: specifier: ^0.7.0 version: 0.7.0