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

@@ -19,7 +19,7 @@ import { I18n } from '@coze-arch/i18n';
import { codeEmptyValidator } from '../code-empty-validator';
// 模拟I18n.t方法
// Simulation I18n.t method
vi.mock('@coze-arch/i18n', () => ({
I18n: { t: vi.fn(key => `translated_${key}`) },
}));

View File

@@ -20,7 +20,7 @@ import { I18n } from '@coze-arch/i18n';
import { nodeMetaValidator } from '../node-meta-validator';
// 模拟 I18n.t 方法
// Simulation I18n.t method
vi.mock('@coze-arch/i18n', () => ({
I18n: { t: vi.fn(key => `translated_${key}`) },
}));
@@ -98,7 +98,7 @@ describe('nodeMetaValidator', () => {
mockNodesService.getAllNodes.mockReturnValue([
{ id: 'node1', title: 'ExistingTitle' },
{ id: 'node2', title: 'AnotherNode' },
{ id: 'node2', title: 'ExistingTitle' }, // 这里模拟一个重复的标题
{ id: 'node2', title: 'ExistingTitle' }, // Here a repeating title is simulated.
]);
const result = nodeMetaValidator({
value: { title: 'ExistingTitle' },

View File

@@ -19,7 +19,7 @@ import { describe, it, vi, expect } from 'vitest';
import { questionOptionValidator } from '../question-option-validator';
// 模拟 I18n.t 方法
// Simulation I18n.t method
vi.mock('@coze-arch/i18n', () => ({
I18n: { t: vi.fn(key => `translated_${key}`) },
}));

View File

@@ -35,7 +35,7 @@ interface Issue {
}
/**
* 输入树校验器
* input tree validator
*/
export class InputTreeValidator {
private node: FlowNodeEntity;
@@ -47,7 +47,7 @@ export class InputTreeValidator {
}
/**
* 校验函数
* check function
* @param inputalues
* @reurns
*/
@@ -58,7 +58,7 @@ export class InputTreeValidator {
}
/**
* 校验多个输入
* Validate multiple inputs
* @param inputValues
* @param path
* @returns
@@ -90,13 +90,13 @@ export class InputTreeValidator {
});
const children = inputValues[i]?.children || [];
// 递归检查子节点
// Recursively check sub-node
this.validateInputValues(children, path.concat(i, 'children'));
}
}
/**
* 输入名称校验
* input name validation
*/
private validateName({ value, values }) {
if (!value) {
@@ -104,12 +104,12 @@ export class InputTreeValidator {
}
const names = values.map(v => v.name).filter(Boolean);
// 名称格式校验
// name format verification
if (!VARIABLE_NAME_REGEX.test(value)) {
return I18n.t('workflow_detail_node_error_format');
}
// 重名校验
// duplicate name verification
const foundSames = names.filter((name: string) => name === value);
return foundSames.length > 1
@@ -118,12 +118,12 @@ export class InputTreeValidator {
}
/**
* 输入值校验
* input value validation
*/
private validateInput({ value }) {
const { variableValidationService } = this.playgroundContext;
// 校验空值
// check null value
if (ValueExpression.isEmpty(value)) {
return I18n.t('workflow_detail_node_error_empty');
}
@@ -160,7 +160,7 @@ export function inputTreeValidator(params: ValidatorProps<InputValueVO>) {
ctx.addIssue({
path: issue.path,
message: issue.message,
// FIXME: 表单校验底层依赖了 validation / code去掉就跑不通了
// FIXME: The underlying layer of form validation relies on validation/code, so it won't work if you remove it.
validation: 'regex',
code: 'invalid_string',
});

View File

@@ -43,7 +43,7 @@ export const jsonSchemaValidator = (
return valid;
// eslint-disable-next-line @coze-arch/use-error-in-catch
} catch (error) {
// parse失败说明不是合法值
// Parse failure indicates that it is not a legal value
return false;
}
};

View File

@@ -59,7 +59,7 @@ export const nodeMetaValidator = ({
return nodes?.length > 1;
}
// 增加节点名重复校验
// Add Node Name Duplicate Validation
const schema = NodeMetaSchema.refine(
({ title }: NodeMeta) => !isTitleRepeated(title),
{

View File

@@ -19,7 +19,7 @@ import { ViewVariableType } from '@coze-workflow/base';
import { I18n } from '@coze-arch/i18n';
import { jsonSchemaValidator } from '../json-schema-validator';
// 定义节点Schema
// Define Node Schema
const OutputTreeNodeSchema: ZodSchema<any> = z.lazy(() =>
z
.object({
@@ -41,7 +41,7 @@ const OutputTreeNodeSchema: ZodSchema<any> = z.lazy(() =>
export const OutputTreeSchema = z.array(OutputTreeNodeSchema);
// 定义一个辅助函数,用于查找重复名字的节点并返回错误路径
// Define a helper function to find nodes with duplicate names and return the error path
const findDuplicates = (nodes, path = []) => {
const seen = new Set();
let result: {
@@ -52,7 +52,7 @@ const findDuplicates = (nodes, path = []) => {
for (let i = 0; i < nodes.length; i++) {
const { name } = nodes[i];
if (seen.has(name)) {
// 找到重复项时返回路径和错误信息
// Returns paths and error messages when duplicates are found
result = {
// @ts-expect-error -- linter-disable-autofix
path: path.concat(i, 'name'),
@@ -62,7 +62,7 @@ const findDuplicates = (nodes, path = []) => {
}
seen.add(name);
if (nodes[i].children) {
// 递归检查子节点
// Recursively check sub-node
const found = findDuplicates(
nodes[i].children,
// @ts-expect-error -- linter-disable-autofix
@@ -78,35 +78,35 @@ const findDuplicates = (nodes, path = []) => {
return result;
};
// 定义同级命名唯一的树结构Schema
// Define a sibling-named unique tree structure schema
export const OutputTreeUniqueNameSchema = z
.array(OutputTreeNodeSchema)
.refine(
data => {
// 使用自定义函数进行检查
// Check with a custom function
const duplicate = findDuplicates(data);
return !duplicate;
},
data => {
// 使用自定义函数进行检查
// Check with a custom function
const duplicate = findDuplicates(data);
return {
path: duplicate.path,
message: duplicate.message,
// FIXME: 表单校验底层依赖了 validation / code去掉就跑不通了
// FIXME: The underlying layer of form validation relies on validation/code, so it won't work if you remove it.
validation: 'regex',
code: 'invalid_string',
};
},
)
.superRefine((data, ctx) => {
// 使用自定义函数进行检查
// Check with a custom function
const issues = checkObjectDefaultValue(data);
issues.forEach(issue => {
ctx.addIssue({
path: issue.path,
message: issue.message,
// FIXME: 表单校验底层依赖了 validation / code去掉就跑不通了
// FIXME: The underlying layer of form validation relies on validation/code, so it won't work if you remove it.
validation: 'regex',
code: 'invalid_string',
});
@@ -128,15 +128,15 @@ const checkObjectDefaultValue = nodes => {
continue;
}
if (!jsonSchemaValidator(defaultValue, nodes[i])) {
// 找到重复项时返回路径和错误信息
// Returns paths and error messages when duplicates are found
result.push({
path: [i, 'defaultValue'],
message: I18n.t('workflow_debug_wrong_json'),
});
}
// json 类型只检查第一层,不需要递归检查
// The JSON type only checks the first layer, no recursive check is required
}
return result;
};
// 导出类型别名
// export type alias
export type OutputTree = z.infer<typeof OutputTreeSchema>;

View File

@@ -18,7 +18,7 @@ import { z, ZodIssueCode } from 'zod';
import { I18n } from '@coze-arch/i18n';
import { type ValidatorProps } from '@flowgram-adapter/free-layout-editor';
// 自定义验证器,检查数组是否为空,并且没有重复的值
// Custom validator to check if the array is empty and there are no duplicate values
const nonEmptyUniqueArray = z
.array(
z.object({
@@ -29,7 +29,7 @@ const nonEmptyUniqueArray = z
const seenValues = new Set();
val.forEach((item, idx) => {
// 检查非空
// check non-empty
if (item.name.trim() === '') {
ctx.addIssue({
code: ZodIssueCode.custom,
@@ -42,7 +42,7 @@ const nonEmptyUniqueArray = z
});
}
// 检查重复
// Check for duplicates
if (seenValues.has(item.name)) {
ctx.addIssue({
code: ZodIssueCode.custom,

View File

@@ -52,7 +52,7 @@ export const settingOnErrorValidator = ({
}
return true;
}
// json 合法性校验
// json legitimacy check
const schemeParesd = SettingOnErrorSchema.refine(
settingOnError => isJSONVerified(settingOnError),
{