bpmax-cli 0.2.1-beta.19 → 0.2.1-beta.20
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/dist/bin.js +699 -34
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-api-platform-editor/SKILL.md +24 -31
- package/skills/bpmax-api-platform-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-api-platform-editor/references/platform-api-map.md +2 -2
- package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +3 -3
- package/skills/bpmax-builder-shared/template_script_hard_rules.py +3 -1
- package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +16 -0
- package/skills/bpmax-console-template-editor/SKILL.md +109 -523
- package/skills/bpmax-console-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-console-template-editor/references/full-detail-guide.md +45 -0
- package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +13 -12
- package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +65 -78
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +86 -30
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +124 -594
- package/skills/bpmax-dataset-field-template-editor/references/full-detail-guide.md +570 -0
- package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +1 -1
- package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +11 -77
- package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +4 -57
- package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +2 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +4 -78
- package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +3 -89
- package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +14 -0
- package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +2 -0
- package/skills/bpmax-dataset-template-editor/SKILL.md +112 -778
- package/skills/bpmax-dataset-template-editor/references/full-detail-guide.md +753 -0
- package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +1 -0
- package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +2 -2
- package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +9 -90
- package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +1 -2
- package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +8 -1
- package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +8 -1
- package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +6 -40
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +8 -4
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +111 -552
- package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +11 -3
- package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +6 -5
- package/skills/bpmax-e2e-flow-test-operator/references/full-detail-guide.md +563 -0
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +4 -4
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +1 -1
- package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +3 -1
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +7 -5
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +2 -2
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +5 -1
- package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +71 -0
- package/skills/bpmax-filter-template-editor/SKILL.md +110 -551
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +18 -18
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +29 -26
- package/skills/bpmax-filter-template-editor/references/full-detail-guide.md +56 -0
- package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +10 -9
- package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +7 -57
- package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +4 -48
- package/skills/bpmax-flow-template-editor/SKILL.md +109 -1151
- package/skills/bpmax-flow-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-flow-template-editor/references/diff-strategy.md +3 -3
- package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +9 -9
- package/skills/bpmax-flow-template-editor/references/full-detail-guide.md +1155 -0
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +1 -1
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +3 -3
- package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +7 -7
- package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +2 -2
- package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +2 -2
- package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +7 -23
- package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +1 -1
- package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +19 -75
- package/skills/bpmax-form-template-editor/SKILL.md +111 -1151
- package/skills/bpmax-form-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +51 -51
- package/skills/bpmax-form-template-editor/references/full-detail-guide.md +1108 -0
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +4 -4
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +1 -1
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +8 -0
- package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +42 -19
- package/skills/bpmax-list-template-editor/SKILL.md +110 -466
- package/skills/bpmax-list-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-list-template-editor/references/full-detail-guide.md +454 -0
- package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +6 -9
- package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +1 -1
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +9 -78
- package/skills/bpmax-nav-config-editor/SKILL.md +13 -17
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +2 -2
- package/skills/bpmax-nav-config-editor/references/runtime-probing.md +11 -12
- package/skills/bpmax-project/SKILL.md +1 -0
- package/skills/bpmax-project-detail-template-editor/SKILL.md +11 -33
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-role-editor/SKILL.md +7 -30
- package/skills/bpmax-user-mock-operator/SKILL.md +1 -1
- package/skills/bpmax-user-mock-operator/agents/openai.yaml +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
interface:
|
|
2
2
|
display_name: "BPMAX Console Template Editor"
|
|
3
|
-
short_description: "
|
|
4
|
-
default_prompt: "使用 $bpmax-console-template-editor
|
|
3
|
+
short_description: "通过 bpmax-cli typed config 创建或编辑 BPMAX 数据看板模板"
|
|
4
|
+
default_prompt: "使用 $bpmax-console-template-editor 通过 bpmax-cli typed config 创建或编辑 BPMAX 数据看板模板,并用回读验证确认结果。"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Console Template Archive Guide
|
|
2
|
+
|
|
3
|
+
> Archive reference for details that used to live in `../SKILL.md`. The active entrypoint is `../SKILL.md`; this file preserves historical decisions and case lessons without weakening the typed CLI write path.
|
|
4
|
+
|
|
5
|
+
## 常驻结论
|
|
6
|
+
- 看板模板是 `flow_page_template.type = 4`。
|
|
7
|
+
- `content.layout[]` 是模块主结构;`search_temp_id` 是看板绑定筛选器的入口。
|
|
8
|
+
- 模板写入必须走 `bpmax-cli config console-template ...` typed CLI。
|
|
9
|
+
- 运行态页面只用于只读展示和真实用户身份 E2E 验收,不是配置写入入口。
|
|
10
|
+
|
|
11
|
+
## 历史经验
|
|
12
|
+
|
|
13
|
+
### 真实结构优先
|
|
14
|
+
编辑前必须先 export/readback 线上模板。仓库镜像、旧请求样例和记忆只能做候选线索。
|
|
15
|
+
|
|
16
|
+
### 局部需求不能扩大范围
|
|
17
|
+
只改模块标题时,默认不改 `dataSource`、筛选器绑定、layout 坐标和其它模块。任何联动改动都必须归入 `required-collateral` 并逐项确认。
|
|
18
|
+
|
|
19
|
+
### 统计类看板必须下推查询
|
|
20
|
+
库存、销量、项目数等统计不能拉大批明细到前端循环计数。优先使用 ES aggregation,并说明事实源、状态口径、排除口径和分组键。
|
|
21
|
+
|
|
22
|
+
### driver 语义
|
|
23
|
+
看板前端 `useDataSource` 识别的是 `driver: 'es'` 等模块数据源类型;`raw-es-search` 是接口/helper 语义,不能写成看板模块 driver。
|
|
24
|
+
|
|
25
|
+
### 保存成功不等于预览通过
|
|
26
|
+
submit 成功后仍要 verify/readback,并在需要时打开预览页验证模块渲染、console 错误、network 请求和筛选联动。
|
|
27
|
+
|
|
28
|
+
## 旧规则去向
|
|
29
|
+
- 本地双确认流程:`local-temp-workflow.md`
|
|
30
|
+
- 模板 shape:`template-shape.md`
|
|
31
|
+
- 模块 catalog:`module-catalog.md`
|
|
32
|
+
- 筛选器联动:`filter-integration.md`
|
|
33
|
+
- 页面只读验收:`runtime-page-shape.md`
|
|
34
|
+
- 简历看板案例:`lessons-from-resume-dashboard.md`
|
|
35
|
+
|
|
36
|
+
## 统一执行入口
|
|
37
|
+
```bash
|
|
38
|
+
bpmax-cli config console-template export --id <id> --out .codex/tmp/console-template-editor --profile <profile> --format json
|
|
39
|
+
bpmax-cli config console-template lint --work .codex/tmp/console-template-editor/work/<file>.json --profile <profile> --format json
|
|
40
|
+
bpmax-cli config console-template build --work .codex/tmp/console-template-editor/work/<file>.json --meta .codex/tmp/console-template-editor/meta/<file>.meta.json --out .codex/tmp/console-template-editor/submit/<file>.json --profile <profile> --format json
|
|
41
|
+
bpmax-cli config console-template submit --id <id> --payload .codex/tmp/console-template-editor/submit/<file>.json --profile <profile> --confirm "submit console-template <id>" --format json
|
|
42
|
+
bpmax-cli config console-template verify --id <id> --expect .codex/tmp/console-template-editor/work/<file>.json --profile <profile> --format json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
旧 Python 脚本只保留为本地结构/lint 参考,不是线上写入路径。
|
|
@@ -5,11 +5,12 @@
|
|
|
5
5
|
- 接口确认真实线上结构
|
|
6
6
|
- 导出本地临时文件
|
|
7
7
|
- work 第一次确认
|
|
8
|
-
- submit
|
|
8
|
+
- typed CLI build 生成 submit
|
|
9
9
|
- lint
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
10
|
+
- submit 第二次确认
|
|
11
|
+
- typed CLI submit/create/delete
|
|
12
|
+
- typed CLI verify/readback
|
|
13
|
+
- 真实用户身份只读预览验收
|
|
13
14
|
|
|
14
15
|
## 目录结构
|
|
15
16
|
- 所有临时文件固定写到 `.codex/tmp/console-template-editor/`
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
- 不允许 build submit
|
|
34
35
|
- `work_confirmed`
|
|
35
36
|
- 用户已确认 `work`
|
|
36
|
-
- 允许执行
|
|
37
|
+
- 允许执行 typed CLI build
|
|
37
38
|
- `submit_built`
|
|
38
39
|
- `submit` 已从 `work` 构建完成
|
|
39
40
|
- `lint_passed`
|
|
@@ -41,14 +42,14 @@
|
|
|
41
42
|
- 等待第二次确认
|
|
42
43
|
- `submit_confirmed`
|
|
43
44
|
- 用户已确认 `submit`
|
|
44
|
-
- 允许执行
|
|
45
|
+
- 允许执行 typed CLI submit/create/delete
|
|
45
46
|
- `submitted`
|
|
46
|
-
-
|
|
47
|
-
-
|
|
47
|
+
- 已通过 typed CLI 提交
|
|
48
|
+
- 已有 verify/readback 与只读预览验收入口
|
|
48
49
|
|
|
49
50
|
## 强制门禁
|
|
50
|
-
- 不能跳过
|
|
51
|
-
-
|
|
51
|
+
- 不能跳过 typed CLI export/readback 或样例详情读取。
|
|
52
|
+
- 平台接口形态只作为 typed adapter 背后的契约说明,不是 Agent 直接调用入口。
|
|
52
53
|
- 没有 `work_confirmed`,不得构建 `submit`。
|
|
53
54
|
- 没有 `lint_passed`,不得做第二次确认。
|
|
54
55
|
- 没有 `submit_confirmed`,不得执行提交。
|
|
@@ -64,6 +65,6 @@
|
|
|
64
65
|
## 验收规则
|
|
65
66
|
- 接口成功不算完成。
|
|
66
67
|
- 必须至少同时满足:
|
|
67
|
-
-
|
|
68
|
-
-
|
|
68
|
+
- typed CLI verify/readback 一致
|
|
69
|
+
- 编辑页只读回显正确
|
|
69
70
|
- 预览页运行态可继续验收
|
|
@@ -4,14 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
import copy
|
|
5
5
|
import hashlib
|
|
6
6
|
import json
|
|
7
|
-
import os
|
|
8
7
|
import re
|
|
9
8
|
import sys
|
|
10
|
-
import ssl
|
|
11
|
-
import urllib.error
|
|
12
|
-
import urllib.parse
|
|
13
|
-
import urllib.request
|
|
14
|
-
from dataclasses import dataclass
|
|
15
9
|
from datetime import datetime, timezone
|
|
16
10
|
from difflib import unified_diff
|
|
17
11
|
from pathlib import Path
|
|
@@ -21,9 +15,9 @@ from typing import Any, Dict, Iterable, Optional
|
|
|
21
15
|
SHARED_SKILL_ROOT = Path(__file__).resolve().parents[2] / "bpmax-builder-shared"
|
|
22
16
|
if str(SHARED_SKILL_ROOT) not in sys.path:
|
|
23
17
|
sys.path.insert(0, str(SHARED_SKILL_ROOT))
|
|
24
|
-
from base_url import DEFAULT_BASE_URL, resolve_base_url
|
|
25
18
|
|
|
26
19
|
DEFAULT_LANGUAGE = "zhCN"
|
|
20
|
+
DEFAULT_BASE_URL = ""
|
|
27
21
|
REPO_ROOT = Path(__file__).resolve().parents[4]
|
|
28
22
|
TMP_ROOT = REPO_ROOT / ".codex" / "tmp" / "console-template-editor"
|
|
29
23
|
TMP_SUBDIRS = ("raw", "work", "meta", "submit", "diffs", "result")
|
|
@@ -44,6 +38,11 @@ OVERVIEW_REQUIRED_CONFIG_KEYS = ("title", "height", "dataSource", "config")
|
|
|
44
38
|
SUPPORTED_DATA_SOURCE_DRIVERS = ("es", "mysql", "customer", "custom_bpmax", "service")
|
|
45
39
|
OVERVIEW_SUPPORTED_ICONS = ("total", "finished", "delay_warning", "delay")
|
|
46
40
|
LINT_FORBIDDEN_PLACEHOLDERS = ("${page_size}", "${offset}")
|
|
41
|
+
LEGACY_NETWORK_DISABLED_MESSAGE = (
|
|
42
|
+
"Legacy console-template network scripts are disabled in bpmax-cli. "
|
|
43
|
+
"Use `bpmax-cli config console-template export|lint|build|submit|create|delete|verify` "
|
|
44
|
+
"so profile, capability, dry-run, confirmation, audit, and baseline checks are enforced."
|
|
45
|
+
)
|
|
47
46
|
|
|
48
47
|
from template_script_hard_rules import scan_named_script_surfaces
|
|
49
48
|
|
|
@@ -399,17 +398,62 @@ def _has_ctx_config_fallback(script: str) -> bool:
|
|
|
399
398
|
|
|
400
399
|
|
|
401
400
|
def _check_data_source_driver(script: Any, module_name: str, errors: list[str]) -> None:
|
|
402
|
-
if
|
|
401
|
+
if isinstance(script, str):
|
|
402
|
+
text = script
|
|
403
|
+
elif isinstance(script, (dict, list)):
|
|
404
|
+
text = json.dumps(script, ensure_ascii=False, sort_keys=True)
|
|
405
|
+
else:
|
|
403
406
|
return
|
|
404
|
-
if "raw-es-search" in
|
|
407
|
+
if "raw-es-search" in text:
|
|
405
408
|
errors.append(
|
|
406
409
|
f"{module_name} dataSource uses unsupported driver raw-es-search; current console frontend supports "
|
|
407
410
|
"driver: 'es' for ES data sources"
|
|
408
411
|
)
|
|
409
|
-
for match in re.finditer(r"['\"]?driver['\"]?\s*:\s*['\"]([^'\"]+)['\"]",
|
|
412
|
+
for match in re.finditer(r"['\"]?driver['\"]?\s*:\s*['\"]([^'\"]+)['\"]", text):
|
|
410
413
|
driver = match.group(1)
|
|
411
414
|
if driver and driver not in SUPPORTED_DATA_SOURCE_DRIVERS:
|
|
412
415
|
errors.append(f"{module_name} dataSource uses unsupported driver: {driver}")
|
|
416
|
+
if re.search(r"['\"]?driver['\"]?\s*:", text) and not re.search(
|
|
417
|
+
r"['\"]?driver['\"]?\s*:\s*['\"][^'\"]+['\"]", text
|
|
418
|
+
):
|
|
419
|
+
errors.append(f"{module_name} dataSource driver must be a static string literal")
|
|
420
|
+
if re.search(r"\[\s*['\"][^\]]+['\"]\s*(?:\+[^\]]*)?\]\s*:", text):
|
|
421
|
+
errors.append(f"{module_name} dataSource property names must be static identifiers")
|
|
422
|
+
if re.search(r"\bdata_set_id\b", text, re.IGNORECASE) and re.search(
|
|
423
|
+
r"raw-es-search|project/list|ESProjectList|\$esQuery|query|search", text, re.IGNORECASE
|
|
424
|
+
):
|
|
425
|
+
errors.append(f"{module_name} must not use data_set_id as an ES/project query entrypoint")
|
|
426
|
+
waiver = isinstance(script, str) and re.search(
|
|
427
|
+
r"bpmax-allow-user-scope-project-list[ \t]*:[ \t]*[^\s\r\n][^\r\n]{2,}", text, re.IGNORECASE
|
|
428
|
+
)
|
|
429
|
+
if re.search(r"/bpmax/project/list|/api/project/list|ESProjectList", text, re.IGNORECASE) and not waiver:
|
|
430
|
+
errors.append(f"{module_name} must not use project/list or ESProjectList without a non-empty allow reason")
|
|
431
|
+
|
|
432
|
+
|
|
433
|
+
def _check_wildcard_fallback(value: Any, module_name: str, errors: list[str]) -> None:
|
|
434
|
+
if isinstance(value, dict):
|
|
435
|
+
for key, child in value.items():
|
|
436
|
+
if key in ("wildcard", "value") and child in ("*", "**"):
|
|
437
|
+
errors.append(f"{module_name}.{key} must not use {child} as a fallback result")
|
|
438
|
+
_check_wildcard_fallback(child, module_name, errors)
|
|
439
|
+
elif isinstance(value, list):
|
|
440
|
+
for child in value:
|
|
441
|
+
_check_wildcard_fallback(child, module_name, errors)
|
|
442
|
+
elif isinstance(value, str) and re.search(r"(?:wildcard|value)\s*:\s*['\"]\*{1,2}['\"]", value):
|
|
443
|
+
errors.append(f"{module_name} must not use wildcard * or ** as a scripted fallback result")
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def _check_frontend_detail_counting(
|
|
447
|
+
script: Any, data_source: Any, module_name: str, errors: list[str]
|
|
448
|
+
) -> None:
|
|
449
|
+
if not isinstance(script, str):
|
|
450
|
+
return
|
|
451
|
+
has_row_loop = bool(re.search(r"\.(?:forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(?:of|in)\b", script))
|
|
452
|
+
has_metric = bool(re.search(r"count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数", script, re.IGNORECASE))
|
|
453
|
+
source_text = data_source if isinstance(data_source, str) else json.dumps(data_source, ensure_ascii=False, sort_keys=True)
|
|
454
|
+
has_aggregation = bool(re.search(r"(?:aggs|aggregations)\b|(?:['\"]?size['\"]?)\s*:\s*0", f"{source_text}\n{script}", re.IGNORECASE))
|
|
455
|
+
if has_row_loop and has_metric and not has_aggregation:
|
|
456
|
+
errors.append(f"{module_name} must use ES size: 0 with aggs/aggregations instead of frontend row counting")
|
|
413
457
|
|
|
414
458
|
|
|
415
459
|
def _check_project_overview_script(script: Any, module_name: str, errors: list[str], warnings: list[str]) -> None:
|
|
@@ -459,11 +503,12 @@ def _check_module_config(module: Dict[str, Any], errors: list[str], warnings: li
|
|
|
459
503
|
module_check = {"id": module_id, "name": module_name, "configKeys": sorted(config.keys())}
|
|
460
504
|
checks.setdefault("modules", []).append(module_check)
|
|
461
505
|
|
|
506
|
+
_check_data_source_driver(config.get("dataSource"), module_name, errors)
|
|
507
|
+
|
|
462
508
|
if module_name == "图表":
|
|
463
509
|
missing = [key for key in CHART_REQUIRED_CONFIG_KEYS if config.get(key) in (None, "")]
|
|
464
510
|
if missing:
|
|
465
511
|
errors.append(f"{module_name} missing required config keys: {', '.join(missing)}")
|
|
466
|
-
_check_data_source_driver(config.get("dataSource"), module_name, errors)
|
|
467
512
|
chart_script = config.get("config")
|
|
468
513
|
if isinstance(chart_script, str) and "ctx.config" in chart_script and not _has_ctx_config_fallback(chart_script):
|
|
469
514
|
errors.append(f"{module_name} config script references ctx.config without fallback")
|
|
@@ -471,12 +516,11 @@ def _check_module_config(module: Dict[str, Any], errors: list[str], warnings: li
|
|
|
471
516
|
missing = [key for key in TABLE_REQUIRED_CONFIG_KEYS if config.get(key) in (None, "")]
|
|
472
517
|
if missing:
|
|
473
518
|
errors.append(f"{module_name} missing required config keys: {', '.join(missing)}")
|
|
474
|
-
_check_data_source_driver(config.get("dataSource"), module_name, errors)
|
|
475
519
|
table_script = config.get("config")
|
|
476
520
|
if isinstance(table_script, str):
|
|
477
521
|
compact_script = table_script.replace(" ", "").replace("\n", "")
|
|
478
522
|
if "cfg.page_size" in compact_script and "ctx.pageInfo" not in table_script and "allRows" not in table_script:
|
|
479
|
-
|
|
523
|
+
errors.append(
|
|
480
524
|
f"{module_name} config script uses cfg.page_size without ctx.pageInfo/allRows export branch; "
|
|
481
525
|
"TableSmart export may only include the first page"
|
|
482
526
|
)
|
|
@@ -484,9 +528,12 @@ def _check_module_config(module: Dict[str, Any], errors: list[str], warnings: li
|
|
|
484
528
|
missing = [key for key in OVERVIEW_REQUIRED_CONFIG_KEYS if config.get(key) in (None, "")]
|
|
485
529
|
if missing:
|
|
486
530
|
errors.append(f"{module_name} missing required config keys: {', '.join(missing)}")
|
|
487
|
-
_check_data_source_driver(config.get("dataSource"), module_name, errors)
|
|
488
531
|
_check_project_overview_script(config.get("config"), module_name, errors, warnings)
|
|
489
532
|
|
|
533
|
+
_check_wildcard_fallback(config.get("dataSource"), f"{module_name}.dataSource", errors)
|
|
534
|
+
_check_wildcard_fallback(config.get("config"), f"{module_name}.config", errors)
|
|
535
|
+
_check_frontend_detail_counting(config.get("config"), config.get("dataSource"), module_name, errors)
|
|
536
|
+
|
|
490
537
|
serialized = json.dumps(config, ensure_ascii=False)
|
|
491
538
|
for placeholder in LINT_FORBIDDEN_PLACEHOLDERS:
|
|
492
539
|
if placeholder in serialized:
|
|
@@ -883,75 +930,15 @@ def record_submission_meta(
|
|
|
883
930
|
return payload
|
|
884
931
|
|
|
885
932
|
|
|
886
|
-
@dataclass
|
|
887
|
-
class ApiClient:
|
|
888
|
-
base_url: str
|
|
889
|
-
workspace: str
|
|
890
|
-
language: str
|
|
891
|
-
cookie_header: str
|
|
892
|
-
timeout: float
|
|
893
|
-
insecure: bool = False
|
|
894
|
-
|
|
895
|
-
def _build_url(self, path: str) -> str:
|
|
896
|
-
suffix = f"$workspace={urllib.parse.quote(self.workspace)}&$language={urllib.parse.quote(self.language)}"
|
|
897
|
-
joiner = "&" if "?" in path else "?"
|
|
898
|
-
return self.base_url.rstrip("/") + path + joiner + suffix
|
|
899
|
-
|
|
900
|
-
def request(self, method: str, path: str, body: Optional[dict] = None) -> dict:
|
|
901
|
-
headers = {
|
|
902
|
-
"content-type": "application/json",
|
|
903
|
-
"cookie": self.cookie_header,
|
|
904
|
-
"accept": "application/json, text/plain, */*",
|
|
905
|
-
}
|
|
906
|
-
data = None if body is None else json.dumps(body, ensure_ascii=False).encode("utf-8")
|
|
907
|
-
req = urllib.request.Request(self._build_url(path), data=data, headers=headers, method=method)
|
|
908
|
-
context = ssl._create_unverified_context() if self.insecure else None
|
|
909
|
-
try:
|
|
910
|
-
with urllib.request.urlopen(req, timeout=self.timeout, context=context) as resp:
|
|
911
|
-
raw = resp.read().decode("utf-8", "replace")
|
|
912
|
-
except urllib.error.HTTPError as err:
|
|
913
|
-
raw = err.read().decode("utf-8", "replace")
|
|
914
|
-
raise SystemExit(f"HTTP {err.code} {path}: {raw}") from err
|
|
915
|
-
except urllib.error.URLError as err:
|
|
916
|
-
raise SystemExit(f"Request failed {path}: {err}") from err
|
|
917
|
-
payload = json.loads(raw)
|
|
918
|
-
if isinstance(payload, dict) and payload.get("code") not in (None, 0):
|
|
919
|
-
raise SystemExit(f"API error {path}: {payload}")
|
|
920
|
-
return payload
|
|
921
|
-
|
|
922
|
-
def get_template(self, template_id: int) -> dict:
|
|
923
|
-
return self.request("GET", f"/flow_page_template/{template_id}?skip_i18n=true")
|
|
924
|
-
|
|
925
|
-
def update_template(self, template_id: int, body: Dict[str, Any]) -> dict:
|
|
926
|
-
return self.request("PUT", f"/flow_page_template/{template_id}", body)
|
|
927
|
-
|
|
928
|
-
def create_template(self, body: Dict[str, Any]) -> dict:
|
|
929
|
-
return self.request("POST", "/flow_page_template", body)
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
def resolve_cookie_header(value: Optional[str]) -> str:
|
|
933
|
-
cookie = value or os.environ.get("BPMAX_COOKIE_HEADER", "")
|
|
934
|
-
if not cookie:
|
|
935
|
-
raise SystemExit("missing cookie header: pass --cookie-header or set BPMAX_COOKIE_HEADER")
|
|
936
|
-
return cookie
|
|
937
|
-
|
|
938
|
-
|
|
939
933
|
def resolve_workspace(value: Optional[str]) -> str:
|
|
940
|
-
workspace = value or
|
|
934
|
+
workspace = value or ""
|
|
941
935
|
if not workspace:
|
|
942
|
-
raise SystemExit("missing workspace: pass --workspace
|
|
936
|
+
raise SystemExit("missing workspace: pass --workspace")
|
|
943
937
|
return workspace
|
|
944
938
|
|
|
945
939
|
|
|
946
|
-
def build_client(args: Any) ->
|
|
947
|
-
|
|
948
|
-
base_url=resolve_base_url(getattr(args, "base_url", None)),
|
|
949
|
-
workspace=resolve_workspace(getattr(args, "workspace", None)),
|
|
950
|
-
language=getattr(args, "language", DEFAULT_LANGUAGE),
|
|
951
|
-
cookie_header=resolve_cookie_header(getattr(args, "cookie_header", None)),
|
|
952
|
-
timeout=float(getattr(args, "timeout", 30)),
|
|
953
|
-
insecure=bool(getattr(args, "insecure", False)),
|
|
954
|
-
)
|
|
940
|
+
def build_client(args: Any) -> None:
|
|
941
|
+
raise SystemExit(LEGACY_NETWORK_DISABLED_MESSAGE)
|
|
955
942
|
|
|
956
943
|
|
|
957
944
|
def sanitize_create_detail(detail: Dict[str, Any]) -> Dict[str, Any]:
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import json
|
|
2
|
-
import os
|
|
3
2
|
import sys
|
|
4
3
|
import tempfile
|
|
5
4
|
import unittest
|
|
6
5
|
from pathlib import Path
|
|
7
|
-
from unittest import mock
|
|
8
6
|
|
|
9
7
|
|
|
10
8
|
SCRIPT_DIR = Path(__file__).resolve().parents[1] / "scripts"
|
|
@@ -13,6 +11,7 @@ if str(SCRIPT_DIR) not in sys.path:
|
|
|
13
11
|
|
|
14
12
|
from console_template_editor_common import ( # noqa: E402
|
|
15
13
|
DEFAULT_BASE_URL,
|
|
14
|
+
LEGACY_NETWORK_DISABLED_MESSAGE,
|
|
16
15
|
build_client,
|
|
17
16
|
build_create_work_payload,
|
|
18
17
|
build_drift_report,
|
|
@@ -101,7 +100,7 @@ class ConsoleTemplateEditorTests(unittest.TestCase):
|
|
|
101
100
|
def test_default_base_url_is_empty_until_runtime_configured(self) -> None:
|
|
102
101
|
self.assertEqual(DEFAULT_BASE_URL, "")
|
|
103
102
|
|
|
104
|
-
def
|
|
103
|
+
def test_legacy_network_client_is_disabled(self) -> None:
|
|
105
104
|
args = type(
|
|
106
105
|
"Args",
|
|
107
106
|
(),
|
|
@@ -114,30 +113,9 @@ class ConsoleTemplateEditorTests(unittest.TestCase):
|
|
|
114
113
|
"insecure": False,
|
|
115
114
|
},
|
|
116
115
|
)()
|
|
117
|
-
with
|
|
118
|
-
|
|
119
|
-
self.
|
|
120
|
-
client._build_url("/flow_page_template/954573436?skip_i18n=true"),
|
|
121
|
-
"https://bpmax.example.com/flow_page_template/954573436?skip_i18n=true&$workspace=store_mgr&$language=zhCN",
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
def test_build_client_requires_runtime_origin_when_not_explicitly_configured(self) -> None:
|
|
125
|
-
args = type(
|
|
126
|
-
"Args",
|
|
127
|
-
(),
|
|
128
|
-
{
|
|
129
|
-
"base_url": None,
|
|
130
|
-
"workspace": "store_mgr",
|
|
131
|
-
"language": "zhCN",
|
|
132
|
-
"cookie_header": "token=demo",
|
|
133
|
-
"timeout": 30,
|
|
134
|
-
"insecure": False,
|
|
135
|
-
},
|
|
136
|
-
)()
|
|
137
|
-
with mock.patch.dict(os.environ, {}, clear=True):
|
|
138
|
-
with self.assertRaises(SystemExit) as ctx:
|
|
139
|
-
build_client(args)
|
|
140
|
-
self.assertIn("BPMAX_BASE_URL", str(ctx.exception))
|
|
116
|
+
with self.assertRaises(SystemExit) as ctx:
|
|
117
|
+
build_client(args)
|
|
118
|
+
self.assertIn(LEGACY_NETWORK_DISABLED_MESSAGE, str(ctx.exception))
|
|
141
119
|
|
|
142
120
|
def test_canonical_layout_key_supports_numeric_values(self) -> None:
|
|
143
121
|
self.assertEqual(canonical_layout_key(1775705110498), "1775705110498")
|
|
@@ -305,7 +283,85 @@ class ConsoleTemplateEditorTests(unittest.TestCase):
|
|
|
305
283
|
self.assertFalse(lint["ok"])
|
|
306
284
|
self.assertTrue(any("project/list" in err for err in lint["errors"]))
|
|
307
285
|
|
|
308
|
-
def
|
|
286
|
+
def test_lint_rejects_object_shaped_unsupported_data_source_driver(self) -> None:
|
|
287
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
288
|
+
work["modules"][0]["config"]["dataSource"] = {
|
|
289
|
+
"driver": "raw-es-search",
|
|
290
|
+
"data_set_id": 123,
|
|
291
|
+
"query": {},
|
|
292
|
+
}
|
|
293
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
294
|
+
self.assertFalse(lint["ok"])
|
|
295
|
+
self.assertTrue(any("raw-es-search" in err for err in lint["errors"]))
|
|
296
|
+
|
|
297
|
+
def test_lint_rejects_computed_data_source_driver(self) -> None:
|
|
298
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
299
|
+
work["modules"][0]["config"]["dataSource"] = (
|
|
300
|
+
"return { driver: ['raw', 'es', 'search'].join('-'), data_set_key: 'demo' };"
|
|
301
|
+
)
|
|
302
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
303
|
+
self.assertFalse(lint["ok"])
|
|
304
|
+
self.assertTrue(any("static string literal" in err for err in lint["errors"]))
|
|
305
|
+
|
|
306
|
+
def test_lint_rejects_computed_data_source_property_name(self) -> None:
|
|
307
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
308
|
+
work["modules"][0]["config"]["dataSource"] = (
|
|
309
|
+
"return { ['dr' + 'iver']: ['raw', 'es', 'search'].join('-') };"
|
|
310
|
+
)
|
|
311
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
312
|
+
self.assertFalse(lint["ok"])
|
|
313
|
+
self.assertTrue(any("property names must be static" in err for err in lint["errors"]))
|
|
314
|
+
|
|
315
|
+
def test_lint_rejects_data_set_id_query_entrypoint(self) -> None:
|
|
316
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
317
|
+
work["modules"][0]["config"]["dataSource"] = {
|
|
318
|
+
"driver": "es", "data_set_id": 123, "query": {"match_all": {}}
|
|
319
|
+
}
|
|
320
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
321
|
+
self.assertFalse(lint["ok"])
|
|
322
|
+
self.assertTrue(any("data_set_id" in err for err in lint["errors"]))
|
|
323
|
+
|
|
324
|
+
def test_lint_rejects_wildcard_fallback(self) -> None:
|
|
325
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
326
|
+
work["modules"][0]["config"]["config"] = (
|
|
327
|
+
"const cfg = ctx.config || {}; return { series: [], wildcard: '*' };"
|
|
328
|
+
)
|
|
329
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
330
|
+
self.assertFalse(lint["ok"])
|
|
331
|
+
self.assertTrue(any("wildcard" in err for err in lint["errors"]))
|
|
332
|
+
|
|
333
|
+
def test_lint_rejects_frontend_detail_counting_without_aggregation(self) -> None:
|
|
334
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
335
|
+
work["modules"][0]["config"]["config"] = (
|
|
336
|
+
"const cfg = ctx.config || {}; return rows.map(row => ({ title: row.name, amount: row.total, config: cfg }));"
|
|
337
|
+
)
|
|
338
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
339
|
+
self.assertFalse(lint["ok"])
|
|
340
|
+
self.assertTrue(any("frontend row counting" in err for err in lint["errors"]))
|
|
341
|
+
|
|
342
|
+
def test_lint_rejects_object_project_list_waiver_to_match_typed_cli(self) -> None:
|
|
343
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
344
|
+
work["modules"][0]["config"]["dataSource"] = {
|
|
345
|
+
"driver": "service",
|
|
346
|
+
"url": "/api/project/list",
|
|
347
|
+
"note": "bpmax-allow-user-scope-project-list: current user chooser",
|
|
348
|
+
}
|
|
349
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
350
|
+
self.assertFalse(lint["ok"])
|
|
351
|
+
self.assertTrue(any("project/list" in err for err in lint["errors"]))
|
|
352
|
+
|
|
353
|
+
def test_lint_rejects_unsafe_data_source_in_custom_module(self) -> None:
|
|
354
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
355
|
+
work["modules"].append({
|
|
356
|
+
"i": "custom_1",
|
|
357
|
+
"name": "自定义模块",
|
|
358
|
+
"config": {"dataSource": "return { driver: 'raw-es-search' };", "config": "return [];"},
|
|
359
|
+
})
|
|
360
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
361
|
+
self.assertFalse(lint["ok"])
|
|
362
|
+
self.assertTrue(any("raw-es-search" in err for err in lint["errors"]))
|
|
363
|
+
|
|
364
|
+
def test_lint_blocks_table_export_when_config_only_uses_page_size(self) -> None:
|
|
309
365
|
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
310
366
|
work["modules"][1]["config"]["config"] = (
|
|
311
367
|
"const cfg = ctx.config || {}; "
|
|
@@ -315,8 +371,8 @@ class ConsoleTemplateEditorTests(unittest.TestCase):
|
|
|
315
371
|
|
|
316
372
|
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
317
373
|
|
|
318
|
-
self.
|
|
319
|
-
self.assertTrue(any("TableSmart export" in
|
|
374
|
+
self.assertFalse(lint["ok"])
|
|
375
|
+
self.assertTrue(any("TableSmart export" in error for error in lint["errors"]))
|
|
320
376
|
|
|
321
377
|
def test_lint_blocks_empty_flow_binding_for_no_flow_console_list_visibility(self) -> None:
|
|
322
378
|
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|