bpmax-cli 0.2.1-beta.57 → 0.2.1-beta.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js
CHANGED
|
@@ -499,7 +499,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
499
499
|
// package.json
|
|
500
500
|
var package_default = {
|
|
501
501
|
name: "bpmax-cli",
|
|
502
|
-
version: "0.2.1-beta.
|
|
502
|
+
version: "0.2.1-beta.58",
|
|
503
503
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
504
504
|
type: "module",
|
|
505
505
|
bin: {
|
|
@@ -6144,7 +6144,8 @@ function validateFlowTemplateStartConditionalJump(value, errors) {
|
|
|
6144
6144
|
let lastJumpResult = "";
|
|
6145
6145
|
if (Array.isArray(jumps)) {
|
|
6146
6146
|
jumps.forEach((jump, index) => {
|
|
6147
|
-
const
|
|
6147
|
+
const evidenceId = isRecord4(jump) && typeof jump.__bpmax_lint_evidence_id === "string" ? jump.__bpmax_lint_evidence_id : null;
|
|
6148
|
+
const pathName = evidenceId ? `data.meta.condational_jump[evidence=${evidenceId}]` : `data.meta.condational_jump[${index}]`;
|
|
6148
6149
|
if (!isRecord4(jump)) {
|
|
6149
6150
|
nextErrors.push(`${pathName} must be an object with name, result, condition_mode, and a boolean condition script.`);
|
|
6150
6151
|
return;
|
|
@@ -9200,8 +9201,108 @@ function flowLiveExportPath(id) {
|
|
|
9200
9201
|
function hasUsableFlowTemplateData(value) {
|
|
9201
9202
|
return isRecord4(value) && isRecord4(value.data) && Object.keys(value.data).length > 0;
|
|
9202
9203
|
}
|
|
9203
|
-
function
|
|
9204
|
-
|
|
9204
|
+
function validateFlowTemplateHardGates(work) {
|
|
9205
|
+
validateFlowTemplateRemoteTemplateRefs(work);
|
|
9206
|
+
validateFlowTemplateExpectedChildFlows(work);
|
|
9207
|
+
validateFlowTemplateStandardPageCreateFormTemplate(work);
|
|
9208
|
+
validateFlowTemplatePluginRejectionControl(work);
|
|
9209
|
+
validateFlowTemplateCodeModeMessages(work);
|
|
9210
|
+
validateFlowTemplateRuntimeScripts(work);
|
|
9211
|
+
validateFlowTemplateFeishuChatPlugin(work);
|
|
9212
|
+
}
|
|
9213
|
+
function collectFlowTemplateLintErrors(work) {
|
|
9214
|
+
const errors = [];
|
|
9215
|
+
validateFlowTemplateStandardFlowType(work, errors);
|
|
9216
|
+
validateFlowTemplateProjectNameTemplate(work, errors);
|
|
9217
|
+
validateFlowTemplateRemoteTemplateRefs(work, errors);
|
|
9218
|
+
validateFlowTemplateExpectedChildFlows(work, errors);
|
|
9219
|
+
validateFlowTemplateProjectAfterCreatePath(work, errors);
|
|
9220
|
+
validateFlowTemplateStandardPageCreateFormTemplate(work, errors);
|
|
9221
|
+
validateFlowTemplateStartConditionalJump(work, errors);
|
|
9222
|
+
validateFlowTemplatePostCreateInitiatorStep(work, errors);
|
|
9223
|
+
validateFlowTemplateApproveActionShape(work, errors);
|
|
9224
|
+
validateFlowTemplatePluginRejectionControl(work, errors);
|
|
9225
|
+
validateFlowTemplateStandardConditionEditorRules(work, errors);
|
|
9226
|
+
validateFlowTemplateCodeModeMessages(work, errors);
|
|
9227
|
+
validateFlowTemplateRuntimeScripts(work, errors);
|
|
9228
|
+
validateFlowTemplateFeishuChatPlugin(work, errors);
|
|
9229
|
+
return errors;
|
|
9230
|
+
}
|
|
9231
|
+
function flowTemplateLintEvidenceWork(work) {
|
|
9232
|
+
const data = isRecord4(work.data) ? work.data : {};
|
|
9233
|
+
const meta = isRecord4(data.meta) ? data.meta : {};
|
|
9234
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes : [];
|
|
9235
|
+
const jumps = meta.condational_jump;
|
|
9236
|
+
return {
|
|
9237
|
+
...work,
|
|
9238
|
+
data: {
|
|
9239
|
+
...data,
|
|
9240
|
+
meta: {
|
|
9241
|
+
...meta,
|
|
9242
|
+
...Array.isArray(jumps) ? {
|
|
9243
|
+
condational_jump: jumps.map((jump) => isRecord4(jump) ? { ...jump, __bpmax_lint_evidence_id: hashJson(jump).slice(0, 16) } : jump)
|
|
9244
|
+
} : {}
|
|
9245
|
+
},
|
|
9246
|
+
nodes: nodes.map((node, index) => {
|
|
9247
|
+
if (!isRecord4(node)) return node;
|
|
9248
|
+
const id = String(node.id ?? "").trim();
|
|
9249
|
+
const name = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
|
|
9250
|
+
return { ...node, name: `${name} [bpmax-node:${id || `index-${index}`}]` };
|
|
9251
|
+
})
|
|
9252
|
+
}
|
|
9253
|
+
};
|
|
9254
|
+
}
|
|
9255
|
+
function collectFlowTemplateLintEvidence(work) {
|
|
9256
|
+
const errors = collectFlowTemplateLintErrors(work);
|
|
9257
|
+
const keys = collectFlowTemplateLintErrors(flowTemplateLintEvidenceWork(work));
|
|
9258
|
+
if (errors.length !== keys.length) {
|
|
9259
|
+
throw new Error("flow-template lint evidence generation was inconsistent; rebuild without a preexisting lint exemption.");
|
|
9260
|
+
}
|
|
9261
|
+
return { errors, keys };
|
|
9262
|
+
}
|
|
9263
|
+
function subtractUnchangedLintErrors(current, baseline) {
|
|
9264
|
+
const remaining = /* @__PURE__ */ new Map();
|
|
9265
|
+
for (const key of baseline.keys) remaining.set(key, (remaining.get(key) ?? 0) + 1);
|
|
9266
|
+
const fresh = [];
|
|
9267
|
+
const ignored = [];
|
|
9268
|
+
current.errors.forEach((error, index) => {
|
|
9269
|
+
const key = current.keys[index];
|
|
9270
|
+
const count = remaining.get(key) ?? 0;
|
|
9271
|
+
if (count > 0) {
|
|
9272
|
+
remaining.set(key, count - 1);
|
|
9273
|
+
ignored.push(error);
|
|
9274
|
+
} else {
|
|
9275
|
+
fresh.push(error);
|
|
9276
|
+
}
|
|
9277
|
+
});
|
|
9278
|
+
return { errors: fresh, ignored };
|
|
9279
|
+
}
|
|
9280
|
+
function evaluateFlowTemplateBaselineLint(work, raw) {
|
|
9281
|
+
validateFlowTemplateHardGates(work);
|
|
9282
|
+
return subtractUnchangedLintErrors(collectFlowTemplateLintEvidence(work), collectFlowTemplateLintEvidence(raw));
|
|
9283
|
+
}
|
|
9284
|
+
async function validateFlowTemplateSubmitLintExemption(submit) {
|
|
9285
|
+
const meta = isRecord4(submit.meta) ? submit.meta : {};
|
|
9286
|
+
const exemption = isRecord4(meta.preexisting_lint_exemption) ? meta.preexisting_lint_exemption : null;
|
|
9287
|
+
if (!exemption) return false;
|
|
9288
|
+
if (exemption.schema_version !== 1 || typeof submit.base_hash !== "string" || exemption.base_hash !== submit.base_hash || !Array.isArray(exemption.ignored_errors) || !exemption.ignored_errors.every((error) => typeof error === "string")) {
|
|
9289
|
+
throw new Error("flow-template preexisting lint exemption evidence is invalid; rebuild from a fresh export baseline.");
|
|
9290
|
+
}
|
|
9291
|
+
const raw = await readFlowTemplateBaselineFromMeta(meta);
|
|
9292
|
+
if (!raw || hashJson(raw) !== submit.base_hash) {
|
|
9293
|
+
throw new Error("flow-template preexisting lint exemption baseline is missing or stale; re-export and rebuild.");
|
|
9294
|
+
}
|
|
9295
|
+
const evaluated = evaluateFlowTemplateBaselineLint(submit.payload, raw);
|
|
9296
|
+
if (evaluated.errors.length) {
|
|
9297
|
+
throw new Error(`flow-template lint failed: ${evaluated.errors.join("; ")}`);
|
|
9298
|
+
}
|
|
9299
|
+
if (!isDeepStrictEqual(evaluated.ignored, exemption.ignored_errors)) {
|
|
9300
|
+
throw new Error("flow-template preexisting lint exemption evidence does not match the submit payload; rebuild before submitting.");
|
|
9301
|
+
}
|
|
9302
|
+
return true;
|
|
9303
|
+
}
|
|
9304
|
+
function normalizeFlowTemplatePayload(work, options = {}) {
|
|
9305
|
+
if (!options.prevalidatedFlowTemplateLint) validateFlowTemplateStandardFlowType(work);
|
|
9205
9306
|
if (!isRecord4(work.data)) {
|
|
9206
9307
|
throw new Error("flow-template work requires data object.");
|
|
9207
9308
|
}
|
|
@@ -9214,19 +9315,16 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
9214
9315
|
meta.form_template = work.meta_form_id;
|
|
9215
9316
|
}
|
|
9216
9317
|
data.meta = meta;
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
validateFlowTemplateCodeModeMessages({ ...work, data });
|
|
9228
|
-
validateFlowTemplateRuntimeScripts({ ...work, data });
|
|
9229
|
-
validateFlowTemplateFeishuChatPlugin({ ...work, data });
|
|
9318
|
+
if (!options.prevalidatedFlowTemplateLint) {
|
|
9319
|
+
const normalizedWork = { ...work, data };
|
|
9320
|
+
validateFlowTemplateProjectNameTemplate(normalizedWork);
|
|
9321
|
+
validateFlowTemplateHardGates(normalizedWork);
|
|
9322
|
+
validateFlowTemplateProjectAfterCreatePath(normalizedWork);
|
|
9323
|
+
validateFlowTemplateStartConditionalJump(normalizedWork);
|
|
9324
|
+
validateFlowTemplatePostCreateInitiatorStep(normalizedWork);
|
|
9325
|
+
validateFlowTemplateApproveActionShape(normalizedWork);
|
|
9326
|
+
validateFlowTemplateStandardConditionEditorRules(normalizedWork);
|
|
9327
|
+
}
|
|
9230
9328
|
const payload = pickDefined(work, [
|
|
9231
9329
|
"name",
|
|
9232
9330
|
"flow_type",
|
|
@@ -12016,7 +12114,7 @@ function buildDomainSubmitPayload(domain, work, options = {}, raw) {
|
|
|
12016
12114
|
return payload;
|
|
12017
12115
|
}
|
|
12018
12116
|
if (domain === "flow-template") {
|
|
12019
|
-
const payload = normalizeFlowTemplatePayload(work);
|
|
12117
|
+
const payload = normalizeFlowTemplatePayload(work, options);
|
|
12020
12118
|
if (work.mode === "create") {
|
|
12021
12119
|
validateNonEmptyFlowCreatePayload(payload);
|
|
12022
12120
|
}
|
|
@@ -14140,6 +14238,21 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
14140
14238
|
throw new Error("Config build requires a meta file produced by `bpmax-cli config <domain> export`.");
|
|
14141
14239
|
}
|
|
14142
14240
|
const raw = typeof meta.raw_file === "string" ? await readJsonFile(meta.raw_file) : void 0;
|
|
14241
|
+
let ignoredPreexistingLintErrors = [];
|
|
14242
|
+
if (domain === "flow-template" && options.allowPreexistingLintErrors) {
|
|
14243
|
+
if (createMode) {
|
|
14244
|
+
throw new Error("--allow-preexisting-lint-errors requires an exported edit baseline and cannot be used for create mode.");
|
|
14245
|
+
}
|
|
14246
|
+
if (!isRecord4(raw) || hashJson(raw) !== meta.base_hash) {
|
|
14247
|
+
throw new Error("--allow-preexisting-lint-errors requires the exact raw export baseline matching meta.base_hash. Re-export before building.");
|
|
14248
|
+
}
|
|
14249
|
+
if (!isRecord4(work)) throw new Error("Config work file must be a JSON object.");
|
|
14250
|
+
const evaluated = evaluateFlowTemplateBaselineLint(work, raw);
|
|
14251
|
+
if (evaluated.errors.length) {
|
|
14252
|
+
throw new Error(`flow-template lint failed: ${evaluated.errors.join("; ")}`);
|
|
14253
|
+
}
|
|
14254
|
+
ignoredPreexistingLintErrors = evaluated.ignored;
|
|
14255
|
+
}
|
|
14143
14256
|
let formTemplateWarnings = [];
|
|
14144
14257
|
let flowDetailTemplateWarnings = [];
|
|
14145
14258
|
let stepDetailReferenceAudit;
|
|
@@ -14228,7 +14341,10 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
14228
14341
|
datasetValidation = datasetValidationArtifact(work, datasetMapping);
|
|
14229
14342
|
}
|
|
14230
14343
|
const payloadWork = (domain === "dataset" || domain === "dataset-field") && createMode && isRecord4(work) ? { ...work, mode: "create" } : work;
|
|
14231
|
-
const payload = buildDomainSubmitPayload(domain, payloadWork,
|
|
14344
|
+
const payload = buildDomainSubmitPayload(domain, payloadWork, {
|
|
14345
|
+
...options,
|
|
14346
|
+
prevalidatedFlowTemplateLint: domain === "flow-template" && options.allowPreexistingLintErrors === true
|
|
14347
|
+
}, raw);
|
|
14232
14348
|
if (domain === "flow-template" && options.publishLive) {
|
|
14233
14349
|
payload.publish_live = true;
|
|
14234
14350
|
}
|
|
@@ -14250,6 +14366,13 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
14250
14366
|
if (createMode) {
|
|
14251
14367
|
submitMeta.mode = "create";
|
|
14252
14368
|
}
|
|
14369
|
+
if (domain === "flow-template" && options.allowPreexistingLintErrors) {
|
|
14370
|
+
submitMeta.preexisting_lint_exemption = {
|
|
14371
|
+
schema_version: 1,
|
|
14372
|
+
base_hash: meta.base_hash,
|
|
14373
|
+
ignored_errors: ignoredPreexistingLintErrors
|
|
14374
|
+
};
|
|
14375
|
+
}
|
|
14253
14376
|
const result = {
|
|
14254
14377
|
domain,
|
|
14255
14378
|
built_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -14286,7 +14409,8 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
14286
14409
|
flow_report_references: flowReportReferenceAudit.references,
|
|
14287
14410
|
flow_report_warnings: flowReportReferenceAudit.warnings,
|
|
14288
14411
|
runtime_proof_required: flowReportReferenceAudit.references.length > 0 || flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
|
|
14289
|
-
} : {}
|
|
14412
|
+
} : {},
|
|
14413
|
+
...ignoredPreexistingLintErrors.length ? { ignored_preexisting_lint_errors: ignoredPreexistingLintErrors } : {}
|
|
14290
14414
|
};
|
|
14291
14415
|
await writeJsonFile(outFile, result);
|
|
14292
14416
|
return {
|
|
@@ -14326,7 +14450,8 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
14326
14450
|
flow_report_references: flowReportReferenceAudit.references,
|
|
14327
14451
|
flow_report_warnings: flowReportReferenceAudit.warnings,
|
|
14328
14452
|
runtime_proof_required: flowReportReferenceAudit.references.length > 0 || flowStepDetailRuntimeProofRequired(stepDetailReferenceAudit)
|
|
14329
|
-
} : {}
|
|
14453
|
+
} : {},
|
|
14454
|
+
...ignoredPreexistingLintErrors.length ? { ignored_preexisting_lint_errors: ignoredPreexistingLintErrors } : {}
|
|
14330
14455
|
};
|
|
14331
14456
|
}
|
|
14332
14457
|
async function runFlowTemplatePluginLint(flowWork, options = {}) {
|
|
@@ -15066,19 +15191,22 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
15066
15191
|
let flowReportReferenceAudit;
|
|
15067
15192
|
let flowCategoryReferenceAudit;
|
|
15068
15193
|
if (domain === "flow-template") {
|
|
15069
|
-
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15076
|
-
|
|
15077
|
-
|
|
15078
|
-
|
|
15079
|
-
|
|
15080
|
-
|
|
15081
|
-
|
|
15194
|
+
const lintExemptionVerified = await validateFlowTemplateSubmitLintExemption(submit);
|
|
15195
|
+
if (!lintExemptionVerified) {
|
|
15196
|
+
validateFlowTemplateRemoteTemplateRefs(submit.payload);
|
|
15197
|
+
validateFlowTemplateExpectedChildFlows(submit.payload);
|
|
15198
|
+
validateFlowTemplateProjectAfterCreatePath(submit.payload);
|
|
15199
|
+
validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
|
|
15200
|
+
validateFlowTemplateStartConditionalJump(submit.payload);
|
|
15201
|
+
validateFlowTemplateApproveActionShape(submit.payload);
|
|
15202
|
+
validateFlowTemplatePluginRejectionControl(submit.payload);
|
|
15203
|
+
validateFlowTemplateStandardConditionEditorRules(submit.payload);
|
|
15204
|
+
validateFlowTemplateCodeModeMessages(submit.payload);
|
|
15205
|
+
validateFlowTemplateRuntimeScripts(submit.payload);
|
|
15206
|
+
validateFlowTemplateFeishuChatPlugin(submit.payload);
|
|
15207
|
+
validateFlowTemplateProjectNameTemplate(submit.payload);
|
|
15208
|
+
validateFlowTemplateStandardFlowType(submit.payload);
|
|
15209
|
+
}
|
|
15082
15210
|
validateFlowTemplateIdentityStandard(id, submit.payload);
|
|
15083
15211
|
const pluginLint = await runFlowTemplatePluginLint(submit.payload, {
|
|
15084
15212
|
profile,
|
|
@@ -18446,7 +18574,11 @@ function registerConfigCommands(program2) {
|
|
|
18446
18574
|
}
|
|
18447
18575
|
printResult(options.format, result);
|
|
18448
18576
|
});
|
|
18449
|
-
domainCommand.command("build").description(`Build a submit payload for ${domain} when a verified domain adapter is available`).requiredOption("--work <file>", "Work JSON file").requiredOption("--out <file>", "Submit payload output file").option("--meta <file>", "Export meta JSON file").option("--all-records", "For aggregate domains, submit every record instead of only changed records").option("--publish-live", "For flow-template, build a live publish payload instead of draft save").option("--usage <usage>", "Filter-template usage: ordinary | console | dashboard").option("--profile <profile>", "Profile name for plugin lint discovery").option("--agent <agent>", "Agent adapter for installed plugin lint discovery", "codex").option("--format <format>", "Output format", "pretty")
|
|
18577
|
+
const buildCommand = domainCommand.command("build").description(`Build a submit payload for ${domain} when a verified domain adapter is available`).requiredOption("--work <file>", "Work JSON file").requiredOption("--out <file>", "Submit payload output file").option("--meta <file>", "Export meta JSON file").option("--all-records", "For aggregate domains, submit every record instead of only changed records").option("--publish-live", "For flow-template, build a live publish payload instead of draft save").option("--usage <usage>", "Filter-template usage: ordinary | console | dashboard").option("--profile <profile>", "Profile name for plugin lint discovery").option("--agent <agent>", "Agent adapter for installed plugin lint discovery", "codex").option("--format <format>", "Output format", "pretty");
|
|
18578
|
+
if (domain === "flow-template") {
|
|
18579
|
+
buildCommand.option("--allow-preexisting-lint-errors", "Allow unchanged non-hard lint errors already present in the verified raw export baseline");
|
|
18580
|
+
}
|
|
18581
|
+
buildCommand.action(async (options) => {
|
|
18450
18582
|
if (options.usage && !["ordinary", "console", "dashboard"].includes(options.usage)) {
|
|
18451
18583
|
throw new Error("--usage \u53EA\u5141\u8BB8 ordinary\u3001console \u6216 dashboard\u3002");
|
|
18452
18584
|
}
|
|
@@ -18461,6 +18593,7 @@ function registerConfigCommands(program2) {
|
|
|
18461
18593
|
const result = await buildConfigSubmitPayload(domain, options.work, options.out, options.meta, {
|
|
18462
18594
|
allRecords: Boolean(options.allRecords),
|
|
18463
18595
|
publishLive: Boolean(options.publishLive),
|
|
18596
|
+
allowPreexistingLintErrors: Boolean(options.allowPreexistingLintErrors),
|
|
18464
18597
|
pluginLint,
|
|
18465
18598
|
usage: options.usage
|
|
18466
18599
|
});
|