@qingflow-tech/qingflow-cli 1.0.34 → 1.0.36
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/README.md +2 -2
- package/package.json +1 -1
- package/pyproject.toml +1 -1
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_BUILDER_APP_DELIVERY_WORKFLOW.md +5 -4
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_BUILDER_CHARTS_WORKFLOW.md +9 -1
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_BUILDER_MATCH_RULES.md +15 -0
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_BUILDER_PORTAL_WORKFLOW.md +1 -0
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_BUILDER_VIEWS_WORKFLOW.md +13 -2
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md +2 -0
- package/src/qingflow_mcp/builder_facade/models.py +20 -1
- package/src/qingflow_mcp/builder_facade/service.py +128 -18
- package/src/qingflow_mcp/tools/ai_builder_tools.py +264 -4
- package/src/qingflow_mcp/tools/record_tools.py +38 -1
package/README.md
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Install:
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
|
-
npm install @qingflow-tech/qingflow-cli@1.0.
|
|
6
|
+
npm install @qingflow-tech/qingflow-cli@1.0.36
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
Run:
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npx -y -p @qingflow-tech/qingflow-cli@1.0.
|
|
12
|
+
npx -y -p @qingflow-tech/qingflow-cli@1.0.36 qingflow
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Environment:
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -317,13 +317,14 @@ qingflow builder flow apply \
|
|
|
317
317
|
|
|
318
318
|
## 7. 系统字段与视图系统列(必读)
|
|
319
319
|
|
|
320
|
-
### 7.1
|
|
320
|
+
### 7.1 平台系统字段 / 视图系统列(不可当普通字段去 `add_fields` / 录入)
|
|
321
321
|
|
|
322
|
-
|
|
322
|
+
平台会自动生成或维护这些系统字段 / 系统列,不要在创建表单时手工造同名控件,也不要在录入数据时写入:
|
|
323
323
|
|
|
324
|
-
|
|
324
|
+
**`数据ID`**、**`编号`**、**`申请人`**、**`申请时间`**、**`创建人`**、**`创建时间`**、**`提交人`**、**`提交时间`**、**`更新时间`**、**`更新人`**、**`当前流程状态`**、**`当前处理人`**、**`当前处理节点`**、**`流程标题`**。
|
|
325
325
|
|
|
326
|
-
-
|
|
326
|
+
- **含义**:这些是平台维护的系统信息,**不要**在 **`add_fields`** 里手工造同名控件来「模拟」,也不要写进 `record insert` 的 `fields` / `items[].fields`。
|
|
327
|
+
- **视图列例外**:`builder views apply` 对部分系统列名会过滤并警告(`ignored_system_columns`);新建/更新业务视图至少要包含一个真实业务字段。
|
|
327
328
|
- **与 `app_get_fields` 的关系**:读回 **`fields[]`** 侧重 **表单搭建字段**;**编号 / 申请人** 等可能不会作为普通 `type` 出现在列表中(视应用模板与工作流是否开启),**以读回 JSON 为准**。交付时 **业务字段** 用 **`app_get_fields`**;**系统列** 由平台在 **数据列表 / 视图** 侧展示。
|
|
328
329
|
|
|
329
330
|
### 7.2 布局 / 流程中的「系统行为」
|
|
@@ -56,13 +56,21 @@ qingflow --json builder charts apply \
|
|
|
56
56
|
| **`chart_id`** | 可选。**有则按 id 命中更新**;无则 **按 `name` 精确匹配**:0 个 → **创建**;多个 → **歧义报错**(须带 **`chart_id`**)。 |
|
|
57
57
|
| **`dimension_field_ids`** | 维度字段 id 列表(**字符串**,如 **`field_343283126`**、字段显示名或原始 **`bi_field_id`**);字段必须来自 **`app get fields` 返回的 `chart_fields[]`**。 |
|
|
58
58
|
| **`indicator_field_ids`** | 指标字段 id;字段必须来自 **`chart_fields[]`**;**`target`** 常为空列表(契约 **minimal_example**)。 |
|
|
59
|
-
| **`filters`** |
|
|
59
|
+
| **`filters`** | 统一固定筛选写法:**`field_name`**(可用 **`chart_fields[].title`** / **`field_id`** / **`bi_field_id`** / 别名 **`field`/`fieldName`**)+ **`operator`** + **`values`/`value`** → 写入配置 **`beforeAggregationFilterMatrix`**(除非你在 **`config`** 里自行提供矩阵)。 |
|
|
60
60
|
| **`visibility`** | 可选;编译为 QingBI **`visibleAuth`**;**仅更新 visibility** 时不重算其它授权结构(见契约)。**更新**时 **省略** 可保留原可见性。 |
|
|
61
61
|
| **`config`** | 透传高级键:`aggregate`、`beforeAggregationFilterMatrix`、`afterAggregationFilterMatrix`、`chartStyleConfigs`、`displayLimitConfig`、`rawDataConfigDTO`、`query_condition_field_ids` 等;未列键会 **merge 进根**(实现 **`_build_public_chart_config_payload`**)。不要在 `config` 中把 `dataSourceType` 改成 `dataset`;数据集报表只允许关联已有。 |
|
|
62
62
|
| **`question_config`** / **`user_config`** | 可选;分别 POST **`/chart/{id}/question/config`** 与 **`/user/config`**。 |
|
|
63
63
|
|
|
64
64
|
**配置是否重算**:若已存在图表且本次 **未显式**改 **`dimension_field_ids` / `indicator_field_ids` / `filters` / `config`**(Pydantic **`model_fields_set`**),实现可 **跳过** **`qingbi_report_update_config`**;**新建**总会写配置。
|
|
65
65
|
|
|
66
|
+
**报表筛选 operator**:推荐使用 `eq` / `neq` / `in` / `contains` / `gte` / `lte` / `is_empty` / `not_empty`;兼容 `equal` / `equals` / `=` / `!=` / `any_of` / `one_of` / `empty` 等别名。CLI 会自动转成 QingBI 字符串判断符(如 `equal`、`anyMatch`、`isNull`),智能体不要手写 `judgeType`、`beforeAggregationFilterMatrix`。
|
|
67
|
+
|
|
68
|
+
示例:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{"field_name": "使用状态", "operator": "eq", "value": "正常"}
|
|
72
|
+
```
|
|
73
|
+
|
|
66
74
|
### 3.1 BI 类型与后端字段映射
|
|
67
75
|
|
|
68
76
|
CLI 对外仍推荐使用通用字段:**`dimension_field_ids`** 和 **`indicator_field_ids`**,但字段来源必须是 **`app_get_fields.chart_fields`** 的 QingBI datasource 字段。部分 QingBI 类型后端字段槽位不同,CLI 会自动转换:
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
它不是 `record_access` 分析筛选 DSL,也不是普通视图 `filters`。
|
|
9
9
|
|
|
10
|
+
统一语义:
|
|
11
|
+
|
|
12
|
+
- 固定筛选用 `field_name + operator + value/values`,例如视图 `filters`、报表 `filters`。
|
|
13
|
+
- 当前记录上下文匹配用 `target_field + operator + source_field/value`,例如关联资源 `match_mappings`、新增数据按钮传参。
|
|
14
|
+
- 不要直接写 `judgeType`、`judgeValues`、`matchRules`;CLI 会按目标协议自动编译。
|
|
15
|
+
|
|
10
16
|
---
|
|
11
17
|
|
|
12
18
|
## 1. 默认写法
|
|
@@ -58,6 +64,15 @@
|
|
|
58
64
|
|
|
59
65
|
动态条件用 `source_field`;静态条件用 `value`。
|
|
60
66
|
|
|
67
|
+
`operator` 推荐使用 `eq` / `neq` / `in` / `contains` / `gte` / `lte` / `is_empty` / `not_empty`;兼容 `equal` / `equals` / `=` / `!=` / `any_of` / `one_of` / `empty` 等别名。`field_name` / `field` 可作为 `target_field` 别名;静态单值可写 `value`,也兼容单元素 `values`。
|
|
68
|
+
|
|
69
|
+
示例:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{"target_field": "客户ID", "operator": "eq", "source_field": "数据ID"}
|
|
73
|
+
{"target_field": "状态", "operator": "eq", "value": "有效"}
|
|
74
|
+
```
|
|
75
|
+
|
|
61
76
|
---
|
|
62
77
|
|
|
63
78
|
## 2. 系统字段
|
|
@@ -123,6 +123,7 @@ CLI 校验(`PortalSectionPatch`):**chart** 须 **`chart_ref`**;**view**
|
|
|
123
123
|
- **理论上**与 solution 编译器一致:外层 **`{"filterConfig": [ … ], "graphList": [ … ]}`**;**`graphList`** 常含 **`graphType`**(如 **`CHART`**)、**`graphKey`** 或 **`graphRef`(`entity_id` / `chart_id`)** 等。
|
|
124
124
|
- **本环境 CLI 直写实测(多次 `--publish`)**:在已验证 **chart / view / grid / text / link** 均可落库的前提下,**`source_type: filter` 始终未出现在 `draft_result.components` 中**;尝试过:**空数组**、**仅 `graphList` + QingBI `chart_id`**、**`graphKey` 为门户 `dashChartId`**、**`chart` 排在 **`filter` 前**、**仅 2 块(chart+filter)** 等,回读仍 **只有 chart(`count: 1`)** 或 **五类缺 `type: 6`**。
|
|
125
125
|
**结论**:当前宜 **在搭建界面创建筛选条**,再 **`builder portal get` 反抓** 原始 `filterConfig` 形状;或向后端确认 **POST `/dash/{dashKey}`** 对 **`type: 6`** 的必填字段。**自动化不要默认认为 `filter` 已写入。**
|
|
126
|
+
- portal `filter` 组件仍按 raw `filterConfig` 处理,不纳入视图 / 报表 / 关联资源的统一筛选 DSL 主链路。
|
|
126
127
|
|
|
127
128
|
### 3.5 **`grid` / `text` / `link` / `view`**
|
|
128
129
|
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
> **权限**:视图**新建**走后端 `createViewgraphConfig`,需要同时满足 **视图管理 / ViewManagementAuth**(`beingViewManageStatus`)和 **数据管理 / DataManageAuth**;视图**更新/删除**只走 **ViewManagementAuth**。未开启高级应用权限时 `beingViewManageStatus` 等价回落到 **DataManageAuth**。失败时常见 **40002 / 40161 / 编辑锁**,参见主技能与 **ADMIN** 速查。
|
|
6
6
|
|
|
7
|
+
> **默认系统视图**:`全部数据`、`我的数据`、`我发起的`、`待办`、`已办`、`抄送` 等由轻流自带,**不要新建同名业务视图**。新建视图必须用业务名,例如 `项目台账视图`、`客户跟进视图`、`逾期任务看板`。如果确实要调整默认系统视图,只能从 `app get views` 取已存在的 raw **`view_key`** 后用 `patch_views` 或带 `view_key` 的 `upsert_views` 更新。
|
|
8
|
+
|
|
7
9
|
> **契约**(权威键名、枚举、`execution_notes`、示例):
|
|
8
10
|
> `qingflow --json builder contract --tool-name app_views_apply`
|
|
9
11
|
> (`--tool-name` 为契约索引,用于拉取 **`allowed_keys` / 别名 / 示例**。)
|
|
@@ -79,6 +81,8 @@ CLI 将参数与文件内容拼装为服务层载荷,**顶层键**如下:
|
|
|
79
81
|
|
|
80
82
|
**`partial_success`**:部分视图成功、部分失败时整体仍可能带成功信封,务必读 **`failed`** 与 **`execution_notes`**。
|
|
81
83
|
|
|
84
|
+
**系统默认名禁止新建**:未提供 `view_key` 的 `upsert_views` 不要使用 `全部数据`、`我的数据`、`我发起的`、`待办`、`已办`、`抄送` 这类默认系统视图名。它们不是业务视图模板,而是平台默认对象;新业务视图用具体业务名。
|
|
85
|
+
|
|
82
86
|
---
|
|
83
87
|
|
|
84
88
|
## 5. `type` 与各类型必填
|
|
@@ -101,9 +105,16 @@ CLI 将参数与文件内容拼装为服务层载荷,**顶层键**如下:
|
|
|
101
105
|
### 6.1 `filters`
|
|
102
106
|
|
|
103
107
|
- 项形状:**`field_name`**、**`operator`**、**`values`**(或契约允许的 **`value`** 别名)。
|
|
104
|
-
- **`operator
|
|
108
|
+
- **`operator`**:统一公共语义,推荐 `eq` / `neq` / `in` / `contains` / `gte` / `lte` / `is_empty` / `not_empty`;兼容 `equal` / `equals` / `=` / `!=` / `any_of` / `one_of` / `empty` 等别名(以契约为准)。
|
|
105
109
|
- **`in` 等多值**:传 **列表**;**`value`** 为列表时可作别名。
|
|
106
110
|
- **语义**:固定筛选条件,打开视图即生效。不要把前端查询栏字段写进 `filters`。
|
|
111
|
+
- **内部编译**:视图、按钮显示条件、工作流条件会由 CLI 自动编译成 Qingflow 数字 `judgeType`,智能体不要手写 `judgeType` / `judgeValues`。
|
|
112
|
+
|
|
113
|
+
示例:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{"field_name": "状态", "operator": "eq", "value": "进行中"}
|
|
117
|
+
```
|
|
107
118
|
|
|
108
119
|
### 6.2 `query_conditions`
|
|
109
120
|
|
|
@@ -188,7 +199,7 @@ CLI 将参数与文件内容拼装为服务层载荷,**顶层键**如下:
|
|
|
188
199
|
```json
|
|
189
200
|
[
|
|
190
201
|
{
|
|
191
|
-
"name": "
|
|
202
|
+
"name": "项目台账视图",
|
|
192
203
|
"type": "table",
|
|
193
204
|
"columns": ["项目名称"],
|
|
194
205
|
"visibility": {
|
|
@@ -12,3 +12,5 @@ qingflow --json record insert --app-key <APP_KEY> --items-file tmp/records.json
|
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
不要用 `record schema applicant` 代替 `record_insert_schema_get` 的主路径;新建记录需要 insert-ready schema 里的 `required_fields`、`optional_fields`、`payload_template`、`format_hint` 和 `example_value`。
|
|
15
|
+
|
|
16
|
+
录入数据时不要填写轻流系统字段:`数据ID`、`编号`、`申请人`、`申请时间`、`创建人`、`创建时间`、`提交人`、`提交时间`、`更新时间`、`更新人`、`当前流程状态`、`当前处理人`、`当前处理节点`、`流程标题`。这些字段由平台生成;需要确认时在创建成功后读取记录详情,不要把它们写进 `fields` / `items[].fields`。
|
|
@@ -1259,11 +1259,30 @@ class CustomButtonFieldMappingPatch(StrictModel):
|
|
|
1259
1259
|
|
|
1260
1260
|
|
|
1261
1261
|
class FieldMatchMappingPatch(StrictModel):
|
|
1262
|
-
target_field: Any = Field(
|
|
1262
|
+
target_field: Any = Field(
|
|
1263
|
+
validation_alias=AliasChoices("target_field", "targetField", "target", "field", "field_name", "fieldName")
|
|
1264
|
+
)
|
|
1263
1265
|
source_field: Any | None = Field(default=None, validation_alias=AliasChoices("source_field", "sourceField", "source"))
|
|
1264
1266
|
value: Any | None = Field(default=None, validation_alias=AliasChoices("value", "static_value", "staticValue"))
|
|
1265
1267
|
operator: str = Field(default="eq", validation_alias=AliasChoices("operator", "op", "judge_type", "judgeType"))
|
|
1266
1268
|
|
|
1269
|
+
@model_validator(mode="before")
|
|
1270
|
+
@classmethod
|
|
1271
|
+
def normalize_semantic_aliases(cls, value: Any) -> Any:
|
|
1272
|
+
if not isinstance(value, dict):
|
|
1273
|
+
return value
|
|
1274
|
+
payload = dict(value)
|
|
1275
|
+
has_static_value = any(key in payload for key in ("value", "static_value", "staticValue"))
|
|
1276
|
+
if "values" in payload:
|
|
1277
|
+
values = payload.pop("values")
|
|
1278
|
+
if has_static_value:
|
|
1279
|
+
return payload
|
|
1280
|
+
if isinstance(values, list) and len(values) == 1:
|
|
1281
|
+
payload["value"] = values[0]
|
|
1282
|
+
else:
|
|
1283
|
+
payload["value"] = values
|
|
1284
|
+
return payload
|
|
1285
|
+
|
|
1267
1286
|
@model_validator(mode="after")
|
|
1268
1287
|
def validate_shape(self) -> "FieldMatchMappingPatch":
|
|
1269
1288
|
has_source = self.source_field is not None and str(self.source_field).strip() != ""
|
|
@@ -160,6 +160,7 @@ MATCH_TYPE_ACCURACY = 1
|
|
|
160
160
|
MATCH_TYPE_QUESTION = 2
|
|
161
161
|
JUDGE_EQUAL = 0
|
|
162
162
|
JUDGE_UNEQUAL = 1
|
|
163
|
+
JUDGE_INCLUDE = 2
|
|
163
164
|
JUDGE_GREATER_OR_EQUAL = 5
|
|
164
165
|
JUDGE_LESS_OR_EQUAL = 7
|
|
165
166
|
JUDGE_EQUAL_ANY = 9
|
|
@@ -10125,14 +10126,31 @@ class AiBuilderFacade:
|
|
|
10125
10126
|
expected_filter_summary = _normalize_view_filter_groups_for_compare(expected_filters)
|
|
10126
10127
|
expected_data_scope = "CUSTOM" if expected_filter_summary else "ALL"
|
|
10127
10128
|
actual_data_scope = str(config_result.get("dataScope") or "").strip().upper() or None
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10129
|
+
(
|
|
10130
|
+
filters_semantically_equivalent,
|
|
10131
|
+
semantic_actual_filters,
|
|
10132
|
+
lossy_filter_readbacks,
|
|
10133
|
+
) = _view_filter_groups_semantic_readback(expected_filter_summary, actual_filters)
|
|
10134
|
+
filters_verified = filters_semantically_equivalent and actual_data_scope == expected_data_scope
|
|
10135
|
+
public_expected_filters = _public_view_filter_groups_from_match_rules(
|
|
10136
|
+
expected_filter_summary,
|
|
10137
|
+
current_fields_by_name=current_fields_by_name,
|
|
10138
|
+
)
|
|
10139
|
+
public_actual_filters = _public_view_filter_groups_from_match_rules(
|
|
10140
|
+
semantic_actual_filters,
|
|
10141
|
+
current_fields_by_name=current_fields_by_name,
|
|
10131
10142
|
)
|
|
10132
10143
|
verification_entry["filters_verified"] = filters_verified
|
|
10133
10144
|
verification_entry["view_key"] = verification_key
|
|
10134
|
-
verification_entry["expected_filters"] =
|
|
10135
|
-
verification_entry["actual_filters"] =
|
|
10145
|
+
verification_entry["expected_filters"] = public_expected_filters
|
|
10146
|
+
verification_entry["actual_filters"] = public_actual_filters
|
|
10147
|
+
verification_entry["expected_filters_raw"] = expected_filter_summary
|
|
10148
|
+
if lossy_filter_readbacks:
|
|
10149
|
+
verification_entry["actual_filters_raw"] = actual_filters
|
|
10150
|
+
verification_entry["filter_value_readback_degraded"] = True
|
|
10151
|
+
verification_entry["filter_value_readback_warnings"] = lossy_filter_readbacks
|
|
10152
|
+
elif public_actual_filters != semantic_actual_filters:
|
|
10153
|
+
verification_entry["actual_filters_raw"] = semantic_actual_filters
|
|
10136
10154
|
verification_entry["expected_data_scope"] = expected_data_scope
|
|
10137
10155
|
verification_entry["actual_data_scope"] = actual_data_scope
|
|
10138
10156
|
if not filters_verified:
|
|
@@ -10140,8 +10158,10 @@ class AiBuilderFacade:
|
|
|
10140
10158
|
{
|
|
10141
10159
|
"name": name,
|
|
10142
10160
|
"type": item.get("type"),
|
|
10143
|
-
"expected_filters":
|
|
10144
|
-
"actual_filters":
|
|
10161
|
+
"expected_filters": public_expected_filters,
|
|
10162
|
+
"actual_filters": public_actual_filters,
|
|
10163
|
+
"expected_filters_raw": expected_filter_summary,
|
|
10164
|
+
"actual_filters_raw": actual_filters if lossy_filter_readbacks else semantic_actual_filters,
|
|
10145
10165
|
"expected_data_scope": expected_data_scope,
|
|
10146
10166
|
"actual_data_scope": actual_data_scope,
|
|
10147
10167
|
}
|
|
@@ -15049,14 +15069,14 @@ def _build_public_chart_filter_matrix(
|
|
|
15049
15069
|
return []
|
|
15050
15070
|
group: list[dict[str, Any]] = []
|
|
15051
15071
|
judge_map = {
|
|
15052
|
-
ViewFilterOperator.eq.value:
|
|
15053
|
-
ViewFilterOperator.neq.value:
|
|
15054
|
-
ViewFilterOperator.gte.value:
|
|
15055
|
-
ViewFilterOperator.lte.value:
|
|
15056
|
-
ViewFilterOperator.in_.value:
|
|
15057
|
-
ViewFilterOperator.contains.value:
|
|
15058
|
-
ViewFilterOperator.is_empty.value:
|
|
15059
|
-
ViewFilterOperator.not_empty.value:
|
|
15072
|
+
ViewFilterOperator.eq.value: "equal",
|
|
15073
|
+
ViewFilterOperator.neq.value: "unequal",
|
|
15074
|
+
ViewFilterOperator.gte.value: "greaterOrEqual",
|
|
15075
|
+
ViewFilterOperator.lte.value: "lessOrEqual",
|
|
15076
|
+
ViewFilterOperator.in_.value: "anyMatch",
|
|
15077
|
+
ViewFilterOperator.contains.value: "include",
|
|
15078
|
+
ViewFilterOperator.is_empty.value: "isNull",
|
|
15079
|
+
ViewFilterOperator.not_empty.value: "notNull",
|
|
15060
15080
|
}
|
|
15061
15081
|
for rule in rules:
|
|
15062
15082
|
qingbi_field = _resolve_qingbi_chart_field(
|
|
@@ -15074,7 +15094,7 @@ def _build_public_chart_filter_matrix(
|
|
|
15074
15094
|
"fieldId": field_id,
|
|
15075
15095
|
"fieldName": qingbi_field.get("fieldName") or form_field.get("name") or field_id,
|
|
15076
15096
|
"fieldType": qingbi_field.get("fieldType") or _qingbi_field_type_from_public_field(str(form_field.get("type") or "")),
|
|
15077
|
-
"judgeType": judge_map.get(operator,
|
|
15097
|
+
"judgeType": judge_map.get(operator, "equal"),
|
|
15078
15098
|
"judgeValues": values,
|
|
15079
15099
|
"matchType": 1,
|
|
15080
15100
|
}
|
|
@@ -22586,7 +22606,7 @@ def _translate_flow_condition_rule(*, field: dict[str, Any], rule: dict[str, Any
|
|
|
22586
22606
|
base["judgeType"] = JUDGE_INCLUDE_ANY if field_type in INCLUDE_ANY_FLOW_FIELD_TYPES else JUDGE_EQUAL_ANY
|
|
22587
22607
|
base["judgeValues"] = [_stringify_condition_value(value) for value in values]
|
|
22588
22608
|
elif operator == "contains":
|
|
22589
|
-
base["judgeType"] =
|
|
22609
|
+
base["judgeType"] = JUDGE_INCLUDE
|
|
22590
22610
|
base["judgeValues"] = [_stringify_condition_value(values[0])]
|
|
22591
22611
|
elif operator == "gte":
|
|
22592
22612
|
base["judgeType"] = JUDGE_GREATER_OR_EQUAL
|
|
@@ -24330,7 +24350,7 @@ def _translate_view_filter_rule(*, field: dict[str, Any], rule: dict[str, Any])
|
|
|
24330
24350
|
payload["judgeType"] = JUDGE_INCLUDE_ANY if field_type in INCLUDE_ANY_FLOW_FIELD_TYPES else JUDGE_EQUAL_ANY
|
|
24331
24351
|
payload["judgeValues"] = judge_values
|
|
24332
24352
|
elif operator == "contains":
|
|
24333
|
-
payload["judgeType"] =
|
|
24353
|
+
payload["judgeType"] = JUDGE_INCLUDE
|
|
24334
24354
|
payload["judgeValues"] = judge_values[:1] if judge_values else []
|
|
24335
24355
|
elif operator == "gte":
|
|
24336
24356
|
payload["judgeType"] = JUDGE_GREATER_OR_EQUAL
|
|
@@ -24515,6 +24535,96 @@ def _view_filter_groups_equivalent(expected: Any, actual: Any) -> bool:
|
|
|
24515
24535
|
return _view_filter_groups_signature(expected) == _view_filter_groups_signature(actual)
|
|
24516
24536
|
|
|
24517
24537
|
|
|
24538
|
+
def _view_filter_groups_semantic_readback(expected: Any, actual: Any) -> tuple[bool, list[list[dict[str, Any]]], list[dict[str, Any]]]:
|
|
24539
|
+
expected_groups = _normalize_view_filter_groups_for_compare(expected)
|
|
24540
|
+
actual_groups = _normalize_view_filter_groups_for_compare(actual)
|
|
24541
|
+
if _view_filter_groups_signature(expected_groups) == _view_filter_groups_signature(actual_groups):
|
|
24542
|
+
return True, actual_groups, []
|
|
24543
|
+
if len(expected_groups) != len(actual_groups):
|
|
24544
|
+
return False, actual_groups, []
|
|
24545
|
+
semantic_groups: list[list[dict[str, Any]]] = []
|
|
24546
|
+
lossy_readbacks: list[dict[str, Any]] = []
|
|
24547
|
+
for group_index, (expected_group, actual_group) in enumerate(zip(expected_groups, actual_groups)):
|
|
24548
|
+
if len(expected_group) != len(actual_group):
|
|
24549
|
+
return False, actual_groups, []
|
|
24550
|
+
semantic_group: list[dict[str, Any]] = []
|
|
24551
|
+
for rule_index, (expected_rule, actual_rule) in enumerate(zip(expected_group, actual_group)):
|
|
24552
|
+
if expected_rule.get("queId") != actual_rule.get("queId") or expected_rule.get("judgeType") != actual_rule.get("judgeType"):
|
|
24553
|
+
return False, actual_groups, []
|
|
24554
|
+
expected_values = _view_filter_rule_values_for_signature(expected_rule)
|
|
24555
|
+
actual_values = _view_filter_rule_values_for_signature(actual_rule)
|
|
24556
|
+
if expected_values == actual_values:
|
|
24557
|
+
semantic_group.append(actual_rule)
|
|
24558
|
+
continue
|
|
24559
|
+
if (
|
|
24560
|
+
expected_values
|
|
24561
|
+
and not actual_values
|
|
24562
|
+
and actual_rule.get("judgeType") in {JUDGE_INCLUDE, JUDGE_FUZZY_MATCH}
|
|
24563
|
+
):
|
|
24564
|
+
semantic_rule = deepcopy(actual_rule)
|
|
24565
|
+
semantic_rule["judgeValues"] = expected_values
|
|
24566
|
+
semantic_group.append(semantic_rule)
|
|
24567
|
+
lossy_readbacks.append(
|
|
24568
|
+
{
|
|
24569
|
+
"group_index": group_index,
|
|
24570
|
+
"rule_index": rule_index,
|
|
24571
|
+
"queId": actual_rule.get("queId"),
|
|
24572
|
+
"judgeType": actual_rule.get("judgeType"),
|
|
24573
|
+
"message": "view filter literal value was accepted by write path but omitted by raw viewConfig readback; semantic readback was reconstructed from the write payload",
|
|
24574
|
+
}
|
|
24575
|
+
)
|
|
24576
|
+
continue
|
|
24577
|
+
return False, actual_groups, []
|
|
24578
|
+
semantic_groups.append(semantic_group)
|
|
24579
|
+
return True, semantic_groups, lossy_readbacks
|
|
24580
|
+
|
|
24581
|
+
|
|
24582
|
+
def _public_view_filter_groups_from_match_rules(
|
|
24583
|
+
groups: Any,
|
|
24584
|
+
*,
|
|
24585
|
+
current_fields_by_name: dict[str, dict[str, Any]],
|
|
24586
|
+
) -> list[list[dict[str, Any]]]:
|
|
24587
|
+
fields_by_que_id = {
|
|
24588
|
+
_coerce_positive_int(field.get("que_id")): field
|
|
24589
|
+
for field in current_fields_by_name.values()
|
|
24590
|
+
if isinstance(field, dict) and _coerce_positive_int(field.get("que_id")) is not None
|
|
24591
|
+
}
|
|
24592
|
+
public_groups: list[list[dict[str, Any]]] = []
|
|
24593
|
+
for group in _normalize_view_filter_groups_for_compare(groups):
|
|
24594
|
+
public_group: list[dict[str, Any]] = []
|
|
24595
|
+
for rule in group:
|
|
24596
|
+
que_id = _coerce_positive_int(rule.get("queId")) or 0
|
|
24597
|
+
field = fields_by_que_id.get(que_id) or {}
|
|
24598
|
+
values = _view_filter_rule_values_for_signature(rule)
|
|
24599
|
+
public_rule: dict[str, Any] = {
|
|
24600
|
+
"field_name": str(field.get("name") or rule.get("queTitle") or que_id),
|
|
24601
|
+
"operator": _public_view_filter_operator_from_judge_type(rule.get("judgeType")),
|
|
24602
|
+
}
|
|
24603
|
+
if values:
|
|
24604
|
+
public_rule["values"] = values
|
|
24605
|
+
public_group.append(public_rule)
|
|
24606
|
+
if public_group:
|
|
24607
|
+
public_groups.append(public_group)
|
|
24608
|
+
return public_groups
|
|
24609
|
+
|
|
24610
|
+
|
|
24611
|
+
def _public_view_filter_operator_from_judge_type(judge_type: Any) -> str:
|
|
24612
|
+
normalized = _coerce_positive_int(judge_type)
|
|
24613
|
+
if normalized == JUDGE_EQUAL:
|
|
24614
|
+
return "eq"
|
|
24615
|
+
if normalized == JUDGE_UNEQUAL:
|
|
24616
|
+
return "neq"
|
|
24617
|
+
if normalized in {JUDGE_INCLUDE, JUDGE_FUZZY_MATCH}:
|
|
24618
|
+
return "contains"
|
|
24619
|
+
if normalized in {JUDGE_EQUAL_ANY, JUDGE_INCLUDE_ANY}:
|
|
24620
|
+
return "in"
|
|
24621
|
+
if normalized == JUDGE_GREATER_OR_EQUAL:
|
|
24622
|
+
return "gte"
|
|
24623
|
+
if normalized == JUDGE_LESS_OR_EQUAL:
|
|
24624
|
+
return "lte"
|
|
24625
|
+
return f"judge_type:{judge_type}"
|
|
24626
|
+
|
|
24627
|
+
|
|
24518
24628
|
def _infer_status_field_id(fields: list[dict[str, Any]]) -> str | None:
|
|
24519
24629
|
preferred_names = {"status", "状态", "订单状态", "审批状态", "流程状态"}
|
|
24520
24630
|
for field in fields:
|
|
@@ -1481,6 +1481,22 @@ class AiBuilderTools(ToolBase):
|
|
|
1481
1481
|
remove_fields: list[JSONObject],
|
|
1482
1482
|
) -> JSONObject:
|
|
1483
1483
|
"""执行应用相关逻辑。"""
|
|
1484
|
+
system_field_failure = _reserved_system_field_name_failure(
|
|
1485
|
+
tool_name="app_schema_plan",
|
|
1486
|
+
profile=profile,
|
|
1487
|
+
app_key=app_key,
|
|
1488
|
+
package_id=package_id,
|
|
1489
|
+
app_name=app_name,
|
|
1490
|
+
icon=icon,
|
|
1491
|
+
color=color,
|
|
1492
|
+
visibility=visibility,
|
|
1493
|
+
create_if_missing=create_if_missing,
|
|
1494
|
+
add_fields=add_fields,
|
|
1495
|
+
update_fields=update_fields,
|
|
1496
|
+
remove_fields=remove_fields,
|
|
1497
|
+
)
|
|
1498
|
+
if system_field_failure is not None:
|
|
1499
|
+
return system_field_failure
|
|
1484
1500
|
try:
|
|
1485
1501
|
request = SchemaPlanRequest.model_validate(
|
|
1486
1502
|
{
|
|
@@ -1631,6 +1647,15 @@ class AiBuilderTools(ToolBase):
|
|
|
1631
1647
|
preset: str | None = None,
|
|
1632
1648
|
) -> JSONObject:
|
|
1633
1649
|
"""执行应用相关逻辑。"""
|
|
1650
|
+
reserved_failure = _reserved_system_view_name_failure(
|
|
1651
|
+
tool_name="app_views_plan",
|
|
1652
|
+
profile=profile,
|
|
1653
|
+
app_key=app_key,
|
|
1654
|
+
upsert_views=upsert_views,
|
|
1655
|
+
remove_views=remove_views,
|
|
1656
|
+
)
|
|
1657
|
+
if reserved_failure is not None:
|
|
1658
|
+
return reserved_failure
|
|
1634
1659
|
try:
|
|
1635
1660
|
request = ViewsPlanRequest.model_validate(
|
|
1636
1661
|
{
|
|
@@ -1758,6 +1783,17 @@ class AiBuilderTools(ToolBase):
|
|
|
1758
1783
|
}
|
|
1759
1784
|
if visibility is not None:
|
|
1760
1785
|
normalized_args["visibility"] = deepcopy(visibility)
|
|
1786
|
+
system_field_failure = _reserved_system_field_name_failure_for_apps(
|
|
1787
|
+
tool_name="app_schema_apply",
|
|
1788
|
+
profile=profile,
|
|
1789
|
+
package_id=package_id,
|
|
1790
|
+
visibility=visibility,
|
|
1791
|
+
create_if_missing=create_if_missing,
|
|
1792
|
+
publish=publish,
|
|
1793
|
+
apps=apps,
|
|
1794
|
+
)
|
|
1795
|
+
if system_field_failure is not None:
|
|
1796
|
+
return system_field_failure
|
|
1761
1797
|
if package_id is None:
|
|
1762
1798
|
return _config_failure(
|
|
1763
1799
|
tool_name="app_schema_apply",
|
|
@@ -2049,6 +2085,23 @@ class AiBuilderTools(ToolBase):
|
|
|
2049
2085
|
) -> JSONObject:
|
|
2050
2086
|
"""执行内部辅助逻辑。"""
|
|
2051
2087
|
effective_app_name = app_name or app_title
|
|
2088
|
+
system_field_failure = _reserved_system_field_name_failure(
|
|
2089
|
+
tool_name="app_schema_apply",
|
|
2090
|
+
profile=profile,
|
|
2091
|
+
app_key=app_key,
|
|
2092
|
+
package_id=package_id,
|
|
2093
|
+
app_name=effective_app_name,
|
|
2094
|
+
icon=icon,
|
|
2095
|
+
color=color,
|
|
2096
|
+
visibility=visibility,
|
|
2097
|
+
create_if_missing=create_if_missing,
|
|
2098
|
+
publish=publish,
|
|
2099
|
+
add_fields=add_fields,
|
|
2100
|
+
update_fields=update_fields,
|
|
2101
|
+
remove_fields=remove_fields,
|
|
2102
|
+
)
|
|
2103
|
+
if system_field_failure is not None:
|
|
2104
|
+
return system_field_failure
|
|
2052
2105
|
icon_failure = _validate_workspace_icon_for_builder(
|
|
2053
2106
|
tool_name="app_schema_apply",
|
|
2054
2107
|
icon=icon,
|
|
@@ -2380,6 +2433,17 @@ class AiBuilderTools(ToolBase):
|
|
|
2380
2433
|
remove_views: list[str],
|
|
2381
2434
|
) -> JSONObject:
|
|
2382
2435
|
"""执行内部辅助逻辑。"""
|
|
2436
|
+
reserved_failure = _reserved_system_view_name_failure(
|
|
2437
|
+
tool_name="app_views_apply",
|
|
2438
|
+
profile=profile,
|
|
2439
|
+
app_key=app_key,
|
|
2440
|
+
publish=publish,
|
|
2441
|
+
upsert_views=upsert_views,
|
|
2442
|
+
patch_views=patch_views,
|
|
2443
|
+
remove_views=remove_views,
|
|
2444
|
+
)
|
|
2445
|
+
if reserved_failure is not None:
|
|
2446
|
+
return reserved_failure
|
|
2383
2447
|
if patch_views:
|
|
2384
2448
|
try:
|
|
2385
2449
|
parsed_views = [ViewUpsertPatch.model_validate(item) for item in (upsert_views or [])]
|
|
@@ -2454,7 +2518,7 @@ class AiBuilderTools(ToolBase):
|
|
|
2454
2518
|
"profile": profile,
|
|
2455
2519
|
"app_key": str(plan_args.get("app_key") or app_key),
|
|
2456
2520
|
"publish": publish,
|
|
2457
|
-
"upsert_views": plan_args.get("upsert_views") or [{"name": "
|
|
2521
|
+
"upsert_views": plan_args.get("upsert_views") or [{"name": "业务台账视图", "type": "table", "columns": ["字段A"]}],
|
|
2458
2522
|
"remove_views": plan_args.get("remove_views") or [],
|
|
2459
2523
|
},
|
|
2460
2524
|
},
|
|
@@ -3062,6 +3126,197 @@ def _visibility_validation_failure(
|
|
|
3062
3126
|
return result
|
|
3063
3127
|
|
|
3064
3128
|
|
|
3129
|
+
_RESERVED_SYSTEM_FIELD_NAMES = {
|
|
3130
|
+
"数据ID",
|
|
3131
|
+
"编号",
|
|
3132
|
+
"申请人",
|
|
3133
|
+
"申请时间",
|
|
3134
|
+
"创建人",
|
|
3135
|
+
"创建时间",
|
|
3136
|
+
"提交人",
|
|
3137
|
+
"提交时间",
|
|
3138
|
+
"更新时间",
|
|
3139
|
+
"更新人",
|
|
3140
|
+
"当前流程状态",
|
|
3141
|
+
"当前处理人",
|
|
3142
|
+
"当前处理节点",
|
|
3143
|
+
"流程标题",
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
|
|
3147
|
+
def _field_patch_name(item: object) -> str:
|
|
3148
|
+
if not isinstance(item, dict):
|
|
3149
|
+
return ""
|
|
3150
|
+
value = item.get("name")
|
|
3151
|
+
if value is None:
|
|
3152
|
+
value = item.get("title")
|
|
3153
|
+
if value is None:
|
|
3154
|
+
value = item.get("field_name")
|
|
3155
|
+
if value is None:
|
|
3156
|
+
value = item.get("fieldName")
|
|
3157
|
+
return str(value or "").strip()
|
|
3158
|
+
|
|
3159
|
+
|
|
3160
|
+
def _reserved_system_field_name_failure(
|
|
3161
|
+
*,
|
|
3162
|
+
tool_name: str,
|
|
3163
|
+
profile: str,
|
|
3164
|
+
app_key: str = "",
|
|
3165
|
+
package_id: int | None = None,
|
|
3166
|
+
app_name: str = "",
|
|
3167
|
+
icon: str | None = None,
|
|
3168
|
+
color: str | None = None,
|
|
3169
|
+
visibility: JSONObject | None = None,
|
|
3170
|
+
create_if_missing: bool = False,
|
|
3171
|
+
publish: bool | None = None,
|
|
3172
|
+
add_fields: list[JSONObject] | None = None,
|
|
3173
|
+
update_fields: list[JSONObject] | None = None,
|
|
3174
|
+
remove_fields: list[JSONObject] | None = None,
|
|
3175
|
+
app_index: int | None = None,
|
|
3176
|
+
) -> JSONObject | None:
|
|
3177
|
+
for index, item in enumerate(add_fields or []):
|
|
3178
|
+
name = _field_patch_name(item)
|
|
3179
|
+
if name not in _RESERVED_SYSTEM_FIELD_NAMES:
|
|
3180
|
+
continue
|
|
3181
|
+
suggested_add_fields = [field for field in (add_fields or []) if _field_patch_name(field) not in _RESERVED_SYSTEM_FIELD_NAMES]
|
|
3182
|
+
arguments: JSONObject = {
|
|
3183
|
+
"profile": profile,
|
|
3184
|
+
"app_key": app_key,
|
|
3185
|
+
"package_id": package_id,
|
|
3186
|
+
"app_name": app_name,
|
|
3187
|
+
"icon": icon or "",
|
|
3188
|
+
"color": color or "",
|
|
3189
|
+
"visibility": visibility,
|
|
3190
|
+
"create_if_missing": create_if_missing,
|
|
3191
|
+
"add_fields": suggested_add_fields,
|
|
3192
|
+
"update_fields": update_fields or [],
|
|
3193
|
+
"remove_fields": remove_fields or [],
|
|
3194
|
+
}
|
|
3195
|
+
if publish is not None:
|
|
3196
|
+
arguments["publish"] = publish
|
|
3197
|
+
return _config_failure(
|
|
3198
|
+
tool_name=tool_name,
|
|
3199
|
+
error_code="RESERVED_SYSTEM_FIELD_NAME",
|
|
3200
|
+
message=f"add_fields[{index}].name uses built-in system field name '{name}'",
|
|
3201
|
+
fix_hint="Do not create form fields named 数据ID, 编号, 申请人, 申请时间, 创建人, 创建时间, 提交人, 提交时间, 更新时间, 更新人, 当前流程状态, 当前处理人, 当前处理节点, or 流程标题. These fields are provided by Qingflow. Remove them from add_fields; only reference them where the tool explicitly supports system fields, such as button source_field 数据ID.",
|
|
3202
|
+
details={
|
|
3203
|
+
"reserved_field_names": sorted(_RESERVED_SYSTEM_FIELD_NAMES),
|
|
3204
|
+
"blocked_index": index,
|
|
3205
|
+
"blocked_name": name,
|
|
3206
|
+
"app_index": app_index,
|
|
3207
|
+
},
|
|
3208
|
+
suggested_next_call={"tool_name": tool_name, "arguments": arguments},
|
|
3209
|
+
)
|
|
3210
|
+
return None
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
def _reserved_system_field_name_failure_for_apps(
|
|
3214
|
+
*,
|
|
3215
|
+
tool_name: str,
|
|
3216
|
+
profile: str,
|
|
3217
|
+
package_id: int | None,
|
|
3218
|
+
visibility: JSONObject | None,
|
|
3219
|
+
create_if_missing: bool,
|
|
3220
|
+
publish: bool,
|
|
3221
|
+
apps: list[JSONObject],
|
|
3222
|
+
) -> JSONObject | None:
|
|
3223
|
+
for index, item in enumerate(apps or []):
|
|
3224
|
+
if not isinstance(item, dict):
|
|
3225
|
+
continue
|
|
3226
|
+
failure = _reserved_system_field_name_failure(
|
|
3227
|
+
tool_name=tool_name,
|
|
3228
|
+
profile=profile,
|
|
3229
|
+
app_key=str(item.get("app_key") or item.get("appKey") or ""),
|
|
3230
|
+
package_id=package_id,
|
|
3231
|
+
app_name=str(item.get("app_name") or item.get("appName") or ""),
|
|
3232
|
+
icon=str(item.get("icon") or ""),
|
|
3233
|
+
color=str(item.get("color") or ""),
|
|
3234
|
+
visibility=item.get("visibility") if isinstance(item.get("visibility"), dict) else visibility,
|
|
3235
|
+
create_if_missing=create_if_missing,
|
|
3236
|
+
publish=publish,
|
|
3237
|
+
add_fields=list(item.get("add_fields") or item.get("addFields") or []),
|
|
3238
|
+
update_fields=list(item.get("update_fields") or item.get("updateFields") or []),
|
|
3239
|
+
remove_fields=list(item.get("remove_fields") or item.get("removeFields") or []),
|
|
3240
|
+
app_index=index,
|
|
3241
|
+
)
|
|
3242
|
+
if failure is not None:
|
|
3243
|
+
suggested = deepcopy(failure.get("suggested_next_call") or {})
|
|
3244
|
+
arguments = suggested.get("arguments")
|
|
3245
|
+
if isinstance(arguments, dict):
|
|
3246
|
+
fixed_apps = deepcopy(apps)
|
|
3247
|
+
if isinstance(fixed_apps[index], dict):
|
|
3248
|
+
fixed_apps[index]["add_fields"] = arguments.get("add_fields") or []
|
|
3249
|
+
arguments = {
|
|
3250
|
+
"profile": profile,
|
|
3251
|
+
"package_id": package_id,
|
|
3252
|
+
"visibility": visibility,
|
|
3253
|
+
"create_if_missing": create_if_missing,
|
|
3254
|
+
"publish": publish,
|
|
3255
|
+
"apps": fixed_apps,
|
|
3256
|
+
}
|
|
3257
|
+
failure["suggested_next_call"] = {"tool_name": tool_name, "arguments": arguments}
|
|
3258
|
+
return failure
|
|
3259
|
+
return None
|
|
3260
|
+
|
|
3261
|
+
|
|
3262
|
+
_RESERVED_SYSTEM_VIEW_NAMES = {
|
|
3263
|
+
"全部数据",
|
|
3264
|
+
"我的数据",
|
|
3265
|
+
"我发起的",
|
|
3266
|
+
"待办",
|
|
3267
|
+
"已办",
|
|
3268
|
+
"抄送",
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
|
|
3272
|
+
def _reserved_system_view_name_failure(
|
|
3273
|
+
*,
|
|
3274
|
+
tool_name: str,
|
|
3275
|
+
profile: str,
|
|
3276
|
+
app_key: str,
|
|
3277
|
+
publish: bool | None = None,
|
|
3278
|
+
upsert_views: list[JSONObject] | None = None,
|
|
3279
|
+
patch_views: list[JSONObject] | None = None,
|
|
3280
|
+
remove_views: list[str] | None = None,
|
|
3281
|
+
) -> JSONObject | None:
|
|
3282
|
+
for index, item in enumerate(upsert_views or []):
|
|
3283
|
+
if not isinstance(item, dict):
|
|
3284
|
+
continue
|
|
3285
|
+
name = str(item.get("name") or "").strip()
|
|
3286
|
+
view_key = str(item.get("view_key") or item.get("viewKey") or "").strip()
|
|
3287
|
+
if name in _RESERVED_SYSTEM_VIEW_NAMES and not view_key:
|
|
3288
|
+
suggested: JSONObject = {
|
|
3289
|
+
"tool_name": tool_name,
|
|
3290
|
+
"arguments": {
|
|
3291
|
+
"profile": profile,
|
|
3292
|
+
"app_key": app_key,
|
|
3293
|
+
"upsert_views": [
|
|
3294
|
+
{
|
|
3295
|
+
**item,
|
|
3296
|
+
"name": "业务台账视图",
|
|
3297
|
+
}
|
|
3298
|
+
],
|
|
3299
|
+
"patch_views": patch_views or [],
|
|
3300
|
+
"remove_views": remove_views or [],
|
|
3301
|
+
},
|
|
3302
|
+
}
|
|
3303
|
+
if publish is not None:
|
|
3304
|
+
suggested["arguments"]["publish"] = publish
|
|
3305
|
+
return _config_failure(
|
|
3306
|
+
tool_name=tool_name,
|
|
3307
|
+
error_code="RESERVED_SYSTEM_VIEW_NAME",
|
|
3308
|
+
message=f"upsert_views[{index}].name uses built-in system view name '{name}' without view_key",
|
|
3309
|
+
fix_hint="Do not create business views named 全部数据, 我的数据, 我发起的, 待办, 已办, or 抄送. Use a business-specific view name for new views; to modify a built-in view, pass its existing raw view_key or use patch_views.",
|
|
3310
|
+
details={
|
|
3311
|
+
"reserved_view_names": sorted(_RESERVED_SYSTEM_VIEW_NAMES),
|
|
3312
|
+
"blocked_index": index,
|
|
3313
|
+
"blocked_name": name,
|
|
3314
|
+
},
|
|
3315
|
+
suggested_next_call=suggested,
|
|
3316
|
+
)
|
|
3317
|
+
return None
|
|
3318
|
+
|
|
3319
|
+
|
|
3065
3320
|
def _config_failure(
|
|
3066
3321
|
*,
|
|
3067
3322
|
tool_name: str,
|
|
@@ -3070,6 +3325,7 @@ def _config_failure(
|
|
|
3070
3325
|
error_code: str = "CONFIG_ERROR",
|
|
3071
3326
|
details: JSONObject | None = None,
|
|
3072
3327
|
allowed_values: JSONObject | None = None,
|
|
3328
|
+
suggested_next_call: JSONObject | None = None,
|
|
3073
3329
|
) -> JSONObject:
|
|
3074
3330
|
contract = _BUILDER_TOOL_CONTRACTS.get(tool_name or "")
|
|
3075
3331
|
public_allowed_values = deepcopy(contract.get("allowed_values", {})) if isinstance(contract, dict) else {}
|
|
@@ -3090,7 +3346,7 @@ def _config_failure(
|
|
|
3090
3346
|
"missing_fields": [],
|
|
3091
3347
|
"allowed_values": public_allowed_values,
|
|
3092
3348
|
"details": public_details,
|
|
3093
|
-
"suggested_next_call":
|
|
3349
|
+
"suggested_next_call": suggested_next_call,
|
|
3094
3350
|
"request_id": None,
|
|
3095
3351
|
"backend_code": None,
|
|
3096
3352
|
"http_status": None,
|
|
@@ -4647,6 +4903,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4647
4903
|
"create mode may set visibility for the new app; edit mode may update visibility on an existing app",
|
|
4648
4904
|
"create mode should include explicit non-template icon + color; apply mode enforces this before writing",
|
|
4649
4905
|
"call workspace_icon_catalog_get or `qingflow --json builder icon catalog` for supported icon/color candidates",
|
|
4906
|
+
"do not add form fields named 数据ID, 编号, 申请人, 申请时间, 创建人, 创建时间, 提交人, 提交时间, 更新时间, 更新人, 当前流程状态, 当前处理人, 当前处理节点, or 流程标题; these are Qingflow built-in system fields, not fields to create",
|
|
4650
4907
|
*_VISIBILITY_EXECUTION_NOTES,
|
|
4651
4908
|
],
|
|
4652
4909
|
"minimal_example": {
|
|
@@ -4777,6 +5034,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4777
5034
|
"single_select and multi_select options accept strings or objects such as {label,value}; builder normalizes them to option labels before writing",
|
|
4778
5035
|
"edit mode preserves existing icon/color when omitted; explicit icon/color values are still validated",
|
|
4779
5036
|
"call workspace_icon_catalog_get or `qingflow --json builder icon catalog` for supported icon/color candidates",
|
|
5037
|
+
"do not add form fields named 数据ID, 编号, 申请人, 申请时间, 创建人, 创建时间, 提交人, 提交时间, 更新时间, 更新人, 当前流程状态, 当前处理人, 当前处理节点, or 流程标题; these are Qingflow built-in system fields, not fields to create",
|
|
4780
5038
|
*_VISIBILITY_EXECUTION_NOTES,
|
|
4781
5039
|
"update_fields is the field-level partial update path; it reads current form schema and preserves untouched field config",
|
|
4782
5040
|
"multiple relation fields are backend-risky; read verification.relation_field_limit_verified and warnings before declaring the schema stable",
|
|
@@ -5176,6 +5434,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
5176
5434
|
"use patch_views for partial parameter replacement on existing views; the tool reads current config, merges patch_views[].set/unset, then submits the backend full-save payload internally",
|
|
5177
5435
|
"remove_views accepts a raw view_key or an exact unique view name; after DELETE the tool verifies deletion by single view_key readback, not by a full app view list",
|
|
5178
5436
|
"deleted views return verification.by_view[].delete_executed, readback_status, and safe_to_retry_delete=false; if readback is pending, do not blindly repeat the delete",
|
|
5437
|
+
"do not create business views named 全部数据, 我的数据, 我发起的, 待办, 已办, or 抄送; these are built-in system/default views. Use business-specific names for new views, and pass the existing raw view_key or patch_views when changing a built-in view",
|
|
5179
5438
|
"new views created by app_views_apply default associated report/view display to visible with limit_type=all; existing views preserve their current associated display unless patch_views/upsert_views explicitly changes associated_resources",
|
|
5180
5439
|
"associated report/view resource pool and per-view selected resources are configured through app_associated_resources_apply; app_views_apply only keeps legacy associated_resources input compatible",
|
|
5181
5440
|
"for multi-value operators such as in, pass values as a list; value may also be used as an alias when it already contains a list",
|
|
@@ -5184,7 +5443,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
5184
5443
|
"minimal_example": {
|
|
5185
5444
|
"profile": "default",
|
|
5186
5445
|
"app_key": "APP_KEY",
|
|
5187
|
-
"upsert_views": [{"name": "
|
|
5446
|
+
"upsert_views": [{"name": "项目台账视图", "type": "table", "columns": ["项目名称"], "visibility": deepcopy(_VISIBILITY_WORKSPACE_EXAMPLE)}],
|
|
5188
5447
|
"remove_views": [],
|
|
5189
5448
|
},
|
|
5190
5449
|
"query_conditions_example": {
|
|
@@ -5305,6 +5564,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
5305
5564
|
"use patch_views for partial parameter replacement on existing views; the public update mode is patch even though the backend save is still a full view payload",
|
|
5306
5565
|
"remove_views accepts a raw view_key or an exact unique view name; after DELETE the tool verifies deletion by single view_key readback, not by a full app view list",
|
|
5307
5566
|
"deleted views return verification.by_view[].delete_executed, readback_status, and safe_to_retry_delete=false; if readback is pending, do not blindly repeat the delete",
|
|
5567
|
+
"do not create business views named 全部数据, 我的数据, 我发起的, 待办, 已办, or 抄送; these are built-in system/default views. Use business-specific names for new views, and pass the existing raw view_key or patch_views when changing a built-in view",
|
|
5308
5568
|
"new views created by app_views_apply default associated report/view display to visible with limit_type=all; existing views preserve their current associated display unless patch_views/upsert_views explicitly changes associated_resources",
|
|
5309
5569
|
"associated report/view resource pool and per-view selected resources are configured through app_associated_resources_apply; app_views_apply keeps legacy associated_resources input compatible but it is no longer the recommended public contract",
|
|
5310
5570
|
"for multi-value operators such as in, pass values as a list; value may also be used as an alias when it already contains a list",
|
|
@@ -5314,7 +5574,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
5314
5574
|
"profile": "default",
|
|
5315
5575
|
"app_key": "APP_KEY",
|
|
5316
5576
|
"publish": True,
|
|
5317
|
-
"upsert_views": [{"name": "
|
|
5577
|
+
"upsert_views": [{"name": "项目台账视图", "type": "table", "columns": ["项目名称"], "visibility": deepcopy(_VISIBILITY_WORKSPACE_EXAMPLE)}],
|
|
5318
5578
|
"remove_views": [],
|
|
5319
5579
|
},
|
|
5320
5580
|
"query_conditions_example": {
|
|
@@ -75,6 +75,22 @@ MAX_SUMMARY_PREVIEW_COLUMN_LIMIT = 6
|
|
|
75
75
|
VERIFY_TASK_FALLBACK_PAGE_SIZE = 50
|
|
76
76
|
VERIFY_TASK_FALLBACK_MAX_PAGES = 3
|
|
77
77
|
BACKEND_LIST_SEARCH_FIELD_LIMIT = 10
|
|
78
|
+
RECORD_WRITE_SYSTEM_FIELD_NAMES = {
|
|
79
|
+
"数据ID",
|
|
80
|
+
"编号",
|
|
81
|
+
"申请人",
|
|
82
|
+
"申请时间",
|
|
83
|
+
"创建人",
|
|
84
|
+
"创建时间",
|
|
85
|
+
"提交人",
|
|
86
|
+
"提交时间",
|
|
87
|
+
"更新时间",
|
|
88
|
+
"更新人",
|
|
89
|
+
"当前流程状态",
|
|
90
|
+
"当前处理人",
|
|
91
|
+
"当前处理节点",
|
|
92
|
+
"流程标题",
|
|
93
|
+
}
|
|
78
94
|
LOOKUP_RESOLUTION_MIN_SCORE = 0.92
|
|
79
95
|
LOOKUP_RESOLUTION_MIN_MARGIN = 0.08
|
|
80
96
|
LOOKUP_CONFIRMATION_CANDIDATE_LIMIT = 5
|
|
@@ -3649,6 +3665,7 @@ class RecordTools(ToolBase):
|
|
|
3649
3665
|
raise_tool_error(QingflowApiError.config_error("app_key is required"))
|
|
3650
3666
|
if items is not None:
|
|
3651
3667
|
normalized_items = self._normalize_public_record_insert_batch_items(fields=fields, items=items)
|
|
3668
|
+
self._reject_record_insert_system_fields([cast(JSONObject, item["fields"]) for item in normalized_items])
|
|
3652
3669
|
return self._record_insert_public_batch(
|
|
3653
3670
|
profile=profile,
|
|
3654
3671
|
app_key=app_key,
|
|
@@ -3658,15 +3675,35 @@ class RecordTools(ToolBase):
|
|
|
3658
3675
|
)
|
|
3659
3676
|
if fields is not None and not isinstance(fields, dict):
|
|
3660
3677
|
raise_tool_error(QingflowApiError.config_error("fields must be an object map keyed by field title"))
|
|
3678
|
+
normalized_fields = cast(JSONObject, fields or {})
|
|
3679
|
+
self._reject_record_insert_system_fields([normalized_fields])
|
|
3661
3680
|
return self._record_insert_public_single(
|
|
3662
3681
|
profile=profile,
|
|
3663
3682
|
app_key=app_key,
|
|
3664
|
-
fields=
|
|
3683
|
+
fields=normalized_fields,
|
|
3665
3684
|
verify_write=verify_write,
|
|
3666
3685
|
output_profile=normalized_output_profile,
|
|
3667
3686
|
capture_exceptions=False,
|
|
3668
3687
|
)
|
|
3669
3688
|
|
|
3689
|
+
def _reject_record_insert_system_fields(self, field_maps: list[JSONObject]) -> None:
|
|
3690
|
+
for row_index, field_map in enumerate(field_maps):
|
|
3691
|
+
for field_name in field_map:
|
|
3692
|
+
normalized_name = str(field_name or "").strip()
|
|
3693
|
+
if normalized_name in RECORD_WRITE_SYSTEM_FIELD_NAMES:
|
|
3694
|
+
raise_tool_error(
|
|
3695
|
+
QingflowApiError.config_error(
|
|
3696
|
+
f"record_insert fields must not include built-in system field '{normalized_name}'",
|
|
3697
|
+
details={
|
|
3698
|
+
"error_code": "RESERVED_SYSTEM_FIELD_NAME",
|
|
3699
|
+
"row_number": row_index + 1,
|
|
3700
|
+
"field_name": normalized_name,
|
|
3701
|
+
"reserved_field_names": sorted(RECORD_WRITE_SYSTEM_FIELD_NAMES),
|
|
3702
|
+
"fix_hint": "Remove Qingflow built-in system fields from record_insert payload. They are generated by the platform and can be read after creation, not manually inserted.",
|
|
3703
|
+
},
|
|
3704
|
+
)
|
|
3705
|
+
)
|
|
3706
|
+
|
|
3670
3707
|
def _record_insert_public_single(
|
|
3671
3708
|
self,
|
|
3672
3709
|
*,
|