From ea15fc2b3b25c34a760862fe3e66b6ab1a5f3a74 Mon Sep 17 00:00:00 2001 From: brokun Date: Tue, 26 Nov 2024 14:02:37 +0800 Subject: [PATCH] fix: typo, specify the function return type. (#87) * fix: typo * fix: vercel build * chore: stylelint --- docs/site/.dumi/theme/styles/heti.less | 12 ++++++---- docs/site/package.json | 3 ++- .../src/views/agent-flow/agent-flow-view.tsx | 6 +++-- .../magent-au/src/agent/agent-manager.ts | 13 ++++++++--- .../magent-au/src/plugin/plugin-manager.ts | 3 ++- .../magent-core/src/fetcher/fetcher.ts | 23 +++++++++++++++---- 6 files changed, 43 insertions(+), 17 deletions(-) diff --git a/docs/site/.dumi/theme/styles/heti.less b/docs/site/.dumi/theme/styles/heti.less index 0ad9dd3f..17a7ab03 100644 --- a/docs/site/.dumi/theme/styles/heti.less +++ b/docs/site/.dumi/theme/styles/heti.less @@ -10,9 +10,10 @@ @font-face { font-family: 'Heti Hei SC'; - src: local('PingFang SC Regular'), local('Heiti SC Regular'), local('Microsoft YaHei'), - local('Source Han Sans CN Regular'), local('Noto Sans CJK SC Regular'), - local('WenQuanYi Micro Hei'), local('Droid Sans Fallback'); + src: local('PingFang SC Regular'), local('Heiti SC Regular'), + local('Microsoft YaHei'), local('Source Han Sans CN Regular'), + local('Noto Sans CJK SC Regular'), local('WenQuanYi Micro Hei'), + local('Droid Sans Fallback'); } @font-face { @@ -45,8 +46,9 @@ @font-face { font-family: 'Heti Hei SC Light'; font-weight: 200; - src: local('PingFang SC Light'), local('Heiti SC Light'), 'Heti Hei SC Light Fallback', - local('Source Han Sans CN Light'), local('Noto Sans CJK SC Light'); + src: local('PingFang SC Light'), local('Heiti SC Light'), + 'Heti Hei SC Light Fallback', local('Source Han Sans CN Light'), + local('Noto Sans CJK SC Light'); } @font-face { diff --git a/docs/site/package.json b/docs/site/package.json index b0dc02c3..9da49c13 100644 --- a/docs/site/package.json +++ b/docs/site/package.json @@ -5,7 +5,8 @@ "license": "MIT", "description": "Document site for magent", "scripts": { - "start": "UMI_DEV_SERVER_COMPRESS=none dumi dev" + "start": "UMI_DEV_SERVER_COMPRESS=none dumi dev", + "build": "dumi build" }, "type": "module", "devDependencies": { diff --git a/web-apps/ui/src/views/agent-flow/agent-flow-view.tsx b/web-apps/ui/src/views/agent-flow/agent-flow-view.tsx index dd8d3279..ee3ef861 100644 --- a/web-apps/ui/src/views/agent-flow/agent-flow-view.tsx +++ b/web-apps/ui/src/views/agent-flow/agent-flow-view.tsx @@ -12,7 +12,7 @@ import { ViewInstance, } from '@difizen/mana-app'; import { Button } from 'antd'; -// import yaml from 'js-yaml'; +import type { AxiosResponse } from 'axios'; import { forwardRef, useEffect, useState } from 'react'; import { AgentManager } from '@/modules/agent/agent-manager.js'; @@ -335,7 +335,9 @@ export class AgentFlowView extends BaseView { return await this.getWorkflowInfo(workflowId); }; - saveGraph = async (graph: Graph) => { + saveGraph = async ( + graph: Graph, + ): Promise | undefined> => { await this.agent.ready; if (!this.workflowId || !this.workflow) { return; diff --git a/web-packages/magent-au/src/agent/agent-manager.ts b/web-packages/magent-au/src/agent/agent-manager.ts index a9e77de5..b6e5163d 100644 --- a/web-packages/magent-au/src/agent/agent-manager.ts +++ b/web-packages/magent-au/src/agent/agent-manager.ts @@ -1,3 +1,4 @@ +import type { FecterResponse } from '@difizen/magent-core'; import { Fetcher } from '@difizen/magent-core'; import { inject, singleton } from '@difizen/mana-app'; @@ -33,7 +34,9 @@ export class AgentManager { return agent; }; - create = async (option: AgentModelCreateOption) => { + create = async ( + option: AgentModelCreateOption, + ): Promise> => { let res; if (option.planner.id === 'workflow_planner') { res = await this.doCreateWorkflowAgent(option); @@ -43,10 +46,14 @@ export class AgentManager { return res; }; - protected doCreateNormalAgent = async (option: AgentModelCreateOption) => { + protected doCreateNormalAgent = async ( + option: AgentModelCreateOption, + ): Promise> => { return await this.fetcher.post(`/api/v1/agents`, option); }; - protected doCreateWorkflowAgent = async (option: AgentModelCreateOption) => { + protected doCreateWorkflowAgent = async ( + option: AgentModelCreateOption, + ): Promise> => { return await this.fetcher.post( `/api/v1/agents/workflow`, option, diff --git a/web-packages/magent-au/src/plugin/plugin-manager.ts b/web-packages/magent-au/src/plugin/plugin-manager.ts index 0bd8c496..71c05bb8 100644 --- a/web-packages/magent-au/src/plugin/plugin-manager.ts +++ b/web-packages/magent-au/src/plugin/plugin-manager.ts @@ -1,4 +1,5 @@ import { Fetcher } from '@difizen/magent-core'; +import type { FecterResponse } from '@difizen/magent-core'; import { inject, prop, singleton } from '@difizen/mana-app'; import type { PluginModel } from './plugin-model.js'; @@ -44,7 +45,7 @@ export class PluginManager { return plugin; }; - create = async (option: PluginMeta) => { + create = async (option: PluginMeta): Promise> => { const res = await this.fetcher.post(`/api/v1/plugins/openapi`, option); return res; }; diff --git a/web-packages/magent-core/src/fetcher/fetcher.ts b/web-packages/magent-core/src/fetcher/fetcher.ts index 4d4aee1a..6594250e 100644 --- a/web-packages/magent-core/src/fetcher/fetcher.ts +++ b/web-packages/magent-core/src/fetcher/fetcher.ts @@ -1,9 +1,11 @@ import { inject, singleton } from '@difizen/mana-app'; -import type { AxiosRequestConfig } from 'axios'; +import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import qs from 'query-string'; import { AxiosClient } from './protocol.js'; +export type FecterResponse = AxiosResponse; + @singleton() export class Fetcher { @inject(AxiosClient) axios: AxiosClient; @@ -11,7 +13,7 @@ export class Fetcher { basePath: string, params?: Record, config?: AxiosRequestConfig, - ) => { + ): Promise> => { let url = basePath; if (params) { url = `${url}?${qs.stringify(params)}`; @@ -19,14 +21,25 @@ export class Fetcher { return this.axios.get(url, config); }; - post = async (url: string, data: any, config?: AxiosRequestConfig) => { + post = async ( + url: string, + data: any, + config?: AxiosRequestConfig, + ): Promise> => { return this.axios.post(url, data, config); }; - put = async (url: string, data: any, config?: AxiosRequestConfig) => { + put = async ( + url: string, + data: any, + config?: AxiosRequestConfig, + ): Promise> => { return this.axios.put(url, data, config); }; - delete = async (url: string, config?: AxiosRequestConfig) => { + delete = async ( + url: string, + config?: AxiosRequestConfig, + ): Promise> => { return this.axios.delete(url, config); }; }