mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-14 14:31:00 +00:00
fix(web): resolve zodResolver type mismatch for optional description fields
Remove .default('') from zod schemas to align input/output types,
preventing type conflict between zodResolver and useForm in
@hookform/resolvers v5. Use nullish coalescing at entity assignment
sites to ensure string type safety.
This commit is contained in:
@@ -53,7 +53,7 @@ import { CustomApiError } from '@/app/infra/entities/common';
|
|||||||
const getFormSchema = (t: (key: string) => string) =>
|
const getFormSchema = (t: (key: string) => string) =>
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string().min(1, { message: t('bots.botNameRequired') }),
|
name: z.string().min(1, { message: t('bots.botNameRequired') }),
|
||||||
description: z.string().optional().default(''),
|
description: z.string().optional(),
|
||||||
adapter: z.string().min(1, { message: t('bots.adapterRequired') }),
|
adapter: z.string().min(1, { message: t('bots.adapterRequired') }),
|
||||||
adapter_config: z.record(z.string(), z.any()),
|
adapter_config: z.record(z.string(), z.any()),
|
||||||
enable: z.boolean().optional(),
|
enable: z.boolean().optional(),
|
||||||
@@ -337,7 +337,7 @@ export default function BotForm({
|
|||||||
const updateBot: Bot = {
|
const updateBot: Bot = {
|
||||||
uuid: initBotId,
|
uuid: initBotId,
|
||||||
name: form.getValues().name,
|
name: form.getValues().name,
|
||||||
description: form.getValues().description,
|
description: form.getValues().description ?? '',
|
||||||
adapter: form.getValues().adapter,
|
adapter: form.getValues().adapter,
|
||||||
adapter_config: form.getValues().adapter_config,
|
adapter_config: form.getValues().adapter_config,
|
||||||
enable: form.getValues().enable,
|
enable: form.getValues().enable,
|
||||||
@@ -360,7 +360,7 @@ export default function BotForm({
|
|||||||
} else {
|
} else {
|
||||||
const newBot: Bot = {
|
const newBot: Bot = {
|
||||||
name: form.getValues().name,
|
name: form.getValues().name,
|
||||||
description: form.getValues().description,
|
description: form.getValues().description ?? '',
|
||||||
adapter: form.getValues().adapter,
|
adapter: form.getValues().adapter,
|
||||||
adapter_config: form.getValues().adapter_config,
|
adapter_config: form.getValues().adapter_config,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import { UUID } from 'uuidjs';
|
|||||||
const getFormSchema = (t: (key: string) => string) =>
|
const getFormSchema = (t: (key: string) => string) =>
|
||||||
z.object({
|
z.object({
|
||||||
name: z.string().min(1, { message: t('knowledge.kbNameRequired') }),
|
name: z.string().min(1, { message: t('knowledge.kbNameRequired') }),
|
||||||
description: z.string().optional().default(''),
|
description: z.string().optional(),
|
||||||
emoji: z.string().optional(),
|
emoji: z.string().optional(),
|
||||||
ragEngineId: z
|
ragEngineId: z
|
||||||
.string()
|
.string()
|
||||||
@@ -238,7 +238,7 @@ export default function KBForm({
|
|||||||
const onSubmit = (data: z.infer<typeof formSchema>) => {
|
const onSubmit = (data: z.infer<typeof formSchema>) => {
|
||||||
const kbData: KnowledgeBase = {
|
const kbData: KnowledgeBase = {
|
||||||
name: data.name,
|
name: data.name,
|
||||||
description: data.description,
|
description: data.description ?? '',
|
||||||
emoji: data.emoji,
|
emoji: data.emoji,
|
||||||
knowledge_engine_plugin_id: selectedEngineId,
|
knowledge_engine_plugin_id: selectedEngineId,
|
||||||
creation_settings: configSettings,
|
creation_settings: configSettings,
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ export default function PipelineFormComponent({
|
|||||||
? z.object({
|
? z.object({
|
||||||
basic: z.object({
|
basic: z.object({
|
||||||
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
|
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
|
||||||
description: z.string().optional().default(''),
|
description: z.string().optional(),
|
||||||
emoji: z.string().optional(),
|
emoji: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
ai: z.record(z.string(), z.any()),
|
ai: z.record(z.string(), z.any()),
|
||||||
@@ -91,7 +91,7 @@ export default function PipelineFormComponent({
|
|||||||
: z.object({
|
: z.object({
|
||||||
basic: z.object({
|
basic: z.object({
|
||||||
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
|
name: z.string().min(1, { message: t('pipelines.nameRequired') }),
|
||||||
description: z.string().optional().default(''),
|
description: z.string().optional(),
|
||||||
emoji: z.string().optional(),
|
emoji: z.string().optional(),
|
||||||
}),
|
}),
|
||||||
ai: z.record(z.string(), z.any()).optional(),
|
ai: z.record(z.string(), z.any()).optional(),
|
||||||
@@ -253,7 +253,7 @@ export default function PipelineFormComponent({
|
|||||||
function handleCreate(values: FormValues) {
|
function handleCreate(values: FormValues) {
|
||||||
const pipeline: Pipeline = {
|
const pipeline: Pipeline = {
|
||||||
config: {},
|
config: {},
|
||||||
description: values.basic.description,
|
description: values.basic.description ?? '',
|
||||||
name: values.basic.name,
|
name: values.basic.name,
|
||||||
emoji: values.basic.emoji,
|
emoji: values.basic.emoji,
|
||||||
};
|
};
|
||||||
@@ -280,7 +280,7 @@ export default function PipelineFormComponent({
|
|||||||
const pipeline: Pipeline = {
|
const pipeline: Pipeline = {
|
||||||
config: realConfig,
|
config: realConfig,
|
||||||
// created_at: '',
|
// created_at: '',
|
||||||
description: values.basic.description,
|
description: values.basic.description ?? '',
|
||||||
// for_version: '',
|
// for_version: '',
|
||||||
name: values.basic.name,
|
name: values.basic.name,
|
||||||
emoji: values.basic.emoji,
|
emoji: values.basic.emoji,
|
||||||
|
|||||||
Reference in New Issue
Block a user