bpmax-cli 0.2.1-beta.41 → 0.2.1-beta.43
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
|
@@ -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.
|
|
499
|
+
version: "0.2.1-beta.43",
|
|
500
500
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
501
501
|
type: "module",
|
|
502
502
|
bin: {
|
|
@@ -6684,8 +6684,62 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
|
|
|
6684
6684
|
return;
|
|
6685
6685
|
}
|
|
6686
6686
|
const dataSourceText = typeof dataSource === "string" ? dataSource : JSON.stringify(dataSource) ?? "";
|
|
6687
|
-
const
|
|
6688
|
-
|
|
6687
|
+
const stripJsComments = (text5) => {
|
|
6688
|
+
let output = "";
|
|
6689
|
+
let state = "code";
|
|
6690
|
+
let escaped = false;
|
|
6691
|
+
for (let index = 0; index < text5.length; index += 1) {
|
|
6692
|
+
const char = text5[index];
|
|
6693
|
+
const next = text5[index + 1];
|
|
6694
|
+
if (state === "code" && char === "/" && next === "/") {
|
|
6695
|
+
state = "line";
|
|
6696
|
+
output += " ";
|
|
6697
|
+
index += 1;
|
|
6698
|
+
continue;
|
|
6699
|
+
}
|
|
6700
|
+
if (state === "code" && char === "/" && next === "*") {
|
|
6701
|
+
state = "block";
|
|
6702
|
+
output += " ";
|
|
6703
|
+
index += 1;
|
|
6704
|
+
continue;
|
|
6705
|
+
}
|
|
6706
|
+
if (state === "code" && (char === "'" || char === '"' || char === "`")) {
|
|
6707
|
+
state = char === "'" ? "single" : char === '"' ? "double" : "template";
|
|
6708
|
+
output += char;
|
|
6709
|
+
escaped = false;
|
|
6710
|
+
continue;
|
|
6711
|
+
}
|
|
6712
|
+
if (state === "line") {
|
|
6713
|
+
if (char === "\n" || char === "\r") {
|
|
6714
|
+
state = "code";
|
|
6715
|
+
output += char;
|
|
6716
|
+
} else output += " ";
|
|
6717
|
+
continue;
|
|
6718
|
+
}
|
|
6719
|
+
if (state === "block") {
|
|
6720
|
+
if (char === "*" && next === "/") {
|
|
6721
|
+
state = "code";
|
|
6722
|
+
output += " ";
|
|
6723
|
+
index += 1;
|
|
6724
|
+
} else output += char === "\n" ? "\n" : " ";
|
|
6725
|
+
continue;
|
|
6726
|
+
}
|
|
6727
|
+
output += char;
|
|
6728
|
+
if (state !== "code") {
|
|
6729
|
+
if (escaped) {
|
|
6730
|
+
escaped = false;
|
|
6731
|
+
continue;
|
|
6732
|
+
}
|
|
6733
|
+
if (char === "\\") {
|
|
6734
|
+
escaped = true;
|
|
6735
|
+
continue;
|
|
6736
|
+
}
|
|
6737
|
+
if (state === "single" && char === "'" || state === "double" && char === '"' || state === "template" && char === "`") state = "code";
|
|
6738
|
+
}
|
|
6739
|
+
}
|
|
6740
|
+
return output;
|
|
6741
|
+
};
|
|
6742
|
+
const customDataSourceCode = stripJsComments(dataSourceText);
|
|
6689
6743
|
const stripJsNonCode = (text5) => {
|
|
6690
6744
|
let output = "";
|
|
6691
6745
|
let state = "code";
|
|
@@ -6767,8 +6821,82 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
|
|
|
6767
6821
|
}
|
|
6768
6822
|
return output;
|
|
6769
6823
|
};
|
|
6824
|
+
const readStaticString = (text5, start) => {
|
|
6825
|
+
const quote = text5[start];
|
|
6826
|
+
if (quote !== "'" && quote !== '"' && quote !== "`") return null;
|
|
6827
|
+
let value = "";
|
|
6828
|
+
let escaped = false;
|
|
6829
|
+
for (let index = start + 1; index < text5.length; index += 1) {
|
|
6830
|
+
const char = text5[index];
|
|
6831
|
+
if (escaped) {
|
|
6832
|
+
value += char === "n" ? "\n" : char === "r" ? "\r" : char === "t" ? " " : char;
|
|
6833
|
+
escaped = false;
|
|
6834
|
+
continue;
|
|
6835
|
+
}
|
|
6836
|
+
if (char === "\\") {
|
|
6837
|
+
escaped = true;
|
|
6838
|
+
continue;
|
|
6839
|
+
}
|
|
6840
|
+
if (char === quote) return { value, end: index + 1 };
|
|
6841
|
+
value += char;
|
|
6842
|
+
}
|
|
6843
|
+
return null;
|
|
6844
|
+
};
|
|
6845
|
+
const customBpmaxServerScripts = () => {
|
|
6846
|
+
if (!/['"]?driver['"]?\s*:\s*['"]custom_bpmax['"]/i.test(customDataSourceCode)) return [];
|
|
6847
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
6848
|
+
const bindingPattern = /\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*/g;
|
|
6849
|
+
for (let match = bindingPattern.exec(customDataSourceCode); match; match = bindingPattern.exec(customDataSourceCode)) {
|
|
6850
|
+
const literalStart = bindingPattern.lastIndex;
|
|
6851
|
+
const literal = readStaticString(customDataSourceCode, literalStart);
|
|
6852
|
+
if (!literal) continue;
|
|
6853
|
+
bindings.set(match[1], literal.value);
|
|
6854
|
+
bindingPattern.lastIndex = literal.end;
|
|
6855
|
+
}
|
|
6856
|
+
const scripts = [];
|
|
6857
|
+
const propertyPattern = /(?:['"]?script['"]?)\s*:\s*/g;
|
|
6858
|
+
for (let match = propertyPattern.exec(customDataSourceCode); match; match = propertyPattern.exec(customDataSourceCode)) {
|
|
6859
|
+
const valueStart = propertyPattern.lastIndex;
|
|
6860
|
+
const literal = readStaticString(customDataSourceCode, valueStart);
|
|
6861
|
+
if (literal) {
|
|
6862
|
+
scripts.push(literal.value);
|
|
6863
|
+
propertyPattern.lastIndex = literal.end;
|
|
6864
|
+
continue;
|
|
6865
|
+
}
|
|
6866
|
+
const identifier = /^([A-Za-z_$][\w$]*)/.exec(customDataSourceCode.slice(valueStart));
|
|
6867
|
+
const bound = identifier ? bindings.get(identifier[1]) : void 0;
|
|
6868
|
+
if (bound) scripts.push(bound);
|
|
6869
|
+
}
|
|
6870
|
+
const shorthandScript = bindings.get("script");
|
|
6871
|
+
if (shorthandScript && /\{[^{}]*\bscript\b[^{}]*\}/s.test(customDataSourceCode)) scripts.push(shorthandScript);
|
|
6872
|
+
return [...new Set(scripts)];
|
|
6873
|
+
};
|
|
6770
6874
|
const paginationCode = stripJsNonCode(dataSourceText);
|
|
6771
6875
|
const frontendCode = stripJsNonCode(script);
|
|
6876
|
+
const customServerCodes = customBpmaxServerScripts().map(stripJsNonCode);
|
|
6877
|
+
const outerCustomCode = stripJsNonCode(customDataSourceCode);
|
|
6878
|
+
const outerBinding = (name) => {
|
|
6879
|
+
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6880
|
+
return new RegExp(`\\b(?:const|let)\\s+${escaped}\\s*=\\s*([^;]+)`, "i").exec(outerCustomCode)?.[1] || "";
|
|
6881
|
+
};
|
|
6882
|
+
const outerPageSizeBinding = outerBinding("pageSize");
|
|
6883
|
+
const outerPageBinding = outerBinding("page");
|
|
6884
|
+
const hasControlledOuterPageSize = /ctx\.pageInfo[\s\S]*?(?:pageSize|page_size)/i.test(outerPageSizeBinding) && !/\b(?:total|count|length)\b/i.test(outerPageSizeBinding);
|
|
6885
|
+
const hasControlledOuterPage = /ctx\.pageInfo[\s\S]*?(?:\.page\b|pageIndex|current)/i.test(outerPageBinding) && !/\b(?:total|count|length)\b/i.test(outerPageBinding);
|
|
6886
|
+
const usesBodyInEsSearch = (code) => /\bctx\.\$searchByEs\s*\(\s*{\s*body(?:\s*:\s*body)?\s*[,}]/i.test(code);
|
|
6887
|
+
const hasCustomBpmaxAggregation = customServerCodes.some((code) => /\b(?:const|let)\s+body\s*=\s*{[\s\S]*?\bsize\s*:\s*0\b[\s\S]*?\b(?:aggs|aggregations)\s*:\s*{/i.test(code) && usesBodyInEsSearch(code));
|
|
6888
|
+
const hasCustomBpmaxServerPagination = customServerCodes.some((code) => {
|
|
6889
|
+
const pageSizeBinding = /\b(?:const|let)\s+pageSize\s*=\s*([^;]+)/i.exec(code)?.[1] || "";
|
|
6890
|
+
const pageBinding = /\b(?:const|let)\s+page\s*=\s*([^;]+)/i.exec(code)?.[1] || "";
|
|
6891
|
+
const offsetBinding = /\b(?:const|let)\s+offset\s*=\s*([^;]+)/i.exec(code)?.[1] || "";
|
|
6892
|
+
const controlledPageSize = /ctx\.pageInfo[\s\S]*?(?:pageSize|page_size)|ctx\.config[\s\S]*?page_size/i.test(pageSizeBinding) && !/\b(?:total|count|length)\b/i.test(pageSizeBinding) || hasControlledOuterPageSize && /\bpageSize\b/.test(code);
|
|
6893
|
+
const controlledPage = /ctx\.pageInfo[\s\S]*?(?:\.page\b|pageIndex|current)/i.test(pageBinding) && !/\b(?:total|count|length)\b/i.test(pageBinding) || hasControlledOuterPage && /\bpage\b/.test(code);
|
|
6894
|
+
const controlledOffset = /ctx\.pageInfo[\s\S]*?offset/i.test(offsetBinding) || controlledPage && /\bpage\b[\s\S]*\bpageSize\b/i.test(offsetBinding);
|
|
6895
|
+
const boundedFromSize = /\bsize\s*:\s*pageSize\b/i.test(code) && /\bfrom\s*:\s*offset\b/i.test(code) && controlledOffset;
|
|
6896
|
+
const boundedSearchAfter = /\bsize\s*:\s*pageSize\b/i.test(code) && /\bsearch_after\b/i.test(code) && controlledPage && /\bwhile\s*\([^)]*\.length\s*<\s*page\s*\*\s*pageSize\s*\)/i.test(code) && /\.slice\s*\(\s*\(\s*page\s*-\s*1\s*\)\s*\*\s*pageSize\s*,\s*page\s*\*\s*pageSize\s*\)/i.test(code);
|
|
6897
|
+
const returnsPage = /\breturn\s*{[\s\S]*\brows\b[\s\S]*\btotal\b[\s\S]*}/i.test(code);
|
|
6898
|
+
return controlledPageSize && returnsPage && usesBodyInEsSearch(code) && (boundedFromSize || boundedSearchAfter);
|
|
6899
|
+
});
|
|
6772
6900
|
const hasFrontendDetailAccess = /\brows\b|\bctx\s*\[|\bctx\.data\?*\.hits\?*\.hits\b|\.(forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(of|in)\b/i.test(frontendCode);
|
|
6773
6901
|
const hasMetric = /(count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数)/i.test(frontendCode);
|
|
6774
6902
|
const topLevelReturnedObjects = (code) => {
|
|
@@ -6830,7 +6958,7 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
|
|
|
6830
6958
|
const returnedFields = topLevelProperties(returnedQuery);
|
|
6831
6959
|
const frontendReturnedFields = topLevelProperties(frontendReturnedQuery);
|
|
6832
6960
|
const aggregationValue = returnedFields?.get("aggs") || returnedFields?.get("aggregations") || [];
|
|
6833
|
-
const hasAggregation = typeof dataSource === "string" ? Boolean(returnedFields && returnedFields.get("size")?.length === 1 && returnedFields.get("size")[0] === "0" && aggregationValue.length === 1 && aggregationValue[0].trim().startsWith("{")) : isRecord3(dataSource) && dataSource.size === 0 && (isRecord3(dataSource.aggs) || isRecord3(dataSource.aggregations));
|
|
6961
|
+
const hasAggregation = typeof dataSource === "string" ? Boolean(returnedFields && returnedFields.get("size")?.length === 1 && returnedFields.get("size")[0] === "0" && aggregationValue.length === 1 && aggregationValue[0].trim().startsWith("{")) || hasCustomBpmaxAggregation : isRecord3(dataSource) && dataSource.size === 0 && (isRecord3(dataSource.aggs) || isRecord3(dataSource.aggregations));
|
|
6834
6962
|
const mapReceivers = [...frontendCode.matchAll(/\b([A-Za-z_$][\w$]*)\s*\.\s*map\s*\(/gi)].map((match) => match[1].toLowerCase());
|
|
6835
6963
|
const uniqueFrontendField = (name) => frontendReturnedFields?.get(name)?.length === 1 ? frontendReturnedFields.get(name)[0] : "";
|
|
6836
6964
|
const dataExpression = uniqueFrontendField("data");
|
|
@@ -6935,7 +7063,8 @@ function lintConsoleTemplateFrontendDetailCounting(script, dataSource, moduleLab
|
|
|
6935
7063
|
});
|
|
6936
7064
|
const hasServerPagination = hasCustomBpmaxServerPagination || hasControlledFrom && hasControlledSize && hasOnlyConstPaginationPrefix && hasTrustedCfgBinding && hasCanonicalPaginationDeclarations && uniqueField("track_total_hits").toLowerCase() === "true" && hasTrustedHitsBinding && hasTrustedTotalBinding && hasReadonlyFrontendInputs && hasOnlyTrustedResultMap && !hasDisallowedFrontendLoop;
|
|
6937
7065
|
if (hasFrontendDetailAccess && hasMetric && !hasAggregation && !hasServerPagination) {
|
|
6938
|
-
|
|
7066
|
+
const detectionBranch = customServerCodes.length > 0 ? "custom_bpmax server script" : "direct dataSource";
|
|
7067
|
+
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\u68C0\u6D4B\u5206\u652F: ${detectionBranch}\uFF1B\u7F3A\u5931\u6761\u4EF6: \u53D7\u63A7\u670D\u52A1\u7AEF\u805A\u5408\u6216\u5206\u9875\u3002`);
|
|
6939
7068
|
}
|
|
6940
7069
|
}
|
|
6941
7070
|
function lintConsoleTemplateOverviewScript(script, moduleLabel, errors, warnings) {
|
|
@@ -9150,7 +9279,7 @@ function formTemplateConditionFieldReferences(expression) {
|
|
|
9150
9279
|
return Array.from(fields);
|
|
9151
9280
|
}
|
|
9152
9281
|
function isSupportedFormTemplateConditionVariable(expression) {
|
|
9153
|
-
return /^\$(?:MOMENT|userInfo|formField|formDisplayField|RANGE)(?:\b|\.|\[|\()/.test(expression.trim());
|
|
9282
|
+
return /^\$(?:MOMENT|userInfo|formField|formDisplayField|FLOW|RANGE)(?:\b|\.|\[|\()/.test(expression.trim());
|
|
9154
9283
|
}
|
|
9155
9284
|
function formTemplateConditionConfigSignature(value) {
|
|
9156
9285
|
if (!isRecord3(value) || !isRecord3(value.condition) || typeof value.action !== "boolean") {
|
|
@@ -9181,7 +9310,7 @@ function validateFormTemplateConditionVariable(expression, reference, side, path
|
|
|
9181
9310
|
return;
|
|
9182
9311
|
}
|
|
9183
9312
|
if (!isSupportedFormTemplateConditionVariable(expression)) {
|
|
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$RANGE\u3002`);
|
|
9313
|
+
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`);
|
|
9185
9314
|
return;
|
|
9186
9315
|
}
|
|
9187
9316
|
const expressionFields = formTemplateConditionFieldReferences(expression);
|
|
@@ -19228,13 +19357,15 @@ function nonEmptyStringArray(value) {
|
|
|
19228
19357
|
async function uxManifestArtifacts(text5, reportPath, runDir) {
|
|
19229
19358
|
const artifacts = /* @__PURE__ */ new Set();
|
|
19230
19359
|
const manifestValue = reportKeyValue(text5, "execution_manifest:");
|
|
19231
|
-
if (!manifestValue) return artifacts;
|
|
19360
|
+
if (!manifestValue) return { artifacts, result: "" };
|
|
19232
19361
|
const manifestPath = path11.resolve(path11.dirname(reportPath), manifestValue);
|
|
19233
19362
|
if (!pathInside(runDir, manifestPath) || !await exists3(manifestPath) || !await pathInsideReal(runDir, manifestPath)) {
|
|
19234
|
-
return artifacts;
|
|
19363
|
+
return { artifacts, result: "" };
|
|
19235
19364
|
}
|
|
19365
|
+
let result = "";
|
|
19236
19366
|
try {
|
|
19237
19367
|
const manifest = JSON.parse(await readText(manifestPath));
|
|
19368
|
+
result = typeof manifest.result === "string" ? manifest.result.toLowerCase() : "";
|
|
19238
19369
|
for (const step of manifest.steps ?? []) {
|
|
19239
19370
|
for (const item of step.evidence ?? []) {
|
|
19240
19371
|
const evidencePath = path11.isAbsolute(item) ? path11.resolve(item) : path11.resolve(path11.dirname(manifestPath), item);
|
|
@@ -19255,7 +19386,7 @@ async function uxManifestArtifacts(text5, reportPath, runDir) {
|
|
|
19255
19386
|
}
|
|
19256
19387
|
} catch {
|
|
19257
19388
|
}
|
|
19258
|
-
return artifacts;
|
|
19389
|
+
return { artifacts, result };
|
|
19259
19390
|
}
|
|
19260
19391
|
async function validateUxEvidence(values, options) {
|
|
19261
19392
|
const errors = [];
|
|
@@ -19319,7 +19450,8 @@ async function lintUxAudit(text5, reportPath, runDir, runName) {
|
|
|
19319
19450
|
const findingsValue = reportKeyValue(text5, "ux_findings:");
|
|
19320
19451
|
const scenarioId = reportKeyValue(text5, "scenario_id:");
|
|
19321
19452
|
const resultValue = reportKeyValue(text5, "result:").toLowerCase();
|
|
19322
|
-
const
|
|
19453
|
+
const manifestContext = await uxManifestArtifacts(text5, reportPath, runDir);
|
|
19454
|
+
const manifestArtifacts = manifestContext.artifacts;
|
|
19323
19455
|
const window = reportExecutionWindow(runName, text5);
|
|
19324
19456
|
let actualCounts = emptyUxBugCounts();
|
|
19325
19457
|
if (!findingsValue) {
|
|
@@ -19402,10 +19534,11 @@ async function lintUxAudit(text5, reportPath, runDir, runName) {
|
|
|
19402
19534
|
errors.push(`[test_suite.report.ux_bug_counts] ${reportPath}: ux_bug_counts \u4E0E ux-findings.json \u4E0D\u4E00\u81F4`);
|
|
19403
19535
|
}
|
|
19404
19536
|
const counts = reportedCounts ?? actualCounts;
|
|
19537
|
+
const preservesBlockedManifest = manifestContext.result === "blocked" && resultValue === "blocked";
|
|
19405
19538
|
if (reportAuditStatus === "blocked" && !["partial", "blocked"].includes(resultValue)) {
|
|
19406
19539
|
errors.push(`[test_suite.report.ux_result] ${reportPath}: UX \u5BA1\u8BA1 blocked \u65F6 result \u53EA\u80FD\u662F partial \u6216 blocked`);
|
|
19407
19540
|
} else if (counts.P0 > 0 || counts.P1 > 0) {
|
|
19408
|
-
if (resultValue !== "fail") errors.push(`[test_suite.report.ux_result] ${reportPath}: \u5B58\u5728 P0/P1 UX BUG \u65F6 result \u5FC5\u987B\u662F fail`);
|
|
19541
|
+
if (resultValue !== "fail" && !preservesBlockedManifest) errors.push(`[test_suite.report.ux_result] ${reportPath}: \u5B58\u5728 P0/P1 UX BUG \u65F6 result \u5FC5\u987B\u662F fail\uFF1B\u5408\u6CD5 blocked manifest \u53EF\u4FDD\u7559 result=blocked`);
|
|
19409
19542
|
} else if (counts.P2 > 0 || counts.P3 > 0) {
|
|
19410
19543
|
if (!["pass-with-warnings", "fail"].includes(resultValue)) errors.push(`[test_suite.report.ux_result] ${reportPath}: \u53EA\u6709 P2/P3 UX BUG \u65F6 result \u5FC5\u987B\u662F pass-with-warnings\uFF1B\u5B58\u5728\u5176\u4ED6\u5931\u8D25\u65F6\u53EF\u4E3A fail`);
|
|
19411
19544
|
} else if (reportAuditStatus === "completed" && resultValue === "pass-with-warnings") {
|
|
@@ -20314,6 +20447,7 @@ function ownerIdsFromStep(step) {
|
|
|
20314
20447
|
const owners = [
|
|
20315
20448
|
step.owner_id,
|
|
20316
20449
|
step.ownerId,
|
|
20450
|
+
...Array.isArray(step.owner) ? step.owner : [],
|
|
20317
20451
|
...Array.isArray(step.owners) ? step.owners : [],
|
|
20318
20452
|
...Array.isArray(step.owner_list) ? step.owner_list : [],
|
|
20319
20453
|
...Array.isArray(step.step_owners) ? step.step_owners : []
|
|
@@ -20338,6 +20472,7 @@ function ownerDiagnosticsFromStep(step, currentUser) {
|
|
|
20338
20472
|
const authoritativeSources = [
|
|
20339
20473
|
{ source: "owner_id", value: step.owner_id },
|
|
20340
20474
|
{ source: "ownerId", value: step.ownerId },
|
|
20475
|
+
{ source: "owner", value: step.owner },
|
|
20341
20476
|
{ source: "owners", value: step.owners },
|
|
20342
20477
|
{ source: "owner_list", value: step.owner_list },
|
|
20343
20478
|
{ source: "step_owners", value: step.step_owners }
|