bpmax-cli 0.2.1-beta.10 → 0.2.1-beta.11

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.10",
472
+ version: "0.2.1-beta.11",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -4610,6 +4610,178 @@ function validateFlowTemplateApproveActionShape(value, errors) {
4610
4610
  }
4611
4611
  throw new Error(`flow-template approve action gate failed: ${nextErrors.join("; ")}`);
4612
4612
  }
4613
+ function validateOptionalBoolean(errors, value, fieldName, pathName) {
4614
+ if (value[fieldName] !== void 0 && typeof value[fieldName] !== "boolean") {
4615
+ errors.push(`${pathName}.${fieldName} must be a boolean when provided.`);
4616
+ }
4617
+ }
4618
+ function flowTemplateNodeRequiresApproval(node) {
4619
+ if (node.approve_count_required === "all") {
4620
+ return true;
4621
+ }
4622
+ const approveCount = Number(node.approve_count_required ?? 0);
4623
+ return Number.isFinite(approveCount) && approveCount > 0;
4624
+ }
4625
+ function validateFlowTemplatePluginRejectionControl(value, errors) {
4626
+ const nextErrors = [];
4627
+ const data = isRecord3(value.data) ? value.data : {};
4628
+ const meta = isRecord3(data.meta) ? data.meta : {};
4629
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4630
+ nodes.forEach((node, nodeIndex) => {
4631
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
4632
+ const config = node.plugin_rejection_control;
4633
+ const pathName = `${nodeName}.plugin_rejection_control`;
4634
+ if (config === void 0 || config === null || config === "") {
4635
+ return;
4636
+ }
4637
+ if (!isRecord3(config)) {
4638
+ nextErrors.push(`${pathName} must be an object when configured.`);
4639
+ return;
4640
+ }
4641
+ validateOptionalBoolean(nextErrors, config, "enabled", pathName);
4642
+ validateOptionalBoolean(nextErrors, config, "disabled_form_validate", pathName);
4643
+ [
4644
+ "reject_to_pre",
4645
+ "reject_to_owner",
4646
+ "reject_to_specific_step",
4647
+ "reject_to_end",
4648
+ "review_default",
4649
+ "review_to_me",
4650
+ "review_to_all",
4651
+ "review_to_any_node"
4652
+ ].forEach((fieldName) => validateOptionalBoolean(nextErrors, config, fieldName, pathName));
4653
+ if (config.enabled !== true) {
4654
+ return;
4655
+ }
4656
+ if (typeof config.button_text !== "string" || !config.button_text.trim()) {
4657
+ nextErrors.push(`${pathName}.button_text is required when plugin rejection control is enabled.`);
4658
+ }
4659
+ if (!flowTemplateNodeRequiresApproval(node)) {
4660
+ nextErrors.push(`${pathName}.enabled requires an approval step with approve_count_required > 0 or "all"; the plugin replaces reject buttons on approval steps only.`);
4661
+ }
4662
+ const hasNativeRejectTarget = typeof node.approve_fail === "string" && node.approve_fail.trim() || Array.isArray(node.approve_fail_actions) && node.approve_fail_actions.length > 0;
4663
+ const hasPluginRejectMethod = config.reject_to_pre === true || config.reject_to_owner === true || config.reject_to_specific_step === true || config.reject_to_end === true;
4664
+ if (!hasNativeRejectTarget && !hasPluginRejectMethod) {
4665
+ nextErrors.push(
4666
+ `${pathName} must enable at least one reject method (reject_to_pre, reject_to_owner, reject_to_specific_step, reject_to_end) or keep a native approve_fail/approve_fail_actions target.`
4667
+ );
4668
+ }
4669
+ if (config.reject_to_owner === true && meta.allow_jump_start !== true && !hasNativeRejectTarget && config.reject_to_pre !== true && config.reject_to_specific_step !== true && config.reject_to_end !== true) {
4670
+ nextErrors.push(
4671
+ `${pathName}.reject_to_owner is the only configured reject method but requires data.meta.allow_jump_start = true; otherwise the runtime will not offer any usable plugin reject method.`
4672
+ );
4673
+ }
4674
+ });
4675
+ if (!nextErrors.length) {
4676
+ return;
4677
+ }
4678
+ if (errors) {
4679
+ errors.push(...nextErrors);
4680
+ return;
4681
+ }
4682
+ throw new Error(`flow-template plugin rejection control gate failed: ${nextErrors.join("; ")}`);
4683
+ }
4684
+ var FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS = /* @__PURE__ */ new Set([
4685
+ "eq",
4686
+ "ne",
4687
+ "gt",
4688
+ "gte",
4689
+ "lt",
4690
+ "lte",
4691
+ "contains",
4692
+ "isEmpty",
4693
+ "isNotEmpty"
4694
+ ]);
4695
+ function validateFlowTemplateStandardConditionEditorRules(value, errors) {
4696
+ const nextErrors = [];
4697
+ const data = isRecord3(value.data) ? value.data : {};
4698
+ const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
4699
+ const visitConditionGroup = (group, pathName) => {
4700
+ if (!isRecord3(group)) {
4701
+ nextErrors.push(`${pathName} must be a condition group object with logic and conditions.`);
4702
+ return;
4703
+ }
4704
+ const logic = typeof group.logic === "string" ? group.logic.trim() : "AND";
4705
+ if (logic !== "AND" && logic !== "OR") {
4706
+ nextErrors.push(`${pathName}.logic must be AND or OR.`);
4707
+ }
4708
+ if (!Array.isArray(group.conditions)) {
4709
+ nextErrors.push(`${pathName}.conditions must be an array.`);
4710
+ return;
4711
+ }
4712
+ group.conditions.forEach((condition, conditionIndex) => {
4713
+ const conditionPath = `${pathName}.conditions[${conditionIndex}]`;
4714
+ if (!isRecord3(condition)) {
4715
+ nextErrors.push(`${conditionPath} must be a condition object or nested condition group.`);
4716
+ return;
4717
+ }
4718
+ if (Array.isArray(condition.conditions) || typeof condition.logic === "string") {
4719
+ visitConditionGroup(condition, conditionPath);
4720
+ return;
4721
+ }
4722
+ const leftValue = typeof condition.leftValue === "string" ? condition.leftValue.trim() : "";
4723
+ if (!leftValue) {
4724
+ nextErrors.push(`${conditionPath}.leftValue is required and must match a form_template rule.field value.`);
4725
+ }
4726
+ const leftValueType = typeof condition.leftValueType === "string" && condition.leftValueType.trim() ? condition.leftValueType.trim() : "field";
4727
+ if (leftValueType !== "field" && leftValueType !== "constant" && leftValueType !== "variable") {
4728
+ nextErrors.push(`${conditionPath}.leftValueType must be field, constant, or variable.`);
4729
+ }
4730
+ const operator = typeof condition.operator === "string" ? condition.operator.trim() : "";
4731
+ if (!operator || !FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS.has(operator)) {
4732
+ nextErrors.push(`${conditionPath}.operator must be one of ${Array.from(FLOW_TEMPLATE_STANDARD_CONDITION_OPERATORS).join(", ")}.`);
4733
+ }
4734
+ const rightValueType = typeof condition.rightValueType === "string" && condition.rightValueType.trim() ? condition.rightValueType.trim() : "constant";
4735
+ if (rightValueType !== "field" && rightValueType !== "constant" && rightValueType !== "variable") {
4736
+ nextErrors.push(`${conditionPath}.rightValueType must be field, constant, or variable.`);
4737
+ }
4738
+ const isWewfDerived = condition._wewf_operator !== void 0 || condition._wewf_source_rule_id !== void 0 || condition._wewf_field_key !== void 0;
4739
+ if (isWewfDerived && condition._bpmax_editor_field_resolved !== true) {
4740
+ nextErrors.push(
4741
+ `${conditionPath} is WEWF-derived but does not prove BPMAX editor field resolution; leftValue must be resolved from form_template rule.field (for example main.<field_key>) before using condition_mode=standard.`
4742
+ );
4743
+ }
4744
+ if (isWewfDerived && typeof condition._wewf_field_key === "string" && condition._wewf_field_key.trim() && condition._wewf_field_key.trim() === leftValue && !leftValue.includes(".")) {
4745
+ nextErrors.push(
4746
+ `${conditionPath}.leftValue (${leftValue}) still looks like a raw WEWF field key; standard condition editor values must use the BPMAX form_template rule.field value.`
4747
+ );
4748
+ }
4749
+ });
4750
+ };
4751
+ nodes.forEach((node, nodeIndex) => {
4752
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${nodeIndex}]`;
4753
+ const conditionalNodes = Array.isArray(node.condational_nodes) ? node.condational_nodes : [];
4754
+ conditionalNodes.forEach((conditionNode, conditionIndex) => {
4755
+ if (!isRecord3(conditionNode)) {
4756
+ return;
4757
+ }
4758
+ const conditionMode = typeof conditionNode.condition_mode === "string" && conditionNode.condition_mode.trim() ? conditionNode.condition_mode.trim() : "code";
4759
+ if (conditionMode !== "standard") {
4760
+ return;
4761
+ }
4762
+ const conditionPath = `${nodeName}.condational_nodes[${conditionIndex}]`;
4763
+ if (!Array.isArray(conditionNode.condition_result_rules)) {
4764
+ nextErrors.push(`${conditionPath}.condition_result_rules must be an array when condition_mode is standard.`);
4765
+ return;
4766
+ }
4767
+ const resultLength = Array.isArray(conditionNode.result) ? conditionNode.result.length : 0;
4768
+ if (conditionNode.condition_result_rules.length !== resultLength) {
4769
+ nextErrors.push(`${conditionPath}.condition_result_rules length must equal result length (${resultLength}).`);
4770
+ }
4771
+ conditionNode.condition_result_rules.forEach((group, groupIndex) => {
4772
+ visitConditionGroup(group, `${conditionPath}.condition_result_rules[${groupIndex}]`);
4773
+ });
4774
+ });
4775
+ });
4776
+ if (!nextErrors.length) {
4777
+ return;
4778
+ }
4779
+ if (errors) {
4780
+ errors.push(...nextErrors);
4781
+ return;
4782
+ }
4783
+ throw new Error(`flow-template standard condition editor gate failed: ${nextErrors.join("; ")}`);
4784
+ }
4613
4785
  function looksLikeParseEvalFunctionBody(script) {
4614
4786
  const text5 = script.trim();
4615
4787
  if (!text5) {
@@ -5286,6 +5458,8 @@ function normalizeFlowTemplatePayload(work) {
5286
5458
  validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
5287
5459
  validateFlowTemplateStartConditionalJump({ ...work, data });
5288
5460
  validateFlowTemplateApproveActionShape({ ...work, data });
5461
+ validateFlowTemplatePluginRejectionControl({ ...work, data });
5462
+ validateFlowTemplateStandardConditionEditorRules({ ...work, data });
5289
5463
  validateFlowTemplateCodeModeMessages({ ...work, data });
5290
5464
  validateFlowTemplateRuntimeScripts({ ...work, data });
5291
5465
  validateFlowTemplateFeishuChatPlugin({ ...work, data });
@@ -7163,6 +7337,8 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
7163
7337
  validateFlowTemplateStandardPageCreateFormTemplate(work);
7164
7338
  validateFlowTemplateStartConditionalJump(work);
7165
7339
  validateFlowTemplateApproveActionShape(work);
7340
+ validateFlowTemplatePluginRejectionControl(work);
7341
+ validateFlowTemplateStandardConditionEditorRules(work);
7166
7342
  validateFlowTemplateCodeModeMessages(work);
7167
7343
  validateFlowTemplateRuntimeScripts(work);
7168
7344
  validateFlowTemplateFeishuChatPlugin(work);
@@ -8060,6 +8236,8 @@ async function lintConfigWorkFile(file, options = {}) {
8060
8236
  validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
8061
8237
  validateFlowTemplateStartConditionalJump(flowWork, errors);
8062
8238
  validateFlowTemplateApproveActionShape(flowWork, errors);
8239
+ validateFlowTemplatePluginRejectionControl(flowWork, errors);
8240
+ validateFlowTemplateStandardConditionEditorRules(flowWork, errors);
8063
8241
  validateFlowTemplateCodeModeMessages(flowWork, errors);
8064
8242
  validateFlowTemplateRuntimeScripts(flowWork, errors);
8065
8243
  validateFlowTemplateFeishuChatPlugin(flowWork, errors);
@@ -8414,6 +8592,8 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
8414
8592
  validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
8415
8593
  validateFlowTemplateStartConditionalJump(submit.payload);
8416
8594
  validateFlowTemplateApproveActionShape(submit.payload);
8595
+ validateFlowTemplatePluginRejectionControl(submit.payload);
8596
+ validateFlowTemplateStandardConditionEditorRules(submit.payload);
8417
8597
  validateFlowTemplateCodeModeMessages(submit.payload);
8418
8598
  validateFlowTemplateRuntimeScripts(submit.payload);
8419
8599
  validateFlowTemplateFeishuChatPlugin(submit.payload);