mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-22 12:58:29 +00:00
Fix: delete episode api -> ingestion delete api
This commit is contained in:
parent
7fa0320d91
commit
ac811bfcb3
@ -310,7 +310,7 @@ export const Graph = forwardRef<GraphRef, GraphProps>(
|
|||||||
...settings,
|
...settings,
|
||||||
barnesHutOptimize: true,
|
barnesHutOptimize: true,
|
||||||
strongGravityMode: false,
|
strongGravityMode: false,
|
||||||
gravity: 0.1,
|
gravity: 1,
|
||||||
scalingRatio: 10,
|
scalingRatio: 10,
|
||||||
slowDown: 5,
|
slowDown: 5,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -20,6 +20,7 @@ interface LogTextCollapseProps {
|
|||||||
text?: string;
|
text?: string;
|
||||||
error?: string;
|
error?: string;
|
||||||
logData: any;
|
logData: any;
|
||||||
|
id: string;
|
||||||
episodeUUID?: string;
|
episodeUUID?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ export function LogTextCollapse({
|
|||||||
episodeUUID,
|
episodeUUID,
|
||||||
text,
|
text,
|
||||||
error,
|
error,
|
||||||
|
id,
|
||||||
logData,
|
logData,
|
||||||
}: LogTextCollapseProps) {
|
}: LogTextCollapseProps) {
|
||||||
const [dialogOpen, setDialogOpen] = useState(false);
|
const [dialogOpen, setDialogOpen] = useState(false);
|
||||||
@ -34,17 +36,16 @@ export function LogTextCollapse({
|
|||||||
const deleteFetcher = useFetcher();
|
const deleteFetcher = useFetcher();
|
||||||
|
|
||||||
const handleDelete = () => {
|
const handleDelete = () => {
|
||||||
console.log(logData);
|
|
||||||
if (!episodeUUID) {
|
if (!episodeUUID) {
|
||||||
console.error("No episodeUuid found in log data");
|
console.error("No episodeUuid found in log data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteFetcher.submit(
|
deleteFetcher.submit(
|
||||||
{ episodeUuid: episodeUUID },
|
{ id },
|
||||||
{
|
{
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
action: "/api/v1/episode/delete",
|
action: "/api/v1/ingestion_queue/delete",
|
||||||
encType: "application/json",
|
encType: "application/json",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@ -100,6 +100,7 @@ function LogItemRenderer(
|
|||||||
text={log.ingestText}
|
text={log.ingestText}
|
||||||
error={log.error}
|
error={log.error}
|
||||||
logData={log.data}
|
logData={log.data}
|
||||||
|
id={log.id}
|
||||||
episodeUUID={log.episodeUUID}
|
episodeUUID={log.episodeUUID}
|
||||||
/>
|
/>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@ -2,9 +2,13 @@ import { z } from "zod";
|
|||||||
import { json } from "@remix-run/node";
|
import { json } from "@remix-run/node";
|
||||||
import { createHybridActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
|
import { createHybridActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
|
||||||
import { deleteEpisodeWithRelatedNodes } from "~/services/graphModels/episode";
|
import { deleteEpisodeWithRelatedNodes } from "~/services/graphModels/episode";
|
||||||
|
import {
|
||||||
|
deleteIngestionQueue,
|
||||||
|
getIngestionQueue,
|
||||||
|
} from "~/services/ingestionLogs.server";
|
||||||
|
|
||||||
export const DeleteEpisodeBodyRequest = z.object({
|
export const DeleteEpisodeBodyRequest = z.object({
|
||||||
episodeUuid: z.string().uuid("Episode UUID must be a valid UUID"),
|
id: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const { action, loader } = createHybridActionApiRoute(
|
const { action, loader } = createHybridActionApiRoute(
|
||||||
@ -19,8 +23,22 @@ const { action, loader } = createHybridActionApiRoute(
|
|||||||
},
|
},
|
||||||
async ({ body, authentication }) => {
|
async ({ body, authentication }) => {
|
||||||
try {
|
try {
|
||||||
|
const ingestionQueue = await getIngestionQueue(body.id);
|
||||||
|
|
||||||
|
if (!ingestionQueue) {
|
||||||
|
return json(
|
||||||
|
{
|
||||||
|
error: "Episode not found or unauthorized",
|
||||||
|
code: "not_found",
|
||||||
|
},
|
||||||
|
{ status: 404 },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const output = ingestionQueue.output as any;
|
||||||
|
|
||||||
const result = await deleteEpisodeWithRelatedNodes({
|
const result = await deleteEpisodeWithRelatedNodes({
|
||||||
episodeUuid: body.episodeUuid,
|
episodeUuid: output?.episodeUuid,
|
||||||
userId: authentication.userId,
|
userId: authentication.userId,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -34,6 +52,8 @@ const { action, loader } = createHybridActionApiRoute(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await deleteIngestionQueue(ingestionQueue.id);
|
||||||
|
|
||||||
return json({
|
return json({
|
||||||
success: true,
|
success: true,
|
||||||
message: "Episode deleted successfully",
|
message: "Episode deleted successfully",
|
||||||
@ -1,30 +0,0 @@
|
|||||||
import { json } from "@remix-run/node";
|
|
||||||
import { z } from "zod";
|
|
||||||
import { createHybridActionApiRoute } from "~/services/routeBuilders/apiBuilder.server";
|
|
||||||
|
|
||||||
const TestSchema = z.object({
|
|
||||||
message: z.string(),
|
|
||||||
});
|
|
||||||
|
|
||||||
// This route can be called with either:
|
|
||||||
// 1. Personal access token: Authorization: Bearer <token>
|
|
||||||
// 2. Cookie-based authentication (when logged in via browser)
|
|
||||||
const { action, loader } = createHybridActionApiRoute(
|
|
||||||
{
|
|
||||||
body: TestSchema,
|
|
||||||
method: "POST",
|
|
||||||
corsStrategy: "all",
|
|
||||||
},
|
|
||||||
async ({ body, authentication }) => {
|
|
||||||
return json({
|
|
||||||
success: true,
|
|
||||||
message: body.message,
|
|
||||||
authType: authentication.type,
|
|
||||||
userId: authentication.userId,
|
|
||||||
// Only include scopes if it's API key authentication
|
|
||||||
...(authentication.type === "PRIVATE" && { scopes: authentication.scopes }),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
export { action, loader };
|
|
||||||
@ -44,3 +44,19 @@ export async function getIngestionLogs(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getIngestionQueue = async (id: string) => {
|
||||||
|
return await prisma.ingestionQueue.findUnique({
|
||||||
|
where: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deleteIngestionQueue = async (id: string) => {
|
||||||
|
return await prisma.ingestionQueue.delete({
|
||||||
|
where: {
|
||||||
|
id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|||||||
@ -272,7 +272,7 @@ async function handleMessageResponse(
|
|||||||
|
|
||||||
// Handle "activity" messages
|
// Handle "activity" messages
|
||||||
if (grouped["activity"]) {
|
if (grouped["activity"]) {
|
||||||
return await handleActivityMessage(
|
await handleActivityMessage(
|
||||||
grouped["activity"],
|
grouped["activity"],
|
||||||
integrationAccountId as string,
|
integrationAccountId as string,
|
||||||
userId,
|
userId,
|
||||||
@ -281,7 +281,7 @@ async function handleMessageResponse(
|
|||||||
|
|
||||||
// Handle "state" messages
|
// Handle "state" messages
|
||||||
if (grouped["state"]) {
|
if (grouped["state"]) {
|
||||||
return await handleStateMessage(
|
await handleStateMessage(
|
||||||
grouped["state"],
|
grouped["state"],
|
||||||
integrationAccountId as string,
|
integrationAccountId as string,
|
||||||
);
|
);
|
||||||
@ -289,12 +289,12 @@ async function handleMessageResponse(
|
|||||||
|
|
||||||
// Handle "identifier" messages
|
// Handle "identifier" messages
|
||||||
if (grouped["identifier"]) {
|
if (grouped["identifier"]) {
|
||||||
return await handleIdentifierMessage(grouped["identifier"][0]);
|
await handleIdentifierMessage(grouped["identifier"][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle "account" messages (these may involve Prisma writes)
|
// Handle "account" messages (these may involve Prisma writes)
|
||||||
if (grouped["account"]) {
|
if (grouped["account"]) {
|
||||||
return await handleAccountMessage(
|
await handleAccountMessage(
|
||||||
grouped["account"],
|
grouped["account"],
|
||||||
integrationDefinition,
|
integrationDefinition,
|
||||||
workspaceId,
|
workspaceId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user