diff --git a/build/cool/eps.d.ts b/build/cool/eps.d.ts index 9d44b2e..e22935c 100644 --- a/build/cool/eps.d.ts +++ b/build/cool/eps.d.ts @@ -834,6 +834,162 @@ declare namespace Eps { [key: string]: any; } + interface FlowConfigEntity { + /** + * ID + */ + id?: number; + + /** + * 名称 + */ + name?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 类型 + */ + type?: string; + + /** + * 节点 + */ + node?: string; + + /** + * 配置 + */ + options?: json; + + /** + * 创建时间 + */ + createTime?: Date; + + /** + * 更新时间 + */ + updateTime?: Date; + + /** + * 任意键值 + */ + [key: string]: any; + } + + interface FlowInfoEntity { + /** + * ID + */ + id?: number; + + /** + * 名称 + */ + name?: string; + + /** + * 标签(可以根据标签调用) + */ + label?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 状态 0-禁用 1-禁用 + */ + status?: number; + + /** + * 版本 + */ + version?: number; + + /** + * 草稿 + */ + draft?: json; + + /** + * 数据 + */ + data?: json; + + /** + * 发布时间 + */ + releaseTime?: Date; + + /** + * 创建时间 + */ + createTime?: Date; + + /** + * 更新时间 + */ + updateTime?: Date; + + /** + * 任意键值 + */ + [key: string]: any; + } + + interface FlowLogEntity { + /** + * ID + */ + id?: number; + + /** + * 流程ID + */ + flowId?: number; + + /** + * 类型 0-失败 1-成功 2-未知 + */ + type?: number; + + /** + * 传入参数 + */ + inputParams?: json; + + /** + * 结果 + */ + result?: json; + + /** + * 节点运行信息 + */ + nodeInfo?: json; + + /** + * 创建时间 + */ + createTime?: Date; + + /** + * 更新时间 + */ + updateTime?: Date; + + /** + * 任意键值 + */ + [key: string]: any; + } + interface GoodsCommentEntity { /** * ID @@ -1136,6 +1292,182 @@ declare namespace Eps { [key: string]: any; } + interface KnowConfigEntity { + /** + * ID + */ + id?: number; + + /** + * 名称 + */ + name?: string; + + /** + * 描述 + */ + description?: string; + + /** + * 类型 + */ + type?: string; + + /** + * 功能 + */ + func?: string; + + /** + * 配置 + */ + options?: json; + + /** + * 创建时间 + */ + createTime?: Date; + + /** + * 更新时间 + */ + updateTime?: Date; + + /** + * 任意键值 + */ + [key: string]: any; + } + + interface KnowDataInfoEntity { + /** + * ID + */ + id?: number; + + /** + * 类型ID + */ + typeId?: number; + + /** + * 标题 + */ + title?: string; + + /** + * 内容 + */ + content?: json; + + /** + * 来源 0-自定义 1-文件 2-链接 + */ + from?: number; + + /** + * 元数据 + */ + metadata?: json; + + /** + * 状态 0-准备中 1-已就绪 + */ + status?: number; + + /** + * 启用 0-禁用 1-启用 + */ + enable?: number; + + /** + * 创建时间 + */ + createTime?: Date; + + /** + * 更新时间 + */ + updateTime?: Date; + + /** + * 任意键值 + */ + [key: string]: any; + } + + interface KnowDataTypeEntity { + /** + * ID + */ + id?: number; + + /** + * 名称 + */ + name?: string; + + /** + * 图标 + */ + icon?: string; + + /** + * 描述 + */ + description?: string; + + /** + * embedding配置ID + */ + embedConfigId?: number; + + /** + * embedding配置 + */ + embedOptions?: json; + + /** + * 是否开启rerank 0-否 1-是 + */ + enableRerank?: number; + + /** + * rerank配置ID + */ + rerankConfigId?: number; + + /** + * rerank配置 + */ + rerankOptions?: json; + + /** + * 链接更新频率(天) + */ + updateFrequency?: number; + + /** + * 状态 0-禁用 1-启用 + */ + enable?: number; + + /** + * 创建时间 + */ + createTime?: Date; + + /** + * 更新时间 + */ + updateTime?: Date; + + /** + * 任意键值 + */ + [key: string]: any; + } + interface MarketCouponInfoEntity { /** * ID @@ -1811,6 +2143,20 @@ declare namespace Eps { [key: string]: any; } + interface ChatMessageEntity { + /** + * 任意键值 + */ + [key: string]: any; + } + + interface ChatSessionEntity { + /** + * 任意键值 + */ + [key: string]: any; + } + interface TestEntity { /** * 任意键值 @@ -2812,6 +3158,296 @@ declare namespace Eps { request: Service["request"]; } + interface FixturesMould { + /** + * 保存配置 + */ + getFixturesPreviewCode(data?: any): Promise; + + /** + * 获取平台页面 + */ + getPlatformPages(data?: any): Promise; + + /** + * 删除 + */ + delete(data?: any): Promise; + + /** + * 修改 + */ + update(data?: any): Promise; + + /** + * 单个信息 + */ + info(data?: any): Promise; + + /** + * 列表查询 + */ + list(data?: any): Promise; + + /** + * 分页查询 + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: FixturesMouldEntity[]; + [key: string]: any; + }>; + + /** + * 新增 + */ + add(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { + getFixturesPreviewCode: string; + getPlatformPages: string; + delete: string; + update: string; + info: string; + list: string; + page: string; + add: string; + }; + + /** + * 权限状态 + */ + _permission: { + getFixturesPreviewCode: boolean; + getPlatformPages: boolean; + delete: boolean; + update: boolean; + info: boolean; + list: boolean; + page: boolean; + add: boolean; + }; + + request: Service["request"]; + } + + interface FlowConfig { + /** + * 通过名称获取配置 + */ + getByNode(data?: any): Promise; + + /** + * 获取节点配置 + */ + config(data?: any): Promise; + + /** + * 删除 + */ + delete(data?: any): Promise; + + /** + * 修改 + */ + update(data?: any): Promise; + + /** + * 单个信息 + */ + info(data?: any): Promise; + + /** + * 列表查询 + */ + list(data?: any): Promise; + + /** + * 分页查询 + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: FlowConfigEntity[]; + [key: string]: any; + }>; + + /** + * 获取所有配置 + */ + all(data?: any): Promise; + + /** + * 新增 + */ + add(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { + getByNode: string; + config: string; + delete: string; + update: string; + info: string; + list: string; + page: string; + all: string; + add: string; + }; + + /** + * 权限状态 + */ + _permission: { + getByNode: boolean; + config: boolean; + delete: boolean; + update: boolean; + info: boolean; + list: boolean; + page: boolean; + all: boolean; + add: boolean; + }; + + request: Service["request"]; + } + + interface FlowInfo { + /** + * 发布流程 + */ + release(data?: any): Promise; + + /** + * 删除 + */ + delete(data?: any): Promise; + + /** + * 修改 + */ + update(data?: any): Promise; + + /** + * 单个信息 + */ + info(data?: any): Promise; + + /** + * 列表查询 + */ + list(data?: any): Promise; + + /** + * 分页查询 + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: FlowInfoEntity[]; + [key: string]: any; + }>; + + /** + * 新增 + */ + add(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { + release: string; + delete: string; + update: string; + info: string; + list: string; + page: string; + add: string; + }; + + /** + * 权限状态 + */ + _permission: { + release: boolean; + delete: boolean; + update: boolean; + info: boolean; + list: boolean; + page: boolean; + add: boolean; + }; + + request: Service["request"]; + } + + interface FlowLog { + /** + * 删除 + */ + delete(data?: any): Promise; + + /** + * 单个信息 + */ + info(data?: any): Promise; + + /** + * 列表查询 + */ + list(data?: any): Promise; + + /** + * 分页查询 + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: FlowLogEntity[]; + [key: string]: any; + }>; + + /** + * 权限标识 + */ + permission: { delete: string; info: string; list: string; page: string }; + + /** + * 权限状态 + */ + _permission: { delete: boolean; info: boolean; list: boolean; page: boolean }; + + request: Service["request"]; + } + + interface FlowRun { + /** + * 调用流程 + */ + invoke(data?: any): Promise; + + /** + * 调试 + */ + debug(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { invoke: string; debug: string }; + + /** + * 权限状态 + */ + _permission: { invoke: boolean; debug: boolean }; + + request: Service["request"]; + } + interface GoodsComment { /** * 分页查询 @@ -3145,6 +3781,263 @@ declare namespace Eps { request: Service["request"]; } + interface KnowConfig { + /** + * 通过功能获取配置 + */ + getByFunc(data?: any): Promise; + + /** + * 获取配置 + */ + config(data?: any): Promise; + + /** + * 删除 + */ + delete(data?: any): Promise; + + /** + * 修改 + */ + update(data?: any): Promise; + + /** + * 单个信息 + */ + info(data?: any): Promise; + + /** + * 列表查询 + */ + list(data?: any): Promise; + + /** + * 分页查询 + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: KnowConfigEntity[]; + [key: string]: any; + }>; + + /** + * 获取所有配置 + */ + all(data?: any): Promise; + + /** + * 新增 + */ + add(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { + getByFunc: string; + config: string; + delete: string; + update: string; + info: string; + list: string; + page: string; + all: string; + add: string; + }; + + /** + * 权限状态 + */ + _permission: { + getByFunc: boolean; + config: boolean; + delete: boolean; + update: boolean; + info: boolean; + list: boolean; + page: boolean; + all: boolean; + add: boolean; + }; + + request: Service["request"]; + } + + interface KnowDataInfo { + /** + * 删除 + */ + delete(data?: any): Promise; + + /** + * 修改 + */ + update(data?: any): Promise; + + /** + * 单个信息 + */ + info(data?: any): Promise; + + /** + * 列表查询 + */ + list(data?: any): Promise; + + /** + * 分页查询 + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: KnowDataInfoEntity[]; + [key: string]: any; + }>; + + /** + * 新增 + */ + add(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { + delete: string; + update: string; + info: string; + list: string; + page: string; + add: string; + }; + + /** + * 权限状态 + */ + _permission: { + delete: boolean; + update: boolean; + info: boolean; + list: boolean; + page: boolean; + add: boolean; + }; + + request: Service["request"]; + } + + interface KnowDataType { + /** + * 重建 + */ + rebuild(data?: any): Promise; + + /** + * 删除 + */ + delete(data?: any): Promise; + + /** + * 修改 + */ + update(data?: any): Promise; + + /** + * 单个信息 + */ + info(data?: any): Promise; + + /** + * 列表查询 + */ + list(data?: any): Promise; + + /** + * 分页查询 + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: KnowDataTypeEntity[]; + [key: string]: any; + }>; + + /** + * 新增 + */ + add(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { + rebuild: string; + delete: string; + update: string; + info: string; + list: string; + page: string; + add: string; + }; + + /** + * 权限状态 + */ + _permission: { + rebuild: boolean; + delete: boolean; + update: boolean; + info: boolean; + list: boolean; + page: boolean; + add: boolean; + }; + + request: Service["request"]; + } + + interface KnowLoader { + /** + * 加载文件,支持多个文件 + */ + file(data?: any): Promise; + + /** + * 加载链接 + */ + link(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { file: string; link: string }; + + /** + * 权限状态 + */ + _permission: { file: boolean; link: boolean }; + + request: Service["request"]; + } + + interface KnowRetriever { + /** + * 调用 + */ + invoke(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { invoke: string }; + + /** + * 权限状态 + */ + _permission: { invoke: boolean }; + + request: Service["request"]; + } + interface MarketCouponInfo { /** * 删除 @@ -3778,6 +4671,130 @@ declare namespace Eps { request: Service["request"]; } + interface ChatMessage { + /** + * page + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: ChatMessageEntity[]; + [key: string]: any; + }>; + + /** + * list + */ + list(data?: any): Promise; + + /** + * info + */ + info(data?: any): Promise; + + /** + * delete + */ + delete(data?: any): Promise; + + /** + * update + */ + update(data?: any): Promise; + + /** + * add + */ + add(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { + page: string; + list: string; + info: string; + delete: string; + update: string; + add: string; + }; + + /** + * 权限状态 + */ + _permission: { + page: boolean; + list: boolean; + info: boolean; + delete: boolean; + update: boolean; + add: boolean; + }; + + request: Service["request"]; + } + + interface ChatSession { + /** + * page + */ + page(data?: any): Promise<{ + pagination: { size: number; page: number; total: number; [key: string]: any }; + list: ChatSessionEntity[]; + [key: string]: any; + }>; + + /** + * list + */ + list(data?: any): Promise; + + /** + * info + */ + info(data?: any): Promise; + + /** + * delete + */ + delete(data?: any): Promise; + + /** + * update + */ + update(data?: any): Promise; + + /** + * add + */ + add(data?: any): Promise; + + /** + * 权限标识 + */ + permission: { + page: string; + list: string; + info: string; + delete: string; + update: string; + add: string; + }; + + /** + * 权限状态 + */ + _permission: { + page: boolean; + list: boolean; + info: boolean; + delete: boolean; + update: boolean; + add: boolean; + }; + + request: Service["request"]; + } + interface Test { /** * page @@ -3985,82 +5002,6 @@ declare namespace Eps { request: Service["request"]; } - interface FixturesMould { - /** - * 保存配置 - */ - getFixturesPreviewCode(data?: any): Promise; - - /** - * 获取平台页面 - */ - getPlatformPages(data?: any): Promise; - - /** - * 删除 - */ - delete(data?: any): Promise; - - /** - * 修改 - */ - update(data?: any): Promise; - - /** - * 单个信息 - */ - info(data?: any): Promise; - - /** - * 列表查询 - */ - list(data?: any): Promise; - - /** - * 分页查询 - */ - page(data?: any): Promise<{ - pagination: { size: number; page: number; total: number; [key: string]: any }; - list: FixturesMouldEntity[]; - [key: string]: any; - }>; - - /** - * 新增 - */ - add(data?: any): Promise; - - /** - * 权限标识 - */ - permission: { - getFixturesPreviewCode: string; - getPlatformPages: string; - delete: string; - update: string; - info: string; - list: string; - page: string; - add: string; - }; - - /** - * 权限状态 - */ - _permission: { - getFixturesPreviewCode: boolean; - getPlatformPages: boolean; - delete: boolean; - update: boolean; - info: boolean; - list: boolean; - page: boolean; - add: boolean; - }; - - request: Service["request"]; - } - type Service = { /** * 基础请求 @@ -4095,6 +5036,8 @@ declare namespace Eps { count: { home: CountHome }; cs: { msg: CsMsg; session: CsSession }; dict: { info: DictInfo; type: DictType }; + fixtures: { mould: FixturesMould }; + flow: { config: FlowConfig; info: FlowInfo; log: FlowLog; run: FlowRun }; goods: { comment: GoodsComment; info: GoodsInfo; @@ -4103,6 +5046,12 @@ declare namespace Eps { type: GoodsType; }; info: { banner: InfoBanner }; + know: { + config: KnowConfig; + data: { info: KnowDataInfo; type: KnowDataType }; + loader: KnowLoader; + retriever: KnowRetriever; + }; market: { coupon: { info: MarketCouponInfo; user: MarketCouponUser } }; order: { info: OrderInfo }; plugin: { info: PluginInfo }; @@ -4110,8 +5059,8 @@ declare namespace Eps { space: { info: SpaceInfo; type: SpaceType }; task: { info: TaskInfo }; user: { address: UserAddress; info: UserInfo }; + chat: { message: ChatMessage; session: ChatSession }; test: Test; demo: { user: { follow: DemoUserFollow; info: DemoUserInfo } }; - fixtures: { mould: FixturesMould }; }; } diff --git a/build/cool/eps.json b/build/cool/eps.json index 9b9691f..0f5df37 100644 --- a/build/cool/eps.json +++ b/build/cool/eps.json @@ -1 +1 @@ -[{"prefix":"/admin/app/complain","name":"AppComplainEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/app/feedback","name":"AppFeedbackEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/app/goods","name":"AppGoodsEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/app/version","name":"AppVersionEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/comm","name":"","api":[{"method":"post","path":"/personUpdate"},{"method":"get","path":"/uploadMode"},{"method":"get","path":"/permmenu"},{"method":"get","path":"/person"},{"method":"post","path":"/upload"},{"method":"post","path":"/logout"}]},{"prefix":"/admin/base/open","name":"","api":[{"method":"get","path":"/refreshToken"},{"method":"get","path":"/captcha"},{"method":"post","path":"/login"},{"method":"get","path":"/html"},{"method":"get","path":"/eps"}]},{"prefix":"/admin/base/sys/department","name":"BaseSysDepartmentEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/order"},{"method":"post","path":"/list"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/sys/log","name":"BaseSysLogEntity","api":[{"method":"post","path":"/setKeep"},{"method":"get","path":"/getKeep"},{"method":"post","path":"/clear"},{"method":"post","path":"/page"}]},{"prefix":"/admin/base/sys/menu","name":"BaseSysMenuEntity","api":[{"method":"post","path":"/create"},{"method":"post","path":"/export"},{"method":"post","path":"/import"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/parse"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/sys/param","name":"BaseSysParamEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/html"},{"method":"get","path":"/info"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/sys/role","name":"BaseSysRoleEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/sys/user","name":"BaseSysUserEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/move"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/count/home","name":"","api":[{"method":"post","path":"/goodsCategory"},{"method":"post","path":"/orderSummary"},{"method":"post","path":"/userSummary"},{"method":"post","path":"/orderChart"},{"method":"post","path":"/userChart"},{"method":"post","path":"/goodsRank"}]},{"prefix":"/admin/cs/msg","name":"CsMsgEntity","api":[{"method":"get","path":"/unreadCount"},{"method":"post","path":"/read"},{"method":"post","path":"/page"}]},{"prefix":"/admin/cs/session","name":"CsSessionEntity","api":[{"method":"get","path":"/detail"},{"method":"post","path":"/create"},{"method":"post","path":"/page"}]},{"prefix":"/admin/cs/session","name":"","api":[{"method":"get","path":"/detail"},{"method":"post","path":"/create"},{"method":"post","path":"/page"}]},{"prefix":"/admin/dict/info","name":"DictInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/data"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/dict/type","name":"DictTypeEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/fixtures/mould","name":"FixturesMouldEntity","api":[{"method":"post","path":"/getFixturesPreviewCode"},{"method":"get","path":"/getPlatformPages"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/goods/comment","name":"GoodsCommentEntity","api":[{"method":"post","path":"/page"}]},{"prefix":"/admin/goods/info","name":"GoodsInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/goods/searchKeyword","name":"GoodsSearchKeywordEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/goods/spec","name":"GoodsSpecEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/goods/type","name":"GoodsTypeEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/info/banner","name":"InfoBannerEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/market/coupon/info","name":"MarketCouponInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/market/coupon/user","name":"MarketCouponUserEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/order/info","name":"OrderInfoEntity","api":[{"method":"post","path":"/refundHandle"},{"method":"get","path":"/logistics"},{"method":"post","path":"/deliver"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"}]},{"prefix":"/admin/plugin/info","name":"PluginInfoEntity","api":[{"method":"post","path":"/install"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/recycle/data","name":"RecycleDataEntity","api":[{"method":"post","path":"/restore"},{"method":"get","path":"/info"},{"method":"post","path":"/page"}]},{"prefix":"/admin/space/info","name":"SpaceInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/space/type","name":"SpaceTypeEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/task/info","name":"TaskInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/start"},{"method":"post","path":"/once"},{"method":"post","path":"/stop"},{"method":"get","path":"/info"},{"method":"post","path":"/page"},{"method":"get","path":"/log"},{"method":"post","path":"/add"}]},{"prefix":"/admin/user/address","name":"UserAddressEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/user/info","name":"UserInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/test","name":"TestEntity","api":[{"path":"/page"},{"path":"/update"},{"path":"/add"},{"path":"/info"},{"path":"/delete"},{"path":"/list"}]},{"prefix":"/admin/demo/user/follow","name":"DemoUserFollowEntity","api":[{"path":"/page"},{"path":"/list"},{"path":"/info"},{"path":"/delete"},{"path":"/update"},{"path":"/add"}]},{"prefix":"/admin/demo/user/info","name":"DemoUserInfoEntity","api":[{"path":"/t1"},{"path":"/t2"},{"path":"/t3"},{"path":"/page"},{"path":"/list"},{"path":"/info"},{"path":"/delete"},{"path":"/update"},{"path":"/add"}]}] \ No newline at end of file +[{"prefix":"/admin/app/complain","name":"AppComplainEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/app/feedback","name":"AppFeedbackEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/app/goods","name":"AppGoodsEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/app/version","name":"AppVersionEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/comm","name":"","api":[{"method":"post","path":"/personUpdate"},{"method":"get","path":"/uploadMode"},{"method":"get","path":"/permmenu"},{"method":"get","path":"/person"},{"method":"post","path":"/upload"},{"method":"post","path":"/logout"}]},{"prefix":"/admin/base/open","name":"","api":[{"method":"get","path":"/refreshToken"},{"method":"get","path":"/captcha"},{"method":"post","path":"/login"},{"method":"get","path":"/html"},{"method":"get","path":"/eps"}]},{"prefix":"/admin/base/sys/department","name":"BaseSysDepartmentEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/order"},{"method":"post","path":"/list"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/sys/log","name":"BaseSysLogEntity","api":[{"method":"post","path":"/setKeep"},{"method":"get","path":"/getKeep"},{"method":"post","path":"/clear"},{"method":"post","path":"/page"}]},{"prefix":"/admin/base/sys/menu","name":"BaseSysMenuEntity","api":[{"method":"post","path":"/create"},{"method":"post","path":"/export"},{"method":"post","path":"/import"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/parse"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/sys/param","name":"BaseSysParamEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/html"},{"method":"get","path":"/info"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/sys/role","name":"BaseSysRoleEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/base/sys/user","name":"BaseSysUserEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/move"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/count/home","name":"","api":[{"method":"post","path":"/goodsCategory"},{"method":"post","path":"/orderSummary"},{"method":"post","path":"/userSummary"},{"method":"post","path":"/orderChart"},{"method":"post","path":"/userChart"},{"method":"post","path":"/goodsRank"}]},{"prefix":"/admin/cs/msg","name":"CsMsgEntity","api":[{"method":"get","path":"/unreadCount"},{"method":"post","path":"/read"},{"method":"post","path":"/page"}]},{"prefix":"/admin/cs/session","name":"CsSessionEntity","api":[{"method":"get","path":"/detail"},{"method":"post","path":"/create"},{"method":"post","path":"/page"}]},{"prefix":"/admin/cs/session","name":"","api":[{"method":"get","path":"/detail"},{"method":"post","path":"/create"},{"method":"post","path":"/page"}]},{"prefix":"/admin/dict/info","name":"DictInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/data"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/dict/type","name":"DictTypeEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/fixtures/mould","name":"FixturesMouldEntity","api":[{"method":"post","path":"/getFixturesPreviewCode"},{"method":"get","path":"/getPlatformPages"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/flow/config","name":"FlowConfigEntity","api":[{"method":"get","path":"/getByNode"},{"method":"post","path":"/config"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"get","path":"/all"},{"method":"post","path":"/add"}]},{"prefix":"/admin/flow/info","name":"FlowInfoEntity","api":[{"method":"post","path":"/release"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/flow/log","name":"FlowLogEntity","api":[{"method":"post","path":"/delete"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"}]},{"prefix":"/admin/flow/run","name":"","api":[{"method":"post","path":"/invoke"},{"method":"post","path":"/debug"}]},{"prefix":"/admin/goods/comment","name":"GoodsCommentEntity","api":[{"method":"post","path":"/page"}]},{"prefix":"/admin/goods/info","name":"GoodsInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/goods/searchKeyword","name":"GoodsSearchKeywordEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/goods/spec","name":"GoodsSpecEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/goods/type","name":"GoodsTypeEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/info/banner","name":"InfoBannerEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/know/config","name":"KnowConfigEntity","api":[{"method":"get","path":"/getByFunc"},{"method":"post","path":"/config"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"get","path":"/all"},{"method":"post","path":"/add"}]},{"prefix":"/admin/know/data/info","name":"KnowDataInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/know/data/type","name":"KnowDataTypeEntity","api":[{"method":"post","path":"/rebuild"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/know/loader","name":"","api":[{"method":"post","path":"/file"},{"method":"post","path":"/link"}]},{"prefix":"/admin/know/retriever","name":"","api":[{"method":"post","path":"/invoke"}]},{"prefix":"/admin/market/coupon/info","name":"MarketCouponInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/market/coupon/user","name":"MarketCouponUserEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/order/info","name":"OrderInfoEntity","api":[{"method":"post","path":"/refundHandle"},{"method":"get","path":"/logistics"},{"method":"post","path":"/deliver"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"}]},{"prefix":"/admin/plugin/info","name":"PluginInfoEntity","api":[{"method":"post","path":"/install"},{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/recycle/data","name":"RecycleDataEntity","api":[{"method":"post","path":"/restore"},{"method":"get","path":"/info"},{"method":"post","path":"/page"}]},{"prefix":"/admin/space/info","name":"SpaceInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/space/type","name":"SpaceTypeEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/task/info","name":"TaskInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"post","path":"/start"},{"method":"post","path":"/once"},{"method":"post","path":"/stop"},{"method":"get","path":"/info"},{"method":"post","path":"/page"},{"method":"get","path":"/log"},{"method":"post","path":"/add"}]},{"prefix":"/admin/user/address","name":"UserAddressEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/user/info","name":"UserInfoEntity","api":[{"method":"post","path":"/delete"},{"method":"post","path":"/update"},{"method":"get","path":"/info"},{"method":"post","path":"/list"},{"method":"post","path":"/page"},{"method":"post","path":"/add"}]},{"prefix":"/admin/chat/message","name":"ChatMessageEntity","api":[{"path":"/page"},{"path":"/list"},{"path":"/info"},{"path":"/delete"},{"path":"/update"},{"path":"/add"}]},{"prefix":"/admin/chat/session","name":"ChatSessionEntity","api":[{"path":"/page"},{"path":"/list"},{"path":"/info"},{"path":"/delete"},{"path":"/update"},{"path":"/add"}]},{"prefix":"/admin/test","name":"TestEntity","api":[{"path":"/page"},{"path":"/update"},{"path":"/add"},{"path":"/info"},{"path":"/delete"},{"path":"/list"}]},{"prefix":"/admin/demo/user/follow","name":"DemoUserFollowEntity","api":[{"path":"/page"},{"path":"/list"},{"path":"/info"},{"path":"/delete"},{"path":"/update"},{"path":"/add"}]},{"prefix":"/admin/demo/user/info","name":"DemoUserInfoEntity","api":[{"path":"/t1"},{"path":"/t2"},{"path":"/t3"},{"path":"/page"},{"path":"/list"},{"path":"/info"},{"path":"/delete"},{"path":"/update"},{"path":"/add"}]}] \ No newline at end of file diff --git a/package.json b/package.json index 7dab5be..86d6bfb 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,11 @@ "@vueuse/core": "^10.4.0", "@wangeditor/editor": "^5.1.23", "@wangeditor/editor-for-vue": "^5.1.12", + "@vue-flow/background": "^1.3.0", + "@vue-flow/controls": "^1.1.2", + "@vue-flow/core": "^1.36.0", + "@vue-flow/minimap": "^1.5.0", + "@vue-flow/node-resizer": "^1.3.6", "axios": "^1.7.2", "chardet": "^2.0.0", "core-js": "^3.32.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 98a12c3..10e22b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,21 @@ importers: '@element-plus/icons-vue': specifier: ^2.3.1 version: 2.3.1(vue@3.5.13(typescript@5.7.3)) + '@vue-flow/background': + specifier: ^1.3.0 + version: 1.3.2(@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3)))(vue@3.5.13(typescript@5.7.3)) + '@vue-flow/controls': + specifier: ^1.1.2 + version: 1.1.2(@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3)))(vue@3.5.13(typescript@5.7.3)) + '@vue-flow/core': + specifier: ^1.36.0 + version: 1.41.7(vue@3.5.13(typescript@5.7.3)) + '@vue-flow/minimap': + specifier: ^1.5.0 + version: 1.5.0(@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3)))(vue@3.5.13(typescript@5.7.3)) + '@vue-flow/node-resizer': + specifier: ^1.3.6 + version: 1.4.0(@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3)))(vue@3.5.13(typescript@5.7.3)) '@vueuse/core': specifier: ^10.4.0 version: 10.11.1(vue@3.5.13(typescript@5.7.3)) @@ -897,6 +912,35 @@ packages: vite: ^5.0.0 || ^6.0.0 vue: ^3.2.25 + '@vue-flow/background@1.3.2': + resolution: {integrity: sha512-eJPhDcLj1wEo45bBoqTXw1uhl0yK2RaQGnEINqvvBsAFKh/camHJd5NPmOdS1w+M9lggc9igUewxaEd3iCQX2w==} + peerDependencies: + '@vue-flow/core': ^1.23.0 + vue: ^3.3.0 + + '@vue-flow/controls@1.1.2': + resolution: {integrity: sha512-6dtl/JnwDBNau5h3pDBdOCK6tdxiVAOL3cyruRL61gItwq5E97Hmjmj2BIIqX2p7gU1ENg3z80Z4zlu58fGlsg==} + peerDependencies: + '@vue-flow/core': ^1.23.0 + vue: ^3.3.0 + + '@vue-flow/core@1.41.7': + resolution: {integrity: sha512-YAavc1wD8nll5IECnUyqzzNX+Y5WEGm7drmVOdkRPU8z9VkxlbgtokK+sTjz3N232Dm9pHuXRHD+u0HHRk0kdQ==} + peerDependencies: + vue: ^3.3.0 + + '@vue-flow/minimap@1.5.0': + resolution: {integrity: sha512-JhxXDF+8uTc7sgkZHDIvFpHqSl4wsK9xp8Kz5OHwNcXlgGcwqj4yad6jcc1B6bGxm+huESpNmoPotQbpMn6rVw==} + peerDependencies: + '@vue-flow/core': ^1.23.0 + vue: ^3.3.0 + + '@vue-flow/node-resizer@1.4.0': + resolution: {integrity: sha512-S52MRcSpd6asza8Cl0bKM2sHGrbq7vBydKHDuPdoTD+cvjNX6XF4LSiPZOuzExePI6b+O6dg2EZ1378oOLGFpA==} + peerDependencies: + '@vue-flow/core': ^1.23.0 + vue: ^3.3.0 + '@vue/babel-helper-vue-transform-on@1.2.5': resolution: {integrity: sha512-lOz4t39ZdmU4DJAa2hwPYmKc8EsuGa2U0L9KaZaOJUt0UwQNjNA3AZTq6uEivhOKhhG1Wvy96SvYBoFmCg3uuw==} @@ -1290,6 +1334,44 @@ packages: csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} + d3-color@3.1.0: + resolution: {integrity: sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==} + engines: {node: '>=12'} + + d3-dispatch@3.0.1: + resolution: {integrity: sha512-rzUyPU/S7rwUflMyLc1ETDeBj0NRuHKKAcvukozwhshr6g6c5d8zh4c2gQjY2bZ0dXeGLWc1PF174P2tVvKhfg==} + engines: {node: '>=12'} + + d3-drag@3.0.0: + resolution: {integrity: sha512-pWbUJLdETVA8lQNJecMxoXfH6x+mO2UQo8rSmZ+QqxcbyA3hfeprFgIT//HW2nlHChWeIIMwS2Fq+gEARkhTkg==} + engines: {node: '>=12'} + + d3-ease@3.0.1: + resolution: {integrity: sha512-wR/XK3D3XcLIZwpbvQwQ5fK+8Ykds1ip7A2Txe0yxncXSdq1L9skcG7blcedkOX+ZcgxGAmLX1FrRGbADwzi0w==} + engines: {node: '>=12'} + + d3-interpolate@3.0.1: + resolution: {integrity: sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==} + engines: {node: '>=12'} + + d3-selection@3.0.0: + resolution: {integrity: sha512-fmTRWbNMmsmWq6xJV8D19U/gw/bwrHfNXxrIN+HfZgnzqTHp9jOmKMhsTUjXOJnZOdZY9Q28y4yebKzqDKlxlQ==} + engines: {node: '>=12'} + + d3-timer@3.0.1: + resolution: {integrity: sha512-ndfJ/JxxMd3nw31uyKoY2naivF+r29V+Lc0svZxe1JvvIRmi8hUsrMvdOwgS1o6uBHmiz91geQ0ylPP0aj1VUA==} + engines: {node: '>=12'} + + d3-transition@3.0.1: + resolution: {integrity: sha512-ApKvfjsSR6tg06xrL434C0WydLr7JewBB3V+/39RMHsaXTOG0zmt/OAXeng5M5LBm0ojmxJrpomQVZ1aPvBL4w==} + engines: {node: '>=12'} + peerDependencies: + d3-selection: 2 - 3 + + d3-zoom@3.0.0: + resolution: {integrity: sha512-b8AmV3kfQaqWAuacbPuNbL6vahnOJflOhexLzMMNLga62+/nh0JzvJ0aO/5a5MVgUFGS7Hu1P9P03o3fJkDCyw==} + engines: {node: '>=12'} + d@1.0.2: resolution: {integrity: sha512-MOqHvMWF9/9MX6nza0KgvFH4HpMU0EF5uUDXqX/BtxtU8NfB0QzRtJ8Oe/6SuS4kbhyzVJwjd97EA4PKrzJ8bw==} engines: {node: '>=0.12'} @@ -3533,6 +3615,40 @@ snapshots: vite: 5.4.11(@types/node@20.17.12)(sass@1.83.1)(terser@5.37.0) vue: 3.5.13(typescript@5.7.3) + '@vue-flow/background@1.3.2(@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3)))(vue@3.5.13(typescript@5.7.3))': + dependencies: + '@vue-flow/core': 1.41.7(vue@3.5.13(typescript@5.7.3)) + vue: 3.5.13(typescript@5.7.3) + + '@vue-flow/controls@1.1.2(@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3)))(vue@3.5.13(typescript@5.7.3))': + dependencies: + '@vue-flow/core': 1.41.7(vue@3.5.13(typescript@5.7.3)) + vue: 3.5.13(typescript@5.7.3) + + '@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3))': + dependencies: + '@vueuse/core': 10.11.1(vue@3.5.13(typescript@5.7.3)) + d3-drag: 3.0.0 + d3-selection: 3.0.0 + d3-zoom: 3.0.0 + vue: 3.5.13(typescript@5.7.3) + transitivePeerDependencies: + - '@vue/composition-api' + + '@vue-flow/minimap@1.5.0(@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3)))(vue@3.5.13(typescript@5.7.3))': + dependencies: + '@vue-flow/core': 1.41.7(vue@3.5.13(typescript@5.7.3)) + d3-selection: 3.0.0 + d3-zoom: 3.0.0 + vue: 3.5.13(typescript@5.7.3) + + '@vue-flow/node-resizer@1.4.0(@vue-flow/core@1.41.7(vue@3.5.13(typescript@5.7.3)))(vue@3.5.13(typescript@5.7.3))': + dependencies: + '@vue-flow/core': 1.41.7(vue@3.5.13(typescript@5.7.3)) + d3-drag: 3.0.0 + d3-selection: 3.0.0 + vue: 3.5.13(typescript@5.7.3) + '@vue/babel-helper-vue-transform-on@1.2.5': {} '@vue/babel-plugin-jsx@1.2.5(@babel/core@7.26.0)': @@ -4020,6 +4136,42 @@ snapshots: csstype@3.1.3: {} + d3-color@3.1.0: {} + + d3-dispatch@3.0.1: {} + + d3-drag@3.0.0: + dependencies: + d3-dispatch: 3.0.1 + d3-selection: 3.0.0 + + d3-ease@3.0.1: {} + + d3-interpolate@3.0.1: + dependencies: + d3-color: 3.1.0 + + d3-selection@3.0.0: {} + + d3-timer@3.0.1: {} + + d3-transition@3.0.1(d3-selection@3.0.0): + dependencies: + d3-color: 3.1.0 + d3-dispatch: 3.0.1 + d3-ease: 3.0.1 + d3-interpolate: 3.0.1 + d3-selection: 3.0.0 + d3-timer: 3.0.1 + + d3-zoom@3.0.0: + dependencies: + d3-dispatch: 3.0.1 + d3-drag: 3.0.0 + d3-interpolate: 3.0.1 + d3-selection: 3.0.0 + d3-transition: 3.0.1(d3-selection@3.0.0) + d@1.0.2: dependencies: es5-ext: 0.10.64 diff --git a/src/modules/chat/components/index.vue b/src/modules/chat/components/index.vue new file mode 100644 index 0000000..c928906 --- /dev/null +++ b/src/modules/chat/components/index.vue @@ -0,0 +1,259 @@ + + + + + diff --git a/src/modules/chat/components/message.vue b/src/modules/chat/components/message.vue new file mode 100644 index 0000000..25dfb4a --- /dev/null +++ b/src/modules/chat/components/message.vue @@ -0,0 +1,354 @@ + + + + + diff --git a/src/modules/chat/components/session.vue b/src/modules/chat/components/session.vue new file mode 100644 index 0000000..dd18150 --- /dev/null +++ b/src/modules/chat/components/session.vue @@ -0,0 +1,209 @@ + + + + + diff --git a/src/modules/chat/config.ts b/src/modules/chat/config.ts new file mode 100644 index 0000000..c9a8899 --- /dev/null +++ b/src/modules/chat/config.ts @@ -0,0 +1,15 @@ +import type { ModuleConfig } from "/@/cool"; + +export default (): ModuleConfig => { + return { + // toolbar: { + // order: 2, + // h5: false, + // component: import("./components/index.vue") + // }, + options: { + // socket.io 连接地址 + path: "/chat" + } + }; +}; diff --git a/src/modules/chat/hooks/index.ts b/src/modules/chat/hooks/index.ts new file mode 100644 index 0000000..ddd8fd9 --- /dev/null +++ b/src/modules/chat/hooks/index.ts @@ -0,0 +1,10 @@ +import { inject } from "vue"; +import { Chat } from "../types"; + +export function useChat() { + const chat = inject("chat") as Chat.Provide; + + return { + chat + }; +} diff --git a/src/modules/chat/service/message.ts b/src/modules/chat/service/message.ts new file mode 100644 index 0000000..142e04d --- /dev/null +++ b/src/modules/chat/service/message.ts @@ -0,0 +1,56 @@ +import { Service } from "/@/cool"; +import Mock from "mockjs"; + +@Service("chat/message") +class ChatMessage { + async page() { + return new Promise((resolve) => { + const data = Mock.mock({ + "list|20": [ + { + id: "@id", + nickName: "@cname", + createTime: "@datetime(HH:mm:ss)", + text: "@cparagraph(5)", + "contentType|0-1": 0, + "userId|1-2": 1, + avatar() { + return Mock.Random.image( + "40x40", + Mock.Random.color(), + "#FFF", + "png", + this.nickName[0] + ); + }, + content() { + return JSON.stringify({ + text: this.text, + imageUrl: Mock.Random.image( + "100x100", + Mock.Random.color(), + "#FFF", + "png", + this.nickName + ) + }); + } + } + ] + }); + + setTimeout(() => { + resolve({ + list: data.list, + pagination: { + total: 20, + page: 1, + size: 20 + } + }); + }, 1000); + }); + } +} + +export default ChatMessage; diff --git a/src/modules/chat/service/session.ts b/src/modules/chat/service/session.ts new file mode 100644 index 0000000..959f62b --- /dev/null +++ b/src/modules/chat/service/session.ts @@ -0,0 +1,43 @@ +import { Service } from "/@/cool"; +import Mock from "mockjs"; + +@Service("chat/session") +class ChatSession { + async page() { + return new Promise((resolve) => { + const data = Mock.mock({ + "list|20": [ + { + id: "@id", + nickName: "@cname", + createTime: "@datetime(HH:mm:ss)", + text: "@cparagraph(5)", + "num|0-99": 0, + avatar() { + return Mock.Random.image( + "40x40", + Mock.Random.color(), + "#FFF", + "png", + this.nickName[0] + ); + } + } + ] + }); + + setTimeout(() => { + resolve({ + list: data.list, + pagination: { + total: 20, + page: 1, + size: 20 + } + }); + }, 1000); + }); + } +} + +export default ChatSession; diff --git a/src/modules/chat/store/index.ts b/src/modules/chat/store/index.ts new file mode 100644 index 0000000..54f6d96 --- /dev/null +++ b/src/modules/chat/store/index.ts @@ -0,0 +1,12 @@ +import { useMessageStore } from "./message"; +import { useSessionStore } from "./session"; + +export function useStore() { + const session = useSessionStore(); + const message = useMessageStore(); + + return { + session, + message + }; +} diff --git a/src/modules/chat/store/message.ts b/src/modules/chat/store/message.ts new file mode 100644 index 0000000..e829928 --- /dev/null +++ b/src/modules/chat/store/message.ts @@ -0,0 +1,46 @@ +import { defineStore } from "pinia"; +import { ref } from "vue"; +import { service } from "/@/cool"; + +export const useMessageStore = defineStore("chat-message", () => { + // 加载状态 + const loading = ref(false); + + // 列表 + const list = ref([]); + + // 分页 + const pagination = ref({ + page: 1, + total: 0, + size: 20 + }); + + // 获取列表 + async function get(params?: any) { + loading.value = true; + + // 清空 + if (params?.page == 1) { + list.value = []; + } + + // 发送请求 + await service.chat.message.page(params).then((res) => { + list.value = res.list.map((e) => { + e.content = JSON.parse(e.content); + return e; + }); + pagination.value = res.pagination; + }); + + loading.value = false; + } + + return { + loading, + list, + pagination, + get + }; +}); diff --git a/src/modules/chat/store/session.ts b/src/modules/chat/store/session.ts new file mode 100644 index 0000000..a98ecb6 --- /dev/null +++ b/src/modules/chat/store/session.ts @@ -0,0 +1,46 @@ +import { defineStore } from "pinia"; +import { ref } from "vue"; +import { service } from "/@/cool"; + +export const useSessionStore = defineStore("chat-session", () => { + // 加载状态 + const loading = ref(false); + + // 列表 + const list = ref([]); + + // 选中 + const value = ref(); + + // 获取列表 + async function get(params?: any) { + loading.value = true; + + // 发送请求 + await service.chat.session.page(params).then((res) => { + // 默认加载第一个会话的消息 + if (!value.value) { + set(res.list[0]); + } + + // 设置列表 + list.value = res.list; + }); + + loading.value = false; + } + + // 设置值 + function set(data: any) { + // 设置值 + value.value = data; + } + + return { + loading, + list, + value, + get, + set + }; +}); diff --git a/src/modules/chat/types/index.d.ts b/src/modules/chat/types/index.d.ts new file mode 100644 index 0000000..7b7e0da --- /dev/null +++ b/src/modules/chat/types/index.d.ts @@ -0,0 +1,36 @@ +import { Socket } from "socket.io-client"; + +export namespace Chat { + enum ContentType { + "text" = 0, + "image" = 1, + "video" = 2 + } + + interface Message { + fromId?: string; + toId?: string; + content: { + text?: string; + imageUrl?: string; + [key: string]: any; + }; + contentType: ContentType; + [key: string]: any; + } + + interface Session { + id: string; + avatar: string; + nickName: string; + [key: string]: any; + } + + interface Provide { + socket?: Socket; + send(message: Message, isAppend?: boolean): void; + append(message: Message): void; + expand(shouldExpand?: boolean): void; + scrollToBottom(): void; + } +} diff --git a/src/modules/flow/components/index.vue b/src/modules/flow/components/index.vue new file mode 100644 index 0000000..3fdcd5d --- /dev/null +++ b/src/modules/flow/components/index.vue @@ -0,0 +1,275 @@ + + + + + diff --git a/src/modules/flow/components/log/detail.vue b/src/modules/flow/components/log/detail.vue new file mode 100644 index 0000000..ee0bc1d --- /dev/null +++ b/src/modules/flow/components/log/detail.vue @@ -0,0 +1,30 @@ + + + diff --git a/src/modules/flow/components/log/index.vue b/src/modules/flow/components/log/index.vue new file mode 100644 index 0000000..90e993b --- /dev/null +++ b/src/modules/flow/components/log/index.vue @@ -0,0 +1,192 @@ + + + diff --git a/src/modules/flow/components/nodes/_base/form/input-number.vue b/src/modules/flow/components/nodes/_base/form/input-number.vue new file mode 100644 index 0000000..99601d7 --- /dev/null +++ b/src/modules/flow/components/nodes/_base/form/input-number.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/modules/flow/components/nodes/_base/form/input-params.vue b/src/modules/flow/components/nodes/_base/form/input-params.vue new file mode 100644 index 0000000..183eaf7 --- /dev/null +++ b/src/modules/flow/components/nodes/_base/form/input-params.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/modules/flow/components/nodes/_base/form/output-params.vue b/src/modules/flow/components/nodes/_base/form/output-params.vue new file mode 100644 index 0000000..2a73a04 --- /dev/null +++ b/src/modules/flow/components/nodes/_base/form/output-params.vue @@ -0,0 +1,165 @@ + + + + + diff --git a/src/modules/flow/components/nodes/_base/form/text.vue b/src/modules/flow/components/nodes/_base/form/text.vue new file mode 100644 index 0000000..c32cf41 --- /dev/null +++ b/src/modules/flow/components/nodes/_base/form/text.vue @@ -0,0 +1,37 @@ + + + + + diff --git a/src/modules/flow/components/nodes/baidu/index.ts b/src/modules/flow/components/nodes/baidu/index.ts new file mode 100644 index 0000000..6e7fed6 --- /dev/null +++ b/src/modules/flow/components/nodes/baidu/index.ts @@ -0,0 +1,11 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; + +export default (): FlowNode => { + return { + group: "信息", + label: "百度搜索", + description: "通过百度搜索引擎查找内容", + component + }; +}; diff --git a/src/modules/flow/components/nodes/baidu/index.vue b/src/modules/flow/components/nodes/baidu/index.vue new file mode 100644 index 0000000..94ddd1c --- /dev/null +++ b/src/modules/flow/components/nodes/baidu/index.vue @@ -0,0 +1,28 @@ + + + + + diff --git a/src/modules/flow/components/nodes/classify/form/adv.vue b/src/modules/flow/components/nodes/classify/form/adv.vue new file mode 100644 index 0000000..09589eb --- /dev/null +++ b/src/modules/flow/components/nodes/classify/form/adv.vue @@ -0,0 +1,38 @@ + + + + + diff --git a/src/modules/flow/components/nodes/classify/form/classify.vue b/src/modules/flow/components/nodes/classify/form/classify.vue new file mode 100644 index 0000000..b84590b --- /dev/null +++ b/src/modules/flow/components/nodes/classify/form/classify.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/src/modules/flow/components/nodes/classify/index.ts b/src/modules/flow/components/nodes/classify/index.ts new file mode 100644 index 0000000..8bcc361 --- /dev/null +++ b/src/modules/flow/components/nodes/classify/index.ts @@ -0,0 +1,119 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormModel from "../llm/form/model.vue"; +import FormClassify from "./form/classify.vue"; +import FormAdv from "./form/adv.vue"; +import FormInputParams from "../_base/form/input-params.vue"; +import FormText from "../_base/form/text.vue"; + +export default (): FlowNode => { + return { + group: "AI", + label: "分类器", + description: "根据内容调用 LLM 进行智能分类", + color: "#409eff", + component, + form: { + items: [ + { + label: "输入变量", + prop: "inputParams", + component: { + vm: FormInputParams, + props: { + editField: false, + disabled: true + } + } + }, + { + label: "模型", + prop: "options.model", + component: { + vm: FormModel + } + }, + { + label: "分类", + prop: "options.types", + component: { + vm: FormClassify + } + }, + // { + // component: { + // name: "cl-form-card", + // props: { + // label: "高级设置", + // expand: false + // } + // }, + // children: [ + // { + // prop: "options.adv", + // component: { + // vm: FormAdv + // } + // } + // ] + // }, + { + label: "输出变量", + component: { + vm: FormText, + props: { + text: ["content 内容", "index 分类索引"] + } + } + } + ] + }, + data: { + inputParams: [ + { + field: "content", + type: "string" + } + ], + outputParams: [ + { + field: "index", + type: "number" + } + ], + options: { + model: { + options: [], + params: { + model: "" + } + }, + types: [""] + } + }, + handle: { + source: false, + next: [] + }, + validator(data) { + const { model, types } = data.options; + + // 验证变量是否绑定值 + const param = data.inputParams?.find((e) => !e.nodeId); + if (param) { + return `请绑定变量:${param.field}`; + } + + // 验证分类内容是否填写 + const type = types?.findIndex((e: string) => !e); + if (type >= 0) { + return `请填写分类${type + 1}的内容`; + } + + // 验证模型是否选择 + if (!model.params.model) { + return "请选择模型"; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/classify/index.vue b/src/modules/flow/components/nodes/classify/index.vue new file mode 100644 index 0000000..7ec39f1 --- /dev/null +++ b/src/modules/flow/components/nodes/classify/index.vue @@ -0,0 +1,89 @@ + + + + + diff --git a/src/modules/flow/components/nodes/code/editor/declares/axios.ts b/src/modules/flow/components/nodes/code/editor/declares/axios.ts new file mode 100644 index 0000000..d71a8b2 --- /dev/null +++ b/src/modules/flow/components/nodes/code/editor/declares/axios.ts @@ -0,0 +1,697 @@ +export const axios = ` +declare module "axios" { + // TypeScript Version: 4.7 + export type AxiosHeaderValue = AxiosHeaders | string | string[] | number | boolean | null; + + interface RawAxiosHeaders { + [key: string]: AxiosHeaderValue; + } + + type MethodsHeaders = Partial< + { + [Key in Method as Lowercase]: AxiosHeaders; + } & { common: AxiosHeaders } + >; + + type AxiosHeaderMatcher = + | string + | RegExp + | ((this: AxiosHeaders, value: string, name: string) => boolean); + + type AxiosHeaderParser = (this: AxiosHeaders, value: AxiosHeaderValue, header: string) => any; + + export class AxiosHeaders { + constructor(headers?: RawAxiosHeaders | AxiosHeaders | string); + + [key: string]: any; + + set( + headerName?: string, + value?: AxiosHeaderValue, + rewrite?: boolean | AxiosHeaderMatcher + ): AxiosHeaders; + set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean): AxiosHeaders; + + get(headerName: string, parser: RegExp): RegExpExecArray | null; + get(headerName: string, matcher?: true | AxiosHeaderParser): AxiosHeaderValue; + + has(header: string, matcher?: AxiosHeaderMatcher): boolean; + + delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean; + + clear(matcher?: AxiosHeaderMatcher): boolean; + + normalize(format: boolean): AxiosHeaders; + + concat( + ...targets: Array + ): AxiosHeaders; + + toJSON(asStrings?: boolean): RawAxiosHeaders; + + static from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders; + + static accessor(header: string | string[]): AxiosHeaders; + + static concat( + ...targets: Array + ): AxiosHeaders; + + setContentType(value: ContentType, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; + getContentType(parser?: RegExp): RegExpExecArray | null; + getContentType(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; + hasContentType(matcher?: AxiosHeaderMatcher): boolean; + + setContentLength( + value: AxiosHeaderValue, + rewrite?: boolean | AxiosHeaderMatcher + ): AxiosHeaders; + getContentLength(parser?: RegExp): RegExpExecArray | null; + getContentLength(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; + hasContentLength(matcher?: AxiosHeaderMatcher): boolean; + + setAccept(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; + getAccept(parser?: RegExp): RegExpExecArray | null; + getAccept(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; + hasAccept(matcher?: AxiosHeaderMatcher): boolean; + + setUserAgent(value: AxiosHeaderValue, rewrite?: boolean | AxiosHeaderMatcher): AxiosHeaders; + getUserAgent(parser?: RegExp): RegExpExecArray | null; + getUserAgent(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; + hasUserAgent(matcher?: AxiosHeaderMatcher): boolean; + + setContentEncoding( + value: AxiosHeaderValue, + rewrite?: boolean | AxiosHeaderMatcher + ): AxiosHeaders; + getContentEncoding(parser?: RegExp): RegExpExecArray | null; + getContentEncoding(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; + hasContentEncoding(matcher?: AxiosHeaderMatcher): boolean; + + setAuthorization( + value: AxiosHeaderValue, + rewrite?: boolean | AxiosHeaderMatcher + ): AxiosHeaders; + getAuthorization(parser?: RegExp): RegExpExecArray | null; + getAuthorization(matcher?: AxiosHeaderMatcher): AxiosHeaderValue; + hasAuthorization(matcher?: AxiosHeaderMatcher): boolean; + + [Symbol.iterator](): IterableIterator<[string, AxiosHeaderValue]>; + } + + type CommonRequestHeadersList = + | "Accept" + | "Content-Length" + | "User-Agent" + | "Content-Encoding" + | "Authorization"; + + type ContentType = + | AxiosHeaderValue + | "text/html" + | "text/plain" + | "multipart/form-data" + | "application/json" + | "application/x-www-form-urlencoded" + | "application/octet-stream"; + + export type RawAxiosRequestHeaders = Partial< + RawAxiosHeaders & { + [Key in CommonRequestHeadersList]: AxiosHeaderValue; + } & { + "Content-Type": ContentType; + } + >; + + export type AxiosRequestHeaders = RawAxiosRequestHeaders & AxiosHeaders; + + type CommonResponseHeadersList = + | "Server" + | "Content-Type" + | "Content-Length" + | "Cache-Control" + | "Content-Encoding"; + + type RawCommonResponseHeaders = { + [Key in CommonResponseHeadersList]: AxiosHeaderValue; + } & { + "set-cookie": string[]; + }; + + export type RawAxiosResponseHeaders = Partial; + + export type AxiosResponseHeaders = RawAxiosResponseHeaders & AxiosHeaders; + + export interface AxiosRequestTransformer { + (this: InternalAxiosRequestConfig, data: any, headers: AxiosRequestHeaders): any; + } + + export interface AxiosResponseTransformer { + ( + this: InternalAxiosRequestConfig, + data: any, + headers: AxiosResponseHeaders, + status?: number + ): any; + } + + export interface AxiosAdapter { + (config: InternalAxiosRequestConfig): AxiosPromise; + } + + export interface AxiosBasicCredentials { + username: string; + password: string; + } + + export interface AxiosProxyConfig { + host: string; + port: number; + auth?: AxiosBasicCredentials; + protocol?: string; + } + + export enum HttpStatusCode { + Continue = 100, + SwitchingProtocols = 101, + Processing = 102, + EarlyHints = 103, + Ok = 200, + Created = 201, + Accepted = 202, + NonAuthoritativeInformation = 203, + NoContent = 204, + ResetContent = 205, + PartialContent = 206, + MultiStatus = 207, + AlreadyReported = 208, + ImUsed = 226, + MultipleChoices = 300, + MovedPermanently = 301, + Found = 302, + SeeOther = 303, + NotModified = 304, + UseProxy = 305, + Unused = 306, + TemporaryRedirect = 307, + PermanentRedirect = 308, + BadRequest = 400, + Unauthorized = 401, + PaymentRequired = 402, + Forbidden = 403, + NotFound = 404, + MethodNotAllowed = 405, + NotAcceptable = 406, + ProxyAuthenticationRequired = 407, + RequestTimeout = 408, + Conflict = 409, + Gone = 410, + LengthRequired = 411, + PreconditionFailed = 412, + PayloadTooLarge = 413, + UriTooLong = 414, + UnsupportedMediaType = 415, + RangeNotSatisfiable = 416, + ExpectationFailed = 417, + ImATeapot = 418, + MisdirectedRequest = 421, + UnprocessableEntity = 422, + Locked = 423, + FailedDependency = 424, + TooEarly = 425, + UpgradeRequired = 426, + PreconditionRequired = 428, + TooManyRequests = 429, + RequestHeaderFieldsTooLarge = 431, + UnavailableForLegalReasons = 451, + InternalServerError = 500, + NotImplemented = 501, + BadGateway = 502, + ServiceUnavailable = 503, + GatewayTimeout = 504, + HttpVersionNotSupported = 505, + VariantAlsoNegotiates = 506, + InsufficientStorage = 507, + LoopDetected = 508, + NotExtended = 510, + NetworkAuthenticationRequired = 511 + } + + export type Method = + | "get" + | "GET" + | "delete" + | "DELETE" + | "head" + | "HEAD" + | "options" + | "OPTIONS" + | "post" + | "POST" + | "put" + | "PUT" + | "patch" + | "PATCH" + | "purge" + | "PURGE" + | "link" + | "LINK" + | "unlink" + | "UNLINK"; + + export type ResponseType = + | "arraybuffer" + | "blob" + | "document" + | "json" + | "text" + | "stream" + | "formdata"; + + export type responseEncoding = + | "ascii" + | "ASCII" + | "ansi" + | "ANSI" + | "binary" + | "BINARY" + | "base64" + | "BASE64" + | "base64url" + | "BASE64URL" + | "hex" + | "HEX" + | "latin1" + | "LATIN1" + | "ucs-2" + | "UCS-2" + | "ucs2" + | "UCS2" + | "utf-8" + | "UTF-8" + | "utf8" + | "UTF8" + | "utf16le" + | "UTF16LE"; + + export interface TransitionalOptions { + silentJSONParsing?: boolean; + forcedJSONParsing?: boolean; + clarifyTimeoutError?: boolean; + } + + export interface GenericAbortSignal { + readonly aborted: boolean; + onabort?: ((...args: any) => any) | null; + addEventListener?: (...args: any) => any; + removeEventListener?: (...args: any) => any; + } + + export interface FormDataVisitorHelpers { + defaultVisitor: SerializerVisitor; + convertValue: (value: any) => any; + isVisitable: (value: any) => boolean; + } + + export interface SerializerVisitor { + ( + this: GenericFormData, + value: any, + key: string | number, + path: null | Array, + helpers: FormDataVisitorHelpers + ): boolean; + } + + export interface SerializerOptions { + visitor?: SerializerVisitor; + dots?: boolean; + metaTokens?: boolean; + indexes?: boolean | null; + } + + // tslint:disable-next-line + export interface FormSerializerOptions extends SerializerOptions {} + + export interface ParamEncoder { + (value: any, defaultEncoder: (value: any) => any): any; + } + + export interface CustomParamsSerializer { + (params: Record, options?: ParamsSerializerOptions): string; + } + + export interface ParamsSerializerOptions extends SerializerOptions { + encode?: ParamEncoder; + serialize?: CustomParamsSerializer; + } + + type MaxUploadRate = number; + + type MaxDownloadRate = number; + + type BrowserProgressEvent = any; + + export interface AxiosProgressEvent { + loaded: number; + total?: number; + progress?: number; + bytes: number; + rate?: number; + estimated?: number; + upload?: boolean; + download?: boolean; + event?: BrowserProgressEvent; + lengthComputable: boolean; + } + + type Milliseconds = number; + + type AxiosAdapterName = "fetch" | "xhr" | "http" | string; + + type AxiosAdapterConfig = AxiosAdapter | AxiosAdapterName; + + export type AddressFamily = 4 | 6 | undefined; + + export interface LookupAddressEntry { + address: string; + family?: AddressFamily; + } + + export type LookupAddress = string | LookupAddressEntry; + + export interface AxiosRequestConfig { + url?: string; + method?: Method | string; + baseURL?: string; + transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[]; + transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[]; + headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders; + params?: any; + paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer; + data?: D; + timeout?: Milliseconds; + timeoutErrorMessage?: string; + withCredentials?: boolean; + adapter?: AxiosAdapterConfig | AxiosAdapterConfig[]; + auth?: AxiosBasicCredentials; + responseType?: ResponseType; + responseEncoding?: responseEncoding | string; + xsrfCookieName?: string; + xsrfHeaderName?: string; + onUploadProgress?: (progressEvent: AxiosProgressEvent) => void; + onDownloadProgress?: (progressEvent: AxiosProgressEvent) => void; + maxContentLength?: number; + validateStatus?: ((status: number) => boolean) | null; + maxBodyLength?: number; + maxRedirects?: number; + maxRate?: number | [MaxUploadRate, MaxDownloadRate]; + beforeRedirect?: ( + options: Record, + responseDetails: { headers: Record; statusCode: HttpStatusCode } + ) => void; + socketPath?: string | null; + transport?: any; + httpAgent?: any; + httpsAgent?: any; + proxy?: AxiosProxyConfig | false; + cancelToken?: CancelToken; + decompress?: boolean; + transitional?: TransitionalOptions; + signal?: GenericAbortSignal; + insecureHTTPParser?: boolean; + env?: { + FormData?: new (...args: any[]) => object; + }; + formSerializer?: FormSerializerOptions; + family?: AddressFamily; + lookup?: + | (( + hostname: string, + options: object, + cb: ( + err: Error | null, + address: LookupAddress | LookupAddress[], + family?: AddressFamily + ) => void + ) => void) + | (( + hostname: string, + options: object + ) => Promise< + | [address: LookupAddressEntry | LookupAddressEntry[], family?: AddressFamily] + | LookupAddress + >); + withXSRFToken?: boolean | ((config: InternalAxiosRequestConfig) => boolean | undefined); + fetchOptions?: Record; + } + + // Alias + export type RawAxiosRequestConfig = AxiosRequestConfig; + + export interface InternalAxiosRequestConfig extends AxiosRequestConfig { + headers: AxiosRequestHeaders; + } + + export interface HeadersDefaults { + common: RawAxiosRequestHeaders; + delete: RawAxiosRequestHeaders; + get: RawAxiosRequestHeaders; + head: RawAxiosRequestHeaders; + post: RawAxiosRequestHeaders; + put: RawAxiosRequestHeaders; + patch: RawAxiosRequestHeaders; + options?: RawAxiosRequestHeaders; + purge?: RawAxiosRequestHeaders; + link?: RawAxiosRequestHeaders; + unlink?: RawAxiosRequestHeaders; + } + + export interface AxiosDefaults extends Omit, "headers"> { + headers: HeadersDefaults; + } + + export interface CreateAxiosDefaults extends Omit, "headers"> { + headers?: RawAxiosRequestHeaders | AxiosHeaders | Partial; + } + + export interface AxiosResponse { + data: T; + status: number; + statusText: string; + headers: RawAxiosResponseHeaders | AxiosResponseHeaders; + config: InternalAxiosRequestConfig; + request?: any; + } + + export class AxiosError extends Error { + constructor( + message?: string, + code?: string, + config?: InternalAxiosRequestConfig, + request?: any, + response?: AxiosResponse + ); + + config?: InternalAxiosRequestConfig; + code?: string; + request?: any; + response?: AxiosResponse; + isAxiosError: boolean; + status?: number; + toJSON: () => object; + cause?: Error; + static from( + error: Error | unknown, + code?: string, + config?: InternalAxiosRequestConfig, + request?: any, + response?: AxiosResponse, + customProps?: object + ): AxiosError; + static readonly ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS"; + static readonly ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE"; + static readonly ERR_BAD_OPTION = "ERR_BAD_OPTION"; + static readonly ERR_NETWORK = "ERR_NETWORK"; + static readonly ERR_DEPRECATED = "ERR_DEPRECATED"; + static readonly ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE"; + static readonly ERR_BAD_REQUEST = "ERR_BAD_REQUEST"; + static readonly ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT"; + static readonly ERR_INVALID_URL = "ERR_INVALID_URL"; + static readonly ERR_CANCELED = "ERR_CANCELED"; + static readonly ECONNABORTED = "ECONNABORTED"; + static readonly ETIMEDOUT = "ETIMEDOUT"; + } + + export class CanceledError extends AxiosError {} + + export type AxiosPromise = Promise>; + + export interface CancelStatic { + new (message?: string): Cancel; + } + + export interface Cancel { + message: string | undefined; + } + + export interface Canceler { + (message?: string, config?: AxiosRequestConfig, request?: any): void; + } + + export interface CancelTokenStatic { + new (executor: (cancel: Canceler) => void): CancelToken; + source(): CancelTokenSource; + } + + export interface CancelToken { + promise: Promise; + reason?: Cancel; + throwIfRequested(): void; + } + + export interface CancelTokenSource { + token: CancelToken; + cancel: Canceler; + } + + export interface AxiosInterceptorOptions { + synchronous?: boolean; + runWhen?: (config: InternalAxiosRequestConfig) => boolean; + } + + export interface AxiosInterceptorManager { + use( + onFulfilled?: ((value: V) => V | Promise) | null, + onRejected?: ((error: any) => any) | null, + options?: AxiosInterceptorOptions + ): number; + eject(id: number): void; + clear(): void; + } + + export class Axios { + constructor(config?: AxiosRequestConfig); + defaults: AxiosDefaults; + interceptors: { + request: AxiosInterceptorManager; + response: AxiosInterceptorManager; + }; + getUri(config?: AxiosRequestConfig): string; + request, D = any>(config: AxiosRequestConfig): Promise; + get, D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + delete, D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + head, D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + options, D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + post, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; + put, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; + patch, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; + postForm, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; + putForm, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; + patchForm, D = any>( + url: string, + data?: D, + config?: AxiosRequestConfig + ): Promise; + } + + export interface AxiosInstance extends Axios { + , D = any>(config: AxiosRequestConfig): Promise; + , D = any>( + url: string, + config?: AxiosRequestConfig + ): Promise; + + defaults: Omit & { + headers: HeadersDefaults & { + [key: string]: AxiosHeaderValue; + }; + }; + } + + export interface GenericFormData { + append(name: string, value: any, options?: any): any; + } + + export interface GenericHTMLFormElement { + name: string; + method: string; + submit(): void; + } + + export function getAdapter( + adapters: AxiosAdapterConfig | AxiosAdapterConfig[] | undefined + ): AxiosAdapter; + + export function toFormData( + sourceObj: object, + targetFormData?: GenericFormData, + options?: FormSerializerOptions + ): GenericFormData; + + export function formToJSON(form: GenericFormData | GenericHTMLFormElement): object; + + export function isAxiosError(payload: any): payload is AxiosError; + + export function spread(callback: (...args: T[]) => R): (array: T[]) => R; + + export function isCancel(value: any): value is Cancel; + + export function all(values: Array>): Promise; + + export interface AxiosStatic extends AxiosInstance { + create(config?: CreateAxiosDefaults): AxiosInstance; + Cancel: CancelStatic; + CancelToken: CancelTokenStatic; + Axios: typeof Axios; + AxiosError: typeof AxiosError; + HttpStatusCode: typeof HttpStatusCode; + readonly VERSION: string; + isCancel: typeof isCancel; + all: typeof all; + spread: typeof spread; + isAxiosError: typeof isAxiosError; + toFormData: typeof toFormData; + formToJSON: typeof formToJSON; + getAdapter: typeof getAdapter; + CanceledError: typeof CanceledError; + AxiosHeaders: typeof AxiosHeaders; + } + + const axios: AxiosStatic; + + export default axios; +} +`; diff --git a/src/modules/flow/components/nodes/code/editor/declares/cool.ts b/src/modules/flow/components/nodes/code/editor/declares/cool.ts new file mode 100644 index 0000000..9b987e8 --- /dev/null +++ b/src/modules/flow/components/nodes/code/editor/declares/cool.ts @@ -0,0 +1,639 @@ +export const cool = ` +/** + * Repository + */ +interface Repository { + /** + * any target that is managed by this repository. + * If this repository manages any from schema, + * then it returns a name of that schema instead. + */ + readonly target: any; + /** + * any Manager used by this repository. + */ + readonly manager: any; + /** + * Query runner provider used for this repository. + */ + readonly queryRunner?: any; + /** + * any metadata of the any current repository manages. + */ + get metadata(): any; + /** + * Creates a new query builder that can be used to build a SQL query. + */ + createQueryBuilder(alias?: string, queryRunner?: any): any; + /** + * Checks if any has an id. + * If any composite compose ids, it will check them all. + */ + hasId(any: any): boolean; + /** + * Gets any mixed id. + */ + getId(any: any): any; + /** + * Creates a new any instance. + */ + create(): any; + /** + * Creates new entities and copies all any properties from given objects into their new entities. + * Note that it copies only properties that are present in any schema. + */ + create(anyLikeArray: any): any[]; + /** + * Creates a new any instance and copies all any properties from this object into a new any. + * Note that it copies only properties that are present in any schema. + */ + create(anyLike: any): any; + /** + * Merges multiple entities (or any-like objects) into a given any. + */ + merge(mergeIntoany: any, ...anyLikes: any): any; + /** + * Creates a new any from the given plain javascript object. If any already exist in the database, then + * it loads it (and everything related to it), replaces all values with the new ones from the given object + * and returns this new any. This new any is actually a loaded from the db any with all properties + * replaced from the new object. + * + * Note that given any-like object must have an any id / primary key to find any by. + * Returns undefined if any with given id was not found. + */ + preload(anyLike: any): Promise; + /** + * Saves all given entities in the database. + * If entities do not exist in the database then inserts, otherwise updates. + */ + save( + entities: any[], + options: any & { + reload: false; + } + ): Promise; + /** + * Saves all given entities in the database. + * If entities do not exist in the database then inserts, otherwise updates. + */ + save(entities: any[], options?: any): Promise; + /** + * Saves a given any in the database. + * If any does not exist in the database then inserts, otherwise updates. + */ + save( + any: any, + options: any & { + reload: false; + } + ): Promise; + /** + * Saves a given any in the database. + * If any does not exist in the database then inserts, otherwise updates. + */ + save(any: any, options?: any): any; + /** + * Removes a given entities from the database. + */ + remove(entities: any[], options?: any): Promise; + /** + * Removes a given any from the database. + */ + remove(any: any, options?: any): Promise; + /** + * Records the delete date of all given entities. + */ + softRemove( + entities: any[], + options: any & { + reload: false; + } + ): Promise; + /** + * Records the delete date of all given entities. + */ + softRemove(entities: any[], options?: any): Promise; + /** + * Records the delete date of a given any. + */ + softRemove( + any: any, + options: any & { + reload: false; + } + ): Promise; + /** + * Records the delete date of a given any. + */ + softRemove(any: any, options?: any): Promise; + /** + * Recovers all given entities in the database. + */ + recover( + entities: any[], + options: any & { + reload: false; + } + ): Promise; + /** + * Recovers all given entities in the database. + */ + recover(entities: any[], options?: any): Promise; + /** + * Recovers a given any in the database. + */ + recover( + any: any, + options: any & { + reload: false; + } + ): Promise; + /** + * Recovers a given any in the database. + */ + recover(any: any, options?: any): Promise; + /** + * Inserts a given any into the database. + * Unlike save method executes a primitive operation without cascades, relations and other operations included. + * Executes fast and efficient INSERT query. + * Does not check if any exist in the database, so query will fail if duplicate any is being inserted. + */ + insert(any: any | any[]): Promise; + /** + * Updates any partially. any can be found by a given conditions. + * Unlike save method executes a primitive operation without cascades, relations and other operations included. + * Executes fast and efficient UPDATE query. + * Does not check if any exist in the database. + */ + update(criteria: any, partialany: any): Promise; + /** + * Inserts a given any into the database, unless a unique constraint conflicts then updates the any + * Unlike save method executes a primitive operation without cascades, relations and other operations included. + * Executes fast and efficient INSERT ... ON CONFLICT DO UPDATE/ON DUPLICATE KEY UPDATE query. + */ + upsert(anyOrEntities: any | any[], conflictPathsOrOptions: string[] | any): Promise; + /** + * Deletes entities by a given criteria. + * Unlike save method executes a primitive operation without cascades, relations and other operations included. + * Executes fast and efficient DELETE query. + * Does not check if any exist in the database. + */ + delete(criteria: any): Promise; + /** + * Records the delete date of entities by a given criteria. + * Unlike save method executes a primitive operation without cascades, relations and other operations included. + * Executes fast and efficient SOFT-DELETE query. + * Does not check if any exist in the database. + */ + softDelete(criteria: any): Promise; + /** + * Restores entities by a given criteria. + * Unlike save method executes a primitive operation without cascades, relations and other operations included. + * Executes fast and efficient SOFT-DELETE query. + * Does not check if any exist in the database. + */ + restore(criteria: any): Promise; + /** + * Checks whether any any exists that matches the given options. + * + * @deprecated use \`exists\` method instead, for example: + * + * .exists() + */ + exist(options?: any): Promise; + /** + * Checks whether any any exists that matches the given options. + */ + exists(options?: any): Promise; + /** + * Checks whether any any exists that matches the given conditions. + */ + existsBy(where: any | any[]): Promise; + /** + * Counts entities that match given options. + * Useful for pagination. + */ + count(options?: any): Promise; + /** + * Counts entities that match given conditions. + * Useful for pagination. + */ + countBy(where: any | any[]): Promise; + /** + * Return the SUM of a column + */ + sum(columnName: any, where?: any | any[]): Promise; + /** + * Return the AVG of a column + */ + average(columnName: any, where?: any | any[]): Promise; + /** + * Return the MIN of a column + */ + minimum(columnName: any, where?: any | any[]): Promise; + /** + * Return the MAX of a column + */ + maximum(columnName: any, where?: any | any[]): Promise; + /** + * Finds entities that match given find options. + */ + find(options?: any): Promise; + /** + * Finds entities that match given find options. + */ + findBy(where: any | any[]): Promise; + /** + * Finds entities that match given find options. + * Also counts all entities that match given conditions, + * but ignores pagination settings (from and take options). + */ + findAndCount(options?: any): Promise<[any[], number]>; + /** + * Finds entities that match given WHERE conditions. + * Also counts all entities that match given conditions, + * but ignores pagination settings (from and take options). + */ + findAndCountBy(where: any | any[]): Promise<[any[], number]>; + /** + * Finds entities with ids. + * Optionally find options or conditions can be applied. + * + * @deprecated use \`findBy\` method instead in conjunction with \`In\` operator, for example: + * + * .findBy({ + * id: In([1, 2, 3]) + * }) + */ + findByIds(ids: any[]): Promise; + /** + * Finds first any by a given find options. + * If any was not found in the database - returns null. + */ + findOne(options: any): Promise; + /** + * Finds first any that matches given where condition. + * If any was not found in the database - returns null. + */ + findOneBy(where: any | any[]): Promise; + /** + * Finds first any that matches given id. + * If any was not found in the database - returns null. + * + * @deprecated use \`findOneBy\` method instead in conjunction with \`In\` operator, for example: + * + * .findOneBy({ + * id: 1 // where "id" is your primary column name + * }) + */ + findOneById(id: number | string | Date | any): Promise; + /** + * Finds first any by a given find options. + * If any was not found in the database - rejects with error. + */ + findOneOrFail(options: any): Promise; + /** + * Finds first any that matches given where condition. + * If any was not found in the database - rejects with error. + */ + findOneByOrFail(where: any | any[]): Promise; + /** + * Executes a raw SQL query and returns a raw database results. + * Raw query execution is supported only by relational databases (MongoDB is not supported). + */ + query(query: string, parameters?: any[]): Promise; + /** + * Clears all the data from the given table/collection (truncates/drops it). + * + * Note: this method uses TRUNCATE and may not work as you expect in transactions on some platforms. + * @see https://stackoverflow.com/a/5972738/925151 + */ + clear(): Promise; + /** + * Increments some column by provided value of the entities matched given conditions. + */ + increment(conditions: any, propertyPath: string, value: number | string): Promise; + /** + * Decrements some column by provided value of the entities matched given conditions. + */ + decrement(conditions: any, propertyPath: string, value: number | string): Promise; + /** + * Extends repository with provided functions. + */ + extend( + customs: CustomRepository & ThisType + ): this & CustomRepository; + + [key: string]: any; +} + +/** + * App + */ +interface App { + /** + * 获得基础目录 + */ + getBaseDir(): string; + /** + * 获得应用目录 + */ + getAppDir(): string; + /** + * 获得环境 + */ + getEnv(): string; + /** + * 获得框架 + */ + getFramework(): any; + /** + * 获得当前进程类型 + */ + getProcessType(): any; + /** + * 获得全局容器 + */ + getApplicationContext(): any; + /** + * 获得配置 + * @param key 配置key + */ + getConfig(key?: string): any; + /** + * 获得日志 + * @param name + */ + getLogger(name?: string): any; + /** + * 获得核心日志 + */ + getCoreLogger(): any; + /** + * 创建日志 + * @param name + * @param options + */ + createLogger(name: string, options: any): any; + /** + * 获得当前应用名称 + */ + getProjectName(): string; + /** + * 创建一个带有RequestContainer的上下文 + * @param args 参数 + */ + createAnonymousContext(...args: any[]): any; + /** + * 创建一个带有RequestContainer的上下文 + * @param BaseContextLoggerClass 上下文日志类 + */ + setContextLoggerClass(BaseContextLoggerClass: any): void; + /** + * 新增配置 + * @param obj 配置对象 + */ + addConfigObject(obj: any): any; + /** + * 设置属性 + * @param key 属性名 + * @param value 属性值 + */ + setAttr(key: string, value: any): any; + /** + * 获得属性 + * @param key + */ + getAttr(key: string): T; + /** + * 使用中间件 + * @param Middleware + */ + useMiddleware(Middleware): void; + /** + * 获得中间件 + */ + getMiddleware(): any; + /** + * 使用过滤器 + * @param Filter 过滤器 + */ + useFilter(Filter): void; + /** + * 新增全局守卫 + * @param guard + */ + useGuard(guard): void; + /** + * 获得命名空间 + */ + getNamespace(): string; + + [key: string]: any; +} + +/** + * OrmManager + */ +interface OrmManager { + /** + * 获得数据源 + * @param dataSourceName + */ + getDataSource(dataSourceName: string): any; + /** + * 检查数据源是否存在 + * @param dataSourceName + */ + hasDataSource(dataSourceName: string): boolean; + /** + * 获得所有数据源名称 + */ + getDataSourceNames(): string[]; + /** + * 获得所有数据源 + */ + getAllDataSources(): Map; + /** + * 检查数据源是否连接 + * @param dataSourceName + */ + isConnected(dataSourceName: string): Promise; + /** + * 创建数据源实例 + * @param config + * @param clientName + * @param options + */ + createInstance( + config: any, + clientName: any, + options?: { + validateConnection?: boolean; + cacheInstance?: boolean | undefined; + } + ): Promise; + /** + * 获得model或者repository的数据源名称 + * @param modelOrRepository + */ + getDataSourceNameByModel(modelOrRepository: any): string | undefined; + /** + * 获得名称 + */ + getName(): string; + /** + * 停止 + */ + stop(): Promise; + /** + * 获得默认数据源名称 + */ + getDefaultDataSourceName(): string; + /** + * 获得数据源优先级 + * @param name + */ + getDataSourcePriority(name: string): string; + /** + * 是否高优先级 + * @param name + */ + isHighPriority(name: string): boolean; + /** + * 是否中等优先级 + * @param + */ + isMediumPriority(name: string): boolean; + /** + * 是否低优先级 + * @param name + */ + isLowPriority(name: string): boolean; + + [key: string]: any; +} + +/** + * PluginService + */ +interface PluginService { + /** + * 获得插件配置 + * @param key 插件key + */ + getConfig(key: string): Promise; + /** + * 调用插件 + * @param key 插件key + * @param method 方法 + * @param params 参数 + * @returns + */ + invoke(key: string, method: string, ...params: any[]): Promise; + /** + * 获得插件实例 + * @param key 插件key + * @returns + */ + getInstance(key: string): Promise; + + [key: string]: any; +} + +/** + * MidwayCache + */ +interface MidwayCache { + /** + * 设置缓存 + * @param key + * @param value + * @param ttl + * @returns + */ + set: (key: string, value: unknown, ttl?: number) => Promise; + /** + * 获得缓存 + * @param key + * @returns + */ + get: (key: string) => Promise; + /** + * 删除缓存 + * @param key + * @returns + */ + del: (key: string) => Promise; + /** + * 重置缓存 + * @returns + */ + reset: () => Promise; + + [key: string]: any; +} + +/** + * 代码执行基类 + */ + +declare class Base { + /** + * 数据源管理器 + */ + typeORMDataSourceManager: OrmManager; + + /** + * 应用 + */ + app: App; + /** + * 插件服务 + */ + pluginService: PluginService; + + /** + * 缓存 + */ + cache: MidwayCache; + + /** + * 主函数 + */ + main(params: any): Promise; + + /** + * 执行sql + * @param sql sql语句 + * @param params 参数 + * @param dataSource 数据源 + */ + execSql(sql: string, params, dataSource): Promise; + + /** + * 获得typeorm的Repository + * @param anyName + * @returns + */ + getRepository(anyName: string): Promise; + + /** + * 调用service + * @param service 服务 + * @param method 方法 + * @param args 参数 + * @returns + */ + invokeService(service: string, method: string, ...args): Promise; + + /** + * 调用插件 + * @param key 插件的key + * @param method 插件的方法 + * @param args 参数 + * @returns + */ + invokePlugin(key: string, method: string, ...args): Promise; +} +`; diff --git a/src/modules/flow/components/nodes/code/editor/declares/dayjs.ts b/src/modules/flow/components/nodes/code/editor/declares/dayjs.ts new file mode 100644 index 0000000..a92a0be --- /dev/null +++ b/src/modules/flow/components/nodes/code/editor/declares/dayjs.ts @@ -0,0 +1,464 @@ +export const dayjs = ` +declare module "dayjs" { + function dayjs(date?: dayjs.ConfigType): dayjs.Dayjs; + + function dayjs( + date?: dayjs.ConfigType, + format?: dayjs.OptionType, + strict?: boolean + ): dayjs.Dayjs; + + function dayjs( + date?: dayjs.ConfigType, + format?: dayjs.OptionType, + locale?: string, + strict?: boolean + ): dayjs.Dayjs; + + namespace dayjs { + interface ConfigTypeMap { + default: string | number | Date | Dayjs | null | undefined; + } + + export type ConfigType = ConfigTypeMap[keyof ConfigTypeMap]; + + export interface FormatObject { + locale?: string; + format?: string; + utc?: boolean; + } + + export type OptionType = FormatObject | string | string[]; + + export type UnitTypeShort = "d" | "D" | "M" | "y" | "h" | "m" | "s" | "ms"; + + export type UnitTypeLong = + | "millisecond" + | "second" + | "minute" + | "hour" + | "day" + | "month" + | "year" + | "date"; + + export type UnitTypeLongPlural = + | "milliseconds" + | "seconds" + | "minutes" + | "hours" + | "days" + | "months" + | "years" + | "dates"; + + export type UnitType = UnitTypeLong | UnitTypeLongPlural | UnitTypeShort; + + export type OpUnitType = UnitType | "week" | "weeks" | "w"; + export type QUnitType = UnitType | "quarter" | "quarters" | "Q"; + export type ManipulateType = Exclude; + class Dayjs { + constructor(config?: ConfigType); + /** + * All Day.js objects are immutable. Still, \`dayjs#clone\` can create a clone of the current object if you need one. + * \`\`\` + * dayjs().clone()// => Dayjs + * dayjs(dayjs('2019-01-25')) // passing a Dayjs object to a constructor will also clone it + * \`\`\` + * Docs: https://day.js.org/docs/en/parse/dayjs-clone + */ + clone(): Dayjs; + /** + * This returns a \`boolean\` indicating whether the Day.js object contains a valid date or not. + * \`\`\` + * dayjs().isValid()// => boolean + * \`\`\` + * Docs: https://day.js.org/docs/en/parse/is-valid + */ + isValid(): boolean; + /** + * Get the year. + * \`\`\` + * dayjs().year()// => 2020 + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/year + */ + year(): number; + /** + * Set the year. + * \`\`\` + * dayjs().year(2000)// => Dayjs + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/year + */ + year(value: number): Dayjs; + /** + * Get the month. + * + * Months are zero indexed, so January is month 0. + * \`\`\` + * dayjs().month()// => 0-11 + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/month + */ + month(): number; + /** + * Set the month. + * + * Months are zero indexed, so January is month 0. + * + * Accepts numbers from 0 to 11. If the range is exceeded, it will bubble up to the next year. + * \`\`\` + * dayjs().month(0)// => Dayjs + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/month + */ + month(value: number): Dayjs; + /** + * Get the date of the month. + * \`\`\` + * dayjs().date()// => 1-31 + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/date + */ + date(): number; + /** + * Set the date of the month. + * + * Accepts numbers from 1 to 31. If the range is exceeded, it will bubble up to the next months. + * \`\`\` + * dayjs().date(1)// => Dayjs + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/date + */ + date(value: number): Dayjs; + /** + * Get the day of the week. + * + * Returns numbers from 0 (Sunday) to 6 (Saturday). + * \`\`\` + * dayjs().day()// 0-6 + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/day + */ + day(): 0 | 1 | 2 | 3 | 4 | 5 | 6; + /** + * Set the day of the week. + * + * Accepts numbers from 0 (Sunday) to 6 (Saturday). If the range is exceeded, it will bubble up to next weeks. + * \`\`\` + * dayjs().day(0)// => Dayjs + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/day + */ + day(value: number): Dayjs; + /** + * Get the hour. + * \`\`\` + * dayjs().hour()// => 0-23 + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/hour + */ + hour(): number; + /** + * Set the hour. + * + * Accepts numbers from 0 to 23. If the range is exceeded, it will bubble up to the next day. + * \`\`\` + * dayjs().hour(12)// => Dayjs + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/hour + */ + hour(value: number): Dayjs; + /** + * Get the minutes. + * \`\`\` + * dayjs().minute()// => 0-59 + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/minute + */ + minute(): number; + /** + * Set the minutes. + * + * Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the next hour. + * \`\`\` + * dayjs().minute(59)// => Dayjs + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/minute + */ + minute(value: number): Dayjs; + /** + * Get the seconds. + * \`\`\` + * dayjs().second()// => 0-59 + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/second + */ + second(): number; + /** + * Set the seconds. + * + * Accepts numbers from 0 to 59. If the range is exceeded, it will bubble up to the next minutes. + * \`\`\` + * dayjs().second(1)// Dayjs + * \`\`\` + */ + second(value: number): Dayjs; + /** + * Get the milliseconds. + * \`\`\` + * dayjs().millisecond()// => 0-999 + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/millisecond + */ + millisecond(): number; + /** + * Set the milliseconds. + * + * Accepts numbers from 0 to 999. If the range is exceeded, it will bubble up to the next seconds. + * \`\`\` + * dayjs().millisecond(1)// => Dayjs + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/millisecond + */ + millisecond(value: number): Dayjs; + /** + * Generic setter, accepting unit as first argument, and value as second, returns a new instance with the applied changes. + * + * In general: + * \`\`\` + * dayjs().set(unit, value) === dayjs()[unit](value) + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * \`\`\` + * dayjs().set('date', 1) + * dayjs().set('month', 3) // April + * dayjs().set('second', 30) + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/set + */ + set(unit: UnitType, value: number): Dayjs; + /** + * String getter, returns the corresponding information getting from Day.js object. + * + * In general: + * \`\`\` + * dayjs().get(unit) === dayjs()[unit]() + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * \`\`\` + * dayjs().get('year') + * dayjs().get('month') // start 0 + * dayjs().get('date') + * \`\`\` + * Docs: https://day.js.org/docs/en/get-set/get + */ + get(unit: UnitType): number; + /** + * Returns a cloned Day.js object with a specified amount of time added. + * \`\`\` + * dayjs().add(7, 'day')// => Dayjs + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * + * Docs: https://day.js.org/docs/en/manipulate/add + */ + add(value: number, unit?: ManipulateType): Dayjs; + /** + * Returns a cloned Day.js object with a specified amount of time subtracted. + * \`\`\` + * dayjs().subtract(7, 'year')// => Dayjs + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * + * Docs: https://day.js.org/docs/en/manipulate/subtract + */ + subtract(value: number, unit?: ManipulateType): Dayjs; + /** + * Returns a cloned Day.js object and set it to the start of a unit of time. + * \`\`\` + * dayjs().startOf('year')// => Dayjs + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * + * Docs: https://day.js.org/docs/en/manipulate/start-of + */ + startOf(unit: OpUnitType): Dayjs; + /** + * Returns a cloned Day.js object and set it to the end of a unit of time. + * \`\`\` + * dayjs().endOf('month')// => Dayjs + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * + * Docs: https://day.js.org/docs/en/manipulate/end-of + */ + endOf(unit: OpUnitType): Dayjs; + /** + * Get the formatted date according to the string of tokens passed in. + * + * To escape characters, wrap them in square brackets (e.g. [MM]). + * \`\`\` + * dayjs().format()// => current date in ISO8601, without fraction seconds e.g. '2020-04-02T08:02:17-05:00' + * dayjs('2019-01-25').format('[YYYYescape] YYYY-MM-DDTHH:mm:ssZ[Z]')// 'YYYYescape 2019-01-25T00:00:00-02:00Z' + * dayjs('2019-01-25').format('DD/MM/YYYY') // '25/01/2019' + * \`\`\` + * Docs: https://day.js.org/docs/en/display/format + */ + format(template?: string): string; + /** + * This indicates the difference between two date-time in the specified unit. + * + * To get the difference in milliseconds, use \`dayjs#diff\` + * \`\`\` + * const date1 = dayjs('2019-01-25') + * const date2 = dayjs('2018-06-05') + * date1.diff(date2) // 20214000000 default milliseconds + * date1.diff() // milliseconds to current time + * \`\`\` + * + * To get the difference in another unit of measurement, pass that measurement as the second argument. + * \`\`\` + * const date1 = dayjs('2019-01-25') + * date1.diff('2018-06-05', 'month') // 7 + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * + * Docs: https://day.js.org/docs/en/display/difference + */ + diff(date?: ConfigType, unit?: QUnitType | OpUnitType, float?: boolean): number; + /** + * This returns the number of **milliseconds** since the Unix Epoch of the Day.js object. + * \`\`\` + * dayjs('2019-01-25').valueOf() // 1548381600000 + * +dayjs(1548381600000) // 1548381600000 + * \`\`\` + * To get a Unix timestamp (the number of seconds since the epoch) from a Day.js object, you should use Unix Timestamp \`dayjs#unix()\`. + * + * Docs: https://day.js.org/docs/en/display/unix-timestamp-milliseconds + */ + valueOf(): number; + /** + * This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object. + * \`\`\` + * dayjs('2019-01-25').unix() // 1548381600 + * \`\`\` + * This value is floored to the nearest second, and does not include a milliseconds component. + * + * Docs: https://day.js.org/docs/en/display/unix-timestamp + */ + unix(): number; + /** + * Get the number of days in the current month. + * \`\`\` + * dayjs('2019-01-25').daysInMonth() // 31 + * \`\`\` + * Docs: https://day.js.org/docs/en/display/days-in-month + */ + daysInMonth(): number; + /** + * To get a copy of the native \`Date\` object parsed from the Day.js object use \`dayjs#toDate\`. + * \`\`\` + * dayjs('2019-01-25').toDate()// => Date + * \`\`\` + */ + toDate(): Date; + /** + * To serialize as an ISO 8601 string. + * \`\`\` + * dayjs('2019-01-25').toJSON() // '2019-01-25T02:00:00.000Z' + * \`\`\` + * Docs: https://day.js.org/docs/en/display/as-json + */ + toJSON(): string; + /** + * To format as an ISO 8601 string. + * \`\`\` + * dayjs('2019-01-25').toISOString() // '2019-01-25T02:00:00.000Z' + * \`\`\` + * Docs: https://day.js.org/docs/en/display/as-iso-string + */ + toISOString(): string; + /** + * Returns a string representation of the date. + * \`\`\` + * dayjs('2019-01-25').toString() // 'Fri, 25 Jan 2019 02:00:00 GMT' + * \`\`\` + * Docs: https://day.js.org/docs/en/display/as-string + */ + toString(): string; + /** + * Get the UTC offset in minutes. + * \`\`\` + * dayjs().utcOffset() + * \`\`\` + * Docs: https://day.js.org/docs/en/manipulate/utc-offset + */ + utcOffset(): number; + /** + * This indicates whether the Day.js object is before the other supplied date-time. + * \`\`\` + * dayjs().isBefore(dayjs('2011-01-01')) // default milliseconds + * \`\`\` + * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter. + * \`\`\` + * dayjs().isBefore('2011-01-01', 'year')// => boolean + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * + * Docs: https://day.js.org/docs/en/query/is-before + */ + isBefore(date?: ConfigType, unit?: OpUnitType): boolean; + /** + * This indicates whether the Day.js object is the same as the other supplied date-time. + * \`\`\` + * dayjs().isSame(dayjs('2011-01-01')) // default milliseconds + * \`\`\` + * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter. + * \`\`\` + * dayjs().isSame('2011-01-01', 'year')// => boolean + * \`\`\` + * Docs: https://day.js.org/docs/en/query/is-same + */ + isSame(date?: ConfigType, unit?: OpUnitType): boolean; + /** + * This indicates whether the Day.js object is after the other supplied date-time. + * \`\`\` + * dayjs().isAfter(dayjs('2011-01-01')) // default milliseconds + * \`\`\` + * If you want to limit the granularity to a unit other than milliseconds, pass it as the second parameter. + * \`\`\` + * dayjs().isAfter('2011-01-01', 'year')// => boolean + * \`\`\` + * Units are case insensitive, and support plural and short forms. + * + * Docs: https://day.js.org/docs/en/query/is-after + */ + isAfter(date?: ConfigType, unit?: OpUnitType): boolean; + + locale(): string; + + locale(preset: string | ILocale, object?: Partial): Dayjs; + } + + export type PluginFunc = (option: T, c: typeof Dayjs, d: typeof dayjs) => void; + + export function extend(plugin: PluginFunc, option?: T): Dayjs; + + export function locale( + preset?: string | ILocale, + object?: Partial, + isLocal?: boolean + ): string; + + export function isDayjs(d: any): d is Dayjs; + + export function unix(t: number): Dayjs; + + const Ls: { [key: string]: ILocale }; + } + + export default dayjs; +} +`; diff --git a/src/modules/flow/components/nodes/code/editor/declares/index.ts b/src/modules/flow/components/nodes/code/editor/declares/index.ts new file mode 100644 index 0000000..f6930c7 --- /dev/null +++ b/src/modules/flow/components/nodes/code/editor/declares/index.ts @@ -0,0 +1,13 @@ +import { axios } from "./axios"; +import { cool } from "./cool"; +import { dayjs } from "./dayjs"; +import { lodash } from "./lodash"; +import { moment } from "./moment"; + +export const declares = { + axios, + cool, + dayjs, + lodash, + moment +}; diff --git a/src/modules/flow/components/nodes/code/editor/declares/lodash.ts b/src/modules/flow/components/nodes/code/editor/declares/lodash.ts new file mode 100644 index 0000000..7e23c67 --- /dev/null +++ b/src/modules/flow/components/nodes/code/editor/declares/lodash.ts @@ -0,0 +1,1263 @@ +export const lodash = ` +declare module "lodash" { + class lodash { + constructor(value: any); + + add(...args: any[]): any; + + after(...args: any[]): any; + + ary(...args: any[]): any; + + assign(...args: any[]): any; + + assignIn(...args: any[]): any; + + assignInWith(...args: any[]): any; + + assignWith(...args: any[]): any; + + at(...args: any[]): any; + + attempt(...args: any[]): any; + + before(...args: any[]): any; + + bind(...args: any[]): any; + + bindAll(...args: any[]): any; + + bindKey(...args: any[]): any; + + camelCase(...args: any[]): any; + + capitalize(...args: any[]): any; + + castArray(...args: any[]): any; + + ceil(...args: any[]): any; + + chain(): any; + + chunk(...args: any[]): any; + + clamp(...args: any[]): any; + + clone(...args: any[]): any; + + cloneDeep(...args: any[]): any; + + cloneDeepWith(...args: any[]): any; + + cloneWith(...args: any[]): any; + + commit(): any; + + compact(...args: any[]): any; + + concat(...args: any[]): any; + + cond(...args: any[]): any; + + conforms(...args: any[]): any; + + conformsTo(...args: any[]): any; + + constant(...args: any[]): any; + + countBy(...args: any[]): any; + + create(...args: any[]): any; + + curry(...args: any[]): any; + + curryRight(...args: any[]): any; + + debounce(...args: any[]): any; + + deburr(...args: any[]): any; + + defaultTo(...args: any[]): any; + + defaults(...args: any[]): any; + + defaultsDeep(...args: any[]): any; + + defer(...args: any[]): any; + + delay(...args: any[]): any; + + difference(...args: any[]): any; + + differenceBy(...args: any[]): any; + + differenceWith(...args: any[]): any; + + divide(...args: any[]): any; + + drop(...args: any[]): any; + + dropRight(...args: any[]): any; + + dropRightWhile(...args: any[]): any; + + dropWhile(...args: any[]): any; + + each(...args: any[]): any; + + eachRight(...args: any[]): any; + + endsWith(...args: any[]): any; + + entries(...args: any[]): any; + + entriesIn(...args: any[]): any; + + eq(...args: any[]): any; + + escape(...args: any[]): any; + + escapeRegExp(...args: any[]): any; + + every(...args: any[]): any; + + extend(...args: any[]): any; + + extendWith(...args: any[]): any; + + fill(...args: any[]): any; + + filter(...args: any[]): any; + + find(...args: any[]): any; + + findIndex(...args: any[]): any; + + findKey(...args: any[]): any; + + findLast(...args: any[]): any; + + findLastIndex(...args: any[]): any; + + findLastKey(...args: any[]): any; + + first(...args: any[]): any; + + flatMap(...args: any[]): any; + + flatMapDeep(...args: any[]): any; + + flatMapDepth(...args: any[]): any; + + flatten(...args: any[]): any; + + flattenDeep(...args: any[]): any; + + flattenDepth(...args: any[]): any; + + flip(...args: any[]): any; + + floor(...args: any[]): any; + + flow(...args: any[]): any; + + flowRight(...args: any[]): any; + + forEach(...args: any[]): any; + + forEachRight(...args: any[]): any; + + forIn(...args: any[]): any; + + forInRight(...args: any[]): any; + + forOwn(...args: any[]): any; + + forOwnRight(...args: any[]): any; + + fromPairs(...args: any[]): any; + + functions(...args: any[]): any; + + functionsIn(...args: any[]): any; + + get(...args: any[]): any; + + groupBy(...args: any[]): any; + + gt(...args: any[]): any; + + gte(...args: any[]): any; + + has(...args: any[]): any; + + hasIn(...args: any[]): any; + + head(...args: any[]): any; + + identity(...args: any[]): any; + + inRange(...args: any[]): any; + + includes(...args: any[]): any; + + indexOf(...args: any[]): any; + + initial(...args: any[]): any; + + intersection(...args: any[]): any; + + intersectionBy(...args: any[]): any; + + intersectionWith(...args: any[]): any; + + invert(...args: any[]): any; + + invertBy(...args: any[]): any; + + invoke(...args: any[]): any; + + invokeMap(...args: any[]): any; + + isArguments(...args: any[]): any; + + isArray(...args: any[]): any; + + isArrayBuffer(...args: any[]): any; + + isArrayLike(...args: any[]): any; + + isArrayLikeObject(...args: any[]): any; + + isBoolean(...args: any[]): any; + + isBuffer(...args: any[]): any; + + isDate(...args: any[]): any; + + isElement(...args: any[]): any; + + isEmpty(...args: any[]): any; + + isEqual(...args: any[]): any; + + isEqualWith(...args: any[]): any; + + isError(...args: any[]): any; + + isFinite(...args: any[]): any; + + isFunction(...args: any[]): any; + + isInteger(...args: any[]): any; + + isLength(...args: any[]): any; + + isMap(...args: any[]): any; + + isMatch(...args: any[]): any; + + isMatchWith(...args: any[]): any; + + isNaN(...args: any[]): any; + + isNative(...args: any[]): any; + + isNil(...args: any[]): any; + + isNull(...args: any[]): any; + + isNumber(...args: any[]): any; + + isObject(...args: any[]): any; + + isObjectLike(...args: any[]): any; + + isPlainObject(...args: any[]): any; + + isRegExp(...args: any[]): any; + + isSafeInteger(...args: any[]): any; + + isSet(...args: any[]): any; + + isString(...args: any[]): any; + + isSymbol(...args: any[]): any; + + isTypedArray(...args: any[]): any; + + isUndefined(...args: any[]): any; + + isWeakMap(...args: any[]): any; + + isWeakSet(...args: any[]): any; + + iteratee(...args: any[]): any; + + join(...args: any[]): any; + + kebabCase(...args: any[]): any; + + keyBy(...args: any[]): any; + + keys(...args: any[]): any; + + keysIn(...args: any[]): any; + + last(...args: any[]): any; + + lastIndexOf(...args: any[]): any; + + lowerCase(...args: any[]): any; + + lowerFirst(...args: any[]): any; + + lt(...args: any[]): any; + + lte(...args: any[]): any; + + map(...args: any[]): any; + + mapKeys(...args: any[]): any; + + mapValues(...args: any[]): any; + + matches(...args: any[]): any; + + matchesProperty(...args: any[]): any; + + max(...args: any[]): any; + + maxBy(...args: any[]): any; + + mean(...args: any[]): any; + + meanBy(...args: any[]): any; + + memoize(...args: any[]): any; + + merge(...args: any[]): any; + + mergeWith(...args: any[]): any; + + method(...args: any[]): any; + + methodOf(...args: any[]): any; + + min(...args: any[]): any; + + minBy(...args: any[]): any; + + mixin(...args: any[]): any; + + multiply(...args: any[]): any; + + negate(...args: any[]): any; + + next(): any; + + noConflict(...args: any[]): any; + + noop(...args: any[]): any; + + now(...args: any[]): any; + + nth(...args: any[]): any; + + nthArg(...args: any[]): any; + + omit(...args: any[]): any; + + omitBy(...args: any[]): any; + + once(...args: any[]): any; + + orderBy(...args: any[]): any; + + over(...args: any[]): any; + + overArgs(...args: any[]): any; + + overEvery(...args: any[]): any; + + overSome(...args: any[]): any; + + pad(...args: any[]): any; + + padEnd(...args: any[]): any; + + padStart(...args: any[]): any; + + parseInt(...args: any[]): any; + + partial(...args: any[]): any; + + partialRight(...args: any[]): any; + + partition(...args: any[]): any; + + pick(...args: any[]): any; + + pickBy(...args: any[]): any; + + plant(value: any): any; + + pop(...args: any[]): any; + + property(...args: any[]): any; + + propertyOf(...args: any[]): any; + + pull(...args: any[]): any; + + pullAll(...args: any[]): any; + + pullAllBy(...args: any[]): any; + + pullAllWith(...args: any[]): any; + + pullAt(...args: any[]): any; + + push(...args: any[]): any; + + random(...args: any[]): any; + + range(...args: any[]): any; + + rangeRight(...args: any[]): any; + + rearg(...args: any[]): any; + + reduce(...args: any[]): any; + + reduceRight(...args: any[]): any; + + reject(...args: any[]): any; + + remove(...args: any[]): any; + + repeat(...args: any[]): any; + + replace(...args: any[]): any; + + rest(...args: any[]): any; + + result(...args: any[]): any; + + reverse(): any; + + round(...args: any[]): any; + + runInContext(...args: any[]): any; + + sample(...args: any[]): any; + + sampleSize(...args: any[]): any; + + set(...args: any[]): any; + + setWith(...args: any[]): any; + + shift(...args: any[]): any; + + shuffle(...args: any[]): any; + + size(...args: any[]): any; + + slice(...args: any[]): any; + + snakeCase(...args: any[]): any; + + some(...args: any[]): any; + + sort(...args: any[]): any; + + sortBy(...args: any[]): any; + + sortedIndex(...args: any[]): any; + + sortedIndexBy(...args: any[]): any; + + sortedIndexOf(...args: any[]): any; + + sortedLastIndex(...args: any[]): any; + + sortedLastIndexBy(...args: any[]): any; + + sortedLastIndexOf(...args: any[]): any; + + sortedUniq(...args: any[]): any; + + sortedUniqBy(...args: any[]): any; + + splice(...args: any[]): any; + + split(...args: any[]): any; + + spread(...args: any[]): any; + + startCase(...args: any[]): any; + + startsWith(...args: any[]): any; + + stubArray(...args: any[]): any; + + stubFalse(...args: any[]): any; + + stubObject(...args: any[]): any; + + stubString(...args: any[]): any; + + stubTrue(...args: any[]): any; + + subtract(...args: any[]): any; + + sum(...args: any[]): any; + + sumBy(...args: any[]): any; + + tail(...args: any[]): any; + + take(...args: any[]): any; + + takeRight(...args: any[]): any; + + takeRightWhile(...args: any[]): any; + + takeWhile(...args: any[]): any; + + tap(...args: any[]): any; + + template(...args: any[]): any; + + throttle(...args: any[]): any; + + thru(...args: any[]): any; + + times(...args: any[]): any; + + toArray(...args: any[]): any; + + toFinite(...args: any[]): any; + + toInteger(...args: any[]): any; + + toJSON(): any; + + toLength(...args: any[]): any; + + toLower(...args: any[]): any; + + toNumber(...args: any[]): any; + + toPairs(...args: any[]): any; + + toPairsIn(...args: any[]): any; + + toPath(...args: any[]): any; + + toPlainObject(...args: any[]): any; + + toSafeInteger(...args: any[]): any; + + toString(...args: any[]): any; + + toUpper(...args: any[]): any; + + transform(...args: any[]): any; + + trim(...args: any[]): any; + + trimEnd(...args: any[]): any; + + trimStart(...args: any[]): any; + + truncate(...args: any[]): any; + + unary(...args: any[]): any; + + unescape(...args: any[]): any; + + union(...args: any[]): any; + + unionBy(...args: any[]): any; + + unionWith(...args: any[]): any; + + uniq(...args: any[]): any; + + uniqBy(...args: any[]): any; + + uniqWith(...args: any[]): any; + + uniqueId(...args: any[]): any; + + unset(...args: any[]): any; + + unshift(...args: any[]): any; + + unzip(...args: any[]): any; + + unzipWith(...args: any[]): any; + + update(...args: any[]): any; + + updateWith(...args: any[]): any; + + upperCase(...args: any[]): any; + + upperFirst(...args: any[]): any; + + value(): any; + + valueOf(): any; + + values(...args: any[]): any; + + valuesIn(...args: any[]): any; + + without(...args: any[]): any; + + words(...args: any[]): any; + + wrap(...args: any[]): any; + + xor(...args: any[]): any; + + xorBy(...args: any[]): any; + + xorWith(...args: any[]): any; + + zip(...args: any[]): any; + + zipObject(...args: any[]): any; + + zipObjectDeep(...args: any[]): any; + + zipWith(...args: any[]): any; + + static VERSION: string; + + static add(value: any, other: any): any; + + static after(n: any, func: any, ...args: any[]): any; + + static ary(func: any, n: any, guard: any): any; + + static assign(...args: any[]): any; + + static assignIn(...args: any[]): any; + + static assignInWith(...args: any[]): any; + + static assignWith(...args: any[]): any; + + static at(...args: any[]): any; + + static attempt(...args: any[]): any; + + static before(n: any, func: any, ...args: any[]): any; + + static bind(...args: any[]): any; + + static bindAll(...args: any[]): any; + + static bindKey(...args: any[]): any; + + static camelCase(string: any): any; + + static capitalize(string: any): any; + + static castArray(...args: any[]): any; + + static ceil(number: any, precision: any): any; + + static chain(value: any): any; + + static chunk(array: any, size: any, guard: any): any; + + static clamp(number: any, lower: any, upper: any): any; + + static clone(value: any): any; + + static cloneDeep(value: any): any; + + static cloneDeepWith(value: any, customizer: any): any; + + static cloneWith(value: any, customizer: any): any; + + static compact(array: any): any; + + static concat(...args: any[]): any; + + static cond(pairs: any): any; + + static conforms(source: any): any; + + static conformsTo(object: any, source: any): any; + + static constant(value: any): any; + + static countBy(collection: any, iteratee: any): any; + + static create(prototype: any, properties: any): any; + + static curry(func: any, arity: any, guard: any): any; + + static curryRight(func: any, arity: any, guard: any): any; + + static debounce(func: any, wait: any, options: any, ...args: any[]): any; + + static deburr(string: any): any; + + static defaultTo(value: any, defaultValue: any): any; + + static defaults(...args: any[]): any; + + static defaultsDeep(...args: any[]): any; + + static defer(...args: any[]): any; + + static delay(...args: any[]): any; + + static difference(...args: any[]): any; + + static differenceBy(...args: any[]): any; + + static differenceWith(...args: any[]): any; + + static divide(value: any, other: any): any; + + static drop(array: any, n: any, guard: any): any; + + static dropRight(array: any, n: any, guard: any): any; + + static dropRightWhile(array: any, predicate: any): any; + + static dropWhile(array: any, predicate: any): any; + + static each(collection: any, iteratee: any): any; + + static eachRight(collection: any, iteratee: any): any; + + static endsWith(string: any, target: any, position: any): any; + + static entries(object: any): any; + + static entriesIn(object: any): any; + + static eq(value: any, other: any): any; + + static escape(string: any): any; + + static escapeRegExp(string: any): any; + + static every(collection: any, predicate: any, guard: any): any; + + static extend(...args: any[]): any; + + static extendWith(...args: any[]): any; + + static fill(array: any, value: any, start: any, end: any): any; + + static filter(collection: any, predicate: any): any; + + static find(collection: any, predicate: any, fromIndex: any): any; + + static findIndex(array: any, predicate: any, fromIndex: any): any; + + static findKey(object: any, predicate: any): any; + + static findLast(collection: any, predicate: any, fromIndex: any): any; + + static findLastIndex(array: any, predicate: any, fromIndex: any): any; + + static findLastKey(object: any, predicate: any): any; + + static first(array: any): any; + + static flatMap(collection: any, iteratee: any): any; + + static flatMapDeep(collection: any, iteratee: any): any; + + static flatMapDepth(collection: any, iteratee: any, depth: any): any; + + static flatten(array: any): any; + + static flattenDeep(array: any): any; + + static flattenDepth(array: any, depth: any): any; + + static flip(func: any): any; + + static floor(number: any, precision: any): any; + + static flow(...args: any[]): any; + + static flowRight(...args: any[]): any; + + static forEach(collection: any, iteratee: any): any; + + static forEachRight(collection: any, iteratee: any): any; + + static forIn(object: any, iteratee: any): any; + + static forInRight(object: any, iteratee: any): any; + + static forOwn(object: any, iteratee: any): any; + + static forOwnRight(object: any, iteratee: any): any; + + static fromPairs(pairs: any): any; + + static functions(object: any): any; + + static functionsIn(object: any): any; + + static get(object: any, path: any, defaultValue: any): any; + + static groupBy(collection: any, iteratee: any): any; + + static gt(value: any, other: any): any; + + static gte(value: any, other: any): any; + + static has(object: any, path: any): any; + + static hasIn(object: any, path: any): any; + + static head(array: any): any; + + static identity(value: any): any; + + static inRange(number: any, start: any, end: any): any; + + static includes(collection: any, value: any, fromIndex: any, guard: any): any; + + static indexOf(array: any, value: any, fromIndex: any): any; + + static initial(array: any): any; + + static intersection(...args: any[]): any; + + static intersectionBy(...args: any[]): any; + + static intersectionWith(...args: any[]): any; + + static invert(object: any, iteratee: any): any; + + static invertBy(object: any, iteratee: any): any; + + static invoke(...args: any[]): any; + + static invokeMap(...args: any[]): any; + + static isArguments(value: any): any; + + static isArray(p0: any): any; + + static isArrayBuffer(value: any): any; + + static isArrayLike(value: any): any; + + static isArrayLikeObject(value: any): any; + + static isBoolean(value: any): any; + + static isBuffer(b: any): any; + + static isDate(value: any): any; + + static isElement(value: any): any; + + static isEmpty(value: any): any; + + static isEqual(value: any, other: any): any; + + static isEqualWith(value: any, other: any, customizer: any): any; + + static isError(value: any): any; + + static isFinite(value: any): any; + + static isFunction(value: any): any; + + static isInteger(value: any): any; + + static isLength(value: any): any; + + static isMap(value: any): any; + + static isMatch(object: any, source: any): any; + + static isMatchWith(object: any, source: any, customizer: any): any; + + static isNaN(value: any): any; + + static isNative(value: any): any; + + static isNil(value: any): any; + + static isNull(value: any): any; + + static isNumber(value: any): any; + + static isObject(value: any): any; + + static isObjectLike(value: any): any; + + static isPlainObject(value: any): any; + + static isRegExp(value: any): any; + + static isSafeInteger(value: any): any; + + static isSet(value: any): any; + + static isString(value: any): any; + + static isSymbol(value: any): any; + + static isTypedArray(value: any): any; + + static isUndefined(value: any): any; + + static isWeakMap(value: any): any; + + static isWeakSet(value: any): any; + + static iteratee(func: any): any; + + static join(array: any, separator: any): any; + + static kebabCase(string: any): any; + + static keyBy(collection: any, iteratee: any): any; + + static keys(object: any): any; + + static keysIn(object: any): any; + + static last(array: any): any; + + static lastIndexOf(array: any, value: any, fromIndex: any): any; + + static lowerCase(string: any): any; + + static lowerFirst(string: any): any; + + static lt(value: any, other: any): any; + + static lte(value: any, other: any): any; + + static map(collection: any, iteratee: any): any; + + static mapKeys(object: any, iteratee: any): any; + + static mapValues(object: any, iteratee: any): any; + + static matches(source: any): any; + + static matchesProperty(path: any, srcValue: any): any; + + static max(array: any): any; + + static maxBy(array: any, iteratee: any): any; + + static mean(array: any): any; + + static meanBy(array: any, iteratee: any): any; + + static memoize(func: any, resolver: any, ...args: any[]): any; + + static merge(...args: any[]): any; + + static mergeWith(...args: any[]): any; + + static method(...args: any[]): any; + + static methodOf(...args: any[]): any; + + static min(array: any): any; + + static minBy(array: any, iteratee: any): any; + + static mixin(object: any, source: any, options: any, ...args: any[]): any; + + static multiply(value: any, other: any): any; + + static negate(predicate: any, ...args: any[]): any; + + static noConflict(): any; + + static noop(): void; + + static now(): any; + + static nth(array: any, n: any): any; + + static nthArg(n: any): any; + + static omit(...args: any[]): any; + + static omitBy(object: any, predicate: any): any; + + static once(func: any): any; + + static orderBy(collection: any, iteratees: any, orders: any, guard: any): any; + + static over(...args: any[]): any; + + static overArgs(...args: any[]): any; + + static overEvery(...args: any[]): any; + + static overSome(...args: any[]): any; + + static pad(string: any, length: any, chars: any): any; + + static padEnd(string: any, length: any, chars: any): any; + + static padStart(string: any, length: any, chars: any): any; + + static parseInt(string: any, radix: any, guard: any): any; + + static partial(...args: any[]): any; + + static partialRight(...args: any[]): any; + + static partition(collection: any, iteratee: any): any; + + static pick(...args: any[]): any; + + static pickBy(object: any, predicate: any): any; + + static property(path: any): any; + + static propertyOf(object: any): any; + + static pull(...args: any[]): any; + + static pullAll(array: any, values: any): any; + + static pullAllBy(array: any, values: any, iteratee: any): any; + + static pullAllWith(array: any, values: any, comparator: any): any; + + static pullAt(...args: any[]): any; + + static random(lower: any, upper: any, floating: any): any; + + static range(start: any, end: any, step: any): any; + + static rangeRight(start: any, end: any, step: any): any; + + static rearg(...args: any[]): any; + + static reduce(collection: any, iteratee: any, accumulator: any, ...args: any[]): any; + + static reduceRight(collection: any, iteratee: any, accumulator: any, ...args: any[]): any; + + static reject(collection: any, predicate: any): any; + + static remove(array: any, predicate: any): any; + + static repeat(string: any, n: any, guard: any): any; + + static replace(...args: any[]): any; + + static rest(func: any, start: any): any; + + static result(object: any, path: any, defaultValue: any): any; + + static reverse(array: any): any; + + static round(number: any, precision: any): any; + + static runInContext(context: any, ...args: any[]): any; + + static sample(collection: any): any; + + static sampleSize(collection: any, n: any, guard: any): any; + + static set(object: any, path: any, value: any): any; + + static setWith(object: any, path: any, value: any, customizer: any): any; + + static shuffle(collection: any): any; + + static size(collection: any): any; + + static slice(array: any, start: any, end: any): any; + + static snakeCase(string: any): any; + + static some(collection: any, predicate: any, guard: any): any; + + static sortBy(...args: any[]): any; + + static sortedIndex(array: any, value: any): any; + + static sortedIndexBy(array: any, value: any, iteratee: any): any; + + static sortedIndexOf(array: any, value: any): any; + + static sortedLastIndex(array: any, value: any): any; + + static sortedLastIndexBy(array: any, value: any, iteratee: any): any; + + static sortedLastIndexOf(array: any, value: any): any; + + static sortedUniq(array: any): any; + + static sortedUniqBy(array: any, iteratee: any): any; + + static split(string: any, separator: any, limit: any): any; + + static spread(func: any, start: any): any; + + static startCase(string: any): any; + + static startsWith(string: any, target: any, position: any): any; + + static stubArray(): any; + + static stubFalse(): any; + + static stubObject(): any; + + static stubString(): any; + + static stubTrue(): any; + + static subtract(value: any, other: any): any; + + static sum(array: any): any; + + static sumBy(array: any, iteratee: any): any; + + static tail(array: any): any; + + static take(array: any, n: any, guard: any): any; + + static takeRight(array: any, n: any, guard: any): any; + + static takeRightWhile(array: any, predicate: any): any; + + static takeWhile(array: any, predicate: any): any; + + static tap(value: any, interceptor: any): any; + + static template(string: any, options: any, guard: any): any; + + static templateSettings: { + escape: RegExp; + evaluate: RegExp; + imports: {}; + interpolate: RegExp; + variable: string; + }; + + static throttle(func: any, wait: any, options: any): any; + + static thru(value: any, interceptor: any): any; + + static times(n: any, iteratee: any): any; + + static toArray(value: any): any; + + static toFinite(value: any): any; + + static toInteger(value: any): any; + + static toLength(value: any): any; + + static toLower(value: any): any; + + static toNumber(value: any): any; + + static toPairs(object: any): any; + + static toPairsIn(object: any): any; + + static toPath(value: any): any; + + static toPlainObject(value: any): any; + + static toSafeInteger(value: any): any; + + static toString(value: any): any; + + static toUpper(value: any): any; + + static transform(object: any, iteratee: any, accumulator: any): any; + + static trim(string: any, chars: any, guard: any): any; + + static trimEnd(string: any, chars: any, guard: any): any; + + static trimStart(string: any, chars: any, guard: any): any; + + static truncate(string: any, options: any): any; + + static unary(func: any): any; + + static unescape(string: any): any; + + static union(...args: any[]): any; + + static unionBy(...args: any[]): any; + + static unionWith(...args: any[]): any; + + static uniq(array: any): any; + + static uniqBy(array: any, iteratee: any): any; + + static uniqWith(array: any, comparator: any): any; + + static uniqueId(prefix: any): any; + + static unset(object: any, path: any): any; + + static unzip(array: any): any; + + static unzipWith(array: any, iteratee: any): any; + + static update(object: any, path: any, updater: any): any; + + static updateWith(object: any, path: any, updater: any, customizer: any): any; + + static upperCase(string: any): any; + + static upperFirst(string: any): any; + + static values(object: any): any; + + static valuesIn(object: any): any; + + static without(...args: any[]): any; + + static words(string: any, pattern: any, guard: any): any; + + static wrap(value: any, wrapper: any): any; + + static xor(...args: any[]): any; + + static xorBy(...args: any[]): any; + + static xorWith(...args: any[]): any; + + static zip(...args: any[]): any; + + static zipObject(props: any, values: any): any; + + static zipObjectDeep(props: any, values: any): any; + + static zipWith(...args: any[]): any; + } + + export = lodash; +} +`; diff --git a/src/modules/flow/components/nodes/code/editor/declares/moment.ts b/src/modules/flow/components/nodes/code/editor/declares/moment.ts new file mode 100644 index 0000000..a936751 --- /dev/null +++ b/src/modules/flow/components/nodes/code/editor/declares/moment.ts @@ -0,0 +1,927 @@ +export const moment = ` +declare module "moment" { + /** + * @param strict Strict parsing disables the deprecated fallback to the native Date constructor when + * parsing a string. + */ + function moment(inp?: Moment.MomentInput, strict?: boolean): Moment.Moment; + /** + * @param strict Strict parsing requires that the format and input match exactly, including delimiters. + * Strict parsing is frequently the best parsing option. For more information about choosing strict vs + * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/). + */ + function moment( + inp?: Moment.MomentInput, + format?: Moment.MomentFormatSpecification, + strict?: boolean + ): Moment.Moment; + /** + * @param strict Strict parsing requires that the format and input match exactly, including delimiters. + * Strict parsing is frequently the best parsing option. For more information about choosing strict vs + * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/). + */ + function moment( + inp?: Moment.MomentInput, + format?: Moment.MomentFormatSpecification, + language?: string, + strict?: boolean + ): Moment.Moment; + + namespace Moment { + type RelativeTimeKey = + | "s" + | "ss" + | "m" + | "mm" + | "h" + | "hh" + | "d" + | "dd" + | "w" + | "ww" + | "M" + | "MM" + | "y" + | "yy"; + type CalendarKey = + | "sameDay" + | "nextDay" + | "lastDay" + | "nextWeek" + | "lastWeek" + | "sameElse" + | string; + type LongDateFormatKey = + | "LTS" + | "LT" + | "L" + | "LL" + | "LLL" + | "LLLL" + | "lts" + | "lt" + | "l" + | "ll" + | "lll" + | "llll"; + + interface Locale { + calendar(key?: CalendarKey, m?: Moment, now?: Moment): string; + + longDateFormat(key: LongDateFormatKey): string; + invalidDate(): string; + ordinal(n: number): string; + + preparse(inp: string): string; + postformat(inp: string): string; + relativeTime( + n: number, + withoutSuffix: boolean, + key: RelativeTimeKey, + isFuture: boolean + ): string; + pastFuture(diff: number, absRelTime: string): string; + set(config: Object): void; + + months(): string[]; + months(m: Moment, format?: string): string; + monthsShort(): string[]; + monthsShort(m: Moment, format?: string): string; + monthsParse(monthName: string, format: string, strict: boolean): number; + monthsRegex(strict: boolean): RegExp; + monthsShortRegex(strict: boolean): RegExp; + + week(m: Moment): number; + firstDayOfYear(): number; + firstDayOfWeek(): number; + + weekdays(): string[]; + weekdays(m: Moment, format?: string): string; + weekdaysMin(): string[]; + weekdaysMin(m: Moment): string; + weekdaysShort(): string[]; + weekdaysShort(m: Moment): string; + weekdaysParse(weekdayName: string, format: string, strict: boolean): number; + weekdaysRegex(strict: boolean): RegExp; + weekdaysShortRegex(strict: boolean): RegExp; + weekdaysMinRegex(strict: boolean): RegExp; + + isPM(input: string): boolean; + meridiem(hour: number, minute: number, isLower: boolean): string; + } + + interface StandaloneFormatSpec { + format: string[]; + standalone: string[]; + isFormat?: RegExp; + } + + interface WeekSpec { + dow: number; + doy?: number; + } + + type CalendarSpecVal = string | ((m?: MomentInput, now?: Moment) => string); + interface CalendarSpec { + sameDay?: CalendarSpecVal; + nextDay?: CalendarSpecVal; + lastDay?: CalendarSpecVal; + nextWeek?: CalendarSpecVal; + lastWeek?: CalendarSpecVal; + sameElse?: CalendarSpecVal; + + // any additional properties might be used with moment.calendarFormat + [x: string]: CalendarSpecVal | void; // undefined + } + + type RelativeTimeSpecVal = + | string + | (( + n: number, + withoutSuffix: boolean, + key: RelativeTimeKey, + isFuture: boolean + ) => string); + type RelativeTimeFuturePastVal = string | ((relTime: string) => string); + + interface RelativeTimeSpec { + future?: RelativeTimeFuturePastVal; + past?: RelativeTimeFuturePastVal; + s?: RelativeTimeSpecVal; + ss?: RelativeTimeSpecVal; + m?: RelativeTimeSpecVal; + mm?: RelativeTimeSpecVal; + h?: RelativeTimeSpecVal; + hh?: RelativeTimeSpecVal; + d?: RelativeTimeSpecVal; + dd?: RelativeTimeSpecVal; + w?: RelativeTimeSpecVal; + ww?: RelativeTimeSpecVal; + M?: RelativeTimeSpecVal; + MM?: RelativeTimeSpecVal; + y?: RelativeTimeSpecVal; + yy?: RelativeTimeSpecVal; + } + + interface LongDateFormatSpec { + LTS: string; + LT: string; + L: string; + LL: string; + LLL: string; + LLLL: string; + + // lets forget for a sec that any upper/lower permutation will also work + lts?: string; + lt?: string; + l?: string; + ll?: string; + lll?: string; + llll?: string; + } + + type MonthWeekdayFn = (momentToFormat: Moment, format?: string) => string; + type WeekdaySimpleFn = (momentToFormat: Moment) => string; + interface EraSpec { + since: string | number; + until: string | number; + offset: number; + name: string; + narrow: string; + abbr: string; + } + + interface LocaleSpecification { + months?: string[] | StandaloneFormatSpec | MonthWeekdayFn; + monthsShort?: string[] | StandaloneFormatSpec | MonthWeekdayFn; + + weekdays?: string[] | StandaloneFormatSpec | MonthWeekdayFn; + weekdaysShort?: string[] | StandaloneFormatSpec | WeekdaySimpleFn; + weekdaysMin?: string[] | StandaloneFormatSpec | WeekdaySimpleFn; + + meridiemParse?: RegExp; + meridiem?: (hour: number, minute: number, isLower: boolean) => string; + + isPM?: (input: string) => boolean; + + longDateFormat?: LongDateFormatSpec; + calendar?: CalendarSpec; + relativeTime?: RelativeTimeSpec; + invalidDate?: string; + ordinal?: (n: number) => string; + ordinalParse?: RegExp; + + week?: WeekSpec; + eras?: EraSpec[]; + + // Allow anything: in general any property that is passed as locale spec is + // put in the locale object so it can be used by locale functions + [x: string]: any; + } + + interface MomentObjectOutput { + years: number; + /* One digit */ + months: number; + /* Day of the month */ + date: number; + hours: number; + minutes: number; + seconds: number; + milliseconds: number; + } + + interface argThresholdOpts { + ss?: number; + s?: number; + m?: number; + h?: number; + d?: number; + w?: number | void; + M?: number; + } + + interface Duration { + clone(): Duration; + + humanize(argWithSuffix?: boolean, argThresholds?: argThresholdOpts): string; + + humanize(argThresholds?: argThresholdOpts): string; + + abs(): Duration; + + as(units: unitOfTime.Base): number; + get(units: unitOfTime.Base): number; + + milliseconds(): number; + asMilliseconds(): number; + + seconds(): number; + asSeconds(): number; + + minutes(): number; + asMinutes(): number; + + hours(): number; + asHours(): number; + + days(): number; + asDays(): number; + + weeks(): number; + asWeeks(): number; + + months(): number; + asMonths(): number; + + years(): number; + asYears(): number; + + add(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration; + subtract(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration; + + locale(): string; + locale(locale: LocaleSpecifier): Duration; + localeData(): Locale; + + toISOString(): string; + toJSON(): string; + + isValid(): boolean; + + /** + * @deprecated since version 2.8.0 + */ + lang(locale: LocaleSpecifier): Moment; + /** + * @deprecated since version 2.8.0 + */ + lang(): Locale; + /** + * @deprecated + */ + toIsoString(): string; + } + + interface MomentRelativeTime { + future: any; + past: any; + s: any; + ss: any; + m: any; + mm: any; + h: any; + hh: any; + d: any; + dd: any; + M: any; + MM: any; + y: any; + yy: any; + } + + interface MomentLongDateFormat { + L: string; + LL: string; + LLL: string; + LLLL: string; + LT: string; + LTS: string; + + l?: string; + ll?: string; + lll?: string; + llll?: string; + lt?: string; + lts?: string; + } + + interface MomentParsingFlags { + empty: boolean; + unusedTokens: string[]; + unusedInput: string[]; + overflow: number; + charsLeftOver: number; + nullInput: boolean; + invalidMonth: string | void; // null + invalidFormat: boolean; + userInvalidated: boolean; + iso: boolean; + parsedDateParts: any[]; + meridiem: string | void; // null + } + + interface MomentParsingFlagsOpt { + empty?: boolean; + unusedTokens?: string[]; + unusedInput?: string[]; + overflow?: number; + charsLeftOver?: number; + nullInput?: boolean; + invalidMonth?: string; + invalidFormat?: boolean; + userInvalidated?: boolean; + iso?: boolean; + parsedDateParts?: any[]; + meridiem?: string; + } + + interface MomentBuiltinFormat { + __momentBuiltinFormatBrand: any; + } + + type MomentFormatSpecification = + | string + | MomentBuiltinFormat + | (string | MomentBuiltinFormat)[]; + + export namespace unitOfTime { + type Base = + | "year" + | "years" + | "y" + | "month" + | "months" + | "M" + | "week" + | "weeks" + | "w" + | "day" + | "days" + | "d" + | "hour" + | "hours" + | "h" + | "minute" + | "minutes" + | "m" + | "second" + | "seconds" + | "s" + | "millisecond" + | "milliseconds" + | "ms"; + + type _quarter = "quarter" | "quarters" | "Q"; + type _isoWeek = "isoWeek" | "isoWeeks" | "W"; + type _date = "date" | "dates" | "D"; + type DurationConstructor = Base | _quarter | _isoWeek; + + export type DurationAs = Base; + + export type StartOf = Base | _quarter | _isoWeek | _date | void; // null + + export type Diff = Base | _quarter; + + export type MomentConstructor = Base | _date; + + export type All = + | Base + | _quarter + | _isoWeek + | _date + | "weekYear" + | "weekYears" + | "gg" + | "isoWeekYear" + | "isoWeekYears" + | "GG" + | "dayOfYear" + | "dayOfYears" + | "DDD" + | "weekday" + | "weekdays" + | "e" + | "isoWeekday" + | "isoWeekdays" + | "E"; + } + + type numberlike = number | string; + interface MomentInputObject { + years?: numberlike; + year?: numberlike; + y?: numberlike; + + months?: numberlike; + month?: numberlike; + M?: numberlike; + + days?: numberlike; + day?: numberlike; + d?: numberlike; + + dates?: numberlike; + date?: numberlike; + D?: numberlike; + + hours?: numberlike; + hour?: numberlike; + h?: numberlike; + + minutes?: numberlike; + minute?: numberlike; + m?: numberlike; + + seconds?: numberlike; + second?: numberlike; + s?: numberlike; + + milliseconds?: numberlike; + millisecond?: numberlike; + ms?: numberlike; + } + + interface DurationInputObject extends MomentInputObject { + quarters?: numberlike; + quarter?: numberlike; + Q?: numberlike; + + weeks?: numberlike; + week?: numberlike; + w?: numberlike; + } + + interface MomentSetObject extends MomentInputObject { + weekYears?: numberlike; + weekYear?: numberlike; + gg?: numberlike; + + isoWeekYears?: numberlike; + isoWeekYear?: numberlike; + GG?: numberlike; + + quarters?: numberlike; + quarter?: numberlike; + Q?: numberlike; + + weeks?: numberlike; + week?: numberlike; + w?: numberlike; + + isoWeeks?: numberlike; + isoWeek?: numberlike; + W?: numberlike; + + dayOfYears?: numberlike; + dayOfYear?: numberlike; + DDD?: numberlike; + + weekdays?: numberlike; + weekday?: numberlike; + e?: numberlike; + + isoWeekdays?: numberlike; + isoWeekday?: numberlike; + E?: numberlike; + } + + interface FromTo { + from: MomentInput; + to: MomentInput; + } + + type MomentInput = + | Moment + | Date + | string + | number + | (number | string)[] + | MomentInputObject + | void; // null | undefined + type DurationInputArg1 = Duration | number | string | FromTo | DurationInputObject | void; // null | undefined + type DurationInputArg2 = unitOfTime.DurationConstructor; + type LocaleSpecifier = string | Moment | Duration | string[] | boolean; + + interface MomentCreationData { + input: MomentInput; + format?: MomentFormatSpecification; + locale: Locale; + isUTC: boolean; + strict?: boolean; + } + + interface Moment extends Object { + format(format?: string): string; + + startOf(unitOfTime: unitOfTime.StartOf): Moment; + endOf(unitOfTime: unitOfTime.StartOf): Moment; + + add(amount?: DurationInputArg1, unit?: DurationInputArg2): Moment; + /** + * @deprecated reverse syntax + */ + add(unit: unitOfTime.DurationConstructor, amount: number | string): Moment; + + subtract(amount?: DurationInputArg1, unit?: DurationInputArg2): Moment; + /** + * @deprecated reverse syntax + */ + subtract(unit: unitOfTime.DurationConstructor, amount: number | string): Moment; + + calendar(): string; + calendar(formats: CalendarSpec): string; + calendar(time: MomentInput, formats?: CalendarSpec): string; + + clone(): Moment; + + /** + * @return Unix timestamp in milliseconds + */ + valueOf(): number; + + // current date/time in local mode + local(keepLocalTime?: boolean): Moment; + isLocal(): boolean; + + // current date/time in UTC mode + utc(keepLocalTime?: boolean): Moment; + isUTC(): boolean; + /** + * @deprecated use isUTC + */ + isUtc(): boolean; + + parseZone(): Moment; + isValid(): boolean; + invalidAt(): number; + + hasAlignedHourOffset(other?: MomentInput): boolean; + + creationData(): MomentCreationData; + parsingFlags(): MomentParsingFlags; + + year(y: number): Moment; + year(): number; + /** + * @deprecated use year(y) + */ + years(y: number): Moment; + /** + * @deprecated use year() + */ + years(): number; + quarter(): number; + quarter(q: number): Moment; + quarters(): number; + quarters(q: number): Moment; + month(M: number | string): Moment; + month(): number; + /** + * @deprecated use month(M) + */ + months(M: number | string): Moment; + /** + * @deprecated use month() + */ + months(): number; + day(d: number | string): Moment; + day(): number; + days(d: number | string): Moment; + days(): number; + date(d: number): Moment; + date(): number; + /** + * @deprecated use date(d) + */ + dates(d: number): Moment; + /** + * @deprecated use date() + */ + dates(): number; + hour(h: number): Moment; + hour(): number; + hours(h: number): Moment; + hours(): number; + minute(m: number): Moment; + minute(): number; + minutes(m: number): Moment; + minutes(): number; + second(s: number): Moment; + second(): number; + seconds(s: number): Moment; + seconds(): number; + millisecond(ms: number): Moment; + millisecond(): number; + milliseconds(ms: number): Moment; + milliseconds(): number; + weekday(): number; + weekday(d: number): Moment; + isoWeekday(): number; + isoWeekday(d: number | string): Moment; + weekYear(): number; + weekYear(d: number): Moment; + isoWeekYear(): number; + isoWeekYear(d: number): Moment; + week(): number; + week(d: number): Moment; + weeks(): number; + weeks(d: number): Moment; + isoWeek(): number; + isoWeek(d: number): Moment; + isoWeeks(): number; + isoWeeks(d: number): Moment; + weeksInYear(): number; + weeksInWeekYear(): number; + isoWeeksInYear(): number; + isoWeeksInISOWeekYear(): number; + dayOfYear(): number; + dayOfYear(d: number): Moment; + + from(inp: MomentInput, suffix?: boolean): string; + to(inp: MomentInput, suffix?: boolean): string; + fromNow(withoutSuffix?: boolean): string; + toNow(withoutPrefix?: boolean): string; + + diff(b: MomentInput, unitOfTime?: unitOfTime.Diff, precise?: boolean): number; + + toArray(): number[]; + toDate(): Date; + toISOString(keepOffset?: boolean): string; + inspect(): string; + toJSON(): string; + unix(): number; + + isLeapYear(): boolean; + /** + * @deprecated in favor of utcOffset + */ + zone(): number; + zone(b: number | string): Moment; + utcOffset(): number; + utcOffset(b: number | string, keepLocalTime?: boolean): Moment; + isUtcOffset(): boolean; + daysInMonth(): number; + isDST(): boolean; + + zoneAbbr(): string; + zoneName(): string; + + isBefore(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean; + isAfter(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean; + isSame(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean; + isSameOrAfter(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean; + isSameOrBefore(inp?: MomentInput, granularity?: unitOfTime.StartOf): boolean; + isBetween( + a: MomentInput, + b: MomentInput, + granularity?: unitOfTime.StartOf, + inclusivity?: "()" | "[)" | "(]" | "[]" + ): boolean; + + /** + * @deprecated as of 2.8.0, use locale + */ + lang(language: LocaleSpecifier): Moment; + /** + * @deprecated as of 2.8.0, use locale + */ + lang(): Locale; + + locale(): string; + locale(locale: LocaleSpecifier): Moment; + + localeData(): Locale; + + /** + * @deprecated no reliable implementation + */ + isDSTShifted(): boolean; + + // NOTE(constructor): Same as moment constructor + /** + * @deprecated as of 2.7.0, use moment.min/max + */ + max(inp?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment; + /** + * @deprecated as of 2.7.0, use moment.min/max + */ + max( + inp?: MomentInput, + format?: MomentFormatSpecification, + language?: string, + strict?: boolean + ): Moment; + + // NOTE(constructor): Same as moment constructor + /** + * @deprecated as of 2.7.0, use moment.min/max + */ + min(inp?: MomentInput, format?: MomentFormatSpecification, strict?: boolean): Moment; + /** + * @deprecated as of 2.7.0, use moment.min/max + */ + min( + inp?: MomentInput, + format?: MomentFormatSpecification, + language?: string, + strict?: boolean + ): Moment; + + get(unit: unitOfTime.All): number; + set(unit: unitOfTime.All, value: number): Moment; + set(objectLiteral: MomentSetObject): Moment; + + toObject(): MomentObjectOutput; + } + + export let version: string; + export let fn: Moment; + + // NOTE(constructor): Same as moment constructor + /** + * @param strict Strict parsing disables the deprecated fallback to the native Date constructor when + * parsing a string. + */ + export function utc(inp?: MomentInput, strict?: boolean): Moment; + /** + * @param strict Strict parsing requires that the format and input match exactly, including delimiters. + * Strict parsing is frequently the best parsing option. For more information about choosing strict vs + * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/). + */ + export function utc( + inp?: MomentInput, + format?: MomentFormatSpecification, + strict?: boolean + ): Moment; + /** + * @param strict Strict parsing requires that the format and input match exactly, including delimiters. + * Strict parsing is frequently the best parsing option. For more information about choosing strict vs + * forgiving parsing, see the [parsing guide](https://momentjs.com/guides/#/parsing/). + */ + export function utc( + inp?: MomentInput, + format?: MomentFormatSpecification, + language?: string, + strict?: boolean + ): Moment; + + export function unix(timestamp: number): Moment; + + export function invalid(flags?: MomentParsingFlagsOpt): Moment; + export function isMoment(m: any): m is Moment; + export function isDate(m: any): m is Date; + export function isDuration(d: any): d is Duration; + + /** + * @deprecated in 2.8.0 + */ + export function lang(language?: string): string; + /** + * @deprecated in 2.8.0 + */ + export function lang(language?: string, definition?: Locale): string; + + export function locale(language?: string): string; + export function locale(language?: string[]): string; + export function locale(language?: string, definition?: LocaleSpecification | void): string; // null | undefined + + export function localeData(key?: string | string[]): Locale; + + export function duration(inp?: DurationInputArg1, unit?: DurationInputArg2): Duration; + + // NOTE(constructor): Same as moment constructor + export function parseZone( + inp?: MomentInput, + format?: MomentFormatSpecification, + strict?: boolean + ): Moment; + export function parseZone( + inp?: MomentInput, + format?: MomentFormatSpecification, + language?: string, + strict?: boolean + ): Moment; + + export function months(): string[]; + export function months(index: number): string; + export function months(format: string): string[]; + export function months(format: string, index: number): string; + export function monthsShort(): string[]; + export function monthsShort(index: number): string; + export function monthsShort(format: string): string[]; + export function monthsShort(format: string, index: number): string; + + export function weekdays(): string[]; + export function weekdays(index: number): string; + export function weekdays(format: string): string[]; + export function weekdays(format: string, index: number): string; + export function weekdays(localeSorted: boolean): string[]; + export function weekdays(localeSorted: boolean, index: number): string; + export function weekdays(localeSorted: boolean, format: string): string[]; + export function weekdays(localeSorted: boolean, format: string, index: number): string; + export function weekdaysShort(): string[]; + export function weekdaysShort(index: number): string; + export function weekdaysShort(format: string): string[]; + export function weekdaysShort(format: string, index: number): string; + export function weekdaysShort(localeSorted: boolean): string[]; + export function weekdaysShort(localeSorted: boolean, index: number): string; + export function weekdaysShort(localeSorted: boolean, format: string): string[]; + export function weekdaysShort(localeSorted: boolean, format: string, index: number): string; + export function weekdaysMin(): string[]; + export function weekdaysMin(index: number): string; + export function weekdaysMin(format: string): string[]; + export function weekdaysMin(format: string, index: number): string; + export function weekdaysMin(localeSorted: boolean): string[]; + export function weekdaysMin(localeSorted: boolean, index: number): string; + export function weekdaysMin(localeSorted: boolean, format: string): string[]; + export function weekdaysMin(localeSorted: boolean, format: string, index: number): string; + + export function min(moments: Moment[]): Moment; + export function min(...moments: Moment[]): Moment; + export function max(moments: Moment[]): Moment; + export function max(...moments: Moment[]): Moment; + + /** + * Returns unix time in milliseconds. Overwrite for profit. + */ + export function now(): number; + + export function defineLocale( + language: string, + localeSpec: LocaleSpecification | void + ): Locale; // null + export function updateLocale( + language: string, + localeSpec: LocaleSpecification | void + ): Locale; // null + + export function locales(): string[]; + + export function normalizeUnits(unit: unitOfTime.All): string; + export function relativeTimeThreshold(threshold: string): number | boolean; + export function relativeTimeThreshold(threshold: string, limit: number): boolean; + export function relativeTimeRounding(fn: (num: number) => number): boolean; + export function relativeTimeRounding(): (num: number) => number; + export function calendarFormat(m: Moment, now: Moment): string; + + export function parseTwoDigitYear(input: string): number; + + /** + * Constant used to enable explicit ISO_8601 format parsing. + */ + export let ISO_8601: MomentBuiltinFormat; + export let RFC_2822: MomentBuiltinFormat; + + export let defaultFormat: string; + export let defaultFormatUtc: string; + export let suppressDeprecationWarnings: boolean; + export let deprecationHandler: ((name: string | void, msg: string) => void) | void; + + export let HTML5_FMT: { + DATETIME_LOCAL: string; + DATETIME_LOCAL_SECONDS: string; + DATETIME_LOCAL_MS: string; + DATE: string; + TIME: string; + TIME_SECONDS: string; + TIME_MS: string; + WEEK: string; + MONTH: string; + }; + } + + export = moment; +} + +`; diff --git a/src/modules/flow/components/nodes/code/editor/index.vue b/src/modules/flow/components/nodes/code/editor/index.vue new file mode 100644 index 0000000..e1bc086 --- /dev/null +++ b/src/modules/flow/components/nodes/code/editor/index.vue @@ -0,0 +1,138 @@ + + + + + diff --git a/src/modules/flow/components/nodes/code/index.ts b/src/modules/flow/components/nodes/code/index.ts new file mode 100644 index 0000000..9a08d41 --- /dev/null +++ b/src/modules/flow/components/nodes/code/index.ts @@ -0,0 +1,65 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormInputParams from "../_base/form/input-params.vue"; +import FormOutputParams from "../_base/form/output-params.vue"; +import Editor from "./editor/index.vue"; +import { Snippet } from "./shippets"; + +export default (): FlowNode => { + return { + group: "行为", + label: "执行代码", + description: "执行一段自定义代码,可以调用框架的插件、数据库、service等", + color: "#67c23a", + component, + form: { + width: "500px", + items: [ + { + label: "输入变量", + prop: "inputParams", + component: { + vm: FormInputParams + } + }, + { + label: "代码编辑", + prop: "options.code", + component: { + vm: Editor + } + }, + { + label: "输出变量", + prop: "outputParams", + component: { + vm: FormOutputParams + } + } + ] + }, + data: { + inputParams: [ + { + field: "arg1" + } + ], + outputParams: [ + { + field: "result", + type: "string" + } + ], + options: { + code: Snippet.base + } + }, + validator(data) { + // 验证变量是否绑定值 + const param = data.inputParams?.find((e) => !e.nodeId); + if (param) { + return `请绑定变量:${param.field}`; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/code/index.vue b/src/modules/flow/components/nodes/code/index.vue new file mode 100644 index 0000000..9b20e02 --- /dev/null +++ b/src/modules/flow/components/nodes/code/index.vue @@ -0,0 +1,20 @@ + + + diff --git a/src/modules/flow/components/nodes/code/shippets/index.ts b/src/modules/flow/components/nodes/code/shippets/index.ts new file mode 100644 index 0000000..9014707 --- /dev/null +++ b/src/modules/flow/components/nodes/code/shippets/index.ts @@ -0,0 +1,48 @@ +import { ctx } from "virtual:ctx"; + +const Java = { + base: `import java.util.Map; +/** + * 代码执行 + */ +public class DynamicClass { + /** + * 主函数 + */ + public Map main(Map params) { + System.out.println("Cool main " + params); + return params; + } +}` +}; + +const Node = { + base: `import axios from 'axios'; +import * as _ from 'lodash'; +import * as moment from 'moment'; + +/** + * 代码执行 + */ +export class Cool extends Base { + /** + * 主函数 + */ + async main(params: Params): Promise { + console.log('Cool main', params); + return { + result: "" + }; + } +}`, + simple: `async function main(params: Params): Promise { + return params; +}` +}; + +export const Snippets = { + Java, + Node +}; + +export const Snippet = Snippets[ctx.serviceLang]; diff --git a/src/modules/flow/components/nodes/end/index.ts b/src/modules/flow/components/nodes/end/index.ts new file mode 100644 index 0000000..41655be --- /dev/null +++ b/src/modules/flow/components/nodes/end/index.ts @@ -0,0 +1,44 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormInputParams from "../_base/form/input-params.vue"; + +export default (): FlowNode => { + return { + group: "逻辑", + label: "结束", + description: "结束节点", + color: "#f56c6c", + component, + form: { + items: [ + { + label: "输出变量", + prop: "outputParams", + component: { + vm: FormInputParams, + props: { + field: "res" + } + } + } + ] + }, + data: { + outputParams: [ + { + field: "res" + } + ] + }, + handle: { + source: false + }, + validator(data) { + // 验证变量是否绑定值 + const param = data.outputParams?.find((e) => !e.nodeId); + if (param) { + return `请绑定变量到${param.field}`; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/end/index.vue b/src/modules/flow/components/nodes/end/index.vue new file mode 100644 index 0000000..fddc9b6 --- /dev/null +++ b/src/modules/flow/components/nodes/end/index.vue @@ -0,0 +1,3 @@ + diff --git a/src/modules/flow/components/nodes/flow/form/info.vue b/src/modules/flow/components/nodes/flow/form/info.vue new file mode 100644 index 0000000..4be08ac --- /dev/null +++ b/src/modules/flow/components/nodes/flow/form/info.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/src/modules/flow/components/nodes/flow/form/select.vue b/src/modules/flow/components/nodes/flow/form/select.vue new file mode 100644 index 0000000..f853f1b --- /dev/null +++ b/src/modules/flow/components/nodes/flow/form/select.vue @@ -0,0 +1,234 @@ + + + + + diff --git a/src/modules/flow/components/nodes/flow/index.ts b/src/modules/flow/components/nodes/flow/index.ts new file mode 100644 index 0000000..04df526 --- /dev/null +++ b/src/modules/flow/components/nodes/flow/index.ts @@ -0,0 +1,64 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormInputParams from "../_base/form/input-params.vue"; +import FormOutputParams from "../_base/form/output-params.vue"; +import FormSelect from "./form/select.vue"; + +export default (): FlowNode => { + return { + group: "扩展", + label: "流程", + description: "执行其他流程", + color: "#fd9d2f", + component, + form: { + items: [ + { + label: "输入变量", + prop: "inputParams", + component: { + vm: FormInputParams, + props: { + disabled: true, + editField: false, + placeholder: "请先选择流程" + } + } + }, + { + label: "选择流程", + prop: "options.flowId", + component: { + vm: FormSelect + } + }, + { + label: "输出变量", + prop: "outputParams", + component: { + vm: FormOutputParams + } + } + ] + }, + data: { + options: {}, + inputParams: [], + outputParams: [ + { + field: "res1", + type: "string" + } + ] + }, + validator(data) { + // 验证if条件是否设置 + const param = data.options.IF?.find( + (e: JudgeItem) => !e.nodeId || !e.condition || !e.value + ); + if (param) { + return "条件判断格式异常"; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/flow/index.vue b/src/modules/flow/components/nodes/flow/index.vue new file mode 100644 index 0000000..098d851 --- /dev/null +++ b/src/modules/flow/components/nodes/flow/index.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/src/modules/flow/components/nodes/index.ts b/src/modules/flow/components/nodes/index.ts new file mode 100644 index 0000000..30feac6 --- /dev/null +++ b/src/modules/flow/components/nodes/index.ts @@ -0,0 +1,32 @@ +import type { FlowNode } from "../../types"; +import { shallowRef } from "vue"; + +const files: { [key: string]: { default: () => FlowNode } } = import.meta.glob( + "./*/index.{ts,tsx}", + { + eager: true + } +); + +const CustomNodes = shallowRef([]); + +for (const i in files) { + const [, type] = i.split("/"); + + const d = files[i].default(); + + if (d.enable !== false) { + const configWidth = d.form?.width || '400px'; + const width = `${parseFloat(configWidth) + 30}px` + + CustomNodes.value.push({ + ...d, + type, + name: `node-${type}`, + icon: type, + cardWidth: width + }); + } +} + +export { CustomNodes }; diff --git a/src/modules/flow/components/nodes/judge/form/if.vue b/src/modules/flow/components/nodes/judge/form/if.vue new file mode 100644 index 0000000..87a6885 --- /dev/null +++ b/src/modules/flow/components/nodes/judge/form/if.vue @@ -0,0 +1,188 @@ + + + + + diff --git a/src/modules/flow/components/nodes/judge/index.ts b/src/modules/flow/components/nodes/judge/index.ts new file mode 100644 index 0000000..509a253 --- /dev/null +++ b/src/modules/flow/components/nodes/judge/index.ts @@ -0,0 +1,74 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormIf from "./form/if.vue"; +import { h, resolveComponent, toRaw } from "vue"; + +export default (): FlowNode => { + return { + group: "逻辑", + label: "条件判断", + description: "条件判断节点", + color: "#f56c6c", + component, + form: { + items: [ + { + label: "满足", + prop: "options.IF", + component: { + vm: FormIf + } + }, + { + label: "不满足", + component: () => { + return h( + toRaw(resolveComponent("el-text")), + { + type: "info", + size: "small" + }, + () => { + return "用于定义当条件不满足时应执行的逻辑。"; + } + ); + } + } + ] + }, + data: { + options: { + IF: [{}] as JudgeItem[], + ELSE: [] as JudgeItem[] + }, + outputParams: [ + { + type: "boolean", + field: "result" + } + ] + }, + handle: { + source: false, + next: [ + { + label: "满足", + value: "source-if" + }, + { + label: "不满足", + value: "source-else" + } + ] + }, + validator(data) { + // 验证if条件是否设置 + const param = data.options.IF?.find( + (e: JudgeItem) => !e.nodeId || !e.condition || !e.value + ); + if (param) { + return "条件判断格式异常"; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/judge/index.vue b/src/modules/flow/components/nodes/judge/index.vue new file mode 100644 index 0000000..3f1f258 --- /dev/null +++ b/src/modules/flow/components/nodes/judge/index.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/src/modules/flow/components/nodes/judge/types.d.ts b/src/modules/flow/components/nodes/judge/types.d.ts new file mode 100644 index 0000000..3f506b3 --- /dev/null +++ b/src/modules/flow/components/nodes/judge/types.d.ts @@ -0,0 +1,8 @@ +declare interface JudgeItem { + nodeType?: string; + nodeId?: string; + field: string; + condition: string; + value?: string; + operator: string; +} diff --git a/src/modules/flow/components/nodes/know/form/list.vue b/src/modules/flow/components/nodes/know/form/list.vue new file mode 100644 index 0000000..a5544cc --- /dev/null +++ b/src/modules/flow/components/nodes/know/form/list.vue @@ -0,0 +1,112 @@ + + + + + diff --git a/src/modules/flow/components/nodes/know/form/select.vue b/src/modules/flow/components/nodes/know/form/select.vue new file mode 100644 index 0000000..e4b0936 --- /dev/null +++ b/src/modules/flow/components/nodes/know/form/select.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/src/modules/flow/components/nodes/know/index.ts b/src/modules/flow/components/nodes/know/index.ts new file mode 100644 index 0000000..4759dc5 --- /dev/null +++ b/src/modules/flow/components/nodes/know/index.ts @@ -0,0 +1,92 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormInputParams from "../_base/form/input-params.vue"; +import FormSelect from "./form/select.vue"; +import FormText from "../_base/form/text.vue"; +import { isEmpty } from "lodash-es"; + +export default (): FlowNode => { + return { + group: "信息", + label: "知识库", + description: "从知识库中检索出相关的内容", + component, + form: { + items: [ + { + label: "输入变量", + prop: "inputParams", + component: { + vm: FormInputParams, + props: { + editField: false, + disabled: true + } + } + }, + { + label: "选择知识库", + prop: "options.knowIds", + component: { + vm: FormSelect + } + }, + { + label: "结果条数", + prop: "options.size", + component: { + name: "el-input-number", + props: { + min: 1, + max: 100 + } + } + }, + { + label: "输出变量", + component: { + vm: FormText, + props: { + text: ["documents 文档列表", "text 文档内容"] + } + } + } + ] + }, + data: { + inputParams: [ + { + field: "text" + } + ], + outputParams: [ + { + field: "documents", + type: "object[]" + }, + { + field: "text", + type: "string" + } + ], + options: { + knowIds: [], + size: 3 + } + }, + validator(data) { + const { knowIds } = data.options; + + // 验证变量是否绑定值 + const param = data.inputParams?.find((e) => !e.nodeId); + if (param) { + return `请绑定变量:${param.field}`; + } + + // 验证知识库是否选择 + if (isEmpty(knowIds)) { + return "请选择知识库"; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/know/index.vue b/src/modules/flow/components/nodes/know/index.vue new file mode 100644 index 0000000..54b34b2 --- /dev/null +++ b/src/modules/flow/components/nodes/know/index.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/modules/flow/components/nodes/llm/form/message.vue b/src/modules/flow/components/nodes/llm/form/message.vue new file mode 100644 index 0000000..8166b68 --- /dev/null +++ b/src/modules/flow/components/nodes/llm/form/message.vue @@ -0,0 +1,376 @@ + + + + + diff --git a/src/modules/flow/components/nodes/llm/form/model-text.vue b/src/modules/flow/components/nodes/llm/form/model-text.vue new file mode 100644 index 0000000..7544c5c --- /dev/null +++ b/src/modules/flow/components/nodes/llm/form/model-text.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/src/modules/flow/components/nodes/llm/form/model.vue b/src/modules/flow/components/nodes/llm/form/model.vue new file mode 100644 index 0000000..f9af9e8 --- /dev/null +++ b/src/modules/flow/components/nodes/llm/form/model.vue @@ -0,0 +1,382 @@ + + + + + diff --git a/src/modules/flow/components/nodes/llm/index.ts b/src/modules/flow/components/nodes/llm/index.ts new file mode 100644 index 0000000..c7b9465 --- /dev/null +++ b/src/modules/flow/components/nodes/llm/index.ts @@ -0,0 +1,122 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormMessage from "./form/message.vue"; +import FormModel from "./form/model.vue"; +import FormInputParams from "../_base/form/input-params.vue"; +import FormInputNumber from "../_base/form/input-number.vue"; +import FormText from "../_base/form/text.vue"; + +export default (): FlowNode => { + return { + group: "AI", + label: "LLM", + description: "调用大语言模型回答问题", + color: "#409eff", + component, + isDisableDrag: true, // 是否允许拖拽(部分组件跟拖拽事件冲突,需禁用。例:伪富文本dom) + form: { + items: [ + { + label: "输入变量", + prop: "inputParams", + component: { + vm: FormInputParams, + props: { + field: "input" + } + } + }, + { + label: "模型", + prop: "options.model", + component: { + vm: FormModel + } + }, + { + label: "消息", + prop: "options.messages", + component: { + vm: FormMessage + } + }, + { + prop: "options.history", + span: 12, + component: { + vm: FormInputNumber, + props: { + prefix: "保存", + suffix: "条历史数据" + } + } + }, + { + label: "输出变量", + component: { + vm: FormText, + props: { + text: ["text 回复内容"] + } + } + } + ] + }, + data: { + inputParams: [ + { + field: "input" + } + ], + outputParams: [ + { + type: "string", + field: "text" + }, + { + type: "stream", + field: "stream" + } + ], + options: { + model: { + options: [], + params: { + model: "" + } + }, + messages: [ + { + role: "system", + content: "" + }, + { + role: "user", + content: "" + }, + ] as LLMMessage[], + history: 0 + } + }, + validator(data) { + const { model, messages } = data.options; + + // 验证变量是否绑定值 + const param = data.inputParams?.find((e) => !e.nodeId); + if (param) { + return `请绑定变量:${param.field}`; + } + + // 验证模型是否选择 + if (!model.params.model) { + return "请选择模型"; + } + + // 验证消息是否填写 + const msg = messages.find((e: LLMMessage) => !e.content); + if (msg) { + return `请填写${msg.role}消息`; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/llm/index.vue b/src/modules/flow/components/nodes/llm/index.vue new file mode 100644 index 0000000..e63488d --- /dev/null +++ b/src/modules/flow/components/nodes/llm/index.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/src/modules/flow/components/nodes/llm/types.d.ts b/src/modules/flow/components/nodes/llm/types.d.ts new file mode 100644 index 0000000..403ab9d --- /dev/null +++ b/src/modules/flow/components/nodes/llm/types.d.ts @@ -0,0 +1,38 @@ +declare interface LLMMessage { + role: string; + content: string; + text?: string; + [key: string]: any; +} + +declare interface LLMData { + supplier: string; + options: LLMOption[]; + params: { + model: string; + [key: string]: any; + }; + configId: number; +} + +declare interface LLMItem { + id: number; + options: LLMOption[]; + title: string; + type: string; + select: string[]; +} + +declare interface LLMOption { + field: string; + value?: any; + type: "number" | "string" | "boolean"; + title: string; + default?: any; + max?: number; + min?: number; + supports?: string[]; + select?: string[]; + status?: boolean; + [key: string]: any; +} diff --git a/src/modules/flow/components/nodes/parse/index.ts b/src/modules/flow/components/nodes/parse/index.ts new file mode 100644 index 0000000..0727512 --- /dev/null +++ b/src/modules/flow/components/nodes/parse/index.ts @@ -0,0 +1,83 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormModel from "../llm/form/model.vue"; +import FormInputParams from "../_base/form/input-params.vue"; +import FormOutputParams from "../_base/form/output-params.vue"; + +export default (): FlowNode => { + return { + group: "扩展", + label: "智能解析", + description: "智能提取内容的关键信息", + color: "#fd9d2f", + component, + form: { + items: [ + { + label: "输入变量", + prop: "inputParams", + component: { + vm: FormInputParams, + props: { + editField: false, + disabled: true + } + } + }, + { + label: "模型", + prop: "options.model", + component: { + vm: FormModel + } + }, + { + label: "输出变量", + prop: "outputParams", + component: { + vm: FormOutputParams, + props: { + typeInput: true, + disabledFields: ["result"] + } + } + } + ] + }, + data: { + options: { + model: { + options: [], + params: { + model: "" + } + } + }, + inputParams: [ + { + field: "text" + } + ], + outputParams: [ + { + field: "result", + type: "输入结果" + } + ] + }, + validator(data) { + const { model } = data.options; + + // 验证变量是否绑定值 + const param = data.inputParams?.find((e) => !e.nodeId); + if (param) { + return `请绑定变量:${param.field}`; + } + + // 验证模型是否选择 + if (!model.params.model) { + return "请选择模型"; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/parse/index.vue b/src/modules/flow/components/nodes/parse/index.vue new file mode 100644 index 0000000..cf7dc46 --- /dev/null +++ b/src/modules/flow/components/nodes/parse/index.vue @@ -0,0 +1,20 @@ + + + diff --git a/src/modules/flow/components/nodes/start/form/fields.vue b/src/modules/flow/components/nodes/start/form/fields.vue new file mode 100644 index 0000000..08e4bc2 --- /dev/null +++ b/src/modules/flow/components/nodes/start/form/fields.vue @@ -0,0 +1,164 @@ + + + + + diff --git a/src/modules/flow/components/nodes/start/index.ts b/src/modules/flow/components/nodes/start/index.ts new file mode 100644 index 0000000..cad2abd --- /dev/null +++ b/src/modules/flow/components/nodes/start/index.ts @@ -0,0 +1,42 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import FormFields from "./form/fields.vue"; +import { isEmpty } from "lodash-es"; + +export default (): FlowNode => { + return { + label: "开始", + description: "开始节点", + color: "#409eff", + form: { + items: [ + { + label: "输入字段", + prop: "inputParams", + component: { + vm: FormFields + } + } + ] + }, + data: { + inputParams: [ + { + label: "内容", + field: "content", + type: "text", + required: true + } + ] + }, + handle: { + target: false + }, + component, + validator(data) { + if (isEmpty(data.inputParams)) { + return "至少要输入一个字段"; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/start/index.vue b/src/modules/flow/components/nodes/start/index.vue new file mode 100644 index 0000000..5bc8eae --- /dev/null +++ b/src/modules/flow/components/nodes/start/index.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/modules/flow/components/nodes/variable/index.ts b/src/modules/flow/components/nodes/variable/index.ts new file mode 100644 index 0000000..0611c6e --- /dev/null +++ b/src/modules/flow/components/nodes/variable/index.ts @@ -0,0 +1,71 @@ +import type { FlowNode } from "/$/flow/types"; +import component from "./index.vue"; +import { isEmpty } from "lodash-es"; +import FormInputParams from "../_base/form/input-params.vue"; +import FormOutputParams from "../_base/form/output-params.vue"; +import CodeEditor from "../code/editor/index.vue"; +import { Snippet } from "../code/shippets"; + +export default (): FlowNode => { + return { + group: "行为", + label: "变量", + description: "变量转换或赋值", + color: "#67c23a", + form: { + width: "500px", + items: [ + { + label: "输入变量", + prop: "inputParams", + component: { + vm: FormInputParams, + props: { + varInputable: true + } + } + }, + { + label: "代码编辑", + prop: "options.code", + component: { + vm: CodeEditor + } + }, + { + label: "输出变量", + prop: "outputParams", + component: { + vm: FormOutputParams + } + } + ] + }, + data: { + options: { + code: Snippet.simple || Snippet.base + }, + inputParams: [ + { + field: "arg1" + } + ], + outputParams: [ + { + field: "string" + } + ] + }, + component, + validator(data) { + if (isEmpty(data.inputParams)) { + return "至少要输入一个字段"; + } + + const param = data.inputParams?.find((e) => !e.value && !e.nodeId); + if (param) { + return `请绑定变量或填写内容:${param.field}`; + } + } + }; +}; diff --git a/src/modules/flow/components/nodes/variable/index.vue b/src/modules/flow/components/nodes/variable/index.vue new file mode 100644 index 0000000..fb2db7e --- /dev/null +++ b/src/modules/flow/components/nodes/variable/index.vue @@ -0,0 +1,15 @@ + + + diff --git a/src/modules/flow/components/tools/card.vue b/src/modules/flow/components/tools/card.vue new file mode 100644 index 0000000..44d583c --- /dev/null +++ b/src/modules/flow/components/tools/card.vue @@ -0,0 +1,509 @@ + + + + + diff --git a/src/modules/flow/components/tools/card/form.vue b/src/modules/flow/components/tools/card/form.vue new file mode 100644 index 0000000..e97fb21 --- /dev/null +++ b/src/modules/flow/components/tools/card/form.vue @@ -0,0 +1,458 @@ + + + + + diff --git a/src/modules/flow/components/tools/connection-line.vue b/src/modules/flow/components/tools/connection-line.vue new file mode 100644 index 0000000..e5c01a3 --- /dev/null +++ b/src/modules/flow/components/tools/connection-line.vue @@ -0,0 +1,41 @@ + + + diff --git a/src/modules/flow/components/tools/context-menu.vue b/src/modules/flow/components/tools/context-menu.vue new file mode 100644 index 0000000..7b23e4e --- /dev/null +++ b/src/modules/flow/components/tools/context-menu.vue @@ -0,0 +1,190 @@ + + + + + diff --git a/src/modules/flow/components/tools/controls.vue b/src/modules/flow/components/tools/controls.vue new file mode 100644 index 0000000..0e19fda --- /dev/null +++ b/src/modules/flow/components/tools/controls.vue @@ -0,0 +1,224 @@ + + + + + diff --git a/src/modules/flow/components/tools/edge-button.vue b/src/modules/flow/components/tools/edge-button.vue new file mode 100644 index 0000000..f3ba839 --- /dev/null +++ b/src/modules/flow/components/tools/edge-button.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/src/modules/flow/components/tools/fields.vue b/src/modules/flow/components/tools/fields.vue new file mode 100644 index 0000000..a5f9c05 --- /dev/null +++ b/src/modules/flow/components/tools/fields.vue @@ -0,0 +1,124 @@ + + + + + diff --git a/src/modules/flow/components/tools/handle.vue b/src/modules/flow/components/tools/handle.vue new file mode 100644 index 0000000..ae17951 --- /dev/null +++ b/src/modules/flow/components/tools/handle.vue @@ -0,0 +1,151 @@ + + + + + diff --git a/src/modules/flow/components/tools/head.vue b/src/modules/flow/components/tools/head.vue new file mode 100644 index 0000000..b54581c --- /dev/null +++ b/src/modules/flow/components/tools/head.vue @@ -0,0 +1,218 @@ + + + + + diff --git a/src/modules/flow/components/tools/history.vue b/src/modules/flow/components/tools/history.vue new file mode 100644 index 0000000..78da54d --- /dev/null +++ b/src/modules/flow/components/tools/history.vue @@ -0,0 +1,132 @@ + + + + + diff --git a/src/modules/flow/components/tools/icon.vue b/src/modules/flow/components/tools/icon.vue new file mode 100644 index 0000000..b3cc76e --- /dev/null +++ b/src/modules/flow/components/tools/icon.vue @@ -0,0 +1,41 @@ + + + + + diff --git a/src/modules/flow/components/tools/import.vue b/src/modules/flow/components/tools/import.vue new file mode 100644 index 0000000..9454851 --- /dev/null +++ b/src/modules/flow/components/tools/import.vue @@ -0,0 +1,134 @@ + + + + + diff --git a/src/modules/flow/components/tools/more.vue b/src/modules/flow/components/tools/more.vue new file mode 100644 index 0000000..d1da247 --- /dev/null +++ b/src/modules/flow/components/tools/more.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/modules/flow/components/tools/node-add.vue b/src/modules/flow/components/tools/node-add.vue new file mode 100644 index 0000000..9c09006 --- /dev/null +++ b/src/modules/flow/components/tools/node-add.vue @@ -0,0 +1,282 @@ + + + + + + + diff --git a/src/modules/flow/components/tools/node-config.vue b/src/modules/flow/components/tools/node-config.vue new file mode 100644 index 0000000..750eb96 --- /dev/null +++ b/src/modules/flow/components/tools/node-config.vue @@ -0,0 +1,358 @@ + + + + + diff --git a/src/modules/flow/components/tools/nodes.vue b/src/modules/flow/components/tools/nodes.vue new file mode 100644 index 0000000..e2d0b08 --- /dev/null +++ b/src/modules/flow/components/tools/nodes.vue @@ -0,0 +1,357 @@ + + + + + diff --git a/src/modules/flow/components/tools/panel/index.vue b/src/modules/flow/components/tools/panel/index.vue new file mode 100644 index 0000000..e589410 --- /dev/null +++ b/src/modules/flow/components/tools/panel/index.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/src/modules/flow/components/tools/panel/run.vue b/src/modules/flow/components/tools/panel/run.vue new file mode 100644 index 0000000..c4048ef --- /dev/null +++ b/src/modules/flow/components/tools/panel/run.vue @@ -0,0 +1,1055 @@ + + + + + diff --git a/src/modules/flow/components/tools/selection.vue b/src/modules/flow/components/tools/selection.vue new file mode 100644 index 0000000..48b006a --- /dev/null +++ b/src/modules/flow/components/tools/selection.vue @@ -0,0 +1,289 @@ + + + + + diff --git a/src/modules/flow/components/tools/var.vue b/src/modules/flow/components/tools/var.vue new file mode 100644 index 0000000..a0b6b41 --- /dev/null +++ b/src/modules/flow/components/tools/var.vue @@ -0,0 +1,466 @@ + + + + + diff --git a/src/modules/flow/config.ts b/src/modules/flow/config.ts new file mode 100644 index 0000000..2144c4d --- /dev/null +++ b/src/modules/flow/config.ts @@ -0,0 +1,6 @@ +import { ModuleConfig } from "/@/cool"; +import "./static/index.scss"; + +export default (): ModuleConfig => { + return {}; +}; diff --git a/src/modules/flow/hooks/flow.ts b/src/modules/flow/hooks/flow.ts new file mode 100644 index 0000000..7022059 --- /dev/null +++ b/src/modules/flow/hooks/flow.ts @@ -0,0 +1,917 @@ +import { defineStore } from "pinia"; +import { computed, ref } from "vue"; +import { sleep } from "/@/cool/utils"; +import { Connection, useVueFlow } from "@vue-flow/core"; +import { CustomNodes } from "../components/nodes"; +import { + assign, + cloneDeep, + debounce, + groupBy, + isArray, + isEmpty, + keys, + last, + orderBy +} from "lodash-es"; +import type { FlowEdge, FlowField, FlowNode } from "../types"; +import { router, service, useCool } from "/@/cool"; +import { ElMessage, ElMessageBox } from "element-plus"; + +const offset = { + x: 400, + y_t: -10, + y_b: 50, + g: 150 +}; + +let id = 1; +let req: Promise; + +export const useFlow = () => { + const vueFlow = useVueFlow(); + const { mitt } = useCool(); + + const store = defineStore(`flow-${vueFlow.id}`, () => { + // 所有节点 + const nodes = computed(() => vueFlow.nodes.value as FlowNode[]); + + // 所有线 + const edges = computed(() => vueFlow.edges.value as FlowEdge[]); + + // 当前选中的节点 + const node = ref(); + + // 选中节点 + function setNode(data: any) { + node.value = data; + mitt.emit("flow.setNode", node.value); + } + + // 清空节点 + function clearNode() { + mitt.emit("flow.clearNode"); + + setTimeout(() => { + node.value = undefined; + }, 0); + } + + // 添加节点 + function addNode(type: string, options?: FlowNode) { + const item = CustomNodes.value.find((e) => e.type == type); + + const data = { + type, + data: { + inputParams: [], + outputParams: [], + options: {} + }, + position: { + x: 0, + y: 0 + }, + ...item, + ...options, + id: String(id++) + }; + + vueFlow.addNodes(cloneDeep(data)); + + return findNode(data.id); + } + + // 插入节点,自动计算位置 + function insertNode(type: string, source: FlowNode, options?: FlowNode) { + if (source) { + return addNode(type, { + position: calcPosition(source, undefined), + ...options + }); + } else { + return; + } + } + + // 更新节点 + function updateNode(id: string, data: any) { + const node = findNode(id); + + if (node) { + // 不同类型,清空相关连线 + if (data.name && data.name != node.name) { + removeEdgeByNodeId(id); + + ["handle", "data", "form"].forEach((k) => { + if (!data[k]) { + data[k] = {}; + } + }); + } + + assign(node, data); + vueFlow.updateNode(id, data); + } + } + + // 移除节点 + function removeNodes(nodes: any[] | any, force?: boolean) { + // start 节点不能删除,除非 force 强制删除 + const vals = (isArray(nodes) ? nodes : [nodes]).filter((e) => + force ? true : e.type != "start" + ); + + // 移除节点 + vueFlow.removeNodes(vals); + + // 移除连线 + vals.forEach((e) => { + removeEdgeByNodeId(e.id); + + // 如果是当前选中节点,则清空 + if (e.id == node.value?.id) { + clearNode(); + } + }); + } + + // 搜索节点 + function findNode(id: string) { + return nodes.value.find((n) => n.id === id) as FlowNode; + } + + // 搜索节点 + function findNodeByType(type: string) { + return nodes.value.find((n) => n.type === type) as FlowNode; + } + + // 叶子节点 + function leafNodes(id: string) { + return childrenAllNodes(id).filter((e) => isEmpty(childrenNodes(e.id!))); + } + + // 兄弟节点 + function slibingNodes(id: string, hasOwn: boolean = true) { + // 找上级节点 + const pNode = parentNode(id); + + // 找同级 + return edges.value + .filter((e) => e.source == pNode?.id) + .map((e) => findNode(e.target)) + .filter((e) => (hasOwn ? true : e.id != id)); + } + + // 父节点 + function parentNode(id: string) { + const edge = edges.value.find((e) => e.target == id); + return edge ? findNode(edge.source!) : null; + } + + // 所有父节点 + function parentAllNodes(id: string) { + const nodes: FlowNode[] = []; + + function next(id: string) { + const pNode = parentNode(id); + + if (pNode) { + nodes.push(pNode); + next(pNode.id!); + } + } + + next(id); + + return nodes; + } + + // 子节点 + function childrenNodes(id: string, handle?: string): FlowNode[] { + const node = findNode(id); + + // 下级连接线 + const childrenEdges = edges.value.filter((e) => e.source == id); + + // 下级连接点 + const handles = node?.handle?.next || [{ value: "source" }]; + + // 根据连接点顺序返回 + return handles + .filter((e) => { + return handle ? e.value == handle : true; + }) + .map((a: { value: string }) => { + const edge = childrenEdges.find((e) => e.sourceHandle == a.value); + return (edge ? findNode(edge.target!) : null)!; + }) + .filter((e) => !!e); + } + + // 子所有节点 + function childrenAllNodes(id: string, handle?: string) { + const nodes: FlowNode[] = []; + + function next(id: string, i = 0) { + const children = childrenNodes(id, i == 0 ? handle : undefined); + + children.forEach((e) => { + nodes.push(e); + next(e.id!, i + 1); + }); + } + + next(id, 0); + + return nodes; + } + + // 获取与节点所有连接的其他节点 + function getConnectedNodes(nodeId: string) { + const pNodes = parentAllNodes(nodeId); + const cNodes = childrenAllNodes(nodeId); + + return [...pNodes, findNode(nodeId), ...cNodes].filter((e) => !!e); + } + + // 是否存在线 + function hasEdge(connection: Connection) { + return edges.value.filter((e) => { + if (e.source == connection.source) { + if (connection.sourceHandle == e.sourceHandle) { + return true; + } + } + + if (e.target == connection.target) { + if (connection.targetHandle == e.targetHandle) { + return true; + } + } + + return false; + }); + } + + // 添加边线 + function addEdge(connection: Connection) { + const list = hasEdge(connection); + + if (!isEmpty(list)) { + removeEdges(list); + } + + vueFlow.addEdges({ + ...connection, + animated: false, + updatable: true, + // markerEnd: MarkerType.ArrowClosed, + style: { + strokeWidth: 1.5 + }, + type: "button" + }); + } + + // 查找边线 + function findEdge(id: string) { + return vueFlow.findEdge(id); + } + + // 更新边线 + function updateEdge(id: string, data: any) { + const edge = findEdge(id); + + if (edge) { + vueFlow.updateEdge(edge, assign(edge, data), false); + } + } + + // 移除线 + function removeEdges(edge: any | any[]) { + vueFlow.removeEdges(edge); + } + + // 根据节点移除线 + function removeEdgeByNodeId(nodeId: string, type?: "source" | "target") { + const list = edges.value.filter((e) => { + if (type) { + return e[type] == nodeId; + } + + return e.source == nodeId || e.target == nodeId; + }); + + removeEdges(list); + + return list; + } + + // 突出已连接的线 + function activeEdge(nodeId: string, isShow: boolean) { + const primaryColor = getComputedStyle(document.documentElement).getPropertyValue( + `--el-color-primary` + ); + + edges.value + .filter((e) => e.target == nodeId || e.source == nodeId) + .forEach((e) => { + const stroke = isShow ? primaryColor : e._stroke || ""; + + // 记录之前的颜色 + e._stroke = e.style?.stroke; + + updateEdge(e.id, { + style: { + stroke + } + }); + }); + } + + // 默认 + function def() { + if (isEmpty(nodes.value)) { + const node = addNode("start", { + position: { + x: 100, + y: 100 + } + }); + + setNode(node); + } + } + + // 清空画布 + function clear() { + // 清空线 + removeEdges(edges.value); + // 清空节点 + removeNodes(nodes.value, true); + + // 默认 + def(); + + // 设置视图 + setViewport({ x: 0, y: 0 }); + } + + // 复制节点 + const copyData = ref(); + function setCopyNode(node: any) { + copyData.value = cloneDeep(node); + } + + // 缩放 + const zoom = ref(100); + function setZoom(val: number) { + zoom.value = val; + } + + // 控制模式 + const controlMode = ref("hand"); + function setControlMode(val: "pointer" | "hand") { + controlMode.value = val; + vueFlow.panOnDrag.value = val == "hand"; + } + + // 滚动距离 、缩放大小 + const viewport = computed(() => { + return vueFlow.viewport.value || { zoom: 1.0 }; + }); + + function setViewport( + { x, y, zoom }: { x: number; y: number; zoom?: number }, + duration = 300 + ) { + vueFlow.setViewport({ x, y, zoom: zoom || viewport.value.zoom }, { duration }); + } + + // 设置节点中心位置 + async function setViewportByNode(node: FlowNode) { + if (!node) { + return false; + } + + await sleep(10); + + const { zoom } = viewport.value; + + if (node) { + const flowEl = document.querySelector(".cl-flow"); + const panelEl = document.querySelector(".cl-flow .tools-panel-right"); + const nodeEl = document.querySelector(`div[data-id="${node.id}"]`); + + const { x = 0, y = 0 } = node.position || {}; + + const top = + ((flowEl?.clientHeight || 0) - (nodeEl?.clientHeight || 0) * zoom) / 2 - + y * zoom; + const left = + ((flowEl?.clientWidth || 0) - + ((panelEl?.clientWidth || 0) + 10) - + (nodeEl?.clientWidth || 0) * zoom) / + 2 - + x * zoom; + + setViewport({ x: left, y: top }); + } else { + setViewport({ x: 0, y: 0 }); + } + } + + // 计算位置信息 + function calcPosition(source: FlowNode, target?: FlowNode) { + const { x = 0, y = 0 } = source.position || {}; + + const position = { + x: x + offset.x, + y: 0 + }; + + // 子节点 + const nodes = childrenNodes(source.id!); + + // 第一个子节点 + const fNode = nodes[0]; + + // 【是否有相邻节点】有目标节点则判断是否与第一个相同,否则判断节点长度 + if (target ? fNode?.id != target.id : !isEmpty(nodes)) { + // 计算到第几个子节点 + const end = target ? nodes.findIndex((e) => e.id == target?.id) : nodes.length; + + // 前几个节点高度之和,从第一个节点的 y 开始算 + const height = nodes + .filter((_, i) => i < end) + .reduce( + (a, b) => { + return ( + a + + (document.querySelector(`div[data-id="${b.id}"]`)?.clientHeight || + 0) + + offset.y_b + ); + }, + fNode?.position?.y || 0 + ); + + position.y = height; + } else { + position.y = y - offset.y_t; + } + + return position; + } + + // 整理 + async function arrange() { + if (node.value) { + clearNode(); + await sleep(200); + } + + const list = nodes.value as FlowNode[]; + + // 是否已连接 + const conntected: string[] = []; + + // 多个连接线 + const group: FlowNode[][] = []; + + list.forEach((e) => { + if (!conntected.includes(e.id!)) { + const nodes = [e, ...childrenAllNodes(e.id!)]; + + nodes.forEach((e) => { + conntected.push(e.id!); + }); + + // 判断最后一个是否相同 + const sn = group.findIndex((e) => last(e)?.id == last(nodes)?.id); + + if (sn >= 0) { + // 长的覆盖短的 + if (nodes.length > group[sn].length) { + group[sn] = nodes; + } + } else { + group.push(nodes); + } + } + }); + + // 遍历组,计算每个节点 + group.forEach((row, i) => { + // 起始 + const x = 100; + let y = 100; + + // 根据上一组的 y 值来计算当前 + const prev = group[i - 1]; + + if (prev) { + const arr = prev.map((e) => { + return ( + (e.position?.y || 0) + + (document.querySelector(`div[data-id="${e.id}"]`)?.clientHeight || 0) + ); + }); + + y = Math.max(...arr.concat(0)) + offset.g; + } + + const node = row[0]; + + if (node) { + // 更新首节点 + updateNode(node.id!, { + position: { + x, + y + } + }); + + // 依次遍历子节点 + function next(item: FlowNode) { + const children = childrenNodes(item.id!); + + children.forEach((e) => { + updateNode(e.id!, { + position: calcPosition(item, e) + }); + + next(e); + }); + } + + next(node); + } + }); + + // 回到初始位置 + setViewport({ x: 0, y: 0, zoom: 1 }); + } + + // 初始化 + function init() { + // 设置删除键 + vueFlow.deleteKeyCode.value = "none"; + + // 禁用点击连接 + vueFlow.connectOnClick.value = false; + } + + // 基本信息 + const info = ref(); + + // 获取 + async function get(flowId?: number) { + await req; + + return service.flow.info + .info({ + id: flowId || info.value?.id + }) + .then((res) => { + if (res) { + info.value = res; + + // 还原节点 + restore(res.draft); + + // 开始节点 + if (isEmpty(nodes.value)) { + def(); + } + } else { + ElMessageBox.alert("流程不存在或异常,请重新选择。", "提示", { + callback() { + router.back(); + } + }); + } + + return res; + }); + } + + /** + * 提取传给后端的数据 + * @param nodes + * @param edges + * @returns + */ + function extractData(nodes, edges) { + const nodesResult = (nodes as FlowNode[]).map((e, i) => { + // 开始节点 + if (e.type == "start") { + e.data?.inputParams?.forEach((p) => { + p.name = p.field; + p.nodeId = e.id; + p.nodeType = "start"; + }); + } + + // 其他节点 + else { + ["inputParams", "outputParams"].forEach((k) => { + if (e.data?.[k]) { + e.data?.[k].forEach((e: FlowField) => { + const d = findNode(e.nodeId!); + + if (d) { + e.nodeType = d.type; + } + }); + } + }); + } + + return { + ...e, + component: undefined, + form: undefined + }; + }); + + const edgesResult = edges.map((e) => { + return { + ...e, + animated: false, + style: {} + }; + }); + + return { + nodes: nodesResult, + edges: edgesResult + }; + } + + // 保存 + async function save() { + if (!info.value?.id) { + return false; + } + + const { nodes, edges, viewport } = vueFlow.toObject(); + + // 提取有用数据 + const { nodes: nodesResult, edges: edgesResult } = extractData(nodes, edges); + + req = service.flow.info.update({ + id: info.value?.id, + draft: { + nodes: nodesResult, + edges: edgesResult, + viewport + } + }); + + await req; + } + + // 还原 + async function restore(data: any) { + if (data) { + await vueFlow.fromObject(data); + + // 还原缩放比例 + zoom.value = viewport.value.zoom * 100; + + // 替换为本地的配置 + if (!isEmpty(nodes.value)) { + id = Math.max(...nodes.value.map((e) => Number(e.id))) + 1; + + nodes.value.forEach((e) => { + const cn = CustomNodes.value.find((a) => a.type == e.type); + + if (cn) { + // 处理卡片宽度 + const configWidth = cn.form?.width || "400px"; + const width = `${parseFloat(configWidth) + 30}px`; + + e.component = cn.component; + e.form = cn.form; + e.color = cn.color; + e.group = cn.group; + e.validator = cn.validator; + e.cardWidth = width; + } + }); + } + } + } + + // 分组显示 + function getGroup(keyWord: string) { + const d = groupBy( + CustomNodes.value.filter((e) => e.type != "start"), + "group" + ); + + let list = keys(d) + .map((k) => { + return { + label: k, + children: d[k].filter((e) => { + return keyWord ? e.label?.includes(keyWord) : true; + }) + }; + }) + .filter((e) => { + return !isEmpty(e.children); + }); + + list = orderBy(list, "label", "asc"); + + return list; + } + + // 视图x,y偏移 + function viewPx(x: number, y: number) { + return [ + (x - viewport.value.x) / viewport.value.zoom, + (y - viewport.value.y) / viewport.value.zoom + ]; + } + + // 禁用拖拽 + function disabledDrag() { + vueFlow.nodesDraggable.value = false; + vueFlow.panOnDrag.value = false; + } + + // 启用拖拽 + function enableDrag() { + vueFlow.nodesDraggable.value = true; + vueFlow.panOnDrag.value = true; + } + + /** + * 节点聚焦或失焦时调整子节点的位置 + * @param type open|close + * @param node + * @param id + * @returns + */ + async function updateChildrenPosition(type: "open" | "close", node: FlowNode) { + if (node) { + let list = [] as FlowNode[]; + + if (type == "open") { + list = childrenAllNodes(node.id!); + } else { + list = nodes.value; + } + + list.forEach((e) => { + e.isMoving = true; + + if (type == "open") { + e._offset = { + x: parseInt(node.form?.width || "400px") - 300 + 30, + y: 0 + }; + e.position!.x += e._offset.x; + } else { + if (e._offset) { + e.position!.x -= e._offset.x; + delete e._offset; + } + } + + updateNode(e.id!, e); + + setTimeout(() => { + e.isMoving = false; + }, 200); + }); + } + } + + /** + * 导出流程 + */ + async function exportFlow() { + if (!info.value?.id) { + return false; + } + + const { nodes, edges, viewport } = vueFlow.toObject(); + + // 提取有用数据 + const { nodes: nodesResult, edges: edgesResult } = extractData(nodes, edges); + + const flowInfo = cloneDeep(info.value); + + // 处理无用数据 + delete flowInfo.id; + delete flowInfo.createTime; + delete flowInfo.updateTime; + delete flowInfo.releaseTime; + delete flowInfo.draft; + + // 导出的数据 + const result = { + ...flowInfo, + draft: { + nodes: nodesResult, + edges: edgesResult, + viewport + } + }; + + const dataStr = JSON.stringify(result, null, 2); + const dataBlob = new Blob([dataStr], { type: "application/json" }); + const url = URL.createObjectURL(dataBlob); + + const link = document.createElement("a"); + link.setAttribute("href", url); + link.setAttribute("download", `${info.value?.name || "flow"}.json`); + link.click(); + + URL.revokeObjectURL(url); + + ElMessage.success("导出成功"); + } + + const expose = { + CustomNodes, + nodes, + node, + addNode, + removeNodes, + setCopyNode, + insertNode, + setNode, + findNode, + findNodeByType, + slibingNodes, + parentNode, + parentAllNodes, + childrenNodes, + childrenAllNodes, + leafNodes, + getConnectedNodes, + clearNode, + updateNode, + edges, + addEdge, + findEdge, + updateEdge, + activeEdge, + removeEdges, + removeEdgeByNodeId, + copyData, + clear, + zoom, + setZoom, + controlMode, + setControlMode, + viewport, + setViewport, + setViewportByNode, + arrange, + init, + info, + get, + save, + restore, + getGroup, + viewPx, + offset, + disabledDrag, + enableDrag, + updateChildrenPosition, + exportFlow + }; + + // 事件传递 + [ + "addNodes", + "updateNode", + "removeNodes", + "addEdge", + "updateEdge", + "removeEdges", + "clear", + "arrange" + ].forEach((k) => { + const fn = expose[k]; + + expose[k] = (...args: any[]) => { + const d = fn(...args); + mitt.emit(`flow.${k}`, d); + + return d; + }; + }); + + return expose; + }); + + return store(); +}; diff --git a/src/modules/flow/hooks/index.ts b/src/modules/flow/hooks/index.ts new file mode 100644 index 0000000..975e964 --- /dev/null +++ b/src/modules/flow/hooks/index.ts @@ -0,0 +1 @@ +export * from "./flow"; diff --git a/src/modules/flow/index.ts b/src/modules/flow/index.ts new file mode 100644 index 0000000..007f69d --- /dev/null +++ b/src/modules/flow/index.ts @@ -0,0 +1 @@ +export * from "./hooks"; diff --git a/src/modules/flow/static/index.scss b/src/modules/flow/static/index.scss new file mode 100644 index 0000000..a782a27 --- /dev/null +++ b/src/modules/flow/static/index.scss @@ -0,0 +1,36 @@ +.el-popper { + &.cl-flow__popper { + border-radius: 8px; + + .el-popper__arrow { + display: none; + } + + .el-scrollbar__view { + padding: 0; + } + + .el-select-dropdown__item { + border-radius: 6px; + height: 30px; + font-size: 12px; + line-height: 30px; + } + + &.el-select__popper { + margin: -7px 0; + + .el-select-dropdown__wrap { + padding: 5px; + } + } + + &:not(.el-select__popper) { + padding: 5px; + } + + &.not-padding { + padding: 0; + } + } +} diff --git a/src/modules/flow/static/svg/add-btn-fill.svg b/src/modules/flow/static/svg/add-btn-fill.svg new file mode 100644 index 0000000..e48c6bb --- /dev/null +++ b/src/modules/flow/static/svg/add-btn-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/add-btn.svg b/src/modules/flow/static/svg/add-btn.svg new file mode 100644 index 0000000..643bc23 --- /dev/null +++ b/src/modules/flow/static/svg/add-btn.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/add.svg b/src/modules/flow/static/svg/add.svg new file mode 100644 index 0000000..c5af320 --- /dev/null +++ b/src/modules/flow/static/svg/add.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/add2.svg b/src/modules/flow/static/svg/add2.svg new file mode 100644 index 0000000..4a6f3c7 --- /dev/null +++ b/src/modules/flow/static/svg/add2.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/arrange.svg b/src/modules/flow/static/svg/arrange.svg new file mode 100644 index 0000000..6d1d1db --- /dev/null +++ b/src/modules/flow/static/svg/arrange.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/arrow-right.svg b/src/modules/flow/static/svg/arrow-right.svg new file mode 100644 index 0000000..08ce56d --- /dev/null +++ b/src/modules/flow/static/svg/arrow-right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/back.svg b/src/modules/flow/static/svg/back.svg new file mode 100644 index 0000000..ff46274 --- /dev/null +++ b/src/modules/flow/static/svg/back.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/baidu.svg b/src/modules/flow/static/svg/baidu.svg new file mode 100644 index 0000000..db32184 --- /dev/null +++ b/src/modules/flow/static/svg/baidu.svg @@ -0,0 +1,21 @@ + + + + + diff --git a/src/modules/flow/static/svg/buckle.svg b/src/modules/flow/static/svg/buckle.svg new file mode 100644 index 0000000..4b6d787 --- /dev/null +++ b/src/modules/flow/static/svg/buckle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/center.svg b/src/modules/flow/static/svg/center.svg new file mode 100644 index 0000000..d1ee24e --- /dev/null +++ b/src/modules/flow/static/svg/center.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/change.svg b/src/modules/flow/static/svg/change.svg new file mode 100644 index 0000000..49ea2ff --- /dev/null +++ b/src/modules/flow/static/svg/change.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/classify.svg b/src/modules/flow/static/svg/classify.svg new file mode 100644 index 0000000..7b41f2c --- /dev/null +++ b/src/modules/flow/static/svg/classify.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/close.svg b/src/modules/flow/static/svg/close.svg new file mode 100644 index 0000000..2dba6d6 --- /dev/null +++ b/src/modules/flow/static/svg/close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/code.svg b/src/modules/flow/static/svg/code.svg new file mode 100644 index 0000000..55a2238 --- /dev/null +++ b/src/modules/flow/static/svg/code.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/config.svg b/src/modules/flow/static/svg/config.svg new file mode 100644 index 0000000..3cad6ca --- /dev/null +++ b/src/modules/flow/static/svg/config.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/debug.svg b/src/modules/flow/static/svg/debug.svg new file mode 100644 index 0000000..348f926 --- /dev/null +++ b/src/modules/flow/static/svg/debug.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/delete.svg b/src/modules/flow/static/svg/delete.svg new file mode 100644 index 0000000..24e3a17 --- /dev/null +++ b/src/modules/flow/static/svg/delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/edit.svg b/src/modules/flow/static/svg/edit.svg new file mode 100644 index 0000000..5c370d6 --- /dev/null +++ b/src/modules/flow/static/svg/edit.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/end.svg b/src/modules/flow/static/svg/end.svg new file mode 100644 index 0000000..850fd22 --- /dev/null +++ b/src/modules/flow/static/svg/end.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/export.svg b/src/modules/flow/static/svg/export.svg new file mode 100644 index 0000000..aef6328 --- /dev/null +++ b/src/modules/flow/static/svg/export.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/flow.svg b/src/modules/flow/static/svg/flow.svg new file mode 100644 index 0000000..366e568 --- /dev/null +++ b/src/modules/flow/static/svg/flow.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/fullscreen.svg b/src/modules/flow/static/svg/fullscreen.svg new file mode 100644 index 0000000..a93b570 --- /dev/null +++ b/src/modules/flow/static/svg/fullscreen.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/hand.svg b/src/modules/flow/static/svg/hand.svg new file mode 100644 index 0000000..1b3ef43 --- /dev/null +++ b/src/modules/flow/static/svg/hand.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/history.svg b/src/modules/flow/static/svg/history.svg new file mode 100644 index 0000000..afb6c6f --- /dev/null +++ b/src/modules/flow/static/svg/history.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/image.svg b/src/modules/flow/static/svg/image.svg new file mode 100644 index 0000000..da20d3d --- /dev/null +++ b/src/modules/flow/static/svg/image.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/import.svg b/src/modules/flow/static/svg/import.svg new file mode 100644 index 0000000..c606f25 --- /dev/null +++ b/src/modules/flow/static/svg/import.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/info.svg b/src/modules/flow/static/svg/info.svg new file mode 100644 index 0000000..906e10e --- /dev/null +++ b/src/modules/flow/static/svg/info.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/judge.svg b/src/modules/flow/static/svg/judge.svg new file mode 100644 index 0000000..267fe82 --- /dev/null +++ b/src/modules/flow/static/svg/judge.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/know.svg b/src/modules/flow/static/svg/know.svg new file mode 100644 index 0000000..cc879ea --- /dev/null +++ b/src/modules/flow/static/svg/know.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/llm.svg b/src/modules/flow/static/svg/llm.svg new file mode 100644 index 0000000..cd9bb83 --- /dev/null +++ b/src/modules/flow/static/svg/llm.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/more.svg b/src/modules/flow/static/svg/more.svg new file mode 100644 index 0000000..8be06a5 --- /dev/null +++ b/src/modules/flow/static/svg/more.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/next.svg b/src/modules/flow/static/svg/next.svg new file mode 100644 index 0000000..e3eeeda --- /dev/null +++ b/src/modules/flow/static/svg/next.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/number.svg b/src/modules/flow/static/svg/number.svg new file mode 100644 index 0000000..6532556 --- /dev/null +++ b/src/modules/flow/static/svg/number.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/parse.svg b/src/modules/flow/static/svg/parse.svg new file mode 100644 index 0000000..bb7b65a --- /dev/null +++ b/src/modules/flow/static/svg/parse.svg @@ -0,0 +1,25 @@ + + + + + + diff --git a/src/modules/flow/static/svg/pointer.svg b/src/modules/flow/static/svg/pointer.svg new file mode 100644 index 0000000..02ffc9c --- /dev/null +++ b/src/modules/flow/static/svg/pointer.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/prev.svg b/src/modules/flow/static/svg/prev.svg new file mode 100644 index 0000000..a0fa68e --- /dev/null +++ b/src/modules/flow/static/svg/prev.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/publish.svg b/src/modules/flow/static/svg/publish.svg new file mode 100644 index 0000000..f1a0e57 --- /dev/null +++ b/src/modules/flow/static/svg/publish.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/reduce-btn-fill.svg b/src/modules/flow/static/svg/reduce-btn-fill.svg new file mode 100644 index 0000000..a202d37 --- /dev/null +++ b/src/modules/flow/static/svg/reduce-btn-fill.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/reduce-btn.svg b/src/modules/flow/static/svg/reduce-btn.svg new file mode 100644 index 0000000..7663f42 --- /dev/null +++ b/src/modules/flow/static/svg/reduce-btn.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/restore.svg b/src/modules/flow/static/svg/restore.svg new file mode 100644 index 0000000..b545b36 --- /dev/null +++ b/src/modules/flow/static/svg/restore.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/run.svg b/src/modules/flow/static/svg/run.svg new file mode 100644 index 0000000..4c48c9f --- /dev/null +++ b/src/modules/flow/static/svg/run.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/run2.svg b/src/modules/flow/static/svg/run2.svg new file mode 100644 index 0000000..9c49d5e --- /dev/null +++ b/src/modules/flow/static/svg/run2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/save.svg b/src/modules/flow/static/svg/save.svg new file mode 100644 index 0000000..a6f8f41 --- /dev/null +++ b/src/modules/flow/static/svg/save.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/save2.svg b/src/modules/flow/static/svg/save2.svg new file mode 100644 index 0000000..c2559d4 --- /dev/null +++ b/src/modules/flow/static/svg/save2.svg @@ -0,0 +1 @@ + diff --git a/src/modules/flow/static/svg/set.svg b/src/modules/flow/static/svg/set.svg new file mode 100644 index 0000000..c0508a1 --- /dev/null +++ b/src/modules/flow/static/svg/set.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/start.svg b/src/modules/flow/static/svg/start.svg new file mode 100644 index 0000000..d3593f8 --- /dev/null +++ b/src/modules/flow/static/svg/start.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/switch.svg b/src/modules/flow/static/svg/switch.svg new file mode 100644 index 0000000..8688c77 --- /dev/null +++ b/src/modules/flow/static/svg/switch.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/t.svg b/src/modules/flow/static/svg/t.svg new file mode 100644 index 0000000..63021a8 --- /dev/null +++ b/src/modules/flow/static/svg/t.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/template-transform.svg b/src/modules/flow/static/svg/template-transform.svg new file mode 100644 index 0000000..0c098f3 --- /dev/null +++ b/src/modules/flow/static/svg/template-transform.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/text.svg b/src/modules/flow/static/svg/text.svg new file mode 100644 index 0000000..9c65bf4 --- /dev/null +++ b/src/modules/flow/static/svg/text.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/var.svg b/src/modules/flow/static/svg/var.svg new file mode 100644 index 0000000..1f5813c --- /dev/null +++ b/src/modules/flow/static/svg/var.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/variable.svg b/src/modules/flow/static/svg/variable.svg new file mode 100644 index 0000000..1f5813c --- /dev/null +++ b/src/modules/flow/static/svg/variable.svg @@ -0,0 +1,17 @@ + + + + diff --git a/src/modules/flow/static/svg/zoom-in.svg b/src/modules/flow/static/svg/zoom-in.svg new file mode 100644 index 0000000..ce25455 --- /dev/null +++ b/src/modules/flow/static/svg/zoom-in.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/static/svg/zoom-out.svg b/src/modules/flow/static/svg/zoom-out.svg new file mode 100644 index 0000000..c8418dd --- /dev/null +++ b/src/modules/flow/static/svg/zoom-out.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/flow/types/index.d.ts b/src/modules/flow/types/index.d.ts new file mode 100644 index 0000000..ec30ec5 --- /dev/null +++ b/src/modules/flow/types/index.d.ts @@ -0,0 +1,83 @@ +import { CSSProperties } from "vue"; + +declare type FlowField = { + field: string; // 自定义命名 + type?: string; // 字段类型 string number ... + value?: string; // 自定义值 + name?: string; // 选择的变量名 + nodeId?: string; // 选择的节点ID + nodeType?: string; // 选择的节点类型 start end ... + label?: string; // 显示名称 + required?: boolean; // 是否必填 + [key: string]: any; +}; + +declare interface FlowData { + inputParams?: FlowField[]; + outputParams?: FlowField[]; + options?: any; +} + +declare interface FlowNode { + enable?: boolean; + id?: string; + label?: string; + description?: string; + type?: string; + icon?: string; + name?: `node-${string}`; + position?: { + x: number; + y: number; + }; + form?: { + width?: string; + focus?: string; + items: ClForm.Item[]; + }; + handle?: { + target?: boolean; + source?: boolean; + next?: { label: string; value: string; [key: string]: any }[]; + }; + data?: FlowData; + validator?(data: FlowData): void | string; + isDisableDrag?: boolean; // 是否禁用拖拽(部分组件跟拖拽事件冲突,需禁用。例:伪富文本dom) + [key: string]: any; +} + +declare interface FlowEdge { + id: string; + type?: string; + target: string; + source: string; + targetHandle?: string | null; + sourceHandle?: string | null; + animated?: boolean; + style?: CSSProperties; + [key: string]: any; +} + +declare interface FlowNodeResult { + duration: number; + isEnd: boolean; + nodeId?: string; + node?: FlowNode; + nextNodeId?: string; + inputParams?: any; + outputParams?: any; + llmStream?: boolean; + count?: { + tokenUsage: number; + }; + result: { + success: boolean; + result: { + [key: string]: any; + }; + error: { + message: string; + }; + }; + [key: string]: any; +} diff --git a/src/modules/flow/utils/index.ts b/src/modules/flow/utils/index.ts new file mode 100644 index 0000000..7f1319a --- /dev/null +++ b/src/modules/flow/utils/index.ts @@ -0,0 +1,37 @@ +import dayjs from "dayjs"; + +export function formatTime(dateString?: Date): string { + if (!dateString) { + return ""; + } + + const now = dayjs(); + const date = dayjs(dateString); + + let secondsDiff = now.diff(date, "second"); + + if (secondsDiff < 60) { + if (secondsDiff < 0) { + secondsDiff = 0; + } + + return `${secondsDiff || 1}秒前`; + } + + const minutesDiff = now.diff(date, "minute"); + if (minutesDiff < 60) { + return `${minutesDiff}分钟前`; + } + + const hoursDiff = now.diff(date, "hour"); + if (hoursDiff < 24) { + return `${hoursDiff}小时前`; + } + + const isYesterday = now.isSame(date, "day"); + if (isYesterday) { + return `昨天 ${date.format("HH:mm")}`; + } + + return date.format("YYYY-MM-DD HH:mm"); +} diff --git a/src/modules/flow/views/info.vue b/src/modules/flow/views/info.vue new file mode 100644 index 0000000..8bb5727 --- /dev/null +++ b/src/modules/flow/views/info.vue @@ -0,0 +1,12 @@ + + + diff --git a/src/modules/flow/views/list.vue b/src/modules/flow/views/list.vue new file mode 100644 index 0000000..f69d497 --- /dev/null +++ b/src/modules/flow/views/list.vue @@ -0,0 +1,169 @@ + + + diff --git a/src/modules/know/components/config.vue b/src/modules/know/components/config.vue new file mode 100644 index 0000000..6847c6a --- /dev/null +++ b/src/modules/know/components/config.vue @@ -0,0 +1,366 @@ + + + + + diff --git a/src/modules/know/components/search-data.vue b/src/modules/know/components/search-data.vue new file mode 100644 index 0000000..eaf785a --- /dev/null +++ b/src/modules/know/components/search-data.vue @@ -0,0 +1,153 @@ + + + + + diff --git a/src/modules/know/components/search-test.vue b/src/modules/know/components/search-test.vue new file mode 100644 index 0000000..963f3b3 --- /dev/null +++ b/src/modules/know/components/search-test.vue @@ -0,0 +1,360 @@ + + + + + diff --git a/src/modules/know/components/select-model.vue b/src/modules/know/components/select-model.vue new file mode 100644 index 0000000..f8bbf39 --- /dev/null +++ b/src/modules/know/components/select-model.vue @@ -0,0 +1,220 @@ + + + + + diff --git a/src/modules/know/hooks/icon.ts b/src/modules/know/hooks/icon.ts new file mode 100644 index 0000000..de8f3f2 --- /dev/null +++ b/src/modules/know/hooks/icon.ts @@ -0,0 +1,37 @@ +import IconData from "../static/icon/data.png"; +import IconDepot from "../static/icon/depot.png"; +import IconGoods from "../static/icon/goods.png"; +import IconInfo from "../static/icon/info.png"; +import IconResource from "../static/icon/resource.png"; + +import { filename } from "/@/cool/utils"; + +export function useIcon() { + const list = [IconData, IconDepot, IconGoods, IconInfo, IconResource].map((e) => { + return { + path: e, + name: filename(e) + }; + }); + + function get(val?: string) { + if (!val) { + return IconData; + } + + if (val.includes("http")) { + return val; + } + + const icon = val.includes("/") + ? list.find((e) => e.path == val)?.name + : list.find((e) => e.name == val)?.path; + + return icon || IconData; + } + + return { + list, + get + }; +} diff --git a/src/modules/know/hooks/index.ts b/src/modules/know/hooks/index.ts new file mode 100644 index 0000000..b975409 --- /dev/null +++ b/src/modules/know/hooks/index.ts @@ -0,0 +1 @@ +export * from "./icon"; diff --git a/src/modules/know/static/icon/data.png b/src/modules/know/static/icon/data.png new file mode 100644 index 0000000..0eae234 Binary files /dev/null and b/src/modules/know/static/icon/data.png differ diff --git a/src/modules/know/static/icon/depot.png b/src/modules/know/static/icon/depot.png new file mode 100644 index 0000000..4fb0e1e Binary files /dev/null and b/src/modules/know/static/icon/depot.png differ diff --git a/src/modules/know/static/icon/goods.png b/src/modules/know/static/icon/goods.png new file mode 100644 index 0000000..53da0eb Binary files /dev/null and b/src/modules/know/static/icon/goods.png differ diff --git a/src/modules/know/static/icon/info.png b/src/modules/know/static/icon/info.png new file mode 100644 index 0000000..f495cbc Binary files /dev/null and b/src/modules/know/static/icon/info.png differ diff --git a/src/modules/know/static/icon/resource.png b/src/modules/know/static/icon/resource.png new file mode 100644 index 0000000..41e2f3b Binary files /dev/null and b/src/modules/know/static/icon/resource.png differ diff --git a/src/modules/know/static/svg/folder.svg b/src/modules/know/static/svg/folder.svg new file mode 100644 index 0000000..f81d8d5 --- /dev/null +++ b/src/modules/know/static/svg/folder.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/know/static/svg/search.svg b/src/modules/know/static/svg/search.svg new file mode 100644 index 0000000..ef421e1 --- /dev/null +++ b/src/modules/know/static/svg/search.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/know/static/svg/text.svg b/src/modules/know/static/svg/text.svg new file mode 100644 index 0000000..9c65bf4 --- /dev/null +++ b/src/modules/know/static/svg/text.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/modules/know/types/index.d.ts b/src/modules/know/types/index.d.ts new file mode 100644 index 0000000..93981f3 --- /dev/null +++ b/src/modules/know/types/index.d.ts @@ -0,0 +1,27 @@ +declare interface KnowType { + id: number; + name: string; + icon: string; + description: string; + embedConfigId: number; + embedOptions: any; + enableRerank?: boolean; + rerankConfigId?: number; + rerankOptions?: any; + updateFrequency: any; + enable: number; + [key: string]: any; +} + +declare interface KnowConfig { + id: number; + func: string; + description: string; + type: string; + options: { + comm?: any; + options?: { field: string; select?: string[]; default: string; title: string }[]; + [key: string]: any; + }; + [key: string]: any; +} diff --git a/src/modules/know/utils/index.ts b/src/modules/know/utils/index.ts new file mode 100644 index 0000000..7f1319a --- /dev/null +++ b/src/modules/know/utils/index.ts @@ -0,0 +1,37 @@ +import dayjs from "dayjs"; + +export function formatTime(dateString?: Date): string { + if (!dateString) { + return ""; + } + + const now = dayjs(); + const date = dayjs(dateString); + + let secondsDiff = now.diff(date, "second"); + + if (secondsDiff < 60) { + if (secondsDiff < 0) { + secondsDiff = 0; + } + + return `${secondsDiff || 1}秒前`; + } + + const minutesDiff = now.diff(date, "minute"); + if (minutesDiff < 60) { + return `${minutesDiff}分钟前`; + } + + const hoursDiff = now.diff(date, "hour"); + if (hoursDiff < 24) { + return `${hoursDiff}小时前`; + } + + const isYesterday = now.isSame(date, "day"); + if (isYesterday) { + return `昨天 ${date.format("HH:mm")}`; + } + + return date.format("YYYY-MM-DD HH:mm"); +} diff --git a/src/modules/know/views/data/info.vue b/src/modules/know/views/data/info.vue new file mode 100644 index 0000000..11157eb --- /dev/null +++ b/src/modules/know/views/data/info.vue @@ -0,0 +1,521 @@ + + + + + diff --git a/src/modules/know/views/data/type.vue b/src/modules/know/views/data/type.vue new file mode 100644 index 0000000..c292acc --- /dev/null +++ b/src/modules/know/views/data/type.vue @@ -0,0 +1,368 @@ + + + + +