bpmax-cli 0.1.43 → 0.1.44-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/bin.js +3397 -433
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-api-platform-editor/SKILL.md +321 -0
- package/skills/bpmax-api-platform-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-api-platform-editor/references/api-doc-debug-workflow.md +34 -0
- package/skills/bpmax-api-platform-editor/references/api-proxy-shape.md +41 -0
- package/skills/bpmax-api-platform-editor/references/instance-config-shape.md +41 -0
- package/skills/bpmax-api-platform-editor/references/platform-api-map.md +52 -0
- package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +32 -0
- package/skills/bpmax-api-platform-editor/scripts/api_platform_editor_common.py +1276 -0
- package/skills/bpmax-api-platform-editor/scripts/build_submit_payload.py +64 -0
- package/skills/bpmax-api-platform-editor/scripts/capture_write_contract.py +40 -0
- package/skills/bpmax-api-platform-editor/scripts/export_layer_bundle.py +212 -0
- package/skills/bpmax-api-platform-editor/scripts/record_doc_debug_acceptance.py +62 -0
- package/skills/bpmax-api-platform-editor/scripts/submit_and_verify_layer.py +75 -0
- package/skills/bpmax-api-platform-editor/tests/test_api_platform_editor.py +287 -0
- package/skills/bpmax-auth/SKILL.md +6 -17
- package/skills/bpmax-builder-shared/SKILL.md +44 -0
- package/skills/bpmax-builder-shared/base_url.py +81 -0
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.json +71 -0
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.md +34 -0
- package/skills/bpmax-builder-shared/runtime-script-template-catalog.md +123 -0
- package/skills/bpmax-builder-shared/runtime_script_rules.py +272 -0
- package/skills/bpmax-builder-shared/skill_audit.py +374 -0
- package/skills/bpmax-builder-shared/template_script_hard_rules.py +280 -0
- package/skills/bpmax-builder-shared/tests/test_base_url.py +80 -0
- package/skills/bpmax-builder-shared/tests/test_runtime_script_rules.py +115 -0
- package/skills/bpmax-builder-shared/tests/test_skill_audit.py +231 -0
- package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +281 -0
- package/skills/bpmax-cli/SKILL.md +2 -0
- package/skills/bpmax-config-latest/SKILL.md +71 -0
- package/skills/bpmax-console-template-editor/SKILL.md +536 -0
- package/skills/bpmax-console-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-console-template-editor/references/filter-integration.md +60 -0
- package/skills/bpmax-console-template-editor/references/lessons-from-resume-dashboard.md +114 -0
- package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +69 -0
- package/skills/bpmax-console-template-editor/references/module-catalog.md +100 -0
- package/skills/bpmax-console-template-editor/references/runtime-page-shape.md +91 -0
- package/skills/bpmax-console-template-editor/references/template-shape.md +149 -0
- package/skills/bpmax-console-template-editor/scripts/build_submit_payload.py +38 -0
- package/skills/bpmax-console-template-editor/scripts/confirm_console_template.py +33 -0
- package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +964 -0
- package/skills/bpmax-console-template-editor/scripts/export_console_template.py +99 -0
- package/skills/bpmax-console-template-editor/scripts/lint_console_template.py +46 -0
- package/skills/bpmax-console-template-editor/scripts/submit_console_template.py +99 -0
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +383 -0
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +600 -0
- package/skills/bpmax-dataset-field-template-editor/references/create-request-gotchas.md +25 -0
- package/skills/bpmax-dataset-field-template-editor/references/field-classify-mapping.md +35 -0
- package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +24 -0
- package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +61 -0
- package/skills/bpmax-dataset-field-template-editor/references/virtual-field-patterns.md +27 -0
- package/skills/bpmax-dataset-field-template-editor/references/work-file-to-submit-mapping.md +127 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/build_submit_payload.py +67 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/confirm_dataset_field.py +37 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +784 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +62 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +104 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +83 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/lint_dataset_field_semantics.py +35 -0
- package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +95 -0
- package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +709 -0
- package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +59 -0
- package/skills/bpmax-dataset-template-editor/SKILL.md +779 -0
- package/skills/bpmax-dataset-template-editor/references/custom-key-usage-patterns.md +18 -0
- package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +73 -0
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-authoring-guide.md +186 -0
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +106 -0
- package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +28 -0
- package/skills/bpmax-dataset-template-editor/references/runtime-verified-dataset-page-shape.md +47 -0
- package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +23 -0
- package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +97 -0
- package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +65 -0
- package/skills/bpmax-dataset-template-editor/scripts/build_submit_payload.py +38 -0
- package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +650 -0
- package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +155 -0
- package/skills/bpmax-dataset-template-editor/scripts/lint_dataset_template.py +42 -0
- package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +43 -0
- package/skills/bpmax-dataset-template-editor/scripts/scan_custom_key_references.py +27 -0
- package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +115 -0
- package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +52 -0
- package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +39 -0
- package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +373 -0
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +151 -0
- package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +4 -0
- package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +60 -0
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +371 -0
- package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +5 -0
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +97 -0
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +105 -0
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +36 -0
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +40 -0
- package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +33 -0
- package/skills/bpmax-e2e-flow-test-operator/references/failure-update-loop.md +17 -0
- package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +40 -0
- package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +19 -0
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +75 -0
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +107 -0
- package/skills/bpmax-e2e-flow-test-operator/references/skill-experience-coverage-matrix.md +29 -0
- package/skills/bpmax-e2e-flow-test-operator/references/stale-runtime-and-clean-sample-rules.md +54 -0
- package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +58 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/bpmax_session.py +287 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_plan.json +59 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_runner.py +687 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +95 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +288 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_api_matrix.py +161 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_filter_fields.py +138 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_form_runtime.py +396 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +341 -0
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +185 -0
- package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +138 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/SKILL.md +69 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-checklist.md +42 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-recipes.md +38 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-shape.md +86 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/gate-lint.md +68 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/hoocoo-patterns.md +39 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/runtime-behavior.md +41 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/script-authoring.md +110 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/scripts/lint_feishu_chat_plugin.py +278 -0
- package/skills/bpmax-feishu-chat-flow-plugin-editor/tests/test_lint_feishu_chat_plugin.py +203 -0
- package/skills/bpmax-filter-template-editor/SKILL.md +564 -0
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +38 -0
- package/skills/bpmax-filter-template-editor/references/filter-and-flow-binding.md +57 -0
- package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +141 -0
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +287 -0
- package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +115 -0
- package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +94 -0
- package/skills/bpmax-filter-template-editor/scripts/build_submit_payload.py +25 -0
- package/skills/bpmax-filter-template-editor/scripts/confirm_filter_template.py +22 -0
- package/skills/bpmax-filter-template-editor/scripts/export_filter_template.py +57 -0
- package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +348 -0
- package/skills/bpmax-filter-template-editor/scripts/init_create_filter_template.py +8 -0
- package/skills/bpmax-filter-template-editor/scripts/lint_filter_template_semantics.py +26 -0
- package/skills/bpmax-filter-template-editor/scripts/submit_filter_template.py +62 -0
- package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +231 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +1043 -0
- package/skills/bpmax-flow-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-flow-template-editor/references/before-next-step-script-runtime-gotchas.md +62 -0
- package/skills/bpmax-flow-template-editor/references/config-surfaces-and-placeholders.md +270 -0
- package/skills/bpmax-flow-template-editor/references/diff-strategy.md +67 -0
- package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +25 -0
- package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +159 -0
- package/skills/bpmax-flow-template-editor/references/intent-model.md +117 -0
- package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +147 -0
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +97 -0
- package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +163 -0
- package/skills/bpmax-flow-template-editor/references/payload-checklist.md +133 -0
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +54 -0
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +149 -0
- package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +41 -0
- package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +155 -0
- package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +179 -0
- package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +91 -0
- package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +93 -0
- package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +57 -0
- package/skills/bpmax-flow-template-editor/scripts/build_submit_payload.py +69 -0
- package/skills/bpmax-flow-template-editor/scripts/confirm_flow_template.py +52 -0
- package/skills/bpmax-flow-template-editor/scripts/export_flow_template.py +114 -0
- package/skills/bpmax-flow-template-editor/scripts/flow_template_editor_common.py +1084 -0
- package/skills/bpmax-flow-template-editor/scripts/submit_flow_template.py +159 -0
- package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +636 -0
- package/skills/bpmax-form-template-editor/SKILL.md +1074 -0
- package/skills/bpmax-form-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +193 -0
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +125 -0
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +77 -0
- package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +49 -0
- package/skills/bpmax-form-template-editor/scripts/build_submit_payload.py +37 -0
- package/skills/bpmax-form-template-editor/scripts/check_form_template_consistency.py +145 -0
- package/skills/bpmax-form-template-editor/scripts/confirm_form_template.py +67 -0
- package/skills/bpmax-form-template-editor/scripts/export_form_template.py +89 -0
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +1745 -0
- package/skills/bpmax-form-template-editor/scripts/lint_form_template_semantics.py +30 -0
- package/skills/bpmax-form-template-editor/scripts/record_runtime_acceptance.py +67 -0
- package/skills/bpmax-form-template-editor/scripts/submit_form_template.py +163 -0
- package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +1303 -0
- package/skills/bpmax-list-template-editor/SKILL.md +468 -0
- package/skills/bpmax-list-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-list-template-editor/references/browser-page-contract.md +81 -0
- package/skills/bpmax-list-template-editor/references/content-config-shape.md +148 -0
- package/skills/bpmax-list-template-editor/references/dataset-field-mapping.md +60 -0
- package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +103 -0
- package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +102 -0
- package/skills/bpmax-list-template-editor/references/payload-checklist.md +47 -0
- package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +140 -0
- package/skills/bpmax-list-template-editor/references/special-formats.md +394 -0
- package/skills/bpmax-list-template-editor/scripts/build_submit_payload.py +37 -0
- package/skills/bpmax-list-template-editor/scripts/confirm_list_template.py +33 -0
- package/skills/bpmax-list-template-editor/scripts/export_list_template.py +89 -0
- package/skills/bpmax-list-template-editor/scripts/fetch_data_set.py +34 -0
- package/skills/bpmax-list-template-editor/scripts/lint_list_template_semantics.py +54 -0
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +955 -0
- package/skills/bpmax-list-template-editor/scripts/record_acceptance.py +55 -0
- package/skills/bpmax-list-template-editor/scripts/submit_list_template.py +117 -0
- package/skills/bpmax-list-template-editor/tests/test_list_template_editor_common.py +441 -0
- package/skills/bpmax-nav-config-editor/SKILL.md +347 -0
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +68 -0
- package/skills/bpmax-nav-config-editor/references/config-shape.md +78 -0
- package/skills/bpmax-nav-config-editor/references/icon-selection.md +83 -0
- package/skills/bpmax-nav-config-editor/references/path-mapping-rules.md +46 -0
- package/skills/bpmax-nav-config-editor/references/payload-checklist.md +41 -0
- package/skills/bpmax-nav-config-editor/references/runtime-probing.md +47 -0
- package/skills/bpmax-nav-config-editor/scripts/build_submit_payload.py +34 -0
- package/skills/bpmax-nav-config-editor/scripts/confirm_nav_config.py +32 -0
- package/skills/bpmax-nav-config-editor/scripts/export_nav_config.py +56 -0
- package/skills/bpmax-nav-config-editor/scripts/lint_nav_config_semantics.py +33 -0
- package/skills/bpmax-nav-config-editor/scripts/nav_config_editor_common.py +812 -0
- package/skills/bpmax-nav-config-editor/scripts/submit_nav_config.py +44 -0
- package/skills/bpmax-nav-config-editor/scripts/verify_nav_config.py +33 -0
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor.py +358 -0
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor_common.py +138 -0
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_lint.py +58 -0
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_submit_verify.py +51 -0
- package/skills/bpmax-project/SKILL.md +1 -1
- package/skills/bpmax-project-detail-template-editor/SKILL.md +329 -0
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +4 -0
- package/skills/bpmax-project-detail-template-editor/references/local-temp-workflow.md +59 -0
- package/skills/bpmax-project-detail-template-editor/references/module-catalog-and-config-notes.md +47 -0
- package/skills/bpmax-project-detail-template-editor/references/payload-checklist.md +33 -0
- package/skills/bpmax-project-detail-template-editor/references/project-detail-template-api-workflow.md +44 -0
- package/skills/bpmax-project-detail-template-editor/scripts/build_submit_payload.py +30 -0
- package/skills/bpmax-project-detail-template-editor/scripts/confirm_project_detail_template.py +33 -0
- package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py +87 -0
- package/skills/bpmax-project-detail-template-editor/scripts/lint_project_detail_template_semantics.py +37 -0
- package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py +507 -0
- package/skills/bpmax-project-detail-template-editor/scripts/submit_project_detail_template.py +120 -0
- package/skills/bpmax-project-detail-template-editor/tests/test_project_detail_template_editor.py +369 -0
- package/skills/bpmax-role-editor/SKILL.md +251 -0
- package/skills/bpmax-role-editor/references/api-workflow.md +30 -0
- package/skills/bpmax-role-editor/references/runtime-page-shape.md +18 -0
- package/skills/bpmax-role-editor/references/work-file-mapping.md +32 -0
- package/skills/bpmax-role-editor/scripts/build_submit_payload.py +38 -0
- package/skills/bpmax-role-editor/scripts/confirm_role.py +33 -0
- package/skills/bpmax-role-editor/scripts/export_role.py +163 -0
- package/skills/bpmax-role-editor/scripts/lint_role_semantics.py +38 -0
- package/skills/bpmax-role-editor/scripts/role_editor_common.py +1231 -0
- package/skills/bpmax-role-editor/scripts/submit_role.py +144 -0
- package/skills/bpmax-role-editor/tests/test_role_editor.py +343 -0
- package/skills/bpmax-shared/SKILL.md +1 -1
- package/skills/form-control-library/SKILL.md +82 -0
- package/skills/form-control-library/agents/openai.yaml +4 -0
- package/skills/form-control-library/references/form-controls.md +199 -0
- package/skills/form-control-library/references/form-template-submit-schema.md +180 -0
- package/skills/form-control-library/references/group-select-runtime.md +191 -0
- package/skills/form-control-library/scripts/rebuild_form_control_library.py +55 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
|
|
6
|
+
from filter_template_editor_common import build_client, build_create_skeleton, detail_to_work_payload, dump_json, paths_for, write_diff
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main() -> int:
|
|
10
|
+
p = argparse.ArgumentParser(description="Export an online BPMAX filter-template into local temp files.")
|
|
11
|
+
p.add_argument("--template-id", type=int)
|
|
12
|
+
p.add_argument("--create-skeleton", action="store_true")
|
|
13
|
+
p.add_argument("--flow-type")
|
|
14
|
+
p.add_argument("--flow-key", default="")
|
|
15
|
+
p.add_argument("--name", default="")
|
|
16
|
+
p.add_argument("--desc", default="")
|
|
17
|
+
p.add_argument("--workspace")
|
|
18
|
+
p.add_argument("--base-url")
|
|
19
|
+
p.add_argument("--language", default="zhCN")
|
|
20
|
+
p.add_argument("--cookie-header")
|
|
21
|
+
p.add_argument("--timeout", type=float, default=30)
|
|
22
|
+
p.add_argument("--insecure", action="store_true")
|
|
23
|
+
args = p.parse_args()
|
|
24
|
+
if args.create_skeleton:
|
|
25
|
+
if not args.flow_type:
|
|
26
|
+
raise SystemExit("--flow-type is required for --create-skeleton")
|
|
27
|
+
stem = f"create-{args.flow_type}-{args.flow_key or 'default'}"
|
|
28
|
+
raw = {
|
|
29
|
+
"name": args.name,
|
|
30
|
+
"desc": args.desc,
|
|
31
|
+
"flow_type": args.flow_type,
|
|
32
|
+
"flow_key": args.flow_key,
|
|
33
|
+
"type": 3,
|
|
34
|
+
"status": 1,
|
|
35
|
+
"content": "{\"config\":[]}",
|
|
36
|
+
}
|
|
37
|
+
work = build_create_skeleton(flow_type=args.flow_type, flow_key=args.flow_key, name=args.name, desc=args.desc)
|
|
38
|
+
else:
|
|
39
|
+
if not args.template_id:
|
|
40
|
+
raise SystemExit("--template-id is required for edit export")
|
|
41
|
+
client = build_client(args)
|
|
42
|
+
raw = client.get_template(args.template_id).get("data") or {}
|
|
43
|
+
stem = str(args.template_id)
|
|
44
|
+
work = detail_to_work_payload(raw, mode="edit")
|
|
45
|
+
paths = paths_for(stem)
|
|
46
|
+
dump_json(paths["raw"], raw)
|
|
47
|
+
dump_json(paths["work"], work)
|
|
48
|
+
dump_json(paths["meta"], {"stem": stem, "mode": work.get("mode"), "workspace": getattr(args, "workspace", None), "status": "exported"})
|
|
49
|
+
write_diff(paths["work_diff"], raw, work, "raw", "work")
|
|
50
|
+
print(paths["raw"])
|
|
51
|
+
print(paths["work"])
|
|
52
|
+
print(paths["meta"])
|
|
53
|
+
return 0
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
if __name__ == "__main__":
|
|
57
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import copy
|
|
5
|
+
import hashlib
|
|
6
|
+
import json
|
|
7
|
+
import ssl
|
|
8
|
+
import sys
|
|
9
|
+
import urllib.error
|
|
10
|
+
import urllib.parse
|
|
11
|
+
import urllib.request
|
|
12
|
+
from dataclasses import dataclass
|
|
13
|
+
from datetime import datetime, timezone
|
|
14
|
+
from difflib import unified_diff
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any, Dict, Optional
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
DEFAULT_LANGUAGE = "zhCN"
|
|
20
|
+
REPO_ROOT = Path(__file__).resolve().parents[4]
|
|
21
|
+
SHARED_SKILL_ROOT = Path(__file__).resolve().parents[2] / "bpmax-builder-shared"
|
|
22
|
+
if str(SHARED_SKILL_ROOT) not in sys.path:
|
|
23
|
+
sys.path.insert(0, str(SHARED_SKILL_ROOT))
|
|
24
|
+
from base_url import resolve_base_url
|
|
25
|
+
TMP_ROOT = REPO_ROOT / ".codex" / "tmp" / "filter-template-editor"
|
|
26
|
+
TMP_SUBDIRS = ("raw", "work", "meta", "submit", "diffs", "result")
|
|
27
|
+
|
|
28
|
+
from template_script_hard_rules import scan_named_script_surfaces
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def utc_now_iso() -> str:
|
|
32
|
+
return datetime.now(timezone.utc).isoformat()
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def ensure_tmp_dirs() -> None:
|
|
36
|
+
for part in TMP_SUBDIRS:
|
|
37
|
+
(TMP_ROOT / part).mkdir(parents=True, exist_ok=True)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def paths_for(stem: str) -> Dict[str, Path]:
|
|
41
|
+
ensure_tmp_dirs()
|
|
42
|
+
return {
|
|
43
|
+
"raw": TMP_ROOT / "raw" / f"{stem}.json",
|
|
44
|
+
"work": TMP_ROOT / "work" / f"{stem}.json",
|
|
45
|
+
"meta": TMP_ROOT / "meta" / f"{stem}.json",
|
|
46
|
+
"submit": TMP_ROOT / "submit" / f"{stem}.json",
|
|
47
|
+
"work_diff": TMP_ROOT / "diffs" / f"{stem}.work.diff.txt",
|
|
48
|
+
"submit_diff": TMP_ROOT / "diffs" / f"{stem}.submit.diff.txt",
|
|
49
|
+
"response": TMP_ROOT / "result" / f"{stem}.response.json",
|
|
50
|
+
"readback": TMP_ROOT / "result" / f"{stem}.readback.json",
|
|
51
|
+
"verify": TMP_ROOT / "result" / f"{stem}.verify.json",
|
|
52
|
+
"lint": TMP_ROOT / "result" / f"{stem}.lint.json",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def dump_json(path: Path, payload: Any) -> None:
|
|
57
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
58
|
+
path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def load_json(path: Path) -> Any:
|
|
62
|
+
return json.loads(path.read_text(encoding="utf-8"))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def file_sha256(path: Path) -> str:
|
|
66
|
+
return hashlib.sha256(path.read_bytes()).hexdigest()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def stable_json_lines(payload: Any) -> list[str]:
|
|
70
|
+
return (json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n").splitlines(keepends=True)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def write_diff(path: Path, before: Any, after: Any, before_label: str, after_label: str) -> None:
|
|
74
|
+
diff = unified_diff(stable_json_lines(before), stable_json_lines(after), fromfile=before_label, tofile=after_label)
|
|
75
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
76
|
+
path.write_text("".join(diff) or "# no diff\n", encoding="utf-8")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def parse_content(value: Any) -> Dict[str, Any]:
|
|
80
|
+
if isinstance(value, dict):
|
|
81
|
+
return copy.deepcopy(value)
|
|
82
|
+
if isinstance(value, str):
|
|
83
|
+
text = value.strip()
|
|
84
|
+
if not text:
|
|
85
|
+
return {"config": []}
|
|
86
|
+
payload = json.loads(text)
|
|
87
|
+
if not isinstance(payload, dict):
|
|
88
|
+
raise SystemExit("filter content must be an object")
|
|
89
|
+
return payload
|
|
90
|
+
raise SystemExit("filter content must be a JSON string or object")
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def detail_to_work_payload(detail: Dict[str, Any], *, mode: str = "edit") -> Dict[str, Any]:
|
|
94
|
+
return {
|
|
95
|
+
"id": detail.get("id") if mode == "edit" else None,
|
|
96
|
+
"mode": mode,
|
|
97
|
+
"basic": {
|
|
98
|
+
"name": detail.get("name", ""),
|
|
99
|
+
"desc": detail.get("desc", ""),
|
|
100
|
+
"flow_type": detail.get("flow_type", ""),
|
|
101
|
+
"flow_key": detail.get("flow_key", ""),
|
|
102
|
+
"type": 3,
|
|
103
|
+
"status": detail.get("status", 1),
|
|
104
|
+
},
|
|
105
|
+
"content": parse_content(detail.get("content")),
|
|
106
|
+
"detailOnly": {"searchTemp": copy.deepcopy(detail.get("searchTemp"))},
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def build_create_skeleton(*, flow_type: str, flow_key: str = "", name: str = "", desc: str = "") -> Dict[str, Any]:
|
|
111
|
+
return {
|
|
112
|
+
"id": None,
|
|
113
|
+
"mode": "create",
|
|
114
|
+
"basic": {
|
|
115
|
+
"name": name,
|
|
116
|
+
"desc": desc,
|
|
117
|
+
"flow_type": flow_type,
|
|
118
|
+
"flow_key": flow_key,
|
|
119
|
+
"type": 3,
|
|
120
|
+
"status": 1,
|
|
121
|
+
},
|
|
122
|
+
"content": {"config": []},
|
|
123
|
+
"detailOnly": {"searchTemp": None},
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def build_submit_payload(work: Dict[str, Any]) -> Dict[str, Any]:
|
|
128
|
+
basic = copy.deepcopy(work.get("basic") or {})
|
|
129
|
+
content = copy.deepcopy(work.get("content") or {})
|
|
130
|
+
if not isinstance(content.get("config", []), list):
|
|
131
|
+
raise SystemExit("content.config must be an array")
|
|
132
|
+
submit = {
|
|
133
|
+
"name": basic.get("name", ""),
|
|
134
|
+
"desc": basic.get("desc", ""),
|
|
135
|
+
"flow_type": basic.get("flow_type", ""),
|
|
136
|
+
"flow_key": basic.get("flow_key", ""),
|
|
137
|
+
"type": 3,
|
|
138
|
+
"content": json.dumps(content, ensure_ascii=False),
|
|
139
|
+
}
|
|
140
|
+
if work.get("mode") == "create":
|
|
141
|
+
submit["status"] = basic.get("status", 1)
|
|
142
|
+
return submit
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def lint_filter_template_semantics(work_payload: Dict[str, Any], *, submit_payload: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
146
|
+
payload = submit_payload or build_submit_payload(work_payload)
|
|
147
|
+
report: Dict[str, Any] = {"ok": True, "errors": [], "warnings": [], "checks": {}}
|
|
148
|
+
content = parse_content(payload.get("content"))
|
|
149
|
+
config = content.get("config") or []
|
|
150
|
+
if not isinstance(config, list):
|
|
151
|
+
report["errors"].append("content.config must be an array")
|
|
152
|
+
if payload.get("type") != 3:
|
|
153
|
+
report["errors"].append("submit.type must be 3")
|
|
154
|
+
hard_rule_report = scan_named_script_surfaces(
|
|
155
|
+
[
|
|
156
|
+
{"path": "content.config", "value": config},
|
|
157
|
+
{"path": "content.customQuery", "value": content.get("customQuery")},
|
|
158
|
+
{"path": "content.beforeSearch", "value": content.get("beforeSearch")},
|
|
159
|
+
{"path": "content.tabFilters", "value": content.get("tabFilters")},
|
|
160
|
+
]
|
|
161
|
+
)
|
|
162
|
+
report["checks"]["scriptHardRules"] = hard_rule_report["findings"]
|
|
163
|
+
report["errors"].extend(hard_rule_report["errors"])
|
|
164
|
+
report["checks"]["configCount"] = len(config) if isinstance(config, list) else None
|
|
165
|
+
report["ok"] = not report["errors"]
|
|
166
|
+
return report
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def summarize_verification(submit_payload: Dict[str, Any], readback_detail: Dict[str, Any]) -> Dict[str, Any]:
|
|
170
|
+
checks: Dict[str, Dict[str, Any]] = {}
|
|
171
|
+
ok = True
|
|
172
|
+
for key in ("name", "desc", "flow_type", "flow_key", "type"):
|
|
173
|
+
expected = submit_payload.get(key)
|
|
174
|
+
actual = readback_detail.get(key)
|
|
175
|
+
match = expected == actual
|
|
176
|
+
checks[key] = {"match": match, "expected": expected, "actual": actual}
|
|
177
|
+
ok = ok and match
|
|
178
|
+
|
|
179
|
+
expected_content = parse_content(submit_payload.get("content"))
|
|
180
|
+
actual_content = parse_content(readback_detail.get("content"))
|
|
181
|
+
content_match = expected_content == actual_content
|
|
182
|
+
checks["content"] = {
|
|
183
|
+
"match": content_match,
|
|
184
|
+
"expectedSummary": {
|
|
185
|
+
"configCount": len(expected_content.get("config") or []),
|
|
186
|
+
"hasCustomQuery": "customQuery" in expected_content,
|
|
187
|
+
"hasBeforeSearch": "beforeSearch" in expected_content,
|
|
188
|
+
"hasTabFilters": "tabFilters" in expected_content,
|
|
189
|
+
},
|
|
190
|
+
"actualSummary": {
|
|
191
|
+
"configCount": len(actual_content.get("config") or []),
|
|
192
|
+
"hasCustomQuery": "customQuery" in actual_content,
|
|
193
|
+
"hasBeforeSearch": "beforeSearch" in actual_content,
|
|
194
|
+
"hasTabFilters": "tabFilters" in actual_content,
|
|
195
|
+
},
|
|
196
|
+
}
|
|
197
|
+
ok = ok and content_match
|
|
198
|
+
|
|
199
|
+
return {
|
|
200
|
+
"ok": ok,
|
|
201
|
+
"checks": checks,
|
|
202
|
+
"submittedContent": expected_content,
|
|
203
|
+
"readbackContent": actual_content,
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def extract_template_id(response_payload: Dict[str, Any]) -> int | None:
|
|
208
|
+
data = response_payload.get("data")
|
|
209
|
+
if isinstance(data, dict) and isinstance(data.get("id"), int):
|
|
210
|
+
return data["id"]
|
|
211
|
+
if isinstance(response_payload.get("id"), int):
|
|
212
|
+
return response_payload["id"]
|
|
213
|
+
return None
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def ensure_meta_shape(meta: Dict[str, Any], stem: str) -> Dict[str, Any]:
|
|
217
|
+
payload = dict(meta)
|
|
218
|
+
payload.setdefault("stem", stem)
|
|
219
|
+
payload.setdefault("status", "exported")
|
|
220
|
+
payload.setdefault("mode", None)
|
|
221
|
+
payload.setdefault("workspace", None)
|
|
222
|
+
payload.setdefault("workSha256", None)
|
|
223
|
+
payload.setdefault("submitSha256", None)
|
|
224
|
+
payload.setdefault("workConfirmedAt", None)
|
|
225
|
+
payload.setdefault("submitConfirmedAt", None)
|
|
226
|
+
payload.setdefault("submitBuiltAt", None)
|
|
227
|
+
payload.setdefault("lintPassed", False)
|
|
228
|
+
payload.setdefault("lintSha256", None)
|
|
229
|
+
payload.setdefault("lintedAt", None)
|
|
230
|
+
return payload
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def update_confirmation_state(meta_path: Path, *, stem: str, actor: str, stage: str, work_path: Path, submit_path: Optional[Path] = None) -> Dict[str, Any]:
|
|
234
|
+
payload = ensure_meta_shape(load_json(meta_path) if meta_path.exists() else {}, stem)
|
|
235
|
+
payload["workSha256"] = file_sha256(work_path)
|
|
236
|
+
now = utc_now_iso()
|
|
237
|
+
if stage == "work":
|
|
238
|
+
payload["workConfirmedAt"] = now
|
|
239
|
+
payload["submitConfirmedAt"] = None
|
|
240
|
+
payload["status"] = "work_confirmed"
|
|
241
|
+
elif stage == "submit":
|
|
242
|
+
if submit_path is None or not submit_path.exists():
|
|
243
|
+
raise SystemExit("submit confirmation requires existing submit file")
|
|
244
|
+
if payload.get("status") not in ("submit_built", "lint_passed"):
|
|
245
|
+
raise SystemExit("submit confirmation requires submit_built or lint_passed status")
|
|
246
|
+
payload["submitSha256"] = file_sha256(submit_path)
|
|
247
|
+
payload["submitConfirmedAt"] = now
|
|
248
|
+
payload["status"] = "submit_confirmed"
|
|
249
|
+
else:
|
|
250
|
+
raise SystemExit(f"unsupported confirmation stage: {stage}")
|
|
251
|
+
dump_json(meta_path, payload)
|
|
252
|
+
return payload
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def update_build_meta(meta_path: Path, *, stem: str, work_path: Path, submit_path: Path) -> Dict[str, Any]:
|
|
256
|
+
payload = ensure_meta_shape(load_json(meta_path) if meta_path.exists() else {}, stem)
|
|
257
|
+
payload["workSha256"] = file_sha256(work_path)
|
|
258
|
+
payload["submitSha256"] = file_sha256(submit_path)
|
|
259
|
+
payload["submitBuiltAt"] = utc_now_iso()
|
|
260
|
+
payload["lintPassed"] = False
|
|
261
|
+
payload["lintSha256"] = None
|
|
262
|
+
payload["lintedAt"] = None
|
|
263
|
+
payload["status"] = "submit_built"
|
|
264
|
+
dump_json(meta_path, payload)
|
|
265
|
+
return payload
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def update_lint_meta(meta_path: Path, *, stem: str, submit_path: Path, lint_path: Path, report: Dict[str, Any]) -> Dict[str, Any]:
|
|
269
|
+
payload = ensure_meta_shape(load_json(meta_path) if meta_path.exists() else {}, stem)
|
|
270
|
+
payload["submitSha256"] = file_sha256(submit_path)
|
|
271
|
+
payload["lintPassed"] = bool(report.get("ok"))
|
|
272
|
+
payload["lintSha256"] = file_sha256(lint_path)
|
|
273
|
+
payload["lintedAt"] = utc_now_iso()
|
|
274
|
+
payload["status"] = "lint_passed" if report.get("ok") else "lint_failed"
|
|
275
|
+
dump_json(meta_path, payload)
|
|
276
|
+
return payload
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def ensure_submission_allowed(meta_path: Path, work_path: Path, submit_path: Path) -> Dict[str, Any]:
|
|
280
|
+
if not meta_path.exists():
|
|
281
|
+
raise SystemExit("missing meta confirmation file")
|
|
282
|
+
meta_raw = load_json(meta_path)
|
|
283
|
+
meta = ensure_meta_shape(meta_raw, meta_raw.get("stem", "unknown"))
|
|
284
|
+
if meta.get("status") != "submit_confirmed":
|
|
285
|
+
raise SystemExit("submission blocked: current status is not submit_confirmed")
|
|
286
|
+
if meta.get("lintPassed") is not True:
|
|
287
|
+
raise SystemExit("submission blocked: lint has not passed")
|
|
288
|
+
if meta.get("workSha256") != file_sha256(work_path):
|
|
289
|
+
raise SystemExit("submission blocked: work file changed after confirmation")
|
|
290
|
+
if meta.get("submitSha256") != file_sha256(submit_path):
|
|
291
|
+
raise SystemExit("submission blocked: submit file changed after confirmation")
|
|
292
|
+
lint_report = lint_filter_template_semantics(load_json(work_path), submit_payload=load_json(submit_path))
|
|
293
|
+
if lint_report["errors"]:
|
|
294
|
+
raise SystemExit("submission blocked by lint: " + "; ".join(lint_report["errors"]))
|
|
295
|
+
return meta
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
@dataclass
|
|
299
|
+
class ApiClient:
|
|
300
|
+
base_url: str
|
|
301
|
+
workspace: str
|
|
302
|
+
language: str
|
|
303
|
+
cookie_header: str
|
|
304
|
+
timeout: float
|
|
305
|
+
insecure: bool = False
|
|
306
|
+
|
|
307
|
+
def _build_url(self, path: str) -> str:
|
|
308
|
+
suffix = f"$workspace={urllib.parse.quote(self.workspace)}&$language={urllib.parse.quote(self.language)}"
|
|
309
|
+
joiner = "&" if "?" in path else "?"
|
|
310
|
+
return self.base_url.rstrip("/") + path + joiner + suffix
|
|
311
|
+
|
|
312
|
+
def request(self, method: str, path: str, body: Optional[dict] = None) -> dict:
|
|
313
|
+
headers = {"content-type": "application/json", "cookie": self.cookie_header, "accept": "application/json, text/plain, */*"}
|
|
314
|
+
data = None if body is None else json.dumps(body, ensure_ascii=False).encode("utf-8")
|
|
315
|
+
req = urllib.request.Request(self._build_url(path), data=data, headers=headers, method=method)
|
|
316
|
+
context = ssl._create_unverified_context() if self.insecure else None
|
|
317
|
+
with urllib.request.urlopen(req, timeout=self.timeout, context=context) as resp:
|
|
318
|
+
raw = resp.read().decode("utf-8", "replace")
|
|
319
|
+
payload = json.loads(raw)
|
|
320
|
+
if payload.get("code") != 0:
|
|
321
|
+
raise SystemExit(f"API error {path}: {raw}")
|
|
322
|
+
return payload
|
|
323
|
+
|
|
324
|
+
def get_template(self, template_id: int) -> dict:
|
|
325
|
+
return self.request("GET", f"/api/flow_page_template/{template_id}?skip_i18n=true")
|
|
326
|
+
|
|
327
|
+
def create_template(self, payload: dict) -> dict:
|
|
328
|
+
return self.request("POST", "/api/flow_page_template", payload)
|
|
329
|
+
|
|
330
|
+
def update_template(self, template_id: int, payload: dict) -> dict:
|
|
331
|
+
return self.request("PUT", f"/api/flow_page_template/{template_id}", payload)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def build_client(args: Any) -> ApiClient:
|
|
335
|
+
workspace = getattr(args, "workspace", None)
|
|
336
|
+
cookie_header = getattr(args, "cookie_header", None)
|
|
337
|
+
if not workspace:
|
|
338
|
+
raise SystemExit("--workspace is required")
|
|
339
|
+
if not cookie_header:
|
|
340
|
+
raise SystemExit("--cookie-header is required")
|
|
341
|
+
return ApiClient(
|
|
342
|
+
base_url=resolve_base_url(getattr(args, "base_url", None)),
|
|
343
|
+
workspace=workspace,
|
|
344
|
+
language=getattr(args, "language", None) or DEFAULT_LANGUAGE,
|
|
345
|
+
cookie_header=cookie_header,
|
|
346
|
+
timeout=float(getattr(args, "timeout", 30)),
|
|
347
|
+
insecure=bool(getattr(args, "insecure", False)),
|
|
348
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
|
|
6
|
+
from filter_template_editor_common import dump_json, lint_filter_template_semantics, load_json, paths_for, update_lint_meta
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main() -> int:
|
|
10
|
+
p = argparse.ArgumentParser(description="Run semantic lint checks for a local BPMAX filter-template work/submit pair.")
|
|
11
|
+
p.add_argument("--stem", required=True)
|
|
12
|
+
args = p.parse_args()
|
|
13
|
+
paths = paths_for(args.stem)
|
|
14
|
+
work = load_json(paths["work"])
|
|
15
|
+
submit = load_json(paths["submit"])
|
|
16
|
+
report = lint_filter_template_semantics(work, submit_payload=submit)
|
|
17
|
+
dump_json(paths["lint"], report)
|
|
18
|
+
update_lint_meta(paths["meta"], stem=args.stem, submit_path=paths["submit"], lint_path=paths["lint"], report=report)
|
|
19
|
+
print(paths["lint"])
|
|
20
|
+
if not report["ok"]:
|
|
21
|
+
raise SystemExit("filter-template lint failed; inspect lint.json for details")
|
|
22
|
+
return 0
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
if __name__ == "__main__":
|
|
26
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
print(
|
|
7
|
+
"Legacy config submit scripts are disabled in bpmax-cli. Use `bpmax-cli config filter-template submit` so capability, dry-run, confirmation, audit, and baseline checks are enforced.",
|
|
8
|
+
file=sys.stderr,
|
|
9
|
+
)
|
|
10
|
+
sys.exit(2)
|
|
11
|
+
|
|
12
|
+
import argparse
|
|
13
|
+
|
|
14
|
+
from filter_template_editor_common import (
|
|
15
|
+
build_client,
|
|
16
|
+
dump_json,
|
|
17
|
+
ensure_submission_allowed,
|
|
18
|
+
extract_template_id,
|
|
19
|
+
load_json,
|
|
20
|
+
paths_for,
|
|
21
|
+
summarize_verification,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def main() -> int:
|
|
26
|
+
p = argparse.ArgumentParser(description="Submit a local BPMAX filter-template payload and verify readback.")
|
|
27
|
+
p.add_argument("--stem", required=True)
|
|
28
|
+
p.add_argument("--workspace")
|
|
29
|
+
p.add_argument("--base-url")
|
|
30
|
+
p.add_argument("--language", default="zhCN")
|
|
31
|
+
p.add_argument("--cookie-header")
|
|
32
|
+
p.add_argument("--timeout", type=float, default=30)
|
|
33
|
+
p.add_argument("--insecure", action="store_true")
|
|
34
|
+
args = p.parse_args()
|
|
35
|
+
paths = paths_for(args.stem)
|
|
36
|
+
meta = ensure_submission_allowed(paths["meta"], paths["work"], paths["submit"])
|
|
37
|
+
client = build_client(args)
|
|
38
|
+
submit_payload = load_json(paths["submit"])
|
|
39
|
+
if meta.get("mode") == "create":
|
|
40
|
+
response = client.create_template(submit_payload)
|
|
41
|
+
template_id = extract_template_id(response)
|
|
42
|
+
if not template_id:
|
|
43
|
+
raise SystemExit("create response did not include a template id")
|
|
44
|
+
else:
|
|
45
|
+
template_id = int(args.stem)
|
|
46
|
+
response = client.update_template(template_id, submit_payload)
|
|
47
|
+
readback = (client.get_template(template_id).get("data") or {})
|
|
48
|
+
verification = summarize_verification(submit_payload, readback)
|
|
49
|
+
verify = {"ok": verification["ok"], "templateId": template_id, "verification": verification}
|
|
50
|
+
dump_json(paths["response"], response)
|
|
51
|
+
dump_json(paths["readback"], readback)
|
|
52
|
+
dump_json(paths["verify"], verify)
|
|
53
|
+
print(paths["response"])
|
|
54
|
+
print(paths["readback"])
|
|
55
|
+
print(paths["verify"])
|
|
56
|
+
if not verify["ok"]:
|
|
57
|
+
raise SystemExit("filter-template verify failed; inspect verify.json for details")
|
|
58
|
+
return 0
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if __name__ == "__main__":
|
|
62
|
+
raise SystemExit(main())
|