@qingflow-tech/qingflow-cli 1.0.33 → 1.0.35
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/SKILL.md +2 -2
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_BUILDER_APP_DELIVERY_WORKFLOW.md +10 -7
- 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_BUILDER_WORKSPACE_ICONS.md +1 -1
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md +2 -0
- package/skills/qingflow-cli/reference/QINGFLOW_CLI_SCHEMA_APPLY_FIELD_TYPES_AND_SCENARIOS.md +3 -3
- package/src/qingflow_mcp/builder_facade/models.py +50 -1
- package/src/qingflow_mcp/builder_facade/service.py +9 -9
- package/src/qingflow_mcp/cli/commands/builder.py +33 -5
- package/src/qingflow_mcp/tools/ai_builder_tools.py +402 -13
- 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.35
|
|
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.35 qingflow
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Environment:
|
package/package.json
CHANGED
package/pyproject.toml
CHANGED
|
@@ -10,7 +10,7 @@ description: |
|
|
|
10
10
|
|
|
11
11
|
**硬约束(必读)**:正文各节与文末「命令速查」中的命令**只作子命令形态索引**,不覆盖 JSON 结构、`--*-file` 键名、枚举全集、执行顺序与排障细节。凡工作**偏复杂**(多步串联、大块 payload、导入全链、**Builder 搭建向**(应用/schema/流程/布局/视图/门户/报表/按钮/关联资源的配置与发布、系统列与字段 `type`)、契约型 `apply`、按 schema 组织写入 payload、任务下钻与 `task action` 等),或你判断当前任务与「关联文件」里某篇所描述的内容**需求一致、场景相同或大体同类**,都应**先 Read 对应 `reference/*.md`**,再结合 `qingflow … --help` 与 **[EXPLORATION_REPORT](./reference/QINGFLOW_CLI_EXPLORATION_REPORT.md)**。**禁止**仅凭索引、习惯或类比去补参数、臆造字段名或推断服务端行为。**最终统计结论、分析报告、趋势/排名/比例/分布等数据分析,必须转交 `qingflow-record-analysis`,统一走 `record_access -> Python/pandas`。**
|
|
12
12
|
|
|
13
|
-
> **CLI**:当前验证包为 `@qingflow-tech/qingflow-cli`(查版本优先用 `qingflow --version`;需要 JSON 时用 `qingflow --json version
|
|
13
|
+
> **CLI**:当前验证包为 `@qingflow-tech/qingflow-cli`(查版本优先用 `qingflow --version`;需要 JSON 时用 `qingflow --json version`)。**搭建/创建/系统配置**:先区分 **完整系统/应用包** 与 **单应用**。完整系统必须走 `builder package apply -> builder schema apply --apps-file`,单应用才走 `builder schema apply --app-key` 或 `--package-id --app-name --create-if-missing`;随后再按 **[APP_DELIVERY](./reference/QINGFLOW_CLI_BUILDER_APP_DELIVERY_WORKFLOW.md)** → **[VIEWS](./reference/QINGFLOW_CLI_BUILDER_VIEWS_WORKFLOW.md)** / **[PORTAL](./reference/QINGFLOW_CLI_BUILDER_PORTAL_WORKFLOW.md)** / **[CHARTS](./reference/QINGFLOW_CLI_BUILDER_CHARTS_WORKFLOW.md)** 选读。仅成员读数速通仍可先打开 **[MEMBER_CHEATSHEET](./reference/QINGFLOW_CLI_MEMBER_CHEATSHEET.md)**。
|
|
14
14
|
|
|
15
15
|
## 关联文件
|
|
16
16
|
|
|
@@ -419,7 +419,7 @@ qingflow auth logout --forget-persisted
|
|
|
419
419
|
| **app / portal / view / chart** | `app list [--query 关键词]` → **`app get --app-key`**(`accessible_views` / `view_id`、`import_capability`)· `builder package list [--query 关键词]` → `builder package get --package-id` · `portal list` · `portal get --dash-key` · `view get --view-id`(只读视图元信息;`baseInfo` 或 `viewConfig` 只有 40002 / 40027 / 404 这类权限/缺失边界可用另一侧降级,非权限类后端错误不隐藏;解析 app 仅依赖同源 view/form 与可见应用树,不回退旧应用搜索)· `chart get --chart-id`(图表 `baseInfo` / 数据 / 配置分阶段读取;单个辅助阶段 40002 / 40027 / 404 只作为 warning,非权限类后端错误不隐藏) |
|
|
420
420
|
| **record** | `record schema insert`(新建记录 insert-ready schema,仅 `--app-key`)· **`browse`/`list`/`access`:`--app-key` + `--view-id`(缺一常 CONFIG)** · `record list --query ... [--query-field FIELD_ID] [--page-size N]` 用于候选定位/样本浏览 · `record get --record-id` 读详情页首屏上下文 · `record logs --record-id` 读完整数据/流程日志 JSONL · `record insert --items-file`(单条也是 items 一行)· `schema update --record-id [--view-id]` / **`update`**(单条 `--fields-file` **或** 批量 `--items-file`/`--dry-run`,二者勿混)· `export start/direct --view-id` 仅用于明确导出文件 · **`delete`/大 schema**:先 **[FIELD_DATA_TYPES](./reference/QINGFLOW_CLI_FIELD_DATA_TYPES.md)** / **[RECORD_CREATE](./reference/QINGFLOW_CLI_RECORD_CREATE_WORKFLOW.md)** / **[RECORD_UPDATE](./reference/QINGFLOW_CLI_RECORD_UPDATE_WORKFLOW.md)**,再 `-h` |
|
|
421
421
|
| **import** | `record schema import?` · `import template` → `verify` → `repair?` → `start`(**`being-enter-auditing` 必填**)→ `status`(**三者 selector 只选一**);导入权限预检的 `baseInfo` 只有 40002 / 40027 / 404 可降级为 unknown,非权限错误不能当成无导入权或继续执行;**链路与本机目录**只靠本节不够 → **[RECORD_IMPORT](./reference/QINGFLOW_CLI_RECORD_IMPORT_WORKFLOW.md)** |
|
|
422
|
-
| **builder** |
|
|
422
|
+
| **builder** | **搭建/系统化配置**:先读 `builder contract`。**完整系统/应用包**:`builder package apply --config-file` → `builder schema apply --apps-file`(`--apps-file` 可为数组或 `{package_id, apps}` 对象;同批 relation 用 `target_app_ref` 或 `target_app`)→ layout/views/flow/portal/charts。**单应用**:`app resolve/get` → `schema/layout/flow/views apply`。图标可用 `icon/color`、`icon_name/icon_color`、`icon_config` 或 `icon:{name,color}`;选择字段 `options` 可用字符串数组或 `{label,value}` 对象数组。与普通读数/`record insert` 不是同一路径 → **[APP_DELIVERY](./reference/QINGFLOW_CLI_BUILDER_APP_DELIVERY_WORKFLOW.md)**、[ICONS](./reference/QINGFLOW_CLI_BUILDER_WORKSPACE_ICONS.md)、[VIEWS](./reference/QINGFLOW_CLI_BUILDER_VIEWS_WORKFLOW.md)、[PORTAL](./reference/QINGFLOW_CLI_BUILDER_PORTAL_WORKFLOW.md)、[CHARTS](./reference/QINGFLOW_CLI_BUILDER_CHARTS_WORKFLOW.md) |
|
|
423
423
|
| **task**(须落盘见上文) | `task list [--task-box][--flow-status][--app-key][--query] --page --page-size`(**枚举、`--query`、与 `record` 视图口径勿混**:见上文 SOP · **[TASK_CONTEXT](./reference/QINGFLOW_CLI_TASK_CONTEXT_WORKFLOW.md)**)· **`get`/`log`/`report`/`action`**:默认只传 `task list` 返回的 **`data.items[].task_id`**;`report` 另须必选 **`--report-id`**;`action` **无 `--dry-run`** |
|
|
424
424
|
|
|
425
425
|
**高发必败**:旧应用搜索入口 · **`record list`/`browse`/`access` 缺 `--view-id`** · **`task report` 缺 `--report-id`** · **`record update` 批量与单条参数混用**。
|
|
@@ -138,13 +138,14 @@ qingflow builder schema apply \
|
|
|
138
138
|
--apps-file tmp/apps.json
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
-
`apps.json`
|
|
141
|
+
`apps.json` 可以是数组,也可以是 `{ "package_id": 123, "apps": [...] }` 对象。每个 `apps[]` 是一个应用 schema 配置;同批应用之间的关联字段用 `target_app_ref` 指向另一个应用的 `client_key`,或用 `target_app` 指向另一个 `app_name`:
|
|
142
142
|
|
|
143
143
|
```json
|
|
144
144
|
[
|
|
145
145
|
{
|
|
146
146
|
"client_key": "employee",
|
|
147
147
|
"app_name": "员工花名册",
|
|
148
|
+
"icon": {"name": "business-personalcard", "color": "emerald"},
|
|
148
149
|
"add_fields": [
|
|
149
150
|
{"name": "员工名称", "type": "text", "as_data_title": true}
|
|
150
151
|
]
|
|
@@ -152,6 +153,7 @@ qingflow builder schema apply \
|
|
|
152
153
|
{
|
|
153
154
|
"client_key": "worklog",
|
|
154
155
|
"app_name": "工时表",
|
|
156
|
+
"icon": {"name": "clock", "color": "blue"},
|
|
155
157
|
"add_fields": [
|
|
156
158
|
{"name": "工时标题", "type": "text", "as_data_title": true},
|
|
157
159
|
{
|
|
@@ -169,7 +171,7 @@ qingflow builder schema apply \
|
|
|
169
171
|
- 返回里看 `mode=multi_app`、`apps[].app_key`、`created_app_keys` 和 `apps[].status`。
|
|
170
172
|
- 多应用 schema apply 不做事务回滚;如果部分失败,只补失败的 `apps[].row_number`,不要整批重复提交。
|
|
171
173
|
- 这个模式只负责应用壳与字段;视图、按钮、关联资源、报表仍拿返回的 `app_key` 继续走各自 apply 工具。
|
|
172
|
-
- 同批 `relation` 优先用 `target_app_ref` 指向 `client_key
|
|
174
|
+
- 同批 `relation` 优先用 `target_app_ref` 指向 `client_key`;也可用 `target_app` 指向同批 `app_name`。不要先分别建应用、再为了补 `target_app_key` 做第二轮字段修补。
|
|
173
175
|
|
|
174
176
|
**`visibility` JSON**(`--visibility-file`):与包/应用通用,键见契约 `allowed_values.visibility.*`:
|
|
175
177
|
|
|
@@ -271,7 +273,7 @@ qingflow builder flow apply \
|
|
|
271
273
|
| **`datetime`** | 同上。 |
|
|
272
274
|
| **`member`** | **`name`**、**`required`**;成员选择器,无额外 scope 键(与 **department** 不同)。 |
|
|
273
275
|
| **`department`** | **`department_scope`**:`mode: all \| custom`;**`custom`** 时 **`departments[]`** 须含 **`dept_id`**(可选 **`dept_name`** 辅助)、**`include_sub_departs`**。 |
|
|
274
|
-
| **`single_select`** / **`multi_select`** | **`options`
|
|
276
|
+
| **`single_select`** / **`multi_select`** | **`options` 可用字符串数组**,如 `["A", "B"]`,也可用对象数组如 `[{"label":"A","value":"a"}]`;工具会归一化为选项文案。可选 **`required`**。 |
|
|
275
277
|
| **`phone`** / **`email`** | 标准校验类字段,**`name` + required**。 |
|
|
276
278
|
| **`address`** | 地址复合字段。 |
|
|
277
279
|
| **`attachment`** | 附件。 |
|
|
@@ -315,13 +317,14 @@ qingflow builder flow apply \
|
|
|
315
317
|
|
|
316
318
|
## 7. 系统字段与视图系统列(必读)
|
|
317
319
|
|
|
318
|
-
### 7.1
|
|
320
|
+
### 7.1 平台系统字段 / 视图系统列(不可当普通字段去 `add_fields` / 录入)
|
|
319
321
|
|
|
320
|
-
|
|
322
|
+
平台会自动生成或维护这些系统字段 / 系统列,不要在创建表单时手工造同名控件,也不要在录入数据时写入:
|
|
321
323
|
|
|
322
|
-
|
|
324
|
+
**`数据ID`**、**`编号`**、**`申请人`**、**`申请时间`**、**`创建人`**、**`创建时间`**、**`提交人`**、**`提交时间`**、**`更新时间`**、**`更新人`**、**`当前流程状态`**、**`当前处理人`**、**`当前处理节点`**、**`流程标题`**。
|
|
323
325
|
|
|
324
|
-
-
|
|
326
|
+
- **含义**:这些是平台维护的系统信息,**不要**在 **`add_fields`** 里手工造同名控件来「模拟」,也不要写进 `record insert` 的 `fields` / `items[].fields`。
|
|
327
|
+
- **视图列例外**:`builder views apply` 对部分系统列名会过滤并警告(`ignored_system_columns`);新建/更新业务视图至少要包含一个真实业务字段。
|
|
325
328
|
- **与 `app_get_fields` 的关系**:读回 **`fields[]`** 侧重 **表单搭建字段**;**编号 / 申请人** 等可能不会作为普通 `type` 出现在列表中(视应用模板与工作流是否开启),**以读回 JSON 为准**。交付时 **业务字段** 用 **`app_get_fields`**;**系统列** 由平台在 **数据列表 / 视图** 侧展示。
|
|
326
329
|
|
|
327
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": {
|
|
@@ -17,7 +17,7 @@ qingflow --json builder icon catalog
|
|
|
17
17
|
## 关键规则
|
|
18
18
|
|
|
19
19
|
- CLI 不会根据业务名称自动猜图标。
|
|
20
|
-
-
|
|
20
|
+
- 智能体必须自己选择业务贴合的图标和颜色;CLI/MCP 可接受 `icon + color`、`icon_name + icon_color`、`icon_config` 或 `icon: {name, color}`,最终都会归一化为 `icon/color`。
|
|
21
21
|
- 创建应用包、应用、门户时缺少 `icon` 或 `color` 会失败。
|
|
22
22
|
- 同批多应用创建时,每个新应用应使用不同 `icon`。
|
|
23
23
|
- 编辑已有资源时,不传 `icon/color` 会保留现状;显式传入时仍会校验合法性。
|
|
@@ -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`。
|
package/skills/qingflow-cli/reference/QINGFLOW_CLI_SCHEMA_APPLY_FIELD_TYPES_AND_SCENARIOS.md
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
|
|
42
42
|
| `type` | 通常必填 | 常见可选 / 约束 |
|
|
43
43
|
|--------|----------|-----------------|
|
|
44
|
-
| 标量与选择器 | `name` + `type`(+ 业务 `required` 等) | `description`、`required`;新建应用时其中一个顶层可读字段须 `as_data_title: true`;**`single_select` / `multi_select` 的 `options`
|
|
44
|
+
| 标量与选择器 | `name` + `type`(+ 业务 `required` 等) | `description`、`required`;新建应用时其中一个顶层可读字段须 `as_data_title: true`;**`single_select` / `multi_select` 的 `options` 可用字符串数组或对象数组**,如 `["A", "B"]` 或 `[{"label":"A","value":"a"}]`,工具会归一化为选项文案 |
|
|
45
45
|
| `department` | 同左 | **`department_scope`**:`mode: all \| custom`;`custom` 时 **`departments[]`**(含 `dept_id` 等) |
|
|
46
46
|
| `relation` | **`target_app_key`**、**`display_field`**、**`visible_fields[]`** | **`relation_mode`**;目标应用元数据不可读时可多写 **`name`** 降级 |
|
|
47
47
|
| `subtable` | **`subfields[]` 非空** | 子列递归同父级规则;更新已存在子列优先契约 **`subfield_updates`** |
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
|------|----------------|------|
|
|
59
59
|
| 编辑已有应用 | `--app-key`;可选 `--no-publish` | **不要**与 `--package-id`、`--create-if-missing` 同用 |
|
|
60
60
|
| 包内新建应用 | `--package-id`、`--app-name`(或 title 映射)、**`--create-if-missing`**;初始 `add-fields-file` 至少包含一个 `as_data_title: true` 字段 | 创建后可得到新 **`app_key`**(以响应为准) |
|
|
61
|
-
| 多应用一次性新建 | `--package-id`、**`--create-if-missing`**、`--apps-file` | 应用包/系统里有 2 个以上应用,或同批应用之间有 `relation`
|
|
61
|
+
| 多应用一次性新建 | `--package-id`、**`--create-if-missing`**、`--apps-file` | 应用包/系统里有 2 个以上应用,或同批应用之间有 `relation` 时使用;`--apps-file` 可为数组或 `{package_id, apps}` 对象;`apps[].client_key` 可被 `target_app_ref` 引用,`apps[].app_name` 可被 `target_app` 引用 |
|
|
62
62
|
| 仅增字段 | `--add-fields-file`(JSON 数组) | 与 **`update_fields`/`remove_fields`** 可同次组合(以契约为准) |
|
|
63
63
|
| 改字段 | `--update-fields-file` | 每项 **`selector`**(`name`/`que_id`/`field_id`)+ **`set`** |
|
|
64
64
|
| 删字段 | `--remove-fields-file` | 每项至少 **`name`/`que_id`/`field_id`** 之一 |
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
|
|
83
83
|
**一次性新建应用**:`--package-id` + `--app-name` + `--create-if-missing` + [schema_apply_add_fields_all_types.json](./schema_apply_add_fields_all_types.json) 是当前推荐示例;它已包含唯一数据标题和可选数据封面(`q_linker` 使用 `https://httpbin.org/get`,`relation` 指向可读模板应用 `ead8ims5i401`)。
|
|
84
84
|
|
|
85
|
-
**一次性新建多个应用**:用 `builder schema apply --package-id <TAG_ID> --create-if-missing --apps-file tmp/apps.json`;`apps[].client_key` 可被同批 relation 字段的 `target_app_ref` 引用,工具会编译成真实 `target_app_key`。这是应用包/系统搭建的默认路径,尤其适合“商机 + 订单 + 回款”“花名册 + 工时”等互相关联场景;不要为了拿 `app_key` 先逐个创建再二次补关联字段。
|
|
85
|
+
**一次性新建多个应用**:用 `builder schema apply --package-id <TAG_ID> --create-if-missing --apps-file tmp/apps.json`;`apps[].client_key` 可被同批 relation 字段的 `target_app_ref` 引用,`apps[].app_name` 可被 `target_app` 引用,工具会编译成真实 `target_app_key`。这是应用包/系统搭建的默认路径,尤其适合“商机 + 订单 + 回款”“花名册 + 工时”等互相关联场景;不要为了拿 `app_key` 先逐个创建再二次补关联字段。
|
|
86
86
|
|
|
87
87
|
**限制(平台硬性)**:每应用 **至多一个** `relation`;`--app-key` 向已有应用追加时须 **字段名不重复**、且 **不能**在已有 relation 上再增第二个。**`example.com`** 作 `q_linker` URL 易触发 **`46031`**,本清单改用 httpbin。**读回缺 `outputs[].target_field` 的 `q_linker`** 会拖死后续 `schema apply`,须修复或删除该题。
|
|
88
88
|
|
|
@@ -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() != ""
|
|
@@ -2292,6 +2311,8 @@ def _normalize_field_payload(value: Any) -> Any:
|
|
|
2292
2311
|
payload = dict(value)
|
|
2293
2312
|
if "fields" in payload and "subfields" not in payload:
|
|
2294
2313
|
payload["subfields"] = payload.pop("fields")
|
|
2314
|
+
if "options" in payload:
|
|
2315
|
+
payload["options"] = _normalize_field_options(payload.get("options"))
|
|
2295
2316
|
raw_type = payload.get("type")
|
|
2296
2317
|
if isinstance(raw_type, int):
|
|
2297
2318
|
normalized_from_id = FIELD_TYPE_ID_ALIASES.get(raw_type)
|
|
@@ -2324,6 +2345,34 @@ def _normalize_field_payload(value: Any) -> Any:
|
|
|
2324
2345
|
return payload
|
|
2325
2346
|
|
|
2326
2347
|
|
|
2348
|
+
def _normalize_field_options(value: Any) -> Any:
|
|
2349
|
+
if not isinstance(value, list):
|
|
2350
|
+
return value
|
|
2351
|
+
normalized: list[str] = []
|
|
2352
|
+
for item in value:
|
|
2353
|
+
if isinstance(item, str):
|
|
2354
|
+
normalized.append(item)
|
|
2355
|
+
continue
|
|
2356
|
+
if isinstance(item, (int, float, bool)):
|
|
2357
|
+
normalized.append(str(item))
|
|
2358
|
+
continue
|
|
2359
|
+
if isinstance(item, dict):
|
|
2360
|
+
label = (
|
|
2361
|
+
item.get("label")
|
|
2362
|
+
or item.get("name")
|
|
2363
|
+
or item.get("title")
|
|
2364
|
+
or item.get("value")
|
|
2365
|
+
or item.get("text")
|
|
2366
|
+
or item.get("optValue")
|
|
2367
|
+
or item.get("optName")
|
|
2368
|
+
)
|
|
2369
|
+
if label is not None:
|
|
2370
|
+
normalized.append(str(label))
|
|
2371
|
+
continue
|
|
2372
|
+
normalized.append(str(item))
|
|
2373
|
+
return normalized
|
|
2374
|
+
|
|
2375
|
+
|
|
2327
2376
|
def _slugify_title(title: str) -> str:
|
|
2328
2377
|
normalized = "".join(ch.lower() if ch.isalnum() else "_" for ch in str(title or ""))
|
|
2329
2378
|
collapsed = "_".join(part for part in normalized.split("_") if part)
|
|
@@ -15049,14 +15049,14 @@ def _build_public_chart_filter_matrix(
|
|
|
15049
15049
|
return []
|
|
15050
15050
|
group: list[dict[str, Any]] = []
|
|
15051
15051
|
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:
|
|
15052
|
+
ViewFilterOperator.eq.value: "equal",
|
|
15053
|
+
ViewFilterOperator.neq.value: "unequal",
|
|
15054
|
+
ViewFilterOperator.gte.value: "greaterOrEqual",
|
|
15055
|
+
ViewFilterOperator.lte.value: "lessOrEqual",
|
|
15056
|
+
ViewFilterOperator.in_.value: "anyMatch",
|
|
15057
|
+
ViewFilterOperator.contains.value: "include",
|
|
15058
|
+
ViewFilterOperator.is_empty.value: "isNull",
|
|
15059
|
+
ViewFilterOperator.not_empty.value: "notNull",
|
|
15060
15060
|
}
|
|
15061
15061
|
for rule in rules:
|
|
15062
15062
|
qingbi_field = _resolve_qingbi_chart_field(
|
|
@@ -15074,7 +15074,7 @@ def _build_public_chart_filter_matrix(
|
|
|
15074
15074
|
"fieldId": field_id,
|
|
15075
15075
|
"fieldName": qingbi_field.get("fieldName") or form_field.get("name") or field_id,
|
|
15076
15076
|
"fieldType": qingbi_field.get("fieldType") or _qingbi_field_type_from_public_field(str(form_field.get("type") or "")),
|
|
15077
|
-
"judgeType": judge_map.get(operator,
|
|
15077
|
+
"judgeType": judge_map.get(operator, "equal"),
|
|
15078
15078
|
"judgeValues": values,
|
|
15079
15079
|
"matchType": 1,
|
|
15080
15080
|
}
|
|
@@ -4,6 +4,7 @@ import argparse
|
|
|
4
4
|
|
|
5
5
|
from ..context import CliContext
|
|
6
6
|
from .common import load_list_arg, load_object_arg, raise_config_error, require_list_arg
|
|
7
|
+
from ..json_io import load_json_value
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
def register(subparsers: argparse._SubParsersAction[argparse.ArgumentParser]) -> None:
|
|
@@ -476,26 +477,30 @@ def _handle_chart_get(args: argparse.Namespace, context: CliContext) -> dict:
|
|
|
476
477
|
|
|
477
478
|
|
|
478
479
|
def _handle_schema_apply(args: argparse.Namespace, context: CliContext) -> dict:
|
|
479
|
-
|
|
480
|
+
apps_payload = _load_apps_file_arg(args.apps_file)
|
|
481
|
+
apps = apps_payload["apps"]
|
|
482
|
+
package_id = args.package_id
|
|
483
|
+
if package_id is None and apps_payload.get("package_id") is not None:
|
|
484
|
+
package_id = int(apps_payload["package_id"])
|
|
480
485
|
if args.apps_file:
|
|
481
486
|
if not apps:
|
|
482
487
|
raise_config_error(
|
|
483
488
|
"schema apply multi-app mode requires a non-empty --apps-file.",
|
|
484
|
-
fix_hint="Pass a JSON array with at least one app item.",
|
|
489
|
+
fix_hint="Pass a JSON array, or a JSON object like {\"package_id\":1001,\"apps\":[...]} with at least one app item.",
|
|
485
490
|
)
|
|
486
491
|
if args.app_key or args.app_name or args.app_title or args.add_fields_file or args.update_fields_file or args.remove_fields_file:
|
|
487
492
|
raise_config_error(
|
|
488
493
|
"schema apply multi-app mode accepts --package-id/--create-if-missing plus --apps-file only.",
|
|
489
494
|
fix_hint="Use `--apps-file` for batch mode, or remove `--apps-file` and use the single-app arguments.",
|
|
490
495
|
)
|
|
491
|
-
if
|
|
496
|
+
if package_id is None:
|
|
492
497
|
raise_config_error(
|
|
493
498
|
"schema apply multi-app mode requires --package-id.",
|
|
494
|
-
fix_hint="Pass `--package-id`
|
|
499
|
+
fix_hint="Pass `--package-id`, or put `package_id` at the top level of --apps-file. `package_name` alone does not create the package here; run `builder package apply` first.",
|
|
495
500
|
)
|
|
496
501
|
return context.builder.app_schema_apply(
|
|
497
502
|
profile=args.profile,
|
|
498
|
-
package_id=
|
|
503
|
+
package_id=package_id,
|
|
499
504
|
visibility=load_object_arg(args.visibility_file, option_name="--visibility-file"),
|
|
500
505
|
create_if_missing=bool(args.create_if_missing),
|
|
501
506
|
publish=bool(args.publish),
|
|
@@ -537,6 +542,29 @@ def _handle_schema_apply(args: argparse.Namespace, context: CliContext) -> dict:
|
|
|
537
542
|
)
|
|
538
543
|
|
|
539
544
|
|
|
545
|
+
def _load_apps_file_arg(path: str | None) -> dict[str, object]:
|
|
546
|
+
if not path:
|
|
547
|
+
return {"apps": []}
|
|
548
|
+
payload = load_json_value(path, option_name="--apps-file")
|
|
549
|
+
if isinstance(payload, list):
|
|
550
|
+
return {"apps": payload}
|
|
551
|
+
if isinstance(payload, dict):
|
|
552
|
+
apps = payload.get("apps")
|
|
553
|
+
if not isinstance(apps, list):
|
|
554
|
+
raise_config_error(
|
|
555
|
+
"--apps-file JSON object requires an apps array.",
|
|
556
|
+
fix_hint="Use {\"package_id\":1001,\"apps\":[...]} or pass a raw JSON array.",
|
|
557
|
+
)
|
|
558
|
+
result: dict[str, object] = {"apps": apps}
|
|
559
|
+
if payload.get("package_id") is not None:
|
|
560
|
+
result["package_id"] = payload.get("package_id")
|
|
561
|
+
return result
|
|
562
|
+
raise_config_error(
|
|
563
|
+
"--apps-file must be a JSON array or an object containing apps.",
|
|
564
|
+
fix_hint="Use [{...}] or {\"package_id\":1001,\"apps\":[...]}",
|
|
565
|
+
)
|
|
566
|
+
|
|
567
|
+
|
|
540
568
|
def _handle_layout_apply(args: argparse.Namespace, context: CliContext) -> dict:
|
|
541
569
|
return context.builder.app_layout_apply(
|
|
542
570
|
profile=args.profile,
|
|
@@ -146,8 +146,11 @@ class AiBuilderTools(ToolBase):
|
|
|
146
146
|
package_id: int | None = None,
|
|
147
147
|
package_name: str | None = None,
|
|
148
148
|
create_if_missing: bool = False,
|
|
149
|
-
icon: str | None = None,
|
|
149
|
+
icon: str | JSONObject | None = None,
|
|
150
150
|
color: str | None = None,
|
|
151
|
+
icon_name: str | None = None,
|
|
152
|
+
icon_color: str | None = None,
|
|
153
|
+
icon_config: JSONObject | None = None,
|
|
151
154
|
visibility: JSONObject | None = None,
|
|
152
155
|
items: list[dict] | None = None,
|
|
153
156
|
allow_detach: bool = False,
|
|
@@ -159,6 +162,9 @@ class AiBuilderTools(ToolBase):
|
|
|
159
162
|
create_if_missing=create_if_missing,
|
|
160
163
|
icon=icon,
|
|
161
164
|
color=color,
|
|
165
|
+
icon_name=icon_name,
|
|
166
|
+
icon_color=icon_color,
|
|
167
|
+
icon_config=icon_config,
|
|
162
168
|
visibility=visibility,
|
|
163
169
|
items=items or None,
|
|
164
170
|
allow_detach=allow_detach,
|
|
@@ -364,8 +370,11 @@ class AiBuilderTools(ToolBase):
|
|
|
364
370
|
package_id: int | None = None,
|
|
365
371
|
app_name: str = "",
|
|
366
372
|
app_title: str = "",
|
|
367
|
-
icon: str = "",
|
|
373
|
+
icon: str | JSONObject = "",
|
|
368
374
|
color: str = "",
|
|
375
|
+
icon_name: str | None = None,
|
|
376
|
+
icon_color: str | None = None,
|
|
377
|
+
icon_config: JSONObject | None = None,
|
|
369
378
|
visibility: JSONObject | None = None,
|
|
370
379
|
create_if_missing: bool = False,
|
|
371
380
|
publish: bool = True,
|
|
@@ -423,6 +432,9 @@ class AiBuilderTools(ToolBase):
|
|
|
423
432
|
app_title=app_title,
|
|
424
433
|
icon=icon,
|
|
425
434
|
color=color,
|
|
435
|
+
icon_name=icon_name,
|
|
436
|
+
icon_color=icon_color,
|
|
437
|
+
icon_config=icon_config,
|
|
426
438
|
visibility=visibility,
|
|
427
439
|
create_if_missing=create_if_missing,
|
|
428
440
|
publish=publish,
|
|
@@ -733,13 +745,23 @@ class AiBuilderTools(ToolBase):
|
|
|
733
745
|
package_id: int | None = None,
|
|
734
746
|
package_name: str | None = None,
|
|
735
747
|
create_if_missing: bool = False,
|
|
736
|
-
icon: str | None = None,
|
|
748
|
+
icon: str | JSONObject | None = None,
|
|
737
749
|
color: str | None = None,
|
|
750
|
+
icon_name: str | None = None,
|
|
751
|
+
icon_color: str | None = None,
|
|
752
|
+
icon_config: JSONObject | None = None,
|
|
738
753
|
visibility: JSONObject | None = None,
|
|
739
754
|
items: list[dict] | None = None,
|
|
740
755
|
allow_detach: bool = False,
|
|
741
756
|
) -> JSONObject:
|
|
742
757
|
"""执行分组与包相关逻辑。"""
|
|
758
|
+
icon, color = _normalize_builder_icon_args(
|
|
759
|
+
icon=icon,
|
|
760
|
+
color=color,
|
|
761
|
+
icon_name=icon_name,
|
|
762
|
+
icon_color=icon_color,
|
|
763
|
+
icon_config=icon_config,
|
|
764
|
+
)
|
|
743
765
|
visibility_patch = None
|
|
744
766
|
if visibility is not None:
|
|
745
767
|
try:
|
|
@@ -1459,6 +1481,22 @@ class AiBuilderTools(ToolBase):
|
|
|
1459
1481
|
remove_fields: list[JSONObject],
|
|
1460
1482
|
) -> JSONObject:
|
|
1461
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
|
|
1462
1500
|
try:
|
|
1463
1501
|
request = SchemaPlanRequest.model_validate(
|
|
1464
1502
|
{
|
|
@@ -1609,6 +1647,15 @@ class AiBuilderTools(ToolBase):
|
|
|
1609
1647
|
preset: str | None = None,
|
|
1610
1648
|
) -> JSONObject:
|
|
1611
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
|
|
1612
1659
|
try:
|
|
1613
1660
|
request = ViewsPlanRequest.model_validate(
|
|
1614
1661
|
{
|
|
@@ -1650,8 +1697,11 @@ class AiBuilderTools(ToolBase):
|
|
|
1650
1697
|
package_id: int | None = None,
|
|
1651
1698
|
app_name: str = "",
|
|
1652
1699
|
app_title: str = "",
|
|
1653
|
-
icon: str = "",
|
|
1700
|
+
icon: str | JSONObject = "",
|
|
1654
1701
|
color: str = "",
|
|
1702
|
+
icon_name: str | None = None,
|
|
1703
|
+
icon_color: str | None = None,
|
|
1704
|
+
icon_config: JSONObject | None = None,
|
|
1655
1705
|
visibility: JSONObject | None = None,
|
|
1656
1706
|
create_if_missing: bool = False,
|
|
1657
1707
|
publish: bool = True,
|
|
@@ -1661,7 +1711,15 @@ class AiBuilderTools(ToolBase):
|
|
|
1661
1711
|
apps: list[JSONObject] | None = None,
|
|
1662
1712
|
) -> JSONObject:
|
|
1663
1713
|
"""执行应用相关逻辑。"""
|
|
1714
|
+
icon, color = _normalize_builder_icon_args(
|
|
1715
|
+
icon=icon,
|
|
1716
|
+
color=color,
|
|
1717
|
+
icon_name=icon_name,
|
|
1718
|
+
icon_color=icon_color,
|
|
1719
|
+
icon_config=icon_config,
|
|
1720
|
+
)
|
|
1664
1721
|
if apps:
|
|
1722
|
+
apps = [_normalize_schema_app_item(item) if isinstance(item, dict) else item for item in apps]
|
|
1665
1723
|
result = self._app_schema_apply_multi(
|
|
1666
1724
|
profile=profile,
|
|
1667
1725
|
package_id=package_id,
|
|
@@ -1725,6 +1783,17 @@ class AiBuilderTools(ToolBase):
|
|
|
1725
1783
|
}
|
|
1726
1784
|
if visibility is not None:
|
|
1727
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
|
|
1728
1797
|
if package_id is None:
|
|
1729
1798
|
return _config_failure(
|
|
1730
1799
|
tool_name="app_schema_apply",
|
|
@@ -1801,6 +1870,7 @@ class AiBuilderTools(ToolBase):
|
|
|
1801
1870
|
)
|
|
1802
1871
|
|
|
1803
1872
|
client_key_to_app_key: dict[str, str] = {}
|
|
1873
|
+
app_name_to_app_key: dict[str, str] = {}
|
|
1804
1874
|
created_app_keys: list[str] = []
|
|
1805
1875
|
results: list[JSONObject] = []
|
|
1806
1876
|
any_write_executed = False
|
|
@@ -1864,11 +1934,14 @@ class AiBuilderTools(ToolBase):
|
|
|
1864
1934
|
created_app_keys.append(resolved_key)
|
|
1865
1935
|
if client_key:
|
|
1866
1936
|
client_key_to_app_key[client_key] = resolved_key
|
|
1937
|
+
resolved_name = str(public_shell.get("app_name_after") or public_shell.get("app_name") or app_name or "").strip()
|
|
1938
|
+
if resolved_name:
|
|
1939
|
+
app_name_to_app_key[resolved_name] = resolved_key
|
|
1867
1940
|
results.append({
|
|
1868
1941
|
"index": index,
|
|
1869
1942
|
"row_number": index + 1,
|
|
1870
1943
|
"client_key": client_key or None,
|
|
1871
|
-
"app_name":
|
|
1944
|
+
"app_name": resolved_name or None,
|
|
1872
1945
|
"app_key": resolved_key,
|
|
1873
1946
|
"status": "shell_ready",
|
|
1874
1947
|
"created": bool(public_shell.get("created")),
|
|
@@ -1888,7 +1961,7 @@ class AiBuilderTools(ToolBase):
|
|
|
1888
1961
|
item = deepcopy(raw_item)
|
|
1889
1962
|
app_key = str(existing.get("app_key") or "").strip()
|
|
1890
1963
|
try:
|
|
1891
|
-
compiled_item = _compile_multi_app_schema_item_refs(item, client_key_to_app_key)
|
|
1964
|
+
compiled_item = _compile_multi_app_schema_item_refs(item, client_key_to_app_key, app_name_to_app_key)
|
|
1892
1965
|
except ValueError as error:
|
|
1893
1966
|
final_items.append({
|
|
1894
1967
|
**{key: existing.get(key) for key in ("index", "row_number", "client_key", "app_name", "app_key", "created")},
|
|
@@ -2012,6 +2085,23 @@ class AiBuilderTools(ToolBase):
|
|
|
2012
2085
|
) -> JSONObject:
|
|
2013
2086
|
"""执行内部辅助逻辑。"""
|
|
2014
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
|
|
2015
2105
|
icon_failure = _validate_workspace_icon_for_builder(
|
|
2016
2106
|
tool_name="app_schema_apply",
|
|
2017
2107
|
icon=icon,
|
|
@@ -2343,6 +2433,17 @@ class AiBuilderTools(ToolBase):
|
|
|
2343
2433
|
remove_views: list[str],
|
|
2344
2434
|
) -> JSONObject:
|
|
2345
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
|
|
2346
2447
|
if patch_views:
|
|
2347
2448
|
try:
|
|
2348
2449
|
parsed_views = [ViewUpsertPatch.model_validate(item) for item in (upsert_views or [])]
|
|
@@ -2417,7 +2518,7 @@ class AiBuilderTools(ToolBase):
|
|
|
2417
2518
|
"profile": profile,
|
|
2418
2519
|
"app_key": str(plan_args.get("app_key") or app_key),
|
|
2419
2520
|
"publish": publish,
|
|
2420
|
-
"upsert_views": plan_args.get("upsert_views") or [{"name": "
|
|
2521
|
+
"upsert_views": plan_args.get("upsert_views") or [{"name": "业务台账视图", "type": "table", "columns": ["字段A"]}],
|
|
2421
2522
|
"remove_views": plan_args.get("remove_views") or [],
|
|
2422
2523
|
},
|
|
2423
2524
|
},
|
|
@@ -2786,8 +2887,58 @@ def _multi_app_item_failure(index: int, item: object, error_code: str, message:
|
|
|
2786
2887
|
}
|
|
2787
2888
|
|
|
2788
2889
|
|
|
2789
|
-
def
|
|
2890
|
+
def _normalize_builder_icon_args(
|
|
2891
|
+
*,
|
|
2892
|
+
icon: str | JSONObject | None,
|
|
2893
|
+
color: str | None,
|
|
2894
|
+
icon_name: str | None = None,
|
|
2895
|
+
icon_color: str | None = None,
|
|
2896
|
+
icon_config: JSONObject | None = None,
|
|
2897
|
+
) -> tuple[str | None, str | None]:
|
|
2898
|
+
payloads: list[JSONObject] = []
|
|
2899
|
+
if isinstance(icon_config, dict):
|
|
2900
|
+
payloads.append(icon_config)
|
|
2901
|
+
if isinstance(icon, dict):
|
|
2902
|
+
payloads.append(icon)
|
|
2903
|
+
|
|
2904
|
+
normalized_icon = None if isinstance(icon, dict) else icon
|
|
2905
|
+
normalized_color = color
|
|
2906
|
+
for payload in payloads:
|
|
2907
|
+
normalized_icon = normalized_icon or payload.get("icon") or payload.get("icon_name") or payload.get("iconName") or payload.get("name")
|
|
2908
|
+
normalized_color = normalized_color or payload.get("color") or payload.get("icon_color") or payload.get("iconColor")
|
|
2909
|
+
normalized_icon = normalized_icon or icon_name
|
|
2910
|
+
normalized_color = normalized_color or icon_color
|
|
2911
|
+
return (
|
|
2912
|
+
str(normalized_icon).strip() if normalized_icon is not None else None,
|
|
2913
|
+
str(normalized_color).strip() if normalized_color is not None else None,
|
|
2914
|
+
)
|
|
2915
|
+
|
|
2916
|
+
|
|
2917
|
+
def _normalize_schema_app_item(item: JSONObject) -> JSONObject:
|
|
2918
|
+
normalized = deepcopy(item)
|
|
2919
|
+
icon, color = _normalize_builder_icon_args(
|
|
2920
|
+
icon=normalized.get("icon"),
|
|
2921
|
+
color=normalized.get("color"),
|
|
2922
|
+
icon_name=normalized.get("icon_name") or normalized.get("iconName"),
|
|
2923
|
+
icon_color=normalized.get("icon_color") or normalized.get("iconColor"),
|
|
2924
|
+
icon_config=normalized.get("icon_config") or normalized.get("iconConfig"),
|
|
2925
|
+
)
|
|
2926
|
+
if icon:
|
|
2927
|
+
normalized["icon"] = icon
|
|
2928
|
+
if color:
|
|
2929
|
+
normalized["color"] = color
|
|
2930
|
+
for key in ("icon_name", "iconName", "icon_color", "iconColor", "icon_config", "iconConfig"):
|
|
2931
|
+
normalized.pop(key, None)
|
|
2932
|
+
return normalized
|
|
2933
|
+
|
|
2934
|
+
|
|
2935
|
+
def _compile_multi_app_schema_item_refs(
|
|
2936
|
+
item: JSONObject,
|
|
2937
|
+
client_key_to_app_key: dict[str, str],
|
|
2938
|
+
app_name_to_app_key: dict[str, str] | None = None,
|
|
2939
|
+
) -> JSONObject:
|
|
2790
2940
|
compiled = deepcopy(item)
|
|
2941
|
+
app_name_to_app_key = app_name_to_app_key or {}
|
|
2791
2942
|
|
|
2792
2943
|
def visit(value):
|
|
2793
2944
|
if isinstance(value, list):
|
|
@@ -2807,6 +2958,13 @@ def _compile_multi_app_schema_item_refs(item: JSONObject, client_key_to_app_key:
|
|
|
2807
2958
|
if not target_app_key:
|
|
2808
2959
|
raise ValueError(f"target_app_ref '{ref_key}' did not match any apps[].client_key")
|
|
2809
2960
|
payload["target_app_key"] = target_app_key
|
|
2961
|
+
target_app = payload.pop("target_app", None) or payload.pop("targetApp", None)
|
|
2962
|
+
if target_app is not None and not str(payload.get("target_app_key") or "").strip():
|
|
2963
|
+
target_name = str(target_app or "").strip()
|
|
2964
|
+
target_app_key = app_name_to_app_key.get(target_name)
|
|
2965
|
+
if not target_app_key:
|
|
2966
|
+
raise ValueError(f"target_app '{target_name}' did not match any apps[].app_name in the same call")
|
|
2967
|
+
payload["target_app_key"] = target_app_key
|
|
2810
2968
|
return payload
|
|
2811
2969
|
|
|
2812
2970
|
return visit(compiled)
|
|
@@ -2855,7 +3013,7 @@ def _contains_multi_app_target_ref(value: object) -> bool:
|
|
|
2855
3013
|
if not isinstance(value, dict):
|
|
2856
3014
|
return False
|
|
2857
3015
|
for key, entry in value.items():
|
|
2858
|
-
if key in {"target_app_ref", "targetAppRef", "target_app_client_key", "targetAppClientKey"}:
|
|
3016
|
+
if key in {"target_app_ref", "targetAppRef", "target_app_client_key", "targetAppClientKey", "target_app", "targetApp"}:
|
|
2859
3017
|
return True
|
|
2860
3018
|
if _contains_multi_app_target_ref(entry):
|
|
2861
3019
|
return True
|
|
@@ -2968,6 +3126,197 @@ def _visibility_validation_failure(
|
|
|
2968
3126
|
return result
|
|
2969
3127
|
|
|
2970
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
|
+
|
|
2971
3320
|
def _config_failure(
|
|
2972
3321
|
*,
|
|
2973
3322
|
tool_name: str,
|
|
@@ -2976,6 +3325,7 @@ def _config_failure(
|
|
|
2976
3325
|
error_code: str = "CONFIG_ERROR",
|
|
2977
3326
|
details: JSONObject | None = None,
|
|
2978
3327
|
allowed_values: JSONObject | None = None,
|
|
3328
|
+
suggested_next_call: JSONObject | None = None,
|
|
2979
3329
|
) -> JSONObject:
|
|
2980
3330
|
contract = _BUILDER_TOOL_CONTRACTS.get(tool_name or "")
|
|
2981
3331
|
public_allowed_values = deepcopy(contract.get("allowed_values", {})) if isinstance(contract, dict) else {}
|
|
@@ -2996,7 +3346,7 @@ def _config_failure(
|
|
|
2996
3346
|
"missing_fields": [],
|
|
2997
3347
|
"allowed_values": public_allowed_values,
|
|
2998
3348
|
"details": public_details,
|
|
2999
|
-
"suggested_next_call":
|
|
3349
|
+
"suggested_next_call": suggested_next_call,
|
|
3000
3350
|
"request_id": None,
|
|
3001
3351
|
"backend_code": None,
|
|
3002
3352
|
"http_status": None,
|
|
@@ -4054,13 +4404,29 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4054
4404
|
},
|
|
4055
4405
|
},
|
|
4056
4406
|
"package_apply": {
|
|
4057
|
-
"allowed_keys": [
|
|
4407
|
+
"allowed_keys": [
|
|
4408
|
+
"package_id",
|
|
4409
|
+
"package_name",
|
|
4410
|
+
"create_if_missing",
|
|
4411
|
+
"icon",
|
|
4412
|
+
"color",
|
|
4413
|
+
"icon_name",
|
|
4414
|
+
"icon_color",
|
|
4415
|
+
"icon_config",
|
|
4416
|
+
"visibility",
|
|
4417
|
+
"items",
|
|
4418
|
+
"allow_detach",
|
|
4419
|
+
],
|
|
4058
4420
|
"aliases": {
|
|
4059
4421
|
"packageId": "package_id",
|
|
4060
4422
|
"packageName": "package_name",
|
|
4061
4423
|
"createIfMissing": "create_if_missing",
|
|
4062
4424
|
"iconName": "icon",
|
|
4063
4425
|
"iconColor": "color",
|
|
4426
|
+
"icon_config.name": "icon",
|
|
4427
|
+
"icon_config.icon_name": "icon",
|
|
4428
|
+
"icon_config.color": "color",
|
|
4429
|
+
"icon_config.icon_color": "color",
|
|
4064
4430
|
"allowDetach": "allow_detach",
|
|
4065
4431
|
},
|
|
4066
4432
|
"allowed_values": {
|
|
@@ -4072,6 +4438,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4072
4438
|
"execution_notes": [
|
|
4073
4439
|
"create or update package metadata, visibility, grouping, and ordering in one call",
|
|
4074
4440
|
"creating a package requires explicit icon + color; icon=template is blocked because it is too generic",
|
|
4441
|
+
"icon can be passed as icon/color, icon_name/icon_color, icon_config, or icon={name,color}; all forms normalize to icon/color",
|
|
4075
4442
|
"updating a package preserves existing icon/color when omitted; explicit icon/color values are still validated",
|
|
4076
4443
|
"call workspace_icon_catalog_get or `qingflow --json builder icon catalog` for supported icon/color candidates",
|
|
4077
4444
|
"metadata keys omitted on update are preserved",
|
|
@@ -4536,6 +4903,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4536
4903
|
"create mode may set visibility for the new app; edit mode may update visibility on an existing app",
|
|
4537
4904
|
"create mode should include explicit non-template icon + color; apply mode enforces this before writing",
|
|
4538
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",
|
|
4539
4907
|
*_VISIBILITY_EXECUTION_NOTES,
|
|
4540
4908
|
],
|
|
4541
4909
|
"minimal_example": {
|
|
@@ -4575,6 +4943,9 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4575
4943
|
"app_title",
|
|
4576
4944
|
"icon",
|
|
4577
4945
|
"color",
|
|
4946
|
+
"icon_name",
|
|
4947
|
+
"icon_color",
|
|
4948
|
+
"icon_config",
|
|
4578
4949
|
"visibility",
|
|
4579
4950
|
"create_if_missing",
|
|
4580
4951
|
"publish",
|
|
@@ -4587,11 +4958,15 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4587
4958
|
"apps[].app_name",
|
|
4588
4959
|
"apps[].icon",
|
|
4589
4960
|
"apps[].color",
|
|
4961
|
+
"apps[].icon_name",
|
|
4962
|
+
"apps[].icon_color",
|
|
4963
|
+
"apps[].icon_config",
|
|
4590
4964
|
"apps[].visibility",
|
|
4591
4965
|
"apps[].add_fields",
|
|
4592
4966
|
"apps[].update_fields",
|
|
4593
4967
|
"apps[].remove_fields",
|
|
4594
4968
|
"apps[].add_fields[].target_app_ref",
|
|
4969
|
+
"apps[].add_fields[].target_app",
|
|
4595
4970
|
],
|
|
4596
4971
|
"aliases": {
|
|
4597
4972
|
"app_title": "app_name",
|
|
@@ -4601,8 +4976,16 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4601
4976
|
"apps[].appKey": "apps[].app_key",
|
|
4602
4977
|
"apps[].appName": "apps[].app_name",
|
|
4603
4978
|
"apps[].appTitle": "apps[].app_name",
|
|
4979
|
+
"apps[].iconName": "apps[].icon",
|
|
4980
|
+
"apps[].iconColor": "apps[].color",
|
|
4981
|
+
"apps[].icon_config.name": "apps[].icon",
|
|
4982
|
+
"apps[].icon_config.color": "apps[].color",
|
|
4604
4983
|
"field.targetAppRef": "field.target_app_ref",
|
|
4605
4984
|
"field.targetAppClientKey": "field.target_app_ref",
|
|
4985
|
+
"field.targetApp": "field.target_app",
|
|
4986
|
+
"field.options[].label": "field.options[]",
|
|
4987
|
+
"field.options[].value": "field.options[]",
|
|
4988
|
+
"field.options[].optValue": "field.options[]",
|
|
4606
4989
|
"field.title": "field.name",
|
|
4607
4990
|
"field.label": "field.name",
|
|
4608
4991
|
"field.fields": "field.subfields",
|
|
@@ -4642,12 +5025,16 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
4642
5025
|
"create mode follows backend CreateAppBean: package add_app permission is checked on the target package; package edit_app is not required for the create precheck",
|
|
4643
5026
|
"multi-app mode: pass package_id + create_if_missing + apps[]; do not mix apps with top-level app_key/app_name/add_fields/update_fields/remove_fields",
|
|
4644
5027
|
"multi-app relation fields may use target_app_ref to point at another apps[].client_key; the tool creates/resolves app shells first and compiles it to target_app_key",
|
|
5028
|
+
"multi-app relation fields may also use target_app with another apps[].app_name; prefer target_app_ref/client_key when names may collide",
|
|
4645
5029
|
"multi-app mode is not transactional; read created_app_keys and apps[].status before retrying, and retry only failed app items",
|
|
4646
5030
|
"create mode defaults new app visibility to workspace/not when visibility is omitted; edit mode preserves current visibility when omitted",
|
|
4647
5031
|
"create mode requires explicit icon + color; icon=template is blocked because it is too generic",
|
|
5032
|
+
"icon can be passed as icon/color, icon_name/icon_color, icon_config, or icon={name,color}; all forms normalize to icon/color",
|
|
4648
5033
|
"multi-app create mode requires each new app item to include a distinct non-template icon and a valid color",
|
|
5034
|
+
"single_select and multi_select options accept strings or objects such as {label,value}; builder normalizes them to option labels before writing",
|
|
4649
5035
|
"edit mode preserves existing icon/color when omitted; explicit icon/color values are still validated",
|
|
4650
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",
|
|
4651
5038
|
*_VISIBILITY_EXECUTION_NOTES,
|
|
4652
5039
|
"update_fields is the field-level partial update path; it reads current form schema and preserves untouched field config",
|
|
4653
5040
|
"multiple relation fields are backend-risky; read verification.relation_field_limit_verified and warnings before declaring the schema stable",
|
|
@@ -5047,6 +5434,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
5047
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",
|
|
5048
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",
|
|
5049
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",
|
|
5050
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",
|
|
5051
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",
|
|
5052
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",
|
|
@@ -5055,7 +5443,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
5055
5443
|
"minimal_example": {
|
|
5056
5444
|
"profile": "default",
|
|
5057
5445
|
"app_key": "APP_KEY",
|
|
5058
|
-
"upsert_views": [{"name": "
|
|
5446
|
+
"upsert_views": [{"name": "项目台账视图", "type": "table", "columns": ["项目名称"], "visibility": deepcopy(_VISIBILITY_WORKSPACE_EXAMPLE)}],
|
|
5059
5447
|
"remove_views": [],
|
|
5060
5448
|
},
|
|
5061
5449
|
"query_conditions_example": {
|
|
@@ -5176,6 +5564,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
5176
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",
|
|
5177
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",
|
|
5178
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",
|
|
5179
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",
|
|
5180
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",
|
|
5181
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",
|
|
@@ -5185,7 +5574,7 @@ _BUILDER_TOOL_CONTRACTS: dict[str, JSONObject] = {
|
|
|
5185
5574
|
"profile": "default",
|
|
5186
5575
|
"app_key": "APP_KEY",
|
|
5187
5576
|
"publish": True,
|
|
5188
|
-
"upsert_views": [{"name": "
|
|
5577
|
+
"upsert_views": [{"name": "项目台账视图", "type": "table", "columns": ["项目名称"], "visibility": deepcopy(_VISIBILITY_WORKSPACE_EXAMPLE)}],
|
|
5189
5578
|
"remove_views": [],
|
|
5190
5579
|
},
|
|
5191
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
|
*,
|