chore: hapus fitur materi (learning materials + RAG chat)
Hapus fitur materi seluruhnya dari GMW monorepo: Backend: - Hapus module materi/ (index.ts, materi.repository.ts, materi.schema.ts, materi.service.ts, ragClient.ts) - Hapus materiRouter dari orpc/router.ts (imports, const, appRouter entry) - Hapus pgMateriDocumentsTable + types dari shared/database/schema.ts Frontend: - Hapus route pages app/(dashboard)/materi/ (page, [id], chat, new) - Hapus lib/api/materi.ts (oRPC client wrappers) - Hapus lib/types/materi.ts + export dari index.ts - Hapus nav item "Materi" dari lib/navigation.ts + unused BookOpen import Scripts: - Hapus scripts/add-materi-documents.sql - Tambah scripts/drop-materi-documents.sql (ops DB cleanup) Verification: - Backend: npx tsc --noEmit — clean (exit 0) - Frontend: npx tsc --noEmit — clean (exit 0) - Grep: zero materi code references remaining (hanya di drop-materi-documents.sql) RAG dependencies (messages/embed.ts, messages/qdrant.ts) tetap karena juga dipakai oleh messages.service.ts.
This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
// Materi API client — talks to backend /trpc materi router
|
||||
import { createORPCClient } from "@orpc/client";
|
||||
import { RPCLink } from "@orpc/client/fetch";
|
||||
import { orpc } from "@/lib/orpc/client";
|
||||
import type { ORPCClient } from "@/lib/orpc/types";
|
||||
import type {
|
||||
CreateMateriInput,
|
||||
MateriDocument,
|
||||
MateriRagChatMessage,
|
||||
MateriRagChatResult,
|
||||
} from "@/lib/types/materi";
|
||||
|
||||
const BACKEND_URL =
|
||||
process.env.GMW_BACKEND_URL?.replace(/\/+$/, "") || "http://127.0.0.1:4001";
|
||||
|
||||
let _serverClient: ORPCClient | null = null;
|
||||
function serverOrpc(): ORPCClient {
|
||||
if (!_serverClient) {
|
||||
const link = new RPCLink({
|
||||
url: `${BACKEND_URL}/trpc`,
|
||||
fetch(url, init) {
|
||||
return fetch(url, { ...init, cache: "no-store" });
|
||||
},
|
||||
});
|
||||
_serverClient = createORPCClient(link) as unknown as ORPCClient;
|
||||
}
|
||||
return _serverClient;
|
||||
}
|
||||
|
||||
// Server-side (SSR seed) — uses the HTTP RPCLink via oRPC
|
||||
export async function listMateriSSR(
|
||||
limit = 50,
|
||||
search?: string,
|
||||
): Promise<MateriDocument[]> {
|
||||
return (serverOrpc() as any).materi.list({
|
||||
limit,
|
||||
search,
|
||||
}) as unknown as Promise<MateriDocument[]>;
|
||||
}
|
||||
|
||||
export async function getMateriSSR(id: string): Promise<MateriDocument | null> {
|
||||
return (serverOrpc() as any).materi.detail({
|
||||
id,
|
||||
}) as unknown as Promise<MateriDocument | null>;
|
||||
}
|
||||
|
||||
// Client-side — browser WebSocket RPCLink (orpc is "use client")
|
||||
export async function createMateri(
|
||||
input: CreateMateriInput,
|
||||
): Promise<MateriDocument> {
|
||||
return orpc.materi.create(input) as unknown as Promise<MateriDocument>;
|
||||
}
|
||||
|
||||
export async function updateMateri(
|
||||
id: string,
|
||||
input: Partial<CreateMateriInput>,
|
||||
): Promise<MateriDocument | null> {
|
||||
return orpc.materi.update({
|
||||
id,
|
||||
...input,
|
||||
}) as unknown as Promise<MateriDocument | null>;
|
||||
}
|
||||
|
||||
export async function deleteMateri(id: string): Promise<boolean> {
|
||||
return orpc.materi.delete({ id }) as unknown as Promise<boolean>;
|
||||
}
|
||||
|
||||
export async function searchMateri(
|
||||
query: string,
|
||||
history: MateriRagChatMessage[] = [],
|
||||
materiId?: string,
|
||||
): Promise<MateriRagChatResult> {
|
||||
return orpc.materi.chat({
|
||||
message: query,
|
||||
history,
|
||||
materiId,
|
||||
}) as unknown as Promise<MateriRagChatResult>;
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
BookOpen,
|
||||
Headphones,
|
||||
LayoutDashboard,
|
||||
type LucideIcon,
|
||||
@@ -64,12 +63,6 @@ export const navItems: NavItem[] = [
|
||||
icon: Search,
|
||||
matchPrefix: "/analysis",
|
||||
},
|
||||
{
|
||||
href: "/materi",
|
||||
label: "Materi",
|
||||
icon: BookOpen,
|
||||
matchPrefix: "/materi",
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
export * from "./dashboard";
|
||||
export * from "./guild";
|
||||
export * from "./knowledge";
|
||||
export * from "./materi";
|
||||
export * from "./media";
|
||||
export * from "./message";
|
||||
export * from "./moderation";
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
export interface MateriDocument {
|
||||
id: string;
|
||||
title: string;
|
||||
description: string | null;
|
||||
content: string;
|
||||
category: string;
|
||||
tags: string[];
|
||||
owner_user_id: string;
|
||||
guild_id: string | null;
|
||||
channel_id: string | null;
|
||||
is_public: boolean;
|
||||
view_count: number;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
}
|
||||
|
||||
export interface CreateMateriInput {
|
||||
title: string;
|
||||
description?: string;
|
||||
content: string;
|
||||
category: string;
|
||||
tags: string[];
|
||||
guildId?: string;
|
||||
channelId?: string;
|
||||
isPublic: boolean;
|
||||
}
|
||||
|
||||
export interface MateriRagChatMessage {
|
||||
role: "user" | "assistant";
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface MateriRagChatResult {
|
||||
answer: string;
|
||||
sources: Array<{
|
||||
id: string;
|
||||
title: string;
|
||||
score: number;
|
||||
excerpt: string;
|
||||
}>;
|
||||
}
|
||||
Reference in New Issue
Block a user