@baishuyun/agents 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/index.ts +10 -0
- package/package.json +30 -0
- package/src/continue-confirmer/index.ts +41 -0
- package/src/continue-confirmer/prompt.ts +11 -0
- package/src/fields-builder/fields-builder.ts +43 -0
- package/src/fields-builder/index.ts +109 -0
- package/src/form-builder/consts/index.ts +5 -0
- package/src/form-builder/index.ts +24 -0
- package/src/form-builder/model/ds.ts +8 -0
- package/src/form-builder/model/openai.ts +7 -0
- package/src/form-builder/model/v0.ts +7 -0
- package/src/form-builder/model/xai.ts +7 -0
- package/src/form-builder/prompts/fields-design-docs.ts +3 -0
- package/src/form-builder/prompts/index.ts +32 -0
- package/src/form-builder/schema/index.ts +7 -0
- package/src/form-builder/tools/address.ts +58 -0
- package/src/form-builder/tools/attachment.ts +62 -0
- package/src/form-builder/tools/button.ts +73 -0
- package/src/form-builder/tools/checkbox.ts +55 -0
- package/src/form-builder/tools/confirm-to-create-fields-for-related-form.ts +16 -0
- package/src/form-builder/tools/confirm-to-create-form.ts +11 -0
- package/src/form-builder/tools/confirm-to-create-related-form.ts +16 -0
- package/src/form-builder/tools/confirm-to-save-checked-fields.ts +11 -0
- package/src/form-builder/tools/date-time.ts +73 -0
- package/src/form-builder/tools/department-group.ts +49 -0
- package/src/form-builder/tools/department.ts +49 -0
- package/src/form-builder/tools/image.ts +123 -0
- package/src/form-builder/tools/index.ts +27 -0
- package/src/form-builder/tools/input.ts +70 -0
- package/src/form-builder/tools/link-data.ts +70 -0
- package/src/form-builder/tools/load-data.ts +49 -0
- package/src/form-builder/tools/location.ts +94 -0
- package/src/form-builder/tools/member-group.ts +51 -0
- package/src/form-builder/tools/member.ts +51 -0
- package/src/form-builder/tools/number-input.ts +106 -0
- package/src/form-builder/tools/prompt-to-create-realted-form.ts +12 -0
- package/src/form-builder/tools/radio.ts +54 -0
- package/src/form-builder/tools/select-checker.ts +58 -0
- package/src/form-builder/tools/select.ts +56 -0
- package/src/form-builder/tools/serial-number.ts +75 -0
- package/src/form-builder/tools/signature.ts +38 -0
- package/src/form-builder/tools/splitline.ts +41 -0
- package/src/form-builder/tools/textarea.ts +55 -0
- package/src/form-builder/types/index.ts +53 -0
- package/src/form-builder/utils/index.ts +5 -0
- package/src/form-builder/utils/process-confirm-tool-call.ts +123 -0
- package/src/form-designer/index.ts +61 -0
- package/src/form-designer/prompts.ts +50 -0
- package/src/utils/index.ts +104 -0
- package/tsconfig.json +7 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
|
|
4
|
+
export const confirmToSaveCheckedFields = tool({
|
|
5
|
+
name: "confirmToSaveCheckedFields",
|
|
6
|
+
description: "confirm after fields created and checked",
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
message: z.string().min(2).max(100),
|
|
9
|
+
}),
|
|
10
|
+
outputSchema: z.string(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
|
|
4
|
+
export const buildDateTimeField = tool({
|
|
5
|
+
name: "buildDateTimeField",
|
|
6
|
+
description: "Builds a date-time field",
|
|
7
|
+
inputSchema: z.object({
|
|
8
|
+
format: z.string().min(1).max(100).default("yyyy-MM-dd"),
|
|
9
|
+
label: z.string().min(1).max(100),
|
|
10
|
+
required: z.boolean().default(false),
|
|
11
|
+
fieldWidth: z.enum(["3", "4", "6", "8", "9", "12"]).default("12"),
|
|
12
|
+
description: z.string().min(1).max(100).default(""),
|
|
13
|
+
}),
|
|
14
|
+
execute: (input) => {
|
|
15
|
+
const { label, required, format, fieldWidth, description } = input;
|
|
16
|
+
return {
|
|
17
|
+
widget: {
|
|
18
|
+
type: "datetime",
|
|
19
|
+
height: 34,
|
|
20
|
+
width: 350,
|
|
21
|
+
enable: true,
|
|
22
|
+
visible: true,
|
|
23
|
+
allowBlank: !required,
|
|
24
|
+
funMode: "module",
|
|
25
|
+
format,
|
|
26
|
+
widgetName: `_widget_${Date.now()}`,
|
|
27
|
+
|
|
28
|
+
widgetNameAlias: "",
|
|
29
|
+
customCls: null,
|
|
30
|
+
value: "today", //默认值, today 填写当前时间 ,如果是数字,如 1762957800000 ,是自定义的时间,为所选时间的时间戳的毫秒级,
|
|
31
|
+
rely: null,
|
|
32
|
+
labelStyle: label,
|
|
33
|
+
module: null,
|
|
34
|
+
libs: [],
|
|
35
|
+
extendSet: {
|
|
36
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
37
|
+
status: true,
|
|
38
|
+
triggerField: "",
|
|
39
|
+
triggerFieldMode: "none",
|
|
40
|
+
version: 1,
|
|
41
|
+
},
|
|
42
|
+
hint: "",
|
|
43
|
+
dateLimit: {
|
|
44
|
+
//日期范围
|
|
45
|
+
week: {
|
|
46
|
+
//可选择星期
|
|
47
|
+
enable: false, //是否开启可选择星期
|
|
48
|
+
value: [
|
|
49
|
+
//星期 星期一到天,用1-7代表
|
|
50
|
+
1, 2, 6,
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
start: {
|
|
54
|
+
//最早可选时间
|
|
55
|
+
enable: false, //是否开启最早可选时间
|
|
56
|
+
mode: "dynamic", //模式: dynamic 动态 static 固定值 fieldValue 字段值
|
|
57
|
+
value: "yesterday", //限定的值: today 今天 yesterday 昨天 tomorrow 明天 7day_before 七天前 7day_after 七天后 30day_before 30天前 30day_after 30天后
|
|
58
|
+
},
|
|
59
|
+
end: {
|
|
60
|
+
//最晚可选时间
|
|
61
|
+
enable: false, //是否开启最晚可选时间
|
|
62
|
+
mode: "static", //模式: dynamic 动态 static 固定值 fieldValue 字段值
|
|
63
|
+
value: 1762093800000, //限定的值:这种数字的为 选择的固定值,时间的时间戳,毫秒级别 ,如果为 _widget_1762154537014 这种,为字段的值,这个字段需要也是日期字段,和当前这个字段是同一个 format的
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
description,
|
|
68
|
+
label,
|
|
69
|
+
lineWidth: parseInt(fieldWidth),
|
|
70
|
+
tab: null,
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { buildWidgetName } from "../utils/index.js";
|
|
4
|
+
|
|
5
|
+
export const buildDepartmentGroupSelectField = tool({
|
|
6
|
+
name: "buildDepartmentGroupSelectField",
|
|
7
|
+
description: "build a multiple department select field for a form",
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
label: z.string().min(1).max(100),
|
|
10
|
+
placeholder: z.string().min(1).max(100).optional(),
|
|
11
|
+
required: z.boolean().default(false),
|
|
12
|
+
fieldWidth: z.enum(["3", "4", "6", "8", "9", "12"]).default("12"),
|
|
13
|
+
description: z.string().min(1).max(100).optional(),
|
|
14
|
+
}),
|
|
15
|
+
execute: (input) => {
|
|
16
|
+
const { label, description, fieldWidth, required } = input;
|
|
17
|
+
return {
|
|
18
|
+
widget: {
|
|
19
|
+
type: "deptgroup",
|
|
20
|
+
widgetName: buildWidgetName(),
|
|
21
|
+
widgetNameAlias: "",
|
|
22
|
+
customCls: null,
|
|
23
|
+
height: "34",
|
|
24
|
+
width: 350,
|
|
25
|
+
enable: true,
|
|
26
|
+
visible: true,
|
|
27
|
+
allowBlank: !required,
|
|
28
|
+
labelStyle: label,
|
|
29
|
+
funMode: "module",
|
|
30
|
+
module: null,
|
|
31
|
+
libs: [],
|
|
32
|
+
extendSet: {
|
|
33
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
34
|
+
status: true,
|
|
35
|
+
triggerField: "",
|
|
36
|
+
triggerFieldMode: "none",
|
|
37
|
+
version: 1,
|
|
38
|
+
},
|
|
39
|
+
noRepeat: false,
|
|
40
|
+
limit: {},
|
|
41
|
+
valueOption: 0,
|
|
42
|
+
},
|
|
43
|
+
description,
|
|
44
|
+
label,
|
|
45
|
+
lineWidth: parseInt(fieldWidth, 10),
|
|
46
|
+
tab: null,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { buildWidgetName } from "../utils/index.js";
|
|
4
|
+
|
|
5
|
+
export const buildDepartmentSelectField = tool({
|
|
6
|
+
name: "buildDepartmentSelectField",
|
|
7
|
+
description: "build a department select field for a form",
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
label: z.string().min(1).max(100),
|
|
10
|
+
placeholder: z.string().min(1).max(100).optional(),
|
|
11
|
+
required: z.boolean().default(false),
|
|
12
|
+
fieldWidth: z.enum(["3", "4", "6", "8", "9", "12"]).default("12"),
|
|
13
|
+
description: z.string().min(1).max(100).optional(),
|
|
14
|
+
}),
|
|
15
|
+
execute: (input) => {
|
|
16
|
+
const { label, description, fieldWidth, required } = input;
|
|
17
|
+
return {
|
|
18
|
+
widget: {
|
|
19
|
+
type: "dept",
|
|
20
|
+
widgetName: buildWidgetName(),
|
|
21
|
+
widgetNameAlias: "",
|
|
22
|
+
customCls: null,
|
|
23
|
+
height: "34",
|
|
24
|
+
width: 350,
|
|
25
|
+
enable: true,
|
|
26
|
+
visible: true,
|
|
27
|
+
allowBlank: !required,
|
|
28
|
+
labelStyle: label,
|
|
29
|
+
funMode: "module",
|
|
30
|
+
module: null,
|
|
31
|
+
libs: [],
|
|
32
|
+
extendSet: {
|
|
33
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
34
|
+
status: true,
|
|
35
|
+
triggerField: "",
|
|
36
|
+
triggerFieldMode: "none",
|
|
37
|
+
version: 1,
|
|
38
|
+
},
|
|
39
|
+
noRepeat: false,
|
|
40
|
+
limit: {},
|
|
41
|
+
valueOption: 0,
|
|
42
|
+
},
|
|
43
|
+
description,
|
|
44
|
+
label,
|
|
45
|
+
lineWidth: parseInt(fieldWidth, 10),
|
|
46
|
+
tab: null,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { buildWidgetName } from "../utils/index.js";
|
|
4
|
+
|
|
5
|
+
export const buildImageField = tool({
|
|
6
|
+
name: "buildImageField",
|
|
7
|
+
description: "Build an image field for a form.",
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
label: z
|
|
10
|
+
.string()
|
|
11
|
+
.min(1)
|
|
12
|
+
.max(100)
|
|
13
|
+
.describe("The label for the image field."),
|
|
14
|
+
required: z.boolean().describe("Whether the image field is required."),
|
|
15
|
+
fieldWidth: z
|
|
16
|
+
.enum(["3", "4", "6", "8", "9", "12"])
|
|
17
|
+
.describe("The width of the field in the form layout."),
|
|
18
|
+
maxFileCount: z
|
|
19
|
+
.number()
|
|
20
|
+
.optional()
|
|
21
|
+
.describe("Maximum number of files allowed.")
|
|
22
|
+
.default(50),
|
|
23
|
+
fileSizeLimit: z
|
|
24
|
+
.number()
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("Maximum file size limit in bytes.")
|
|
27
|
+
.default(20971520),
|
|
28
|
+
watermarkField: z
|
|
29
|
+
.array(
|
|
30
|
+
z.object({
|
|
31
|
+
text: z.string().describe("Field name."),
|
|
32
|
+
name: z.string().describe("Field ID."),
|
|
33
|
+
type: z.string().describe("Field type."),
|
|
34
|
+
regex: z.string().optional().describe("Field regex."),
|
|
35
|
+
value: z.string().describe("Field value."),
|
|
36
|
+
newText: z.string().describe("New field text."),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
.optional()
|
|
40
|
+
.describe("Fields to be used for watermarking."),
|
|
41
|
+
watermarkColor: z
|
|
42
|
+
.string()
|
|
43
|
+
.optional()
|
|
44
|
+
.describe("Color of the watermark text.")
|
|
45
|
+
.default("#616161"),
|
|
46
|
+
description: z
|
|
47
|
+
.string()
|
|
48
|
+
.max(300)
|
|
49
|
+
.optional()
|
|
50
|
+
.describe("A brief description of the image field."),
|
|
51
|
+
}),
|
|
52
|
+
execute: (input) => {
|
|
53
|
+
const {
|
|
54
|
+
label,
|
|
55
|
+
required,
|
|
56
|
+
fieldWidth,
|
|
57
|
+
description,
|
|
58
|
+
maxFileCount,
|
|
59
|
+
fileSizeLimit,
|
|
60
|
+
watermarkColor,
|
|
61
|
+
watermarkField,
|
|
62
|
+
} = input;
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
widget: {
|
|
66
|
+
type: "image",
|
|
67
|
+
widgetName: buildWidgetName(),
|
|
68
|
+
widgetNameAlias: "",
|
|
69
|
+
customCls: null,
|
|
70
|
+
height: 100,
|
|
71
|
+
enable: true,
|
|
72
|
+
visible: true,
|
|
73
|
+
allowBlank: !required,
|
|
74
|
+
labelStyle: label,
|
|
75
|
+
funMode: "module",
|
|
76
|
+
module: null,
|
|
77
|
+
libs: [],
|
|
78
|
+
extendSet: {
|
|
79
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
80
|
+
status: true,
|
|
81
|
+
triggerField: "",
|
|
82
|
+
triggerFieldMode: "none",
|
|
83
|
+
version: 1,
|
|
84
|
+
},
|
|
85
|
+
maxFileCount,
|
|
86
|
+
download: true, //打包下载
|
|
87
|
+
is_file_down: true, //操作权限 可下载
|
|
88
|
+
check_image_exif: true, //照片支持查看EXIF扩展信息
|
|
89
|
+
online_edit: false,
|
|
90
|
+
online_edit_record: false,
|
|
91
|
+
fileSizeLimit,
|
|
92
|
+
fileType: [
|
|
93
|
+
//支持上传的类型,默认,不可以设置
|
|
94
|
+
"jpg",
|
|
95
|
+
"jpeg",
|
|
96
|
+
"png",
|
|
97
|
+
"gif",
|
|
98
|
+
"bmp",
|
|
99
|
+
"tif",
|
|
100
|
+
],
|
|
101
|
+
compressed: true, //三方图片压缩
|
|
102
|
+
wxOriginalComponent: true, //微信/企业微信原生拍照模式
|
|
103
|
+
onlyCamera: false, //仅允许拍照上传
|
|
104
|
+
preview: true, //是否可以预览 默认 不可以设置
|
|
105
|
+
watermarkSwitch: true, //水印属性
|
|
106
|
+
watermarkPosition: "center", //水印位置
|
|
107
|
+
watermarkFieldTitle: true, //是否显示水印字段标题
|
|
108
|
+
watermarkSize: "14", //水印字体大小 不可以设置
|
|
109
|
+
watermarkColor,
|
|
110
|
+
watermarkField,
|
|
111
|
+
watermarkFixedField: {},
|
|
112
|
+
previewWidth: 450, //预览的宽 默认 不可以设置
|
|
113
|
+
previewHeight: 450, //预览的高 默认 不可以设置
|
|
114
|
+
browserCompress: true, //浏览器图片压缩
|
|
115
|
+
quality: 0.7, //压缩图片比例,开启 浏览器图片压缩 后才能设置
|
|
116
|
+
},
|
|
117
|
+
description,
|
|
118
|
+
label,
|
|
119
|
+
lineWidth: parseInt(fieldWidth, 10),
|
|
120
|
+
tab: null,
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export * from "./date-time.js";
|
|
2
|
+
export * from "./select.js";
|
|
3
|
+
export * from "./input.js";
|
|
4
|
+
export * from "./radio.js";
|
|
5
|
+
export * from "./confirm-to-save-checked-fields.js";
|
|
6
|
+
export * from "./confirm-to-create-form.js";
|
|
7
|
+
export * from "./confirm-to-create-fields-for-related-form.js";
|
|
8
|
+
export * from "./confirm-to-create-related-form.js";
|
|
9
|
+
export * from "./prompt-to-create-realted-form.js";
|
|
10
|
+
export * from "./textarea.js";
|
|
11
|
+
export * from "./checkbox.js";
|
|
12
|
+
export * from "./select-checker.js";
|
|
13
|
+
export * from "./button.js";
|
|
14
|
+
export * from "./splitline.js";
|
|
15
|
+
export * from "./address.js";
|
|
16
|
+
export * from "./location.js";
|
|
17
|
+
export * from "./number-input.js";
|
|
18
|
+
export * from "./image.js";
|
|
19
|
+
export * from "./attachment.js";
|
|
20
|
+
export * from "./signature.js";
|
|
21
|
+
export * from "./member.js";
|
|
22
|
+
export * from "./department.js";
|
|
23
|
+
export * from "./department-group.js";
|
|
24
|
+
export * from "./member-group.js";
|
|
25
|
+
export * from "./serial-number.js";
|
|
26
|
+
export * from "./load-data.js";
|
|
27
|
+
export * from "./link-data.js";
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { tool } from "ai";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
export const buildInputField = tool({
|
|
5
|
+
name: "buildInputField",
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
label: z.string().min(1).max(100),
|
|
8
|
+
placeholder: z.string().min(1).max(100).optional(),
|
|
9
|
+
required: z.boolean().default(false),
|
|
10
|
+
fieldWidth: z.enum(["3", "4", "6", "8", "9", "12"]).default("12"),
|
|
11
|
+
description: z.string().min(1).max(100).optional(),
|
|
12
|
+
textMode: z.enum(["text", "email", "password", "number"]).default("text"),
|
|
13
|
+
regex: z.string().min(1).max(1000).optional(),
|
|
14
|
+
}),
|
|
15
|
+
execute: (input) => {
|
|
16
|
+
const {
|
|
17
|
+
label,
|
|
18
|
+
placeholder,
|
|
19
|
+
required,
|
|
20
|
+
textMode,
|
|
21
|
+
regex,
|
|
22
|
+
fieldWidth,
|
|
23
|
+
description,
|
|
24
|
+
} = input;
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
widget: {
|
|
28
|
+
type: "text",
|
|
29
|
+
widgetName: `_widget_${Date.now()}`,
|
|
30
|
+
widgetNameAlias: "",
|
|
31
|
+
// triggerEvent: 0,
|
|
32
|
+
customCls: null,
|
|
33
|
+
height: 34,
|
|
34
|
+
width: 350,
|
|
35
|
+
text: null,
|
|
36
|
+
value: "", //默认值 没有默认值的话 整个value不存在
|
|
37
|
+
enable: true,
|
|
38
|
+
visible: true,
|
|
39
|
+
hint: placeholder,
|
|
40
|
+
allowBlank: !required,
|
|
41
|
+
rely: null,
|
|
42
|
+
labelStyle: label,
|
|
43
|
+
libs: [],
|
|
44
|
+
extendSet: {
|
|
45
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
46
|
+
status: true,
|
|
47
|
+
triggerField: "",
|
|
48
|
+
triggerFieldMode: "none",
|
|
49
|
+
version: 1,
|
|
50
|
+
},
|
|
51
|
+
regex, //格式 ^((\(\d{2,3}\))|(\d{3}\-))?1\d{10}$ 手机号码 ^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$ 电话号码 ^\d{6}$ 邮政编码 (^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$) 身份证号码 ^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$ 邮箱 (^[0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[2]{1}[0-3]{1}:[0-5]{1}[0-9]{1}$|^[0-9]{1}:[0-5]{1}[0-9]{1}$) 时分 (^[0-1]{1}[0-9]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[2]{1}[0-3]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$|^[0-9]{1}:[0-5]{1}[0-9]{1}:[0-5]{1}[0-9]{1}$) 时分秒 imageurl 图片链接 qrcode 二维码图片 barcode 条形码图片 custom 自定义
|
|
52
|
+
noRepeat: true,
|
|
53
|
+
scan: null,
|
|
54
|
+
textMode,
|
|
55
|
+
generateQR: false,
|
|
56
|
+
eventAlert: true,
|
|
57
|
+
alertinfo: {
|
|
58
|
+
icon: "error",
|
|
59
|
+
tip: placeholder,
|
|
60
|
+
msg: placeholder,
|
|
61
|
+
},
|
|
62
|
+
enterClearText: true,
|
|
63
|
+
},
|
|
64
|
+
description,
|
|
65
|
+
label,
|
|
66
|
+
lineWidth: parseInt(fieldWidth),
|
|
67
|
+
tab: null,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { buildWidgetName } from "../utils/index.js";
|
|
4
|
+
import type { FormBuilderContext } from "../types/index.js";
|
|
5
|
+
|
|
6
|
+
export const buildLinkDataField = tool({
|
|
7
|
+
name: "buildLinkDataField",
|
|
8
|
+
description:
|
|
9
|
+
"Build a field to present multipyle related fields from another form",
|
|
10
|
+
inputSchema: z.object({
|
|
11
|
+
label: z.string().min(1).max(100),
|
|
12
|
+
required: z.boolean().default(false),
|
|
13
|
+
fieldWidth: z.enum(["3", "4", "6", "8", "9", "12"]).default("12"),
|
|
14
|
+
description: z.string().min(1).max(100).optional(),
|
|
15
|
+
|
|
16
|
+
relatedFormName: z.string().min(1).max(100).optional(),
|
|
17
|
+
// relatedFormId: z.string().min(1).max(100).optional(),
|
|
18
|
+
// relatedAppId: z.string().min(1).max(100).optional(),
|
|
19
|
+
// primaryKeyField: z.string().min(1).max(100).optional(),
|
|
20
|
+
// primaryKeyFieldType: z.enum(["text", "number", "uuid"]).optional(),
|
|
21
|
+
}),
|
|
22
|
+
execute: (input, { experimental_context: ctx }) => {
|
|
23
|
+
const {
|
|
24
|
+
label,
|
|
25
|
+
description,
|
|
26
|
+
required,
|
|
27
|
+
fieldWidth,
|
|
28
|
+
// relatedFormName,
|
|
29
|
+
// relatedFormId,
|
|
30
|
+
// relatedAppId,
|
|
31
|
+
// primaryKeyField,
|
|
32
|
+
// primaryKeyFieldType,
|
|
33
|
+
} = input;
|
|
34
|
+
|
|
35
|
+
const builderCtx = ctx as FormBuilderContext;
|
|
36
|
+
const widgetName = buildWidgetName();
|
|
37
|
+
|
|
38
|
+
if (label && builderCtx) {
|
|
39
|
+
builderCtx.relatedForms[label] = widgetName;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
widget: {
|
|
44
|
+
type: "linkdata",
|
|
45
|
+
widgetName,
|
|
46
|
+
widgetNameAlias: "",
|
|
47
|
+
customCls: null,
|
|
48
|
+
enable: true,
|
|
49
|
+
visible: true,
|
|
50
|
+
allowBlank: !required,
|
|
51
|
+
rely: {
|
|
52
|
+
widgets: [],
|
|
53
|
+
},
|
|
54
|
+
labelStyle: label,
|
|
55
|
+
linkFilter: {},
|
|
56
|
+
linkFields: [],
|
|
57
|
+
// linkForm: relatedFormId,
|
|
58
|
+
// linkKey: primaryKeyField,
|
|
59
|
+
// linkType: primaryKeyFieldType,
|
|
60
|
+
// refAppId: relatedAppId,
|
|
61
|
+
allowAdd: true, //允许新增关联表数据
|
|
62
|
+
refType: "form", //关联表的类型,只能是form
|
|
63
|
+
},
|
|
64
|
+
description,
|
|
65
|
+
label,
|
|
66
|
+
lineWidth: parseInt(fieldWidth, 10),
|
|
67
|
+
tab: null,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { buildWidgetName } from '../utils/index.js';
|
|
4
|
+
|
|
5
|
+
export const buildLoadDataBtn = tool({
|
|
6
|
+
name: 'buildLoadDataBtn',
|
|
7
|
+
description: 'add a button field to load data from another form.',
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
label: z.string().min(1).max(100),
|
|
10
|
+
placeholder: z.string().min(1).max(100).optional(),
|
|
11
|
+
required: z.boolean().default(false),
|
|
12
|
+
fieldWidth: z.enum(['3', '4', '6', '8', '9', '12']).default('12'),
|
|
13
|
+
description: z.string().min(1).max(100).optional(),
|
|
14
|
+
}),
|
|
15
|
+
execute: (input) => {
|
|
16
|
+
const { label, required, fieldWidth, description } = input;
|
|
17
|
+
return {
|
|
18
|
+
widget: {
|
|
19
|
+
type: 'dataload',
|
|
20
|
+
widgetName: buildWidgetName(),
|
|
21
|
+
widgetNameAlias: '',
|
|
22
|
+
customCls: null,
|
|
23
|
+
width: 350,
|
|
24
|
+
text: label,
|
|
25
|
+
enable: true,
|
|
26
|
+
visible: true,
|
|
27
|
+
allowBlank: !required,
|
|
28
|
+
labelStyle: label,
|
|
29
|
+
loaddataconfig: {
|
|
30
|
+
//数据加载的配置
|
|
31
|
+
mode: 'tree', //显示模式 tree 树菜单 list 列表
|
|
32
|
+
extendSet: {
|
|
33
|
+
sort: ['datahelp', 'module', 'formEvent'],
|
|
34
|
+
status: true,
|
|
35
|
+
triggerField: '',
|
|
36
|
+
triggerFieldMode: 'none',
|
|
37
|
+
},
|
|
38
|
+
dataloadmode: ['add', 'cover'],
|
|
39
|
+
},
|
|
40
|
+
allowAddData: true, // 允许新增数据源数据
|
|
41
|
+
mode: 'list', //一直是 list 应该是废弃的
|
|
42
|
+
},
|
|
43
|
+
description,
|
|
44
|
+
label,
|
|
45
|
+
lineWidth: parseInt(fieldWidth),
|
|
46
|
+
tab: null,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { tool } from "ai";
|
|
3
|
+
import { buildWidgetName } from "../utils/index.js";
|
|
4
|
+
|
|
5
|
+
export const buildLocationField = tool({
|
|
6
|
+
name: "buildLocationField",
|
|
7
|
+
description: "Builds a location field for a form.",
|
|
8
|
+
inputSchema: z.object({
|
|
9
|
+
radius: z
|
|
10
|
+
.number()
|
|
11
|
+
.min(0)
|
|
12
|
+
.max(10000)
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("The radius for location accuracy in meters.")
|
|
15
|
+
.default(1500),
|
|
16
|
+
label: z
|
|
17
|
+
.string()
|
|
18
|
+
.min(1)
|
|
19
|
+
.max(100)
|
|
20
|
+
.describe("The label for the location field."),
|
|
21
|
+
limits: z
|
|
22
|
+
.optional(
|
|
23
|
+
z.array(
|
|
24
|
+
z.object({
|
|
25
|
+
name: z
|
|
26
|
+
.string()
|
|
27
|
+
.min(1)
|
|
28
|
+
.max(100)
|
|
29
|
+
.describe("The name of the location limit."),
|
|
30
|
+
position: z
|
|
31
|
+
.array(z.number())
|
|
32
|
+
.length(2)
|
|
33
|
+
.describe("The [longitude, latitude] of the location limit."),
|
|
34
|
+
radius: z
|
|
35
|
+
.number()
|
|
36
|
+
.min(0)
|
|
37
|
+
.max(10000)
|
|
38
|
+
.describe("The radius of the location limit in meters."),
|
|
39
|
+
}),
|
|
40
|
+
),
|
|
41
|
+
)
|
|
42
|
+
.default([])
|
|
43
|
+
.describe("The location limits for the field."),
|
|
44
|
+
description: z
|
|
45
|
+
.string()
|
|
46
|
+
.max(500)
|
|
47
|
+
.optional()
|
|
48
|
+
.describe("An optional description for the location field."),
|
|
49
|
+
required: z
|
|
50
|
+
.boolean()
|
|
51
|
+
.default(false)
|
|
52
|
+
.describe("Whether the field can be left blank."),
|
|
53
|
+
fieldWidth: z
|
|
54
|
+
.enum(["3", "4", "6", "8", "9", "12"])
|
|
55
|
+
.default("12")
|
|
56
|
+
.describe("The width of the field in the form. total is 12."),
|
|
57
|
+
}),
|
|
58
|
+
execute: (input) => {
|
|
59
|
+
const { label, description, required, fieldWidth, radius, limits } = input;
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
widget: {
|
|
63
|
+
type: "location",
|
|
64
|
+
widgetName: buildWidgetName(),
|
|
65
|
+
widgetNameAlias: "",
|
|
66
|
+
customCls: null,
|
|
67
|
+
enable: true,
|
|
68
|
+
visible: true,
|
|
69
|
+
allowBlank: !required,
|
|
70
|
+
labelStyle: label,
|
|
71
|
+
funMode: "module",
|
|
72
|
+
module: null,
|
|
73
|
+
libs: [],
|
|
74
|
+
extendSet: {
|
|
75
|
+
sort: ["datahelp", "module", "formEvent"],
|
|
76
|
+
status: true,
|
|
77
|
+
triggerField: "",
|
|
78
|
+
triggerFieldMode: "none",
|
|
79
|
+
version: 1,
|
|
80
|
+
},
|
|
81
|
+
adjustable: true, //允许移动端微调
|
|
82
|
+
radius,
|
|
83
|
+
limits,
|
|
84
|
+
lnglatVisible: true, //显示经纬度坐标
|
|
85
|
+
autoLocation: true, //移动端自动触发定位
|
|
86
|
+
enablePcLocation: true, //允许PC端定位并选择位置
|
|
87
|
+
},
|
|
88
|
+
description,
|
|
89
|
+
label,
|
|
90
|
+
lineWidth: parseInt(fieldWidth, 10),
|
|
91
|
+
tab: null,
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { tool } from 'ai';
|
|
3
|
+
import { buildWidgetName } from '../utils/index.js';
|
|
4
|
+
|
|
5
|
+
export const buildMemberGroupSelectField = tool({
|
|
6
|
+
name: 'buildMemberGroupSelectField',
|
|
7
|
+
description:
|
|
8
|
+
'Build a team member multipyle select field for a form. The field allows users to select multiple members from own orgnization.',
|
|
9
|
+
inputSchema: z.object({
|
|
10
|
+
label: z.string().min(1).max(100),
|
|
11
|
+
placeholder: z.string().min(1).max(100).optional(),
|
|
12
|
+
required: z.boolean().default(false),
|
|
13
|
+
fieldWidth: z.enum(['3', '4', '6', '8', '9', '12']).default('12'),
|
|
14
|
+
description: z.string().min(1).max(100).optional(),
|
|
15
|
+
}),
|
|
16
|
+
execute: (input) => {
|
|
17
|
+
const { label, required, fieldWidth, description } = input;
|
|
18
|
+
return {
|
|
19
|
+
widget: {
|
|
20
|
+
type: 'usergroup',
|
|
21
|
+
widgetName: buildWidgetName(),
|
|
22
|
+
widgetNameAlias: '',
|
|
23
|
+
customCls: null,
|
|
24
|
+
height: '34',
|
|
25
|
+
width: 350,
|
|
26
|
+
enable: true,
|
|
27
|
+
visible: true,
|
|
28
|
+
allowBlank: !required,
|
|
29
|
+
labelStyle: label,
|
|
30
|
+
funMode: 'module',
|
|
31
|
+
module: null,
|
|
32
|
+
libs: [],
|
|
33
|
+
extendSet: {
|
|
34
|
+
sort: ['datahelp', 'module', 'formEvent'],
|
|
35
|
+
status: true,
|
|
36
|
+
triggerField: '',
|
|
37
|
+
triggerFieldMode: 'none',
|
|
38
|
+
version: 1,
|
|
39
|
+
},
|
|
40
|
+
noRepeat: false,
|
|
41
|
+
limit: {},
|
|
42
|
+
limitWidget: null, //可选范围 由部门字段确定,如果有值 是 _widget_1762226067008 这种,另一个部门字段的id。和limit互斥,limit将为[]
|
|
43
|
+
valueOption: 0,
|
|
44
|
+
},
|
|
45
|
+
description,
|
|
46
|
+
label,
|
|
47
|
+
lineWidth: parseInt(fieldWidth),
|
|
48
|
+
tab: null,
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|