chore: replace all cn comments of fe to en version by volc api (#320)

This commit is contained in:
tecvan
2025-07-31 10:32:15 +08:00
committed by GitHub
parent 716ec0cba8
commit 71f6245a01
2960 changed files with 15545 additions and 15545 deletions

View File

@@ -21,7 +21,7 @@ import { type Dataset } from '@coze-arch/bot-api/knowledge';
import { KnowledgeApi as knowledgeApi } from '@coze-arch/bot-api';
/**
* 知识库全局状态管理 (单例)
* Knowledge Base Global State Management (Singleton)
*/
export class DataSetStore {
private dataSetInfosMap: { [k: string]: Dataset } = {};
@@ -59,31 +59,31 @@ export class DataSetStore {
}
});
// 如果全部命中缓存,直接返回
// If all hits cache, return directly
if (needQueryInfoIds.length === 0) {
callback(existDataInfoIds.map(id => this.dataSetInfosMap[id]));
return;
}
// 否则注册队列,等待查询完成后调用 callback
// Otherwise, register the queue and call the callback after the query is completed.
this.listeners.push({
ids,
callback,
});
// 分析出需要额外查询的 ids
// Analyze IDs that require additional queries
const needAddToQueryQueueIds = needQueryInfoIds.filter(
id => !this.queryQueue.includes(id),
);
// 如果没有需要额外查询的 ids ,就等着吧
// If there are no ids that require additional queries, just wait
if (needAddToQueryQueueIds.length === 0) {
return;
}
// 如果有需要额外的查询的 ids ,就扔到待查询队列里
// If there are ids that require additional queries, throw them into the queue to be queried
this.queryQueue = this.queryQueue.concat(needAddToQueryQueueIds);
// 调用 query
// Invoke query
this.query(spaceId);
}
@@ -143,7 +143,7 @@ export class DataSetStore {
if (!this.dataSetInfosMap[d.dataset_id as string]) {
this.dataSetInfosMap[d.dataset_id as string] = d;
} else {
// 更新缓存的知识库信息
// Update cached knowledge base information
this.dataSetInfosMap[d.dataset_id as string] = {
...this.dataSetInfosMap[d.dataset_id as string],
...d,

View File

@@ -30,50 +30,50 @@ export type NodeError = ValidateError;
export type NodeErrorMap = Map<string, NodeError[]>;
/**
* 当前流程状态
* Current process status
*/
export interface WorkflowExecState extends GetWorkFlowProcessData {
executeId: string;
// 是否有执行历史
// Is there any execution history?
exeHistoryStatus: WorkflowExeHistoryStatus;
/**
* 当前工作流视图状态
* Current workflow view state
*/
viewStatus?: WorkflowExecStatus;
/**
* 运行结果面板显隐状态
* Run Results Panel Hidden Status
*/
resultSideSheetVisible: boolean;
resultSideSheetLoading: boolean;
// 这里的 version 暂时无意义,只是为了触发errorMap更新
// The version here is temporarily meaningless, just to trigger an errorMap update
version?: number;
// 错误信息
// error message
nodeErrorMap: NodeErrorMap;
// 有些错误无法定位到具体节点,放在 systemError
// Some errors cannot be located to specific nodes and are placed in systemError
systemError?: string;
// 执行ID
// Execution ID
executeLogId?: string;
// 是否为单节点运行
// Whether to run as a single node
isSingleMode?: boolean;
// 运行的项目环境 id
// Running project environment id
projectId?: string;
nodeEvents: NodeEvent[];
}
export interface NodeErrorSetting {
showError: boolean; // 是否展示错误
showError: boolean; // Whether to display errors
}
/**
* 流程全局状态管理 (单例)
* Process global state management (singleton)
*/
export class WorkflowExecStateEntity extends ConfigEntity<WorkflowExecState> {
static type = 'WorkflowExecStateEntity';
@@ -133,7 +133,7 @@ export class WorkflowExecStateEntity extends ConfigEntity<WorkflowExecState> {
version: Date.now(),
});
}
/** 批量设置 */
/** batch setup */
setNodeErrors(map: { [nodeId: string]: NodeError[] }) {
Object.keys(map).forEach(nodeId => {
const nodeError = map[nodeId];

View File

@@ -53,7 +53,7 @@ const getAutoSaveTime = timestamp => {
let autoSaveTime = dayjs().format('HH:mm:ss');
/**
* 如果后端有回传更新时间且更新时间为 unix 时间戳则使用,否则兜底显示假时间
* If the backend has a return update time and the update time is unix timestamp, it will be used, otherwise the bottom cover will display the fake time.
*/
if (timestamp && typeof timestamp === 'number') {
const time = dayjs.unix(timestamp);
@@ -88,98 +88,98 @@ export type WorkflowInfo = Omit<Workflow, 'status'> & {
workflow_version?: string;
} & {
/**
* workflow 详情中返回的 spaceId, 官方示例场景下和当前空间的值不相等
* The spaceId returned in the workflow details is not equal to the value of the current space in the official example scenario
*/
workflowSourceSpaceId?: string;
};
export enum WorkflowExecStatus {
DEFAULT = 'default',
/** 执行中 */
/** in progress */
EXECUTING = 'executing',
/** 执行结束(此时依然有执行结束 banner且工作流为 disable 状态) */
/** End of execution (there is still an end of execution banner at this time, and the workflow is disabled) */
DONE = 'done',
}
/**
* 当前流程状态
* Current process status
*/
export interface WorkflowGlobalState {
/** Workflow 组件传入属性 */
/** Workflow component pass-in properties */
playgroundProps: WorkflowPlaygroundProps;
workflowId: string;
/** 画布加载中 */
/** Canvas loading */
loading: boolean;
/** save接口请求时间比saving要短。 */
/** Save interface request time is shorter than save. */
saveLoading: boolean;
/** 保存中包含debounce时间 */
/** Saving, including debouncing time */
saving: boolean;
savingError?: boolean;
loadingError?: string;
/**
* 发布中
* In release
*/
publishing: boolean;
/**
* 工作流自动保存时间
* Workflow auto-save time
*/
autoSaveTime?: string;
autoSaveTimestamp?: number;
/** 工作流详情 */
/** Workflow Details */
info: WorkflowInfo;
/** 当前空间类型 */
/** Current space type */
spaceType?: SpaceType;
/** 用户的空间列表 */
/** List of user spaces */
spaceList: BotSpace[];
/** 空间模式 */
/** Spatial Mode */
spaceMode: SpaceMode;
/** 流程是否是预览态 */
/** Is the process in preview state? */
preview: boolean;
/**
* 工作流视图状态(与发布状态区分)
* Workflow view state (distinguished from publication state)
* @default WorkflowExecStatus.DEFAULT
*/
viewStatus?: WorkflowExecStatus;
/** 是否发布过, 流程首次发布的时候会向 bot 注册成插件 */
/** Has it been released? When the process is first released, it will be registered as a plugin with the bot. */
pluginId: string;
// 增加 is_bind_agent 字段,该流程是否绑定了 bot 当做 agent
// Add is_bind_agent field, whether the process is bound to the bot as an agent
isBindAgent: boolean;
/** 是否绑定了抖音 */
/** Is Douyin bound? */
isBindDouyin: boolean;
/** Workflow 存量插件是否存在更新,如果存在更新,此时会修改相关表单数据,并且需要试运行 */
/** Is there an update to the Workflow stock plug-in, and if so, modifies the relevant form data and requires a practice run */
inPluginUpdated?: boolean;
/* 是否在查看历史 */
/* Are you checking history? */
historyStatus?: OperateType;
/** 绑定的业务场景 id */
/** Bound business scenario id */
bindBizID?: string;
/** 绑定的业务类型 */
/** bound business type */
bindBizType?: number;
/** 节点侧栏床是否打开 */
/** Is the node sidebar bed open? */
nodeSideSheetVisible?: boolean;
schemaGray?: {
loop?: string;
batch?: string;
};
/** 流程的节点和线条是否为初始状态,只判断开始结束节点的出入参 */
/** Whether the nodes and lines of the process are in the initial state, only the entry and exit parameters of the beginning and end nodes are judged */
isInitWorkflow?: boolean;
/**
* 知识库信息
* Knowledge Base Information
*/
sharedDataSet?: DataSetStore;
}
/**
* 流程全局状态管理 (单例)
* Process global state management (singleton)
*/
export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState> {
static type = 'WorkflowGlobalStateEntity';
@@ -220,13 +220,13 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
);
}
// 加载workflow tcc配置
// Load workflow tcc configuration
await Promise.all([this.setSpaceInfo()]);
const workflowInfo = await this.queryWorkflowDetail(workflowId, spaceId);
const autoSaveTime = getAutoSaveTime(workflowInfo?.update_time);
/** 判断流程是否是预览态,来自官方的流程、组件配置只读 readonly、非vcs模式不是创建者的流程、 vcs模式无协作者权限 的流程为预览态 */
/** Determine whether the process is in preview state, from the official process, component configuration read-only readonly, non-vcs mode is not the creator's process, vcs mode has no collaborator permission, and the process is in preview state */
const isVcsMode = workflowInfo.collaborator_mode === CollaboratorMode.Open;
const isReadOnly = this.config.playgroundProps.readonly;
const isGuanFangType = workflowInfo?.type === WorkFlowType.GuanFang;
@@ -277,11 +277,11 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
isInitWorkflow,
});
// 更新画布的 readonly 状态
// Update the readonly status of the canvas
this.entityManager
.getEntity<PlaygroundConfigEntity>(PlaygroundConfigEntity)
?.updateConfig({
/** 初始情况下,预览态 => 画布不可编辑 */
/** Initially, the preview state = > canvas is not editable */
readonly: preview,
});
return workflowJSON;
@@ -379,18 +379,18 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
)?.versions,
});
// 更新画布的 readonly 状态
// Update the readonly status of the canvas
this.entityManager
.getEntity<PlaygroundConfigEntity>(PlaygroundConfigEntity)
?.updateConfig({
/** 初始情况下,预览态 => 画布不可编辑 */
/** Initially, the preview state = > canvas is not editable */
readonly: true,
});
return workflowJSON;
}
/** 获取空间相关信息 */
/** Acquire space-related information */
async setSpaceInfo() {
if (!this.config.spaceList.length) {
const { bot_space_list } = await DeveloperApi.SpaceList();
@@ -428,14 +428,14 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
return this.config?.spaceType === SpaceType.Team;
}
/** 流程是否发布过, 是否有 pluginId 标识本流程是否发布过 */
/** Whether the process has been published, and whether there is a pluginId indicating whether the process has been published */
get hasPublished(): boolean {
return Boolean(this.config?.pluginId);
}
/**
* 空间是否启用 Dev 模式
* @deprecated 目前 Dev 模式已经下线
* Is the space enabled in Dev mode?
* @Deprecated Dev mode is currently offline
*/
get isDevSpace(): boolean {
return this.config.spaceMode === SpaceMode.DevMode;
@@ -448,7 +448,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
return target?.id ?? '';
}
/* 新版接口,多人协作模式灰度下走这个接口 */
/* New interface, multi-player collaboration mode grey release under this interface */
protected async queryCollaborationWorkflow(
workflowId: string,
spaceId: string,
@@ -501,7 +501,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
namespace: 'workflow',
error: e,
});
// 公共空间模版删除时,存在约 5 分钟的缓存,这里需要兜底,防止预览已被删除的流程导致崩溃
// When the public space template is deleted, there is a cache for about 5 minutes. Here, you need to back up to prevent the preview of the deleted process from crashing.
if (spaceId !== PUBLIC_SPACE_ID) {
throw e;
}
@@ -509,7 +509,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
}
}
/** 外部传入属性 */
/** external incoming property */
get playgroundProps(): WorkflowPlaygroundProps {
return this.config.playgroundProps;
}
@@ -535,19 +535,19 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
}
get projectId(): string | undefined {
// 页面当前传入的 projectId 或者 canvas 等接口返回的 projectId
// The projectId currently passed into the page or the projectId returned by interfaces such as canvas
return (
this.config.playgroundProps.projectId || this.config.info?.project_id
);
}
/** 是否在 IDE */
/** Is it in the IDE? */
get isInIDE(): boolean {
return !!this.projectId;
}
/**
* 获取 project 注入的能力,非 project 内返回为 null
* Get the ability of project injection, return null in non-project
*/
getProjectApi = () => {
const outGetProjectApi = this.config.playgroundProps.getProjectApi;
@@ -557,7 +557,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
return null;
};
/**
* 重新加载
* Reload
*/
reload = async () => {
const workflowJson = await this.load(
@@ -568,7 +568,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
};
/**
* 画布描述信息
* canvas description information
*/
get info(): WorkflowInfo {
return this.config.info;
@@ -583,7 +583,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
}
/**
* 流程不可编辑, 如: 试运行中的流程、预览态的流程不可编辑、组件配置 readonly
* The process cannot be edited, such as: the process in practice run, the process in preview state cannot be edited, the component configuration readonly, etc
*/
get readonly(): boolean {
return this.config.preview || this.isExecuting;
@@ -594,7 +594,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
}
/**
* 已发布的 Workflow 发生变更需要展示文案
* The published workflow has changed and the copy needs to be displayed
*/
get hasChanged(): boolean {
const { config } = this;
@@ -609,7 +609,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
}
/**
* 画布是否加载中
* Is the canvas loading?
*/
get loading(): boolean {
return this.config.loading;
@@ -635,7 +635,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
}
/**
* 是否开启协作模式
* Whether to enable collaboration mode
*/
get isCollaboratorMode() {
return this.info.collaborator_mode === CollaboratorMode.Open;
@@ -653,7 +653,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
return this.config.bindBizType;
}
/** 当前工作流是否绑定抖音分身 */
/** Is the current workflow bound to the Douyin doppelganger? */
get isBindDouyin() {
return Boolean(
this.config.bindBizType === BindBizType.DouYinBot &&
@@ -666,7 +666,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
WorkflowMode.Workflow) as WorkflowMode;
}
/* 判断存储模式是否为vcs模式vcs模式下需要走新接口 */
/* Determine whether the storage mode is vcs mode, and a new interface is required in vcs mode */
get isVcsMode() {
return this.config.info.persistence_model === PersistenceModel.VCS;
}
@@ -680,18 +680,18 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
}
/**
* @deprecated 待下线
* @deprecated to be offline
*/
get isSceneFlow() {
return this.flowMode === WorkflowMode.SceneFlow;
}
/** 存量插件是否存在更新 */
/** Is there an update for the existing plugins? */
get inPluginUpdated() {
return Boolean(this.config.inPluginUpdated);
}
/** 设置存量插件是否存在更新值 */
/** Set whether there is an updated value for the existing plug-ins. */
set inPluginUpdated(value: boolean) {
this.updateConfig({
inPluginUpdated: value,
@@ -727,7 +727,7 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
);
}
/** 是否展示添加协作者功能 */
/** Whether to show the Add Collaborator feature */
get canCollaboration() {
return (
this.isTeamSpace &&
@@ -738,18 +738,18 @@ export class WorkflowGlobalStateEntity extends ConfigEntity<WorkflowGlobalState>
}
get canTestRunHistory() {
// 查看历史时,无法获取试运行历史
// Unable to get practice run history when viewing history
if (this.isViewHistory) {
return false;
}
// 作者未开启协作模式时,相当于单人,可以获取历史
// When the author does not turn on the collaboration mode, it is equivalent to a single person and can access history
if (!this.isCollaboratorMode && this.info.creator?.self) {
return true;
}
const { vcsData, persistence_model } = this.info;
// vcs模式下只有自己的草稿能获取试运行历史
// In VCS mode, only your own draft can get the practice run history
if (
persistence_model === PersistenceModel.VCS &&
!(vcsData?.type === VCSCanvasType.Draft && this.info.vcsData?.can_edit)

View File

@@ -33,7 +33,7 @@ export class WorkflowTemplateStateEntity extends ConfigEntity<WorkflowTemplateSt
previewInfo: Workflow;
dataList: Workflow[];
// 更新后触发
// Triggered after update
onPreviewUpdatedEmitter = new Emitter();
onPreviewUpdated = this.onPreviewUpdatedEmitter.event;

View File

@@ -25,13 +25,13 @@ import { TestRunDataSource } from '../components/test-run/constants';
import { WorkflowGlobalStateEntity } from './workflow-global-state-entity';
interface WorkflowTestFormState {
/** test run form 是否可见 */
/** Test run form is visible */
formVisible: boolean;
/** 同时只能运行一个 test run,用于冻结 */
/** Only one test run can be run at a time for freezing */
frozen: string | null;
autoGenerating: boolean;
/** coze graph 2.0 节点面板 */
/** Coze graph 2.0 Node panel */
commonSheetKey: null | string;
testNodeFormVisible: boolean;
}
@@ -39,18 +39,18 @@ interface WorkflowTestFormState {
export class WorkflowTestFormStateEntity extends ConfigEntity<WorkflowTestFormState> {
static type = 'WorkflowTestFormStateEntity';
/** schema 无需响应式 */
/** Schema without reactive */
formSchema?: TestFormSchema;
testRunDataSource = TestRunDataSource.User;
/**
* 缓存用户填写过的数据
* Cache user-filled data
*/
formDataCacheMap = new Map<string, FormDataType>();
/**
* 表单默认值,优先级低于 formDataCache
* Form default, lower priority than formDataCache
*/
formDefaultValue: Array<TestFormDefaultValue> = [];
@@ -77,17 +77,17 @@ export class WorkflowTestFormStateEntity extends ConfigEntity<WorkflowTestFormSt
}
/**
* 设置 testForm 缓存数据
* Set testForm to cache data
*/
setFormData(id: string, data: FormDataType) {
this.formDataCacheMap.set(id, data);
}
/**
* 设置当前打开的 testForm 的缓存数据
* Set the cached data for the currently open testForm
*/
setThisFormData(data: FormDataType) {
/** 本方法无需指定 id为保证 formSchema 有效,仅当 testForm 打开时允许使用 */
/** This method does not need to specify an id. To ensure that formSchema is valid, it is only allowed when the testForm is open */
if (!this.config.formVisible) {
return;
}
@@ -98,21 +98,21 @@ export class WorkflowTestFormStateEntity extends ConfigEntity<WorkflowTestFormSt
}
/**
* testForm 是否有缓存数据
* Does testForm have cached data?
*/
hasFormData(id: string) {
return this.formDataCacheMap.has(id);
}
/**
* 获取 testForm 缓存数据
* Get testForm cache data
*/
getFormData(id: string) {
return this.formDataCacheMap.get(id);
}
/**
* 清除所有缓存数据,画布销毁时必须要做
* Clear all cached data, must be done when the canvas is destroyed
*/
clearFormData() {
this.formDataCacheMap.clear();
@@ -129,7 +129,7 @@ export class WorkflowTestFormStateEntity extends ConfigEntity<WorkflowTestFormSt
return (
this.formDefaultValue.find(item => item.node_id === id) ??
// playgroundProps 可传入test run表单默认值
// PlaygroundProps can pass in test run form defaults
globalState?.config.playgroundProps.testFormDefaultValues?.find(
item => item.node_id === id,
)
@@ -140,13 +140,13 @@ export class WorkflowTestFormStateEntity extends ConfigEntity<WorkflowTestFormSt
this.formDefaultValue = [];
}
/** 冻结 test run */
/** Freeze test run */
freezeTestRun(id: string) {
this.updateConfig({
frozen: id,
});
}
/** 解冻 test run */
/** Thaw test run */
unfreezeTestRun() {
this.updateConfig({
frozen: null,