bpmax-cli 0.2.1-beta.27 → 0.2.1-beta.29
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 +1025 -69
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-dataset-field-template-editor/SKILL.md +1 -0
- package/skills/bpmax-dataset-template-editor/SKILL.md +1 -0
- package/skills/bpmax-e2e-flow-test-operator/SKILL.md +3 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +4 -1
- package/skills/bpmax-flow-template-editor/references/flow-template-api-workflow.md +1 -1
- package/skills/bpmax-flow-template-editor/references/full-detail-guide.md +3 -1
- package/skills/bpmax-form-template-editor/SKILL.md +1 -0
- package/skills/bpmax-project/SKILL.md +1 -0
- package/skills/bpmax-project-detail-template-editor/SKILL.md +2 -6
package/dist/bin.js
CHANGED
|
@@ -437,6 +437,9 @@ function flowPageTemplateCapabilityPrefix(path16) {
|
|
|
437
437
|
if (type === "4") {
|
|
438
438
|
return "config.console_template";
|
|
439
439
|
}
|
|
440
|
+
if (type === "6") {
|
|
441
|
+
return "config.step_detail_template";
|
|
442
|
+
}
|
|
440
443
|
return "config.list_template";
|
|
441
444
|
}
|
|
442
445
|
function normalizePath2(path16) {
|
|
@@ -471,7 +474,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
471
474
|
// package.json
|
|
472
475
|
var package_default = {
|
|
473
476
|
name: "bpmax-cli",
|
|
474
|
-
version: "0.2.1-beta.
|
|
477
|
+
version: "0.2.1-beta.29",
|
|
475
478
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
476
479
|
type: "module",
|
|
477
480
|
bin: {
|
|
@@ -4215,6 +4218,19 @@ import path9 from "path";
|
|
|
4215
4218
|
import { createHash as createHash4 } from "crypto";
|
|
4216
4219
|
import { mkdir as mkdir5, readdir as readdir2, readFile as readFile8, writeFile as writeFile5 } from "fs/promises";
|
|
4217
4220
|
import path5 from "path";
|
|
4221
|
+
import { isDeepStrictEqual } from "util";
|
|
4222
|
+
function configWorkflowError(message, details) {
|
|
4223
|
+
return Object.assign(new Error(message), details);
|
|
4224
|
+
}
|
|
4225
|
+
function errorStatus(error) {
|
|
4226
|
+
if (!isRecord3(error) || !isRecord3(error.response)) return void 0;
|
|
4227
|
+
const status = Number(error.response.status);
|
|
4228
|
+
return Number.isFinite(status) ? status : void 0;
|
|
4229
|
+
}
|
|
4230
|
+
function isJsonParseFailure(error) {
|
|
4231
|
+
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
4232
|
+
return error instanceof SyntaxError || /Unexpected end of JSON input|JSON.*(?:parse|position)|unterminated JSON/i.test(message);
|
|
4233
|
+
}
|
|
4218
4234
|
var NAV_CONFIG_TYPES = ["navmenu", "shortcut", "navmenu_mobile", "shortcut_mobile"];
|
|
4219
4235
|
var NAV_CONTENT_KEY_BY_TYPE = {
|
|
4220
4236
|
navmenu: "navConfig",
|
|
@@ -4246,6 +4262,7 @@ var LOCAL_UUID_DOMAIN_DIR = {
|
|
|
4246
4262
|
"list-template": "think_flow_page_template",
|
|
4247
4263
|
"filter-template": "think_flow_page_template",
|
|
4248
4264
|
"project-detail-template": "think_flow_page_template",
|
|
4265
|
+
"step-detail-template": "think_flow_page_template",
|
|
4249
4266
|
"console-template": "think_flow_page_template",
|
|
4250
4267
|
dataset: "think_data_set",
|
|
4251
4268
|
"dataset-field": "think_data_set_field",
|
|
@@ -4257,6 +4274,7 @@ var REMOTE_UUID_EXPORT_PATH = {
|
|
|
4257
4274
|
"list-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
|
|
4258
4275
|
"filter-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
|
|
4259
4276
|
"project-detail-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
|
|
4277
|
+
"step-detail-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`,
|
|
4260
4278
|
"console-template": (uuid) => `/flow_page_template/get_by_uuid?uuid=${encodeURIComponent(uuid)}`
|
|
4261
4279
|
};
|
|
4262
4280
|
var CONFIG_DOMAINS = {
|
|
@@ -4371,6 +4389,23 @@ var CONFIG_DOMAINS = {
|
|
|
4371
4389
|
writeEndpoints: ["POST /api/flow_page_template", "PUT /api/flow_page_template/:id", "DELETE /api/flow_page_template/:id"],
|
|
4372
4390
|
notes: ["type=2 project detail template. Create and edit both use the typed flow_page_template adapter; create automatically finalizes data_set_id/flow_type through PUT when needed; activate/delete remain domain-specific operations."]
|
|
4373
4391
|
},
|
|
4392
|
+
"step-detail-template": {
|
|
4393
|
+
capability: "config.step_detail_template",
|
|
4394
|
+
exportPath: (id) => `/flow_page_template/${id}?type=6&skip_i18n=true`,
|
|
4395
|
+
exportStatus: "supported",
|
|
4396
|
+
buildStatus: "supported",
|
|
4397
|
+
submitStatus: "supported",
|
|
4398
|
+
createPath: "/flow_page_template?type=6",
|
|
4399
|
+
createMethod: "POST",
|
|
4400
|
+
deletePath: (id) => `/flow_page_template/${id}?type=6`,
|
|
4401
|
+
deleteMethod: "DELETE",
|
|
4402
|
+
submitPath: (id) => `/flow_page_template/${id}?type=6`,
|
|
4403
|
+
submitMethod: "PUT",
|
|
4404
|
+
expectedType: 6,
|
|
4405
|
+
readEndpoints: ["GET /api/flow_page_template/:id?type=6&skip_i18n=true"],
|
|
4406
|
+
writeEndpoints: ["POST /api/flow_page_template?type=6", "PUT /api/flow_page_template/:id?type=6", "DELETE /api/flow_page_template/:id?type=6"],
|
|
4407
|
+
notes: ["type=6 flow-step detail template referenced by flow node step_detail_id. This domain has its own typed capability and must not be submitted as another page-template type."]
|
|
4408
|
+
},
|
|
4374
4409
|
"console-template": {
|
|
4375
4410
|
capability: "config.console_template",
|
|
4376
4411
|
exportPath: (id) => `/flow_page_template/${id}?skip_i18n=true`,
|
|
@@ -4591,8 +4626,18 @@ function assertFormTemplateDraftId(id, data, action) {
|
|
|
4591
4626
|
const detail = formTemplateDetail(data);
|
|
4592
4627
|
const originTemplateId = numericId(detail.origin_template_id);
|
|
4593
4628
|
if (originTemplateId && originTemplateId > 0) {
|
|
4594
|
-
throw
|
|
4595
|
-
`Refusing to ${action} published form-template id ${id}. Use draft id ${originTemplateId}; published ids are readback-only and must not be used for export/submit/publish
|
|
4629
|
+
throw configWorkflowError(
|
|
4630
|
+
`Refusing to ${action} published form-template id ${id}. Use draft id ${originTemplateId}; published ids are readback-only and must not be used for export/submit/publish.`,
|
|
4631
|
+
{
|
|
4632
|
+
code: "config_form_template_published_readonly",
|
|
4633
|
+
rule_id: "config.form_template.draft_required",
|
|
4634
|
+
domain: "form-template",
|
|
4635
|
+
path: `/form_template/${id}`,
|
|
4636
|
+
published_id: id,
|
|
4637
|
+
draft_id: originTemplateId,
|
|
4638
|
+
request_phase: "readback",
|
|
4639
|
+
suggestion: `Use bpmax-cli config form-template ${action} --id ${originTemplateId} with the editable draft id.`
|
|
4640
|
+
}
|
|
4596
4641
|
);
|
|
4597
4642
|
}
|
|
4598
4643
|
}
|
|
@@ -4865,6 +4910,7 @@ async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
|
|
|
4865
4910
|
const flowErrors = [];
|
|
4866
4911
|
const warnings = [];
|
|
4867
4912
|
let pluginLint;
|
|
4913
|
+
let stepDetailReferenceAudit;
|
|
4868
4914
|
if (!isRecord3(formWork)) {
|
|
4869
4915
|
formErrors.push("flow-app create requires form work to be a JSON object.");
|
|
4870
4916
|
} else if (formWork.mode !== "create") {
|
|
@@ -4886,6 +4932,11 @@ async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
|
|
|
4886
4932
|
flowErrors.push(...pluginLint.errors);
|
|
4887
4933
|
warnings.push(...pluginLint.warnings);
|
|
4888
4934
|
}
|
|
4935
|
+
if (options.pluginLint?.profile) {
|
|
4936
|
+
stepDetailReferenceAudit = await auditFlowStepDetailReferences(flowWork, options.pluginLint.profile);
|
|
4937
|
+
flowErrors.push(...stepDetailReferenceAudit.errors.filter((error) => !flowErrors.includes(error)));
|
|
4938
|
+
warnings.push(...stepDetailReferenceAudit.warnings);
|
|
4939
|
+
}
|
|
4889
4940
|
}
|
|
4890
4941
|
errors.push(...formErrors, ...flowErrors);
|
|
4891
4942
|
return {
|
|
@@ -4901,6 +4952,11 @@ async function lintFlowAppWorkFiles(formWorkFile, flowWorkFile, options = {}) {
|
|
|
4901
4952
|
flow_template: flowErrors
|
|
4902
4953
|
},
|
|
4903
4954
|
...pluginLint ? { plugin_lints: pluginLint.plugin_lints } : {},
|
|
4955
|
+
...stepDetailReferenceAudit ? {
|
|
4956
|
+
step_detail_references: stepDetailReferenceAudit.references,
|
|
4957
|
+
step_detail_warnings: stepDetailReferenceAudit.warnings,
|
|
4958
|
+
runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
|
|
4959
|
+
} : {},
|
|
4904
4960
|
warnings,
|
|
4905
4961
|
flow_type_policy: "flow_type is allocated by the platform during config flow-app create; pre-create lint intentionally does not require flow_type.",
|
|
4906
4962
|
evidence_requirements: [
|
|
@@ -5966,6 +6022,329 @@ function lintTemplateFieldReferences(value, errors) {
|
|
|
5966
6022
|
}
|
|
5967
6023
|
}
|
|
5968
6024
|
}
|
|
6025
|
+
var STEP_DETAIL_CORE_MODULE_NAMES = /* @__PURE__ */ new Set([
|
|
6026
|
+
"\u4E0A\u4E00\u73AF\u8282",
|
|
6027
|
+
"\u73AF\u8282\u9644\u4EF6",
|
|
6028
|
+
"\u8BC4\u8BBA",
|
|
6029
|
+
"\u64CD\u4F5C\u65E5\u5FD7",
|
|
6030
|
+
"\u5F53\u524D\u73AF\u8282",
|
|
6031
|
+
"\u4EFB\u610F\u73AF\u8282\u8868\u5355",
|
|
6032
|
+
"\u5907\u6CE8",
|
|
6033
|
+
"\u73AF\u8282\u8868\u5355",
|
|
6034
|
+
"\u5F15\u7528\u9644\u4EF6",
|
|
6035
|
+
"\u590D\u6742\u8868\u5355",
|
|
6036
|
+
"\u6284\u9001\u4EBA",
|
|
6037
|
+
"\u73AF\u8282\u8017\u65F6",
|
|
6038
|
+
"\u7ED1\u5B9A\u5B50\u6D41\u7A0B",
|
|
6039
|
+
"\u4F20\u9605[\u4FA7\u8FB9\u680F]",
|
|
6040
|
+
"\u9879\u76EE\u4FE1\u606F",
|
|
6041
|
+
"\u540E\u7EED\u73AF\u8282\u8D1F\u8D23\u4EBA\u5206\u914D",
|
|
6042
|
+
"\u6D41\u7A0B\u65E5\u5FD7[\u4FA7\u8FB9\u680F]",
|
|
6043
|
+
"\u9879\u76EE\u4FE1\u606F[\u4FA7\u8FB9\u680F]",
|
|
6044
|
+
"\u8868\u5355[\u4FA7\u8FB9\u680F]",
|
|
6045
|
+
"\u4E0A\u4E00\u73AF\u8282\u8868\u5355",
|
|
6046
|
+
"\u5173\u8054\u9879\u76EE\u8868\u5355",
|
|
6047
|
+
"\u9644\u4EF6[\u4FA7\u8FB9\u680F]"
|
|
6048
|
+
]);
|
|
6049
|
+
function stepDetailLintCustomModules(value) {
|
|
6050
|
+
const lint = isRecord3(value.bpmax_lint) ? value.bpmax_lint : {};
|
|
6051
|
+
const modules = Array.isArray(lint.step_detail_custom_modules) ? lint.step_detail_custom_modules : [];
|
|
6052
|
+
return new Set(
|
|
6053
|
+
modules.filter((item) => typeof item === "string" && Boolean(item.trim())).map((item) => item.trim())
|
|
6054
|
+
);
|
|
6055
|
+
}
|
|
6056
|
+
function parseStepDetailContent(value, errors) {
|
|
6057
|
+
const basic = isRecord3(value.basic) ? value.basic : value;
|
|
6058
|
+
const rawContent = value.content ?? basic.content;
|
|
6059
|
+
if (rawContent === void 0 || rawContent === null || rawContent === "") {
|
|
6060
|
+
errors.push("step-detail-template content \u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u4E14\u5FC5\u987B\u5305\u542B\u975E\u7A7A layout\u3002");
|
|
6061
|
+
return void 0;
|
|
6062
|
+
}
|
|
6063
|
+
if (typeof rawContent === "string") {
|
|
6064
|
+
try {
|
|
6065
|
+
const parsed = JSON.parse(rawContent);
|
|
6066
|
+
if (!isRecord3(parsed)) {
|
|
6067
|
+
errors.push("step-detail-template content \u5FC5\u987B\u89E3\u6790\u4E3A JSON \u5BF9\u8C61\u3002");
|
|
6068
|
+
return void 0;
|
|
6069
|
+
}
|
|
6070
|
+
return parsed;
|
|
6071
|
+
} catch {
|
|
6072
|
+
errors.push("step-detail-template content \u5FC5\u987B\u662F\u5408\u6CD5 JSON\u3002");
|
|
6073
|
+
return void 0;
|
|
6074
|
+
}
|
|
6075
|
+
}
|
|
6076
|
+
if (!isRecord3(rawContent)) {
|
|
6077
|
+
errors.push("step-detail-template content \u5FC5\u987B\u662F JSON \u5BF9\u8C61\u3002");
|
|
6078
|
+
return void 0;
|
|
6079
|
+
}
|
|
6080
|
+
return rawContent;
|
|
6081
|
+
}
|
|
6082
|
+
function analyzeStepDetailTemplate(value, options = {}) {
|
|
6083
|
+
const errors = [];
|
|
6084
|
+
const warnings = [];
|
|
6085
|
+
const basic = isRecord3(value.basic) ? value.basic : value;
|
|
6086
|
+
if (typeof basic.name !== "string" || !basic.name.trim()) {
|
|
6087
|
+
errors.push("step-detail-template name \u5FC5\u987B\u662F\u975E\u7A7A\u5B57\u7B26\u4E32\u3002");
|
|
6088
|
+
}
|
|
6089
|
+
if (basic.type !== void 0 && Number(basic.type) !== 6) {
|
|
6090
|
+
errors.push(`step-detail-template type \u5FC5\u987B\u4E3A 6\uFF0C\u5F53\u524D\u4E3A ${JSON.stringify(basic.type)}\u3002`);
|
|
6091
|
+
}
|
|
6092
|
+
const content = parseStepDetailContent(value, errors);
|
|
6093
|
+
const layout = content?.layout;
|
|
6094
|
+
if (!Array.isArray(layout) || layout.length === 0) {
|
|
6095
|
+
errors.push("step-detail-template content.layout \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4\u3002");
|
|
6096
|
+
return {
|
|
6097
|
+
errors,
|
|
6098
|
+
warnings,
|
|
6099
|
+
moduleNames: [],
|
|
6100
|
+
unknownModules: [],
|
|
6101
|
+
customModules: [],
|
|
6102
|
+
hasMainColumn: false,
|
|
6103
|
+
hasCurrentStepForm: false,
|
|
6104
|
+
hasRelatedProjectForm: false,
|
|
6105
|
+
requiresRuntimeProof: false
|
|
6106
|
+
};
|
|
6107
|
+
}
|
|
6108
|
+
const declaredCustomModules = stepDetailLintCustomModules(value);
|
|
6109
|
+
const moduleNames = [];
|
|
6110
|
+
const unknownModules = /* @__PURE__ */ new Set();
|
|
6111
|
+
const usedCustomModules = /* @__PURE__ */ new Set();
|
|
6112
|
+
const occupied = /* @__PURE__ */ new Set();
|
|
6113
|
+
let hasMainColumn = false;
|
|
6114
|
+
layout.forEach((item, index) => {
|
|
6115
|
+
const itemPath = `content.layout[${index}]`;
|
|
6116
|
+
if (!isRecord3(item)) {
|
|
6117
|
+
errors.push(`${itemPath} \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
|
|
6118
|
+
return;
|
|
6119
|
+
}
|
|
6120
|
+
const name = typeof item.name === "string" ? item.name.trim() : "";
|
|
6121
|
+
if (!name) {
|
|
6122
|
+
errors.push(`${itemPath}.name \u5FC5\u987B\u662F\u975E\u7A7A\u6A21\u5757\u540D\u79F0\u3002`);
|
|
6123
|
+
} else {
|
|
6124
|
+
moduleNames.push(name);
|
|
6125
|
+
if (!STEP_DETAIL_CORE_MODULE_NAMES.has(name) && !declaredCustomModules.has(name)) {
|
|
6126
|
+
unknownModules.add(name);
|
|
6127
|
+
} else if (!STEP_DETAIL_CORE_MODULE_NAMES.has(name)) {
|
|
6128
|
+
usedCustomModules.add(name);
|
|
6129
|
+
}
|
|
6130
|
+
}
|
|
6131
|
+
const x = item.x;
|
|
6132
|
+
const y = item.y;
|
|
6133
|
+
if (x !== 0 && x !== 1) {
|
|
6134
|
+
errors.push(`${itemPath}.x \u53EA\u80FD\u4E3A 0\uFF08\u4E3B\u680F\uFF09\u6216 1\uFF08\u4FA7\u680F\uFF09\u3002`);
|
|
6135
|
+
} else if (x === 0) {
|
|
6136
|
+
hasMainColumn = true;
|
|
6137
|
+
}
|
|
6138
|
+
if (typeof y !== "number" || !Number.isInteger(y) || y < 0) {
|
|
6139
|
+
errors.push(`${itemPath}.y \u5FC5\u987B\u662F\u975E\u8D1F\u6574\u6570\u3002`);
|
|
6140
|
+
}
|
|
6141
|
+
if ((x === 0 || x === 1) && typeof y === "number" && Number.isInteger(y) && y >= 0) {
|
|
6142
|
+
const position = `${x}:${y}`;
|
|
6143
|
+
if (occupied.has(position)) {
|
|
6144
|
+
errors.push(`${itemPath} \u4E0E\u5176\u4ED6\u6A21\u5757\u5360\u7528\u4E86\u91CD\u590D\u4F4D\u7F6E x=${x}, y=${y}\u3002`);
|
|
6145
|
+
}
|
|
6146
|
+
occupied.add(position);
|
|
6147
|
+
}
|
|
6148
|
+
if (item.config !== void 0 && !isRecord3(item.config)) {
|
|
6149
|
+
errors.push(`${itemPath}.config \u5FC5\u987B\u662F\u5BF9\u8C61\u3002`);
|
|
6150
|
+
}
|
|
6151
|
+
if (item.detailFormConfig !== void 0 && (!Array.isArray(item.detailFormConfig) || item.detailFormConfig.some((entry) => !isRecord3(entry)))) {
|
|
6152
|
+
errors.push(`${itemPath}.detailFormConfig \u5FC5\u987B\u662F\u5BF9\u8C61\u6570\u7EC4\u3002`);
|
|
6153
|
+
}
|
|
6154
|
+
});
|
|
6155
|
+
if (!hasMainColumn) {
|
|
6156
|
+
errors.push("step-detail-template \u81F3\u5C11\u9700\u8981\u4E00\u4E2A x=0 \u7684\u4E3B\u680F\u6A21\u5757\u3002");
|
|
6157
|
+
}
|
|
6158
|
+
if (unknownModules.size) {
|
|
6159
|
+
const names = [...unknownModules].join(", ");
|
|
6160
|
+
const message = `step-detail-template \u5305\u542B\u672A\u58F0\u660E\u7684\u81EA\u5B9A\u4E49\u6A21\u5757\uFF1A${names}\u3002\u5E73\u53F0\u4F1A\u9759\u9ED8\u8FC7\u6EE4\u672A\u6CE8\u518C\u6A21\u5757\uFF1B\u8BF7\u786E\u8BA4\u63D2\u4EF6\u5DF2\u6CE8\u518C\uFF0C\u5E76\u5728 work.bpmax_lint.step_detail_custom_modules \u4E2D\u663E\u5F0F\u58F0\u660E\u3002`;
|
|
6161
|
+
if (options.allowUndeclaredCustomModules) {
|
|
6162
|
+
warnings.push(message);
|
|
6163
|
+
} else {
|
|
6164
|
+
errors.push(message);
|
|
6165
|
+
}
|
|
6166
|
+
}
|
|
6167
|
+
if (usedCustomModules.size) {
|
|
6168
|
+
warnings.push(
|
|
6169
|
+
`step-detail-template \u4F7F\u7528\u5DF2\u58F0\u660E\u7684\u63D2\u4EF6\u81EA\u5B9A\u4E49\u6A21\u5757\uFF1A${[...usedCustomModules].join(", ")}\u3002CLI \u53EA\u80FD\u786E\u8BA4\u58F0\u660E\u5B58\u5728\uFF0C\u4E0D\u80FD\u9759\u6001\u8BC1\u660E\u524D\u7AEF\u63D2\u4EF6\u5DF2\u6CE8\u518C\uFF1B\u5B8C\u6210\u7ED3\u8BBA\u5FC5\u987B\u5305\u542B\u771F\u5B9E\u73AF\u8282\u9875\u9762\u8BC1\u636E\u3002`
|
|
6170
|
+
);
|
|
6171
|
+
}
|
|
6172
|
+
return {
|
|
6173
|
+
errors,
|
|
6174
|
+
warnings,
|
|
6175
|
+
moduleNames,
|
|
6176
|
+
unknownModules: [...unknownModules],
|
|
6177
|
+
customModules: [...usedCustomModules],
|
|
6178
|
+
hasMainColumn,
|
|
6179
|
+
hasCurrentStepForm: moduleNames.some((name) => ["\u73AF\u8282\u8868\u5355", "\u4EFB\u610F\u73AF\u8282\u8868\u5355", "\u590D\u6742\u8868\u5355"].includes(name)),
|
|
6180
|
+
hasRelatedProjectForm: moduleNames.includes("\u5173\u8054\u9879\u76EE\u8868\u5355"),
|
|
6181
|
+
requiresRuntimeProof: unknownModules.size > 0 || usedCustomModules.size > 0
|
|
6182
|
+
};
|
|
6183
|
+
}
|
|
6184
|
+
function lintStepDetailTemplateWork(value, errors, warnings) {
|
|
6185
|
+
const analysis = analyzeStepDetailTemplate(value);
|
|
6186
|
+
errors.push(...analysis.errors);
|
|
6187
|
+
warnings.push(...analysis.warnings);
|
|
6188
|
+
return analysis;
|
|
6189
|
+
}
|
|
6190
|
+
function stepDetailAnalysisEvidence(analysis) {
|
|
6191
|
+
return {
|
|
6192
|
+
modules: analysis.moduleNames,
|
|
6193
|
+
unknown_modules: analysis.unknownModules,
|
|
6194
|
+
custom_modules: analysis.customModules,
|
|
6195
|
+
has_main_column: analysis.hasMainColumn,
|
|
6196
|
+
has_current_step_form: analysis.hasCurrentStepForm,
|
|
6197
|
+
has_related_project_form: analysis.hasRelatedProjectForm,
|
|
6198
|
+
runtime_proof_required: analysis.requiresRuntimeProof
|
|
6199
|
+
};
|
|
6200
|
+
}
|
|
6201
|
+
function stepDetailLintArtifact(value) {
|
|
6202
|
+
return {
|
|
6203
|
+
step_detail_custom_modules: [...stepDetailLintCustomModules(value)]
|
|
6204
|
+
};
|
|
6205
|
+
}
|
|
6206
|
+
function stepDetailPayloadWithLintArtifact(payload, submit) {
|
|
6207
|
+
const lint = isRecord3(submit.step_detail_lint) ? submit.step_detail_lint : {};
|
|
6208
|
+
return {
|
|
6209
|
+
...payload,
|
|
6210
|
+
bpmax_lint: lint
|
|
6211
|
+
};
|
|
6212
|
+
}
|
|
6213
|
+
function numericTemplateId(value) {
|
|
6214
|
+
return isRemoteNumericTemplateId(value) ? String(value).trim() : null;
|
|
6215
|
+
}
|
|
6216
|
+
async function auditFlowStepDetailReferences(flowWork, profile) {
|
|
6217
|
+
const errors = [];
|
|
6218
|
+
const warnings = [];
|
|
6219
|
+
const references = [];
|
|
6220
|
+
const data = isRecord3(flowWork.data) ? flowWork.data : {};
|
|
6221
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
6222
|
+
const metaConfigured = !isEmptyTemplateReference(meta.step_detail_id);
|
|
6223
|
+
const metaId = numericTemplateId(meta.step_detail_id);
|
|
6224
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.map((node, index) => ({ node, index })).filter((entry) => isRecord3(entry.node)) : [];
|
|
6225
|
+
const ids = /* @__PURE__ */ new Set();
|
|
6226
|
+
if (metaConfigured && !metaId) {
|
|
6227
|
+
addFlowTemplateRemoteIdError(errors, "data.meta.step_detail_id", meta.step_detail_id);
|
|
6228
|
+
}
|
|
6229
|
+
if (metaId) ids.add(metaId);
|
|
6230
|
+
nodes.forEach(({ node, index }) => {
|
|
6231
|
+
const directConfigured = !isEmptyTemplateReference(node.step_detail_id);
|
|
6232
|
+
const directId = numericTemplateId(node.step_detail_id);
|
|
6233
|
+
if (directConfigured && !directId) {
|
|
6234
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
|
|
6235
|
+
addFlowTemplateRemoteIdError(errors, `data.nodes[${index}].step_detail_id (${nodeName})`, node.step_detail_id);
|
|
6236
|
+
}
|
|
6237
|
+
if (directId) ids.add(directId);
|
|
6238
|
+
});
|
|
6239
|
+
const templates = /* @__PURE__ */ new Map();
|
|
6240
|
+
if (ids.size) {
|
|
6241
|
+
await ensureConfigCapability(profile, "config.step_detail_template.export");
|
|
6242
|
+
const definition = CONFIG_DOMAINS["step-detail-template"];
|
|
6243
|
+
const remoteResults = await Promise.all([...ids].map(async (id) => {
|
|
6244
|
+
try {
|
|
6245
|
+
const remote = await readRemoteConfigDomain(profile, "step-detail-template", id, definition);
|
|
6246
|
+
validateExpectedType("step-detail-template", definition, remote);
|
|
6247
|
+
if (!isRecord3(remote)) {
|
|
6248
|
+
throw new Error("\u8FDC\u7AEF\u54CD\u5E94\u4E0D\u662F\u6A21\u677F\u5BF9\u8C61");
|
|
6249
|
+
}
|
|
6250
|
+
const analysis = analyzeStepDetailTemplate(remote, { allowUndeclaredCustomModules: true });
|
|
6251
|
+
return { id, remote, analysis, error: null };
|
|
6252
|
+
} catch (error) {
|
|
6253
|
+
return {
|
|
6254
|
+
id,
|
|
6255
|
+
remote: null,
|
|
6256
|
+
analysis: null,
|
|
6257
|
+
error: error instanceof Error ? error.message : String(error)
|
|
6258
|
+
};
|
|
6259
|
+
}
|
|
6260
|
+
}));
|
|
6261
|
+
remoteResults.forEach((result) => {
|
|
6262
|
+
if (result.error || !result.remote || !result.analysis) {
|
|
6263
|
+
errors.push(`step_detail_id=${result.id} \u65E0\u6CD5\u5728\u5F53\u524D profile \u56DE\u8BFB\u4E3A type=6 \u73AF\u8282\u8BE6\u60C5\u6A21\u677F\uFF1A${result.error || "\u8FDC\u7AEF\u54CD\u5E94\u65E0\u6548"}\u3002`);
|
|
6264
|
+
return;
|
|
6265
|
+
}
|
|
6266
|
+
errors.push(...result.analysis.errors.map((message) => `step_detail_id=${result.id}: ${message}`));
|
|
6267
|
+
warnings.push(...result.analysis.warnings.map((message) => `step_detail_id=${result.id}: ${message}`));
|
|
6268
|
+
templates.set(result.id, {
|
|
6269
|
+
record: result.remote,
|
|
6270
|
+
analysis: result.analysis,
|
|
6271
|
+
structuralOk: result.analysis.errors.length === 0
|
|
6272
|
+
});
|
|
6273
|
+
});
|
|
6274
|
+
}
|
|
6275
|
+
if (metaConfigured) {
|
|
6276
|
+
const template = metaId ? templates.get(metaId) : void 0;
|
|
6277
|
+
references.push({
|
|
6278
|
+
path: "data.meta.step_detail_id",
|
|
6279
|
+
source: metaId ? "flow_default" : "invalid_flow_default",
|
|
6280
|
+
configured_value: meta.step_detail_id,
|
|
6281
|
+
effective_id: metaId,
|
|
6282
|
+
status: metaId && template?.structuralOk ? "verified" : "invalid",
|
|
6283
|
+
template_name: template?.record.name ?? null,
|
|
6284
|
+
template_type: template?.record.type ?? null,
|
|
6285
|
+
template_structural_ok: template ? template.structuralOk : null,
|
|
6286
|
+
template_errors: template?.analysis.errors ?? [],
|
|
6287
|
+
modules: template?.analysis.moduleNames ?? [],
|
|
6288
|
+
unknown_modules: template?.analysis.unknownModules ?? [],
|
|
6289
|
+
custom_modules: template?.analysis.customModules ?? [],
|
|
6290
|
+
runtime_proof_required: template?.analysis.requiresRuntimeProof ?? false
|
|
6291
|
+
});
|
|
6292
|
+
}
|
|
6293
|
+
nodes.forEach(({ node, index }) => {
|
|
6294
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
|
|
6295
|
+
const directConfigured = !isEmptyTemplateReference(node.step_detail_id);
|
|
6296
|
+
const directId = numericTemplateId(node.step_detail_id);
|
|
6297
|
+
const effectiveId = directConfigured ? directId : metaConfigured ? metaId : null;
|
|
6298
|
+
const template = effectiveId ? templates.get(effectiveId) : void 0;
|
|
6299
|
+
const source = directConfigured ? directId ? "node" : "invalid_node_reference" : metaConfigured ? metaId ? "flow_default" : "invalid_flow_default" : "platform_default_layout";
|
|
6300
|
+
const hideStepDetail = node.hide_step_detail === true;
|
|
6301
|
+
const hasStepForm = !isEmptyTemplateReference(node.form_template);
|
|
6302
|
+
const enableRelatedProjectForm = node.enable_relate_project_form === true;
|
|
6303
|
+
let suitability = hideStepDetail ? "hidden" : source === "invalid_node_reference" || source === "invalid_flow_default" ? "invalid" : effectiveId ? template?.structuralOk ? "verified" : "mismatch" : "platform_default_layout";
|
|
6304
|
+
if (hideStepDetail && effectiveId) {
|
|
6305
|
+
warnings.push(`${nodeName} \u5DF2\u8BBE\u7F6E hide_step_detail=true\uFF0C\u4F46\u4ECD\u7ED1\u5B9A step_detail_id=${effectiveId}\uFF1B\u8BE5\u6A21\u677F\u4E0D\u4F1A\u4F5C\u4E3A\u6B63\u5E38\u73AF\u8282\u8BE6\u60C5\u5165\u53E3\u5C55\u793A\u3002`);
|
|
6306
|
+
}
|
|
6307
|
+
if (!hideStepDetail && template && enableRelatedProjectForm && !template.analysis.hasRelatedProjectForm) {
|
|
6308
|
+
errors.push(`${nodeName} \u542F\u7528\u4E86 enable_relate_project_form\uFF0C\u4F46 step_detail_id=${effectiveId} \u4E0D\u5305\u542B\u201C\u5173\u8054\u9879\u76EE\u8868\u5355\u201D\u6A21\u5757\u3002`);
|
|
6309
|
+
suitability = "mismatch";
|
|
6310
|
+
}
|
|
6311
|
+
if (!hideStepDetail && template && hasStepForm && !template.analysis.hasCurrentStepForm) {
|
|
6312
|
+
if (template.analysis.unknownModules.length) {
|
|
6313
|
+
warnings.push(`${nodeName} \u914D\u7F6E\u4E86\u73AF\u8282 form_template\uFF0C\u4F46 step_detail_id=${effectiveId} \u4EC5\u80FD\u901A\u8FC7\u81EA\u5B9A\u4E49\u6A21\u5757\u63A8\u65AD\u586B\u5199\u80FD\u529B\uFF1B\u5FC5\u987B\u8865\u771F\u5B9E\u9875\u9762\u8BC1\u636E\u3002`);
|
|
6314
|
+
suitability = "runtime_proof_required";
|
|
6315
|
+
} else {
|
|
6316
|
+
errors.push(`${nodeName} \u914D\u7F6E\u4E86\u73AF\u8282 form_template\uFF0C\u4F46 step_detail_id=${effectiveId} \u4E0D\u5305\u542B\u201C\u73AF\u8282\u8868\u5355\u201D\u201C\u4EFB\u610F\u73AF\u8282\u8868\u5355\u201D\u6216\u201C\u590D\u6742\u8868\u5355\u201D\u6A21\u5757\u3002`);
|
|
6317
|
+
suitability = "mismatch";
|
|
6318
|
+
}
|
|
6319
|
+
}
|
|
6320
|
+
references.push({
|
|
6321
|
+
path: `data.nodes[${index}].step_detail_id`,
|
|
6322
|
+
node_id: node.id ?? null,
|
|
6323
|
+
node_name: nodeName,
|
|
6324
|
+
configured_value: directConfigured ? node.step_detail_id : null,
|
|
6325
|
+
direct_id: directId,
|
|
6326
|
+
effective_id: effectiveId,
|
|
6327
|
+
source,
|
|
6328
|
+
hide_step_detail: hideStepDetail,
|
|
6329
|
+
form_template: node.form_template ?? null,
|
|
6330
|
+
enable_relate_project_form: enableRelatedProjectForm,
|
|
6331
|
+
status: source === "invalid_node_reference" || source === "invalid_flow_default" ? "invalid" : effectiveId ? template?.structuralOk ? "verified" : "invalid" : "not_configured",
|
|
6332
|
+
suitability,
|
|
6333
|
+
template_name: template?.record.name ?? null,
|
|
6334
|
+
template_type: template?.record.type ?? null,
|
|
6335
|
+
template_structural_ok: template ? template.structuralOk : null,
|
|
6336
|
+
template_errors: template?.analysis.errors ?? [],
|
|
6337
|
+
modules: template?.analysis.moduleNames ?? [],
|
|
6338
|
+
unknown_modules: template?.analysis.unknownModules ?? [],
|
|
6339
|
+
custom_modules: template?.analysis.customModules ?? [],
|
|
6340
|
+
runtime_proof_required: template?.analysis.requiresRuntimeProof ?? false
|
|
6341
|
+
});
|
|
6342
|
+
});
|
|
6343
|
+
return { errors, warnings, references };
|
|
6344
|
+
}
|
|
6345
|
+
function flowStepDetailRuntimeProofRequired(audit) {
|
|
6346
|
+
return Boolean(audit?.references.some((reference) => reference.runtime_proof_required === true));
|
|
6347
|
+
}
|
|
5969
6348
|
function parseTemplateContent(value, errors) {
|
|
5970
6349
|
const basic = isRecord3(value.basic) ? value.basic : {};
|
|
5971
6350
|
const rawContent = value.content ?? basic.content;
|
|
@@ -6873,6 +7252,14 @@ function normalizePageTemplatePayload(domain, work) {
|
|
|
6873
7252
|
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
6874
7253
|
}
|
|
6875
7254
|
}
|
|
7255
|
+
if (domain === "step-detail-template") {
|
|
7256
|
+
const errors = [];
|
|
7257
|
+
const warnings = [];
|
|
7258
|
+
lintStepDetailTemplateWork(work, errors, warnings);
|
|
7259
|
+
if (errors.length) {
|
|
7260
|
+
throw new Error(`step-detail-template lint failed: ${errors.join("; ")}`);
|
|
7261
|
+
}
|
|
7262
|
+
}
|
|
6876
7263
|
const basic = isRecord3(work.basic) ? work.basic : work;
|
|
6877
7264
|
const rawContent = work.content ?? basic.content;
|
|
6878
7265
|
const type = definition.expectedType;
|
|
@@ -7101,7 +7488,11 @@ function normalizeDatasetPayload(work) {
|
|
|
7101
7488
|
const basic = isRecord3(work.basic) ? work.basic : work;
|
|
7102
7489
|
const scripts = isRecord3(work.scripts) ? work.scripts : work;
|
|
7103
7490
|
const search = isRecord3(work.search) ? work.search : work;
|
|
7104
|
-
const
|
|
7491
|
+
const fieldCandidates = [work.fields, work.dataSetFields, work.data_set_fields, work.relationFields];
|
|
7492
|
+
const fieldSource = fieldCandidates.find(
|
|
7493
|
+
(candidate) => Array.isArray(candidate) && candidate.length > 0 || isRecord3(candidate) && Array.isArray(candidate.selected) && candidate.selected.length > 0
|
|
7494
|
+
) ?? fieldCandidates.find((candidate) => candidate !== void 0 && candidate !== null);
|
|
7495
|
+
const selectedFields = isRecord3(fieldSource) && Array.isArray(fieldSource.selected) ? fieldSource.selected : Array.isArray(fieldSource) ? fieldSource : [];
|
|
7105
7496
|
const payload = {
|
|
7106
7497
|
name: basic.name || "",
|
|
7107
7498
|
basic_table: basic.basicTable ?? basic.basic_table ?? "",
|
|
@@ -7271,7 +7662,6 @@ function normalizeDatasetFieldPayload(work) {
|
|
|
7271
7662
|
}
|
|
7272
7663
|
const sourcePayload = isRecord3(work.x_wewf_source_payload) ? work.x_wewf_source_payload : {};
|
|
7273
7664
|
const payload = {
|
|
7274
|
-
data_set_id: firstNonEmpty(work.data_set_id, work.dataSetId, work.dataset_id, sourcePayload.data_set_id, sourcePayload.dataSetId, sourcePayload.dataset_id),
|
|
7275
7665
|
name: work.name || "",
|
|
7276
7666
|
key: work.key || work.field || "",
|
|
7277
7667
|
type: work.type || "",
|
|
@@ -7285,6 +7675,16 @@ function normalizeDatasetFieldPayload(work) {
|
|
|
7285
7675
|
relation_flow: normalizeRelationFlow(source.relationFlow ?? source.relation_flow ?? {}),
|
|
7286
7676
|
post_script: normalizeOptionalText(work.postScript ?? work.post_script ?? "")
|
|
7287
7677
|
};
|
|
7678
|
+
if (mode === "create") {
|
|
7679
|
+
payload.data_set_id = firstNonEmpty(
|
|
7680
|
+
work.data_set_id,
|
|
7681
|
+
work.dataSetId,
|
|
7682
|
+
work.dataset_id,
|
|
7683
|
+
sourcePayload.data_set_id,
|
|
7684
|
+
sourcePayload.dataSetId,
|
|
7685
|
+
sourcePayload.dataset_id
|
|
7686
|
+
);
|
|
7687
|
+
}
|
|
7288
7688
|
if (work.classify === "virtual") {
|
|
7289
7689
|
const virtual = isRecord3(work.virtual) ? work.virtual : {};
|
|
7290
7690
|
payload.source_table = virtual.sql || "";
|
|
@@ -7518,6 +7918,21 @@ function normalizeRemovedFields(value) {
|
|
|
7518
7918
|
}
|
|
7519
7919
|
return new Set(value.filter((item) => typeof item === "string" && item.length > 0));
|
|
7520
7920
|
}
|
|
7921
|
+
function formTemplateValueFieldType(value) {
|
|
7922
|
+
if (typeof value.field_type === "string" && value.field_type) {
|
|
7923
|
+
return value.field_type;
|
|
7924
|
+
}
|
|
7925
|
+
return typeof value.type === "string" ? value.type : "";
|
|
7926
|
+
}
|
|
7927
|
+
function normalizeStructuredFormTemplateValue(value, ruleType) {
|
|
7928
|
+
const fieldType = typeof value.field_type === "string" ? value.field_type : "";
|
|
7929
|
+
const typeAlias = typeof value.type === "string" ? value.type : "";
|
|
7930
|
+
if (fieldType && typeAlias && fieldType !== typeAlias) {
|
|
7931
|
+
throw new Error(`form-template value type aliases conflict: field_type=${fieldType}, type=${typeAlias}.`);
|
|
7932
|
+
}
|
|
7933
|
+
const resolvedType = fieldType || typeAlias || (typeof ruleType === "string" ? ruleType : "");
|
|
7934
|
+
return resolvedType ? { ...value, field_type: resolvedType } : { ...value };
|
|
7935
|
+
}
|
|
7521
7936
|
function buildStructuredFormTemplatePayload(work) {
|
|
7522
7937
|
const mode = work.mode;
|
|
7523
7938
|
if (mode !== "edit" && mode !== "create") {
|
|
@@ -7559,12 +7974,13 @@ function buildStructuredFormTemplatePayload(work) {
|
|
|
7559
7974
|
if (bundle.rule.field !== ref || bundle.value.field !== ref) {
|
|
7560
7975
|
throw new Error(`form-template field mismatch for ${ref}.`);
|
|
7561
7976
|
}
|
|
7562
|
-
|
|
7977
|
+
const normalizedValue = normalizeStructuredFormTemplateValue(bundle.value, bundle.rule.type);
|
|
7978
|
+
if (formTemplateValueFieldType(normalizedValue) !== bundle.rule.type) {
|
|
7563
7979
|
throw new Error(`form-template field_type mismatch for ${ref}.`);
|
|
7564
7980
|
}
|
|
7565
7981
|
const rule = mode === "create" ? stripKeys(bundle.rule, FORM_RULE_ID_KEYS) : { ...bundle.rule };
|
|
7566
7982
|
const value = normalizeFormTemplateValueValidateMap(
|
|
7567
|
-
mode === "create" ? stripKeys(
|
|
7983
|
+
mode === "create" ? stripKeys(normalizedValue, FORM_VALUE_ID_KEYS) : normalizedValue
|
|
7568
7984
|
);
|
|
7569
7985
|
submitRow.push(rule);
|
|
7570
7986
|
valueItems.push(value);
|
|
@@ -7581,7 +7997,7 @@ function buildStructuredFormTemplatePayload(work) {
|
|
|
7581
7997
|
for (const value of preservedValues) {
|
|
7582
7998
|
const field = typeof value.field === "string" ? value.field : "";
|
|
7583
7999
|
if (field && !seen.has(field) && !removedFields.has(field)) {
|
|
7584
|
-
valueItems.push(normalizeFormTemplateValueValidateMap(value));
|
|
8000
|
+
valueItems.push(normalizeFormTemplateValueValidateMap(normalizeStructuredFormTemplateValue(value)));
|
|
7585
8001
|
}
|
|
7586
8002
|
}
|
|
7587
8003
|
return {
|
|
@@ -7676,6 +8092,37 @@ function validateFormTemplateValueValidateMaps(payload, errors) {
|
|
|
7676
8092
|
}
|
|
7677
8093
|
}
|
|
7678
8094
|
}
|
|
8095
|
+
function validateStructuredFormTemplateFieldTypes(payload, errors) {
|
|
8096
|
+
if (isRecord3(payload.fields)) {
|
|
8097
|
+
for (const [field, bundle] of Object.entries(payload.fields)) {
|
|
8098
|
+
if (!isRecord3(bundle) || !isRecord3(bundle.rule) || !isRecord3(bundle.value)) {
|
|
8099
|
+
continue;
|
|
8100
|
+
}
|
|
8101
|
+
try {
|
|
8102
|
+
const value = normalizeStructuredFormTemplateValue(bundle.value, bundle.rule.type);
|
|
8103
|
+
const valueType = formTemplateValueFieldType(value);
|
|
8104
|
+
if (typeof bundle.rule.type === "string" && valueType !== bundle.rule.type) {
|
|
8105
|
+
errors.push(`form-template field_type mismatch for ${field}.`);
|
|
8106
|
+
}
|
|
8107
|
+
} catch (error) {
|
|
8108
|
+
errors.push(`form-template field ${field}: ${error instanceof Error ? error.message : String(error)}`);
|
|
8109
|
+
}
|
|
8110
|
+
}
|
|
8111
|
+
}
|
|
8112
|
+
if (isRecord3(payload.preserve) && Array.isArray(payload.preserve.value)) {
|
|
8113
|
+
payload.preserve.value.forEach((value, index) => {
|
|
8114
|
+
if (!isRecord3(value)) {
|
|
8115
|
+
return;
|
|
8116
|
+
}
|
|
8117
|
+
try {
|
|
8118
|
+
normalizeStructuredFormTemplateValue(value);
|
|
8119
|
+
} catch (error) {
|
|
8120
|
+
const field = typeof value.field === "string" && value.field ? value.field : `#${index}`;
|
|
8121
|
+
errors.push(`form-template preserved field ${field}: ${error instanceof Error ? error.message : String(error)}`);
|
|
8122
|
+
}
|
|
8123
|
+
});
|
|
8124
|
+
}
|
|
8125
|
+
}
|
|
7679
8126
|
function formTemplateControlOptions(rule, value) {
|
|
7680
8127
|
const candidates = [
|
|
7681
8128
|
rule?.options,
|
|
@@ -7732,7 +8179,7 @@ function validateRadioFormTemplateControl(field, rule, value, errors) {
|
|
|
7732
8179
|
}
|
|
7733
8180
|
function validateFormTemplateControlContracts(payload, errors) {
|
|
7734
8181
|
const validatePair = (field, rule, value) => {
|
|
7735
|
-
const type = typeof rule?.type === "string" ? rule.type :
|
|
8182
|
+
const type = typeof rule?.type === "string" ? rule.type : value ? formTemplateValueFieldType(value) : "";
|
|
7736
8183
|
if (type === "serial_number") {
|
|
7737
8184
|
errors.push(`form-template field ${field} uses legacy serial_number; use BPMAX frontend control type sn_number.`);
|
|
7738
8185
|
}
|
|
@@ -7932,6 +8379,7 @@ function validateStructuredFormTemplateVisualReview(payload, errors) {
|
|
|
7932
8379
|
function validateFormTemplateWorkLint(payload, errors) {
|
|
7933
8380
|
validateFormTemplateNameLength(payload, errors);
|
|
7934
8381
|
validateFormTemplateValueValidateMaps(payload, errors);
|
|
8382
|
+
validateStructuredFormTemplateFieldTypes(payload, errors);
|
|
7935
8383
|
validateFormTemplateControlContracts(payload, errors);
|
|
7936
8384
|
validateFormTemplateHeaderContract(payload, errors);
|
|
7937
8385
|
validateStructuredFormTemplateVisualReview(payload, errors);
|
|
@@ -7970,12 +8418,12 @@ function formTemplateRawToStructured(raw) {
|
|
|
7970
8418
|
continue;
|
|
7971
8419
|
}
|
|
7972
8420
|
const field = rule.field;
|
|
7973
|
-
const value = valueByField.get(field) || {
|
|
8421
|
+
const value = normalizeStructuredFormTemplateValue(valueByField.get(field) || {
|
|
7974
8422
|
field,
|
|
7975
8423
|
title: rule.title,
|
|
7976
8424
|
field_type: rule.type,
|
|
7977
8425
|
value: { type: rule.type }
|
|
7978
|
-
};
|
|
8426
|
+
}, rule.type);
|
|
7979
8427
|
layoutRow.push(field);
|
|
7980
8428
|
fields[field] = { rule, value };
|
|
7981
8429
|
seenFields.add(field);
|
|
@@ -7984,7 +8432,7 @@ function formTemplateRawToStructured(raw) {
|
|
|
7984
8432
|
layout.push(layoutRow);
|
|
7985
8433
|
}
|
|
7986
8434
|
}
|
|
7987
|
-
const preservedValues = values.filter((item) => isRecord3(item) && typeof item.field === "string" && item.field && !seenFields.has(item.field));
|
|
8435
|
+
const preservedValues = values.filter((item) => isRecord3(item) && typeof item.field === "string" && item.field && !seenFields.has(item.field)).map((item) => normalizeStructuredFormTemplateValue(item));
|
|
7988
8436
|
const preserve = pickDefined(raw, [
|
|
7989
8437
|
"status",
|
|
7990
8438
|
"meta_form_id",
|
|
@@ -8879,7 +9327,7 @@ function buildDomainSubmitPayload(domain, work, options = {}, raw) {
|
|
|
8879
9327
|
if (domain === "nav-config") {
|
|
8880
9328
|
return buildNavConfigSubmitPayload(work, isRecord3(raw) ? raw : void 0, options);
|
|
8881
9329
|
}
|
|
8882
|
-
if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "console-template") {
|
|
9330
|
+
if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template" || domain === "console-template") {
|
|
8883
9331
|
return normalizePageTemplatePayload(domain, work);
|
|
8884
9332
|
}
|
|
8885
9333
|
throw new Error(`${CONFIG_SUBMIT_UNSUPPORTED_MESSAGE} Domain: ${domain}.`);
|
|
@@ -9227,6 +9675,10 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
9227
9675
|
if (pluginLint?.errors.length) {
|
|
9228
9676
|
throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
|
|
9229
9677
|
}
|
|
9678
|
+
const stepDetailReferenceAudit = await auditFlowStepDetailReferences(work, profile);
|
|
9679
|
+
if (stepDetailReferenceAudit.errors.length) {
|
|
9680
|
+
throw new Error(`flow-template step-detail reference gate failed: ${stepDetailReferenceAudit.errors.join("; ")}`);
|
|
9681
|
+
}
|
|
9230
9682
|
const expectedConfirm = `create flow-template ${createShell.name}`;
|
|
9231
9683
|
if (confirm3 !== expectedConfirm) {
|
|
9232
9684
|
return {
|
|
@@ -9235,6 +9687,9 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
9235
9687
|
create_endpoint: "/flow/flow_type",
|
|
9236
9688
|
create_payload: createShell,
|
|
9237
9689
|
draft_endpoint: "/flow?flow_type=<platform-flow-type>&publish=2",
|
|
9690
|
+
step_detail_references: stepDetailReferenceAudit.references,
|
|
9691
|
+
step_detail_warnings: stepDetailReferenceAudit.warnings,
|
|
9692
|
+
runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit),
|
|
9238
9693
|
...options.publishLive ? { live_endpoint: "/flow?flow_type=<platform-flow-type>&publish=1" } : {},
|
|
9239
9694
|
next: `Run again with --confirm "${expectedConfirm}" to create.`
|
|
9240
9695
|
};
|
|
@@ -9293,6 +9748,9 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
9293
9748
|
create_response: createResponse,
|
|
9294
9749
|
draft_endpoint: draftEndpoint,
|
|
9295
9750
|
draft_response: draftResponse,
|
|
9751
|
+
step_detail_references: stepDetailReferenceAudit.references,
|
|
9752
|
+
step_detail_warnings: stepDetailReferenceAudit.warnings,
|
|
9753
|
+
runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit),
|
|
9296
9754
|
...liveEndpoint ? { live_endpoint: liveEndpoint, live_response: liveResponse } : {},
|
|
9297
9755
|
readback_hash: hashJson(readback)
|
|
9298
9756
|
};
|
|
@@ -9397,6 +9855,9 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
|
|
|
9397
9855
|
workspace,
|
|
9398
9856
|
name,
|
|
9399
9857
|
preflight,
|
|
9858
|
+
step_detail_references: preflight.step_detail_references,
|
|
9859
|
+
step_detail_warnings: preflight.step_detail_warnings,
|
|
9860
|
+
runtime_proof_required: preflight.runtime_proof_required === true,
|
|
9400
9861
|
operation_plan: dryRunPlan,
|
|
9401
9862
|
post_create_checklist: [
|
|
9402
9863
|
"Save this dry-run response; operation_plan.save_flow_draft.payload_summary must show data.meta.form_template=<published-form-id> before confirm.",
|
|
@@ -9560,6 +10021,9 @@ async function createFlowAppFromWork(config, profile, formWorkFile, flowWorkFile
|
|
|
9560
10021
|
...liveEndpoint ? { flow_live_response: flowLiveResponse, live_endpoint: liveEndpoint } : {},
|
|
9561
10022
|
workspace_bind_response: workspaceBindResponse,
|
|
9562
10023
|
workspace_readback_hash: hashJson(workspaceReadback),
|
|
10024
|
+
step_detail_references: preflight.step_detail_references,
|
|
10025
|
+
step_detail_warnings: preflight.step_detail_warnings,
|
|
10026
|
+
runtime_proof_required: preflight.runtime_proof_required === true,
|
|
9563
10027
|
evidence
|
|
9564
10028
|
};
|
|
9565
10029
|
} catch (error) {
|
|
@@ -9605,6 +10069,38 @@ function normalizeComparableFieldKeys(value) {
|
|
|
9605
10069
|
});
|
|
9606
10070
|
return [...new Set(keys)].sort();
|
|
9607
10071
|
}
|
|
10072
|
+
function canonicalFormTemplateValues(value) {
|
|
10073
|
+
if (!Array.isArray(value)) {
|
|
10074
|
+
return value;
|
|
10075
|
+
}
|
|
10076
|
+
const canonical = value.map((item) => {
|
|
10077
|
+
if (!isRecord3(item)) {
|
|
10078
|
+
return item;
|
|
10079
|
+
}
|
|
10080
|
+
const fieldType = typeof item.field_type === "string" && item.field_type ? item.field_type : typeof item.type === "string" ? item.type : "";
|
|
10081
|
+
if (!fieldType) {
|
|
10082
|
+
return item;
|
|
10083
|
+
}
|
|
10084
|
+
const normalized = { ...item, field_type: fieldType };
|
|
10085
|
+
if (typeof normalized.type === "string" && normalized.type === fieldType) {
|
|
10086
|
+
delete normalized.type;
|
|
10087
|
+
}
|
|
10088
|
+
return normalized;
|
|
10089
|
+
});
|
|
10090
|
+
return canonical.sort((left, right) => {
|
|
10091
|
+
const identity = (item) => {
|
|
10092
|
+
if (!isRecord3(item)) return `~${JSON.stringify(item)}`;
|
|
10093
|
+
for (const key of ["field", "key", "id", "uuid", "guid", "name"]) {
|
|
10094
|
+
const candidate = item[key];
|
|
10095
|
+
if (candidate !== void 0 && candidate !== null && String(candidate).trim()) {
|
|
10096
|
+
return `${key}:${String(candidate).trim()}`;
|
|
10097
|
+
}
|
|
10098
|
+
}
|
|
10099
|
+
return `~${JSON.stringify(item)}`;
|
|
10100
|
+
};
|
|
10101
|
+
return identity(left).localeCompare(identity(right));
|
|
10102
|
+
});
|
|
10103
|
+
}
|
|
9608
10104
|
function normalizeTypedReadbackComparable(domain, value) {
|
|
9609
10105
|
let comparable2 = value;
|
|
9610
10106
|
try {
|
|
@@ -9615,6 +10111,9 @@ function normalizeTypedReadbackComparable(domain, value) {
|
|
|
9615
10111
|
return comparable2;
|
|
9616
10112
|
}
|
|
9617
10113
|
const normalized = { ...comparable2 };
|
|
10114
|
+
if (domain === "form-template") {
|
|
10115
|
+
normalized.value = canonicalFormTemplateValues(normalized.value);
|
|
10116
|
+
}
|
|
9618
10117
|
if (domain === "dataset") {
|
|
9619
10118
|
normalized.refresh_setting = refreshSettingToSubmit(normalized.refresh_setting);
|
|
9620
10119
|
const raw = isRecord3(value) ? value : {};
|
|
@@ -9627,7 +10126,7 @@ function normalizeTypedReadbackComparable(domain, value) {
|
|
|
9627
10126
|
normalized.data_set_id ?? normalized.dataSetId ?? normalized.dataset_id
|
|
9628
10127
|
);
|
|
9629
10128
|
}
|
|
9630
|
-
if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "console-template") {
|
|
10129
|
+
if (domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template" || domain === "console-template") {
|
|
9631
10130
|
if (Object.prototype.hasOwnProperty.call(normalized, "data_set_id")) {
|
|
9632
10131
|
normalized.data_set_id = normalizeComparableId(normalized.data_set_id);
|
|
9633
10132
|
}
|
|
@@ -9685,7 +10184,7 @@ function assertJsonSubset(expected, actual, label) {
|
|
|
9685
10184
|
}
|
|
9686
10185
|
}
|
|
9687
10186
|
function isPageTemplateCreateFinalizeDomain(domain) {
|
|
9688
|
-
return domain === "list-template" || domain === "filter-template" || domain === "project-detail-template";
|
|
10187
|
+
return domain === "list-template" || domain === "filter-template" || domain === "project-detail-template" || domain === "step-detail-template";
|
|
9689
10188
|
}
|
|
9690
10189
|
function pageTemplateCreateNeedsFinalize(domain, payload, comparison) {
|
|
9691
10190
|
if (!isPageTemplateCreateFinalizeDomain(domain)) {
|
|
@@ -9806,7 +10305,11 @@ async function inspectFlowAppContext(config, profile, options) {
|
|
|
9806
10305
|
}
|
|
9807
10306
|
function comparableSubmitPayload(domain, value, options) {
|
|
9808
10307
|
const comparable2 = domain === "form-template" && options.ignoreServerFields ? stripServerFilledFields(value, FORM_TEMPLATE_SERVER_FIELD_KEYS) : value;
|
|
9809
|
-
|
|
10308
|
+
const normalized = normalizeTypedReadbackComparable(domain, comparable2);
|
|
10309
|
+
if (!isRecord3(normalized)) {
|
|
10310
|
+
throw new Error(`${domain} verify comparable payload must be an object.`);
|
|
10311
|
+
}
|
|
10312
|
+
return normalized;
|
|
9810
10313
|
}
|
|
9811
10314
|
function diffMismatchCount(diff) {
|
|
9812
10315
|
const counts = isRecord3(diff?.counts) ? diff.counts : {};
|
|
@@ -9842,24 +10345,68 @@ async function verifyConfigDomain(config, profile, domain, id, options = {}) {
|
|
|
9842
10345
|
const expected = options.expectFile ? await readJsonFile(options.expectFile) : void 0;
|
|
9843
10346
|
const actualComparable = expected ? comparableSubmitPayload(domain, actual, options) : void 0;
|
|
9844
10347
|
const expectedComparable = expected ? comparableSubmitPayload(domain, expected, options) : void 0;
|
|
9845
|
-
const
|
|
10348
|
+
const comparisonOk = expected ? isDeepStrictEqual(actualComparable, expectedComparable) : true;
|
|
10349
|
+
const structuralErrors = [];
|
|
10350
|
+
const semanticErrors = [];
|
|
10351
|
+
const verificationWarnings = [];
|
|
10352
|
+
let stepDetailAnalysis;
|
|
10353
|
+
let stepDetailReferenceAudit;
|
|
10354
|
+
if (domain === "step-detail-template" && isRecord3(actual)) {
|
|
10355
|
+
stepDetailAnalysis = analyzeStepDetailTemplate(actual, { allowUndeclaredCustomModules: true });
|
|
10356
|
+
structuralErrors.push(...stepDetailAnalysis.errors);
|
|
10357
|
+
verificationWarnings.push(...stepDetailAnalysis.warnings);
|
|
10358
|
+
if (isRecord3(expected)) {
|
|
10359
|
+
const expectedAnalysis = analyzeStepDetailTemplate(expected);
|
|
10360
|
+
structuralErrors.push(...expectedAnalysis.errors.map((message) => `expect: ${message}`));
|
|
10361
|
+
verificationWarnings.push(...expectedAnalysis.warnings.map((message) => `expect: ${message}`));
|
|
10362
|
+
}
|
|
10363
|
+
}
|
|
10364
|
+
if (domain === "flow-template" && isRecord3(actual)) {
|
|
10365
|
+
stepDetailReferenceAudit = await auditFlowStepDetailReferences(actual, profile);
|
|
10366
|
+
semanticErrors.push(...stepDetailReferenceAudit.errors);
|
|
10367
|
+
verificationWarnings.push(...stepDetailReferenceAudit.warnings);
|
|
10368
|
+
}
|
|
10369
|
+
const ok = comparisonOk && structuralErrors.length === 0 && semanticErrors.length === 0;
|
|
10370
|
+
const runtimeProofRequired = Boolean(
|
|
10371
|
+
stepDetailAnalysis?.requiresRuntimeProof || stepDetailReferenceAudit?.references.some((reference) => reference.runtime_proof_required === true)
|
|
10372
|
+
);
|
|
9846
10373
|
const diff = expected ? diffJsonComparable(domain, expected, actual, (value) => comparableSubmitPayload(domain, value, options)) : void 0;
|
|
9847
10374
|
const rawDiff = expected && domain === "form-template" && options.ignoreServerFields ? diffJsonComparable(domain, expected, actual, (value) => buildDomainSubmitPayload(domain, value)) : void 0;
|
|
9848
10375
|
const comparisonSkippedReason = expected ? null : "no --expect file provided; verify performed readback only";
|
|
9849
|
-
const serverDefaultDrift = Boolean(
|
|
9850
|
-
const mismatchCount = diffMismatchCount(diff);
|
|
9851
|
-
const reasons =
|
|
10376
|
+
const serverDefaultDrift = Boolean(comparisonOk && rawDiff?.changed === true);
|
|
10377
|
+
const mismatchCount = diffMismatchCount(diff) + structuralErrors.length + semanticErrors.length;
|
|
10378
|
+
const reasons = [
|
|
10379
|
+
...structuralErrors,
|
|
10380
|
+
...semanticErrors,
|
|
10381
|
+
...!comparisonOk ? verifyFailureReasons(false, diff, comparisonSkippedReason) : []
|
|
10382
|
+
];
|
|
9852
10383
|
return {
|
|
9853
10384
|
domain,
|
|
9854
10385
|
id,
|
|
9855
10386
|
ok,
|
|
9856
|
-
structural_ok:
|
|
9857
|
-
semantic_ok:
|
|
10387
|
+
structural_ok: structuralErrors.length === 0,
|
|
10388
|
+
semantic_ok: comparisonOk && semanticErrors.length === 0,
|
|
10389
|
+
structural_errors: structuralErrors,
|
|
10390
|
+
semantic_errors: semanticErrors,
|
|
10391
|
+
warnings: verificationWarnings,
|
|
10392
|
+
runtime_proof_required: runtimeProofRequired,
|
|
9858
10393
|
server_default_drift: serverDefaultDrift,
|
|
9859
10394
|
comparison_skipped_reason: comparisonSkippedReason,
|
|
9860
10395
|
mismatch_count: mismatchCount,
|
|
9861
10396
|
...!ok ? { reason: reasons[0], reasons } : {},
|
|
9862
10397
|
compare: expected ? "normalized_submit_payload" : "readback_only",
|
|
10398
|
+
...stepDetailAnalysis ? {
|
|
10399
|
+
step_detail_template: {
|
|
10400
|
+
modules: stepDetailAnalysis.moduleNames,
|
|
10401
|
+
unknown_modules: stepDetailAnalysis.unknownModules,
|
|
10402
|
+
custom_modules: stepDetailAnalysis.customModules,
|
|
10403
|
+
has_main_column: stepDetailAnalysis.hasMainColumn,
|
|
10404
|
+
has_current_step_form: stepDetailAnalysis.hasCurrentStepForm,
|
|
10405
|
+
has_related_project_form: stepDetailAnalysis.hasRelatedProjectForm,
|
|
10406
|
+
runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
|
|
10407
|
+
}
|
|
10408
|
+
} : {},
|
|
10409
|
+
...stepDetailReferenceAudit ? { step_detail_references: stepDetailReferenceAudit.references } : {},
|
|
9863
10410
|
...expected ? {
|
|
9864
10411
|
expected_hash: expectedComparable ? hashJson(expectedComparable) : null,
|
|
9865
10412
|
actual_hash: actualComparable ? hashJson(actualComparable) : null,
|
|
@@ -10108,7 +10655,27 @@ async function exportConfigDomain(config, profile, domain, id, outDir, options =
|
|
|
10108
10655
|
throw new Error(definition.unsupportedExportReason || `Config export is not implemented for ${domain}.`);
|
|
10109
10656
|
}
|
|
10110
10657
|
await ensureConfigCapability(profile, `${definition.capability}.export`);
|
|
10111
|
-
|
|
10658
|
+
let data;
|
|
10659
|
+
try {
|
|
10660
|
+
data = await readRemoteConfigDomain(profile, domain, id, definition);
|
|
10661
|
+
} catch (error) {
|
|
10662
|
+
if (domain === "form-template" && options.workFormat === "structured" && isJsonParseFailure(error)) {
|
|
10663
|
+
throw configWorkflowError(
|
|
10664
|
+
`\u65E0\u6CD5\u89E3\u6790 form-template ${id} \u7684\u7ED3\u6784\u5316\u5BFC\u51FA\u54CD\u5E94\uFF1B\u8BE5 ID \u53EF\u80FD\u662F\u53EA\u8BFB\u53D1\u5E03\u6001\uFF0C\u6216\u5E73\u53F0\u8FD4\u56DE\u4E86\u622A\u65AD JSON\u3002`,
|
|
10665
|
+
{
|
|
10666
|
+
code: "config_form_template_structured_export_failed",
|
|
10667
|
+
rule_id: "config.form_template.structured_export_response",
|
|
10668
|
+
domain,
|
|
10669
|
+
path: `/form_template/${id}`,
|
|
10670
|
+
published_id: id,
|
|
10671
|
+
draft_id: null,
|
|
10672
|
+
request_phase: "readback",
|
|
10673
|
+
suggestion: "\u5148\u4ECE\u6D41\u7A0B meta.form_template \u786E\u8BA4\u53D1\u5E03\u6001 ID\uFF0C\u518D\u4F7F\u7528\u5E73\u53F0\u8FD4\u56DE\u7684 origin_template_id \u5BF9\u5E94\u8349\u7A3F ID\u6267\u884C structured export\u3002"
|
|
10674
|
+
}
|
|
10675
|
+
);
|
|
10676
|
+
}
|
|
10677
|
+
throw error;
|
|
10678
|
+
}
|
|
10112
10679
|
if (domain === "form-template") {
|
|
10113
10680
|
assertFormTemplateDraftId(id, data, "export");
|
|
10114
10681
|
}
|
|
@@ -10157,11 +10724,19 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
10157
10724
|
throw new Error("Config build requires a meta file produced by `bpmax-cli config <domain> export`.");
|
|
10158
10725
|
}
|
|
10159
10726
|
const raw = typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
|
|
10727
|
+
let stepDetailReferenceAudit;
|
|
10728
|
+
let stepDetailAnalysis;
|
|
10160
10729
|
if (domain === "flow-template" && isRecord3(work)) {
|
|
10161
10730
|
const pluginLint = await runFlowTemplatePluginLint(work, options.pluginLint);
|
|
10162
10731
|
if (pluginLint?.errors.length) {
|
|
10163
10732
|
throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
|
|
10164
10733
|
}
|
|
10734
|
+
if (options.pluginLint?.profile) {
|
|
10735
|
+
stepDetailReferenceAudit = await auditFlowStepDetailReferences(work, options.pluginLint.profile);
|
|
10736
|
+
if (stepDetailReferenceAudit.errors.length) {
|
|
10737
|
+
throw new Error(`flow-template step-detail reference gate failed: ${stepDetailReferenceAudit.errors.join("; ")}`);
|
|
10738
|
+
}
|
|
10739
|
+
}
|
|
10165
10740
|
}
|
|
10166
10741
|
if (domain === "form-template" && isRecord3(work)) {
|
|
10167
10742
|
const errors = [];
|
|
@@ -10178,7 +10753,16 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
10178
10753
|
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
10179
10754
|
}
|
|
10180
10755
|
}
|
|
10181
|
-
|
|
10756
|
+
if (domain === "step-detail-template" && isRecord3(work)) {
|
|
10757
|
+
const errors = [];
|
|
10758
|
+
const warnings = [];
|
|
10759
|
+
stepDetailAnalysis = lintStepDetailTemplateWork(work, errors, warnings);
|
|
10760
|
+
if (errors.length) {
|
|
10761
|
+
throw new Error(`step-detail-template lint failed: ${errors.join("; ")}`);
|
|
10762
|
+
}
|
|
10763
|
+
}
|
|
10764
|
+
const payloadWork = domain === "dataset-field" && createMode && isRecord3(work) ? { ...work, mode: "create" } : work;
|
|
10765
|
+
const payload = buildDomainSubmitPayload(domain, payloadWork, options, raw);
|
|
10182
10766
|
if (domain === "flow-template" && options.publishLive) {
|
|
10183
10767
|
payload.publish_live = true;
|
|
10184
10768
|
}
|
|
@@ -10195,10 +10779,36 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
10195
10779
|
built_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
10196
10780
|
meta: submitMeta,
|
|
10197
10781
|
base_hash: createMode ? null : typeof meta.base_hash === "string" ? meta.base_hash : null,
|
|
10198
|
-
payload
|
|
10782
|
+
payload,
|
|
10783
|
+
...stepDetailReferenceAudit ? {
|
|
10784
|
+
step_detail_references: stepDetailReferenceAudit.references,
|
|
10785
|
+
step_detail_warnings: stepDetailReferenceAudit.warnings,
|
|
10786
|
+
runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
|
|
10787
|
+
} : {},
|
|
10788
|
+
...stepDetailAnalysis ? {
|
|
10789
|
+
step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
|
|
10790
|
+
step_detail_lint: stepDetailLintArtifact(work),
|
|
10791
|
+
step_detail_warnings: stepDetailAnalysis.warnings,
|
|
10792
|
+
runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
|
|
10793
|
+
} : {}
|
|
10199
10794
|
};
|
|
10200
10795
|
await writeJsonFile(outFile, result);
|
|
10201
|
-
return {
|
|
10796
|
+
return {
|
|
10797
|
+
domain,
|
|
10798
|
+
work_file: workFile,
|
|
10799
|
+
submit_file: outFile,
|
|
10800
|
+
payload_keys: Object.keys(payload),
|
|
10801
|
+
...stepDetailReferenceAudit ? {
|
|
10802
|
+
step_detail_references: stepDetailReferenceAudit.references,
|
|
10803
|
+
warnings: stepDetailReferenceAudit.warnings,
|
|
10804
|
+
runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
|
|
10805
|
+
} : {},
|
|
10806
|
+
...stepDetailAnalysis ? {
|
|
10807
|
+
step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
|
|
10808
|
+
warnings: stepDetailAnalysis.warnings,
|
|
10809
|
+
runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
|
|
10810
|
+
} : {}
|
|
10811
|
+
};
|
|
10202
10812
|
}
|
|
10203
10813
|
async function runFlowTemplatePluginLint(flowWork, options = {}) {
|
|
10204
10814
|
if (!options.profile) {
|
|
@@ -10295,12 +10905,21 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
10295
10905
|
const errors = [];
|
|
10296
10906
|
const warnings = [];
|
|
10297
10907
|
let pluginLint;
|
|
10908
|
+
let stepDetailAnalysis;
|
|
10909
|
+
let stepDetailReferenceAudit;
|
|
10298
10910
|
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
10299
10911
|
errors.push("Config work file must be a JSON object.");
|
|
10300
10912
|
} else {
|
|
10301
10913
|
if (Object.prototype.hasOwnProperty.call(value, "classify") && Object.prototype.hasOwnProperty.call(value, "source_table")) {
|
|
10302
10914
|
lintDatasetFieldWork(value, errors);
|
|
10303
10915
|
}
|
|
10916
|
+
if (options.domain === "dataset") {
|
|
10917
|
+
try {
|
|
10918
|
+
normalizeDatasetPayload(value);
|
|
10919
|
+
} catch (error) {
|
|
10920
|
+
errors.push(error instanceof Error ? error.message : String(error));
|
|
10921
|
+
}
|
|
10922
|
+
}
|
|
10304
10923
|
if (Object.prototype.hasOwnProperty.call(value, "content")) {
|
|
10305
10924
|
lintTemplateFieldReferences(value, errors);
|
|
10306
10925
|
}
|
|
@@ -10308,6 +10927,9 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
10308
10927
|
if (shouldLintFormTemplate) {
|
|
10309
10928
|
validateFormTemplateWorkLint(value, errors);
|
|
10310
10929
|
}
|
|
10930
|
+
if (options.domain === "step-detail-template") {
|
|
10931
|
+
stepDetailAnalysis = lintStepDetailTemplateWork(value, errors, warnings);
|
|
10932
|
+
}
|
|
10311
10933
|
if ((Object.prototype.hasOwnProperty.call(value, "content") || isRecord3(value.basic)) && pageTemplateType(value) === 1) {
|
|
10312
10934
|
validateListTemplateActionGate(value, errors);
|
|
10313
10935
|
}
|
|
@@ -10334,6 +10956,12 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
10334
10956
|
errors.push(...pluginLint.errors);
|
|
10335
10957
|
warnings.push(...pluginLint.warnings);
|
|
10336
10958
|
}
|
|
10959
|
+
const profile = options.pluginLint?.profile;
|
|
10960
|
+
if (profile) {
|
|
10961
|
+
stepDetailReferenceAudit = await auditFlowStepDetailReferences(flowWork, profile);
|
|
10962
|
+
errors.push(...stepDetailReferenceAudit.errors.filter((error) => !errors.includes(error)));
|
|
10963
|
+
warnings.push(...stepDetailReferenceAudit.warnings);
|
|
10964
|
+
}
|
|
10337
10965
|
if (flowWork.mode === "create") {
|
|
10338
10966
|
validateFlowTemplateFormDrivenCreateBaseline(flowWork, errors, { context: "flow-template create" });
|
|
10339
10967
|
} else {
|
|
@@ -10346,6 +10974,21 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
10346
10974
|
ok: errors.length === 0,
|
|
10347
10975
|
errors,
|
|
10348
10976
|
warnings,
|
|
10977
|
+
...stepDetailAnalysis ? {
|
|
10978
|
+
step_detail_template: {
|
|
10979
|
+
modules: stepDetailAnalysis.moduleNames,
|
|
10980
|
+
unknown_modules: stepDetailAnalysis.unknownModules,
|
|
10981
|
+
custom_modules: stepDetailAnalysis.customModules,
|
|
10982
|
+
has_main_column: stepDetailAnalysis.hasMainColumn,
|
|
10983
|
+
has_current_step_form: stepDetailAnalysis.hasCurrentStepForm,
|
|
10984
|
+
has_related_project_form: stepDetailAnalysis.hasRelatedProjectForm,
|
|
10985
|
+
runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
|
|
10986
|
+
}
|
|
10987
|
+
} : {},
|
|
10988
|
+
...stepDetailReferenceAudit ? {
|
|
10989
|
+
step_detail_references: stepDetailReferenceAudit.references,
|
|
10990
|
+
runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
|
|
10991
|
+
} : {},
|
|
10349
10992
|
...pluginLint ? { plugin_lints: pluginLint.plugin_lints } : {},
|
|
10350
10993
|
checked_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
10351
10994
|
};
|
|
@@ -10625,6 +11268,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10625
11268
|
if (meta.workspace !== profile.config.workspace) {
|
|
10626
11269
|
throw new Error(`Config submit metadata workspace mismatch. Expected ${profile.config.workspace}, got ${String(meta.workspace)}.`);
|
|
10627
11270
|
}
|
|
11271
|
+
let stepDetailAnalysis;
|
|
10628
11272
|
const submitMode = isRecord3(meta) ? meta.mode : void 0;
|
|
10629
11273
|
if (submitMode === "create" && domain !== "form-template") {
|
|
10630
11274
|
if (!definition.createPath || !definition.createMethod) {
|
|
@@ -10644,6 +11288,12 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10644
11288
|
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
10645
11289
|
}
|
|
10646
11290
|
}
|
|
11291
|
+
if (domain === "step-detail-template") {
|
|
11292
|
+
stepDetailAnalysis = analyzeStepDetailTemplate(stepDetailPayloadWithLintArtifact(submit.payload, submit));
|
|
11293
|
+
if (stepDetailAnalysis.errors.length) {
|
|
11294
|
+
throw new Error(`step-detail-template lint failed: ${stepDetailAnalysis.errors.join("; ")}`);
|
|
11295
|
+
}
|
|
11296
|
+
}
|
|
10647
11297
|
if (domain === "dataset-field") {
|
|
10648
11298
|
validateDatasetFieldCreatePayload(submit.payload);
|
|
10649
11299
|
}
|
|
@@ -10660,6 +11310,11 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10660
11310
|
endpoint: definition.createPath,
|
|
10661
11311
|
method: definition.createMethod,
|
|
10662
11312
|
payload: submit.payload,
|
|
11313
|
+
...stepDetailAnalysis ? {
|
|
11314
|
+
step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
|
|
11315
|
+
warnings: stepDetailAnalysis.warnings,
|
|
11316
|
+
runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
|
|
11317
|
+
} : {},
|
|
10663
11318
|
next: `Run again with --confirm "${expectedConfirm2}" to submit.`
|
|
10664
11319
|
};
|
|
10665
11320
|
}
|
|
@@ -10733,6 +11388,11 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10733
11388
|
method: definition.createMethod,
|
|
10734
11389
|
response: response2,
|
|
10735
11390
|
readback_hash: readbackHash,
|
|
11391
|
+
...stepDetailAnalysis ? {
|
|
11392
|
+
step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
|
|
11393
|
+
warnings: stepDetailAnalysis.warnings,
|
|
11394
|
+
runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
|
|
11395
|
+
} : {},
|
|
10736
11396
|
...readbackMismatches.length ? { readback_mismatches: readbackMismatches.slice(0, 10) } : {},
|
|
10737
11397
|
...readbackError ? { readback_error: readbackError } : {},
|
|
10738
11398
|
...finalizeAttempted ? {
|
|
@@ -10745,6 +11405,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10745
11405
|
}
|
|
10746
11406
|
await ensureConfigCapability(profile, `${definition.capability}.submit`);
|
|
10747
11407
|
await ensureConfigCapability(profile, `${definition.capability}.export`);
|
|
11408
|
+
let stepDetailReferenceAudit;
|
|
10748
11409
|
if (domain === "flow-template") {
|
|
10749
11410
|
validateFlowTemplateRemoteTemplateRefs(submit.payload);
|
|
10750
11411
|
validateFlowTemplateProjectAfterCreatePath(submit.payload);
|
|
@@ -10766,6 +11427,10 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10766
11427
|
if (pluginLint?.errors.length) {
|
|
10767
11428
|
throw new Error(`flow-template plugin lint failed: ${pluginLint.errors.join("; ")}`);
|
|
10768
11429
|
}
|
|
11430
|
+
stepDetailReferenceAudit = await auditFlowStepDetailReferences(submit.payload, profile);
|
|
11431
|
+
if (stepDetailReferenceAudit.errors.length) {
|
|
11432
|
+
throw new Error(`flow-template step-detail reference gate failed: ${stepDetailReferenceAudit.errors.join("; ")}`);
|
|
11433
|
+
}
|
|
10769
11434
|
}
|
|
10770
11435
|
if (domain === "list-template") {
|
|
10771
11436
|
validateListTemplateActionGate(submit.payload);
|
|
@@ -10778,6 +11443,12 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10778
11443
|
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
10779
11444
|
}
|
|
10780
11445
|
}
|
|
11446
|
+
if (domain === "step-detail-template") {
|
|
11447
|
+
stepDetailAnalysis = analyzeStepDetailTemplate(stepDetailPayloadWithLintArtifact(submit.payload, submit));
|
|
11448
|
+
if (stepDetailAnalysis.errors.length) {
|
|
11449
|
+
throw new Error(`step-detail-template lint failed: ${stepDetailAnalysis.errors.join("; ")}`);
|
|
11450
|
+
}
|
|
11451
|
+
}
|
|
10781
11452
|
if (domain === "form-template" && submitMode === "create") {
|
|
10782
11453
|
validateNonEmptyFormCreatePayload(submit.payload);
|
|
10783
11454
|
await ensureConfigCapability(profile, `${definition.capability}.create`);
|
|
@@ -10868,6 +11539,13 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10868
11539
|
let endpoint = definition.submitPath(id);
|
|
10869
11540
|
let submitPayload = submit.payload;
|
|
10870
11541
|
let publishMode;
|
|
11542
|
+
if (domain === "dataset-field") {
|
|
11543
|
+
const datasetFieldPayload = { ...submit.payload };
|
|
11544
|
+
delete datasetFieldPayload.data_set_id;
|
|
11545
|
+
delete datasetFieldPayload.dataSetId;
|
|
11546
|
+
delete datasetFieldPayload.dataset_id;
|
|
11547
|
+
submitPayload = datasetFieldPayload;
|
|
11548
|
+
}
|
|
10871
11549
|
if (domain === "flow-template") {
|
|
10872
11550
|
const flowPayload = { ...submit.payload };
|
|
10873
11551
|
if (options.publishLive) {
|
|
@@ -10884,6 +11562,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10884
11562
|
})}`;
|
|
10885
11563
|
submitPayload = flowPayload;
|
|
10886
11564
|
}
|
|
11565
|
+
const mutationDiff = diffJsonNormalized(domain, current, submitPayload);
|
|
10887
11566
|
if (confirm3 !== expectedConfirm) {
|
|
10888
11567
|
return {
|
|
10889
11568
|
...dryRunFields(expectedConfirm),
|
|
@@ -10893,18 +11572,63 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10893
11572
|
method: definition.submitMethod,
|
|
10894
11573
|
payload: submitPayload,
|
|
10895
11574
|
...publishMode ? { publish_mode: publishMode } : {},
|
|
10896
|
-
|
|
11575
|
+
...stepDetailReferenceAudit ? {
|
|
11576
|
+
step_detail_references: stepDetailReferenceAudit.references,
|
|
11577
|
+
step_detail_warnings: stepDetailReferenceAudit.warnings,
|
|
11578
|
+
runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
|
|
11579
|
+
} : {},
|
|
11580
|
+
...stepDetailAnalysis ? {
|
|
11581
|
+
step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
|
|
11582
|
+
warnings: stepDetailAnalysis.warnings,
|
|
11583
|
+
runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
|
|
11584
|
+
} : {},
|
|
11585
|
+
diff: mutationDiff,
|
|
10897
11586
|
current_hash: currentHash,
|
|
10898
11587
|
next: `Run again with --confirm "${expectedConfirm}" to submit.`
|
|
10899
11588
|
};
|
|
10900
11589
|
}
|
|
10901
11590
|
const client = createApiClient(profile);
|
|
10902
|
-
|
|
10903
|
-
|
|
10904
|
-
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
11591
|
+
let response;
|
|
11592
|
+
try {
|
|
11593
|
+
response = await apiRequest(
|
|
11594
|
+
client,
|
|
11595
|
+
definition.submitMethod,
|
|
11596
|
+
endpoint,
|
|
11597
|
+
{ data: submitPayload, capability: `${definition.capability}.submit` }
|
|
11598
|
+
);
|
|
11599
|
+
} catch (error) {
|
|
11600
|
+
let remoteWriteState = "unknown";
|
|
11601
|
+
let readbackConfirmed = false;
|
|
11602
|
+
let readbackError;
|
|
11603
|
+
try {
|
|
11604
|
+
const safeReadback = await readRemoteConfigDomain(profile, domain, id, definition);
|
|
11605
|
+
readbackConfirmed = compareTypedReadback(domain, submitPayload, safeReadback).ok;
|
|
11606
|
+
remoteWriteState = readbackConfirmed ? "confirmed" : hashJson(safeReadback) === currentHash ? "not_started" : "unknown";
|
|
11607
|
+
} catch (readError) {
|
|
11608
|
+
readbackError = readError instanceof Error ? readError.message : String(readError ?? "");
|
|
11609
|
+
}
|
|
11610
|
+
const status = errorStatus(error);
|
|
11611
|
+
const remoteError = error instanceof Error ? error.message : String(error ?? "");
|
|
11612
|
+
const changedPaths = Array.isArray(mutationDiff.changed_paths) ? mutationDiff.changed_paths : [];
|
|
11613
|
+
throw configWorkflowError(
|
|
11614
|
+
`${domain} \u63D0\u4EA4\u5728\u8FDC\u7AEF\u5199\u5165\u9636\u6BB5\u5931\u8D25${status ? `\uFF08HTTP ${status}\uFF09` : ""}\uFF1B\u8FDC\u7AEF\u5199\u5165\u72B6\u6001\u4E3A ${remoteWriteState}\u3002${remoteWriteState === "unknown" ? " \u5728\u5B8C\u6210\u53EA\u8BFB\u56DE\u8BFB\u524D\u4E0D\u8981\u91CD\u590D\u63D0\u4EA4\u3002" : ""}`,
|
|
11615
|
+
{
|
|
11616
|
+
code: "config_remote_mutation_failed",
|
|
11617
|
+
rule_id: "config.submit.remote_mutation",
|
|
11618
|
+
domain,
|
|
11619
|
+
path: endpoint,
|
|
11620
|
+
request_phase: "mutation",
|
|
11621
|
+
http_status: status ?? null,
|
|
11622
|
+
remote_error: remoteError,
|
|
11623
|
+
changed_paths: changedPaths,
|
|
11624
|
+
remote_write_state: remoteWriteState,
|
|
11625
|
+
remote_submitted: remoteWriteState === "confirmed",
|
|
11626
|
+
readback_confirmed: readbackConfirmed,
|
|
11627
|
+
...readbackError ? { readback_error: readbackError } : {},
|
|
11628
|
+
suggestion: `\u5148\u6267\u884C bpmax-cli config ${domain} verify --id ${id} --profile ${profile.name} --format json\uFF1B\u786E\u8BA4\u7EBF\u4E0A\u72B6\u6001\u540E\u518D\u51B3\u5B9A\u662F\u5426\u91CD\u8BD5\u3002`
|
|
11629
|
+
}
|
|
11630
|
+
);
|
|
11631
|
+
}
|
|
10908
11632
|
let publishResponse = null;
|
|
10909
11633
|
if (domain === "form-template") {
|
|
10910
11634
|
publishResponse = await apiRequest(
|
|
@@ -10923,6 +11647,16 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
10923
11647
|
endpoint,
|
|
10924
11648
|
method: definition.submitMethod,
|
|
10925
11649
|
...publishMode ? { publish_mode: publishMode } : {},
|
|
11650
|
+
...stepDetailReferenceAudit ? {
|
|
11651
|
+
step_detail_references: stepDetailReferenceAudit.references,
|
|
11652
|
+
step_detail_warnings: stepDetailReferenceAudit.warnings,
|
|
11653
|
+
runtime_proof_required: flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
|
|
11654
|
+
} : {},
|
|
11655
|
+
...stepDetailAnalysis ? {
|
|
11656
|
+
step_detail_template: stepDetailAnalysisEvidence(stepDetailAnalysis),
|
|
11657
|
+
warnings: stepDetailAnalysis.warnings,
|
|
11658
|
+
runtime_proof_required: stepDetailAnalysis.requiresRuntimeProof
|
|
11659
|
+
} : {},
|
|
10926
11660
|
response,
|
|
10927
11661
|
publish_response: publishResponse,
|
|
10928
11662
|
readback_hash: readback.readback_hash
|
|
@@ -13280,16 +14014,21 @@ function registerConfigCommands(program2) {
|
|
|
13280
14014
|
});
|
|
13281
14015
|
printResult(options.format, result);
|
|
13282
14016
|
});
|
|
13283
|
-
domainCommand.command("diff").description(`Compare raw/work or inspect a submit payload for ${domain}`).option("--raw <file>", "Raw baseline JSON file").option("--work <file>", "Work JSON file").option("--submit <file>", "Submit JSON file").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
14017
|
+
domainCommand.command("diff").description(`Compare raw/work or inspect a submit payload for ${domain}`).option("--raw <file>", "Raw baseline JSON file").option("--work <file>", "Work JSON file").option("--submit <file>", "Submit JSON file").option("--payload <file>", "Alias for --submit").option("--profile <profile>", "Profile name; accepted for command consistency").option("--format <format>", "Output format", "pretty").action(async (options) => {
|
|
14018
|
+
if (options.submit && options.payload && path9.resolve(options.submit) !== path9.resolve(options.payload)) {
|
|
14019
|
+
throw new Error(`config ${domain} diff received different --submit and --payload files; provide only one artifact.`);
|
|
14020
|
+
}
|
|
14021
|
+
const submitFile = options.submit ?? options.payload;
|
|
13284
14022
|
const raw = options.raw ? await readJsonFile(options.raw) : void 0;
|
|
13285
14023
|
const work = options.work ? await readJsonFile(options.work) : void 0;
|
|
13286
|
-
const submit =
|
|
14024
|
+
const submit = submitFile ? await readJsonFile(submitFile) : void 0;
|
|
13287
14025
|
const diff = raw && work ? diffJsonNormalized(domain, raw, work) : void 0;
|
|
13288
14026
|
printResult(options.format, {
|
|
13289
14027
|
domain,
|
|
14028
|
+
profile: options.profile ?? null,
|
|
13290
14029
|
raw_file: options.raw || null,
|
|
13291
14030
|
work_file: options.work || null,
|
|
13292
|
-
submit_file:
|
|
14031
|
+
submit_file: submitFile || null,
|
|
13293
14032
|
...diff || {},
|
|
13294
14033
|
submit_preview: submit || null
|
|
13295
14034
|
});
|
|
@@ -13421,6 +14160,7 @@ import {
|
|
|
13421
14160
|
open as open2,
|
|
13422
14161
|
readdir as readdir3,
|
|
13423
14162
|
readFile as readFile11,
|
|
14163
|
+
realpath as realpath2,
|
|
13424
14164
|
rename,
|
|
13425
14165
|
rm as rm4,
|
|
13426
14166
|
stat as stat6,
|
|
@@ -14739,6 +15479,12 @@ async function validateExecutionManifestStep(options) {
|
|
|
14739
15479
|
fail(`execution manifest current step is ${manifest.case_id}/${manifest.current_step_id ?? "<complete>"}, not ${options.caseId}/${options.caseStepId}`, { rule_id: "test_suite.run.step_mismatch", path: manifestPath });
|
|
14740
15480
|
}
|
|
14741
15481
|
await assertExecutionManifestFresh(manifest, manifestPath);
|
|
15482
|
+
if (options.profile && manifest.profile !== options.profile) {
|
|
15483
|
+
fail(`execution manifest profile is ${manifest.profile}, not ${options.profile}`, {
|
|
15484
|
+
rule_id: "test_suite.run.profile_mismatch",
|
|
15485
|
+
path: manifestPath
|
|
15486
|
+
});
|
|
15487
|
+
}
|
|
14742
15488
|
const step = currentManifestStep(manifest);
|
|
14743
15489
|
if (!step || step.status !== "planned") fail("execution manifest has no runnable current step", { rule_id: "test_suite.run.no_current_step", path: manifestPath });
|
|
14744
15490
|
if (options.runners?.length && !options.runners.includes(step.runner)) {
|
|
@@ -14746,6 +15492,49 @@ async function validateExecutionManifestStep(options) {
|
|
|
14746
15492
|
}
|
|
14747
15493
|
return { manifestPath, manifest, step };
|
|
14748
15494
|
}
|
|
15495
|
+
async function preflightExecutionEvidenceDirectory(options) {
|
|
15496
|
+
const manifestPath = path10.resolve(options.manifest);
|
|
15497
|
+
const manifest = await readExecutionManifest(manifestPath);
|
|
15498
|
+
await assertExecutionManifestFresh(manifest, manifestPath);
|
|
15499
|
+
const runDir = path10.dirname(manifestPath);
|
|
15500
|
+
const evidenceDir = path10.resolve(options.evidenceDir);
|
|
15501
|
+
if (!pathInside(runDir, evidenceDir)) {
|
|
15502
|
+
fail("formal execution evidence must stay inside the current report run directory", {
|
|
15503
|
+
rule_id: "test_suite.run.evidence_scope",
|
|
15504
|
+
path: evidenceDir,
|
|
15505
|
+
suggestion: `Use an evidence directory under ${runDir}.`
|
|
15506
|
+
});
|
|
15507
|
+
}
|
|
15508
|
+
try {
|
|
15509
|
+
await mkdir9(evidenceDir, { recursive: true });
|
|
15510
|
+
} catch (error) {
|
|
15511
|
+
fail(`formal execution evidence directory cannot be created: ${error instanceof Error ? error.message : String(error)}`, {
|
|
15512
|
+
rule_id: "test_suite.run.evidence_unwritable",
|
|
15513
|
+
path: evidenceDir
|
|
15514
|
+
});
|
|
15515
|
+
}
|
|
15516
|
+
const [realRunDir, realEvidenceDir] = await Promise.all([realpath2(runDir), realpath2(evidenceDir)]);
|
|
15517
|
+
if (!pathInside(realRunDir, realEvidenceDir)) {
|
|
15518
|
+
fail("formal execution evidence directory resolves outside the current report run directory", {
|
|
15519
|
+
rule_id: "test_suite.run.evidence_scope",
|
|
15520
|
+
path: evidenceDir,
|
|
15521
|
+
suggestion: `Remove the symlink and use a real directory under ${runDir}.`
|
|
15522
|
+
});
|
|
15523
|
+
}
|
|
15524
|
+
const probe = path10.join(evidenceDir, `.bpmax-write-probe-${process.pid}-${Date.now()}`);
|
|
15525
|
+
try {
|
|
15526
|
+
await writeFile9(probe, "ok", "utf8");
|
|
15527
|
+
await readFile11(probe, "utf8");
|
|
15528
|
+
} catch (error) {
|
|
15529
|
+
fail(`formal execution evidence directory is not writable: ${error instanceof Error ? error.message : String(error)}`, {
|
|
15530
|
+
rule_id: "test_suite.run.evidence_unwritable",
|
|
15531
|
+
path: evidenceDir
|
|
15532
|
+
});
|
|
15533
|
+
} finally {
|
|
15534
|
+
await unlink(probe).catch(() => void 0);
|
|
15535
|
+
}
|
|
15536
|
+
return { manifest: manifestPath, evidence_dir: evidenceDir };
|
|
15537
|
+
}
|
|
14749
15538
|
async function appendExecutionManifestEvidence(options) {
|
|
14750
15539
|
await withExecutionManifestLock(options.manifest, async () => {
|
|
14751
15540
|
const validated = await validateExecutionManifestStep(options);
|
|
@@ -14755,9 +15544,10 @@ async function appendExecutionManifestEvidence(options) {
|
|
|
14755
15544
|
await writeExecutionManifest(validated.manifestPath, validated.manifest, true);
|
|
14756
15545
|
});
|
|
14757
15546
|
}
|
|
14758
|
-
async function nextTestSuiteRunStep(manifestPath) {
|
|
15547
|
+
async function nextTestSuiteRunStep(manifestPath, profile) {
|
|
14759
15548
|
const manifest = await readExecutionManifest(manifestPath);
|
|
14760
15549
|
await assertExecutionManifestFresh(manifest, path10.resolve(manifestPath));
|
|
15550
|
+
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
14761
15551
|
const step = currentManifestStep(manifest);
|
|
14762
15552
|
if (!step) return { ok: true, complete: true, result: manifest.result, execution: manifest };
|
|
14763
15553
|
if (step.status !== "planned") fail("current execution step is not planned", { rule_id: "test_suite.run.no_current_step", path: manifestPath });
|
|
@@ -14804,9 +15594,10 @@ async function recordTestSuiteRunStep(options) {
|
|
|
14804
15594
|
};
|
|
14805
15595
|
});
|
|
14806
15596
|
}
|
|
14807
|
-
async function testSuiteRunStatus(manifestPath) {
|
|
15597
|
+
async function testSuiteRunStatus(manifestPath, profile) {
|
|
14808
15598
|
const manifest = await readExecutionManifest(manifestPath);
|
|
14809
15599
|
await assertExecutionManifestFresh(manifest, path10.resolve(manifestPath));
|
|
15600
|
+
if (profile && manifest.profile !== profile) fail(`execution manifest profile is ${manifest.profile}, not ${profile}`, { rule_id: "test_suite.run.profile_mismatch", path: manifestPath });
|
|
14810
15601
|
return { ok: true, execution: manifest };
|
|
14811
15602
|
}
|
|
14812
15603
|
async function indexSuite(root = DEFAULT_SUITE_ROOT, includeInactive = false) {
|
|
@@ -15502,10 +16293,14 @@ function linesForCase(text5, caseId) {
|
|
|
15502
16293
|
const pattern = new RegExp(`\\b${escaped}\\b`);
|
|
15503
16294
|
return text5.split(/\r?\n/).filter((line) => pattern.test(line));
|
|
15504
16295
|
}
|
|
15505
|
-
async function lintReport(root = DEFAULT_REPORT_ROOT) {
|
|
16296
|
+
async function lintReport(root = DEFAULT_REPORT_ROOT, options = {}) {
|
|
15506
16297
|
if (!await exists3(root)) return [`report root not found: ${root}`];
|
|
15507
16298
|
const errors = [];
|
|
15508
|
-
|
|
16299
|
+
const resolvedRoot = path10.resolve(root);
|
|
16300
|
+
const candidateDirs = RUN_RE.test(path10.basename(resolvedRoot)) ? [resolvedRoot] : (await scenarioDirs(resolvedRoot)).filter((dir) => RUN_RE.test(path10.basename(dir)));
|
|
16301
|
+
if (candidateDirs.length === 0) return [`report run not found under: ${resolvedRoot}`];
|
|
16302
|
+
const runDirs = options.allRuns ? candidateDirs : candidateDirs.slice(-1);
|
|
16303
|
+
for (const runDir of runDirs) {
|
|
15509
16304
|
const runName = path10.basename(runDir);
|
|
15510
16305
|
if (!RUN_RE.test(runName)) {
|
|
15511
16306
|
errors.push(`${runDir}: run directory name must be YYYYMMDD-NNN`);
|
|
@@ -16620,7 +17415,7 @@ function registerStepCommands(program2) {
|
|
|
16620
17415
|
}
|
|
16621
17416
|
|
|
16622
17417
|
// src/commands/e2e.ts
|
|
16623
|
-
async function requireE2eExecutionBinding(options, runners) {
|
|
17418
|
+
async function requireE2eExecutionBinding(options, runners, evidenceDir) {
|
|
16624
17419
|
if (options.diagnostic) return;
|
|
16625
17420
|
if (!options.executionManifest || !options.caseId || !options.caseStepId) {
|
|
16626
17421
|
throw new Error("Formal E2E execution requires --execution-manifest, --case-id, and --case-step-id. Use --diagnostic only for non-pass troubleshooting.");
|
|
@@ -16631,6 +17426,12 @@ async function requireE2eExecutionBinding(options, runners) {
|
|
|
16631
17426
|
caseStepId: options.caseStepId,
|
|
16632
17427
|
runners
|
|
16633
17428
|
});
|
|
17429
|
+
if (evidenceDir) {
|
|
17430
|
+
await preflightExecutionEvidenceDirectory({
|
|
17431
|
+
manifest: options.executionManifest,
|
|
17432
|
+
evidenceDir
|
|
17433
|
+
});
|
|
17434
|
+
}
|
|
16634
17435
|
}
|
|
16635
17436
|
async function appendE2eExecutionEvidence(options, evidence, runners) {
|
|
16636
17437
|
if (options.diagnostic || !options.executionManifest || !options.caseId || !options.caseStepId) return;
|
|
@@ -16673,6 +17474,55 @@ async function writeEvidence(dir, name, value) {
|
|
|
16673
17474
|
`, "utf8");
|
|
16674
17475
|
return file;
|
|
16675
17476
|
}
|
|
17477
|
+
function summarizeRemoteResult(value) {
|
|
17478
|
+
if (!isRecord8(value)) return value;
|
|
17479
|
+
const summary = {};
|
|
17480
|
+
for (const key of ["id", "project_id", "step_id", "status", "state", "code", "msg", "message", "next", "action"]) {
|
|
17481
|
+
if (value[key] !== void 0) summary[key] = value[key];
|
|
17482
|
+
}
|
|
17483
|
+
return Object.keys(summary).length > 0 ? redactAuditValue(summary) : { received: true };
|
|
17484
|
+
}
|
|
17485
|
+
function stepReadbackConfirmed(before, after) {
|
|
17486
|
+
const beforeStatus = isRecord8(before.step) ? before.step.status : void 0;
|
|
17487
|
+
const afterStatus = isRecord8(after.step) ? after.step.status : void 0;
|
|
17488
|
+
const beforeProjectStep = isRecord8(before.project) ? before.project.current_flow_step_id : void 0;
|
|
17489
|
+
const afterProjectStep = isRecord8(after.project) ? after.project.current_flow_step_id : void 0;
|
|
17490
|
+
return after.step_finished === true || beforeStatus !== afterStatus || beforeProjectStep !== afterProjectStep;
|
|
17491
|
+
}
|
|
17492
|
+
function evidenceMime(buffer, file) {
|
|
17493
|
+
if (buffer.length >= 8 && buffer.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))) return "image/png";
|
|
17494
|
+
if (buffer.length >= 3 && buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255) return "image/jpeg";
|
|
17495
|
+
if (buffer.length >= 12 && buffer.subarray(0, 4).toString("ascii") === "RIFF" && buffer.subarray(8, 12).toString("ascii") === "WEBP") return "image/webp";
|
|
17496
|
+
if (path11.extname(file).toLowerCase() === ".json") return "application/json";
|
|
17497
|
+
if ([".txt", ".md", ".log"].includes(path11.extname(file).toLowerCase())) return "text/plain";
|
|
17498
|
+
return "application/octet-stream";
|
|
17499
|
+
}
|
|
17500
|
+
async function writeEvidenceManifest(evidenceDir, details) {
|
|
17501
|
+
const files = await readdir4(evidenceDir, { withFileTypes: true });
|
|
17502
|
+
const artifacts = [];
|
|
17503
|
+
for (const entry of files) {
|
|
17504
|
+
if (!entry.isFile() || entry.name === "evidence-manifest.json") continue;
|
|
17505
|
+
const file = path11.join(evidenceDir, entry.name);
|
|
17506
|
+
const buffer = await readFile12(file);
|
|
17507
|
+
const mimeType = evidenceMime(buffer, entry.name);
|
|
17508
|
+
const extension = path11.extname(entry.name).toLowerCase();
|
|
17509
|
+
const expectedMime = extension === ".png" ? "image/png" : [".jpg", ".jpeg"].includes(extension) ? "image/jpeg" : extension === ".webp" ? "image/webp" : void 0;
|
|
17510
|
+
artifacts.push({
|
|
17511
|
+
path: entry.name,
|
|
17512
|
+
size: buffer.length,
|
|
17513
|
+
sha256: createHash6("sha256").update(buffer).digest("hex"),
|
|
17514
|
+
mime_type: mimeType,
|
|
17515
|
+
...expectedMime && expectedMime !== mimeType ? { extension_mismatch: true, expected_mime: expectedMime } : {}
|
|
17516
|
+
});
|
|
17517
|
+
}
|
|
17518
|
+
return writeEvidence(evidenceDir, "evidence-manifest.json", {
|
|
17519
|
+
schema_version: 1,
|
|
17520
|
+
generated_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
17521
|
+
evidence_dir: path11.resolve(evidenceDir),
|
|
17522
|
+
...details,
|
|
17523
|
+
artifacts
|
|
17524
|
+
});
|
|
17525
|
+
}
|
|
16676
17526
|
function cacheRoot() {
|
|
16677
17527
|
return path11.resolve(".codex/cache/bpmax-e2e");
|
|
16678
17528
|
}
|
|
@@ -17007,7 +17857,7 @@ function recordKey(record, index) {
|
|
|
17007
17857
|
function registerE2eCommands(program2) {
|
|
17008
17858
|
const e2e = program2.command("e2e").description("BPMAX E2E acceleration helpers with evidence-first safety gates");
|
|
17009
17859
|
e2e.command("step-run").description("Run one or more BPMAX step safe-chain submissions with evidence files").requiredOption("--project-id <projectId>", "Project id").option("--step-id <stepId>", "Step id for single-step mode").option("--action <action>", "Step action", "approve").option("--data <json>", "Single-step submit data JSON or @file").option("--data-profile <json>", "Reusable step profile JSON or @file; supports steps[] or steps object").option("--auto-refresh-cache", "Write a refreshed cache template when expected checks are missing or stale").option("--cache-out <file>", "Refreshed cache template output; defaults to --data-profile @file when possible").option("--comments <comments>", "Step comments").option("--urgency <urgency>", "Urgency value", "1").option("--confirm <confirmation>", "Actually submit; otherwise dry-run only").option("--profile <profile>", "Profile name").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; result cannot be used as pass evidence").option("--evidence-dir <dir>", "Evidence directory", `.codex/tmp/e2e/${timestampSlug()}`).option("--format <format>", "Output format", "json").action(async (options) => {
|
|
17010
|
-
await requireE2eExecutionBinding(options, ["e2e_step_run"]);
|
|
17860
|
+
await requireE2eExecutionBinding(options, ["e2e_step_run"], options.evidenceDir);
|
|
17011
17861
|
const config = await loadConfig();
|
|
17012
17862
|
const profile = resolveProfile(config, options.profile);
|
|
17013
17863
|
const client = createApiClient(profile);
|
|
@@ -17120,29 +17970,89 @@ function registerE2eCommands(program2) {
|
|
|
17120
17970
|
params: { action: plan.action },
|
|
17121
17971
|
data: payload
|
|
17122
17972
|
});
|
|
17123
|
-
|
|
17124
|
-
|
|
17125
|
-
|
|
17126
|
-
|
|
17973
|
+
let readback = null;
|
|
17974
|
+
let readbackError = null;
|
|
17975
|
+
try {
|
|
17976
|
+
readback = await buildStepContext(profile, client, plan.step_id, options.projectId);
|
|
17977
|
+
} catch (error) {
|
|
17978
|
+
readbackError = error instanceof Error ? error.message : String(error);
|
|
17979
|
+
}
|
|
17980
|
+
const readbackConfirmed2 = Boolean(readback && stepReadbackConfirmed(context, readback));
|
|
17981
|
+
let submitFile;
|
|
17982
|
+
let evidenceError;
|
|
17983
|
+
try {
|
|
17984
|
+
submitFile = await writeEvidence(evidenceDir, `${prefix}-submit.json`, {
|
|
17985
|
+
status: "submitted",
|
|
17986
|
+
operation_executed: true,
|
|
17987
|
+
remote_submitted: true,
|
|
17988
|
+
evidence_failed: false,
|
|
17989
|
+
readback_confirmed: readbackConfirmed2,
|
|
17990
|
+
request,
|
|
17991
|
+
remote_response_summary: summarizeRemoteResult(result),
|
|
17992
|
+
readback,
|
|
17993
|
+
...readbackError ? { readback_error: readbackError } : {}
|
|
17994
|
+
});
|
|
17995
|
+
} catch (error) {
|
|
17996
|
+
evidenceError = error instanceof Error ? error.message : String(error);
|
|
17997
|
+
}
|
|
17998
|
+
if (evidenceError || !readbackConfirmed2) {
|
|
17999
|
+
stopped = true;
|
|
18000
|
+
}
|
|
17127
18001
|
steps.push({
|
|
17128
18002
|
step_id: plan.step_id,
|
|
17129
18003
|
action: plan.action,
|
|
17130
|
-
status: "submitted",
|
|
17131
|
-
|
|
17132
|
-
|
|
18004
|
+
status: evidenceError ? "evidence_failed" : readbackConfirmed2 ? "submitted" : "submitted_unconfirmed",
|
|
18005
|
+
operation_executed: true,
|
|
18006
|
+
remote_submitted: true,
|
|
18007
|
+
evidence_failed: Boolean(evidenceError),
|
|
18008
|
+
readback_confirmed: readbackConfirmed2,
|
|
18009
|
+
evidence: { context: contextFile, ...submitFile ? { submit: submitFile } : {} },
|
|
18010
|
+
remote_response_summary: summarizeRemoteResult(result),
|
|
18011
|
+
...readback ? { readback } : {},
|
|
18012
|
+
...readbackError ? { readback_error: readbackError } : {},
|
|
18013
|
+
...!evidenceError && !readbackConfirmed2 ? {
|
|
18014
|
+
requires_manual_reconciliation: true,
|
|
18015
|
+
next_action: "Do not continue to another step or resubmit. Confirm the current project/step state with readback first."
|
|
18016
|
+
} : {},
|
|
18017
|
+
...evidenceError ? {
|
|
18018
|
+
evidence_error: evidenceError,
|
|
18019
|
+
requires_manual_reconciliation: true,
|
|
18020
|
+
next_action: "Do not resubmit. Read back the project/step state and repair evidence for this already-submitted operation."
|
|
18021
|
+
} : {}
|
|
17133
18022
|
});
|
|
17134
18023
|
}
|
|
17135
|
-
|
|
18024
|
+
let evidenceManifest;
|
|
18025
|
+
let evidenceManifestError;
|
|
18026
|
+
try {
|
|
18027
|
+
evidenceManifest = await writeEvidenceManifest(evidenceDir, {
|
|
18028
|
+
command: "e2e step-run",
|
|
18029
|
+
project_id: options.projectId,
|
|
18030
|
+
profile: profile.name,
|
|
18031
|
+
steps
|
|
18032
|
+
});
|
|
18033
|
+
} catch (error) {
|
|
18034
|
+
evidenceManifestError = error instanceof Error ? error.message : String(error);
|
|
18035
|
+
}
|
|
18036
|
+
const remoteSubmitted = steps.some((step) => step.remote_submitted === true);
|
|
18037
|
+
const evidenceFailed = steps.some((step) => step.evidence_failed === true) || Boolean(evidenceManifestError);
|
|
18038
|
+
const readbackConfirmed = remoteSubmitted && steps.filter((step) => step.remote_submitted === true).every((step) => step.readback_confirmed === true);
|
|
18039
|
+
if (options.confirm && remoteSubmitted && readbackConfirmed && !evidenceFailed && evidenceManifest && steps.every((step) => step.status !== "blocked" && step.status !== "cache_stale")) {
|
|
17136
18040
|
await appendE2eExecutionEvidence(options, evidenceDir, ["e2e_step_run"]);
|
|
17137
18041
|
}
|
|
17138
18042
|
printResult(options.format, {
|
|
17139
|
-
ok: steps.every((step) => step.status !== "blocked" && step.status !== "cache_stale"),
|
|
17140
|
-
result: options.diagnostic ? "diagnostic" : options.confirm &&
|
|
18043
|
+
ok: !evidenceFailed && (!remoteSubmitted || readbackConfirmed) && steps.every((step) => step.status !== "blocked" && step.status !== "cache_stale"),
|
|
18044
|
+
result: options.diagnostic ? "diagnostic" : evidenceFailed && remoteSubmitted ? "remote_submitted_evidence_failed" : options.confirm && remoteSubmitted ? readbackConfirmed ? "execution_evidence_recorded" : "remote_submitted_readback_unconfirmed" : "execution_plan_generated",
|
|
17141
18045
|
diagnostic: Boolean(options.diagnostic),
|
|
17142
18046
|
dry_run: !options.confirm,
|
|
18047
|
+
operation_executed: remoteSubmitted,
|
|
18048
|
+
remote_submitted: remoteSubmitted,
|
|
18049
|
+
evidence_failed: evidenceFailed,
|
|
18050
|
+
readback_confirmed: readbackConfirmed,
|
|
17143
18051
|
project_id: options.projectId,
|
|
17144
18052
|
profile: profile.name,
|
|
17145
18053
|
evidence_dir: evidenceDir,
|
|
18054
|
+
evidence_manifest: evidenceManifest ?? null,
|
|
18055
|
+
...evidenceManifestError ? { evidence_manifest_error: evidenceManifestError } : {},
|
|
17146
18056
|
steps
|
|
17147
18057
|
});
|
|
17148
18058
|
});
|
|
@@ -17421,12 +18331,24 @@ function assertProjectSearchBody(value) {
|
|
|
17421
18331
|
}
|
|
17422
18332
|
function withProjectListPagination(body, options) {
|
|
17423
18333
|
const data = { ...body };
|
|
17424
|
-
|
|
17425
|
-
|
|
17426
|
-
|
|
17427
|
-
|
|
17428
|
-
|
|
17429
|
-
|
|
18334
|
+
const normalizePositiveInteger = (value, path16) => {
|
|
18335
|
+
if (typeof value === "string" && value.trim() === "") {
|
|
18336
|
+
throw new Error(`project search ${path16} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u4E0D\u80FD\u662F\u7A7A\u5B57\u7B26\u4E32\u3002`);
|
|
18337
|
+
}
|
|
18338
|
+
const number = typeof value === "number" ? value : Number(value);
|
|
18339
|
+
if (!Number.isSafeInteger(number) || number < 1) {
|
|
18340
|
+
throw new Error(`project search ${path16} \u5FC5\u987B\u662F\u5927\u4E8E\u7B49\u4E8E 1 \u7684\u6574\u6570\uFF0C\u5F53\u524D\u503C\u4E3A ${String(value)}\u3002`);
|
|
18341
|
+
}
|
|
18342
|
+
return number;
|
|
18343
|
+
};
|
|
18344
|
+
data.page = normalizePositiveInteger(
|
|
18345
|
+
options.pageExplicit || data.page === void 0 ? options.page : data.page,
|
|
18346
|
+
"page"
|
|
18347
|
+
);
|
|
18348
|
+
data.page_size = normalizePositiveInteger(
|
|
18349
|
+
options.pageSizeExplicit || data.page_size === void 0 ? options.pageSize : data.page_size,
|
|
18350
|
+
"page_size"
|
|
18351
|
+
);
|
|
17430
18352
|
return data;
|
|
17431
18353
|
}
|
|
17432
18354
|
|
|
@@ -19898,6 +20820,10 @@ var schemaEntries = [
|
|
|
19898
20820
|
{ name: "config.console_template.create", description: "Create console template config through a verified typed adapter.", method: "POST", path: "/api/flow_page_template" },
|
|
19899
20821
|
{ name: "config.console_template.delete", description: "Delete console template config through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id" },
|
|
19900
20822
|
{ name: "config.console_template.submit", description: "Submit console template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id" },
|
|
20823
|
+
{ name: "config.step_detail_template.export", description: "Export type=6 flow-step detail template config.", method: "GET", path: "/api/flow_page_template/:id?type=6&skip_i18n=true" },
|
|
20824
|
+
{ name: "config.step_detail_template.create", description: "Create a type=6 flow-step detail template through a verified typed adapter.", method: "POST", path: "/api/flow_page_template?type=6" },
|
|
20825
|
+
{ name: "config.step_detail_template.delete", description: "Delete a type=6 flow-step detail template through a verified typed adapter.", method: "DELETE", path: "/api/flow_page_template/:id?type=6" },
|
|
20826
|
+
{ name: "config.step_detail_template.submit", description: "Submit type=6 flow-step detail template edits through a verified typed adapter.", method: "PUT", path: "/api/flow_page_template/:id?type=6" },
|
|
19901
20827
|
{ 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" },
|
|
19902
20828
|
{ name: "config.dataset.create", description: "Create dataset config through the huanpingtong API-key proxy.", method: "POST", path: "/api/data_set" },
|
|
19903
20829
|
{ name: "config.dataset.delete", description: "Delete dataset config through the huanpingtong API-key proxy.", method: "DELETE", path: "/api/data_set/:id" },
|
|
@@ -20170,7 +21096,7 @@ var CONFIG_TASK_RULES = [
|
|
|
20170
21096
|
writeEvidence: [/bpmax-cli config flow-template lint/, /bpmax-cli config flow-template build/, /bpmax-cli config flow-template submit/, /bpmax-cli config flow-template verify/],
|
|
20171
21097
|
readonlyEvidence: [/bpmax-cli config flow-template export|流程.*回读|readback/i],
|
|
20172
21098
|
constraintEvidence: /project_after_create_path|message_template|return ""|matrix_owner|cc_matrix|流程模板约束|flow-template lint/i,
|
|
20173
|
-
mentionPattern: /流程模板|flow-template|flow_template
|
|
21099
|
+
mentionPattern: /流程模板|flow-template|flow_template|流程配置|创建流程|编辑流程|step_detail_id/
|
|
20174
21100
|
},
|
|
20175
21101
|
{
|
|
20176
21102
|
domain: "form-template",
|
|
@@ -20206,7 +21132,16 @@ var CONFIG_TASK_RULES = [
|
|
|
20206
21132
|
writeEvidence: [/bpmax-cli config project-detail-template lint/, /bpmax-cli config project-detail-template build/, /bpmax-cli config project-detail-template submit/, /bpmax-cli config project-detail-template verify/],
|
|
20207
21133
|
readonlyEvidence: [/bpmax-cli config project-detail-template export|详情.*回读|resolve-default|readback/i],
|
|
20208
21134
|
constraintEvidence: /默认详情模板|resolve-default|详情页|project_detail|project-detail-template lint/i,
|
|
20209
|
-
mentionPattern:
|
|
21135
|
+
mentionPattern: /项目详情模板|项目详情页|project-detail-template|project_detail/
|
|
21136
|
+
},
|
|
21137
|
+
{
|
|
21138
|
+
domain: "step-detail-template",
|
|
21139
|
+
skill: "bpmax-flow-template-editor",
|
|
21140
|
+
lockPattern: /step-detail-template:(?:\d+|new-[A-Za-z0-9_-]+)/,
|
|
21141
|
+
writeEvidence: [/bpmax-cli config step-detail-template lint/, /bpmax-cli config step-detail-template build/, /bpmax-cli config step-detail-template submit/, /bpmax-cli config step-detail-template verify/],
|
|
21142
|
+
readonlyEvidence: [/bpmax-cli config step-detail-template export|环节详情.*回读|step_detail_id|readback/i],
|
|
21143
|
+
constraintEvidence: /type=6|content\.layout|step_detail_id|自定义模块|step-detail-template lint/i,
|
|
21144
|
+
mentionPattern: /(?:(?<!不)(?<!不得)(?<!禁止)(?:创建|编辑|修改|新增|删除|配置|优化|调整|调研|检查|回读)[^。\n]{0,16}(?:环节详情模板|环节处理模板)|(?:环节详情模板|环节处理模板)[^。\n]{0,16}(?<!不)(?<!不得)(?<!禁止)(?:创建|编辑|修改|新增|删除|配置|优化|调整|调研|检查|回读)|step-detail-template)/
|
|
20210
21145
|
},
|
|
20211
21146
|
{
|
|
20212
21147
|
domain: "console-template",
|
|
@@ -20290,6 +21225,9 @@ var CONFIG_TASK_RULES = [
|
|
|
20290
21225
|
mentionPattern: /E2E|端到端|浏览器测试|测试用例|回归测试/
|
|
20291
21226
|
}
|
|
20292
21227
|
];
|
|
21228
|
+
function skillOwnsMultipleConfigDomains(skill) {
|
|
21229
|
+
return CONFIG_TASK_RULES.filter((rule) => rule.skill === skill).length > 1;
|
|
21230
|
+
}
|
|
20293
21231
|
function isWriteMode(rowOrText) {
|
|
20294
21232
|
const mode = typeof rowOrText === "string" ? rowOrText.match(/subagent_mode\s*[::]\s*([^\n]+)/)?.[1] || "" : rowOrText.subagent_mode || "";
|
|
20295
21233
|
return !/\breadonly\b/i.test(mode);
|
|
@@ -20514,6 +21452,9 @@ function validateConfigRuleForTaskRow(row, rule, issues) {
|
|
|
20514
21452
|
if (!hasSkill) {
|
|
20515
21453
|
return;
|
|
20516
21454
|
}
|
|
21455
|
+
if (!mentionsDomain && skillOwnsMultipleConfigDomains(rule.skill)) {
|
|
21456
|
+
return;
|
|
21457
|
+
}
|
|
20517
21458
|
const writeMode = isWriteMode(row);
|
|
20518
21459
|
if (writeMode && !rule.lockPattern.test(row.object_lock || "")) {
|
|
20519
21460
|
addTaskbookIssue(
|
|
@@ -20654,6 +21595,9 @@ function validatePromptConfigSkillGates(text5, issues) {
|
|
|
20654
21595
|
if (!hasSkill) {
|
|
20655
21596
|
continue;
|
|
20656
21597
|
}
|
|
21598
|
+
if (!mentionsDomain && skillOwnsMultipleConfigDomains(rule.skill)) {
|
|
21599
|
+
continue;
|
|
21600
|
+
}
|
|
20657
21601
|
if (writeMode && !rule.lockPattern.test(objectLock)) {
|
|
20658
21602
|
addTaskbookIssue(
|
|
20659
21603
|
issues,
|
|
@@ -20827,6 +21771,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
|
|
|
20827
21771
|
"| \u6D41\u7A0B\u6A21\u677F | bpmax-flow-template-editor | bpmax-cli config flow-template export/lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | project_after_create_path\u3001message_template\u3001matrix_owner\u3001\u6D41\u7A0B\u6A21\u677F\u7EA6\u675F |",
|
|
20828
21772
|
"| \u8868\u5355\u6A21\u677F | bpmax-form-template-editor | bpmax-cli config form-template export/lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | \u5B57\u6BB5 schema\u3001\u8868\u5355\u987A\u5E8F\u3001raw.value\u3001layout\u3001sub_form\u3001form-template inspect |",
|
|
20829
21773
|
"| \u5217\u8868\u6A21\u677F | bpmax-list-template-editor | bpmax-cli config list-template lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | \u64CD\u4F5C\u5217\u3001\u8BE6\u60C5\u52A8\u4F5C\u3001\u5220\u9664\u6743\u9650 guard\uFF08\u9996\u9009 ctx.$CAN_DELETE\uFF0C\u7981\u6B62\u5F53\u524D\u73AF\u8282\u4E3A\u7A7A\u6761\u4EF6\uFF09\u3001icon\u3001\u67E5\u8BE2\u5B89\u5168\u3001\u771F\u5B9E\u5217\u8868\u9875 |",
|
|
21774
|
+
"| \u73AF\u8282\u8BE6\u60C5\u6A21\u677F | bpmax-flow-template-editor | bpmax-cli config step-detail-template export/lint/build/submit/verify\uFF1B\u6D41\u7A0B\u7ED1\u5B9A\u8FD8\u9700 flow-template verify | type=6\u3001content.layout\u3001\u6A21\u5757\u58F0\u660E\u3001step_detail_id \u8FDC\u7AEF\u5B58\u5728\u6027\u4E0E\u8282\u70B9\u9002\u914D |",
|
|
20830
21775
|
"| \u5BFC\u822A\u914D\u7F6E | bpmax-nav-config-editor | bpmax-cli config nav-config lint/build/submit/verify\uFF1B\u5199\u4EFB\u52A1\u5148\u8DD1 bpmax-cli config adapters --format json \u6838\u5BF9 capability/adapter | PC/H5 \u5BFC\u822A\u3001\u5FEB\u6377\u5165\u53E3\u3001\u6D4F\u89C8\u5668\u6253\u5F00\u9A8C\u8BC1 |",
|
|
20831
21776
|
"",
|
|
20832
21777
|
"## AI \u6700\u5C0F\u4EFB\u52A1\u5355\u5143",
|
|
@@ -21068,17 +22013,17 @@ function registerTestSuiteCommands(program2) {
|
|
|
21068
22013
|
skillVersion: skill.version
|
|
21069
22014
|
}));
|
|
21070
22015
|
});
|
|
21071
|
-
run.command("next").description("Return only the current runnable case step from an execution manifest").requiredOption("--manifest <file>", "Execution manifest file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21072
|
-
printResult(options.format, await nextTestSuiteRunStep(options.manifest));
|
|
22016
|
+
run.command("next").description("Return only the current runnable case step from an execution manifest").requiredOption("--manifest <file>", "Execution manifest file").option("--profile <profile>", "Profile name; must match the execution manifest").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
22017
|
+
printResult(options.format, await nextTestSuiteRunStep(options.manifest, options.profile));
|
|
21073
22018
|
});
|
|
21074
|
-
run.command("record").description("Record pass/fail/blocked evidence for the current case step").requiredOption("--manifest <file>", "Execution manifest file").requiredOption("--case-id <id>", "Case id").requiredOption("--case-step-id <id>", "Case step id").requiredOption("--result <result>", "pass, fail, or blocked").requiredOption("--evidence <path>", "Current-run evidence file or directory").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
22019
|
+
run.command("record").description("Record pass/fail/blocked evidence for the current case step").requiredOption("--manifest <file>", "Execution manifest file").requiredOption("--case-id <id>", "Case id").requiredOption("--case-step-id <id>", "Case step id").requiredOption("--result <result>", "pass, fail, or blocked").requiredOption("--evidence <path>", "Current-run evidence file or directory").option("--profile <profile>", "Profile name; must match the execution manifest").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21075
22020
|
printResult(options.format, await recordTestSuiteRunStep(options));
|
|
21076
22021
|
});
|
|
21077
22022
|
run.command("report-sync").description("Synchronize the generated scenario report from the execution manifest").requiredOption("--manifest <file>", "Execution manifest file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21078
22023
|
printResult(options.format, await syncTestSuiteRunReport(options.manifest));
|
|
21079
22024
|
});
|
|
21080
|
-
run.command("status").description("Show execution manifest status").requiredOption("--manifest <file>", "Execution manifest file").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21081
|
-
printResult(options.format, await testSuiteRunStatus(options.manifest));
|
|
22025
|
+
run.command("status").description("Show execution manifest status").requiredOption("--manifest <file>", "Execution manifest file").option("--profile <profile>", "Profile name; must match the execution manifest").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
22026
|
+
printResult(options.format, await testSuiteRunStatus(options.manifest, options.profile));
|
|
21082
22027
|
});
|
|
21083
22028
|
review.command("repair").description("Repair missing schema fields in an existing draft review.json").requiredOption("--scenario <id>", "Scenario id").option("--draft-root <path>", "Draft suite root directory", DEFAULT_DRAFT_ROOT).requiredOption("--latest-proof <path>", "latest-* proof JSON written after syncing the sysconfig repo").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21084
22029
|
printResult(options.format, await initOrRepairReview({ ...options, repair: true }));
|
|
@@ -21098,8 +22043,8 @@ function registerTestSuiteCommands(program2) {
|
|
|
21098
22043
|
const reportDir = await nextReportDir(options.root, Boolean(options.create));
|
|
21099
22044
|
printResult(options.format, { path: reportDir });
|
|
21100
22045
|
});
|
|
21101
|
-
suite.command("lint-report").description("Lint BPMAX E2E test report artifacts").option("--root <path>", "Report root directory", DEFAULT_REPORT_ROOT).option("--format <format>", "Output format", "json").action(async (options) => {
|
|
21102
|
-
const errors = await lintReport(options.root);
|
|
22046
|
+
suite.command("lint-report").description("Lint BPMAX E2E test report artifacts").option("--root <path>", "Report root directory", DEFAULT_REPORT_ROOT).option("--all-runs", "Lint every historical run instead of only the latest/current run").option("--format <format>", "Output format", "json").action(async (options) => {
|
|
22047
|
+
const errors = await lintReport(options.root, { allRuns: Boolean(options.allRuns) });
|
|
21103
22048
|
if (errors.length > 0) {
|
|
21104
22049
|
throw new Error(errors.join("\n"));
|
|
21105
22050
|
}
|
|
@@ -21108,7 +22053,7 @@ function registerTestSuiteCommands(program2) {
|
|
|
21108
22053
|
}
|
|
21109
22054
|
|
|
21110
22055
|
// src/core/update.ts
|
|
21111
|
-
import { access as access2, mkdir as mkdir13, readFile as readFile18, realpath as
|
|
22056
|
+
import { access as access2, mkdir as mkdir13, readFile as readFile18, realpath as realpath3, writeFile as writeFile13 } from "fs/promises";
|
|
21112
22057
|
import path15 from "path";
|
|
21113
22058
|
var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
|
|
21114
22059
|
var UPDATE_STATE_FILE = "update-state.json";
|
|
@@ -21274,7 +22219,7 @@ async function executablePath() {
|
|
|
21274
22219
|
return "";
|
|
21275
22220
|
}
|
|
21276
22221
|
try {
|
|
21277
|
-
return await
|
|
22222
|
+
return await realpath3(candidate);
|
|
21278
22223
|
} catch {
|
|
21279
22224
|
return candidate;
|
|
21280
22225
|
}
|
|
@@ -21687,6 +22632,7 @@ function commandEndpointHint(argv) {
|
|
|
21687
22632
|
"list-template": "/flow_page_template",
|
|
21688
22633
|
"filter-template": "/flow_page_template",
|
|
21689
22634
|
"project-detail-template": "/flow_page_template",
|
|
22635
|
+
"step-detail-template": "/flow_page_template",
|
|
21690
22636
|
"console-template": "/flow_page_template"
|
|
21691
22637
|
};
|
|
21692
22638
|
return endpointByDomain[args[1]];
|
|
@@ -21704,6 +22650,16 @@ function printCommandError(error) {
|
|
|
21704
22650
|
...typeof structured.rule_id === "string" ? { rule_id: structured.rule_id } : {},
|
|
21705
22651
|
...typeof structured.path === "string" ? { path: structured.path } : {},
|
|
21706
22652
|
...typeof structured.suggestion === "string" ? { suggestion: structured.suggestion } : {},
|
|
22653
|
+
...typeof structured.request_phase === "string" ? { request_phase: structured.request_phase } : {},
|
|
22654
|
+
...typeof structured.http_status === "number" || structured.http_status === null ? { http_status: structured.http_status } : {},
|
|
22655
|
+
...Array.isArray(structured.changed_paths) ? { changed_paths: structured.changed_paths } : {},
|
|
22656
|
+
...typeof structured.remote_write_state === "string" ? { remote_write_state: structured.remote_write_state } : {},
|
|
22657
|
+
...typeof structured.remote_submitted === "boolean" ? { remote_submitted: structured.remote_submitted } : {},
|
|
22658
|
+
...typeof structured.readback_confirmed === "boolean" ? { readback_confirmed: structured.readback_confirmed } : {},
|
|
22659
|
+
...typeof structured.readback_error === "string" ? { readback_error: structured.readback_error } : {},
|
|
22660
|
+
...typeof structured.remote_error === "string" ? { remote_error: structured.remote_error } : {},
|
|
22661
|
+
...typeof structured.published_id === "string" || typeof structured.published_id === "number" ? { published_id: structured.published_id } : {},
|
|
22662
|
+
...typeof structured.draft_id === "string" || typeof structured.draft_id === "number" || structured.draft_id === null ? { draft_id: structured.draft_id } : {},
|
|
21707
22663
|
...Array.isArray(structured.missing) ? { missing: structured.missing } : {},
|
|
21708
22664
|
...typeof structured.profile === "string" ? { profile: structured.profile } : {},
|
|
21709
22665
|
...typeof structured.env === "string" ? { env: structured.env } : {},
|