Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions apps/http-backend/src/routes/userRoutes/userRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,9 @@ router.get(
"Error Fetching the credentials ",
e instanceof Error ? e.message : "Unknown reason"
);
return res
.status(statusCodes.INTERNAL_SERVER_ERROR)
.json({
message: "Internal server error from fetching the credentials",
});
return res.status(statusCodes.INTERNAL_SERVER_ERROR).json({
message: "Internal server error from fetching the credentials",
});
}
}
);
Expand Down Expand Up @@ -433,7 +431,6 @@ router.get(
}
);


// router.put("/workflow/update" , userMiddleware , (req : AuthRequest , res : Response) => {

// })
Expand Down Expand Up @@ -508,7 +505,7 @@ router.post(
});
}
const data = req.body;
console.log(" from http-backeden" , data);
console.log(" from http-backeden", data);

const dataSafe = NodeSchema.safeParse(data);
console.log("The error is ", dataSafe.error);
Expand All @@ -525,10 +522,10 @@ router.post(
data: {
name: dataSafe.data.Name,
workflowId: dataSafe.data.WorkflowId,
config: dataSafe.data.Config || {},
stage: Number(dataSafe.data.stage ?? 0),
position: {},
AvailableNodeID: dataSafe.data.AvailableNodeId,
config: {}, // Config is an empty object by default
stage: Number(dataSafe.data.stage),
position: {}
},
});

Expand Down Expand Up @@ -628,8 +625,6 @@ router.put(
}
);



