fix(wizard): unique names on createStep/View/Version to avoid (tenant_id,name,kind) collisions

This commit is contained in:
2026-06-14 14:44:51 +04:00
parent b951724c5f
commit 338864a8e1
+6 -3
View File
@@ -122,7 +122,8 @@ export const wizardApi = {
ops: { ops: {
createStep(node: { display_name: string; dispatch_kind: string; agent_capability?: string; description?: string }): CreateOp { createStep(node: { display_name: string; dispatch_kind: string; agent_capability?: string; description?: string }): CreateOp {
const name = node.display_name.toLowerCase().replace(/[^a-z0-9]+/g, "_").slice(0, 40) || "step"; const slug = node.display_name.toLowerCase().replace(/[^a-z0-9]+/g, "_").slice(0, 30) || "step";
const name = `${slug}_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
return { return {
op: "create", op: "create",
coll: "flow", coll: "flow",
@@ -139,7 +140,8 @@ export const wizardApi = {
}; };
}, },
createView(node: { display_name: string }): CreateOp { createView(node: { display_name: string }): CreateOp {
const name = `${node.display_name.toLowerCase().replace(/[^a-z0-9]+/g, "_").slice(0, 40) || "view"}_view`; const slug = node.display_name.toLowerCase().replace(/[^a-z0-9]+/g, "_").slice(0, 30) || "view";
const name = `${slug}_view_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
return { return {
op: "create", op: "create",
coll: "view", coll: "view",
@@ -162,7 +164,8 @@ export const wizardApi = {
}; };
}, },
createVersion(parentDisplayName: string): CreateOp { createVersion(parentDisplayName: string): CreateOp {
const name = `${parentDisplayName.toLowerCase().replace(/[^a-z0-9]+/g, "_").slice(0, 40) || "process"}_v1`; const slug = parentDisplayName.toLowerCase().replace(/[^a-z0-9]+/g, "_").slice(0, 30) || "process";
const name = `${slug}_v1_${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
return { return {
op: "create", op: "create",
coll: "version", coll: "version",