From 43a9cd6137dbafb5e007ad68cfe22c376631c46f Mon Sep 17 00:00:00 2001 From: zttProjectSpace Date: Thu, 23 Jan 2025 10:25:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E4=B8=AD=E5=BF=83=E5=92=8C?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/appCenter/index.ts | 59 +++++++++++++ src/apis/appCenter/type.ts | 115 +++++++++++++++++++++++++ src/apis/workFlow/index.ts | 62 ++++++++++++++ src/apis/workFlow/type.ts | 162 ++++++++++++++++++++++++++++++++++++ 4 files changed, 398 insertions(+) create mode 100644 src/apis/appCenter/index.ts create mode 100644 src/apis/appCenter/type.ts create mode 100644 src/apis/workFlow/index.ts create mode 100644 src/apis/workFlow/type.ts diff --git a/src/apis/appCenter/index.ts b/src/apis/appCenter/index.ts new file mode 100644 index 0000000..7bfa29b --- /dev/null +++ b/src/apis/appCenter/index.ts @@ -0,0 +1,59 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +import { post, get, del, put } from 'src/apis/server'; +import type { FcResponse } from 'src/apis/server'; +import { QueryAppListParamsType, CreateOrUpdateAppParamsType } from './type'; +/** + * 获取应用列表 + * @param params + * @returns + */ +export const queryAppList = (params: QueryAppListParamsType): Promise<[any, FcResponse | undefined]> => { + return get('/app', params); +}; + +/** + * 创建应用/更新应用 + * @param params + * @returns + */ +export const createOrUpdateApp = ( + params: CreateOrUpdateAppParamsType, +): Promise<[any, FcResponse | undefined]> => { + return post('/app', params); +}; + +/** + * 获取应用数据 + * @param params + * @returns + */ +export const querySingleAppData = (params: { id: string }): Promise<[any, FcResponse | undefined]> => { + return get(`/app/${params.id}`, params); +}; + +/** + * 删除应用 + * @param params + * @returns + */ +export const deleteSingleAppData = (params: { id: string }): Promise<[any, FcResponse | undefined]> => { + return del(`/app/${params.id}`, params); +}; + +/** + * 发布应用 + * @param params + * @returns + */ +export const releaseSingleAppData = (params: { id: string }): Promise<[any, FcResponse | undefined]> => { + return post(`/app/${params.id}`, params); +}; + +/** + * 更改应用收藏状态 + * @param params + * @returns + */ +export const changeSingleAppCollect = (params: { id: string }): Promise<[any, FcResponse | undefined]> => { + return put(`/app/${params.id}`, params); +}; diff --git a/src/apis/appCenter/type.ts b/src/apis/appCenter/type.ts new file mode 100644 index 0000000..e29d127 --- /dev/null +++ b/src/apis/appCenter/type.ts @@ -0,0 +1,115 @@ +export interface QueryAppListParamsType { + /** + * 筛选“我创建的”应用 + */ + createdByMe?: boolean; + /** + * 筛选“我收藏的”应用 + */ + favorited?: boolean; + /** + * 搜索关键字 + */ + keyword?: string; + /** + * 页码 + */ + page?: number; + /** + * 每页数量 + */ + pageSize?: number; + /** + * 搜索类型:全部字段或仅按名称/简介/作者字段;若不填,则视为 'all' + */ + searchType?: SearchType; + [property: string]: any; +} + +/** + * 搜索类型:全部字段或仅按名称/简介/作者字段;若不填,则视为 'all' + */ +export enum SearchType { + All = "all", + Author = "author", + Description = "description", + Name = "name", +} + +/** + * CreateAppRequest, 创建/更新应用请求数据结构 + */ +export interface CreateOrUpdateAppParamsType { + /** + * 应用ID + */ + appId?: string; + /** + * 应用简介 + */ + description: string; + /** + * 对话轮次(1~10) + */ + dialogRounds?: number; + /** + * 图标 + */ + icon?: string; + /** + * 相关链接(URL列表,最多5项) + */ + links?: AppLink[]; + /** + * 应用名称 + */ + name: string; + /** + * 权限配置 + */ + permission?: AppPermissionData; + /** + * 推荐问题(列表,最多3项) + */ + recommendedQuestions?: string[]; + /** + * 工作流(列表,每个元素为工作流ID) + */ + workflows?: string[]; + [property: string]: any; +} + +/** + * AppLink, 应用链接数据结构 + */ +export interface AppLink { + /** + * 链接标题 + */ + title?: string; + /** + * 链接地址 + */ + url: string; + [property: string]: any; +} + +/** + * 权限配置 + * + * AppPermissionData, 应用权限配置数据结构 + */ +export interface AppPermissionData { + /** + * 附加人员名单(如果可见性为部分人可见) + */ + authorizedUsers?: string[]; + visibility: Visibility; + [property: string]: any; +} + +export enum Visibility { + Private = "private", + Protected = "protected", + Public = "public", +} diff --git a/src/apis/workFlow/index.ts b/src/apis/workFlow/index.ts new file mode 100644 index 0000000..19f1a36 --- /dev/null +++ b/src/apis/workFlow/index.ts @@ -0,0 +1,62 @@ +// Copyright (c) Huawei Technologies Co., Ltd. 2023-2024. All rights reserved. +import { post, get, del, put } from 'src/apis/server'; +import type { FcResponse } from 'src/apis/server'; +import { CreateOrUpdateFlowParamsType, CreateOrUpdataFlowBodyType } from './type'; +/** + * 获取所有服务 + * @param params + * @returns + */ +export const queryAllFlowService = (params: { + page: number; + pageSize: number; +}): Promise<[any, FcResponse | undefined]> => { + return get('/flow/service', params); +}; + +/** + * 获取服务下的所有节点的元数据 + * @param params + * @returns + */ +export const querySingleFlowServiceNode = (params: { + serviceId: string; +}): Promise<[any, FcResponse | undefined]> => { + return get('/flow/service/node', params); +}; + +/** + * 获取工作流拓扑结构 + * @param params + * @returns + */ +export const querySingleFlowTopology = (params: { + appId: number; + flowId: number; +}): Promise<[any, FcResponse | undefined]> => { + return get('/flow', params); +}; + +/** + * 创建/修改工作流拓扑结构 + * @param params + * @returns + */ +export const createOrUpdateFlowTopology = ( + params: CreateOrUpdateFlowParamsType, + data: CreateOrUpdataFlowBodyType, +): Promise<[any, FcResponse | undefined]> => { + return put('/flow', data, params); +}; + +/** + * 删除工作流拓扑结构 + * @param params + * @returns + */ +export const delFlowTopology = (params: { + appId: number; + flowId: number; +}): Promise<[any, FcResponse | undefined]> => { + return del('/flow', params); +}; diff --git a/src/apis/workFlow/type.ts b/src/apis/workFlow/type.ts new file mode 100644 index 0000000..94bbe0a --- /dev/null +++ b/src/apis/workFlow/type.ts @@ -0,0 +1,162 @@ +export interface CreateOrUpdateFlowParamsType { + appId: string; + flowId: string; + topologyCheck?: boolean; + [property: string]: any; +} + + +/** + * Flow + */ +export interface CreateOrUpdataFlowBodyType { + /** + * 流创建时间 + */ + createdAt: string; + /** + * 流的介绍 + */ + description: string; + edges: Edge[]; + editable: string; + /** + * 流是否启用 + */ + enable: boolean; + /** + * 流id + */ + flowId?: string; + /** + * 流的名称 + */ + name: string; + nodes: Node[]; + [property: string]: any; +} + +/** + * Edge + */ +export interface Edge { + /** + * 边对应的分支id + */ + branchId: string; + /** + * 边创建的时间 + */ + createdAt?: string; + /** + * 边的id + */ + edgeId: string; + /** + * 源节点的id + */ + sourceNode: string; + /** + * 目标节点的id + */ + targetNode: string; + /** + * 边的类型 + */ + type: string; + [property: string]: any; +} + +/** + * Node + */ +export interface Node { + /** + * 节点对应apiId + */ + apiId: string; + /** + * 节点创建时间 + */ + createdAt?: string; + /** + * 节点的伴生节点(例如for的begin和end) + */ + dependency?: Dependency; + /** + * 节点介绍 + */ + description: string; + /** + * 节点是否可被编辑/删除 + */ + editable: boolean; + /** + * 节点是否被启用 + */ + enable: boolean; + /** + * 节点名称 + */ + name: string; + /** + * 节点id + */ + nodeId: string; + parameters?: Parameters; + /** + * 节点的位置 + */ + position: Position; + serviceId: string; + type: string; + [property: string]: any; +} + +/** + * 节点的伴生节点(例如for的begin和end) + * + * Dependency + */ +export interface Dependency { + nodeId: string; + type: string; + [property: string]: any; +} + +export interface Parameters { + /** + * 节点类型为choice时才存在这个变量 + */ + choices?: Choice[]; + [property: string]: any; +} + +/** + * choice + */ +export interface Choice { + /** + * ID 编号 + */ + branch: string; + description: string; + [property: string]: any; +} + +/** + * 节点的位置 + * + * Position + */ +export interface Position { + /** + * 前端显示相对位置的x坐标 + */ + x: number; + /** + * 前端显示相对位置的y坐标 + */ + y: number; + [property: string]: any; +} \ No newline at end of file -- Gitee