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.
Files changed (258) hide show
  1. package/README.md +5 -3
  2. package/dist/bin.js +466 -4578
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +1 -1
  5. package/scripts/install-skills.mjs +0 -98
  6. package/skills/bpmax-auth/SKILL.md +17 -6
  7. package/skills/bpmax-cli/SKILL.md +0 -2
  8. package/skills/bpmax-project/SKILL.md +2 -1
  9. package/skills/bpmax-shared/SKILL.md +1 -1
  10. package/skills/bpmax-api-platform-editor/SKILL.md +0 -321
  11. package/skills/bpmax-api-platform-editor/agents/openai.yaml +0 -4
  12. package/skills/bpmax-api-platform-editor/references/api-doc-debug-workflow.md +0 -34
  13. package/skills/bpmax-api-platform-editor/references/api-proxy-shape.md +0 -41
  14. package/skills/bpmax-api-platform-editor/references/instance-config-shape.md +0 -41
  15. package/skills/bpmax-api-platform-editor/references/platform-api-map.md +0 -52
  16. package/skills/bpmax-api-platform-editor/references/runtime-workflow.md +0 -32
  17. package/skills/bpmax-api-platform-editor/scripts/api_platform_editor_common.py +0 -1276
  18. package/skills/bpmax-api-platform-editor/scripts/build_submit_payload.py +0 -64
  19. package/skills/bpmax-api-platform-editor/scripts/capture_write_contract.py +0 -40
  20. package/skills/bpmax-api-platform-editor/scripts/export_layer_bundle.py +0 -212
  21. package/skills/bpmax-api-platform-editor/scripts/record_doc_debug_acceptance.py +0 -62
  22. package/skills/bpmax-api-platform-editor/scripts/submit_and_verify_layer.py +0 -75
  23. package/skills/bpmax-api-platform-editor/tests/test_api_platform_editor.py +0 -287
  24. package/skills/bpmax-builder-shared/SKILL.md +0 -44
  25. package/skills/bpmax-builder-shared/base_url.py +0 -81
  26. package/skills/bpmax-builder-shared/runtime-script-site-matrix.json +0 -71
  27. package/skills/bpmax-builder-shared/runtime-script-site-matrix.md +0 -34
  28. package/skills/bpmax-builder-shared/runtime-script-template-catalog.md +0 -123
  29. package/skills/bpmax-builder-shared/runtime_script_rules.py +0 -272
  30. package/skills/bpmax-builder-shared/skill_audit.py +0 -374
  31. package/skills/bpmax-builder-shared/template_script_hard_rules.py +0 -280
  32. package/skills/bpmax-builder-shared/tests/test_base_url.py +0 -80
  33. package/skills/bpmax-builder-shared/tests/test_runtime_script_rules.py +0 -115
  34. package/skills/bpmax-builder-shared/tests/test_skill_audit.py +0 -231
  35. package/skills/bpmax-builder-shared/tests/test_template_script_hard_rules.py +0 -281
  36. package/skills/bpmax-config-latest/SKILL.md +0 -71
  37. package/skills/bpmax-console-template-editor/SKILL.md +0 -536
  38. package/skills/bpmax-console-template-editor/agents/openai.yaml +0 -4
  39. package/skills/bpmax-console-template-editor/references/filter-integration.md +0 -60
  40. package/skills/bpmax-console-template-editor/references/lessons-from-resume-dashboard.md +0 -114
  41. package/skills/bpmax-console-template-editor/references/local-temp-workflow.md +0 -69
  42. package/skills/bpmax-console-template-editor/references/module-catalog.md +0 -100
  43. package/skills/bpmax-console-template-editor/references/runtime-page-shape.md +0 -91
  44. package/skills/bpmax-console-template-editor/references/template-shape.md +0 -149
  45. package/skills/bpmax-console-template-editor/scripts/build_submit_payload.py +0 -38
  46. package/skills/bpmax-console-template-editor/scripts/confirm_console_template.py +0 -33
  47. package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +0 -964
  48. package/skills/bpmax-console-template-editor/scripts/export_console_template.py +0 -99
  49. package/skills/bpmax-console-template-editor/scripts/lint_console_template.py +0 -46
  50. package/skills/bpmax-console-template-editor/scripts/submit_console_template.py +0 -99
  51. package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +0 -383
  52. package/skills/bpmax-dataset-field-template-editor/SKILL.md +0 -600
  53. package/skills/bpmax-dataset-field-template-editor/references/create-request-gotchas.md +0 -25
  54. package/skills/bpmax-dataset-field-template-editor/references/field-classify-mapping.md +0 -35
  55. package/skills/bpmax-dataset-field-template-editor/references/nested-field-patterns.md +0 -24
  56. package/skills/bpmax-dataset-field-template-editor/references/runtime-verified-field-page-shape.md +0 -61
  57. package/skills/bpmax-dataset-field-template-editor/references/virtual-field-patterns.md +0 -27
  58. package/skills/bpmax-dataset-field-template-editor/references/work-file-to-submit-mapping.md +0 -127
  59. package/skills/bpmax-dataset-field-template-editor/scripts/build_submit_payload.py +0 -67
  60. package/skills/bpmax-dataset-field-template-editor/scripts/confirm_dataset_field.py +0 -37
  61. package/skills/bpmax-dataset-field-template-editor/scripts/dataset_field_editor_common.py +0 -784
  62. package/skills/bpmax-dataset-field-template-editor/scripts/export_dataset_field.py +0 -62
  63. package/skills/bpmax-dataset-field-template-editor/scripts/init_create_dataset_field.py +0 -104
  64. package/skills/bpmax-dataset-field-template-editor/scripts/inspect_dataset_field_runtime.py +0 -83
  65. package/skills/bpmax-dataset-field-template-editor/scripts/lint_dataset_field_semantics.py +0 -35
  66. package/skills/bpmax-dataset-field-template-editor/scripts/submit_dataset_field.py +0 -95
  67. package/skills/bpmax-dataset-field-template-editor/tests/test_dataset_field_editor.py +0 -709
  68. package/skills/bpmax-dataset-field-template-editor/tests/test_init_create_dataset_field.py +0 -59
  69. package/skills/bpmax-dataset-template-editor/SKILL.md +0 -779
  70. package/skills/bpmax-dataset-template-editor/references/custom-key-usage-patterns.md +0 -18
  71. package/skills/bpmax-dataset-template-editor/references/dataset-script-runtime-matrix.md +0 -73
  72. package/skills/bpmax-dataset-template-editor/references/pre-process-script-authoring-guide.md +0 -186
  73. package/skills/bpmax-dataset-template-editor/references/pre-process-script-example-catalog.md +0 -106
  74. package/skills/bpmax-dataset-template-editor/references/runtime-gotchas.md +0 -28
  75. package/skills/bpmax-dataset-template-editor/references/runtime-verified-dataset-page-shape.md +0 -47
  76. package/skills/bpmax-dataset-template-editor/references/ui-to-backend-field-map.md +0 -23
  77. package/skills/bpmax-dataset-template-editor/references/work-file-to-submit-mapping.md +0 -97
  78. package/skills/bpmax-dataset-template-editor/scripts/basic_table_audit.py +0 -65
  79. package/skills/bpmax-dataset-template-editor/scripts/build_submit_payload.py +0 -38
  80. package/skills/bpmax-dataset-template-editor/scripts/dataset_editor_common.py +0 -650
  81. package/skills/bpmax-dataset-template-editor/scripts/export_dataset.py +0 -155
  82. package/skills/bpmax-dataset-template-editor/scripts/lint_dataset_template.py +0 -42
  83. package/skills/bpmax-dataset-template-editor/scripts/resolve_dataset.py +0 -43
  84. package/skills/bpmax-dataset-template-editor/scripts/scan_custom_key_references.py +0 -27
  85. package/skills/bpmax-dataset-template-editor/scripts/submit_dataset.py +0 -115
  86. package/skills/bpmax-dataset-template-editor/scripts/verify_dataset_list.py +0 -52
  87. package/skills/bpmax-dataset-template-editor/scripts/verify_publish_health.py +0 -39
  88. package/skills/bpmax-dataset-template-editor/tests/test_dataset_editor.py +0 -373
  89. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +0 -177
  90. package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +0 -4
  91. package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +0 -60
  92. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +0 -394
  93. package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +0 -5
  94. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale.json +0 -97
  95. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_final_v2.json +0 -105
  96. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_main.json +0 -36
  97. package/skills/bpmax-e2e-flow-test-operator/profiles/negative_sale_region.json +0 -40
  98. package/skills/bpmax-e2e-flow-test-operator/references/browser-only-checkpoints.md +0 -41
  99. package/skills/bpmax-e2e-flow-test-operator/references/failure-update-loop.md +0 -17
  100. package/skills/bpmax-e2e-flow-test-operator/references/filter-field-discovery.md +0 -40
  101. package/skills/bpmax-e2e-flow-test-operator/references/minimal-test-loop.md +0 -24
  102. package/skills/bpmax-e2e-flow-test-operator/references/negative-sale-api-matrix.md +0 -75
  103. package/skills/bpmax-e2e-flow-test-operator/references/profile-schema.md +0 -107
  104. package/skills/bpmax-e2e-flow-test-operator/references/skill-experience-coverage-matrix.md +0 -29
  105. package/skills/bpmax-e2e-flow-test-operator/references/stale-runtime-and-clean-sample-rules.md +0 -54
  106. package/skills/bpmax-e2e-flow-test-operator/references/state-schema.md +0 -83
  107. package/skills/bpmax-e2e-flow-test-operator/scripts/bpmax_session.py +0 -287
  108. package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_plan.json +0 -59
  109. package/skills/bpmax-e2e-flow-test-operator/scripts/dealer_sample_on_shelf_runner.py +0 -687
  110. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_doc.py +0 -121
  111. package/skills/bpmax-e2e-flow-test-operator/scripts/e2e_state.py +0 -288
  112. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_api_matrix.py +0 -161
  113. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_filter_fields.py +0 -138
  114. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_form_runtime.py +0 -396
  115. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_runner.py +0 -341
  116. package/skills/bpmax-e2e-flow-test-operator/scripts/flow_test_profile.py +0 -185
  117. package/skills/bpmax-e2e-flow-test-operator/tests/test_negative_sale_api_tools.py +0 -138
  118. package/skills/bpmax-feishu-chat-flow-plugin-editor/SKILL.md +0 -69
  119. package/skills/bpmax-feishu-chat-flow-plugin-editor/agents/openai.yaml +0 -4
  120. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-checklist.md +0 -42
  121. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-recipes.md +0 -38
  122. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/config-shape.md +0 -86
  123. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/gate-lint.md +0 -68
  124. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/hoocoo-patterns.md +0 -39
  125. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/runtime-behavior.md +0 -41
  126. package/skills/bpmax-feishu-chat-flow-plugin-editor/references/script-authoring.md +0 -110
  127. package/skills/bpmax-feishu-chat-flow-plugin-editor/scripts/lint_feishu_chat_plugin.py +0 -278
  128. package/skills/bpmax-feishu-chat-flow-plugin-editor/tests/test_lint_feishu_chat_plugin.py +0 -203
  129. package/skills/bpmax-filter-template-editor/SKILL.md +0 -564
  130. package/skills/bpmax-filter-template-editor/references/experience-coverage-matrix.md +0 -38
  131. package/skills/bpmax-filter-template-editor/references/filter-and-flow-binding.md +0 -57
  132. package/skills/bpmax-filter-template-editor/references/filter-content-schema.md +0 -141
  133. package/skills/bpmax-filter-template-editor/references/filter-request-shape.md +0 -287
  134. package/skills/bpmax-filter-template-editor/references/filter-runtime-patterns.md +0 -115
  135. package/skills/bpmax-filter-template-editor/references/runtime-verified-filter-page-shape.md +0 -94
  136. package/skills/bpmax-filter-template-editor/scripts/build_submit_payload.py +0 -25
  137. package/skills/bpmax-filter-template-editor/scripts/confirm_filter_template.py +0 -22
  138. package/skills/bpmax-filter-template-editor/scripts/export_filter_template.py +0 -57
  139. package/skills/bpmax-filter-template-editor/scripts/filter_template_editor_common.py +0 -348
  140. package/skills/bpmax-filter-template-editor/scripts/init_create_filter_template.py +0 -8
  141. package/skills/bpmax-filter-template-editor/scripts/lint_filter_template_semantics.py +0 -26
  142. package/skills/bpmax-filter-template-editor/scripts/submit_filter_template.py +0 -62
  143. package/skills/bpmax-filter-template-editor/tests/test_filter_template_editor.py +0 -231
  144. package/skills/bpmax-flow-template-editor/SKILL.md +0 -1058
  145. package/skills/bpmax-flow-template-editor/agents/openai.yaml +0 -4
  146. package/skills/bpmax-flow-template-editor/references/before-next-step-script-runtime-gotchas.md +0 -62
  147. package/skills/bpmax-flow-template-editor/references/config-surfaces-and-placeholders.md +0 -270
  148. package/skills/bpmax-flow-template-editor/references/diff-strategy.md +0 -67
  149. package/skills/bpmax-flow-template-editor/references/editor-runtime-vs-draft.md +0 -25
  150. package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +0 -174
  151. package/skills/bpmax-flow-template-editor/references/intent-model.md +0 -117
  152. package/skills/bpmax-flow-template-editor/references/lessons-from-price-plan-flow.md +0 -147
  153. package/skills/bpmax-flow-template-editor/references/local-temp-workflow.md +0 -97
  154. package/skills/bpmax-flow-template-editor/references/matrix-flow-form-nav-collaboration.md +0 -165
  155. package/skills/bpmax-flow-template-editor/references/payload-checklist.md +0 -133
  156. package/skills/bpmax-flow-template-editor/references/project-create-runtime-gotchas.md +0 -54
  157. package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +0 -149
  158. package/skills/bpmax-flow-template-editor/references/runtime-verified-flow-detail-shape.md +0 -41
  159. package/skills/bpmax-flow-template-editor/references/runtime-verified-meta-fields.md +0 -155
  160. package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +0 -179
  161. package/skills/bpmax-flow-template-editor/references/save-draft-request-shape.md +0 -91
  162. package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +0 -93
  163. package/skills/bpmax-flow-template-editor/references/work-file-to-submit-mapping.md +0 -57
  164. package/skills/bpmax-flow-template-editor/scripts/build_submit_payload.py +0 -69
  165. package/skills/bpmax-flow-template-editor/scripts/confirm_flow_template.py +0 -52
  166. package/skills/bpmax-flow-template-editor/scripts/export_flow_template.py +0 -114
  167. package/skills/bpmax-flow-template-editor/scripts/flow_template_editor_common.py +0 -1084
  168. package/skills/bpmax-flow-template-editor/scripts/submit_flow_template.py +0 -159
  169. package/skills/bpmax-flow-template-editor/tests/test_flow_template_editor.py +0 -636
  170. package/skills/bpmax-form-template-editor/SKILL.md +0 -1099
  171. package/skills/bpmax-form-template-editor/agents/openai.yaml +0 -4
  172. package/skills/bpmax-form-template-editor/references/form-template-api-workflow.md +0 -203
  173. package/skills/bpmax-form-template-editor/references/local-temp-workflow.md +0 -125
  174. package/skills/bpmax-form-template-editor/references/payload-checklist.md +0 -77
  175. package/skills/bpmax-form-template-editor/references/sub-form-patterns.md +0 -49
  176. package/skills/bpmax-form-template-editor/scripts/build_submit_payload.py +0 -37
  177. package/skills/bpmax-form-template-editor/scripts/check_form_template_consistency.py +0 -145
  178. package/skills/bpmax-form-template-editor/scripts/confirm_form_template.py +0 -67
  179. package/skills/bpmax-form-template-editor/scripts/export_form_template.py +0 -91
  180. package/skills/bpmax-form-template-editor/scripts/form_template_editor_common.py +0 -1762
  181. package/skills/bpmax-form-template-editor/scripts/lint_form_template_semantics.py +0 -30
  182. package/skills/bpmax-form-template-editor/scripts/record_runtime_acceptance.py +0 -67
  183. package/skills/bpmax-form-template-editor/scripts/submit_form_template.py +0 -163
  184. package/skills/bpmax-form-template-editor/tests/test_form_template_editor.py +0 -1292
  185. package/skills/bpmax-list-template-editor/SKILL.md +0 -468
  186. package/skills/bpmax-list-template-editor/agents/openai.yaml +0 -4
  187. package/skills/bpmax-list-template-editor/references/browser-page-contract.md +0 -81
  188. package/skills/bpmax-list-template-editor/references/content-config-shape.md +0 -148
  189. package/skills/bpmax-list-template-editor/references/dataset-field-mapping.md +0 -60
  190. package/skills/bpmax-list-template-editor/references/list-template-api-workflow.md +0 -103
  191. package/skills/bpmax-list-template-editor/references/local-temp-workflow.md +0 -102
  192. package/skills/bpmax-list-template-editor/references/payload-checklist.md +0 -47
  193. package/skills/bpmax-list-template-editor/references/runtime-verified-workflow.md +0 -140
  194. package/skills/bpmax-list-template-editor/references/special-formats.md +0 -394
  195. package/skills/bpmax-list-template-editor/scripts/build_submit_payload.py +0 -37
  196. package/skills/bpmax-list-template-editor/scripts/confirm_list_template.py +0 -33
  197. package/skills/bpmax-list-template-editor/scripts/export_list_template.py +0 -89
  198. package/skills/bpmax-list-template-editor/scripts/fetch_data_set.py +0 -34
  199. package/skills/bpmax-list-template-editor/scripts/lint_list_template_semantics.py +0 -54
  200. package/skills/bpmax-list-template-editor/scripts/list_template_editor_common.py +0 -955
  201. package/skills/bpmax-list-template-editor/scripts/record_acceptance.py +0 -55
  202. package/skills/bpmax-list-template-editor/scripts/submit_list_template.py +0 -117
  203. package/skills/bpmax-list-template-editor/tests/test_list_template_editor_common.py +0 -441
  204. package/skills/bpmax-memory-protocol/SKILL.md +0 -72
  205. package/skills/bpmax-nav-config-editor/SKILL.md +0 -347
  206. package/skills/bpmax-nav-config-editor/agents/openai.yaml +0 -4
  207. package/skills/bpmax-nav-config-editor/references/api-workflow.md +0 -68
  208. package/skills/bpmax-nav-config-editor/references/config-shape.md +0 -78
  209. package/skills/bpmax-nav-config-editor/references/icon-selection.md +0 -83
  210. package/skills/bpmax-nav-config-editor/references/path-mapping-rules.md +0 -46
  211. package/skills/bpmax-nav-config-editor/references/payload-checklist.md +0 -41
  212. package/skills/bpmax-nav-config-editor/references/runtime-probing.md +0 -47
  213. package/skills/bpmax-nav-config-editor/scripts/build_submit_payload.py +0 -34
  214. package/skills/bpmax-nav-config-editor/scripts/confirm_nav_config.py +0 -32
  215. package/skills/bpmax-nav-config-editor/scripts/export_nav_config.py +0 -56
  216. package/skills/bpmax-nav-config-editor/scripts/lint_nav_config_semantics.py +0 -33
  217. package/skills/bpmax-nav-config-editor/scripts/nav_config_editor_common.py +0 -812
  218. package/skills/bpmax-nav-config-editor/scripts/submit_nav_config.py +0 -44
  219. package/skills/bpmax-nav-config-editor/scripts/verify_nav_config.py +0 -33
  220. package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor.py +0 -358
  221. package/skills/bpmax-nav-config-editor/tests/test_nav_config_editor_common.py +0 -138
  222. package/skills/bpmax-nav-config-editor/tests/test_nav_config_lint.py +0 -58
  223. package/skills/bpmax-nav-config-editor/tests/test_nav_config_submit_verify.py +0 -51
  224. package/skills/bpmax-project-detail-template-editor/SKILL.md +0 -329
  225. package/skills/bpmax-project-detail-template-editor/agents/openai.yaml +0 -4
  226. package/skills/bpmax-project-detail-template-editor/references/local-temp-workflow.md +0 -59
  227. package/skills/bpmax-project-detail-template-editor/references/module-catalog-and-config-notes.md +0 -47
  228. package/skills/bpmax-project-detail-template-editor/references/payload-checklist.md +0 -33
  229. package/skills/bpmax-project-detail-template-editor/references/project-detail-template-api-workflow.md +0 -44
  230. package/skills/bpmax-project-detail-template-editor/scripts/build_submit_payload.py +0 -30
  231. package/skills/bpmax-project-detail-template-editor/scripts/confirm_project_detail_template.py +0 -33
  232. package/skills/bpmax-project-detail-template-editor/scripts/export_project_detail_template.py +0 -87
  233. package/skills/bpmax-project-detail-template-editor/scripts/lint_project_detail_template_semantics.py +0 -37
  234. package/skills/bpmax-project-detail-template-editor/scripts/project_detail_template_editor_common.py +0 -507
  235. package/skills/bpmax-project-detail-template-editor/scripts/submit_project_detail_template.py +0 -120
  236. package/skills/bpmax-project-detail-template-editor/tests/test_project_detail_template_editor.py +0 -369
  237. package/skills/bpmax-role-editor/SKILL.md +0 -251
  238. package/skills/bpmax-role-editor/references/api-workflow.md +0 -30
  239. package/skills/bpmax-role-editor/references/runtime-page-shape.md +0 -18
  240. package/skills/bpmax-role-editor/references/work-file-mapping.md +0 -32
  241. package/skills/bpmax-role-editor/scripts/build_submit_payload.py +0 -38
  242. package/skills/bpmax-role-editor/scripts/confirm_role.py +0 -33
  243. package/skills/bpmax-role-editor/scripts/export_role.py +0 -163
  244. package/skills/bpmax-role-editor/scripts/lint_role_semantics.py +0 -38
  245. package/skills/bpmax-role-editor/scripts/role_editor_common.py +0 -1231
  246. package/skills/bpmax-role-editor/scripts/submit_role.py +0 -144
  247. package/skills/bpmax-role-editor/tests/test_role_editor.py +0 -343
  248. package/skills/bpmax-user-mock-operator/SKILL.md +0 -106
  249. package/skills/bpmax-user-mock-operator/agents/openai.yaml +0 -4
  250. package/skills/bpmax-user-mock-operator/scripts/switch_user_identity.py +0 -37
  251. package/skills/bpmax-user-mock-operator/scripts/user_mock_operator_common.py +0 -136
  252. package/skills/bpmax-user-mock-operator/tests/test_user_mock_operator.py +0 -138
  253. package/skills/form-control-library/SKILL.md +0 -82
  254. package/skills/form-control-library/agents/openai.yaml +0 -4
  255. package/skills/form-control-library/references/form-controls.md +0 -199
  256. package/skills/form-control-library/references/form-template-submit-schema.md +0 -180
  257. package/skills/form-control-library/references/group-select-runtime.md +0 -191
  258. package/skills/form-control-library/scripts/rebuild_form_control_library.py +0 -55