router.get("/protected", userMiddleware, (req: AuthRequest, res) => {
return res.json({
ok: true,
Expand Down
9 changes: 5 additions & 4 deletions apps/web/app/workflows/[id]/components/ConfigModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { getNodeConfig } from "@/app/lib/nodeConfigs";
import { useState } from "react";
import { HOOKS_URL } from "@repo/common/zod";
import { userAction } from "@/store/slices/userSlice";
import { useAppSelector } from "@/app/hooks/redux";
interface ConfigModalProps {
isOpen: boolean;
Expand All @@ -19,10 +18,12 @@ export default function ConfigModal({
onSave,
}: ConfigModalProps) {
const [loading, setLoading] = useState(false);

const userId = useAppSelector(
(state) => state.user.userId
) as unknown as string;
console.log("we are getting this userId from ConfigModal", userId);
if (!isOpen || !selectedNode) return null;
const userId = useAppSelector((state) => state.user.userId) as unknown as string;
console.log("we are getting this userId from ConfigModal" , userId)

const handleSave = async () => {
setLoading(true);
try {
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/workflows/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export default function WorkflowCanvas() {
const isTrigger =
nodes.find((n) => n.id === nodeId)?.data.nodeType === "trigger";
if (isTrigger) {
await api.triggers.update({ TriggerId: nodeId, Config: config});
await api.triggers.update({ TriggerId: nodeId, Config: config });
} else {
await api.nodes.update({ NodeId: nodeId, Config: config });
}
Expand Down
19 changes: 11 additions & 8 deletions packages/db/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ model User {
}

model Credential {
id String @id @default(uuid())
id String @id @default(uuid())
userId String
type String
config Json
nodeId String?
node Node? @relation(fields: [nodeId], references: [id])
user User @relation(fields: [userId], references: [id])
// Node_Node_CredentialsIDToCredential Node[] @relation("Node_CredentialsIDToCredential")
node Node? @relation(fields: [nodeId], references: [id])
user User @relation(fields: [userId], references: [id])
Node_Node_CredentialsIDToCredential Node[] @relation("Node_CredentialsIDToCredential")
Trigger Trigger[]
}

model Trigger {
Expand All @@ -35,7 +36,9 @@ model Trigger {
config Json
workflowId String? @unique
AvailableTriggerID String
CredentialsID String?
triggerType AvailableTrigger @relation(fields: [AvailableTriggerID], references: [id])
Credential Credential? @relation(fields: [CredentialsID], references: [id])
workflow Workflow? @relation(fields: [workflowId], references: [id])
}

Expand All @@ -62,14 +65,14 @@ model Node {
id String @id @default(uuid())
name String
config Json
position Json
stage Int
workflowId String?
AvailableNodeID String
// CredentialsID String
CredentialsID String?
position Json?
credentials Credential[]
AvailableNode AvailableNode? @relation(fields: [AvailableNodeID], references: [id])
// Credential_Node_CredentialsIDToCredential Credential @relation("Node_CredentialsIDToCredential", fields: [CredentialsID], references: [id], onDelete: Cascade)
AvailableNode AvailableNode @relation(fields: [AvailableNodeID], references: [id])
Credential_Node_CredentialsIDToCredential Credential? @relation("Node_CredentialsIDToCredential", fields: [CredentialsID], references: [id])
Comment on lines +71 to +75
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat packages/db/prisma/schema.prisma

Repository: Dev-Pross/BuildFlow

Length of output: 4928


🏁 Script executed:

find packages/db -type f \( -name "*.sql" -o -name "*.ts" \) -path "*/migration*" | head -20

Repository: Dev-Pross/BuildFlow

Length of output: 45


🏁 Script executed:

find packages/db -type d -name "migrations" -o -name "prisma"
ls -la packages/db/prisma/

Repository: Dev-Pross/BuildFlow

Length of output: 345


🏁 Script executed:

ls -la packages/db/prisma/migrations/ && echo "---" && find packages/db/prisma/migrations -type f -name "*.sql" | sort

Repository: Dev-Pross/BuildFlow

Length of output: 243


🏁 Script executed:

cat packages/db/prisma/migrations/migration_lock.toml
echo "---"
git log --oneline packages/db/prisma/schema.prisma | head -10

Repository: Dev-Pross/BuildFlow

Length of output: 267


🏁 Script executed:

git show 83ab84d:packages/db/prisma/schema.prisma | grep -A 20 "model Node"
echo "---CURRENT---"
git show HEAD:packages/db/prisma/schema.prisma | grep -A 20 "model Node"

Repository: Dev-Pross/BuildFlow

Length of output: 4300


🏁 Script executed:

git log --oneline packages/db/prisma/schema.prisma | head -20

Repository: Dev-Pross/BuildFlow

Length of output: 135


🏁 Script executed:

git branch -a
echo "---"
git log --all --oneline -- packages/db/prisma/schema.prisma
echo "---"
git status packages/db/prisma/

Repository: Dev-Pross/BuildFlow

Length of output: 1734


🏁 Script executed:

# Check the schema in a few earlier commits to see AvailableNodeID state
git show cd00170:packages/db/prisma/schema.prisma 2>/dev/null | grep -A 15 "model Node" || echo "File not found in cd00170"
echo "---"
git show be91f24:packages/db/prisma/schema.prisma 2>/dev/null | grep -A 15 "model Node" || echo "File not found in be91f24"
echo "---"
git show 85a5ad6:packages/db/prisma/schema.prisma 2>/dev/null | grep -A 15 "model Node" || echo "File not found in 85a5ad6"

Repository: Dev-Pross/BuildFlow

Length of output: 1636


🏁 Script executed:

# Check more recent commits
git show 81945da:packages/db/prisma/schema.prisma 2>/dev/null | grep -A 20 "model Node" || echo "File not found in 81945da"
echo "---"
git show 5b8ae59:packages/db/prisma/schema.prisma 2>/dev/null | grep -A 20 "model Node" || echo "File not found in 5b8ae59"
echo "---"
git show 2c89b31:packages/db/prisma/schema.prisma 2>/dev/null | grep -A 20 "model Node" || echo "File not found in 2c89b31"

Repository: Dev-Pross/BuildFlow

Length of output: 4631


🏁 Script executed:

# Check when CredentialsID and credential relations were added
git show f556da3:packages/db/prisma/schema.prisma 2>/dev/null | grep -A 20 "model Node" || echo "File not found in f556da3"
echo "---"
git show 83ab84d:packages/db/prisma/schema.prisma 2>/dev/null | grep -A 20 "model Node" || echo "File not found in 83ab84d"
echo "---CURRENT---"
head -85 packages/db/prisma/schema.prisma | tail -20

Repository: Dev-Pross/BuildFlow

Length of output: 5358


Address breaking change: AvailableNode relation is now mandatory.

The schema was updated to make AvailableNode required (changed from AvailableNode? to AvailableNode). This is a breaking change—existing Node records without a valid AvailableNodeID will violate constraints. Create a database migration to handle this before deploying:

  • Set default AvailableNodeID values for existing records, or
  • Delete nodes without valid references, or
  • Make this change on a fresh database only.

Credential relationships are intentionally dual-pattern. Node now has two credential associations:

  1. credentials Credential[] (many credentials per node via nodeId FK on Credential)
  2. Credential_Node_CredentialsIDToCredential Credential? (optional primary credential via CredentialsID FK on Node)

This allows a node to reference multiple credentials while optionally designating one as primary. Confirm this design matches your requirements.

🤖 Prompt for AI Agents
In `@packages/db/prisma/schema.prisma` around lines 71 - 75, The schema change
made AvailableNode mandatory on the Node model (AvailableNode changed from
optional to required), which will break existing rows lacking AvailableNodeID;
create a migration to handle existing data before applying this schema change:
either backfill Node.AvailableNodeID with a valid AvailableNode.id (e.g., pick a
default/placeholder AvailableNode row) or remove Node rows without a matching
AvailableNode, then apply the schema change; if you prefer a safer multi-step
deploy, revert the schema to keep AvailableNode optional, add a script to
populate/fix AvailableNodeID for all Node rows, run that migration/script in
production, and only then change AvailableNode to required. Also verify the dual
credential relations (credentials: Credential[] and
Credential_Node_CredentialsIDToCredential: Credential?) meet requirements and
that CredentialsID foreign keys are consistent before deploying.

workflow Workflow? @relation(fields: [workflowId], references: [id])
executions NodeExecution[]
}
Expand Down
Loading