52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
/*
|
|
* This file is part of the kernelstudio package.
|
|
*
|
|
* (c) 2014-2025 zlin <admin@kernelstudio.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE file
|
|
* that was distributed with this source code.
|
|
*/
|
|
|
|
import { HttpRequestClient } from '@/utils/request';
|
|
import type { NodeTemplateQuery, NodeTemplatesResponse, TreeModelDetailsResponse, TreeModelGraph, TreeModelsResponse } from './types';
|
|
import type { ApiPaginationQuery, BasicResponse } from '@/types';
|
|
|
|
const req = HttpRequestClient.create<BasicResponse>({
|
|
baseURL: '/bhtree/api',
|
|
});
|
|
|
|
export const findTemplatesByQuery = (query: Partial<NodeTemplateQuery>): Promise<NodeTemplatesResponse> => {
|
|
return req.postJson('/node-templates', query);
|
|
};
|
|
|
|
export const findTreesByQuery = (query: Partial<ApiPaginationQuery>): Promise<TreeModelsResponse> => {
|
|
return req.postJson<TreeModelsResponse>('/behavior-trees', query);
|
|
};
|
|
|
|
export const findOneTreeById = (id: number): Promise<TreeModelDetailsResponse> => {
|
|
return req.get(`/behavior-trees/${id}`);
|
|
};
|
|
|
|
export const updateTree = (rt: Partial<TreeModelGraph>): Promise<BasicResponse> => {
|
|
return req.postJson('/behavior-trees', rt);
|
|
};
|
|
|
|
export const createTree = (rt: Partial<TreeModelGraph>): Promise<BasicResponse> => {
|
|
return req.putJson('/behavior-trees', rt);
|
|
};
|
|
|
|
|
|
// export const findOneTreeById = (id: number): Promise<TreeModelDetailsResponse> => {
|
|
// return req.postJson(`/tree-details`,{
|
|
// tree_id: id
|
|
// });
|
|
// };
|
|
//
|
|
// export const updateTree = (rt: Partial<TreeModelGraph>): Promise<BasicResponse> => {
|
|
// return req.postJson('/update-tree', rt);
|
|
// };
|
|
//
|
|
// export const createTree = (rt: Partial<TreeModelGraph>): Promise<BasicResponse> => {
|
|
// return req.postJson('/update-tree', rt);
|
|
// };
|