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
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ jobs:
rm -rf node_modules/lightningcss node_modules/@tailwindcss
npm install lightningcss @tailwindcss/postcss @tailwindcss/node

- name: Test Control Plane
run: npm test --workspace=hindsight-control-plane

- name: Build Control Plane
run: npm run build --workspace=hindsight-control-plane

Expand Down Expand Up @@ -3200,6 +3203,9 @@ jobs:
rm -rf node_modules/lightningcss node_modules/@tailwindcss
npm install lightningcss @tailwindcss/postcss @tailwindcss/node

- name: Test Control Plane
run: npm test --workspace=hindsight-control-plane

- name: Build Control Plane
run: npm run build --workspace=hindsight-control-plane

Expand Down
5 changes: 4 additions & 1 deletion hindsight-control-plane/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"build:standalone": "rm -rf standalone && SERVER_JS=$(find .next/standalone -path '*/node_modules' -prune -o -name 'server.js' -print | head -1) && test -n \"$SERVER_JS\" || (echo 'Error: server.js not found in .next/standalone - standalone build failed' && exit 1) && STANDALONE_ROOT=$(dirname \"$SERVER_JS\") && cp -r \"$STANDALONE_ROOT\" standalone && cp -r .next/standalone/node_modules standalone/node_modules && mkdir -p standalone/.next && cp -r .next/static standalone/.next/static && mkdir -p standalone/public && (cp -r public/* standalone/public/ 2>/dev/null || true)",
"start": "next start",
"lint": "next lint",
"test": "vitest run",
"test:watch": "vitest",
"prepublishOnly": "npm run build"
},
"keywords": [
Expand Down Expand Up @@ -81,6 +83,7 @@
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"prettier": "^3.7.4",
"typescript-eslint": "^8.50.0"
"typescript-eslint": "^8.50.0",
"vitest": "^4.1.7"
}
}
81 changes: 26 additions & 55 deletions hindsight-control-plane/src/app/api/banks/[bankId]/config/route.ts
Original file line number Diff line number Diff line change
@@ -1,77 +1,48 @@
import { NextRequest, NextResponse } from "next/server";
import { lowLevelClient, sdk } from "@/lib/hindsight-client";
import { respondWithSdk } from "@/lib/sdk-response";

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

const response = await sdk.getBankConfig({
client: lowLevelClient,
path: { bank_id: bankId },
});

if (!response.data) {
console.error("[Bank Config API] No data in response", { response, error: response.error });
throw new Error(`API returned no data: ${JSON.stringify(response.error || "Unknown error")}`);
}

return NextResponse.json(response.data, { status: 200 });
} catch (error) {
console.error("Error fetching bank config:", error);
return NextResponse.json({ error: "Failed to fetch bank config" }, { status: 500 });
}
const { bankId } = await params;
const response = await sdk.getBankConfig({
client: lowLevelClient,
path: { bank_id: bankId },
});
return respondWithSdk(response, "Failed to fetch bank config");
}

export async function PATCH(
request: NextRequest,
{ params }: { params: Promise<{ bankId: string }> }
) {
const { bankId } = await params;
let body;
try {
const { bankId } = await params;
const body = await request.json();
const { updates } = body;

const response = await sdk.updateBankConfig({
client: lowLevelClient,
path: { bank_id: bankId },
body: { updates },
});

if (!response.data) {
console.error("[Bank Config API] No data in response", { response, error: response.error });
throw new Error(`API returned no data: ${JSON.stringify(response.error || "Unknown error")}`);
}

return NextResponse.json(response.data, { status: 200 });
} catch (error) {
console.error("Error updating bank config:", error);
return NextResponse.json({ error: "Failed to update bank config" }, { status: 500 });
body = await request.json();
} catch {
return NextResponse.json({ error: "Invalid JSON body" }, { status: 400 });
}
const { updates } = body;

const response = await sdk.updateBankConfig({
client: lowLevelClient,
path: { bank_id: bankId },
body: { updates },
});
return respondWithSdk(response, "Failed to update bank config");
}

