Add Profile/Channel entities with CRUD and remove legacy parser builder.
Introduce reusable ParserProfile and ParseChannel, pair jobs with enqueue flatten, Events admin CRUD, and drop inline/legacy parser-builder UI and aliases. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
import { ADMIN_BASE, request } from "./client";
|
||||
import type {
|
||||
HeuristicProfile,
|
||||
ParseChannel,
|
||||
ParseChannelCreate,
|
||||
ParseChannelUpdate,
|
||||
ParserProfile,
|
||||
ParserProfileCreate,
|
||||
ParserProfileUpdate,
|
||||
TargetField,
|
||||
} from "../types/admin";
|
||||
|
||||
export type { HeuristicProfile, TargetField } from "../types/admin";
|
||||
|
||||
export function fetchChannels(): Promise<ParseChannel[]> {
|
||||
return request<ParseChannel[]>("/parse-channels", undefined, ADMIN_BASE);
|
||||
}
|
||||
|
||||
export function createChannel(payload: ParseChannelCreate): Promise<ParseChannel> {
|
||||
return request<ParseChannel>(
|
||||
"/parse-channels",
|
||||
{ method: "POST", body: JSON.stringify(payload) },
|
||||
ADMIN_BASE,
|
||||
);
|
||||
}
|
||||
|
||||
export function updateChannel(id: number, payload: ParseChannelUpdate): Promise<ParseChannel> {
|
||||
return request<ParseChannel>(
|
||||
`/parse-channels/${id}`,
|
||||
{ method: "PATCH", body: JSON.stringify(payload) },
|
||||
ADMIN_BASE,
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteChannel(id: number): Promise<void> {
|
||||
return request<void>(`/parse-channels/${id}`, { method: "DELETE" }, ADMIN_BASE);
|
||||
}
|
||||
|
||||
export function fetchProfiles(): Promise<ParserProfile[]> {
|
||||
return request<ParserProfile[]>("/parser-profiles", undefined, ADMIN_BASE);
|
||||
}
|
||||
|
||||
export function createProfile(payload: ParserProfileCreate): Promise<ParserProfile> {
|
||||
return request<ParserProfile>(
|
||||
"/parser-profiles",
|
||||
{ method: "POST", body: JSON.stringify(payload) },
|
||||
ADMIN_BASE,
|
||||
);
|
||||
}
|
||||
|
||||
export function updateProfile(id: number, payload: ParserProfileUpdate): Promise<ParserProfile> {
|
||||
return request<ParserProfile>(
|
||||
`/parser-profiles/${id}`,
|
||||
{ method: "PATCH", body: JSON.stringify(payload) },
|
||||
ADMIN_BASE,
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteProfile(id: number): Promise<void> {
|
||||
return request<void>(`/parser-profiles/${id}`, { method: "DELETE" }, ADMIN_BASE);
|
||||
}
|
||||
|
||||
export function fetchTargetFields(): Promise<{ fields: TargetField[] }> {
|
||||
return request<{ fields: TargetField[] }>("/parser-profiles/target-fields", undefined, ADMIN_BASE);
|
||||
}
|
||||
|
||||
export function generateParserProfile(sample_post: string): Promise<{ profile: HeuristicProfile }> {
|
||||
return request<{ profile: HeuristicProfile }>(
|
||||
"/parser-profiles/generate",
|
||||
{ method: "POST", body: JSON.stringify({ sample_post }) },
|
||||
ADMIN_BASE,
|
||||
);
|
||||
}
|
||||
|
||||
export function previewParserProfile(
|
||||
sample_post: string,
|
||||
heuristic_profile: HeuristicProfile | Record<string, unknown>,
|
||||
): Promise<{ fields: Record<string, string> }> {
|
||||
return request<{ fields: Record<string, string> }>(
|
||||
"/parser-profiles/preview",
|
||||
{ method: "POST", body: JSON.stringify({ sample_post, heuristic_profile }) },
|
||||
ADMIN_BASE,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user