bpmax-cli 0.1.44-beta.6 → 0.1.44-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -265,6 +265,7 @@ function getValue(value, path9) {
265
265
  function capabilityForRequest(method, path9) {
266
266
  const normalizedMethod = method.toUpperCase();
267
267
  const normalizedPath = normalizePath2(path9);
268
+ const pageTemplatePrefix = flowPageTemplateCapabilityPrefix(path9);
268
269
  if (normalizedPath === "/cli/capabilities") {
269
270
  return void 0;
270
271
  }
@@ -285,11 +286,48 @@ function capabilityForRequest(method, path9) {
285
286
  if (normalizedMethod === "GET" && normalizedPath === "/flow/options") return "flow.options";
286
287
  if (normalizedMethod === "GET" && normalizedPath === "/flow") return "config.flow_template.export";
287
288
  if (normalizedMethod === "PUT" && normalizedPath === "/flow") return "config.flow_template.submit";
289
+ if (normalizedMethod === "DELETE" && normalizedPath === "/flow") return "config.flow_template.delete";
288
290
  if (normalizedMethod === "POST" && normalizedPath === "/flow/batch_get") return "flow.get";
289
291
  if (normalizedMethod === "GET" && normalizedPath.startsWith("/form_template/")) return "config.form_template.export";
290
292
  if (normalizedMethod === "POST" && normalizedPath === "/form_template") return "config.form_template.create";
291
293
  if (normalizedMethod === "PUT" && /^\/form_template\/[^/]+$/.test(normalizedPath)) return "config.form_template.submit";
294
+ if (normalizedMethod === "DELETE" && /^\/form_template\/[^/]+$/.test(normalizedPath)) return "config.form_template.delete";
292
295
  if (normalizedMethod === "POST" && normalizedPath === "/form_template/publish") return "config.form_template.submit";
296
+ if (normalizedMethod === "POST" && normalizedPath === "/flow_page_template") return `${pageTemplatePrefix}.create`;
297
+ if (normalizedMethod === "GET" && /^\/flow_page_template\/[^/]+$/.test(normalizedPath)) return `${pageTemplatePrefix}.export`;
298
+ if (normalizedMethod === "PUT" && /^\/flow_page_template\/[^/]+$/.test(normalizedPath)) return `${pageTemplatePrefix}.submit`;
299
+ if (normalizedMethod === "DELETE" && /^\/flow_page_template\/[^/]+$/.test(normalizedPath)) return `${pageTemplatePrefix}.delete`;
300
+ if (normalizedMethod === "POST" && normalizedPath === "/data_set") return "config.dataset.create";
301
+ if (normalizedMethod === "GET" && /^\/data_set\/[^/]+$/.test(normalizedPath)) return "config.dataset.export";
302
+ if (normalizedMethod === "POST" && /^\/data_set\/relationFields\/[^/]+$/.test(normalizedPath)) return "config.dataset.submit";
303
+ if (normalizedMethod === "DELETE" && /^\/data_set\/[^/]+$/.test(normalizedPath)) return "config.dataset.delete";
304
+ if (normalizedMethod === "POST" && normalizedPath === "/data_set_field") return "config.dataset_field.create";
305
+ if (normalizedMethod === "GET" && /^\/data_set_field\/[^/]+$/.test(normalizedPath)) return "config.dataset_field.export";
306
+ if (normalizedMethod === "PUT" && /^\/data_set_field\/[^/]+$/.test(normalizedPath)) return "config.dataset_field.submit";
307
+ if (normalizedMethod === "DELETE" && /^\/data_set_field\/[^/]+$/.test(normalizedPath)) return "config.dataset_field.delete";
308
+ if (normalizedMethod === "POST" && normalizedPath === "/api_platform") return "config.api_platform.create";
309
+ if (normalizedMethod === "POST" && normalizedPath === "/api_platform_instance") return "config.api_platform.create";
310
+ if (normalizedMethod === "POST" && normalizedPath === "/api_proxy") return "config.api_platform.create";
311
+ if (normalizedMethod === "POST" && normalizedPath === "/api_proxy_entity_binding") return "config.api_platform.create";
312
+ if (normalizedMethod === "PUT" && /^\/api_platform\/[^/]+$/.test(normalizedPath)) return "config.api_platform.submit";
313
+ if (normalizedMethod === "PUT" && /^\/api_platform_instance\/[^/]+$/.test(normalizedPath)) return "config.api_platform.submit";
314
+ if (normalizedMethod === "PUT" && /^\/api_proxy\/[^/]+$/.test(normalizedPath)) return "config.api_platform.submit";
315
+ if (normalizedMethod === "PUT" && /^\/api_proxy_entity_binding\/[^/]+$/.test(normalizedPath)) return "config.api_platform.submit";
316
+ if (normalizedMethod === "DELETE" && /^\/api_platform\/[^/]+$/.test(normalizedPath)) return "config.api_platform.delete";
317
+ if (normalizedMethod === "DELETE" && /^\/api_platform_instance\/[^/]+$/.test(normalizedPath)) return "config.api_platform.delete";
318
+ if (normalizedMethod === "DELETE" && /^\/api_proxy\/[^/]+$/.test(normalizedPath)) return "config.api_platform.delete";
319
+ if (normalizedMethod === "DELETE" && /^\/api_proxy_entity_binding\/[^/]+$/.test(normalizedPath)) return "config.api_platform.delete";
320
+ if (normalizedMethod === "POST" && normalizedPath === "/role") return "config.role.create";
321
+ if (normalizedMethod === "POST" && normalizedPath === "/point") return "config.role.create";
322
+ if (normalizedMethod === "POST" && normalizedPath === "/user_role") return "config.role.create";
323
+ if (normalizedMethod === "PUT" && /^\/role\/[^/]+$/.test(normalizedPath)) return "config.role.submit";
324
+ if (normalizedMethod === "PUT" && /^\/point\/[^/]+$/.test(normalizedPath)) return "config.role.submit";
325
+ if (normalizedMethod === "DELETE" && /^\/role\/[^/]+$/.test(normalizedPath)) return "config.role.delete";
326
+ if (normalizedMethod === "DELETE" && /^\/point\/[^/]+$/.test(normalizedPath)) return "config.role.delete";
327
+ if (normalizedMethod === "DELETE" && /^\/user_role\/[^/]+$/.test(normalizedPath)) return "config.role.delete";
328
+ if (normalizedMethod === "POST" && normalizedPath === "/configuration") return "config.nav_config.create";
329
+ if (normalizedMethod === "PUT" && /^\/configuration\/[^/]+$/.test(normalizedPath)) return "config.nav_config.submit";
330
+ if (normalizedMethod === "DELETE" && /^\/configuration\/[^/]+$/.test(normalizedPath)) return "config.nav_config.delete";
293
331
  if (normalizedMethod === "PUT" && normalizedPath === "/workspace/workspace_flow") return "config.workspace_flow.submit";
294
332
  if (normalizedMethod === "POST" && normalizedPath === "/project_staging/prefill") return "project.create";
295
333
  if (normalizedMethod === "POST" && normalizedPath === "/project/search") return "project.search";
@@ -371,6 +409,20 @@ async function updateProfileCapabilities(profileName, cache) {
371
409
  };
372
410
  await saveConfig(config);
373
411
  }
412
+ function flowPageTemplateCapabilityPrefix(path9) {
413
+ const query = path9.includes("?") ? path9.slice(path9.indexOf("?") + 1) : "";
414
+ const type = new URLSearchParams(query).get("type");
415
+ if (type === "2") {
416
+ return "config.project_detail_template";
417
+ }
418
+ if (type === "3") {
419
+ return "config.filter_template";
420
+ }
421
+ if (type === "4") {
422
+ return "config.console_template";
423
+ }
424
+ return "config.list_template";
425
+ }
374
426
  function normalizePath2(path9) {
375
427
  let normalized = path9.split("?")[0] || "/";
376
428
  if (!normalized.startsWith("/")) {
@@ -389,7 +441,7 @@ function normalizePath2(path9) {
389
441
  // package.json
390
442
  var package_default = {
391
443
  name: "bpmax-cli",
392
- version: "0.1.44-beta.6",
444
+ version: "0.1.44-beta.8",
393
445
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
394
446
  type: "module",
395
447
  bin: {
@@ -2591,10 +2643,14 @@ var CONFIG_DOMAINS = {
2591
2643
  exportStatus: "supported",
2592
2644
  buildStatus: "supported",
2593
2645
  submitStatus: "supported",
2646
+ createPath: "/form_template",
2647
+ createMethod: "POST",
2648
+ deletePath: (id) => `/form_template/${id}`,
2649
+ deleteMethod: "DELETE",
2594
2650
  submitPath: (id) => `/form_template/${id}`,
2595
2651
  submitMethod: "PUT",
2596
2652
  readEndpoints: ["GET /api/form_template/:id"],
2597
- writeEndpoints: ["POST /api/form_template", "PUT /api/form_template/:id", "POST /api/form_template/publish"],
2653
+ writeEndpoints: ["POST /api/form_template", "PUT /api/form_template/:id", "DELETE /api/form_template/:id", "POST /api/form_template/publish"],
2598
2654
  notes: ["Supports edit and create modes. Edit updates the draft/current template and publishes after update; create posts a new draft and publishes it through the typed adapter."]
2599
2655
  },
2600
2656
  "flow-template": {
@@ -2603,10 +2659,12 @@ var CONFIG_DOMAINS = {
2603
2659
  exportStatus: "supported",
2604
2660
  buildStatus: "supported",
2605
2661
  submitStatus: "supported",
2662
+ deletePath: (id) => `/flow?${flowIdentityQuery(parseFlowIdentity(id))}`,
2663
+ deleteMethod: "DELETE",
2606
2664
  submitPath: (id) => `/flow?${flowIdentityQuery(parseFlowIdentity(id), { publish: 2 })}`,
2607
2665
  submitMethod: "PUT",
2608
2666
  readEndpoints: ["GET /api/flow?flow_type=:flow_type&draft=1", "GET /api/flow?key=:key&draft=1", "POST /api/flow/batch_get"],
2609
- writeEndpoints: ["POST /api/flow/flow_type", "PUT /api/flow?flow_type=:flow_type&publish=2", "PUT /api/flow?key=:key&publish=2", "PUT /api/flow?flow_type=:flow_type&publish=1", "PUT /api/flow?key=:key&publish=1"],
2667
+ writeEndpoints: ["POST /api/flow/flow_type", "PUT /api/flow?flow_type=:flow_type&publish=2", "PUT /api/flow?key=:key&publish=2", "PUT /api/flow?flow_type=:flow_type&publish=1", "PUT /api/flow?key=:key&publish=1", "DELETE /api/flow?flow_type=:flow_type&key=:key"],
2610
2668
  notes: ["Flow config is keyed by flow_type for main flows or key for subflows. Export id format: flow_type, flow_type:<type>, or key:<subflowKey>. Submit writes draft by default and only publishes when payload.publish_live=true. Create first asks the platform for a flow<number> and never accepts a hand-authored main flow_type."]
2611
2669
  },
2612
2670
  "workspace-flow": {
@@ -2615,11 +2673,13 @@ var CONFIG_DOMAINS = {
2615
2673
  exportStatus: "supported",
2616
2674
  buildStatus: "supported",
2617
2675
  submitStatus: "supported",
2676
+ createPath: "/workspace/workspace_flow",
2677
+ createMethod: "PUT",
2618
2678
  submitPath: () => "/workspace/workspace_flow",
2619
2679
  submitMethod: "PUT",
2620
2680
  readEndpoints: ["GET /api/workspace/by_key?key=:workspace"],
2621
2681
  writeEndpoints: ["PUT /api/workspace/workspace_flow"],
2622
- notes: ["Workspace flow submit replaces the workspace_flow relation list for one workspace, then verifies by /workspace/by_key."]
2682
+ notes: ["Workspace flow create/submit replaces the workspace_flow relation list for one workspace, then verifies by /workspace/by_key. Create is a capability alias for adding a new binding through the typed submit adapter."]
2623
2683
  },
2624
2684
  "list-template": {
2625
2685
  capability: "config.list_template",
@@ -2627,12 +2687,16 @@ var CONFIG_DOMAINS = {
2627
2687
  exportStatus: "supported",
2628
2688
  buildStatus: "supported",
2629
2689
  submitStatus: "supported",
2690
+ createPath: "/flow_page_template",
2691
+ createMethod: "POST",
2692
+ deletePath: (id) => `/flow_page_template/${id}`,
2693
+ deleteMethod: "DELETE",
2630
2694
  submitPath: (id) => `/flow_page_template/${id}`,
2631
2695
  submitMethod: "PUT",
2632
2696
  expectedType: 1,
2633
2697
  readEndpoints: ["GET /api/flow_page_template/:id?skip_i18n=true"],
2634
- writeEndpoints: ["PUT /api/flow_page_template/:id"],
2635
- notes: ["type=1 list template."]
2698
+ writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
2699
+ notes: ["type=1 list template. Create and edit both use the typed flow_page_template adapter."]
2636
2700
  },
2637
2701
  "filter-template": {
2638
2702
  capability: "config.filter_template",
@@ -2640,12 +2704,16 @@ var CONFIG_DOMAINS = {
2640
2704
  exportStatus: "supported",
2641
2705
  buildStatus: "supported",
2642
2706
  submitStatus: "supported",
2707
+ createPath: "/flow_page_template",
2708
+ createMethod: "POST",
2709
+ deletePath: (id) => `/flow_page_template/${id}`,
2710
+ deleteMethod: "DELETE",
2643
2711
  submitPath: (id) => `/flow_page_template/${id}`,
2644
2712
  submitMethod: "PUT",
2645
2713
  expectedType: 3,
2646
2714
  readEndpoints: ["GET /api/flow_page_template/:id?skip_i18n=true"],
2647
- writeEndpoints: ["PUT /api/flow_page_template/:id"],
2648
- notes: ["type=3 filter template."]
2715
+ writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
2716
+ notes: ["type=3 filter template. Create and edit both use the typed flow_page_template adapter."]
2649
2717
  },
2650
2718
  "project-detail-template": {
2651
2719
  capability: "config.project_detail_template",
@@ -2653,12 +2721,16 @@ var CONFIG_DOMAINS = {
2653
2721
  exportStatus: "supported",
2654
2722
  buildStatus: "supported",
2655
2723
  submitStatus: "supported",
2724
+ createPath: "/flow_page_template",
2725
+ createMethod: "POST",
2726
+ deletePath: (id) => `/flow_page_template/${id}`,
2727
+ deleteMethod: "DELETE",
2656
2728
  submitPath: (id) => `/flow_page_template/${id}`,
2657
2729
  submitMethod: "PUT",
2658
2730
  expectedType: 2,
2659
2731
  readEndpoints: ["GET /api/flow_page_template/:id?type=2&create=&skip_i18n=true"],
2660
- writeEndpoints: ["PUT /api/flow_page_template/:id"],
2661
- notes: ["type=2 project detail template; activate/delete remain domain-specific operations."]
2732
+ writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
2733
+ notes: ["type=2 project detail template. Create and edit both use the typed flow_page_template adapter; activate/delete remain domain-specific operations."]
2662
2734
  },
2663
2735
  "console-template": {
2664
2736
  capability: "config.console_template",
@@ -2666,12 +2738,16 @@ var CONFIG_DOMAINS = {
2666
2738
  exportStatus: "supported",
2667
2739
  buildStatus: "supported",
2668
2740
  submitStatus: "supported",
2741
+ createPath: "/flow_page_template",
2742
+ createMethod: "POST",
2743
+ deletePath: (id) => `/flow_page_template/${id}`,
2744
+ deleteMethod: "DELETE",
2669
2745
  submitPath: (id) => `/flow_page_template/${id}`,
2670
2746
  submitMethod: "PUT",
2671
2747
  expectedType: 4,
2672
2748
  readEndpoints: ["GET /api/flow_page_template/:id?skip_i18n=true"],
2673
- writeEndpoints: ["PUT /api/flow_page_template/:id"],
2674
- notes: ["type=4 console template; this is not /api/configuration."]
2749
+ writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
2750
+ notes: ["type=4 console template; this is not /api/configuration. Create and edit both use the typed flow_page_template adapter."]
2675
2751
  },
2676
2752
  dataset: {
2677
2753
  capability: "config.dataset",
@@ -2679,11 +2755,15 @@ var CONFIG_DOMAINS = {
2679
2755
  exportStatus: "supported",
2680
2756
  buildStatus: "supported",
2681
2757
  submitStatus: "supported",
2758
+ createPath: "/data_set",
2759
+ createMethod: "POST",
2760
+ deletePath: (id) => `/data_set/${id}`,
2761
+ deleteMethod: "DELETE",
2682
2762
  submitPath: (id) => `/data_set/relationFields/${id}`,
2683
2763
  submitMethod: "POST",
2684
2764
  readEndpoints: ["GET /api/data_set/:id", "POST /api/data_set/list"],
2685
- writeEndpoints: ["POST /api/data_set/relationFields/:id"],
2686
- notes: ["Edit submit updates dataset basics and selected field relations through the huanpingtong API-Key proxy. Create, publish, pause, cancel-refresh, and index refresh remain blocked until those workflows have dedicated adapters."]
2765
+ writeEndpoints: ["POST /api/data_set", "POST /api/data_set/relationFields/:id", "DELETE /api/data_set/:id"],
2766
+ notes: ["Create posts a new dataset through the huanpingtong API-Key proxy. Edit submit updates dataset basics and selected field relations. Publish, pause, cancel-refresh, and index refresh remain separate lifecycle operations."]
2687
2767
  },
2688
2768
  "dataset-field": {
2689
2769
  capability: "config.dataset_field",
@@ -2691,28 +2771,35 @@ var CONFIG_DOMAINS = {
2691
2771
  exportStatus: "supported",
2692
2772
  buildStatus: "supported",
2693
2773
  submitStatus: "supported",
2774
+ createPath: "/data_set_field",
2775
+ createMethod: "POST",
2776
+ deletePath: (id) => `/data_set_field/${id}`,
2777
+ deleteMethod: "DELETE",
2694
2778
  submitPath: (id) => `/data_set_field/${id}`,
2695
2779
  submitMethod: "PUT",
2696
2780
  readEndpoints: ["GET /api/data_set_field/:id", "GET /api/data_set_field/getBatchByFlow"],
2697
- writeEndpoints: ["PUT /api/data_set_field/:id"],
2698
- notes: ["Edit submit updates one dataset field through the huanpingtong API-Key proxy. Create/delete remain blocked until those workflows have dedicated adapters and list checks."]
2781
+ writeEndpoints: ["POST /api/data_set_field", "PUT /api/data_set_field/:id", "DELETE /api/data_set_field/:id"],
2782
+ notes: ["Create, edit, and delete one dataset field through the huanpingtong API-Key proxy."]
2699
2783
  },
2700
2784
  "api-platform": {
2701
2785
  capability: "config.api_platform",
2702
2786
  exportStatus: "supported",
2703
2787
  buildStatus: "supported",
2704
2788
  submitStatus: "supported",
2789
+ deleteMethod: "DELETE",
2705
2790
  readEndpoints: ["GET /api/api_platform/by_key/:key", "GET /api/api_platform_instance/:id", "GET /api/api_platform_instance?api_platform_guid=:guid", "GET /api/api_proxy/:id", "GET /api/api_proxy?api_platform_guid=:guid", "GET /api/api_proxy_entity_binding?q_proxy_guid=:guid&q_direction=response"],
2706
- writeEndpoints: ["PUT /api/api_platform/:id", "PUT /api/api_platform_instance/:id", "PUT /api/api_proxy/:id", "PUT /api/api_proxy_entity_binding/:id", "POST /api/api_platform", "POST /api/api_platform_instance", "POST /api/api_proxy", "POST /api/api_proxy_entity_binding"],
2707
- notes: ["API platform config is layered. Export id format: platform:<platform_key>, instance:<id>, or api:<id>. Submit supports create/edit operation plans for platform, instance, API, and optional response binding."]
2791
+ writeEndpoints: ["PUT /api/api_platform/:id", "PUT /api/api_platform_instance/:id", "PUT /api/api_proxy/:id", "PUT /api/api_proxy_entity_binding/:id", "POST /api/api_platform", "POST /api/api_platform_instance", "POST /api/api_proxy", "POST /api/api_proxy_entity_binding", "DELETE /api/api_platform/:id", "DELETE /api/api_platform_instance/:id", "DELETE /api/api_proxy/:id", "DELETE /api/api_proxy_entity_binding/:id"],
2792
+ notes: ["API platform config is layered. Export id format: platform:<platform_key>, instance:<id>, api:<id>, or binding:<id>. Submit supports create/edit operation plans for platform, instance, API, and optional response binding."]
2708
2793
  },
2709
2794
  role: {
2710
2795
  capability: "config.role",
2711
2796
  exportStatus: "supported",
2712
2797
  buildStatus: "supported",
2713
2798
  submitStatus: "supported",
2799
+ deletePath: (id) => `/role/${id}`,
2800
+ deleteMethod: "DELETE",
2714
2801
  readEndpoints: ["GET /api/role?page=1&page_size=1000&sort=-id", "GET /api/point/point_list", "GET /api/user_role?role_id=:id", "GET /api/workspace?page_size=10000", "POST /api/flow/list/lightweight?page_size=1000"],
2715
- writeEndpoints: ["POST /api/role", "PUT /api/role/:id", "POST/PUT/DELETE /api/point", "POST/DELETE /api/user_role"],
2802
+ writeEndpoints: ["POST /api/role", "PUT /api/role/:id", "DELETE /api/role/:id", "POST/PUT/DELETE /api/point", "POST/DELETE /api/user_role"],
2716
2803
  notes: ["Role submit executes point operations, role create/update, then member operations with role_id injection."]
2717
2804
  },
2718
2805
  "nav-config": {
@@ -2721,22 +2808,30 @@ var CONFIG_DOMAINS = {
2721
2808
  buildStatus: "supported",
2722
2809
  submitStatus: "supported",
2723
2810
  readEndpoints: ["GET /api/configuration?q_type=:type&is_default_action=1&page=1&page_size=10000", "GET /api/point/point_list", "GET /api/group/sub_groups"],
2724
- writeEndpoints: ["PUT /api/configuration/:id?is_default_action=1", "POST /api/configuration?is_default_action=1"],
2811
+ writeEndpoints: ["PUT /api/configuration/:id?is_default_action=1", "POST /api/configuration?is_default_action=1", "DELETE /api/configuration/:id?is_default_action=1"],
2725
2812
  notes: ["Nav config is four configuration records (navmenu/shortcut/navmenu_mobile/shortcut_mobile). Export id is the workspace key. Submit writes all four records as an operation plan."]
2726
2813
  }
2727
2814
  };
2728
2815
  var CONFIG_SUBMIT_UNSUPPORTED_MESSAGE = "Typed config build/submit adapters are not implemented for this domain yet. Stop before remote writes and use the matching editor Skill verified scripts until bpmax-cli adds a domain-specific adapter.";
2729
2816
  function configAdapterMatrix() {
2730
- return Object.entries(CONFIG_DOMAINS).map(([domain, definition]) => ({
2731
- domain,
2732
- capability_prefix: definition.capability,
2733
- export_status: definition.exportStatus,
2734
- build_status: definition.buildStatus,
2735
- submit_status: definition.submitStatus,
2736
- read_endpoints: definition.readEndpoints,
2737
- write_endpoints: definition.writeEndpoints,
2738
- notes: definition.notes
2739
- }));
2817
+ return Object.entries(CONFIG_DOMAINS).map(([domain, definition]) => {
2818
+ const supportsCreate = Boolean(definition.createPath) || ["flow-template", "api-platform", "role", "nav-config"].includes(domain);
2819
+ const supportsDelete = Boolean(definition.deletePath) || ["workspace-flow", "api-platform", "nav-config"].includes(domain);
2820
+ return {
2821
+ domain,
2822
+ capability_prefix: definition.capability,
2823
+ export_status: definition.exportStatus,
2824
+ create_status: supportsCreate ? "supported" : "blocked",
2825
+ build_status: definition.buildStatus,
2826
+ submit_status: definition.submitStatus,
2827
+ delete_status: supportsDelete ? "supported" : "blocked",
2828
+ create_capability: supportsCreate ? `${definition.capability}.create` : null,
2829
+ delete_capability: supportsDelete ? `${definition.capability}.delete` : null,
2830
+ read_endpoints: definition.readEndpoints,
2831
+ write_endpoints: definition.writeEndpoints,
2832
+ notes: definition.notes
2833
+ };
2834
+ });
2740
2835
  }
2741
2836
  function hashJson(value) {
2742
2837
  return createHash3("sha256").update(JSON.stringify(value)).digest("hex");
@@ -2914,7 +3009,7 @@ function lintDatasetFieldWork(value, errors) {
2914
3009
  }
2915
3010
  function isFlowTemplateWork(value) {
2916
3011
  const data = value.data;
2917
- return isRecord3(data) && (Array.isArray(data.nodes) || Array.isArray(data.periods) || Object.prototype.hasOwnProperty.call(value, "flow_type") || Object.prototype.hasOwnProperty.call(value, "flowType"));
3012
+ return isRecord3(data) && (Array.isArray(data.nodes) || Array.isArray(data.periods) || value.mode === "create" || Object.prototype.hasOwnProperty.call(value, "flow_type") || Object.prototype.hasOwnProperty.call(value, "flowType"));
2918
3013
  }
2919
3014
  function flowTemplateMainFlowTypeError(flowType) {
2920
3015
  if (typeof flowType !== "string" || !flowType.trim()) {
@@ -2952,6 +3047,102 @@ function validateFlowTemplateIdentityStandard(id, payload) {
2952
3047
  key: payload?.key ?? payload?.flow_key ?? payload?.flowKey ?? ""
2953
3048
  });
2954
3049
  }
3050
+ var FORM_DRIVEN_CREATE_HIDE_FIELDS = ["project.name", "project.brief", "project.plan_end_time"];
3051
+ function hasConfiguredFormTemplate(meta) {
3052
+ const value = meta.form_template ?? meta.formTemplate;
3053
+ return value !== void 0 && value !== null && String(value).trim() !== "" && String(value).trim() !== "0";
3054
+ }
3055
+ function hasConfiguredFlowTemplateFormSource(value, meta) {
3056
+ return hasConfiguredFormTemplate(meta) || !isEmptyTemplateReference(value.meta_form_id);
3057
+ }
3058
+ function validateFlowTemplateFormDrivenCreateBaseline(value, errors, options = {}) {
3059
+ const data = isRecord3(value.data) ? value.data : {};
3060
+ const meta = isRecord3(data.meta) ? data.meta : {};
3061
+ if (!options.force && !hasConfiguredFlowTemplateFormSource(value, meta)) {
3062
+ return;
3063
+ }
3064
+ const context = options.context || "flow-template create";
3065
+ const missing = [];
3066
+ const hideFields = Array.isArray(meta.hide_fields) ? meta.hide_fields.map(String) : [];
3067
+ for (const field of FORM_DRIVEN_CREATE_HIDE_FIELDS) {
3068
+ if (!hideFields.includes(field)) {
3069
+ missing.push(`data.meta.hide_fields must include ${field}`);
3070
+ }
3071
+ }
3072
+ if (meta.use_template_project_name !== true) {
3073
+ missing.push("data.meta.use_template_project_name must be true");
3074
+ }
3075
+ if (typeof meta.project_name_template !== "string" || !meta.project_name_template.trim()) {
3076
+ missing.push("data.meta.project_name_template must be a non-empty string");
3077
+ }
3078
+ if (missing.length === 0) {
3079
+ return;
3080
+ }
3081
+ const message = `${context} for form-driven project creation requires default system-field hiding and a project name template: ${missing.join("; ")}.`;
3082
+ if (errors) {
3083
+ errors.push(message);
3084
+ return;
3085
+ }
3086
+ throw new Error(message);
3087
+ }
3088
+ function isEmptyTemplateReference(value) {
3089
+ return value === void 0 || value === null || value === "" || value === 0 || value === "0";
3090
+ }
3091
+ function isRemoteNumericTemplateId(value) {
3092
+ if (typeof value === "number") {
3093
+ return Number.isInteger(value) && Number.isFinite(value) && value > 0;
3094
+ }
3095
+ if (typeof value === "string") {
3096
+ return /^[1-9]\d*$/.test(value.trim());
3097
+ }
3098
+ return false;
3099
+ }
3100
+ function addFlowTemplateRemoteIdError(errors, pathName, value) {
3101
+ errors.push(
3102
+ `${pathName} must be a current-environment remote numeric id; got ${JSON.stringify(value)}. Do not write local uuid or directory references into flow-template payloads.`
3103
+ );
3104
+ }
3105
+ function validateFlowTemplateRemoteTemplateRefs(value, errors) {
3106
+ const nextErrors = [];
3107
+ const data = isRecord3(value.data) ? value.data : {};
3108
+ const meta = isRecord3(data.meta) ? data.meta : {};
3109
+ const metaRefs = [
3110
+ ["meta_form_id", value.meta_form_id],
3111
+ ["data.meta.form_template", meta.form_template],
3112
+ ["data.meta.table_list_template", meta.table_list_template],
3113
+ ["data.meta.table_filter_template", meta.table_filter_template],
3114
+ ["data.meta.step_detail_id", meta.step_detail_id]
3115
+ ];
3116
+ for (const [pathName, refValue] of metaRefs) {
3117
+ if (!isEmptyTemplateReference(refValue) && !isRemoteNumericTemplateId(refValue)) {
3118
+ addFlowTemplateRemoteIdError(nextErrors, pathName, refValue);
3119
+ }
3120
+ }
3121
+ const nodes = Array.isArray(data.nodes) ? data.nodes : [];
3122
+ nodes.forEach((node, index) => {
3123
+ if (!isRecord3(node)) {
3124
+ return;
3125
+ }
3126
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
3127
+ const nodeRefs = [
3128
+ [`data.nodes[${index}].form_template (${nodeName})`, node.form_template],
3129
+ [`data.nodes[${index}].step_detail_id (${nodeName})`, node.step_detail_id]
3130
+ ];
3131
+ for (const [pathName, refValue] of nodeRefs) {
3132
+ if (!isEmptyTemplateReference(refValue) && !isRemoteNumericTemplateId(refValue)) {
3133
+ addFlowTemplateRemoteIdError(nextErrors, pathName, refValue);
3134
+ }
3135
+ }
3136
+ });
3137
+ if (!nextErrors.length) {
3138
+ return;
3139
+ }
3140
+ if (errors) {
3141
+ errors.push(...nextErrors);
3142
+ return;
3143
+ }
3144
+ throw new Error(`flow-template online template reference gate failed: ${nextErrors.join("; ")}`);
3145
+ }
2955
3146
  function lintTemplateFieldReferences(value, errors) {
2956
3147
  const content = typeof value.content === "string" ? (() => {
2957
3148
  try {
@@ -3076,6 +3267,7 @@ function normalizeFlowTemplatePayload(work) {
3076
3267
  meta.form_template = work.meta_form_id;
3077
3268
  }
3078
3269
  data.meta = meta;
3270
+ validateFlowTemplateRemoteTemplateRefs({ ...work, data });
3079
3271
  const payload = pickDefined(work, [
3080
3272
  "name",
3081
3273
  "flow_type",
@@ -3128,8 +3320,8 @@ function buildWorkspaceFlowSubmitPayload(work) {
3128
3320
  }
3129
3321
  function normalizeDatasetPayload(work) {
3130
3322
  const mode = work.mode;
3131
- if (mode !== void 0 && mode !== "edit") {
3132
- throw new Error("dataset typed adapter currently supports edit mode only. Create/publish/pause/cancel-refresh require dedicated adapters.");
3323
+ if (mode !== void 0 && mode !== "edit" && mode !== "create") {
3324
+ throw new Error("dataset typed adapter supports mode edit or create. Publish/pause/cancel-refresh require dedicated lifecycle commands.");
3133
3325
  }
3134
3326
  const basic = isRecord3(work.basic) ? work.basic : work;
3135
3327
  const scripts = isRecord3(work.scripts) ? work.scripts : work;
@@ -3163,8 +3355,8 @@ function normalizeDatasetPayload(work) {
3163
3355
  }
3164
3356
  function normalizeDatasetFieldPayload(work) {
3165
3357
  const mode = work.mode;
3166
- if (mode !== void 0 && mode !== "edit") {
3167
- throw new Error("dataset-field typed adapter currently supports edit mode only. Create/delete require dedicated adapters.");
3358
+ if (mode !== void 0 && mode !== "edit" && mode !== "create") {
3359
+ throw new Error("dataset-field typed adapter supports mode edit or create. Delete requires a dedicated adapter.");
3168
3360
  }
3169
3361
  const source = isRecord3(work.source) ? work.source : work;
3170
3362
  const payload = {
@@ -3629,6 +3821,13 @@ function parseApiPlatformIdentity(id) {
3629
3821
  }
3630
3822
  return { layer: "api", value };
3631
3823
  }
3824
+ if (trimmed.startsWith("binding:")) {
3825
+ const value = trimmed.slice("binding:".length).trim();
3826
+ if (!value) {
3827
+ throw new Error("api-platform binding id must include id.");
3828
+ }
3829
+ return { layer: "binding", value };
3830
+ }
3632
3831
  return { layer: "platform", value: trimmed };
3633
3832
  }
3634
3833
  function firstRecord(value) {
@@ -4088,11 +4287,89 @@ function responseFlowType(response) {
4088
4287
  }
4089
4288
  return flowType;
4090
4289
  }
4290
+ function operationMethod(value) {
4291
+ return isRecord3(value) && typeof value.method === "string" ? value.method.toUpperCase() : "";
4292
+ }
4293
+ function aggregatePayloadHasNonCreateOperations(domain, payload) {
4294
+ if (domain === "role") {
4295
+ return operationMethod(payload.role) !== "POST" || Array.isArray(payload.pointOps) && payload.pointOps.some((op) => operationMethod(op) !== "POST") || Array.isArray(payload.memberOps) && payload.memberOps.some((op) => operationMethod(op) !== "POST");
4296
+ }
4297
+ return Array.isArray(payload.operations) && payload.operations.some((op) => operationMethod(op) !== "POST");
4298
+ }
4299
+ function apiPlatformDeletePath(id) {
4300
+ const identity = parseApiPlatformIdentity(id);
4301
+ if (identity.layer === "platform") {
4302
+ if (/^\d+$/.test(identity.value)) {
4303
+ return `/api_platform/${identity.value}`;
4304
+ }
4305
+ throw new Error("api-platform delete for platform requires a numeric platform id. Use platform:<id>.");
4306
+ }
4307
+ if (identity.layer === "instance") {
4308
+ return `/api_platform_instance/${identity.value}`;
4309
+ }
4310
+ if (identity.layer === "api") {
4311
+ return `/api_proxy/${identity.value}`;
4312
+ }
4313
+ return `/api_proxy_entity_binding/${identity.value}`;
4314
+ }
4315
+ function parseWorkspaceFlowDeleteId(id, profile) {
4316
+ const [workspacePart = "", flowType = "", flowKey = ""] = id.split("|");
4317
+ const workspace = normalizeWorkspaceKey(workspacePart || profile.config.workspace || "");
4318
+ if (!workspace || !flowType) {
4319
+ throw new Error('workspace-flow delete id must be "<workspace>|<flow_type>|<flow_key>". Use an empty final flow_key for main flows.');
4320
+ }
4321
+ return { workspace, flowType, flowKey };
4322
+ }
4323
+ async function deleteWorkspaceFlowBinding(profile, id, confirm3) {
4324
+ const definition = CONFIG_DOMAINS["workspace-flow"];
4325
+ await ensureConfigCapability(profile, `${definition.capability}.delete`);
4326
+ await ensureConfigCapability(profile, `${definition.capability}.export`);
4327
+ const { workspace, flowType, flowKey } = parseWorkspaceFlowDeleteId(id, profile);
4328
+ const current = await readRemoteConfigDomain(profile, "workspace-flow", workspace, definition);
4329
+ const bindings = isRecord3(current) ? normalizeWorkspaceFlowItems(current.workspace_flow) : [];
4330
+ const nextBindings = bindings.filter(
4331
+ (item) => buildWorkspaceFlowBindingKey(item.flow_type, item.flow_key) !== buildWorkspaceFlowBindingKey(flowType, flowKey)
4332
+ );
4333
+ const expectedConfirm = `delete workspace-flow ${id}`;
4334
+ if (confirm3 !== expectedConfirm) {
4335
+ return {
4336
+ dry_run: true,
4337
+ domain: "workspace-flow",
4338
+ id,
4339
+ endpoint: "/workspace/workspace_flow",
4340
+ method: "PUT",
4341
+ params: { workspace },
4342
+ delete_binding: { flow_type: flowType, flow_key: flowKey },
4343
+ before_count: bindings.length,
4344
+ after_count: nextBindings.length,
4345
+ next: `Run again with --confirm "${expectedConfirm}" to delete.`
4346
+ };
4347
+ }
4348
+ const response = await apiRequest(
4349
+ createApiClient(profile),
4350
+ "PUT",
4351
+ "/workspace/workspace_flow",
4352
+ { data: { workspace_flow: nextBindings }, params: { workspace }, capability: `${definition.capability}.delete` }
4353
+ );
4354
+ const readback = await readRemoteConfigDomain(profile, "workspace-flow", workspace, definition);
4355
+ return {
4356
+ dry_run: false,
4357
+ domain: "workspace-flow",
4358
+ id,
4359
+ endpoint: "/workspace/workspace_flow",
4360
+ method: "PUT",
4361
+ response,
4362
+ readback_hash: hashJson(readback)
4363
+ };
4364
+ }
4091
4365
  async function submitRoleOperations(profile, id, submit) {
4092
4366
  const definition = CONFIG_DOMAINS.role;
4093
- const current = await collectRoleAggregate(profile, id);
4094
- if (hashJson(current.raw) !== submit.base_hash) {
4095
- throw new Error("Remote config changed after export. Re-export before submitting.");
4367
+ const createMode = isRecord3(submit.meta) && submit.meta.mode === "create";
4368
+ if (!createMode) {
4369
+ const current = await collectRoleAggregate(profile, id);
4370
+ if (hashJson(current.raw) !== submit.base_hash) {
4371
+ throw new Error("Remote config changed after export. Re-export before submitting.");
4372
+ }
4096
4373
  }
4097
4374
  const payload = submit.payload;
4098
4375
  if (!isRecord3(payload) || !isRecord3(payload.role)) {
@@ -4108,7 +4385,10 @@ async function submitRoleOperations(profile, id, submit) {
4108
4385
  client,
4109
4386
  op.method,
4110
4387
  op.path,
4111
- { data: op.body === null ? void 0 : op.body, capability: `${definition.capability}.submit` }
4388
+ {
4389
+ data: op.body === null ? void 0 : op.body,
4390
+ capability: op.method === "POST" ? `${definition.capability}.create` : op.method === "DELETE" ? `${definition.capability}.delete` : `${definition.capability}.submit`
4391
+ }
4112
4392
  ));
4113
4393
  }
4114
4394
  const roleMethod = String(payload.role.method || "");
@@ -4117,7 +4397,7 @@ async function submitRoleOperations(profile, id, submit) {
4117
4397
  client,
4118
4398
  roleMethod,
4119
4399
  rolePath,
4120
- { data: payload.role.body, capability: `${definition.capability}.submit` }
4400
+ { data: payload.role.body, capability: roleMethod === "POST" ? `${definition.capability}.create` : `${definition.capability}.submit` }
4121
4401
  );
4122
4402
  const resolvedRoleId = responseDataId(roleResponse) ?? payload.role.id ?? id;
4123
4403
  const memberResponses = [];
@@ -4136,7 +4416,10 @@ async function submitRoleOperations(profile, id, submit) {
4136
4416
  client,
4137
4417
  op.method,
4138
4418
  op.path,
4139
- { data: body, capability: `${definition.capability}.submit` }
4419
+ {
4420
+ data: body,
4421
+ capability: op.method === "POST" ? `${definition.capability}.create` : op.method === "DELETE" ? `${definition.capability}.delete` : `${definition.capability}.submit`
4422
+ }
4140
4423
  ));
4141
4424
  }
4142
4425
  return {
@@ -4147,7 +4430,7 @@ async function submitRoleOperations(profile, id, submit) {
4147
4430
  readback_hash: hashJson((await collectRoleAggregate(profile, String(resolvedRoleId))).raw)
4148
4431
  };
4149
4432
  }
4150
- async function submitOperationPlan(profile, capability, operations) {
4433
+ async function submitOperationPlan(profile, capabilityPrefix, operations) {
4151
4434
  if (!Array.isArray(operations)) {
4152
4435
  throw new Error("Config submit payload must contain operations array.");
4153
4436
  }
@@ -4157,14 +4440,17 @@ async function submitOperationPlan(profile, capability, operations) {
4157
4440
  if (!isRecord3(op) || typeof op.method !== "string" || typeof op.path !== "string") {
4158
4441
  throw new Error("Invalid config submit operation.");
4159
4442
  }
4160
- if (op.method !== "POST" && op.method !== "PUT") {
4443
+ if (op.method !== "POST" && op.method !== "PUT" && op.method !== "DELETE") {
4161
4444
  throw new Error(`Unsupported config submit operation method: ${op.method}.`);
4162
4445
  }
4163
4446
  responses.push(await apiRequest(
4164
4447
  client,
4165
4448
  op.method,
4166
4449
  op.path,
4167
- { data: op.payload, capability }
4450
+ {
4451
+ data: op.method === "DELETE" ? void 0 : op.payload,
4452
+ capability: op.method === "POST" ? `${capabilityPrefix}.create` : op.method === "DELETE" ? `${capabilityPrefix}.delete` : `${capabilityPrefix}.submit`
4453
+ }
4168
4454
  ));
4169
4455
  }
4170
4456
  return responses;
@@ -4174,7 +4460,13 @@ async function submitAggregateConfigDomain(profile, domain, id, submit) {
4174
4460
  if (!isRecord3(payload) || !Array.isArray(payload.operations)) {
4175
4461
  throw new Error(`${domain} submit payload must contain an operation plan.`);
4176
4462
  }
4177
- const responses = await submitOperationPlan(profile, `${CONFIG_DOMAINS[domain].capability}.submit`, payload.operations);
4463
+ const responses = await submitOperationPlan(profile, CONFIG_DOMAINS[domain].capability, payload.operations);
4464
+ if (isRecord3(submit.meta) && submit.meta.mode === "create") {
4465
+ return {
4466
+ operation_responses: responses,
4467
+ readback_hash: null
4468
+ };
4469
+ }
4178
4470
  const current = domain === "api-platform" ? await collectApiPlatformAggregate(profile, id) : await collectNavConfigAggregate(profile, id);
4179
4471
  return {
4180
4472
  operation_responses: responses,
@@ -4190,6 +4482,8 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
4190
4482
  if (!isRecord3(work)) {
4191
4483
  throw new Error("flow-template create requires a work JSON object.");
4192
4484
  }
4485
+ validateFlowTemplateRemoteTemplateRefs(work);
4486
+ validateFlowTemplateFormDrivenCreateBaseline(work, void 0, { context: "flow-template create" });
4193
4487
  const createShell = {
4194
4488
  name: String(work.name || ""),
4195
4489
  category: work.category || "system",
@@ -4300,6 +4594,11 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
4300
4594
  }
4301
4595
  const formPayload = buildDomainSubmitPayload("form-template", formWork);
4302
4596
  const flowWorkRecord = isRecord3(flowWork) ? flowWork : {};
4597
+ validateFlowTemplateRemoteTemplateRefs(flowWorkRecord);
4598
+ validateFlowTemplateFormDrivenCreateBaseline(flowWorkRecord, void 0, {
4599
+ force: true,
4600
+ context: "flow-app create"
4601
+ });
4303
4602
  const flowShell = {
4304
4603
  name: String(flowWorkRecord.name || name),
4305
4604
  category: flowWorkRecord.category || "system",
@@ -4614,7 +4913,13 @@ async function lintConfigWorkFile(file) {
4614
4913
  lintTemplateFieldReferences(value, errors);
4615
4914
  }
4616
4915
  if (isFlowTemplateWork(value)) {
4617
- validateFlowTemplateStandardFlowType(value, errors);
4916
+ const flowWork = value;
4917
+ validateFlowTemplateRemoteTemplateRefs(flowWork, errors);
4918
+ if (flowWork.mode === "create") {
4919
+ validateFlowTemplateFormDrivenCreateBaseline(flowWork, errors, { context: "flow-template create" });
4920
+ } else {
4921
+ validateFlowTemplateStandardFlowType(flowWork, errors);
4922
+ }
4618
4923
  }
4619
4924
  }
4620
4925
  return {
@@ -4631,7 +4936,6 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
4631
4936
  if (definition.submitStatus !== "supported") {
4632
4937
  throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
4633
4938
  }
4634
- await ensureConfigCapability(profile, `${definition.capability}.submit`);
4635
4939
  await ensureConfigCapability(profile, `${definition.capability}.export`);
4636
4940
  const submit2 = await readJsonFile(submitFile);
4637
4941
  if (!isRecord3(submit2) || submit2.domain !== domain || !isRecord3(submit2.payload)) {
@@ -4650,6 +4954,8 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
4650
4954
  if (meta2.profile !== profile.name) {
4651
4955
  throw new Error(`Config submit metadata profile mismatch. Expected ${profile.name}, got ${String(meta2.profile)}.`);
4652
4956
  }
4957
+ const createMode = meta2.mode === "create";
4958
+ await ensureConfigCapability(profile, `${definition.capability}.${createMode ? "create" : "submit"}`);
4653
4959
  const workspace = normalizeWorkspaceKey(String(submit2.payload.workspace || id));
4654
4960
  const metaWorkspace = normalizeWorkspaceKey(String(meta2.workspace || meta2.id || ""));
4655
4961
  if (metaWorkspace && metaWorkspace !== workspace) {
@@ -4680,7 +4986,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
4680
4986
  client2,
4681
4987
  "PUT",
4682
4988
  endpoint2,
4683
- { data: submitPayload2, params: { workspace }, capability: `${definition.capability}.submit` }
4989
+ { data: submitPayload2, params: { workspace }, capability: `${definition.capability}.${createMode ? "create" : "submit"}` }
4684
4990
  );
4685
4991
  const readback2 = await readRemoteConfigDomain(profile, domain, workspace, definition);
4686
4992
  const bindings = isRecord3(readback2) ? normalizeWorkspaceFlowItems(readback2.workspace_flow) : [];
@@ -4708,8 +5014,6 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
4708
5014
  if (definition.submitStatus !== "supported") {
4709
5015
  throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
4710
5016
  }
4711
- await ensureConfigCapability(profile, `${definition.capability}.submit`);
4712
- await ensureConfigCapability(profile, `${definition.capability}.export`);
4713
5017
  const submit2 = await readJsonFile(submitFile);
4714
5018
  if (!isRecord3(submit2) || submit2.domain !== domain || !isRecord3(submit2.payload)) {
4715
5019
  throw new Error("Config submit requires a payload produced by `bpmax-cli config <domain> build`.");
@@ -4730,10 +5034,22 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
4730
5034
  if (meta2.workspace !== profile.config.workspace) {
4731
5035
  throw new Error(`Config submit metadata workspace mismatch. Expected ${profile.config.workspace}, got ${String(meta2.workspace)}.`);
4732
5036
  }
5037
+ const createMode = meta2.mode === "create";
5038
+ if (createMode) {
5039
+ await ensureConfigCapability(profile, `${definition.capability}.create`);
5040
+ if (aggregatePayloadHasNonCreateOperations(domain, submit2.payload)) {
5041
+ await ensureConfigCapability(profile, `${definition.capability}.submit`);
5042
+ }
5043
+ } else {
5044
+ await ensureConfigCapability(profile, `${definition.capability}.submit`);
5045
+ await ensureConfigCapability(profile, `${definition.capability}.export`);
5046
+ }
4733
5047
  const expectedConfirm2 = `submit ${domain} ${id}`;
4734
- const current2 = domain === "role" ? await collectRoleAggregate(profile, id) : domain === "api-platform" ? await collectApiPlatformAggregate(profile, id) : await collectNavConfigAggregate(profile, id);
4735
- if (hashJson(current2.raw) !== submit2.base_hash) {
4736
- throw new Error("Remote config changed after export. Re-export before submitting.");
5048
+ if (!createMode) {
5049
+ const current2 = domain === "role" ? await collectRoleAggregate(profile, id) : domain === "api-platform" ? await collectApiPlatformAggregate(profile, id) : await collectNavConfigAggregate(profile, id);
5050
+ if (hashJson(current2.raw) !== submit2.base_hash) {
5051
+ throw new Error("Remote config changed after export. Re-export before submitting.");
5052
+ }
4737
5053
  }
4738
5054
  if (confirm3 !== expectedConfirm2) {
4739
5055
  return {
@@ -4756,8 +5072,6 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
4756
5072
  if (definition.submitStatus !== "supported" || !definition.submitPath || !definition.submitMethod) {
4757
5073
  throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
4758
5074
  }
4759
- await ensureConfigCapability(profile, `${definition.capability}.submit`);
4760
- await ensureConfigCapability(profile, `${definition.capability}.export`);
4761
5075
  const submit = await readJsonFile(submitFile);
4762
5076
  if (!isRecord3(submit) || submit.domain !== domain || !isRecord3(submit.payload)) {
4763
5077
  throw new Error("Config submit requires a payload produced by `bpmax-cli config <domain> build`.");
@@ -4778,11 +5092,59 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
4778
5092
  if (meta.workspace !== profile.config.workspace) {
4779
5093
  throw new Error(`Config submit metadata workspace mismatch. Expected ${profile.config.workspace}, got ${String(meta.workspace)}.`);
4780
5094
  }
5095
+ const submitMode = isRecord3(meta) ? meta.mode : void 0;
5096
+ if (submitMode === "create" && domain !== "form-template") {
5097
+ if (!definition.createPath || !definition.createMethod) {
5098
+ throw new Error(`${domain} create is not implemented in the typed adapter.`);
5099
+ }
5100
+ await ensureConfigCapability(profile, `${definition.capability}.create`);
5101
+ const expectedConfirm2 = `submit ${domain} ${id}`;
5102
+ if (confirm3 !== expectedConfirm2) {
5103
+ return {
5104
+ dry_run: true,
5105
+ domain,
5106
+ id,
5107
+ endpoint: definition.createPath,
5108
+ method: definition.createMethod,
5109
+ payload: submit.payload,
5110
+ next: `Run again with --confirm "${expectedConfirm2}" to submit.`
5111
+ };
5112
+ }
5113
+ const client2 = createApiClient(profile);
5114
+ const response2 = await apiRequest(
5115
+ client2,
5116
+ definition.createMethod,
5117
+ definition.createPath,
5118
+ { data: submit.payload, capability: `${definition.capability}.create` }
5119
+ );
5120
+ const createdId = responseDataId(response2);
5121
+ let readbackHash = null;
5122
+ if (createdId !== void 0 && createdId !== null && createdId !== "" && definition.exportPath) {
5123
+ try {
5124
+ await ensureConfigCapability(profile, `${definition.capability}.export`);
5125
+ readbackHash = hashJson(await readRemoteConfigDomain(profile, domain, String(createdId), definition));
5126
+ } catch {
5127
+ readbackHash = null;
5128
+ }
5129
+ }
5130
+ return {
5131
+ dry_run: false,
5132
+ domain,
5133
+ id,
5134
+ created_id: createdId ?? null,
5135
+ endpoint: definition.createPath,
5136
+ method: definition.createMethod,
5137
+ response: response2,
5138
+ readback_hash: readbackHash
5139
+ };
5140
+ }
5141
+ await ensureConfigCapability(profile, `${definition.capability}.submit`);
5142
+ await ensureConfigCapability(profile, `${definition.capability}.export`);
4781
5143
  if (domain === "flow-template") {
5144
+ validateFlowTemplateRemoteTemplateRefs(submit.payload);
4782
5145
  validateFlowTemplateStandardFlowType(submit.payload);
4783
5146
  validateFlowTemplateIdentityStandard(id, submit.payload);
4784
5147
  }
4785
- const submitMode = isRecord3(meta) ? meta.mode : void 0;
4786
5148
  if (domain === "form-template" && submitMode === "create") {
4787
5149
  await ensureConfigCapability(profile, `${definition.capability}.create`);
4788
5150
  const expectedConfirm2 = `submit ${domain} ${id}`;
@@ -4915,6 +5277,73 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
4915
5277
  ...readback
4916
5278
  };
4917
5279
  }
5280
+ async function deleteConfigDomain(config, profile, domain, id, confirm3) {
5281
+ void config;
5282
+ const definition = CONFIG_DOMAINS[domain];
5283
+ if (domain === "workspace-flow") {
5284
+ return deleteWorkspaceFlowBinding(profile, id, confirm3);
5285
+ }
5286
+ await ensureConfigCapability(profile, `${definition.capability}.delete`);
5287
+ const expectedConfirm = `delete ${domain} ${id}`;
5288
+ const client = createApiClient(profile);
5289
+ if (domain === "nav-config") {
5290
+ await ensureConfigCapability(profile, `${definition.capability}.export`);
5291
+ const current = await collectNavConfigAggregate(profile, id);
5292
+ const configs = isRecord3(current.raw.configs) ? current.raw.configs : {};
5293
+ const operations = [];
5294
+ for (const type of NAV_CONFIG_TYPES) {
5295
+ const item = isRecord3(configs[type]) ? configs[type] : {};
5296
+ const itemId = item.id;
5297
+ if (itemId !== void 0 && itemId !== null && itemId !== "") {
5298
+ operations.push({ type, method: "DELETE", path: `/configuration/${itemId}?is_default_action=1`, id: itemId });
5299
+ }
5300
+ }
5301
+ if (confirm3 !== expectedConfirm) {
5302
+ return {
5303
+ dry_run: true,
5304
+ domain,
5305
+ id,
5306
+ operation_plan: { operations },
5307
+ next: `Run again with --confirm "${expectedConfirm}" to delete.`
5308
+ };
5309
+ }
5310
+ const responses = await submitOperationPlan(profile, definition.capability, operations);
5311
+ return {
5312
+ dry_run: false,
5313
+ domain,
5314
+ id,
5315
+ operation_responses: responses
5316
+ };
5317
+ }
5318
+ const endpoint = domain === "api-platform" ? apiPlatformDeletePath(id) : definition.deletePath?.(id);
5319
+ if (!endpoint || !definition.deleteMethod) {
5320
+ throw new Error(`${domain} delete is not implemented in the typed adapter.`);
5321
+ }
5322
+ if (confirm3 !== expectedConfirm) {
5323
+ return {
5324
+ dry_run: true,
5325
+ domain,
5326
+ id,
5327
+ endpoint,
5328
+ method: definition.deleteMethod,
5329
+ next: `Run again with --confirm "${expectedConfirm}" to delete.`
5330
+ };
5331
+ }
5332
+ const response = await apiRequest(
5333
+ client,
5334
+ definition.deleteMethod,
5335
+ endpoint,
5336
+ { capability: `${definition.capability}.delete` }
5337
+ );
5338
+ return {
5339
+ dry_run: false,
5340
+ domain,
5341
+ id,
5342
+ endpoint,
5343
+ method: definition.deleteMethod,
5344
+ response
5345
+ };
5346
+ }
4918
5347
 
4919
5348
  // src/core/config-workspace.ts
4920
5349
  import { mkdir as mkdir4, readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
@@ -5848,21 +6277,33 @@ function registerConfigCommands(program2) {
5848
6277
  });
5849
6278
  Object.keys(CONFIG_DOMAINS).forEach((domain) => {
5850
6279
  const domainCommand = config.command(domain).description(`Manage BPMAX ${domain} configuration`);
6280
+ const createCommand = domainCommand.command("create").description(domain === "flow-template" ? "Create a new main flow template through the typed adapter" : `Create a ${domain} config object through a verified typed adapter; dry-run unless --confirm is exact`).option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--publish-live", "For flow-template, publish the created flow to live after saving draft").option("--format <format>", "Output format", "pretty");
5851
6281
  if (domain === "flow-template") {
5852
- domainCommand.command("create").description("Create a new main flow template through the typed adapter").requiredOption("--work <file>", "Flow-template work JSON file").option("--profile <profile>", "Profile name").option("--publish-live", "Publish the created flow to live after saving draft").option("--confirm <text>", "Exact confirmation text").option("--format <format>", "Output format", "pretty").action(async (options) => {
5853
- const configData = await loadConfig();
5854
- const resolved = resolveProfile(configData, options.profile);
5855
- const result = await createFlowTemplateFromWork(
5856
- configData,
5857
- resolved,
5858
- options.work,
5859
- options.confirm,
5860
- { publishLive: Boolean(options.publishLive) }
5861
- );
5862
- await saveConfig(configData);
5863
- printResult(options.format, result);
5864
- });
6282
+ createCommand.requiredOption("--work <file>", "Flow-template work JSON file");
6283
+ } else {
6284
+ createCommand.requiredOption("--id <id>", "Create operation id used in payload metadata, for example create:<domain>").requiredOption("--payload <file>", "Create submit payload JSON file produced by build");
5865
6285
  }
6286
+ createCommand.action(async (options) => {
6287
+ const configData = await loadConfig();
6288
+ const resolved = resolveProfile(configData, options.profile);
6289
+ const result = domain === "flow-template" ? await createFlowTemplateFromWork(
6290
+ configData,
6291
+ resolved,
6292
+ String(options.work || ""),
6293
+ options.confirm,
6294
+ { publishLive: Boolean(options.publishLive) }
6295
+ ) : await submitConfigDomain(
6296
+ configData,
6297
+ resolved,
6298
+ domain,
6299
+ String(options.id || ""),
6300
+ String(options.payload || ""),
6301
+ options.confirm,
6302
+ { publishLive: Boolean(options.publishLive) }
6303
+ );
6304
+ await saveConfig(configData);
6305
+ printResult(options.format, result);
6306
+ });
5866
6307
  domainCommand.command("export").description(`Export remote ${domain} configuration into raw/work/meta files`).requiredOption("--id <id>", "Remote config id").option("--profile <profile>", "Profile name").option("--out <outDir>", "Output directory", `.codex/tmp/${domain}-editor`).option("--work-format <format>", "Work file format for supported domains: raw | structured", "raw").option("--format <format>", "Output format", "pretty").action(async (options) => {
5867
6308
  const configData = await loadConfig();
5868
6309
  const resolved = resolveProfile(configData, options.profile);
@@ -5915,6 +6356,19 @@ function registerConfigCommands(program2) {
5915
6356
  await saveConfig(configData);
5916
6357
  printResult(options.format, result);
5917
6358
  });
6359
+ domainCommand.command("delete").description(`Delete a ${domain} config object through a verified typed adapter; dry-run unless --confirm is exact`).requiredOption("--id <id>", "Remote config id").option("--profile <profile>", "Profile name").option("--confirm <text>", "Exact confirmation text").option("--format <format>", "Output format", "pretty").action(async (options) => {
6360
+ const configData = await loadConfig();
6361
+ const resolved = resolveProfile(configData, options.profile);
6362
+ const result = await deleteConfigDomain(
6363
+ configData,
6364
+ resolved,
6365
+ domain,
6366
+ options.id,
6367
+ options.confirm
6368
+ );
6369
+ await saveConfig(configData);
6370
+ printResult(options.format, result);
6371
+ });
5918
6372
  domainCommand.command("verify").description(`Read back a ${domain} config and optionally compare with an expected JSON file`).requiredOption("--id <id>", "Remote config id").option("--expect <file>", "Expected JSON file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "pretty").action(async (options) => {
5919
6373
  const configData = await loadConfig();
5920
6374
  const resolved = resolveProfile(configData, options.profile);
@@ -8075,30 +8529,52 @@ var schemaEntries = [
8075
8529
  { name: "config.init.workspace", description: "Create or update a local AGENTS.md BPMAX config guide.", bootstrap: true },
8076
8530
  { name: "config.form_template.export", description: "Export form template config.", method: "GET", path: "/api/form_template/:id" },
8077
8531
  { name: "config.form_template.create", description: "Create and publish a form template through a verified typed adapter.", method: "POST", path: "/api/form_template + /api/form_template/publish" },
8532
+ { name: "config.form_template.delete", description: "Delete a form template through a verified typed adapter.", method: "DELETE", path: "/api/form_template/:id" },
8078
8533
  { name: "config.form_template.submit", description: "Submit form template edits through a verified typed adapter.", method: "PUT/POST", path: "/api/form_template/:id + /api/form_template/publish" },
8079
8534
  { name: "config.flow_template.export", description: "Export flow template config when a verified draft-aware adapter is available.", method: "GET", path: "/api/flow?flow_type=:flow_type&key=:key&draft=1" },
8080
8535
  { name: "config.flow_template.create", description: "Create a platform-generated main flow shell through a verified typed adapter.", method: "POST", path: "/api/flow/flow_type" },
8536
+ { name: "config.flow_template.delete", description: "Delete a flow template by flow_type or key through a verified typed adapter.", method: "DELETE", path: "/api/flow?flow_type=:flow_type&key=:key" },
8081
8537
  { name: "config.flow_template.submit", description: "Submit flow template config when a verified draft-aware adapter is available.", method: "PUT", path: "/api/flow?flow_type=:flow_type&key=:key&publish=:publish" },
8082
8538
  { name: "config.workspace_flow.export", description: "Export workspace-bound flow relations.", method: "GET", path: "/api/workspace/by_key?key=:workspace" },
8539
+ { name: "config.workspace_flow.create", description: "Create one workspace-flow binding through the verified workspace-flow adapter.", method: "PUT", path: "/api/workspace/workspace_flow" },
8540
+ { name: "config.workspace_flow.delete", description: "Delete one workspace-flow binding through a typed adapter.", method: "PUT", path: "/api/workspace/workspace_flow" },
8083
8541
  { name: "config.workspace_flow.submit", description: "Submit workspace-bound flow relations through a verified typed adapter.", method: "PUT", path: "/api/workspace/workspace_flow" },
8084
8542
  { name: "config.flow_app.create", description: "Create form template, create flow template, bind form, and bind the flow to a workspace.", method: "POST/PUT", path: "/api/form_template + /api/flow/flow_type + /api/flow + /api/workspace/workspace_flow" },
8085
8543
  { name: "config.list_template.export", description: "Export list template config.", method: "GET", path: "/api/flow_page_template/:id?skip_i18n=true" },
8544
+ { name: "config.list_template.create", description: "Create list template config through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
8545
+ { name: "config.list_template.delete", description: "Delete list template config through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
8086
8546
  { name: "config.list_template.submit", description: "Submit list template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
8087
8547
  { name: "config.filter_template.export", description: "Export filter template config.", method: "GET", path: "/api/flow_page_template/:id?skip_i18n=true" },
8548
+ { name: "config.filter_template.create", description: "Create filter template config through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
8549
+ { name: "config.filter_template.delete", description: "Delete filter template config through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
8088
8550
  { name: "config.filter_template.submit", description: "Submit filter template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
8089
8551
  { name: "config.project_detail_template.export", description: "Export project detail template config.", method: "GET", path: "/api/flow_page_template/:id?type=2&create=&skip_i18n=true" },
8552
+ { name: "config.project_detail_template.create", description: "Create project detail template config through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
8553
+ { name: "config.project_detail_template.delete", description: "Delete project detail template config through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
8090
8554
  { name: "config.project_detail_template.submit", description: "Submit project detail template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
8091
8555
  { name: "config.console_template.export", description: "Export console template config.", method: "GET", path: "/api/flow_page_template/:id?skip_i18n=true" },
8556
+ { name: "config.console_template.create", description: "Create console template config through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
8557
+ { name: "config.console_template.delete", description: "Delete console template config through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
8092
8558
  { name: "config.console_template.submit", description: "Submit console template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
8093
8559
  { name: "config.dataset.export", description: "Export dataset config through huanpingtong API-key proxy.", method: "GET/POST", path: "/api/data_set/:id + /api/data_set/list" },
8560
+ { name: "config.dataset.create", description: "Create dataset config through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set" },
8561
+ { name: "config.dataset.delete", description: "Delete dataset config through the huanpingtong API-key proxy.", method: "DELETE", path: "/api/data_set/:id" },
8094
8562
  { name: "config.dataset.submit", description: "Submit dataset edit payloads through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set/relationFields/:id" },
8095
8563
  { name: "config.dataset_field.export", description: "Export dataset field config through huanpingtong API-key proxy.", method: "GET", path: "/api/data_set_field/:id + /api/data_set_field/getBatchByFlow" },
8564
+ { name: "config.dataset_field.create", description: "Create dataset field config through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set_field" },
8565
+ { name: "config.dataset_field.delete", description: "Delete dataset field config through the huanpingtong API-key proxy.", method: "DELETE", path: "/api/data_set_field/:id" },
8096
8566
  { name: "config.dataset_field.submit", description: "Submit dataset field edit payloads through the huanpingtong API-key proxy.", method: "PUT", path: "/api/data_set_field/:id" },
8097
8567
  { name: "config.api_platform.export", description: "Export API platform, instance, API proxy, and response binding config through a typed layered adapter.", method: "GET", path: "/api/api_platform/by_key/:key + /api/api_platform_instance/:id + /api/api_proxy/:id + /api/api_proxy_entity_binding" },
8568
+ { name: "config.api_platform.create", description: "Create API platform, instance, API proxy, or response binding through typed operation plans.", method: "POST", path: "/api/api_platform + /api/api_platform_instance + /api/api_proxy + /api/api_proxy_entity_binding" },
8569
+ { name: "config.api_platform.delete", description: "Delete API platform, instance, API proxy, or response binding through typed adapters.", method: "DELETE", path: "/api/api_platform/:id + /api/api_platform_instance/:id + /api/api_proxy/:id + /api/api_proxy_entity_binding/:id" },
8098
8570
  { name: "config.api_platform.submit", description: "Submit API platform layered operation plans through verified typed endpoints.", method: "POST/PUT", path: "/api/api_platform + /api/api_platform_instance + /api/api_proxy + /api/api_proxy_entity_binding" },
8099
8571
  { name: "config.role.export", description: "Export role, points, workspaces, flows, and members.", method: "GET", path: "/api/role + /api/point/point_list + /api/user_role + /api/workspace + /api/flow/list/lightweight" },
8572
+ { name: "config.role.create", description: "Create roles, custom points, and role members through typed operation plans.", method: "POST", path: "/api/role + /api/point + /api/user_role" },
8573
+ { name: "config.role.delete", description: "Delete roles, custom points, or role members through typed adapters.", method: "DELETE", path: "/api/role/:id + /api/point/:id + /api/user_role/:id" },
8100
8574
  { name: "config.role.submit", description: "Submit role operation plan through a verified typed adapter.", method: "POST/PUT/DELETE", path: "/api/role + /api/point + /api/user_role" },
8101
8575
  { name: "config.nav_config.export", description: "Export all workspace navigation config records.", method: "GET", path: "/api/configuration?q_type=:type&is_default_action=1" },
8576
+ { name: "config.nav_config.create", description: "Create workspace navigation config records through a typed operation plan.", method: "POST", path: "/api/configuration?is_default_action=1" },
8577
+ { name: "config.nav_config.delete", description: "Delete workspace navigation config records through a typed operation plan.", method: "DELETE", path: "/api/configuration/:id?is_default_action=1" },
8102
8578
  { name: "config.nav_config.submit", description: "Submit all workspace navigation config records through a typed operation plan.", method: "POST/PUT", path: "/api/configuration?is_default_action=1 + /api/configuration/:id?is_default_action=1" },
8103
8579
  { name: "config.repository.view", description: "View sysconfig repository environment details from BPMAX.", method: "GET", path: "/api/config_repository + /api/config_repository/:env" },
8104
8580
  { name: "config.repository.sync", description: "Run platform sysconfigdiff pullcommit/extract/pushcommit steps.", method: "POST", path: "/api/config_repository/:env?action=sync" },