Skip to content
Draft
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
4 changes: 1 addition & 3 deletions apps/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"@radix-ui/react-select": "^2.2.6",
"@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-tabs": "^1.1.13",
"@c4c/core": "workspace:*",
"@c4c/workflow": "workspace:*",
"@c4c/workflow-react": "workspace:*",
"hono": "^4.9.12",
"@xyflow/react": "^12.8.6",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand Down
37 changes: 2 additions & 35 deletions apps/workflow/src/app/api/workflow/definitions/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,3 @@
/**
* API Route: GET /api/workflow/definitions/[id]
* Proxies request to backend server
*/
import { workflowRouter } from "@/server/useworkflow-router";

import { NextResponse } from "next/server";
import { config } from "@/lib/config";

export async function GET(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;

// Proxy request to backend server
const response = await fetch(`${config.apiBase}/workflow/definitions/${id}`, {
cache: "no-store",
});

const data = await response.json();

if (!response.ok) {
return NextResponse.json(data, { status: response.status });
}

// Backend returns { definition }, we want to return just the definition
return NextResponse.json(data.definition || data);
} catch (error) {
console.error("Failed to get workflow definition:", error);
return NextResponse.json(
{ error: "Failed to get workflow definition" },
{ status: 500 }
);
}
}
export const GET = (request: Request) => workflowRouter.fetch(request);
33 changes: 2 additions & 31 deletions apps/workflow/src/app/api/workflow/definitions/route.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
/**
* API Route: GET /api/workflow/definitions
* Proxies request to backend server
*/
import { workflowRouter } from "@/server/useworkflow-router";

import { NextResponse } from "next/server";
import { config } from "@/lib/config";

export async function GET() {
try {
// Proxy request to backend server
const response = await fetch(`${config.apiBase}/workflow/definitions`, {
cache: "no-store",
});

const data = await response.json();

if (!response.ok) {
return NextResponse.json(data, { status: response.status });
}

// Transform data to match expected format
const workflows = data.workflows || [];
return NextResponse.json(workflows);
} catch (error) {
console.error("Failed to get workflow definitions:", error);
return NextResponse.json(
{ error: "Failed to get workflow definitions" },
{ status: 500 }
);
}
}
export const GET = (request: Request) => workflowRouter.fetch(request);
40 changes: 2 additions & 38 deletions apps/workflow/src/app/api/workflow/execute/route.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
/**
* API Route: POST /api/workflow/execute
* Proxies request to backend server
*/
import { workflowRouter } from "@/server/useworkflow-router";

import { NextResponse } from "next/server";
import { config } from "@/lib/config";

export async function POST(request: Request) {
try {
const body = await request.json();

// Proxy request to backend server
const response = await fetch(`${config.apiBase}/workflow/execute`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});

const data = await response.json();

if (!response.ok) {
return NextResponse.json(data, { status: response.status });
}

return NextResponse.json(data);
} catch (error) {
console.error("Failed to execute workflow:", error);
return NextResponse.json(
{
error: "Failed to execute workflow",
message: error instanceof Error ? error.message : String(error),
},
{ status: 500 }
);
}
}
export const POST = (request: Request) => workflowRouter.fetch(request);
38 changes: 2 additions & 36 deletions apps/workflow/src/app/api/workflow/executions-stream/route.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,5 @@
/**
* API Route: GET /api/workflow/executions-stream
* Proxies SSE stream for updates of all executions
*/

import { config } from "@/lib/config";
import { workflowRouter } from "@/server/useworkflow-router";

export const dynamic = "force-dynamic";

export async function GET(request: Request) {
try {
// Proxy SSE stream from backend server
const response = await fetch(`${config.apiBase}/workflow/executions-stream`, {
signal: request.signal,
});

if (!response.ok) {
return new Response(JSON.stringify({ error: "Failed to connect to stream" }), {
status: response.status,
headers: { "Content-Type": "application/json" },
});
}

// Forward the SSE stream
return new Response(response.body, {
headers: {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache, no-transform",
Connection: "keep-alive",
},
});
} catch (error) {
console.error("Failed to proxy SSE stream:", error);
return new Response(JSON.stringify({ error: "Failed to connect to stream" }), {
status: 500,
headers: { "Content-Type": "application/json" },
});
}
}
export const GET = (request: Request) => workflowRouter.fetch(request);
37 changes: 2 additions & 35 deletions apps/workflow/src/app/api/workflow/executions/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
/**
* API Route: GET /api/workflow/executions/[id]
* Proxies request to backend server
*/

import { NextResponse } from "next/server";
import { config } from "@/lib/config";
import { workflowRouter } from "@/server/useworkflow-router";

export const dynamic = "force-dynamic";

export async function GET(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;

// Proxy request to backend server
const response = await fetch(`${config.apiBase}/workflow/executions/${id}`, {
cache: "no-store",
});

const data = await response.json();

if (!response.ok) {
return NextResponse.json(data, { status: response.status });
}

// Backend returns { execution }, we want to return just the execution
return NextResponse.json(data.execution || data);
} catch (error) {
console.error("Failed to get execution:", error);
return NextResponse.json(
{ error: "Failed to get execution" },
{ status: 500 }
);
}
}
export const GET = (request: Request) => workflowRouter.fetch(request);
41 changes: 2 additions & 39 deletions apps/workflow/src/app/api/workflow/executions/[id]/stream/route.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,5 @@
/**
* API Route: GET /api/workflow/executions/[id]/stream
* Proxies SSE stream to backend server
*/

import { config } from "@/lib/config";
import { workflowRouter } from "@/server/useworkflow-router";

export const dynamic = "force-dynamic";

export async function GET(
request: Request,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;

try {
const response = await fetch(`${config.apiBase}/workflow/executions/${id}/stream`, {
signal: request.signal,
});

if (!response.ok) {
return new Response(JSON.stringify({ error: "Failed to connect to stream" }), {
status: response.status,
headers: { "Content-Type": "application/json" },
});
}

return new Response(response.body, {
headers: {
"Content-Type": "text/event-stream",
"Cache-Control": "no-cache, no-transform",
Connection: "keep-alive",
},
});
} catch (error) {
console.error("Failed to proxy SSE stream:", error);
return new Response(JSON.stringify({ error: "Failed to connect to stream" }), {
status: 500,
headers: { "Content-Type": "application/json" },
});
}
}
export const GET = (request: Request) => workflowRouter.fetch(request);
31 changes: 2 additions & 29 deletions apps/workflow/src/app/api/workflow/executions/route.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
/**
* API Route: GET /api/workflow/executions
* Proxies request to backend server
*/

import { NextResponse } from "next/server";
import { config } from "@/lib/config";
import { workflowRouter } from "@/server/useworkflow-router";

export const dynamic = "force-dynamic";

export async function GET() {
try {
// Proxy request to backend server
const response = await fetch(`${config.apiBase}/workflow/executions`, {
cache: "no-store",
});

const data = await response.json();

if (!response.ok) {
return NextResponse.json(data, { status: response.status });
}

return NextResponse.json(data);
} catch (error) {
console.error("Failed to get executions:", error);
return NextResponse.json(
{ error: "Failed to get executions" },
{ status: 500 }
);
}
}
export const GET = (request: Request) => workflowRouter.fetch(request);
Loading