bpmax-cli 0.1.44-beta.8 → 0.1.44
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 +5 -3
- package/dist/bin.js +466 -4578
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/scripts/install-skills.mjs +0 -98
- package/skills/bpmax-auth/SKILL.md +17 -6
- package/skills/bpmax-cli/SKILL.md +0 -2
- package/skills/bpmax-project/SKILL.md +2 -1
- package/skills/bpmax-shared/SKILL.md +1 -1
- package/skills/bpmax-api-platform-editor/SKILL.md +0 -321
- package/skills/bpmax-api-platform-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-api-platform-editor/references/api-doc-debug-workflow.md +0 -34
- package/skills/bpmax-api-platform-editor/references/api-proxy-shape.md +0 -41
- package/skills/bpmax-api-platform-editor/references/instance-config-shape.md +0 -41
- package/skills/bpmax-api-platform-editor/references/platform-api-map.md +0 -52
- package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +0 -32
- package/skills/bpmax-api-platform-editor/scripts/api_platform_editor_common.py +0 -1276
- package/skills/bpmax-api-platform-editor/scripts/build_submit_payload.py +0 -64
- package/skills/bpmax-api-platform-editor/scripts/capture_write_contract.py +0 -40
- package/skills/bpmax-api-platform-editor/scripts/export_layer_bundle.py +0 -212
- package/skills/bpmax-api-platform-editor/scripts/record_doc_debug_acceptance.py +0 -62
- package/skills/bpmax-api-platform-editor/scripts/submit_and_verify_layer.py +0 -75
- package/skills/bpmax-api-platform-editor/tests/test_api_platform_editor.py +0 -287
- package/skills/bpmax-builder-shared/SKILL.md +0 -44
- package/skills/bpmax-builder-shared/base_url.py +0 -81
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.json +0 -71
- package/skills/bpmax-builder-shared/runtime-script-site-matrix.md +0 -34
- package/skills/bpmax-builder-shared/runtime-script-template-catalog.md +0 -123
- package/skills/bpmax-builder-shared/runtime_script_rules.py +0 -272
- package/skills/bpmax-builder-shared/skill_audit.py +0 -374
- package/skills/bpmax-builder-shared/template_script_hard_rules.py +0 -280
- package/skills/bpmax-builder-shared/tests/test_base_url.py +0 -80
- package/skills/bpmax-builder-shared/tests/test_runtime_script_rules.py +0 -115
- package/skills/bpmax-builder-shared/tests/test_skill_audit.py +0 -231
- package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +0 -281
- package/skills/bpmax-config-latest/SKILL.md +0 -71
- package/skills/bpmax-console-template-editor/SKILL.md +0 -536
- package/skills/bpmax-console-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-console-template-editor/references/filter-integration.md +0 -60
- package/skills/bpmax-console-template-editor/references/lessons-from-resume-dashboard.md +0 -114
- package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +0 -69
- package/skills/bpmax-console-template-editor/references/module-catalog.md +0 -100
- package/skills/bpmax-console-template-editor/references/runtime-page-shape.md +0 -91
- package/skills/bpmax-console-template-editor/references/template-shape.md +0 -149
- package/skills/bpmax-console-template-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-console-template-editor/scripts/confirm_console_template.py +0 -33
- package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +0 -964
- package/skills/bpmax-console-template-editor/scripts/export_console_template.py +0 -99
- package/skills/bpmax-console-template-editor/scripts/lint_console_template.py +0 -46
- package/skills/bpmax-console-template-editor/scripts/submit_console_template.py +0 -99
- package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +0 -383
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +0 -600
- package/skills/bpmax-dataset-field-template-editor/references/create-request-gotchas.md +0 -25
- package/skills/bpmax-dataset-field-template-editor/references/field-classify-mapping.md +0 -35
- package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +0 -24
- package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +0 -61
- package/skills/bpmax-dataset-field-template-editor/references/virtual-field-patterns.md +0 -27
- package/skills/bpmax-dataset-field-template-editor/references/work-file-to-submit-mapping.md +0 -127
- package/skills/bpmax-dataset-field-template-editor/scripts/build_submit_payload.py +0 -67
- package/skills/bpmax-dataset-field-template-editor/scripts/confirm_dataset_field.py +0 -37
- package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +0 -784
- package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +0 -62
- package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +0 -104
- package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +0 -83
- package/skills/bpmax-dataset-field-template-editor/scripts/lint_dataset_field_semantics.py +0 -35
- package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +0 -95
- package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +0 -709
- package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +0 -59
- package/skills/bpmax-dataset-template-editor/SKILL.md +0 -779
- package/skills/bpmax-dataset-template-editor/references/custom-key-usage-patterns.md +0 -18
- package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +0 -73
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-authoring-guide.md +0 -186
- package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +0 -106
- package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +0 -28
- package/skills/bpmax-dataset-template-editor/references/runtime-verified-dataset-page-shape.md +0 -47
- package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +0 -23
- package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +0 -97
- package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +0 -65
- package/skills/bpmax-dataset-template-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +0 -650
- package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +0 -155
- package/skills/bpmax-dataset-template-editor/scripts/lint_dataset_template.py +0 -42
- package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +0 -43
- package/skills/bpmax-dataset-template-editor/scripts/scan_custom_key_references.py +0 -27
- package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +0 -115
- package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +0 -52
- package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +0 -39
- package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +0 -373
- package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +0 -177
- package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +0 -4
- package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +0 -60
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +0 -394
- package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +0 -5
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +0 -97
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +0 -105
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +0 -36
- package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +0 -40
- package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +0 -41
- package/skills/bpmax-e2e-flow-test-operator/references/failure-update-loop.md +0 -17
- package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +0 -40
- package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +0 -24
- package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +0 -75
- package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +0 -107
- package/skills/bpmax-e2e-flow-test-operator/references/skill-experience-coverage-matrix.md +0 -29
- package/skills/bpmax-e2e-flow-test-operator/references/stale-runtime-and-clean-sample-rules.md +0 -54
- package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +0 -83
- package/skills/bpmax-e2e-flow-test-operator/scripts/bpmax_session.py +0 -287
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_plan.json +0 -59
- package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_runner.py +0 -687
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +0 -121
- package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +0 -288
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_api_matrix.py +0 -161
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_filter_fields.py +0 -138
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_form_runtime.py +0 -396
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +0 -341
- package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +0 -185
- package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +0 -138
- package/skills/bpmax-feishu-chat-flow-plugin-editor/SKILL.md +0 -69
- package/skills/bpmax-feishu-chat-flow-plugin-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-checklist.md +0 -42
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-recipes.md +0 -38
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-shape.md +0 -86
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/gate-lint.md +0 -68
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/hoocoo-patterns.md +0 -39
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/runtime-behavior.md +0 -41
- package/skills/bpmax-feishu-chat-flow-plugin-editor/references/script-authoring.md +0 -110
- package/skills/bpmax-feishu-chat-flow-plugin-editor/scripts/lint_feishu_chat_plugin.py +0 -278
- package/skills/bpmax-feishu-chat-flow-plugin-editor/tests/test_lint_feishu_chat_plugin.py +0 -203
- package/skills/bpmax-filter-template-editor/SKILL.md +0 -564
- package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +0 -38
- package/skills/bpmax-filter-template-editor/references/filter-and-flow-binding.md +0 -57
- package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +0 -141
- package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +0 -287
- package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +0 -115
- package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +0 -94
- package/skills/bpmax-filter-template-editor/scripts/build_submit_payload.py +0 -25
- package/skills/bpmax-filter-template-editor/scripts/confirm_filter_template.py +0 -22
- package/skills/bpmax-filter-template-editor/scripts/export_filter_template.py +0 -57
- package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +0 -348
- package/skills/bpmax-filter-template-editor/scripts/init_create_filter_template.py +0 -8
- package/skills/bpmax-filter-template-editor/scripts/lint_filter_template_semantics.py +0 -26
- package/skills/bpmax-filter-template-editor/scripts/submit_filter_template.py +0 -62
- package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +0 -231
- package/skills/bpmax-flow-template-editor/SKILL.md +0 -1058
- package/skills/bpmax-flow-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-flow-template-editor/references/before-next-step-script-runtime-gotchas.md +0 -62
- package/skills/bpmax-flow-template-editor/references/config-surfaces-and-placeholders.md +0 -270
- package/skills/bpmax-flow-template-editor/references/diff-strategy.md +0 -67
- package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +0 -25
- package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +0 -174
- package/skills/bpmax-flow-template-editor/references/intent-model.md +0 -117
- package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +0 -147
- package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +0 -97
- package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +0 -165
- package/skills/bpmax-flow-template-editor/references/payload-checklist.md +0 -133
- package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +0 -54
- package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +0 -149
- package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +0 -41
- package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +0 -155
- package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +0 -179
- package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +0 -91
- package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +0 -93
- package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +0 -57
- package/skills/bpmax-flow-template-editor/scripts/build_submit_payload.py +0 -69
- package/skills/bpmax-flow-template-editor/scripts/confirm_flow_template.py +0 -52
- package/skills/bpmax-flow-template-editor/scripts/export_flow_template.py +0 -114
- package/skills/bpmax-flow-template-editor/scripts/flow_template_editor_common.py +0 -1084
- package/skills/bpmax-flow-template-editor/scripts/submit_flow_template.py +0 -159
- package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +0 -636
- package/skills/bpmax-form-template-editor/SKILL.md +0 -1099
- package/skills/bpmax-form-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +0 -203
- package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +0 -125
- package/skills/bpmax-form-template-editor/references/payload-checklist.md +0 -77
- package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +0 -49
- package/skills/bpmax-form-template-editor/scripts/build_submit_payload.py +0 -37
- package/skills/bpmax-form-template-editor/scripts/check_form_template_consistency.py +0 -145
- package/skills/bpmax-form-template-editor/scripts/confirm_form_template.py +0 -67
- package/skills/bpmax-form-template-editor/scripts/export_form_template.py +0 -91
- package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +0 -1762
- package/skills/bpmax-form-template-editor/scripts/lint_form_template_semantics.py +0 -30
- package/skills/bpmax-form-template-editor/scripts/record_runtime_acceptance.py +0 -67
- package/skills/bpmax-form-template-editor/scripts/submit_form_template.py +0 -163
- package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +0 -1292
- package/skills/bpmax-list-template-editor/SKILL.md +0 -468
- package/skills/bpmax-list-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-list-template-editor/references/browser-page-contract.md +0 -81
- package/skills/bpmax-list-template-editor/references/content-config-shape.md +0 -148
- package/skills/bpmax-list-template-editor/references/dataset-field-mapping.md +0 -60
- package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +0 -103
- package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +0 -102
- package/skills/bpmax-list-template-editor/references/payload-checklist.md +0 -47
- package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +0 -140
- package/skills/bpmax-list-template-editor/references/special-formats.md +0 -394
- package/skills/bpmax-list-template-editor/scripts/build_submit_payload.py +0 -37
- package/skills/bpmax-list-template-editor/scripts/confirm_list_template.py +0 -33
- package/skills/bpmax-list-template-editor/scripts/export_list_template.py +0 -89
- package/skills/bpmax-list-template-editor/scripts/fetch_data_set.py +0 -34
- package/skills/bpmax-list-template-editor/scripts/lint_list_template_semantics.py +0 -54
- package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +0 -955
- package/skills/bpmax-list-template-editor/scripts/record_acceptance.py +0 -55
- package/skills/bpmax-list-template-editor/scripts/submit_list_template.py +0 -117
- package/skills/bpmax-list-template-editor/tests/test_list_template_editor_common.py +0 -441
- package/skills/bpmax-memory-protocol/SKILL.md +0 -72
- package/skills/bpmax-nav-config-editor/SKILL.md +0 -347
- package/skills/bpmax-nav-config-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-nav-config-editor/references/api-workflow.md +0 -68
- package/skills/bpmax-nav-config-editor/references/config-shape.md +0 -78
- package/skills/bpmax-nav-config-editor/references/icon-selection.md +0 -83
- package/skills/bpmax-nav-config-editor/references/path-mapping-rules.md +0 -46
- package/skills/bpmax-nav-config-editor/references/payload-checklist.md +0 -41
- package/skills/bpmax-nav-config-editor/references/runtime-probing.md +0 -47
- package/skills/bpmax-nav-config-editor/scripts/build_submit_payload.py +0 -34
- package/skills/bpmax-nav-config-editor/scripts/confirm_nav_config.py +0 -32
- package/skills/bpmax-nav-config-editor/scripts/export_nav_config.py +0 -56
- package/skills/bpmax-nav-config-editor/scripts/lint_nav_config_semantics.py +0 -33
- package/skills/bpmax-nav-config-editor/scripts/nav_config_editor_common.py +0 -812
- package/skills/bpmax-nav-config-editor/scripts/submit_nav_config.py +0 -44
- package/skills/bpmax-nav-config-editor/scripts/verify_nav_config.py +0 -33
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor.py +0 -358
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor_common.py +0 -138
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_lint.py +0 -58
- package/skills/bpmax-nav-config-editor/tests/test_nav_config_submit_verify.py +0 -51
- package/skills/bpmax-project-detail-template-editor/SKILL.md +0 -329
- package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +0 -4
- package/skills/bpmax-project-detail-template-editor/references/local-temp-workflow.md +0 -59
- package/skills/bpmax-project-detail-template-editor/references/module-catalog-and-config-notes.md +0 -47
- package/skills/bpmax-project-detail-template-editor/references/payload-checklist.md +0 -33
- package/skills/bpmax-project-detail-template-editor/references/project-detail-template-api-workflow.md +0 -44
- package/skills/bpmax-project-detail-template-editor/scripts/build_submit_payload.py +0 -30
- package/skills/bpmax-project-detail-template-editor/scripts/confirm_project_detail_template.py +0 -33
- package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py +0 -87
- package/skills/bpmax-project-detail-template-editor/scripts/lint_project_detail_template_semantics.py +0 -37
- package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py +0 -507
- package/skills/bpmax-project-detail-template-editor/scripts/submit_project_detail_template.py +0 -120
- package/skills/bpmax-project-detail-template-editor/tests/test_project_detail_template_editor.py +0 -369
- package/skills/bpmax-role-editor/SKILL.md +0 -251
- package/skills/bpmax-role-editor/references/api-workflow.md +0 -30
- package/skills/bpmax-role-editor/references/runtime-page-shape.md +0 -18
- package/skills/bpmax-role-editor/references/work-file-mapping.md +0 -32
- package/skills/bpmax-role-editor/scripts/build_submit_payload.py +0 -38
- package/skills/bpmax-role-editor/scripts/confirm_role.py +0 -33
- package/skills/bpmax-role-editor/scripts/export_role.py +0 -163
- package/skills/bpmax-role-editor/scripts/lint_role_semantics.py +0 -38
- package/skills/bpmax-role-editor/scripts/role_editor_common.py +0 -1231
- package/skills/bpmax-role-editor/scripts/submit_role.py +0 -144
- package/skills/bpmax-role-editor/tests/test_role_editor.py +0 -343
- package/skills/bpmax-user-mock-operator/SKILL.md +0 -106
- package/skills/bpmax-user-mock-operator/agents/openai.yaml +0 -4
- 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
- package/skills/form-control-library/SKILL.md +0 -82
- package/skills/form-control-library/agents/openai.yaml +0 -4
- package/skills/form-control-library/references/form-controls.md +0 -199
- package/skills/form-control-library/references/form-template-submit-schema.md +0 -180
- package/skills/form-control-library/references/group-select-runtime.md +0 -191
- package/skills/form-control-library/scripts/rebuild_form_control_library.py +0 -55
package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import argparse
|
|
5
|
-
|
|
6
|
-
from project_detail_template_editor_common import (
|
|
7
|
-
build_client,
|
|
8
|
-
build_create_raw_payload,
|
|
9
|
-
create_stem,
|
|
10
|
-
detail_to_work_payload,
|
|
11
|
-
dump_json,
|
|
12
|
-
paths_for,
|
|
13
|
-
write_diff,
|
|
14
|
-
write_export_meta,
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def build_parser() -> argparse.ArgumentParser:
|
|
19
|
-
p = argparse.ArgumentParser(description="Export an online BPMAX project-detail-template into local temp files.")
|
|
20
|
-
p.add_argument("--template-id", type=int)
|
|
21
|
-
p.add_argument("--sample-template-id", type=int)
|
|
22
|
-
p.add_argument("--create-skeleton", action="store_true")
|
|
23
|
-
p.add_argument("--workspace")
|
|
24
|
-
p.add_argument("--base-url")
|
|
25
|
-
p.add_argument("--language", default="zhCN")
|
|
26
|
-
p.add_argument("--cookie-header")
|
|
27
|
-
p.add_argument("--timeout", type=float, default=30)
|
|
28
|
-
p.add_argument("--insecure", action="store_true")
|
|
29
|
-
return p
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def main() -> int:
|
|
33
|
-
args = build_parser().parse_args()
|
|
34
|
-
client = build_client(args)
|
|
35
|
-
|
|
36
|
-
if args.template_id:
|
|
37
|
-
response = client.get_flow_page_template(args.template_id)
|
|
38
|
-
detail = response.get("data") or {}
|
|
39
|
-
stem = str(args.template_id)
|
|
40
|
-
mode = "edit"
|
|
41
|
-
raw = detail
|
|
42
|
-
work = detail_to_work_payload(detail, mode=mode)
|
|
43
|
-
template_id = args.template_id
|
|
44
|
-
sample_template_id = None
|
|
45
|
-
request_url = client._build_url(f"/api/flow_page_template/{args.template_id}?type=2&create=&skip_i18n=true")
|
|
46
|
-
else:
|
|
47
|
-
if not args.create_skeleton:
|
|
48
|
-
raise SystemExit("either --template-id or --create-skeleton is required")
|
|
49
|
-
if not args.sample_template_id:
|
|
50
|
-
raise SystemExit("--sample-template-id is required for --create-skeleton")
|
|
51
|
-
response = client.get_flow_page_template(args.sample_template_id)
|
|
52
|
-
detail = response.get("data") or {}
|
|
53
|
-
stem = create_stem(detail.get("flow_type", ""), detail.get("flow_key", ""), args.sample_template_id)
|
|
54
|
-
mode = "create"
|
|
55
|
-
raw = build_create_raw_payload(detail, sample_template_id=args.sample_template_id)
|
|
56
|
-
work = detail_to_work_payload(detail, mode=mode, sample_template_id=args.sample_template_id)
|
|
57
|
-
template_id = None
|
|
58
|
-
sample_template_id = args.sample_template_id
|
|
59
|
-
request_url = client._build_url(f"/api/flow_page_template/{args.sample_template_id}?type=2&create=&skip_i18n=true")
|
|
60
|
-
|
|
61
|
-
paths = paths_for(stem)
|
|
62
|
-
dump_json(paths["raw"], raw)
|
|
63
|
-
dump_json(paths["work"], work)
|
|
64
|
-
write_export_meta(
|
|
65
|
-
paths["meta"],
|
|
66
|
-
stem=stem,
|
|
67
|
-
mode=mode,
|
|
68
|
-
template_id=template_id,
|
|
69
|
-
template_uuid=(response.get("data") or {}).get("uuid"),
|
|
70
|
-
sample_template_id=sample_template_id,
|
|
71
|
-
workspace=client.workspace,
|
|
72
|
-
language=client.language,
|
|
73
|
-
request_url=request_url,
|
|
74
|
-
raw_path=paths["raw"],
|
|
75
|
-
work_path=paths["work"],
|
|
76
|
-
)
|
|
77
|
-
write_diff(paths["work_diff"], raw, work, "raw", "work")
|
|
78
|
-
|
|
79
|
-
print(paths["raw"])
|
|
80
|
-
print(paths["work"])
|
|
81
|
-
print(paths["meta"])
|
|
82
|
-
print(paths["work_diff"])
|
|
83
|
-
return 0
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if __name__ == "__main__":
|
|
87
|
-
raise SystemExit(main())
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
import argparse
|
|
5
|
-
|
|
6
|
-
from project_detail_template_editor_common import (
|
|
7
|
-
dump_json,
|
|
8
|
-
lint_project_detail_template_semantics,
|
|
9
|
-
load_json,
|
|
10
|
-
paths_for,
|
|
11
|
-
update_lint_meta,
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def build_parser() -> argparse.ArgumentParser:
|
|
16
|
-
p = argparse.ArgumentParser(description="Run semantic lint for a local BPMAX project-detail-template work/submit pair.")
|
|
17
|
-
p.add_argument("--stem", required=True)
|
|
18
|
-
return p
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def main() -> int:
|
|
22
|
-
args = build_parser().parse_args()
|
|
23
|
-
paths = paths_for(args.stem)
|
|
24
|
-
work = load_json(paths["work"])
|
|
25
|
-
submit = load_json(paths["submit"])
|
|
26
|
-
report = lint_project_detail_template_semantics(work, submit_payload=submit)
|
|
27
|
-
dump_json(paths["semantic_lint"], report)
|
|
28
|
-
update_lint_meta(paths["meta"], stem=args.stem, submit_path=paths["submit"], lint_path=paths["semantic_lint"], report=report)
|
|
29
|
-
print(paths["semantic_lint"])
|
|
30
|
-
print(paths["meta"])
|
|
31
|
-
if not report["ok"]:
|
|
32
|
-
raise SystemExit("project-detail-template lint failed; inspect semantic-lint.json for details")
|
|
33
|
-
return 0
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if __name__ == "__main__":
|
|
37
|
-
raise SystemExit(main())
|
package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py
DELETED
|
@@ -1,507 +0,0 @@
|
|
|
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, Iterable, 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
|
-
|
|
25
|
-
from base_url import resolve_base_url
|
|
26
|
-
from template_script_hard_rules import scan_named_script_surfaces
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
TMP_ROOT = REPO_ROOT / ".codex" / "tmp" / "project-detail-template-editor"
|
|
30
|
-
TMP_SUBDIRS = ("raw", "work", "meta", "submit", "diffs", "result")
|
|
31
|
-
|
|
32
|
-
MODULE_ALLOW_IN = {
|
|
33
|
-
"project-info": {"main_col", "side_col"},
|
|
34
|
-
"meta-form": {"main_col"},
|
|
35
|
-
"step-form": {"main_col"},
|
|
36
|
-
"step-form-any": {"main_col"},
|
|
37
|
-
"comment-list": {"main_col", "side_col"},
|
|
38
|
-
"project-list": {"main_col", "side_col"},
|
|
39
|
-
"step-log": {"side_col"},
|
|
40
|
-
"attachment-list": {"side_col"},
|
|
41
|
-
"circulate": {"side_col"},
|
|
42
|
-
"finance": {"main_col"},
|
|
43
|
-
"customer-binding": {"main_col"},
|
|
44
|
-
"step-arrange": {"main_col"},
|
|
45
|
-
"periods": {"main_col"},
|
|
46
|
-
"auto-replay-info": {"main_col"},
|
|
47
|
-
"delay-reason": {"main_col"},
|
|
48
|
-
"generate-report": {"main_col"},
|
|
49
|
-
"project-detail-panel": {"main_col"},
|
|
50
|
-
"project-meta-info": {"main_col", "side_col"},
|
|
51
|
-
"project-reopen": {"main_col"},
|
|
52
|
-
"custom-form-list": {"side_col"},
|
|
53
|
-
}
|
|
54
|
-
KNOWN_MODULE_TYPES = set(MODULE_ALLOW_IN)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def utc_now_iso() -> str:
|
|
58
|
-
return datetime.now(timezone.utc).isoformat()
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def ensure_tmp_dirs() -> None:
|
|
62
|
-
for part in TMP_SUBDIRS:
|
|
63
|
-
(TMP_ROOT / part).mkdir(parents=True, exist_ok=True)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def paths_for(stem: str) -> Dict[str, Path]:
|
|
67
|
-
ensure_tmp_dirs()
|
|
68
|
-
return {
|
|
69
|
-
"raw": TMP_ROOT / "raw" / f"{stem}.json",
|
|
70
|
-
"work": TMP_ROOT / "work" / f"{stem}.json",
|
|
71
|
-
"meta": TMP_ROOT / "meta" / f"{stem}.json",
|
|
72
|
-
"submit": TMP_ROOT / "submit" / f"{stem}.json",
|
|
73
|
-
"work_diff": TMP_ROOT / "diffs" / f"{stem}.work.diff.txt",
|
|
74
|
-
"submit_diff": TMP_ROOT / "diffs" / f"{stem}.submit.diff.txt",
|
|
75
|
-
"response": TMP_ROOT / "result" / f"{stem}.response.json",
|
|
76
|
-
"readback": TMP_ROOT / "result" / f"{stem}.readback.json",
|
|
77
|
-
"verify": TMP_ROOT / "result" / f"{stem}.verify.json",
|
|
78
|
-
"semantic_lint": TMP_ROOT / "result" / f"{stem}.semantic-lint.json",
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
def dump_json(path: Path, payload: Any) -> None:
|
|
83
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
84
|
-
path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def load_json(path: Path) -> Any:
|
|
88
|
-
return json.loads(path.read_text(encoding="utf-8"))
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def file_sha256(path: Path) -> str:
|
|
92
|
-
return hashlib.sha256(path.read_bytes()).hexdigest()
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def stable_json_lines(payload: Any) -> list[str]:
|
|
96
|
-
return (json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n").splitlines(keepends=True)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
def write_diff(path: Path, before: Any, after: Any, before_label: str, after_label: str) -> None:
|
|
100
|
-
diff = unified_diff(stable_json_lines(before), stable_json_lines(after), fromfile=before_label, tofile=after_label)
|
|
101
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
102
|
-
path.write_text("".join(diff) or "# no diff\n", encoding="utf-8")
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
def parse_content(value: Any) -> Dict[str, Any]:
|
|
106
|
-
if isinstance(value, dict):
|
|
107
|
-
payload = copy.deepcopy(value)
|
|
108
|
-
elif isinstance(value, str):
|
|
109
|
-
text = value.strip()
|
|
110
|
-
payload = json.loads(text) if text else {}
|
|
111
|
-
elif value in (None, ""):
|
|
112
|
-
payload = {}
|
|
113
|
-
else:
|
|
114
|
-
raise SystemExit("project detail template content must be a JSON string or object")
|
|
115
|
-
if not isinstance(payload, dict):
|
|
116
|
-
raise SystemExit("project detail template content must be an object")
|
|
117
|
-
payload.setdefault("config", {})
|
|
118
|
-
payload.setdefault("main_col", [])
|
|
119
|
-
payload.setdefault("side_col", [])
|
|
120
|
-
if not isinstance(payload["config"], dict):
|
|
121
|
-
raise SystemExit("content.config must be an object")
|
|
122
|
-
if not isinstance(payload["main_col"], list):
|
|
123
|
-
raise SystemExit("content.main_col must be an array")
|
|
124
|
-
if not isinstance(payload["side_col"], list):
|
|
125
|
-
raise SystemExit("content.side_col must be an array")
|
|
126
|
-
return payload
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
def serialize_content(content: Dict[str, Any]) -> str:
|
|
130
|
-
return json.dumps(parse_content(content), ensure_ascii=False, separators=(",", ":"))
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
def create_stem(flow_type: str, flow_key: str, sample_template_id: int) -> str:
|
|
134
|
-
return f"create-{flow_type}-{flow_key or 'default'}-{sample_template_id}"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def build_create_raw_payload(detail: Dict[str, Any], *, sample_template_id: int) -> Dict[str, Any]:
|
|
138
|
-
content = parse_content(detail.get("content"))
|
|
139
|
-
return {
|
|
140
|
-
"id": None,
|
|
141
|
-
"name": detail.get("name", ""),
|
|
142
|
-
"desc": detail.get("desc", ""),
|
|
143
|
-
"type": 2,
|
|
144
|
-
"flow_type": detail.get("flow_type", ""),
|
|
145
|
-
"flow_key": detail.get("flow_key", ""),
|
|
146
|
-
"status": 1,
|
|
147
|
-
"content": content,
|
|
148
|
-
"sampleTemplateId": sample_template_id,
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
def detail_to_work_payload(detail: Dict[str, Any], *, mode: str, sample_template_id: int | None = None) -> Dict[str, Any]:
|
|
153
|
-
if mode not in ("edit", "create"):
|
|
154
|
-
raise SystemExit(f"unsupported mode: {mode}")
|
|
155
|
-
return {
|
|
156
|
-
"id": detail.get("id") if mode == "edit" else None,
|
|
157
|
-
"mode": mode,
|
|
158
|
-
"basic": {
|
|
159
|
-
"name": detail.get("name", ""),
|
|
160
|
-
"desc": detail.get("desc", ""),
|
|
161
|
-
"type": 2,
|
|
162
|
-
"flow_type": detail.get("flow_type", ""),
|
|
163
|
-
"flow_key": detail.get("flow_key", ""),
|
|
164
|
-
"status": detail.get("status", 1),
|
|
165
|
-
},
|
|
166
|
-
"content": parse_content(detail.get("content")),
|
|
167
|
-
"meta": {
|
|
168
|
-
"templateUuid": detail.get("uuid"),
|
|
169
|
-
"sourceTemplateId": detail.get("id"),
|
|
170
|
-
"sampleTemplateId": sample_template_id,
|
|
171
|
-
"moduleSources": [
|
|
172
|
-
"browser/api",
|
|
173
|
-
"ProjectDetailConfig/utils/moduleRegistry.js",
|
|
174
|
-
"components/DetailSections/README.md",
|
|
175
|
-
"doc.bpmax.cn/script/ui/project-detail.html",
|
|
176
|
-
],
|
|
177
|
-
},
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
def build_submit_payload(work: Dict[str, Any]) -> Dict[str, Any]:
|
|
182
|
-
basic = copy.deepcopy(work.get("basic") or {})
|
|
183
|
-
content = parse_content(work.get("content"))
|
|
184
|
-
submit = {
|
|
185
|
-
"name": basic.get("name", ""),
|
|
186
|
-
"desc": basic.get("desc", ""),
|
|
187
|
-
"type": 2,
|
|
188
|
-
"flow_type": basic.get("flow_type", ""),
|
|
189
|
-
"flow_key": basic.get("flow_key", ""),
|
|
190
|
-
"content": serialize_content(content),
|
|
191
|
-
}
|
|
192
|
-
if work.get("mode") == "create":
|
|
193
|
-
submit["status"] = basic.get("status", 1)
|
|
194
|
-
return submit
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
def _scan_modules(modules: list[Any], *, area: str, report: Dict[str, Any]) -> None:
|
|
198
|
-
for idx, module in enumerate(modules):
|
|
199
|
-
path = f"content.{area}[{idx}]"
|
|
200
|
-
if not isinstance(module, dict):
|
|
201
|
-
report["errors"].append(f"{path} must be an object")
|
|
202
|
-
continue
|
|
203
|
-
module_type = module.get("type")
|
|
204
|
-
title = module.get("title")
|
|
205
|
-
config = module.get("config")
|
|
206
|
-
if not isinstance(module_type, str) or not module_type.strip():
|
|
207
|
-
report["errors"].append(f"{path}.type must be a non-empty string")
|
|
208
|
-
continue
|
|
209
|
-
if not isinstance(title, str) or not title.strip():
|
|
210
|
-
report["errors"].append(f"{path}.title must be a non-empty string")
|
|
211
|
-
if not isinstance(config, dict):
|
|
212
|
-
report["errors"].append(f"{path}.config must be an object")
|
|
213
|
-
config = {}
|
|
214
|
-
|
|
215
|
-
allowed_areas = MODULE_ALLOW_IN.get(module_type)
|
|
216
|
-
if allowed_areas is None:
|
|
217
|
-
report["warnings"].append(
|
|
218
|
-
f"{path}.type={module_type!r} is not in the known registry union; allow as advanced JSON mode candidate only"
|
|
219
|
-
)
|
|
220
|
-
elif area not in allowed_areas:
|
|
221
|
-
report["errors"].append(f"{path}.type={module_type!r} is not allowed in {area}")
|
|
222
|
-
|
|
223
|
-
if module_type == "step-form":
|
|
224
|
-
step_id = config.get("flow_step_id")
|
|
225
|
-
if step_id in (None, "", 0, "0"):
|
|
226
|
-
report["errors"].append(f"{path}.config.flow_step_id is required for step-form")
|
|
227
|
-
if module_type == "project-list":
|
|
228
|
-
if not config.get("isSubProcess") and not (config.get("flow_type") or config.get("flow_key")):
|
|
229
|
-
report["warnings"].append(
|
|
230
|
-
f"{path}.config should usually include flow_type/flow_key unless it is an isSubProcess sidebar module"
|
|
231
|
-
)
|
|
232
|
-
if area == "main_col" and config.get("isSubProcess") is True:
|
|
233
|
-
report["errors"].append(f"{path}.config.isSubProcess=true is only valid in side_col")
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
def lint_project_detail_template_semantics(
|
|
237
|
-
work_payload: Dict[str, Any], *, submit_payload: Optional[Dict[str, Any]] = None
|
|
238
|
-
) -> Dict[str, Any]:
|
|
239
|
-
payload = submit_payload or build_submit_payload(work_payload)
|
|
240
|
-
content = parse_content(payload.get("content"))
|
|
241
|
-
report: Dict[str, Any] = {
|
|
242
|
-
"ok": True,
|
|
243
|
-
"errors": [],
|
|
244
|
-
"warnings": [],
|
|
245
|
-
"checks": {
|
|
246
|
-
"knownModuleTypes": sorted(KNOWN_MODULE_TYPES),
|
|
247
|
-
"mainModuleCount": len(content["main_col"]),
|
|
248
|
-
"sideModuleCount": len(content["side_col"]),
|
|
249
|
-
},
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if payload.get("type") != 2:
|
|
253
|
-
report["errors"].append("submit.type must be 2")
|
|
254
|
-
|
|
255
|
-
_scan_modules(content["main_col"], area="main_col", report=report)
|
|
256
|
-
_scan_modules(content["side_col"], area="side_col", report=report)
|
|
257
|
-
|
|
258
|
-
try:
|
|
259
|
-
json.dumps(content, ensure_ascii=False)
|
|
260
|
-
except TypeError as exc:
|
|
261
|
-
report["errors"].append(f"content is not JSON-serializable: {exc}")
|
|
262
|
-
|
|
263
|
-
hard_rule_report = scan_named_script_surfaces(
|
|
264
|
-
[
|
|
265
|
-
{"path": "content.config", "value": content.get("config")},
|
|
266
|
-
{"path": "content.main_col", "value": content.get("main_col")},
|
|
267
|
-
{"path": "content.side_col", "value": content.get("side_col")},
|
|
268
|
-
]
|
|
269
|
-
)
|
|
270
|
-
report["checks"]["scriptHardRules"] = hard_rule_report["findings"]
|
|
271
|
-
report["errors"].extend(hard_rule_report["errors"])
|
|
272
|
-
report["ok"] = not report["errors"]
|
|
273
|
-
return report
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
def ensure_meta_shape(meta: Dict[str, Any], stem: str) -> Dict[str, Any]:
|
|
277
|
-
payload = dict(meta)
|
|
278
|
-
payload.setdefault("stem", stem)
|
|
279
|
-
payload.setdefault("mode", None)
|
|
280
|
-
payload.setdefault("workspace", None)
|
|
281
|
-
payload.setdefault("status", "exported")
|
|
282
|
-
payload.setdefault("templateId", None)
|
|
283
|
-
payload.setdefault("templateUuid", None)
|
|
284
|
-
payload.setdefault("sampleTemplateId", None)
|
|
285
|
-
payload.setdefault("workSha256", None)
|
|
286
|
-
payload.setdefault("submitSha256", None)
|
|
287
|
-
payload.setdefault("workConfirmedAt", None)
|
|
288
|
-
payload.setdefault("submitConfirmedAt", None)
|
|
289
|
-
payload.setdefault("submitBuiltAt", None)
|
|
290
|
-
payload.setdefault("lintPassed", False)
|
|
291
|
-
payload.setdefault("lintedAt", None)
|
|
292
|
-
payload.setdefault("lintSha256", None)
|
|
293
|
-
return payload
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
def write_export_meta(
|
|
297
|
-
meta_path: Path,
|
|
298
|
-
*,
|
|
299
|
-
stem: str,
|
|
300
|
-
mode: str,
|
|
301
|
-
template_id: int | None,
|
|
302
|
-
template_uuid: str | None,
|
|
303
|
-
sample_template_id: int | None,
|
|
304
|
-
workspace: str,
|
|
305
|
-
language: str,
|
|
306
|
-
request_url: str,
|
|
307
|
-
raw_path: Path,
|
|
308
|
-
work_path: Path,
|
|
309
|
-
) -> Dict[str, Any]:
|
|
310
|
-
payload = ensure_meta_shape({}, stem)
|
|
311
|
-
payload.update(
|
|
312
|
-
{
|
|
313
|
-
"mode": mode,
|
|
314
|
-
"templateId": template_id,
|
|
315
|
-
"templateUuid": template_uuid,
|
|
316
|
-
"sampleTemplateId": sample_template_id,
|
|
317
|
-
"workspace": workspace,
|
|
318
|
-
"language": language,
|
|
319
|
-
"requestUrl": request_url,
|
|
320
|
-
"rawSha256": file_sha256(raw_path),
|
|
321
|
-
"workSha256": file_sha256(work_path),
|
|
322
|
-
"status": "exported",
|
|
323
|
-
"exportedAt": utc_now_iso(),
|
|
324
|
-
}
|
|
325
|
-
)
|
|
326
|
-
dump_json(meta_path, payload)
|
|
327
|
-
return payload
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
def update_build_meta(meta_path: Path, *, stem: str, work_path: Path, submit_path: Path) -> Dict[str, Any]:
|
|
331
|
-
payload = ensure_meta_shape(load_json(meta_path) if meta_path.exists() else {}, stem)
|
|
332
|
-
payload["workSha256"] = file_sha256(work_path)
|
|
333
|
-
payload["submitSha256"] = file_sha256(submit_path)
|
|
334
|
-
payload["submitBuiltAt"] = utc_now_iso()
|
|
335
|
-
payload["lintPassed"] = False
|
|
336
|
-
payload["lintedAt"] = None
|
|
337
|
-
payload["lintSha256"] = None
|
|
338
|
-
payload["submitConfirmedAt"] = None
|
|
339
|
-
payload["status"] = "submit_built"
|
|
340
|
-
dump_json(meta_path, payload)
|
|
341
|
-
return payload
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
def update_confirmation_state(meta_path: Path, *, stem: str, actor: str, stage: str, work_path: Path, submit_path: Path) -> Dict[str, Any]:
|
|
345
|
-
payload = ensure_meta_shape(load_json(meta_path) if meta_path.exists() else {}, stem)
|
|
346
|
-
payload["actor"] = actor
|
|
347
|
-
payload["workSha256"] = file_sha256(work_path)
|
|
348
|
-
now = utc_now_iso()
|
|
349
|
-
if stage == "work":
|
|
350
|
-
payload["workConfirmedAt"] = now
|
|
351
|
-
payload["submitConfirmedAt"] = None
|
|
352
|
-
payload["status"] = "work_confirmed"
|
|
353
|
-
elif stage == "submit":
|
|
354
|
-
if not submit_path.exists():
|
|
355
|
-
raise SystemExit("submit confirmation requires an existing submit file")
|
|
356
|
-
payload["submitSha256"] = file_sha256(submit_path)
|
|
357
|
-
payload["submitConfirmedAt"] = now
|
|
358
|
-
payload["status"] = "submit_confirmed"
|
|
359
|
-
else:
|
|
360
|
-
raise SystemExit(f"unsupported confirmation stage: {stage}")
|
|
361
|
-
dump_json(meta_path, payload)
|
|
362
|
-
return payload
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
def update_lint_meta(meta_path: Path, *, stem: str, submit_path: Path, lint_path: Path, report: Dict[str, Any]) -> Dict[str, Any]:
|
|
366
|
-
payload = ensure_meta_shape(load_json(meta_path) if meta_path.exists() else {}, stem)
|
|
367
|
-
payload["submitSha256"] = file_sha256(submit_path)
|
|
368
|
-
payload["lintPassed"] = bool(report.get("ok"))
|
|
369
|
-
payload["lintSha256"] = file_sha256(lint_path)
|
|
370
|
-
payload["lintedAt"] = utc_now_iso()
|
|
371
|
-
payload["status"] = "lint_passed" if report.get("ok") else "lint_failed"
|
|
372
|
-
dump_json(meta_path, payload)
|
|
373
|
-
return payload
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
def persist_create_submission_meta(
|
|
377
|
-
meta_path: Path,
|
|
378
|
-
*,
|
|
379
|
-
stem: str,
|
|
380
|
-
action_mode: str,
|
|
381
|
-
template_id: int,
|
|
382
|
-
readback: Dict[str, Any],
|
|
383
|
-
) -> Dict[str, Any]:
|
|
384
|
-
payload = ensure_meta_shape(load_json(meta_path) if meta_path.exists() else {}, stem)
|
|
385
|
-
if action_mode != "create":
|
|
386
|
-
raise SystemExit("persist_create_submission_meta requires action_mode=create")
|
|
387
|
-
payload["mode"] = "edit"
|
|
388
|
-
payload["templateId"] = template_id
|
|
389
|
-
if readback.get("uuid"):
|
|
390
|
-
payload["templateUuid"] = readback["uuid"]
|
|
391
|
-
payload["status"] = payload.get("status") or "submit_confirmed"
|
|
392
|
-
dump_json(meta_path, payload)
|
|
393
|
-
return payload
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
def ensure_submission_allowed(meta_path: Path, work_path: Path, submit_path: Path) -> Dict[str, Any]:
|
|
397
|
-
if not meta_path.exists():
|
|
398
|
-
raise SystemExit("missing meta confirmation file")
|
|
399
|
-
meta_raw = load_json(meta_path)
|
|
400
|
-
meta = ensure_meta_shape(meta_raw, meta_raw.get("stem", "unknown"))
|
|
401
|
-
if meta.get("status") != "submit_confirmed":
|
|
402
|
-
raise SystemExit("submission blocked: current status is not submit_confirmed")
|
|
403
|
-
if meta.get("lintPassed") is not True:
|
|
404
|
-
raise SystemExit("submission blocked: lint has not passed")
|
|
405
|
-
if meta.get("workSha256") != file_sha256(work_path):
|
|
406
|
-
raise SystemExit("submission blocked: work file changed after confirmation")
|
|
407
|
-
if meta.get("submitSha256") != file_sha256(submit_path):
|
|
408
|
-
raise SystemExit("submission blocked: submit file changed after confirmation")
|
|
409
|
-
return meta
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
def summarize_verification(submit_payload: Dict[str, Any], readback: Dict[str, Any]) -> Dict[str, Any]:
|
|
413
|
-
submitted_content = parse_content(submit_payload.get("content"))
|
|
414
|
-
readback_content = parse_content(readback.get("content"))
|
|
415
|
-
mismatches = []
|
|
416
|
-
for key in ("name", "desc", "type", "flow_type", "flow_key"):
|
|
417
|
-
if submit_payload.get(key) != readback.get(key):
|
|
418
|
-
mismatches.append({"field": key, "expected": submit_payload.get(key), "actual": readback.get(key)})
|
|
419
|
-
if submitted_content != readback_content:
|
|
420
|
-
mismatches.append({"field": "content", "expected": submitted_content, "actual": readback_content})
|
|
421
|
-
return {
|
|
422
|
-
"ok": not mismatches,
|
|
423
|
-
"submittedContent": submitted_content,
|
|
424
|
-
"readbackContent": readback_content,
|
|
425
|
-
"mismatches": mismatches,
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
def extract_template_id(response_payload: Dict[str, Any]) -> int | None:
|
|
430
|
-
data = response_payload.get("data")
|
|
431
|
-
if isinstance(data, dict) and isinstance(data.get("id"), int):
|
|
432
|
-
return data["id"]
|
|
433
|
-
if isinstance(response_payload.get("id"), int):
|
|
434
|
-
return response_payload["id"]
|
|
435
|
-
return None
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
@dataclass
|
|
439
|
-
class ApiClient:
|
|
440
|
-
base_url: str
|
|
441
|
-
workspace: str
|
|
442
|
-
language: str
|
|
443
|
-
cookie_header: str
|
|
444
|
-
timeout: float
|
|
445
|
-
insecure: bool = False
|
|
446
|
-
|
|
447
|
-
def _build_url(self, path: str) -> str:
|
|
448
|
-
query = urllib.parse.urlencode({"$workspace": self.workspace, "$language": self.language})
|
|
449
|
-
return f"{self.base_url}{path}{'&' if '?' in path else '?'}{query}"
|
|
450
|
-
|
|
451
|
-
def _request(self, method: str, path: str, payload: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
|
|
452
|
-
data = None
|
|
453
|
-
headers = {
|
|
454
|
-
"Accept": "application/json, text/plain, */*",
|
|
455
|
-
"Content-Type": "application/json",
|
|
456
|
-
}
|
|
457
|
-
if self.cookie_header:
|
|
458
|
-
headers["Cookie"] = self.cookie_header
|
|
459
|
-
if payload is not None:
|
|
460
|
-
data = json.dumps(payload, ensure_ascii=False).encode("utf-8")
|
|
461
|
-
req = urllib.request.Request(self._build_url(path), data=data, headers=headers, method=method.upper())
|
|
462
|
-
context = None
|
|
463
|
-
if self.insecure:
|
|
464
|
-
context = ssl._create_unverified_context()
|
|
465
|
-
try:
|
|
466
|
-
with urllib.request.urlopen(req, timeout=self.timeout, context=context) as resp:
|
|
467
|
-
raw = resp.read().decode("utf-8")
|
|
468
|
-
except urllib.error.HTTPError as exc:
|
|
469
|
-
body = exc.read().decode("utf-8", errors="replace")
|
|
470
|
-
raise SystemExit(f"HTTP {exc.code} for {path}: {body}") from exc
|
|
471
|
-
payload = json.loads(raw)
|
|
472
|
-
if payload.get("code") not in (0, None):
|
|
473
|
-
raise SystemExit(f"API returned error for {path}: {payload}")
|
|
474
|
-
return payload
|
|
475
|
-
|
|
476
|
-
def get_flow_page_template(self, template_id: int) -> Dict[str, Any]:
|
|
477
|
-
return self._request("GET", f"/api/flow_page_template/{template_id}?type=2&create=&skip_i18n=true")
|
|
478
|
-
|
|
479
|
-
def create_flow_page_template(self, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
480
|
-
return self._request("POST", "/api/flow_page_template", payload)
|
|
481
|
-
|
|
482
|
-
def update_flow_page_template(self, template_id: int, payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
483
|
-
return self._request("PUT", f"/api/flow_page_template/{template_id}", payload)
|
|
484
|
-
|
|
485
|
-
def activate_flow_page_template(self, template_id: int, *, flow_type: str, flow_key: str = "") -> Dict[str, Any]:
|
|
486
|
-
return self._request(
|
|
487
|
-
"PUT",
|
|
488
|
-
f"/api/flow_page_template/{template_id}",
|
|
489
|
-
{"status": 1, "flow_type": flow_type, "flow_key": flow_key},
|
|
490
|
-
)
|
|
491
|
-
|
|
492
|
-
def delete_flow_page_template(self, template_id: int) -> Dict[str, Any]:
|
|
493
|
-
return self._request("DELETE", f"/api/flow_page_template/{template_id}")
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
def build_client(args: Any) -> ApiClient:
|
|
497
|
-
workspace = getattr(args, "workspace", None) or ""
|
|
498
|
-
if not workspace:
|
|
499
|
-
raise SystemExit("missing workspace: pass --workspace from the current browser page")
|
|
500
|
-
return ApiClient(
|
|
501
|
-
base_url=resolve_base_url(getattr(args, "base_url", None)),
|
|
502
|
-
workspace=workspace,
|
|
503
|
-
language=getattr(args, "language", DEFAULT_LANGUAGE),
|
|
504
|
-
cookie_header=getattr(args, "cookie_header", "") or "",
|
|
505
|
-
timeout=float(getattr(args, "timeout", 30)),
|
|
506
|
-
insecure=bool(getattr(args, "insecure", False)),
|
|
507
|
-
)
|