feat(web): API 层扩展 — batch/patch/timeseries/kanban 类型
- PluginFieldSchema 新增 ref_entity/ref_label_field/ref_search_fields/cascade_from/cascade_filter - PluginPageSchema 新增 kanban 页面类型(lane_field/card_title_field 等) - PluginPageSchema dashboard 类型扩展 widgets 字段 - 新增 DashboardWidget 接口(stat_card/bar/pie/funnel/line 图表) - pluginData 新增 batchPluginData/patchPluginData/getPluginTimeseries 三个 API 函数
This commit is contained in:
@@ -123,3 +123,51 @@ export async function aggregatePluginData(
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// ── 批量操作 ──
|
||||
|
||||
export async function batchPluginData(
|
||||
pluginId: string,
|
||||
entity: string,
|
||||
req: { action: string; ids: string[]; data?: Record<string, unknown> },
|
||||
) {
|
||||
const { data } = await client.post<{ success: boolean; data: unknown }>(
|
||||
`/plugins/${pluginId}/${entity}/batch`,
|
||||
req,
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// ── 部分更新 ──
|
||||
|
||||
export async function patchPluginData(
|
||||
pluginId: string,
|
||||
entity: string,
|
||||
id: string,
|
||||
req: { data: Record<string, unknown>; version: number },
|
||||
) {
|
||||
const { data } = await client.patch<{ success: boolean; data: PluginDataRecord }>(
|
||||
`/plugins/${pluginId}/${entity}/${id}`,
|
||||
req,
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// ── 时间序列 ──
|
||||
|
||||
export async function getPluginTimeseries(
|
||||
pluginId: string,
|
||||
entity: string,
|
||||
params: {
|
||||
time_field: string;
|
||||
time_grain: string;
|
||||
start?: string;
|
||||
end?: string;
|
||||
},
|
||||
) {
|
||||
const { data } = await client.get<{ success: boolean; data: unknown }>(
|
||||
`/plugins/${pluginId}/${entity}/timeseries`,
|
||||
{ params },
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
@@ -134,6 +134,11 @@ export interface PluginFieldSchema {
|
||||
sortable?: boolean;
|
||||
visible_when?: string;
|
||||
unique?: boolean;
|
||||
ref_entity?: string;
|
||||
ref_label_field?: string;
|
||||
ref_search_fields?: string[];
|
||||
cascade_from?: string;
|
||||
cascade_filter?: string;
|
||||
}
|
||||
|
||||
export interface PluginEntitySchema {
|
||||
@@ -157,7 +162,30 @@ export type PluginPageSchema =
|
||||
| { type: 'detail'; entity: string; label: string; sections: PluginSectionSchema[] }
|
||||
| { type: 'tabs'; label: string; icon?: string; tabs: PluginPageSchema[] }
|
||||
| { type: 'graph'; entity: string; label: string; relationship_entity: string; source_field: string; target_field: string; edge_label_field: string; node_label_field: string }
|
||||
| { type: 'dashboard'; label: string };
|
||||
| { type: 'dashboard'; label: string; widgets?: DashboardWidget[] }
|
||||
| {
|
||||
type: 'kanban';
|
||||
entity: string;
|
||||
label: string;
|
||||
icon?: string;
|
||||
lane_field: string;
|
||||
lane_order?: string[];
|
||||
card_title_field: string;
|
||||
card_subtitle_field?: string;
|
||||
card_fields?: string[];
|
||||
enable_drag?: boolean;
|
||||
};
|
||||
|
||||
export interface DashboardWidget {
|
||||
type: 'stat_card' | 'bar_chart' | 'pie_chart' | 'funnel_chart' | 'line_chart';
|
||||
entity: string;
|
||||
title: string;
|
||||
icon?: string;
|
||||
color?: string;
|
||||
dimension_field?: string;
|
||||
dimension_order?: string[];
|
||||
metric?: string;
|
||||
}
|
||||
|
||||
export type PluginSectionSchema =
|
||||
| { type: 'fields'; label: string; fields: string[] }
|
||||
|
||||
Reference in New Issue
Block a user