bpmax-cli 0.2.1-beta.4 → 0.2.1-beta.41
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 +13 -5
- package/dist/bin.js +18658 -8166
- package/dist/bin.js.map +1 -1
- package/package.json +7 -4
- package/scripts/run-source-cli.mjs +121 -0
- package/skills/bpmax-ai-taskbook/SKILL.md +1 -0
- 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-approval-matrix/SKILL.md +54 -2
- package/skills/bpmax-blueprint-doc-workflow/SKILL.md +87 -0
- package/skills/bpmax-blueprint-doc-workflow/agents/openai.yaml +4 -0
- package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +60 -0
- package/skills/bpmax-blueprint-doc-workflow/references/per-flow-required-structure.md +98 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-forbidden-term.xml +12 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-mermaid-codeblock.xml +12 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-boundary.xml +10 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-whiteboard.xml +10 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +55 -0
- package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +257 -0
- package/skills/bpmax-bug-reporting/SKILL.md +72 -0
- package/skills/bpmax-builder-shared/SKILL.md +1 -0
- package/skills/bpmax-builder-shared/configuration-impact-review.md +76 -0
- 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-cli/SKILL.md +42 -0
- package/skills/bpmax-config-latest/SKILL.md +4 -0
- package/skills/bpmax-console-template-editor/SKILL.md +112 -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 +299 -78
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +344 -30
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +127 -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 +116 -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 +15 -4
- package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +2 -2
- package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +13 -9
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +139 -533
- package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +2 -3
- package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +150 -9
- 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 +570 -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 +114 -551
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +18 -18
- package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +21 -0
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +29 -26
- package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +19 -2
- 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-detail-template-editor/SKILL.md +43 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +117 -1084
- 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/flow-template-api-workflow.md +2 -1
- package/skills/bpmax-flow-template-editor/references/full-detail-guide.md +1157 -0
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +1 -1
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +17 -0
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +8 -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 +8 -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 +130 -1104
- package/skills/bpmax-form-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-form-template-editor/references/dynamic-field-state.md +164 -0
- 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 +1109 -0
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +4 -4
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +3 -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-functional-test-design/LICENSE.upstream +24 -0
- package/skills/bpmax-functional-test-design/SKILL.md +80 -0
- package/skills/bpmax-functional-test-design/agents/openai.yaml +4 -0
- package/skills/bpmax-functional-test-design/references/bpmax-test-suite-output.md +95 -0
- package/skills/bpmax-functional-test-design/references/decision-table-testing.md +50 -0
- package/skills/bpmax-functional-test-design/references/domain-testing.md +43 -0
- package/skills/bpmax-functional-test-design/references/state-transition-testing.md +47 -0
- package/skills/bpmax-functional-test-design/references/technique-selection.md +38 -0
- package/skills/bpmax-functional-test-design/references/use-case-testing.md +55 -0
- package/skills/bpmax-group-model-editor/SKILL.md +24 -0
- package/skills/bpmax-list-template-editor/SKILL.md +119 -466
- package/skills/bpmax-list-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-list-template-editor/references/content-config-shape.md +16 -4
- package/skills/bpmax-list-template-editor/references/full-detail-guide.md +458 -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/references/special-formats.md +5 -2
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +9 -78
- package/skills/bpmax-memory-protocol/SKILL.md +7 -6
- 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-plugin-config/SKILL.md +20 -4
- package/skills/bpmax-project/SKILL.md +37 -1
- package/skills/bpmax-project-detail-template-editor/SKILL.md +13 -39
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +2 -2
- package/skills/bpmax-role-editor/SKILL.md +7 -30
- package/skills/bpmax-shared/SKILL.md +19 -9
- package/skills/bpmax-team-editor/SKILL.md +27 -0
- package/skills/bpmax-ui-ux-audit/LICENSE.upstream +23 -0
- package/skills/bpmax-ui-ux-audit/SKILL.md +42 -0
- package/skills/bpmax-ui-ux-audit/agents/openai.yaml +4 -0
- package/skills/bpmax-ui-ux-audit/references/audit-framework.md +39 -0
- package/skills/bpmax-ui-ux-audit/references/bpmax-ux-findings.md +56 -0
- package/skills/bpmax-user/SKILL.md +33 -1
- package/skills/bpmax-user-mock-operator/SKILL.md +20 -48
- package/skills/bpmax-user-mock-operator/agents/openai.yaml +2 -2
- package/skills/bpmax-user-model-editor/SKILL.md +24 -0
- package/skills/form-control-library/references/form-template-submit-schema.md +1 -1
- package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +0 -37
- package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +0 -136
- package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +0 -138
|
@@ -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,343 @@ 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_allows_table_es_server_pagination_with_current_page_mapping(self) -> None:
|
|
343
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
344
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
345
|
+
"const cfg = ctx.config || {}; "
|
|
346
|
+
"const pageSize = Number(ctx.pageInfo?.pageSize || cfg.page_size || 20); "
|
|
347
|
+
"const page = Number(ctx.pageInfo?.page || 1); "
|
|
348
|
+
"return { driver: 'es', data_set_key: 'demo_dataset', "
|
|
349
|
+
"from: (page - 1) * pageSize, size: pageSize, track_total_hits: true };"
|
|
350
|
+
)
|
|
351
|
+
work["modules"][1]["config"]["config"] = (
|
|
352
|
+
"const hits = ctx.data?.hits?.hits || []; "
|
|
353
|
+
"const total = ctx.data?.hits?.total?.value || 0; "
|
|
354
|
+
"return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
358
|
+
|
|
359
|
+
self.assertTrue(lint["ok"], lint["errors"])
|
|
360
|
+
|
|
361
|
+
def test_lint_rejects_frontend_aggregation_mixed_with_server_pagination(self) -> None:
|
|
362
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
363
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
364
|
+
"return { driver: 'es', data_set_key: 'demo_dataset', "
|
|
365
|
+
"from: 0, size: pageSize, track_total_hits: true };"
|
|
366
|
+
)
|
|
367
|
+
work["modules"][1]["config"]["config"] = (
|
|
368
|
+
"const hits = ctx.data?.hits?.hits || []; "
|
|
369
|
+
"const total = ctx.data?.hits?.total?.value || 0; "
|
|
370
|
+
"const totalAmount = hits.reduce((sum, hit) => sum + Number(hit._source.amount || 0), 0); "
|
|
371
|
+
"return { data: hits.map(hit => hit._source), cols: [], totalAmount, pageInfo: { count: total } };"
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
375
|
+
|
|
376
|
+
self.assertFalse(lint["ok"])
|
|
377
|
+
self.assertTrue(any("frontend row counting" in err for err in lint["errors"]))
|
|
378
|
+
|
|
379
|
+
def test_lint_rejects_unbounded_variable_size_as_server_pagination(self) -> None:
|
|
380
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
381
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
382
|
+
"return { driver: 'es', data_set_key: 'demo_dataset', "
|
|
383
|
+
"from: 0, size: total, track_total_hits: true };"
|
|
384
|
+
)
|
|
385
|
+
work["modules"][1]["config"]["config"] = (
|
|
386
|
+
"const hits = ctx.data?.hits?.hits || []; "
|
|
387
|
+
"const total = ctx.data?.hits?.total?.value || 0; "
|
|
388
|
+
"return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
|
|
389
|
+
)
|
|
390
|
+
|
|
391
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
392
|
+
|
|
393
|
+
self.assertFalse(lint["ok"])
|
|
394
|
+
self.assertTrue(any("frontend row counting" in err for err in lint["errors"]))
|
|
395
|
+
|
|
396
|
+
def test_lint_rejects_pagination_named_variables_without_controlled_bindings(self) -> None:
|
|
397
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
398
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
399
|
+
"const offset = 0; const pageSize = total; "
|
|
400
|
+
"return { driver: 'es', data_set_key: 'demo_dataset', "
|
|
401
|
+
"from: offset, size: pageSize, track_total_hits: true };"
|
|
402
|
+
)
|
|
403
|
+
work["modules"][1]["config"]["config"] = (
|
|
404
|
+
"const hits = ctx.data?.hits?.hits || []; "
|
|
405
|
+
"const total = ctx.data?.hits?.total?.value || 0; "
|
|
406
|
+
"return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
|
|
407
|
+
)
|
|
408
|
+
|
|
409
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
410
|
+
|
|
411
|
+
self.assertFalse(lint["ok"])
|
|
412
|
+
self.assertTrue(any("frontend row counting" in err for err in lint["errors"]))
|
|
413
|
+
|
|
414
|
+
def test_lint_rejects_reassigned_or_case_colliding_pagination_bindings(self) -> None:
|
|
415
|
+
unsafe_sources = (
|
|
416
|
+
"let pageSize = ctx.pageInfo?.pageSize; pageSize = total; const offset = ctx.pageInfo?.offset; return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };",
|
|
417
|
+
"const pagesize = ctx.pageInfo?.pageSize; const pageSize = total; const offset = ctx.pageInfo?.offset; return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };",
|
|
418
|
+
"const pageSize = ctx.pageInfo?.pageSize || total; const offset = ctx.pageInfo?.offset; return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };",
|
|
419
|
+
"const pageSize = ctx.pageInfo?.pageSize * 0 + 1000000; const offset = ctx.pageInfo?.offset; return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };",
|
|
420
|
+
)
|
|
421
|
+
for source in unsafe_sources:
|
|
422
|
+
with self.subTest(source=source):
|
|
423
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
424
|
+
work["modules"][1]["config"]["dataSource"] = source
|
|
425
|
+
work["modules"][1]["config"]["config"] = (
|
|
426
|
+
"const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
|
|
427
|
+
"return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
|
|
428
|
+
)
|
|
429
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
430
|
+
self.assertFalse(lint["ok"])
|
|
431
|
+
|
|
432
|
+
def test_lint_rejects_safe_looking_pagination_bindings_inside_comments_or_strings(self) -> None:
|
|
433
|
+
prefixes = (
|
|
434
|
+
"// const pageSize = ctx.pageInfo?.pageSize || 20;\n",
|
|
435
|
+
"/* const pageSize = ctx.pageInfo?.pageSize || 20; */ ",
|
|
436
|
+
'const decoy = "const pageSize = ctx.pageInfo?.pageSize || 20;"; ',
|
|
437
|
+
)
|
|
438
|
+
for prefix in prefixes:
|
|
439
|
+
with self.subTest(prefix=prefix):
|
|
440
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
441
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
442
|
+
prefix + "const pageSize = 1000000; const offset = ctx.pageInfo?.offset; "
|
|
443
|
+
"return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };"
|
|
444
|
+
)
|
|
445
|
+
work["modules"][1]["config"]["config"] = (
|
|
446
|
+
"const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
|
|
447
|
+
"return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
|
|
448
|
+
)
|
|
449
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
450
|
+
self.assertFalse(lint["ok"])
|
|
451
|
+
|
|
452
|
+
def test_lint_rejects_aggregation_comments_and_decoy_query_objects(self) -> None:
|
|
453
|
+
unsafe_sources = (
|
|
454
|
+
"// aggs: {}, size: 0\nreturn { driver: 'es', data_set_key: 'demo_dataset', from: 0, size: 1000000, track_total_hits: true };",
|
|
455
|
+
"const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; "
|
|
456
|
+
"const decoy = { from: offset, size: pageSize, track_total_hits: true }; "
|
|
457
|
+
"return { driver: 'es', data_set_key: 'demo_dataset', from: 0, size: 1000000, track_total_hits: true };",
|
|
458
|
+
)
|
|
459
|
+
for source in unsafe_sources:
|
|
460
|
+
with self.subTest(source=source):
|
|
461
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
462
|
+
work["modules"][1]["config"]["dataSource"] = source
|
|
463
|
+
work["modules"][1]["config"]["config"] = (
|
|
464
|
+
"const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
|
|
465
|
+
"return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
|
|
466
|
+
)
|
|
467
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
468
|
+
self.assertFalse(lint["ok"])
|
|
469
|
+
|
|
470
|
+
def test_lint_rejects_ambiguous_query_structure_and_frontend_map_side_effects(self) -> None:
|
|
471
|
+
unsafe_sources = (
|
|
472
|
+
"const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; return { from: offset, size: pageSize, track_total_hits: true, size: 1000000 };",
|
|
473
|
+
"const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; return { from: offset, size: pageSize, track_total_hits: true, ...unsafe };",
|
|
474
|
+
"const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; { const pageSize = 1000000; return { from: offset, size: pageSize, track_total_hits: true }; }",
|
|
475
|
+
"const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; return { from: offset, size: pageSize, track_total_hits: true, 'size': 1000000 };",
|
|
476
|
+
"const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; const size = 1000000; return { from: offset, size: pageSize, track_total_hits: true, size };",
|
|
477
|
+
)
|
|
478
|
+
for source in unsafe_sources:
|
|
479
|
+
with self.subTest(source=source):
|
|
480
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
481
|
+
work["modules"][1]["config"]["dataSource"] = source
|
|
482
|
+
work["modules"][1]["config"]["config"] = (
|
|
483
|
+
"const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
|
|
484
|
+
"return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
|
|
485
|
+
)
|
|
486
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
487
|
+
self.assertFalse(lint["ok"])
|
|
488
|
+
|
|
489
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
490
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
491
|
+
"const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; "
|
|
492
|
+
"return { from: offset, size: pageSize, track_total_hits: true };"
|
|
493
|
+
)
|
|
494
|
+
work["modules"][1]["config"]["config"] = (
|
|
495
|
+
"let total = 0; ctx.rows.map(row => { total += row.amount || 0; }); "
|
|
496
|
+
"// hits.map( pageInfo: { count:\nreturn { data: ctx.rows, total };"
|
|
497
|
+
)
|
|
498
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
499
|
+
self.assertFalse(lint["ok"])
|
|
500
|
+
|
|
501
|
+
unsafe_frontend_scripts = (
|
|
502
|
+
"const hits = ctx.rows; let total = 0; const data = hits.map(row => { total += row.amount || 0; return row; }); return { data, pageInfo: { count: total } };",
|
|
503
|
+
"const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; (ctx.rows).map(row => row.amount); return { data: hits.map(hit => hit._source), pageInfo: { count: total } };",
|
|
504
|
+
"const hits = ctx.data?.hits?.hits || []; let total = 0; const data = hits.map(row => { total = total + Number(row._source.amount || 0); return row._source; }); return { data, pageInfo: { count: total } };",
|
|
505
|
+
"const hits = ctx.data?.hits?.hits || []; let total = 0; { const hits = ctx.rows; const data = hits.map(row => { total = total + row.amount; return row; }); return { data, pageInfo: { count: total } }; }",
|
|
506
|
+
"let total = 0; ctx.rows['forEach'](row => { total += row.amount || 0; }); return { data: ctx.rows, total };",
|
|
507
|
+
"return [{ title: '项目数', amount: ctx.rows.length, icon: 'total' }];",
|
|
508
|
+
"let total = 0; const each = 'forEach'; ctx.rows[each](row => { total += row.amount || 0; }); return { data: ctx.rows, total };",
|
|
509
|
+
"let total = 0; ctx.rows['for' + 'Each'](row => { total += row.amount || 0; }); return { data: ctx.rows, total };",
|
|
510
|
+
"let total = 0; Array.prototype.forEach.call(ctx.rows, row => { total += row.amount || 0; }); return { data: ctx.rows, total };",
|
|
511
|
+
"const hits = ctx.data?.hits?.hits || []; return { decoy: hits.map(hit => hit._source), data: ctx.rows, pageInfo: { count: ctx.rows.length } };",
|
|
512
|
+
"return [{ title: '项目数', amount: ctx['rows'].length, icon: 'total' }];",
|
|
513
|
+
"const { rows } = ctx; return [{ title: '项目数', amount: rows.length, icon: 'total' }];",
|
|
514
|
+
"const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; hits.push(...ctx.rows); return { data: hits.map(hit => hit._source), pageInfo: { count: total } };",
|
|
515
|
+
"const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; hits.map = () => ctx.rows; return { data: hits.map(hit => hit._source), pageInfo: { count: total } };",
|
|
516
|
+
)
|
|
517
|
+
for script in unsafe_frontend_scripts:
|
|
518
|
+
with self.subTest(script=script):
|
|
519
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
520
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
521
|
+
"const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; "
|
|
522
|
+
"return { from: offset, size: pageSize, track_total_hits: true };"
|
|
523
|
+
)
|
|
524
|
+
work["modules"][1]["config"]["config"] = script
|
|
525
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
526
|
+
self.assertFalse(lint["ok"])
|
|
527
|
+
|
|
528
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
529
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
530
|
+
"const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; "
|
|
531
|
+
"return { 'from': offset, 'size': pageSize, 'track_total_hits': true };"
|
|
532
|
+
)
|
|
533
|
+
work["modules"][1]["config"]["config"] = (
|
|
534
|
+
"const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
|
|
535
|
+
"return { data: hits.map(hit => hit._source), pageInfo: { count: total } };"
|
|
536
|
+
)
|
|
537
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
538
|
+
self.assertTrue(lint["ok"], lint["errors"])
|
|
539
|
+
|
|
540
|
+
for source in (
|
|
541
|
+
"const cfg = { page_size: 1000000 }; const pageSize = cfg.page_size; const offset = ctx.pageInfo?.offset; return { from: offset, size: pageSize, track_total_hits: true };",
|
|
542
|
+
"ctx.pageInfo.pageSize = 1000000; const pageSize = ctx.pageInfo.pageSize; const offset = ctx.pageInfo.offset; return { from: offset, size: pageSize, track_total_hits: true };",
|
|
543
|
+
"const evil = (ctx.pageInfo.pageSize = 1000000); const pageSize = ctx.pageInfo.pageSize; const offset = ctx.pageInfo.offset; return { from: offset, size: pageSize, track_total_hits: true };",
|
|
544
|
+
"const evil = ctx.rows.reduce((value, row) => value + row.amount, 0); const pageSize = ctx.pageInfo.pageSize; const offset = ctx.pageInfo.offset; return { from: offset, size: pageSize, track_total_hits: true };",
|
|
545
|
+
):
|
|
546
|
+
with self.subTest(source=source):
|
|
547
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
548
|
+
work["modules"][1]["config"]["dataSource"] = source
|
|
549
|
+
work["modules"][1]["config"]["config"] = (
|
|
550
|
+
"const hits = ctx.data?.hits?.hits ?? []; const total = ctx.data?.hits?.total?.value ?? 0; "
|
|
551
|
+
"return { data: hits.map((hit) => hit._source), pageInfo: { count: total } };"
|
|
552
|
+
)
|
|
553
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
554
|
+
self.assertFalse(lint["ok"])
|
|
555
|
+
|
|
556
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
557
|
+
work["modules"][1]["config"]["dataSource"] = (
|
|
558
|
+
"const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; "
|
|
559
|
+
"return { from: offset, size: pageSize, track_total_hits: true };"
|
|
560
|
+
)
|
|
561
|
+
work["modules"][1]["config"]["config"] = (
|
|
562
|
+
"const hits = ctx.data?.hits?.hits ?? []; const total = ctx.data?.hits?.total?.value ?? 0; "
|
|
563
|
+
"return { data: hits.map((hit) => hit._source), pageInfo: { count: total } };"
|
|
564
|
+
)
|
|
565
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
566
|
+
self.assertTrue(lint["ok"], lint["errors"])
|
|
567
|
+
|
|
568
|
+
def test_lint_does_not_accept_nested_object_size_zero_as_aggregation(self) -> None:
|
|
569
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
570
|
+
work["modules"][1]["config"]["dataSource"] = {"driver": "es", "size": 1000000, "note": {"size": 0}}
|
|
571
|
+
work["modules"][1]["config"]["config"] = (
|
|
572
|
+
"const rows = ctx.data?.hits?.hits || []; return rows.map(row => ({ title: row._source.name, amount: row._source.total }));"
|
|
573
|
+
)
|
|
574
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
575
|
+
self.assertFalse(lint["ok"])
|
|
576
|
+
|
|
577
|
+
for source in (
|
|
578
|
+
"return { driver: 'es', size: 1000000, aggs: null };",
|
|
579
|
+
"return { driver: 'es', size: 0, aggs: {}, size: 1000000 };",
|
|
580
|
+
):
|
|
581
|
+
with self.subTest(source=source):
|
|
582
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
583
|
+
work["modules"][1]["config"]["dataSource"] = source
|
|
584
|
+
work["modules"][1]["config"]["config"] = (
|
|
585
|
+
"const rows = ctx.data?.hits?.hits || []; return rows.map(row => ({ title: row._source.name, amount: row._source.total }));"
|
|
586
|
+
)
|
|
587
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
588
|
+
self.assertFalse(lint["ok"])
|
|
589
|
+
|
|
590
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
591
|
+
work["modules"][1]["config"]["dataSource"] = {
|
|
592
|
+
"driver": "es", "size": 0, "aggs": None, "aggregations": {}
|
|
593
|
+
}
|
|
594
|
+
work["modules"][1]["config"]["config"] = (
|
|
595
|
+
"const rows = ctx.data?.hits?.hits || []; return rows.map(row => ({ title: row._source.name, amount: row._source.total }));"
|
|
596
|
+
)
|
|
597
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
598
|
+
self.assertTrue(lint["ok"], lint["errors"])
|
|
599
|
+
|
|
600
|
+
def test_lint_rejects_object_project_list_waiver_to_match_typed_cli(self) -> None:
|
|
601
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
602
|
+
work["modules"][0]["config"]["dataSource"] = {
|
|
603
|
+
"driver": "service",
|
|
604
|
+
"url": "/api/project/list",
|
|
605
|
+
"note": "bpmax-allow-user-scope-project-list: current user chooser",
|
|
606
|
+
}
|
|
607
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
608
|
+
self.assertFalse(lint["ok"])
|
|
609
|
+
self.assertTrue(any("project/list" in err for err in lint["errors"]))
|
|
610
|
+
|
|
611
|
+
def test_lint_rejects_unsafe_data_source_in_custom_module(self) -> None:
|
|
612
|
+
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
613
|
+
work["modules"].append({
|
|
614
|
+
"i": "custom_1",
|
|
615
|
+
"name": "自定义模块",
|
|
616
|
+
"config": {"dataSource": "return { driver: 'raw-es-search' };", "config": "return [];"},
|
|
617
|
+
})
|
|
618
|
+
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
619
|
+
self.assertFalse(lint["ok"])
|
|
620
|
+
self.assertTrue(any("raw-es-search" in err for err in lint["errors"]))
|
|
621
|
+
|
|
622
|
+
def test_lint_blocks_table_export_when_config_only_uses_page_size(self) -> None:
|
|
309
623
|
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|
|
310
624
|
work["modules"][1]["config"]["config"] = (
|
|
311
625
|
"const cfg = ctx.config || {}; "
|
|
@@ -315,8 +629,8 @@ class ConsoleTemplateEditorTests(unittest.TestCase):
|
|
|
315
629
|
|
|
316
630
|
lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
|
|
317
631
|
|
|
318
|
-
self.
|
|
319
|
-
self.assertTrue(any("TableSmart export" in
|
|
632
|
+
self.assertFalse(lint["ok"])
|
|
633
|
+
self.assertTrue(any("TableSmart export" in error for error in lint["errors"]))
|
|
320
634
|
|
|
321
635
|
def test_lint_blocks_empty_flow_binding_for_no_flow_console_list_visibility(self) -> None:
|
|
322
636
|
work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
|