import { NextRequest, NextResponse } from "next/server"; import { GridColDef } from "@mui/x-data-grid-pro"; import { Database } from "./database"; const entities = [ "facebook", "whatsapp", "signal", "voice", "webhooks", "users", ] as const; export type Entity = (typeof entities)[number]; export type SelectOption = { value: string; label: string; }; export type FieldDescription = { name: string; label: string; kind?: "text" | "phone" | "select" | "multi"; getOptions?: (formState: any) => Promise; autogenerated?: "token"; hidden?: boolean; type?: string; lines?: number; copyable?: boolean; refreshable?: boolean; defaultValue?: string; required?: boolean; disabled?: boolean; size?: number; helperText?: string; }; export type ServiceConfig = { entity: Entity; table: keyof Database; displayName: string; createFields: FieldDescription[]; updateFields: FieldDescription[]; displayFields: FieldDescription[]; listColumns: GridColDef[]; }; export class Service { sendMessage: (req: NextRequest) => Promise = async (req) => { return NextResponse.json({ ok: "nice" }); }; receiveMessages: (req: NextRequest) => Promise = async ( req, ) => { return NextResponse.json({ ok: "nice" }); }; handleWebhook: (req: NextRequest) => Promise = async (req) => { return NextResponse.json({ ok: "nice" }); }; }