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

@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { type shortcut_command } from '@coze-arch/bot-api/playground_api';
import { type DSL } from '../../types';
@@ -25,7 +25,7 @@ import {
getLayoutDSL,
} from './templates';
// 通过 Components 生成完整的 DSL
// Generating a complete DSL with Components
export const getDSLFromComponents = (
params: shortcut_command.Components[],
): DSL => {
@@ -36,7 +36,7 @@ export const getDSLFromComponents = (
[...formItemsDSL, ...layoutDSL].forEach(
item => (template.elements[item.id] = item),
);
// @ts-expect-error 支持直接传递 props
// @ts-expect-error supports direct delivery of props
template.elements.submitButton.props.formFields = formItemsDSL.map(
item => item.id,
);
@@ -45,7 +45,7 @@ export const getDSLFromComponents = (
type DSLElement = DSL['elements'][string];
// 通过 Components 创建 DSL 中对应的表单元素 Element
// Create the corresponding form element Element in the DSL through Components
export const getFormElementFromComponent = (
param: shortcut_command.Components,
): DSLElement => {
@@ -55,12 +55,12 @@ export const getFormElementFromComponent = (
return getFormItemPlaceholderDSL();
};
// 用于生成 DSL 语法中双列布局的容器元素
// Container elements for generating two-column layouts in DSL syntax
const ITEMS_PER_LINE = 2;
export const getElementsLayout = (elements: DSLElement[]): DSLElement[] => {
const res: DSLElement[] = [];
const elementsCopy = [...elements];
// 如出现奇数个,最后一行占满
// If an odd number appears, the last line is full
while (elementsCopy.length) {
res.push(getLayoutDSL(elementsCopy.splice(0, ITEMS_PER_LINE)));
}

View File

@@ -20,7 +20,7 @@ import { shortid } from '../uuid';
import { getAcceptByUploadItemTypes } from '../file-const';
import { type DSL, ElementDirectiveType, ElementPropsType } from '../../types';
// @fixme DSL 类型定义需要更新
// @Fixme DSL type definition needs to be updated
export const getDSLTemplate = (): DSL => ({
elements: {
root: {
@@ -32,7 +32,7 @@ export const getDSLTemplate = (): DSL => ({
},
form: {
id: 'form',
name: 'FlowpdCiciComponentsForm', // TODO 组件名 & type 最好也能事先就约定好
name: 'FlowpdCiciComponentsForm', // TODO component name & type can preferably be agreed in advance
type: '@flowpd/cici-components/Form',
props: {
value: {
@@ -47,15 +47,15 @@ export const getDSLTemplate = (): DSL => ({
// some rules value
},
},
children: ['submitButton'], // 根据 variables + layout 生成
children: ['submitButton'], // Generated from variables + layout
},
// 通过 getFormElementsFromcomponent 生成表单元素
// Generate form elements from getFormElementsFromcomponent
// ...inputElements,
// 通过 getElementsLayout 生成表单元素 layout
// Generate form element layout with getElementsLayout
// ...inputLayoutElements,
submitButton: {
id: 'submitButton',
name: 'FlowpdCiciComponentsButton', // TODO 组件名 & type 最好也能事先就约定好
name: 'FlowpdCiciComponentsButton', // TODO component name & type can preferably be agreed in advance
type: '@flowpd/cici-components/Button',
props: {
onClick: {
@@ -69,7 +69,7 @@ export const getDSLTemplate = (): DSL => ({
variables: {
formValue: {
id: 'formValue',
defaultValue: {}, // 不需要缺省值
defaultValue: {}, // No default is required
},
},
actions: {
@@ -96,7 +96,7 @@ export type GetFormItemTemplate = (
export const getInputElementDSL: GetFormItemTemplate = component => ({
id: component.name ?? shortid(),
name: 'FlowpdCiciComponentsInput', // TODO 组件名最好也能事先就约定好
name: 'FlowpdCiciComponentsInput', // The TODO component name should preferably be agreed in advance
type: '@flowpd/cici-components/Input',
props: {
name: component.name,
@@ -104,13 +104,13 @@ export const getInputElementDSL: GetFormItemTemplate = component => ({
defaultValue: component.default_value,
rules: [],
noErrorMessage: true,
// @FIXME DSL 解析逻辑实际支持传入任意值作为 props但是类型定义里没有兼容这种语法
// The @FIXME DSL parsing logic actually supports passing arbitrary values as props, but there is no compatible syntax in the type definition
} as unknown as DSLElement['props'],
});
export const getSelectElementDSL: GetFormItemTemplate = component => ({
id: component.name ?? shortid(),
name: 'FlowpdCiciComponentsSelect', // TODO 组件名最好也能事先就约定好
name: 'FlowpdCiciComponentsSelect', // The TODO component name should preferably be agreed in advance
type: '@flowpd/cici-components/Select',
props: {
name: component.name,
@@ -126,11 +126,11 @@ export const getSelectElementDSL: GetFormItemTemplate = component => ({
},
],
noErrorMessage: true,
// @FIXME DSL 解析逻辑实际支持传入任意值作为 props但是类型定义里没有兼容这种语法
// The @FIXME DSL parsing logic actually supports passing arbitrary values as props, but there is no compatible syntax in the type definition
} as unknown as DSLElement['props'],
});
// 单位 kb
// Unit kb
export const IMAGE_MAX_SIZE = 500 * 1024; // 500 mb
export const FILE_MAX_SIZE = 500 * 1024; // 500 mb
@@ -147,7 +147,7 @@ const getAcceptByComponent = (component: shortcut_command.Components) => {
export const getUploadElementDSL: GetFormItemTemplate = component => ({
id: component.name ?? shortid(),
name: 'FlowpdCiciComponentsUpload', // TODO 组件名最好也能事先就约定好
name: 'FlowpdCiciComponentsUpload', // The TODO component name should preferably be agreed in advance
type: '@flowpd/cici-components/Upload',
props: {
name: component.name,
@@ -164,11 +164,11 @@ export const getUploadElementDSL: GetFormItemTemplate = component => ({
},
],
noErrorMessage: true,
// @FIXME DSL 解析逻辑实际支持传入任意值作为 props但是类型定义里没有兼容这种语法
// The @FIXME DSL parsing logic actually supports passing arbitrary values as props, but there is no compatible syntax in the type definition
} as unknown as DSLElement['props'],
});
// 配置 & 预览模式占位符
// Configuration & Preview Mode Placeholders
export const getFormItemPlaceholderDSL = () => ({
id: shortid(),
name: 'FlowpdCiciComponentsFormItemPlaceholder',
@@ -180,7 +180,7 @@ export const getLayoutDSL = (items: DSLElement[]): DSLElement => ({
name: 'FlowpdCiciComponentsColumnLayout',
type: '@flowpd/cici-components/ColumnLayout',
props: {
// 如出现奇数个,最后一行占满
// If an odd number appears, the last line is full
Columns: items.map(item => ({
children: [item.id],
config: { vertical: 'top', weight: 1, width: 'weighted' },
@@ -189,7 +189,7 @@ export const getLayoutDSL = (items: DSLElement[]): DSLElement => ({
action: 'enableUrl',
backgroundColor: 'transparent',
enableClickEvent: false,
// @FIXME card-buidler Layout 现有的数据结构,但是实际上类型非法
// @FIXME card-buidler Layout an existing data structure, but the type is actually illegal
} as unknown as DSLElement['props'],
});
export const getFormItemDSLMap: Record<

View File

@@ -95,7 +95,7 @@ export const ACCEPT_UPLOAD_TYPES: {
},
];
// 和chat支持的文件格式做映射
// Map with file formats supported by chat
export const fileTypeToInputTypeMap = {
[FileTypeEnum.IMAGE]: shortcut_command.InputType.UploadImage,
[FileTypeEnum.AUDIO]: shortcut_command.InputType.UploadAudio,
@@ -126,7 +126,7 @@ export const acceptMap = FILE_TYPE_CONFIG.reduce<{
return acc;
}, {});
// 根据acceptUploadItemTypes获取accept
// Accept based on acceptUploadItemTypes
export const getAcceptByUploadItemTypes = (
acceptUploadItemTypes: shortcut_command.InputType[],
) => {
@@ -144,7 +144,7 @@ export const getAcceptByUploadItemTypes = (
return accept.join(',');
};
// 根据fileType获取对应的fileInfo
// Get the corresponding fileInfo according to fileType
export const getFileInfoByFileType = (fileType: FileTypeEnum) => {
const inputType = fileTypeToInputTypeMap[fileType];
if (!inputType) {
@@ -153,7 +153,7 @@ export const getFileInfoByFileType = (fileType: FileTypeEnum) => {
return ACCEPT_UPLOAD_TYPES.find(item => item.type === inputType);
};
// ACCEPT_UPLOAD_TYPES转化为map
// ACCEPT_UPLOAD_TYPES converted to map
export const getAcceptUploadItemTypesMap = () =>
ACCEPT_UPLOAD_TYPES.reduce<{
[key in shortcut_command.InputType]?: string;

View File

@@ -14,13 +14,13 @@
* limitations under the License.
*/
// 根据template_querycomponents拼接query
// Stitching queries based on template_query and components
export const getQueryFromTemplate = (
templateQuery: string,
values: Record<string, unknown>,
) => {
let query = templateQuery;
// 替换模板中的{{key}}为values中key对应的值
// Replace the {{key}} in the template with the value corresponding to the key in values
Object.keys(values).forEach(key => {
query = query.replace(
new RegExp(`\\{\\{${key}\\}\\}`, 'g'),

View File

@@ -21,7 +21,7 @@ import {
import { type ToolInfo } from '../shortcut-tool/types';
// 根据shortcut获取toolInfo
// Get toolInfo by shortcut
export const getToolInfoByShortcut = (
shortcut: shortcut_command.ShortcutCommand | undefined,
): ToolInfo => {
@@ -51,11 +51,11 @@ export const getToolInfoByShortcut = (
};
};
// 校验string数字 + 英文 + _ & 不能是纯数字
// Check string: number + English + _ & cannot be pure numbers
export const validateCmdString = (value: string) =>
/^[a-zA-Z0-9_]+$/.test(value) && !/^[0-9]+$/.test(value);
// 根据tool_type判断是否开启了tool
// According to tool_type determine whether the tool is turned on.
export const initToolEnabledByToolTYpe = (
toolType: shortcut_command.ToolType | undefined,
) =>
@@ -65,7 +65,7 @@ export const initToolEnabledByToolTYpe = (
shortcut_command.ToolType.ToolTypePlugin,
].includes(toolType);
// 校验pluginworkflow参数是否为string|integer类型,不支持复杂的对象类型
// Verify that the plugin and workflow parameters are of type string | integer, and do not support complex object types
export const validatePluginAndWorkflowParams = (
params: ToolParams[],
enableEmpty = false,
@@ -89,7 +89,7 @@ export const validatePluginAndWorkflowParams = (
};
};
// 校验shortcut_command是否重复
// Check if shortcut_command duplicate
export const validateCommandNameRepeat = (
checkShortcut: shortcut_command.ShortcutCommand,
shortcuts: shortcut_command.ShortcutCommand[],
@@ -101,7 +101,7 @@ export const validateCommandNameRepeat = (
shortcut.shortcut_command === shortcutCommand,
);
};
// 校验按钮名称command_name是否重复
// Check button name command_name duplicate
export const validateButtonNameRepeat = (
checkShortcut: shortcut_command.ShortcutCommand,
shortcuts: shortcut_command.ShortcutCommand[],

View File

@@ -14,12 +14,12 @@
* limitations under the License.
*/
// 对齐 card-builder 生成 ID 的逻辑,暂时拷贝一份,未来计划直接使用 card-buidler 的底层能力
// Align the logic of card-builder generating ID, make a copy temporarily, and plan to use the underlying capabilities of card-buidler directly in the future
import { nanoid, customAlphabet } from 'nanoid';
/**
* @param prefix - id前缀
* @param options - alphabet: 字母表; length: 长度,默认10;
* @param prefix - id prefix
* @Param options - alphabet; length: length, default 10;
*/
export const shortid = (
prefix = '',