export async function DELETE(
request: NextRequest,
{ params }: { params: Promise<{ bankId: string }> }
) {
try {
const { bankId } = await params;

const response = await sdk.resetBankConfig({
client: lowLevelClient,
path: { bank_id: bankId },
});

if (!response.data) {
console.error("[Bank Config API] No data in response", { response, error: response.error });
throw new Error(`API returned no data: ${JSON.stringify(response.error || "Unknown error")}`);
}

return NextResponse.json(response.data, { status: 200 });
} catch (error) {
console.error("Error resetting bank config:", error);
return NextResponse.json({ error: "Failed to reset bank config" }, { status: 500 });
}
const { bankId } = await params;
const response = await sdk.resetBankConfig({
client: lowLevelClient,
path: { bank_id: bankId },
});
return respondWithSdk(response, "Failed to reset bank config");
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import { NextResponse } from "next/server";
import { sdk, lowLevelClient } from "@/lib/hindsight-client";
import { respondWithSdk } from "@/lib/sdk-response";

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

if (!bankId) {
return NextResponse.json({ error: "bank_id is required" }, { status: 400 });
}

const response = await sdk.triggerConsolidation({
client: lowLevelClient,
path: { bank_id: bankId },
});

if (response.error) {
console.error("API error triggering consolidation:", response.error);
return NextResponse.json({ error: "Failed to trigger consolidation" }, { status: 500 });
}

return NextResponse.json(response.data, { status: 200 });
} catch (error) {
console.error("Error triggering consolidation:", error);
return NextResponse.json({ error: "Failed to trigger consolidation" }, { status: 500 });
if (!bankId) {
return NextResponse.json({ error: "bank_id is required" }, { status: 400 });
}

const response = await sdk.triggerConsolidation({
client: lowLevelClient,
path: { bank_id: bankId },
});
return respondWithSdk(response, "Failed to trigger consolidation");
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
import { NextResponse } from "next/server";
import { sdk, lowLevelClient } from "@/lib/hindsight-client";
import { respondWithSdk } from "@/lib/sdk-response";

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

if (!bankId) {
return NextResponse.json({ error: "bank_id is required" }, { status: 400 });
}

const response = await sdk.recoverConsolidation({
client: lowLevelClient,
path: { bank_id: bankId },
});

if (response.error) {
console.error("API error recovering consolidation:", response.error);
return NextResponse.json({ error: "Failed to recover consolidation" }, { status: 500 });
}

return NextResponse.json(response.data, { status: 200 });
} catch (error) {
console.error("Error recovering consolidation:", error);
return NextResponse.json({ error: "Failed to recover consolidation" }, { status: 500 });
if (!bankId) {
return NextResponse.json({ error: "bank_id is required" }, { status: 400 });
}

const response = await sdk.recoverConsolidation({
client: lowLevelClient,
path: { bank_id: bankId },
});
return respondWithSdk(response, "Failed to recover consolidation");
}
Original file line number Diff line number Diff line change
@@ -1,40 +1,30 @@
import { NextResponse } from "next/server";
import { sdk, lowLevelClient, dataplaneBankUrl, getDataplaneHeaders } from "@/lib/hindsight-client";
import { respondWithSdk } from "@/lib/sdk-response";

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

if (!bankId) {
return NextResponse.json({ error: "bank_id is required" }, { status: 400 });
}

if (!operationId) {
return NextResponse.json({ error: "operation_id is required" }, { status: 400 });
}
const { bankId, operationId } = await params;

const url = new URL(request.url);
const includePayload = url.searchParams.get("include_payload") === "true";
if (!bankId) {
return NextResponse.json({ error: "bank_id is required" }, { status: 400 });
}

const response = await sdk.getOperationStatus({
client: lowLevelClient,
path: { bank_id: bankId, operation_id: operationId },
query: includePayload ? { include_payload: true } : undefined,
});
if (!operationId) {
return NextResponse.json({ error: "operation_id is required" }, { status: 400 });
}

if (response.error) {
console.error("API error getting operation status:", response.error);
return NextResponse.json({ error: "Failed to get operation status" }, { status: 500 });
}
const url = new URL(request.url);
const includePayload = url.searchParams.get("include_payload") === "true";

return NextResponse.json(response.data, { status: 200 });
} catch (error) {
console.error("Error getting operation status:", error);
return NextResponse.json({ error: "Failed to get operation status" }, { status: 500 });
}
const response = await sdk.getOperationStatus({
client: lowLevelClient,
path: { bank_id: bankId, operation_id: operationId },
query: includePayload ? { include_payload: true } : undefined,
});
return respondWithSdk(response, "Failed to get operation status");
}

export async function POST(
Expand Down
Loading