bpmax-cli 0.2.1-beta.8 → 0.2.1-beta.9

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
@@ -469,7 +469,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
469
469
  // package.json
470
470
  var package_default = {
471
471
  name: "bpmax-cli",
472
- version: "0.2.1-beta.8",
472
+ version: "0.2.1-beta.9",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -4458,6 +4458,158 @@ function validateFlowTemplateStartConditionalJump(value, errors) {
4458
4458
  }
4459
4459
  throw new Error(`flow-template start conditional jump gate failed: ${nextErrors.join("; ")}`);
4460
4460
  }
4461
+ function isFlowTemplateEndpointTarget(value) {
4462
+ return /^-\d+$/.test(value.trim());
4463
+ }
4464
+ function isFlowTemplateSpecialStepTarget(value) {
4465
+ const normalized = value.trim();
4466
+ return normalized === "[source]" || normalized === "anyNode";
4467
+ }
4468
+ function isFlowTemplateBackSourceTarget(value) {
4469
+ return value.trim() === "[source]";
4470
+ }
4471
+ function isFlowTemplateConditionalTarget(value, conditionNames) {
4472
+ const match = value.trim().match(/^(.+)\[condition\]\d+$/);
4473
+ if (!match) {
4474
+ return false;
4475
+ }
4476
+ return conditionNames.has(match[1].trim());
4477
+ }
4478
+ function validateFlowTemplateActionTarget(errors, pathName, target, nodeIds, conditionNames, options = {}) {
4479
+ const normalizedTarget = target.trim();
4480
+ if (!normalizedTarget) {
4481
+ if (options.actionString) {
4482
+ errors.push(`${pathName} target step is required after "|"; use "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" or "\u6309\u94AE\u6587\u6848|\u6761\u4EF6\u540D[condition]0".`);
4483
+ } else {
4484
+ errors.push(`${pathName} target step is required; use a node id, -1, [source], anyNode, or \u6761\u4EF6\u540D[condition]0.`);
4485
+ }
4486
+ return;
4487
+ }
4488
+ const conditionalTargetAllowed = options.allowConditionalTarget !== false;
4489
+ const specialTargetAllowed = options.allowAnyNode === false ? isFlowTemplateBackSourceTarget(normalizedTarget) : isFlowTemplateSpecialStepTarget(normalizedTarget);
4490
+ if (!nodeIds.has(normalizedTarget) && !isFlowTemplateEndpointTarget(normalizedTarget) && !specialTargetAllowed && !(conditionalTargetAllowed && isFlowTemplateConditionalTarget(normalizedTarget, conditionNames))) {
4491
+ const allowedTargets = conditionalTargetAllowed ? "an existing data.nodes[].id, an endpoint like -1, [source], anyNode, or a condational_nodes reference like \u6761\u4EF6\u540D[condition]0" : options.allowAnyNode === false ? "an existing data.nodes[].id, an endpoint like -1, or [source]" : "an existing data.nodes[].id, an endpoint like -1, [source], or anyNode";
4492
+ errors.push(`${pathName} target (${normalizedTarget}) must be ${allowedTargets}.`);
4493
+ }
4494
+ }
4495
+ function validateFlowTemplateApproveActionShape(value, errors) {
4496
+ const nextErrors = [];
4497
+ const data = isRecord3(value.data) ? value.data : {};
4498
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4499
+ const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
4500
+ nodes.forEach((node, nodeIndex) => {
4501
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
4502
+ const conditionNames = /* @__PURE__ */ new Set();
4503
+ if (node.condational_nodes !== void 0 && node.condational_nodes !== null && node.condational_nodes !== "" && !Array.isArray(node.condational_nodes)) {
4504
+ nextErrors.push(`${nodeName}.condational_nodes must be an array of condition route objects.`);
4505
+ }
4506
+ const conditionalNodes = Array.isArray(node.condational_nodes) ? node.condational_nodes : [];
4507
+ conditionalNodes.forEach((conditionNode, conditionIndex) => {
4508
+ const conditionPath = `${nodeName}.condational_nodes[${conditionIndex}]`;
4509
+ if (!isRecord3(conditionNode)) {
4510
+ nextErrors.push(`${conditionPath} must be an object with name, result, condition_mode, and an index-returning condition script.`);
4511
+ return;
4512
+ }
4513
+ const conditionName = typeof conditionNode.name === "string" ? conditionNode.name.trim() : "";
4514
+ if (conditionName) {
4515
+ conditionNames.add(conditionName);
4516
+ } else {
4517
+ nextErrors.push(`${conditionPath}.name is required so approve_to_step/approve_actions can reference this condational_nodes entry.`);
4518
+ }
4519
+ const conditionMode = typeof conditionNode.condition_mode === "string" && conditionNode.condition_mode.trim() ? conditionNode.condition_mode.trim() : "code";
4520
+ if (conditionMode === "standard") {
4521
+ if (typeof conditionNode.standard_condition !== "string" || !conditionNode.standard_condition.trim()) {
4522
+ nextErrors.push(`${conditionPath}.standard_condition is required when condition_mode is standard; condition is ignored by the backend in this mode.`);
4523
+ }
4524
+ } else if (conditionMode === "code") {
4525
+ if (typeof conditionNode.condition !== "string" || !conditionNode.condition.trim()) {
4526
+ nextErrors.push(`${conditionPath}.condition is required when condition_mode is code or omitted; standard_condition is ignored by the backend in code mode.`);
4527
+ }
4528
+ } else {
4529
+ nextErrors.push(`${conditionPath}.condition_mode must be code or standard.`);
4530
+ }
4531
+ const conditionResult = conditionNode.result;
4532
+ const resultPath = `${conditionPath}.result`;
4533
+ if (!Array.isArray(conditionResult) || !conditionResult.length) {
4534
+ nextErrors.push(`${resultPath} must be a non-empty array of target node ids.`);
4535
+ return;
4536
+ }
4537
+ conditionResult.forEach((target, targetIndex) => {
4538
+ const targetPath = `${resultPath}[${targetIndex}]`;
4539
+ if (Array.isArray(target) || isRecord3(target) || target === void 0 || target === null) {
4540
+ nextErrors.push(`${targetPath} must be a target node id, endpoint like -1, or [source].`);
4541
+ return;
4542
+ }
4543
+ validateFlowTemplateActionTarget(
4544
+ nextErrors,
4545
+ targetPath,
4546
+ String(target),
4547
+ nodeIds,
4548
+ conditionNames,
4549
+ { allowConditionalTarget: false, allowAnyNode: false }
4550
+ );
4551
+ });
4552
+ });
4553
+ [
4554
+ ["approve_to_step", node.approve_to_step],
4555
+ ["approve_fail", node.approve_fail]
4556
+ ].forEach(([fieldName, fieldValue]) => {
4557
+ if (fieldValue === void 0 || fieldValue === null || fieldValue === "") {
4558
+ return;
4559
+ }
4560
+ if (Array.isArray(fieldValue) || isRecord3(fieldValue)) {
4561
+ nextErrors.push(`${nodeName}.${fieldName} must be a target node id, endpoint like -1, [source], anyNode, or \u6761\u4EF6\u540D[condition]0.`);
4562
+ return;
4563
+ }
4564
+ validateFlowTemplateActionTarget(nextErrors, `${nodeName}.${fieldName}`, String(fieldValue), nodeIds, conditionNames);
4565
+ });
4566
+ const actionGroups = [
4567
+ ["approve_actions", node.approve_actions],
4568
+ ["approve_fail_actions", node.approve_fail_actions]
4569
+ ];
4570
+ actionGroups.forEach(([fieldName, fieldValue]) => {
4571
+ if (fieldValue === void 0 || fieldValue === null || fieldValue === "") {
4572
+ return;
4573
+ }
4574
+ const pathPrefix = `${nodeName}.${fieldName}`;
4575
+ if (!Array.isArray(fieldValue)) {
4576
+ nextErrors.push(`${pathPrefix} must be an array of action strings.`);
4577
+ return;
4578
+ }
4579
+ fieldValue.forEach((action, actionIndex) => {
4580
+ const pathName = `${pathPrefix}[${actionIndex}]`;
4581
+ if (typeof action !== "string") {
4582
+ nextErrors.push(`${pathName} must be a string action in "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" format.`);
4583
+ return;
4584
+ }
4585
+ const parts = action.split("|");
4586
+ if (parts.length < 2) {
4587
+ const raw = action.trim();
4588
+ if (raw && (nodeIds.has(raw) || isFlowTemplateEndpointTarget(raw) || isFlowTemplateSpecialStepTarget(raw) || isFlowTemplateConditionalTarget(raw, conditionNames))) {
4589
+ nextErrors.push(`${pathName} is a bare target (${raw}); action strings must be "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID", not just a node id.`);
4590
+ } else {
4591
+ nextErrors.push(`${pathName} must contain "|" and use "\u6309\u94AE\u6587\u6848|\u76EE\u6807\u8282\u70B9ID" or "\u6309\u94AE\u6587\u6848|\u6761\u4EF6\u540D[condition]0".`);
4592
+ }
4593
+ return;
4594
+ }
4595
+ const label = parts[0].trim();
4596
+ const target = parts[1].trim();
4597
+ if (!label) {
4598
+ nextErrors.push(`${pathName} label is required before "|".`);
4599
+ }
4600
+ validateFlowTemplateActionTarget(nextErrors, pathName, target, nodeIds, conditionNames, { actionString: true });
4601
+ });
4602
+ });
4603
+ });
4604
+ if (!nextErrors.length) {
4605
+ return;
4606
+ }
4607
+ if (errors) {
4608
+ errors.push(...nextErrors);
4609
+ return;
4610
+ }
4611
+ throw new Error(`flow-template approve action gate failed: ${nextErrors.join("; ")}`);
4612
+ }
4461
4613
  function looksLikeParseEvalFunctionBody(script) {
4462
4614
  const text5 = script.trim();
4463
4615
  if (!text5) {
@@ -5133,6 +5285,7 @@ function normalizeFlowTemplatePayload(work) {
5133
5285
  validateFlowTemplateProjectAfterCreatePath({ ...work, data });
5134
5286
  validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
5135
5287
  validateFlowTemplateStartConditionalJump({ ...work, data });
5288
+ validateFlowTemplateApproveActionShape({ ...work, data });
5136
5289
  validateFlowTemplateCodeModeMessages({ ...work, data });
5137
5290
  validateFlowTemplateRuntimeScripts({ ...work, data });
5138
5291
  validateFlowTemplateFeishuChatPlugin({ ...work, data });
@@ -7009,6 +7162,7 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
7009
7162
  validateFlowTemplateProjectAfterCreatePath(work);
7010
7163
  validateFlowTemplateStandardPageCreateFormTemplate(work);
7011
7164
  validateFlowTemplateStartConditionalJump(work);
7165
+ validateFlowTemplateApproveActionShape(work);
7012
7166
  validateFlowTemplateCodeModeMessages(work);
7013
7167
  validateFlowTemplateRuntimeScripts(work);
7014
7168
  validateFlowTemplateFeishuChatPlugin(work);
@@ -7905,6 +8059,7 @@ async function lintConfigWorkFile(file, options = {}) {
7905
8059
  validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
7906
8060
  validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
7907
8061
  validateFlowTemplateStartConditionalJump(flowWork, errors);
8062
+ validateFlowTemplateApproveActionShape(flowWork, errors);
7908
8063
  validateFlowTemplateCodeModeMessages(flowWork, errors);
7909
8064
  validateFlowTemplateRuntimeScripts(flowWork, errors);
7910
8065
  validateFlowTemplateFeishuChatPlugin(flowWork, errors);
@@ -8258,6 +8413,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
8258
8413
  validateFlowTemplateProjectAfterCreatePath(submit.payload);
8259
8414
  validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
8260
8415
  validateFlowTemplateStartConditionalJump(submit.payload);
8416
+ validateFlowTemplateApproveActionShape(submit.payload);
8261
8417
  validateFlowTemplateCodeModeMessages(submit.payload);
8262
8418
  validateFlowTemplateRuntimeScripts(submit.payload);
8263
8419
  validateFlowTemplateFeishuChatPlugin(submit.payload);