59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
/**
|
||
* 世界模型 API(河图枢,独立 /world 域)。
|
||
* 实体列表/创建 + 关系图谱(relations)。独立域无 PATCH/DELETE——实体编辑/删除仍走
|
||
* adminApi(保留 WorldEntityList 的完整 CRUD);本模块提供独立域的分页查询与关系管理。
|
||
* 世界实体候选审核(approve/reject)见 extractionApi。
|
||
*/
|
||
|
||
import { apiDelete, apiGet, apiPost } from "./client";
|
||
import type {
|
||
CreateWorldEntityRequest,
|
||
CreateWorldRelationRequest,
|
||
Paginated,
|
||
WorldEntity,
|
||
WorldRelation,
|
||
} from "@/types/api";
|
||
|
||
/** 列出世界实体(GET /world/entities,独立域分页) */
|
||
export function listWorldEntities(params?: {
|
||
character_id?: string;
|
||
type?: string;
|
||
page?: number;
|
||
page_size?: number;
|
||
}): Promise<Paginated<WorldEntity>> {
|
||
return apiGet<Paginated<WorldEntity>>("/world/entities", params);
|
||
}
|
||
|
||
/** 创建世界实体(POST /world/entities) */
|
||
export function createWorldEntity(
|
||
body: CreateWorldEntityRequest,
|
||
): Promise<WorldEntity> {
|
||
return apiPost<WorldEntity>("/world/entities", body);
|
||
}
|
||
|
||
/** 获取单个世界实体(GET /world/entities/{id}) */
|
||
export function getWorldEntity(entityId: string): Promise<WorldEntity> {
|
||
return apiGet<WorldEntity>(`/world/entities/${entityId}`);
|
||
}
|
||
|
||
/** 列出世界关系(GET /world/relations) */
|
||
export function listWorldRelations(params?: {
|
||
character_id?: string;
|
||
page?: number;
|
||
page_size?: number;
|
||
}): Promise<Paginated<WorldRelation>> {
|
||
return apiGet<Paginated<WorldRelation>>("/world/relations", params);
|
||
}
|
||
|
||
/** 创建世界关系(POST /world/relations,subject-predicate-object 三元组) */
|
||
export function createWorldRelation(
|
||
body: CreateWorldRelationRequest,
|
||
): Promise<WorldRelation> {
|
||
return apiPost<WorldRelation>("/world/relations", body);
|
||
}
|
||
|
||
/** 删除世界关系(DELETE /world/relations/{relation_id}) */
|
||
export function deleteWorldRelation(relationId: string): Promise<void> {
|
||
return apiDelete<void>(`/world/relations/${relationId}`);
|
||
}
|