@@ -1,650 +0,0 @@
1
- #!/usr/bin/env python3
2
- from __future__ import annotations
3
-
4
- import json
5
- import subprocess
6
- import sys
7
- import ssl
8
- import urllib.error
9
- import urllib.parse
10
- import urllib.request
11
- from dataclasses import dataclass
12
- from datetime import datetime, timezone
13
- from difflib import unified_diff
14
- from pathlib import Path
15
- from typing import Any, Dict, Optional
16
-
17
-
18
- SHARED_SKILL_ROOT = Path(__file__).resolve().parents[2] / "bpmax-builder-shared"
19
- if str(SHARED_SKILL_ROOT) not in sys.path:
20
- sys.path.insert(0, str(SHARED_SKILL_ROOT))
21
- from base_url import DEFAULT_BASE_URL, resolve_base_url
22
-
23
- DEFAULT_LANGUAGE = "zhCN"
24
- DEFAULT_CONFIRM_TOKEN = "SUBMIT_CONFIRMED"
25
- REPO_ROOT = Path(__file__).resolve().parents[4]
26
- TMP_ROOT = REPO_ROOT / ".codex" / "tmp" / "dataset-editor"
27
- TMP_SUBDIRS = ("raw", "work", "meta", "submit", "diffs", "result")
28
- DEFAULT_LIST_PAGE_SIZE = 100
29
- DEFAULT_REFRESH_SETTING = {
30
- "replace_strategy": "full_refresh",
31
- "stop_refresh": 0,
32
- "stop_refresh_time": "",
33
- "stop_refresh_count": 0,
34
- }
35
-
36
- from template_script_hard_rules import scan_named_script_surfaces
37
-
38
-
39
- def utc_now_iso() -> str:
40
- return datetime.now(timezone.utc).isoformat()
41
-
42
-
43
- def ensure_tmp_dirs() -> None:
44
- for part in TMP_SUBDIRS:
45
- (TMP_ROOT / part).mkdir(parents=True, exist_ok=True)
46
-
47
-
48
- def slugify_flow_key(flow_key: str) -> str:
49
- text = flow_key.strip() if flow_key else ""
50
- return text or "default"
51
-
52
-
53
- def create_stem(flow_type: str, flow_key: str) -> str:
54
- return f"create-{flow_type}-{slugify_flow_key(flow_key)}"
55
-
56
-
57
- def paths_for(stem: Any) -> Dict[str, Path]:
58
- ensure_tmp_dirs()
59
- key = str(stem)
60
- return {
61
- "raw": TMP_ROOT / "raw" / f"{key}.json",
62
- "work": TMP_ROOT / "work" / f"{key}.json",
63
- "meta": TMP_ROOT / "meta" / f"{key}.json",
64
- "submit": TMP_ROOT / "submit" / f"{key}.json",
65
- "work_diff": TMP_ROOT / "diffs" / f"{key}.work.diff.txt",
66
- "submit_diff": TMP_ROOT / "diffs" / f"{key}.submit.diff.txt",
67
- "response": TMP_ROOT / "result" / f"{key}.response.json",
68
- "readback": TMP_ROOT / "result" / f"{key}.readback.json",
69
- "verify": TMP_ROOT / "result" / f"{key}.verify.json",
70
- "lint": TMP_ROOT / "result" / f"{key}.lint.json",
71
- }
72
-
73
-
74
- def dump_json(path: Path, payload: Any) -> None:
75
- path.parent.mkdir(parents=True, exist_ok=True)
76
- path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
77
-
78
-
79
- def load_json(path: Path) -> Any:
80
- return json.loads(path.read_text(encoding="utf-8"))
81
-
82
-
83
- def stable_json_lines(payload: Any) -> list[str]:
84
- return (json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n").splitlines(keepends=True)
85
-
86
-
87
- def write_diff(path: Path, before: Any, after: Any, before_label: str, after_label: str) -> None:
88
- diff = unified_diff(
89
- stable_json_lines(before),
90
- stable_json_lines(after),
91
- fromfile=before_label,
92
- tofile=after_label,
93
- )
94
- text = "".join(diff)
95
- path.parent.mkdir(parents=True, exist_ok=True)
96
- path.write_text(text or "# no diff\n", encoding="utf-8")
97
-
98
-
99
- def normalize_text(value: Any) -> str:
100
- if value is None:
101
- return ""
102
- if isinstance(value, str):
103
- return value
104
- return json.dumps(value, ensure_ascii=False, sort_keys=True)
105
-
106
-
107
- def normalize_int(value: Any) -> int:
108
- if value in (None, ""):
109
- return 0
110
- return int(value)
111
-
112
-
113
- def normalize_refresh_setting(value: Any) -> Dict[str, Any]:
114
- data = dict(DEFAULT_REFRESH_SETTING)
115
- if isinstance(value, dict):
116
- data.update(value)
117
- return {
118
- "replace_strategy": normalize_text(data.get("replace_strategy", DEFAULT_REFRESH_SETTING["replace_strategy"])),
119
- "stop_refresh": normalize_int(data.get("stop_refresh", DEFAULT_REFRESH_SETTING["stop_refresh"])),
120
- "stop_refresh_time": normalize_text(data.get("stop_refresh_time", DEFAULT_REFRESH_SETTING["stop_refresh_time"])),
121
- "stop_refresh_count": normalize_int(data.get("stop_refresh_count", DEFAULT_REFRESH_SETTING["stop_refresh_count"])),
122
- }
123
-
124
-
125
- def refresh_setting_to_work(value: Any) -> Dict[str, Any]:
126
- data = normalize_refresh_setting(value)
127
- return {
128
- "replaceStrategy": data["replace_strategy"],
129
- "stopRefresh": data["stop_refresh"],
130
- "stopRefreshTime": data["stop_refresh_time"],
131
- "stopRefreshCount": data["stop_refresh_count"],
132
- }
133
-
134
-
135
- def refresh_setting_to_submit(value: Any) -> Dict[str, Any]:
136
- if not isinstance(value, dict):
137
- return dict(DEFAULT_REFRESH_SETTING)
138
- return normalize_refresh_setting(
139
- {
140
- "replace_strategy": value.get("replaceStrategy", value.get("replace_strategy")),
141
- "stop_refresh": value.get("stopRefresh", value.get("stop_refresh")),
142
- "stop_refresh_time": value.get("stopRefreshTime", value.get("stop_refresh_time")),
143
- "stop_refresh_count": value.get("stopRefreshCount", value.get("stop_refresh_count")),
144
- }
145
- )
146
-
147
-
148
- def simplify_field(item: Dict[str, Any]) -> Dict[str, Any]:
149
- return {
150
- "id": item.get("id"),
151
- "key": item.get("key", ""),
152
- "name": item.get("name", ""),
153
- }
154
-
155
-
156
- def field_summary(items: list[Dict[str, Any]]) -> Dict[str, Any]:
157
- normalized = [simplify_field(item) for item in items]
158
- return {
159
- "count": len(normalized),
160
- "items": normalized,
161
- "ids": [item["id"] for item in normalized if item.get("id") is not None],
162
- "keys": [item["key"] for item in normalized if item.get("key")],
163
- }
164
-
165
-
166
- def detail_to_work_payload(detail: Dict[str, Any], available_fields: Optional[list[Dict[str, Any]]] = None) -> Dict[str, Any]:
167
- selected_fields = [simplify_field(item) for item in detail.get("dataSetFields") or detail.get("fields") or []]
168
- available = [simplify_field(item) for item in (available_fields or [])]
169
- selected_ids = {item.get("id") for item in selected_fields}
170
- available = [item for item in available if item.get("id") not in selected_ids]
171
- return {
172
- "id": detail.get("id"),
173
- "mode": "edit",
174
- "flowType": detail.get("flow_type", ""),
175
- "flowKey": detail.get("flow_key", ""),
176
- "status": detail.get("status"),
177
- "basic": {
178
- "name": detail.get("name", ""),
179
- "basicTable": detail.get("basic_table", ""),
180
- "customKey": normalize_text(detail.get("custom_key", "")),
181
- "nonBlock": normalize_int(detail.get("non_block", 0)),
182
- "isDefault": normalize_int(detail.get("is_default", 0)),
183
- },
184
- "scripts": {
185
- "postScript": normalize_text(detail.get("post_script", "")),
186
- "postEsMapping": normalize_text(detail.get("post_es_mapping", "")),
187
- "refreshProjectScript": normalize_text(detail.get("refresh_project_script", "")),
188
- },
189
- "search": {
190
- "preProcessScript": normalize_text(detail.get("pre_process_script", "")),
191
- "postProcessScript": normalize_text(detail.get("post_process_script", "")),
192
- "tag": normalize_int(detail.get("process_script_tag", 0)),
193
- },
194
- "refreshSetting": refresh_setting_to_work(detail.get("refresh_setting")),
195
- "fields": {
196
- "selected": selected_fields,
197
- "selectedKeys": [item["key"] for item in selected_fields if item.get("key")],
198
- "available": available,
199
- },
200
- }
201
-
202
-
203
- def build_create_skeleton(
204
- flow_type: str,
205
- flow_key: str = "",
206
- basic_table: str = "",
207
- defaults: Optional[Dict[str, Any]] = None,
208
- field_options: Optional[list[Dict[str, Any]]] = None,
209
- ) -> Dict[str, Any]:
210
- defaults = defaults or {}
211
- return {
212
- "id": None,
213
- "mode": "create",
214
- "flowType": flow_type,
215
- "flowKey": flow_key,
216
- "status": None,
217
- "basic": {
218
- "name": defaults.get("name", ""),
219
- "basicTable": defaults.get("basicTable", basic_table),
220
- "customKey": defaults.get("customKey", ""),
221
- "nonBlock": normalize_int(defaults.get("nonBlock", 0)),
222
- "isDefault": normalize_int(defaults.get("isDefault", 0)),
223
- },
224
- "scripts": {
225
- "postScript": normalize_text(defaults.get("postScript", "")),
226
- "postEsMapping": normalize_text(defaults.get("postEsMapping", "")),
227
- "refreshProjectScript": normalize_text(defaults.get("refreshProjectScript", "")),
228
- },
229
- "search": {
230
- "preProcessScript": normalize_text(defaults.get("preProcessScript", "")),
231
- "postProcessScript": normalize_text(defaults.get("postProcessScript", "")),
232
- "tag": normalize_int(defaults.get("tag", 0)),
233
- },
234
- "refreshSetting": refresh_setting_to_work(defaults.get("refreshSetting")),
235
- "fields": {
236
- "selected": [simplify_field(item) for item in defaults.get("selectedFields", [])],
237
- "selectedKeys": [item["key"] for item in defaults.get("selectedFields", []) if item.get("key")],
238
- "available": [simplify_field(item) for item in (field_options or [])],
239
- },
240
- }
241
-
242
-
243
- def build_submit_payload(work: Dict[str, Any]) -> Dict[str, Any]:
244
- basic = work.get("basic") or {}
245
- scripts = work.get("scripts") or {}
246
- search = work.get("search") or {}
247
- selected_fields = (work.get("fields") or {}).get("selected") or []
248
- payload: Dict[str, Any] = {
249
- "name": basic.get("name", ""),
250
- "basic_table": basic.get("basicTable", ""),
251
- "custom_key": normalize_text(basic.get("customKey", "")),
252
- "non_block": normalize_int(basic.get("nonBlock", 0)),
253
- "is_default": normalize_int(basic.get("isDefault", 0)),
254
- "flow_type": work.get("flowType", ""),
255
- "post_script": normalize_text(scripts.get("postScript", "")),
256
- "post_es_mapping": normalize_text(scripts.get("postEsMapping", "")),
257
- "refresh_project_script": normalize_text(scripts.get("refreshProjectScript", "")),
258
- "pre_process_script": normalize_text(search.get("preProcessScript", "")),
259
- "post_process_script": normalize_text(search.get("postProcessScript", "")),
260
- "process_script_tag": normalize_int(search.get("tag", 0)),
261
- "refresh_setting": refresh_setting_to_submit(work.get("refreshSetting")),
262
- "fields": [item["key"] for item in selected_fields if item.get("key")],
263
- }
264
- if work.get("flowKey", "") not in ("", None):
265
- payload["flow_key"] = work["flowKey"]
266
- if work.get("id") not in (None, ""):
267
- payload["id"] = work["id"]
268
- return payload
269
-
270
-
271
- def load_repo_dataset_snapshots(
272
- flow_type: str,
273
- flow_key: str = "",
274
- repo_root: Path = REPO_ROOT,
275
- ) -> list[Dict[str, Any]]:
276
- base = repo_root / "think_data_set"
277
- snapshots: list[Dict[str, Any]] = []
278
- if not base.exists():
279
- return snapshots
280
- for path in base.rglob("data_set"):
281
- try:
282
- payload = load_json(path)
283
- except (json.JSONDecodeError, OSError):
284
- continue
285
- if payload.get("flow_type") != flow_type:
286
- continue
287
- if normalize_text(payload.get("flow_key", "")) != normalize_text(flow_key):
288
- continue
289
- snapshots.append(
290
- {
291
- "path": str(path.relative_to(repo_root)),
292
- "id": payload.get("id"),
293
- "name": payload.get("name", ""),
294
- "basic_table": payload.get("basic_table", ""),
295
- "custom_key": normalize_text(payload.get("custom_key", "")),
296
- "status": payload.get("status"),
297
- }
298
- )
299
- return snapshots
300
-
301
-
302
- def summarize_basic_table_audit(
303
- detail: Dict[str, Any],
304
- peer_items: Optional[list[Dict[str, Any]]] = None,
305
- repo_items: Optional[list[Dict[str, Any]]] = None,
306
- preferred_basic_tables: Optional[list[str]] = None,
307
- ) -> Dict[str, Any]:
308
- actual = normalize_text(detail.get("basic_table", ""))
309
- preferred = [normalize_text(item) for item in (preferred_basic_tables or []) if normalize_text(item)]
310
- peer_tables = sorted(
311
- {
312
- normalize_text(item.get("basic_table", ""))
313
- for item in (peer_items or [])
314
- if normalize_text(item.get("basic_table", ""))
315
- }
316
- )
317
- repo_tables = sorted(
318
- {
319
- normalize_text(item.get("basic_table", ""))
320
- for item in (repo_items or [])
321
- if normalize_text(item.get("basic_table", ""))
322
- }
323
- )
324
- recommended = preferred or peer_tables or repo_tables
325
- reasons: list[str] = []
326
- suspicious = False
327
- if not actual:
328
- suspicious = True
329
- reasons.append("basic_table is empty")
330
- if actual == "project" and "think_project" in recommended:
331
- suspicious = True
332
- reasons.append("project conflicts with recommended think_project")
333
- if recommended and actual and actual not in recommended:
334
- suspicious = True
335
- reasons.append("basic_table differs from same-flow defaults")
336
- return {
337
- "ok": not suspicious,
338
- "severity": "blocker" if suspicious else "ok",
339
- "actual": actual,
340
- "recommended": recommended,
341
- "reasons": reasons,
342
- "peerSummary": {
343
- "count": len(peer_items or []),
344
- "basicTables": peer_tables,
345
- },
346
- "repoSummary": {
347
- "count": len(repo_items or []),
348
- "basicTables": repo_tables,
349
- },
350
- }
351
-
352
-
353
- def summarize_publish_health(detail: Dict[str, Any], es_data: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
354
- status = detail.get("status")
355
- batch = {
356
- "current_batch_id": normalize_text(detail.get("current_batch_id", "")),
357
- "current_batch_count": detail.get("current_batch_count"),
358
- "current_batch_create_time": normalize_text(detail.get("current_batch_create_time", "")),
359
- }
360
- batch_missing = (
361
- batch["current_batch_id"] == ""
362
- and batch["current_batch_count"] in (None, "")
363
- and batch["current_batch_create_time"] == ""
364
- )
365
- reasons: list[str] = []
366
- suspicious = False
367
- if status == 3 and batch_missing:
368
- suspicious = True
369
- reasons.append("status=3 while current_batch_* is empty")
370
- es_summary: Dict[str, Any] = {"available": es_data is not None}
371
- if isinstance(es_data, dict):
372
- docs = es_data.get("docs") or es_data.get("data") or es_data.get("rows")
373
- if isinstance(docs, list):
374
- es_summary["docCount"] = len(docs)
375
- elif isinstance(docs, dict):
376
- es_summary["docCount"] = len(docs)
377
- else:
378
- es_summary["docCount"] = 0 if docs in (None, "") else 1
379
- return {
380
- "ok": not suspicious,
381
- "severity": "blocker" if suspicious else "ok",
382
- "status": status,
383
- "batch": batch,
384
- "esData": es_summary,
385
- "reasons": reasons,
386
- }
387
-
388
-
389
- def summarize_list_verification(
390
- submit_payload: Dict[str, Any],
391
- readback_detail: Dict[str, Any],
392
- list_item: Optional[Dict[str, Any]],
393
- ) -> Dict[str, Any]:
394
- expected_fields = [item for item in submit_payload.get("fields", []) if item]
395
- checks = {
396
- "found": bool(list_item),
397
- "name": False,
398
- "custom_key": False,
399
- "status": False,
400
- "field_count": False,
401
- }
402
- actual = {
403
- "list": list_item or {},
404
- "detail": {
405
- "fieldCount": len((readback_detail.get("dataSetFields") or readback_detail.get("fields") or [])),
406
- },
407
- }
408
- expected = {
409
- "name": submit_payload.get("name", ""),
410
- "custom_key": normalize_text(submit_payload.get("custom_key", "")),
411
- "status": readback_detail.get("status"),
412
- "fieldCount": len(expected_fields),
413
- }
414
- if list_item:
415
- checks["name"] = normalize_text(list_item.get("name", "")) == expected["name"]
416
- checks["custom_key"] = normalize_text(list_item.get("custom_key", "")) == expected["custom_key"]
417
- checks["status"] = list_item.get("status") == expected["status"]
418
- checks["field_count"] = actual["detail"]["fieldCount"] == expected["fieldCount"]
419
- return {
420
- "ok": all(checks.values()),
421
- "checks": checks,
422
- "expected": expected,
423
- "actual": actual,
424
- }
425
-
426
-
427
- def build_dataset_lint_report(
428
- work_payload: Dict[str, Any],
429
- *,
430
- meta: Optional[Dict[str, Any]] = None,
431
- submit_payload: Optional[Dict[str, Any]] = None,
432
- ) -> Dict[str, Any]:
433
- report: Dict[str, Any] = {"ok": True, "errors": [], "warnings": [], "checks": {}}
434
- normalized_meta = dict(meta or {})
435
- basic_table_audit = normalized_meta.get("basicTableAudit")
436
- if isinstance(basic_table_audit, dict):
437
- report["checks"]["basicTableAudit"] = basic_table_audit
438
- if basic_table_audit.get("severity") == "blocker":
439
- report["errors"].append("basicTableAudit blocker: " + "; ".join(basic_table_audit.get("reasons") or ["unknown"]))
440
-
441
- payload = submit_payload or build_submit_payload(work_payload)
442
- script_surfaces = [
443
- {"path": "scripts.postScript", "script": payload.get("post_script")},
444
- {"path": "scripts.postEsMapping", "script": payload.get("post_es_mapping")},
445
- {"path": "scripts.refreshProjectScript", "script": payload.get("refresh_project_script")},
446
- {"path": "search.preProcessScript", "script": payload.get("pre_process_script")},
447
- {"path": "search.postProcessScript", "script": payload.get("post_process_script")},
448
- ]
449
- hard_rule_report = scan_named_script_surfaces(script_surfaces)
450
- report["checks"]["scriptHardRules"] = hard_rule_report["findings"]
451
- report["errors"].extend(hard_rule_report["errors"])
452
- report["ok"] = not report["errors"]
453
- return report
454
-
455
-
456
- def scan_custom_key_references(custom_key: str, repo_root: Path = REPO_ROOT) -> Dict[str, Any]:
457
- needle = normalize_text(custom_key).strip()
458
- if not needle:
459
- return {"ok": True, "customKey": needle, "count": 0, "matches": [], "warning": False}
460
- cmd = [
461
- "rg",
462
- "-n",
463
- "-F",
464
- "--glob",
465
- "!think_data_set/**",
466
- needle,
467
- str(repo_root / "think_flow_page_template"),
468
- str(repo_root / "think_configuration"),
469
- str(repo_root / "think_flow"),
470
- ]
471
- result = subprocess.run(cmd, capture_output=True, text=True, check=False)
472
- matches: list[Dict[str, Any]] = []
473
- if result.returncode in (0, 1):
474
- for line in result.stdout.splitlines():
475
- path_text, line_no, snippet = (line.split(":", 2) + ["", ""])[:3]
476
- path = Path(path_text)
477
- try:
478
- relative = str(path.relative_to(repo_root))
479
- except ValueError:
480
- relative = path_text
481
- matches.append({"path": relative, "line": int(line_no), "snippet": snippet.strip()})
482
- else:
483
- raise SystemExit(f"rg failed while scanning custom_key references: {result.stderr.strip()}")
484
- return {
485
- "ok": True,
486
- "customKey": needle,
487
- "count": len(matches),
488
- "matches": matches[:50],
489
- "warning": bool(matches),
490
- }
491
-
492
-
493
- def resolve_dataset_candidates(
494
- list_rows: list[Dict[str, Any]],
495
- *,
496
- name: str = "",
497
- custom_key: str = "",
498
- ) -> Dict[str, Any]:
499
- target_name = normalize_text(name).strip()
500
- target_key = normalize_text(custom_key).strip()
501
- candidates: list[Dict[str, Any]] = []
502
- for item in list_rows:
503
- matches_name = not target_name or normalize_text(item.get("name", "")).strip() == target_name
504
- matches_key = not target_key or normalize_text(item.get("custom_key", "")).strip() == target_key
505
- if matches_name and matches_key:
506
- candidates.append(item)
507
- return {
508
- "ok": len(candidates) == 1,
509
- "count": len(candidates),
510
- "candidates": candidates,
511
- }
512
-
513
-
514
- def summarize_verification(submit_payload: Dict[str, Any], readback_detail: Dict[str, Any]) -> Dict[str, Any]:
515
- checks: Dict[str, Dict[str, Any]] = {}
516
- ok = True
517
- simple_mapping = {
518
- "name": "name",
519
- "basic_table": "basic_table",
520
- "custom_key": "custom_key",
521
- "non_block": "non_block",
522
- "is_default": "is_default",
523
- "post_script": "post_script",
524
- "post_es_mapping": "post_es_mapping",
525
- "refresh_project_script": "refresh_project_script",
526
- "pre_process_script": "pre_process_script",
527
- "post_process_script": "post_process_script",
528
- "process_script_tag": "process_script_tag",
529
- "refresh_setting": "refresh_setting",
530
- }
531
- for submit_key, readback_key in simple_mapping.items():
532
- expected = normalize_text(submit_payload.get(submit_key, ""))
533
- actual = normalize_text(readback_detail.get(readback_key, ""))
534
- match = expected == actual
535
- ok = ok and match
536
- checks[submit_key] = {"match": match, "expected": expected, "actual": actual}
537
-
538
- expected_fields = [item for item in submit_payload.get("fields", []) if item]
539
- readback_fields = readback_detail.get("dataSetFields") or readback_detail.get("fields") or []
540
- actual_summary = field_summary(readback_fields)
541
- expected_summary = {
542
- "count": len(expected_fields),
543
- "ids": [item.get("id") for item in readback_fields if item.get("key") in set(expected_fields)],
544
- "keys": expected_fields,
545
- }
546
- fields_match = expected_summary["keys"] == actual_summary["keys"]
547
- ok = ok and fields_match
548
- checks["fields"] = {
549
- "match": fields_match,
550
- "expected": expected_summary,
551
- "actual": actual_summary,
552
- }
553
- return {"ok": ok, "checks": checks}
554
-
555
-
556
- def require_confirm_token(token: str) -> None:
557
- if token != DEFAULT_CONFIRM_TOKEN:
558
- raise SystemExit(f"refusing to submit: --confirm-token must equal {DEFAULT_CONFIRM_TOKEN}")
559
-
560
-
561
- @dataclass
562
- class ApiClient:
563
- base_url: str
564
- workspace: str
565
- language: str
566
- cookie_header: str
567
- timeout: float
568
- insecure: bool = False
569
-
570
- def _build_url(self, path: str) -> str:
571
- suffix = f"$workspace={urllib.parse.quote(self.workspace)}&$language={urllib.parse.quote(self.language)}"
572
- joiner = "&" if "?" in path else "?"
573
- return self.base_url.rstrip("/") + path + joiner + suffix
574
-
575
- def request(self, method: str, path: str, body: Optional[dict] = None) -> dict:
576
- headers = {
577
- "content-type": "application/json",
578
- "cookie": self.cookie_header,
579
- "accept": "application/json, text/plain, */*",
580
- }
581
- data = None if body is None else json.dumps(body, ensure_ascii=False).encode("utf-8")
582
- req = urllib.request.Request(self._build_url(path), data=data, headers=headers, method=method)
583
- context = ssl._create_unverified_context() if self.insecure else None
584
- try:
585
- with urllib.request.urlopen(req, timeout=self.timeout, context=context) as resp:
586
- raw = resp.read().decode("utf-8", "replace")
587
- except urllib.error.HTTPError as err:
588
- raw = err.read().decode("utf-8", "replace")
589
- raise SystemExit(f"HTTP {err.code} {path}: {raw}") from err
590
- except urllib.error.URLError as err:
591
- raise SystemExit(f"Request failed {path}: {err}") from err
592
- payload = json.loads(raw)
593
- if payload.get("code") != 0:
594
- raise SystemExit(f"API error {path}: {raw}")
595
- return payload
596
-
597
- def get_dataset(self, dataset_id: int) -> dict:
598
- return self.request("GET", f"/bpmax/data-set/{dataset_id}")
599
-
600
- def list_datasets(
601
- self,
602
- flow_type: str,
603
- flow_key: str = "",
604
- *,
605
- page: int = 1,
606
- page_size: int = DEFAULT_LIST_PAGE_SIZE,
607
- include_relations: bool = True,
608
- include_progress: bool = True,
609
- is_del: int = 0,
610
- ) -> dict:
611
- payload: Dict[str, Any] = {
612
- "is_del": is_del,
613
- "flow_type": flow_type,
614
- "flow_key": flow_key,
615
- "includeRelations": include_relations,
616
- "includeProgress": include_progress,
617
- }
618
- return self.request("POST", f"/bpmax/data-set/list?page_size={page_size}&page={page}", payload)
619
-
620
- def create_dataset(self, payload: dict) -> dict:
621
- return self.request("POST", "/bpmax/data-set", payload)
622
-
623
- def update_dataset_relation_fields(self, dataset_id: int, payload: dict) -> dict:
624
- return self.request("POST", f"/bpmax/data-set/relationFields/{dataset_id}", payload)
625
-
626
- def get_flow_fields(self, flow_type: str, flow_key: str = "") -> dict:
627
- query = f"/bpmax/data-set-field/getBatchByFlow?flow_type={urllib.parse.quote(flow_type)}"
628
- if flow_key not in ("", None):
629
- query += f"&flow_key={urllib.parse.quote(flow_key)}"
630
- return self.request("GET", query)
631
-
632
- def get_dataset_es_data(self, dataset_id: int) -> dict:
633
- return self.request("GET", f"/bpmax/data-set/esData/{dataset_id}")
634
-
635
-
636
- def build_client(args: Any) -> ApiClient:
637
- workspace = getattr(args, "workspace", None)
638
- cookie_header = getattr(args, "cookie_header", None)
639
- if not workspace:
640
- raise SystemExit("--workspace is required")
641
- if not cookie_header:
642
- raise SystemExit("--cookie-header is required")
643
- return ApiClient(
644
- base_url=resolve_base_url(getattr(args, "base_url", None)),
645
- workspace=workspace,
646
- language=getattr(args, "language", None) or DEFAULT_LANGUAGE,
647
- cookie_header=cookie_header,
648
- timeout=float(getattr(args, "timeout", 30)),
649
- insecure=bool(getattr(args, "insecure", False)),
650
- )