bpmax-cli 0.2.1-beta.40 → 0.2.1-beta.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -138,7 +138,7 @@ bpmax-cli step actions 15690 --project-id 13097 --format json
138
138
  bpmax-cli step requirements 15690 --project-id 13097 --format json
139
139
  ```
140
140
 
141
- `step context` reports the project/step URL, current user ownership, parsed actions, current-step input requirements, form evidence, and `identity_unverified`. `step requirements` focuses on current-step bound form fields, required inputs, existing values, missing required inputs, and a submit payload template. If project and step form values are empty, do not advance from an ES keyword or attachment-text match alone.
141
+ `step context` reports the project/step URL, current user ownership, parsed actions, current-step input requirements, form evidence, and `identity_unverified`. Owner/assignee fields are authoritative for processability; `step.user_id` is diagnostic-only and cannot override a conflicting owner. `step requirements` focuses on current-step bound form fields, required inputs, existing values, missing required inputs, and a submit payload template. If project and step form values are empty, do not advance from an ES keyword or attachment-text match alone.
142
142
 
143
143
  Submit step actions through a dry-run first:
144
144
 
package/dist/bin.js CHANGED
@@ -496,7 +496,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
496
496
  // package.json
497
497
  var package_default = {
498
498
  name: "bpmax-cli",
499
- version: "0.2.1-beta.40",
499
+ version: "0.2.1-beta.42",
500
500
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
501
501
  type: "module",
502
502
  bin: {
@@ -6684,6 +6684,8 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
6684
6684
  return;
6685
6685
  }
6686
6686
  const dataSourceText = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
6687
+ const customDataSourceCode = dataSourceText.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/\/\/[^\r\n]*/g, " ");
6688
+ const hasCustomBpmaxServerPagination = /['"]?driver['"]?\s*:\s*['"]custom_bpmax['"]/i.test(customDataSourceCode) && /\bsearch_after\b/i.test(customDataSourceCode) && /\bpage(?:Size|_size)?\b/i.test(customDataSourceCode) && /\.slice\s*\(/i.test(customDataSourceCode) && /\brows\b/i.test(customDataSourceCode) && /\btotal\b/i.test(customDataSourceCode);
6687
6689
  const stripJsNonCode = (text5) => {
6688
6690
  let output = "";
6689
6691
  let state = "code";
@@ -6931,7 +6933,7 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
6931
6933
  if (name === "offset") return safeConstExpression(expression, offsetSource);
6932
6934
  return false;
6933
6935
  });
6934
- const hasServerPagination = hasControlledFrom && hasControlledSize && hasOnlyConstPaginationPrefix && hasTrustedCfgBinding && hasCanonicalPaginationDeclarations && uniqueField("track_total_hits").toLowerCase() === "true" && hasTrustedHitsBinding && hasTrustedTotalBinding && hasReadonlyFrontendInputs && hasOnlyTrustedResultMap && !hasDisallowedFrontendLoop;
6936
+ const hasServerPagination = hasCustomBpmaxServerPagination || hasControlledFrom && hasControlledSize && hasOnlyConstPaginationPrefix && hasTrustedCfgBinding && hasCanonicalPaginationDeclarations && uniqueField("track_total_hits").toLowerCase() === "true" && hasTrustedHitsBinding && hasTrustedTotalBinding && hasReadonlyFrontendInputs && hasOnlyTrustedResultMap && !hasDisallowedFrontendLoop;
6935
6937
  if (hasFrontendDetailAccess && hasMetric && !hasAggregation && !hasServerPagination) {
6936
6938
  errors.push(`${moduleLabel} \u7981\u6B62\u62C9\u5168\u91CF\u660E\u7EC6\u5230\u524D\u7AEF\u9010\u884C\u7EDF\u8BA1\uFF1B\u7EDF\u8BA1\u7C7B\u770B\u677F\u5FC5\u987B\u4F7F\u7528 ES size: 0 + aggs/aggregations\u3002`);
6937
6939
  }
@@ -9148,7 +9150,7 @@ function formTemplateConditionFieldReferences(expression) {
9148
9150
  return Array.from(fields);
9149
9151
  }
9150
9152
  function isSupportedFormTemplateConditionVariable(expression) {
9151
- return /^\$(?:MOMENT|userInfo|formField|formDisplayField|RANGE)(?:\b|\.|\[|\()/.test(expression.trim());
9153
+ return /^\$(?:MOMENT|userInfo|formField|formDisplayField|FLOW|RANGE)(?:\b|\.|\[|\()/.test(expression.trim());
9152
9154
  }
9153
9155
  function formTemplateConditionConfigSignature(value) {
9154
9156
  if (!isRecord3(value) || !isRecord3(value.condition) || typeof value.action !== "boolean") {
@@ -9179,7 +9181,7 @@ function validateFormTemplateConditionVariable(expression, reference, side, path
9179
9181
  return;
9180
9182
  }
9181
9183
  if (!isSupportedFormTemplateConditionVariable(expression)) {
9182
- errors.push(`[form.dynamic_condition.variable_root] ${pathName}.${side}Value \u4F7F\u7528\u4E86\u4E0D\u652F\u6301\u7684\u53D8\u91CF\uFF1B\u4EC5\u5141\u8BB8 $MOMENT\u3001$userInfo\u3001$formField\u3001$formDisplayField\u3001$RANGE\u3002`);
9184
+ errors.push(`[form.dynamic_condition.variable_root] ${pathName}.${side}Value \u4F7F\u7528\u4E86\u4E0D\u652F\u6301\u7684\u53D8\u91CF\uFF1B\u4EC5\u5141\u8BB8 $MOMENT\u3001$userInfo\u3001$formField\u3001$formDisplayField\u3001$FLOW\u3001$RANGE\u3002`);
9183
9185
  return;
9184
9186
  }
9185
9187
  const expressionFields = formTemplateConditionFieldReferences(expression);
@@ -16775,7 +16777,8 @@ var REQUIRED_README_KEYS = ["scenario_id", "workspace", "flow_type", "core", "st
16775
16777
  var PRIORITIES = /* @__PURE__ */ new Set(["P0", "P1", "P2"]);
16776
16778
  var CASE_TYPES = /* @__PURE__ */ new Set(["positive", "negative", "boundary", "permission", "data_consistency", "regression"]);
16777
16779
  var STATUSES = /* @__PURE__ */ new Set(["active", "deprecated", "draft"]);
16778
- var CASE_STEP_RUNNERS = /* @__PURE__ */ new Set(["browser", "e2e_create_page", "e2e_step_run", "observe"]);
16780
+ var CASE_STEP_RUNNERS = /* @__PURE__ */ new Set(["browser", "identity", "e2e_create_page", "e2e_step_run", "observe"]);
16781
+ var IDENTITY_STEP_RE = /(?:切换|恢复|检查|核对|验证).{0,12}(?:身份|用户|管理员)|(?:mock|unmock|模拟用户)/i;
16779
16782
  var CASE_STEP_ACTION_VERBS = [
16780
16783
  "\u6253\u5F00",
16781
16784
  "\u8FDB\u5165",
@@ -17393,6 +17396,28 @@ function validateCaseSteps(filePath, cases, steps) {
17393
17396
  if (step.runner === "e2e_step_run" && !/(context|submit|readback|step)/i.test(step.evidence_required)) {
17394
17397
  fail(`${location}: e2e_step_run \u6B65\u9AA4\u5FC5\u987B\u8981\u6C42 context/submit/readback \u8BC1\u636E`, { rule_id: "test_suite.case_step.cli_evidence", path: filePath });
17395
17398
  }
17399
+ const identityStepText = [step.action, step.target, step.input_data, step.expected_result].join(" ");
17400
+ if (step.runner === "e2e_step_run" && IDENTITY_STEP_RE.test(identityStepText)) {
17401
+ fail(`${location}: identity mock/status/unmock \u4E0D\u80FD\u58F0\u660E\u4E3A e2e_step_run\uFF1B\u8BF7\u4F7F\u7528 runner=identity`, {
17402
+ rule_id: "test_suite.case_step.identity_runner",
17403
+ path: filePath,
17404
+ suggestion: "Set runner=identity and require identity operation plus readback evidence."
17405
+ });
17406
+ }
17407
+ if (step.runner === "identity") {
17408
+ if (!IDENTITY_STEP_RE.test(identityStepText)) {
17409
+ fail(`${location}: runner=identity \u53EA\u80FD\u7528\u4E8E\u8EAB\u4EFD mock/status/unmock \u6B65\u9AA4`, {
17410
+ rule_id: "test_suite.case_step.identity_action",
17411
+ path: filePath
17412
+ });
17413
+ }
17414
+ if (!/(identity|mock|unmock|身份)/i.test(step.evidence_required) || !/(readback|status|回读|恢复)/i.test(step.evidence_required)) {
17415
+ fail(`${location}: identity \u6B65\u9AA4\u5FC5\u987B\u8981\u6C42 identity operation \u548C readback/status \u8BC1\u636E`, {
17416
+ rule_id: "test_suite.case_step.identity_evidence",
17417
+ path: filePath
17418
+ });
17419
+ }
17420
+ }
17396
17421
  const values = grouped.get(caseId) ?? [];
17397
17422
  values.push(step);
17398
17423
  grouped.set(caseId, values);
@@ -17613,7 +17638,7 @@ async function migrateScenarioSteps(options) {
17613
17638
  step_id: stepId,
17614
17639
  step_no: String(index + 1),
17615
17640
  actor: roles.length === 1 ? roles[0] : "REVIEW_REQUIRED",
17616
- runner: /发起|创建/.test(action) ? "e2e_create_page" : /审批|驳回|回退|处理/.test(action) ? "e2e_step_run" : "browser",
17641
+ runner: IDENTITY_STEP_RE.test(action) ? "identity" : /发起|创建/.test(action) ? "e2e_create_page" : /审批|驳回|回退|处理/.test(action) ? "e2e_step_run" : "browser",
17617
17642
  action,
17618
17643
  target: "REVIEW_REQUIRED",
17619
17644
  input_data: "REVIEW_REQUIRED",
@@ -18055,6 +18080,24 @@ async function assertFormalExecutionEvidence(manifest, manifestPath, step, evide
18055
18080
  if (step.runner === "e2e_step_run" && !/"?status"?\s*:\s*"submitted"|"?operation_executed"?\s*:\s*true/i.test(joined)) {
18056
18081
  fail("e2e_step_run pass evidence must prove a confirmed submitted operation", { rule_id: "test_suite.run.unexecuted_evidence", path: evidencePath });
18057
18082
  }
18083
+ if (step.runner === "identity") {
18084
+ const validIdentityEvidence = jsonRecords.some(({ value }) => {
18085
+ const operation = String(value.operation || "").toLowerCase();
18086
+ if (operation === "status") {
18087
+ return ["observed", "verified"].includes(String(value.result || value.status || "").toLowerCase()) && Object.keys(asRecord(value.current_user)).length > 0;
18088
+ }
18089
+ if (operation === "mock" || operation === "unmock") {
18090
+ return value.operation_executed === true && value.remote_submitted === true && value.readback_confirmed === true;
18091
+ }
18092
+ return false;
18093
+ });
18094
+ if (!validIdentityEvidence) {
18095
+ fail("identity pass evidence must prove status readback or a confirmed mock/unmock operation", {
18096
+ rule_id: "test_suite.run.unexecuted_evidence",
18097
+ path: evidencePath
18098
+ });
18099
+ }
18100
+ }
18058
18101
  if (step.runner === "browser" || step.runner === "e2e_create_page") {
18059
18102
  const screenshots = await browserEvidenceScreenshots(manifest, manifestPath, step, evidencePath);
18060
18103
  const previousHashes = await previousBrowserScreenshotHashes(manifest, step);
@@ -20271,8 +20314,7 @@ function ownerIdsFromStep(step) {
20271
20314
  const owners = [
20272
20315
  step.owner_id,
20273
20316
  step.ownerId,
20274
- step.user_id,
20275
- step.userId,
20317
+ ...Array.isArray(step.owner) ? step.owner : [],
20276
20318
  ...Array.isArray(step.owners) ? step.owners : [],
20277
20319
  ...Array.isArray(step.owner_list) ? step.owner_list : [],
20278
20320
  ...Array.isArray(step.step_owners) ? step.step_owners : []
@@ -20294,19 +20336,24 @@ function ownerIdsFromStep(step) {
20294
20336
  return [...ids];
20295
20337
  }
20296
20338
  function ownerDiagnosticsFromStep(step, currentUser) {
20297
- const sources = [
20339
+ const authoritativeSources = [
20298
20340
  { source: "owner_id", value: step.owner_id },
20299
20341
  { source: "ownerId", value: step.ownerId },
20300
- { source: "user_id", value: step.user_id },
20301
- { source: "userId", value: step.userId },
20342
+ { source: "owner", value: step.owner },
20302
20343
  { source: "owners", value: step.owners },
20303
20344
  { source: "owner_list", value: step.owner_list },
20304
20345
  { source: "step_owners", value: step.step_owners }
20305
20346
  ];
20347
+ const auxiliarySources = [
20348
+ { source: "user_id", value: step.user_id },
20349
+ { source: "userId", value: step.userId }
20350
+ ];
20306
20351
  const ownerIds = /* @__PURE__ */ new Set();
20307
20352
  const ownerSources = /* @__PURE__ */ new Set();
20353
+ const auxiliaryUserIds = /* @__PURE__ */ new Set();
20354
+ const auxiliarySourceNames = /* @__PURE__ */ new Set();
20308
20355
  const emptyOwnerArrays = [];
20309
- for (const { source, value } of sources) {
20356
+ for (const { source, value } of authoritativeSources) {
20310
20357
  if (Array.isArray(value) && value.length === 0) {
20311
20358
  emptyOwnerArrays.push(source);
20312
20359
  }
@@ -20324,14 +20371,25 @@ function ownerDiagnosticsFromStep(step, currentUser) {
20324
20371
  }
20325
20372
  }
20326
20373
  }
20374
+ for (const { source, value } of auxiliarySources) {
20375
+ const id = idValue(value);
20376
+ if (id) {
20377
+ auxiliaryUserIds.add(id);
20378
+ auxiliarySourceNames.add(source);
20379
+ }
20380
+ }
20327
20381
  const currentUserId = currentUser ? idValue(currentUser.id ?? currentUser.user_id ?? currentUser.owner_id) : void 0;
20382
+ const sourceConflict = ownerIds.size > 0 && [...auxiliaryUserIds].some((id) => !ownerIds.has(id));
20328
20383
  return {
20329
20384
  explicit_owner_ids: [...ownerIds],
20330
20385
  owner_sources: [...ownerSources],
20386
+ auxiliary_user_ids: [...auxiliaryUserIds],
20387
+ auxiliary_sources: [...auxiliarySourceNames],
20331
20388
  ...currentUserId ? { current_user_id: currentUserId } : {},
20332
20389
  current_user_matched_explicit_owner: currentUserId ? ownerIds.has(currentUserId) : null,
20390
+ source_conflict: sourceConflict,
20333
20391
  empty_owner_arrays: emptyOwnerArrays,
20334
- ...ownerIds.size === 0 ? { note: "No explicit step owner ids were returned; processability may come from admin fallback, permission fallback, or unresolved matrix owner behavior." } : {}
20392
+ ...ownerIds.size === 0 ? { note: auxiliaryUserIds.size > 0 ? "Only auxiliary step.user_id data was returned; it is not sufficient proof that the current user can process this step." : "No explicit step owner ids were returned; processability may come from admin fallback, permission fallback, or unresolved matrix owner behavior." } : {}
20335
20393
  };
20336
20394
  }
20337
20395
  function checkCurrentUserCanProcess(step, currentUser) {
@@ -20351,7 +20409,7 @@ function checkCurrentUserCanProcess(step, currentUser) {
20351
20409
  }
20352
20410
  return {
20353
20411
  current_user_can_process: ownerIds.includes(currentUserId),
20354
- current_user_reason: ownerIds.includes(currentUserId) ? "Current user is listed as a step owner." : "Current user is not listed as a step owner."
20412
+ current_user_reason: ownerIds.includes(currentUserId) ? "Current user is listed as an authoritative step owner." : "Current user is not listed as an authoritative step owner."
20355
20413
  };
20356
20414
  }
20357
20415
  async function buildStepContext(profile, client, stepId, projectId) {
@@ -20531,7 +20589,7 @@ function registerStepCommands(program2) {
20531
20589
  if (context2.step_finished) {
20532
20590
  throw new Error("Refusing to submit: step appears to be finished.");
20533
20591
  }
20534
- if (context2.current_user_can_process === false) {
20592
+ if (context2.current_user_can_process !== true) {
20535
20593
  throw new Error(`Refusing to submit: ${context2.current_user_reason}`);
20536
20594
  }
20537
20595
  if (!requirements.can_submit) {
@@ -20787,7 +20845,9 @@ function expectationTarget(context2, requirements) {
20787
20845
  current_user_reason: context2.current_user_reason,
20788
20846
  actions: context2.actions.map((action) => action.action),
20789
20847
  action_labels: context2.actions.map((action) => action.label),
20790
- owner_sources: context2.owner_diagnostics.owner_sources
20848
+ owner_sources: context2.owner_diagnostics.owner_sources,
20849
+ auxiliary_owner_sources: context2.owner_diagnostics.auxiliary_sources,
20850
+ owner_source_conflict: context2.owner_diagnostics.source_conflict
20791
20851
  },
20792
20852
  requirements: {
20793
20853
  can_submit: requirements.can_submit,
@@ -20978,6 +21038,9 @@ function blockedReason(context2, canSubmit) {
20978
21038
  if (context2.current_user_can_process === false) {
20979
21039
  return "current_user_cannot_process";
20980
21040
  }
21041
+ if (context2.current_user_can_process === null) {
21042
+ return "step_owner_unverified";
21043
+ }
20981
21044
  if (!canSubmit) {
20982
21045
  return "missing_required_step_inputs";
20983
21046
  }
@@ -21066,7 +21129,7 @@ function registerE2eCommands(program2) {
21066
21129
  const identity = e2e.command("identity").description("Control browser-session mock identity for formal multi-role E2E");
21067
21130
  const addIdentityOptions = (command) => command.requiredOption("--evidence-dir <dir>", "Current-run identity evidence directory").option("--execution-manifest <file>", "Formal test-suite execution manifest").option("--case-id <id>", "Formal test-suite case id").option("--case-step-id <id>", "Formal test-suite case step id").option("--diagnostic", "Run without a formal manifest; cannot become pass evidence").option("--profile <profile>", "Profile providing origin and workspace").option("--cookie-env <name>", "Environment variable containing current browser Cookie", "BPMAX_COOKIE_HEADER").option("--href-path <path>", "BPMAX page path used for Referer and x-href").option("--format <format>", "Output format", "json");
21068
21131
  addIdentityOptions(identity.command("status").description("Read and record current browser-session identity")).action(async (options) => {
21069
- await requireE2eExecutionBinding(options, ["browser", "observe"], options.evidenceDir);
21132
+ await requireE2eExecutionBinding(options, ["identity", "browser", "observe"], options.evidenceDir);
21070
21133
  const config = await loadConfig();
21071
21134
  const profile = resolveProfile(config, options.profile);
21072
21135
  const current = safeIdentity(await browserSessionRequest(
@@ -21084,7 +21147,7 @@ function registerE2eCommands(program2) {
21084
21147
  remote_submitted: false,
21085
21148
  current_user: current
21086
21149
  });
21087
- await appendE2eExecutionEvidence(options, evidence, ["browser", "observe"]);
21150
+ await appendE2eExecutionEvidence(options, evidence, ["identity", "browser", "observe"]);
21088
21151
  printResult(options.format, {
21089
21152
  ok: true,
21090
21153
  result: options.diagnostic ? "diagnostic" : "observed",
@@ -21098,7 +21161,7 @@ function registerE2eCommands(program2) {
21098
21161
  if (!Number.isSafeInteger(userId) || userId <= 0) {
21099
21162
  throw new Error("e2e.identity.invalid_user_id: --user-id \u5FC5\u987B\u662F\u6B63\u6574\u6570\u3002");
21100
21163
  }
21101
- await requireE2eExecutionBinding(options, ["browser"], options.evidenceDir);
21164
+ await requireE2eExecutionBinding(options, ["identity", "browser"], options.evidenceDir);
21102
21165
  const config = await loadConfig();
21103
21166
  const profile = resolveProfile(config, options.profile);
21104
21167
  const cookie = identityCookie(options.cookieEnv);
@@ -21147,7 +21210,7 @@ function registerE2eCommands(program2) {
21147
21210
  throw new Error(`e2e.identity.evidence_failed: mock \u540E\u8BC1\u636E\u5199\u5165\u5931\u8D25\uFF0C\u5DF2\u5C1D\u8BD5\u6062\u590D\u539F\u8EAB\u4EFD\u3002${error instanceof Error ? error.message : String(error)}`);
21148
21211
  }
21149
21212
  try {
21150
- await appendE2eExecutionEvidence(options, evidence, ["browser"]);
21213
+ await appendE2eExecutionEvidence(options, evidence, ["identity", "browser"]);
21151
21214
  } catch (error) {
21152
21215
  await browserSessionRequest(profile, cookie, "PUT", "/user/current?identity_action=unmock", { unmock: true }, options.hrefPath).catch(() => void 0);
21153
21216
  throw new Error(`e2e.identity.manifest_evidence_failed: mock \u5DF2\u6267\u884C\u4F46\u7528\u4F8B\u8BC1\u636E\u767B\u8BB0\u5931\u8D25\uFF0CCLI \u5DF2\u5C1D\u8BD5\u81EA\u52A8 unmock\u3002${error instanceof Error ? error.message : String(error)}`);
@@ -21165,7 +21228,7 @@ function registerE2eCommands(program2) {
21165
21228
  });
21166
21229
  });
21167
21230
  addIdentityOptions(identity.command("unmock").description("Restore the original browser-session identity and verify recovery")).action(async (options) => {
21168
- await requireE2eExecutionBinding(options, ["browser"], options.evidenceDir);
21231
+ await requireE2eExecutionBinding(options, ["identity", "browser"], options.evidenceDir);
21169
21232
  const config = await loadConfig();
21170
21233
  const profile = resolveProfile(config, options.profile);
21171
21234
  const cookie = identityCookie(options.cookieEnv);
@@ -21188,7 +21251,7 @@ function registerE2eCommands(program2) {
21188
21251
  before,
21189
21252
  after
21190
21253
  });
21191
- await appendE2eExecutionEvidence(options, evidence, ["browser"]);
21254
+ await appendE2eExecutionEvidence(options, evidence, ["identity", "browser"]);
21192
21255
  printResult(options.format, {
21193
21256
  ok: true,
21194
21257
  result: options.diagnostic ? "diagnostic" : "restored",