fix: allow saving imported workflow brand trees
This commit is contained in:
parent
0f1548fdc9
commit
ba539ce236
@ -1974,7 +1974,32 @@ export function AgentWorkflowSettingsClient({
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("保存失败");
|
let message = "保存失败";
|
||||||
|
|
||||||
|
try {
|
||||||
|
const payload = await response.json();
|
||||||
|
if (Array.isArray(payload?.details) && payload.details.length > 0) {
|
||||||
|
const firstIssue = payload.details[0] as {
|
||||||
|
message?: string;
|
||||||
|
path?: Array<string | number>;
|
||||||
|
};
|
||||||
|
const pathText =
|
||||||
|
Array.isArray(firstIssue.path) && firstIssue.path.length > 0
|
||||||
|
? firstIssue.path
|
||||||
|
.filter((segment) => segment !== undefined && segment !== null && segment !== "")
|
||||||
|
.join(" / ")
|
||||||
|
: "";
|
||||||
|
const reasonText = String(firstIssue.message || "").trim();
|
||||||
|
|
||||||
|
message = [payload?.error, pathText, reasonText].filter(Boolean).join(":");
|
||||||
|
} else if (typeof payload?.error === "string" && payload.error.trim()) {
|
||||||
|
message = payload.error.trim();
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Ignore JSON parsing issues and keep the generic message.
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success("智能体工作流配置已保存");
|
toast.success("智能体工作流配置已保存");
|
||||||
|
|||||||
@ -631,6 +631,8 @@ export async function GET() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS = 5000;
|
||||||
|
|
||||||
const updateSchema = z.object({
|
const updateSchema = z.object({
|
||||||
siteName: z.string().min(1).max(128).optional(),
|
siteName: z.string().min(1).max(128).optional(),
|
||||||
siteLogo: z.string().nullable().optional(),
|
siteLogo: z.string().nullable().optional(),
|
||||||
@ -728,8 +730,14 @@ const updateSchema = z.object({
|
|||||||
.object({
|
.object({
|
||||||
inputOptions: z
|
inputOptions: z
|
||||||
.object({
|
.object({
|
||||||
brands: z.array(z.string().trim().min(1).max(64)).max(300).optional(),
|
brands: z
|
||||||
stores: z.array(z.string().trim().min(1).max(64)).max(300).optional(),
|
.array(z.string().trim().min(1).max(64))
|
||||||
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
|
.optional(),
|
||||||
|
stores: z
|
||||||
|
.array(z.string().trim().min(1).max(64))
|
||||||
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
|
.optional(),
|
||||||
categoryLabels: z
|
categoryLabels: z
|
||||||
.object({
|
.object({
|
||||||
thirdCategory: z.string().trim().min(1).max(24).optional(),
|
thirdCategory: z.string().trim().min(1).max(24).optional(),
|
||||||
@ -737,22 +745,37 @@ const updateSchema = z.object({
|
|||||||
fifthCategory: z.string().trim().min(1).max(24).optional(),
|
fifthCategory: z.string().trim().min(1).max(24).optional(),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
thirdCategories: z.array(z.string().trim().min(1).max(64)).max(300).optional(),
|
thirdCategories: z
|
||||||
fourthCategories: z.array(z.string().trim().min(1).max(64)).max(300).optional(),
|
.array(z.string().trim().min(1).max(64))
|
||||||
fifthCategories: z.array(z.string().trim().min(1).max(64)).max(300).optional(),
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
priceBands: z.array(z.string().trim().min(1).max(64)).max(300).optional(),
|
.optional(),
|
||||||
|
fourthCategories: z
|
||||||
|
.array(z.string().trim().min(1).max(64))
|
||||||
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
|
.optional(),
|
||||||
|
fifthCategories: z
|
||||||
|
.array(z.string().trim().min(1).max(64))
|
||||||
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
|
.optional(),
|
||||||
|
priceBands: z
|
||||||
|
.array(z.string().trim().min(1).max(64))
|
||||||
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
|
.optional(),
|
||||||
brandStoreEntries: z
|
brandStoreEntries: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
brandName: z.string().trim().min(1).max(64),
|
brandName: z.string().trim().min(1).max(64),
|
||||||
stores: z.array(z.string().trim().min(1).max(64)).max(300).optional(),
|
stores: z
|
||||||
|
.array(z.string().trim().min(1).max(64))
|
||||||
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
|
.optional(),
|
||||||
storeEntries: z
|
storeEntries: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
storeName: z.string().trim().min(1).max(64),
|
storeName: z.string().trim().min(1).max(64),
|
||||||
thirdCategories: z
|
thirdCategories: z
|
||||||
.array(z.string().trim().min(1).max(64))
|
.array(z.string().trim().min(1).max(64))
|
||||||
.max(300)
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
.optional(),
|
.optional(),
|
||||||
thirdCategoryEntries: z
|
thirdCategoryEntries: z
|
||||||
.array(
|
.array(
|
||||||
@ -760,7 +783,7 @@ const updateSchema = z.object({
|
|||||||
categoryName: z.string().trim().min(1).max(64),
|
categoryName: z.string().trim().min(1).max(64),
|
||||||
fourthCategories: z
|
fourthCategories: z
|
||||||
.array(z.string().trim().min(1).max(64))
|
.array(z.string().trim().min(1).max(64))
|
||||||
.max(300)
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
.optional(),
|
.optional(),
|
||||||
fourthCategoryEntries: z
|
fourthCategoryEntries: z
|
||||||
.array(
|
.array(
|
||||||
@ -768,27 +791,27 @@ const updateSchema = z.object({
|
|||||||
categoryName: z.string().trim().min(1).max(64),
|
categoryName: z.string().trim().min(1).max(64),
|
||||||
fifthCategories: z
|
fifthCategories: z
|
||||||
.array(z.string().trim().min(1).max(64))
|
.array(z.string().trim().min(1).max(64))
|
||||||
.max(300)
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
.optional(),
|
.optional(),
|
||||||
sortOrder: z.number().min(0).max(999).optional(),
|
sortOrder: z.number().min(0).max(999).optional(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.max(300)
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
.optional(),
|
.optional(),
|
||||||
sortOrder: z.number().min(0).max(999).optional(),
|
sortOrder: z.number().min(0).max(999).optional(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.max(300)
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
.optional(),
|
.optional(),
|
||||||
sortOrder: z.number().min(0).max(999).optional(),
|
sortOrder: z.number().min(0).max(999).optional(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.max(300)
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
.optional(),
|
.optional(),
|
||||||
sortOrder: z.number().min(0).max(999).optional(),
|
sortOrder: z.number().min(0).max(999).optional(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.max(300)
|
.max(AGENT_WORKFLOW_INPUT_OPTIONS_MAX_ITEMS)
|
||||||
.optional(),
|
.optional(),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user