bpmax-cli 0.2.1-beta.7 → 0.2.1-beta.8
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 +124 -1
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-flow-template-editor/SKILL.md +43 -4
package/dist/bin.js
CHANGED
|
@@ -469,7 +469,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
469
469
|
// package.json
|
|
470
470
|
var package_default = {
|
|
471
471
|
name: "bpmax-cli",
|
|
472
|
-
version: "0.2.1-beta.
|
|
472
|
+
version: "0.2.1-beta.8",
|
|
473
473
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
474
474
|
type: "module",
|
|
475
475
|
bin: {
|
|
@@ -4339,6 +4339,125 @@ function validateFlowTemplateStandardPageCreateFormTemplate(value, errors) {
|
|
|
4339
4339
|
}
|
|
4340
4340
|
throw new Error(message);
|
|
4341
4341
|
}
|
|
4342
|
+
function startConditionalJumpScriptLooksLikeIndexReturn(script) {
|
|
4343
|
+
const text5 = script.trim();
|
|
4344
|
+
if (!text5) {
|
|
4345
|
+
return false;
|
|
4346
|
+
}
|
|
4347
|
+
const directReturns = Array.from(text5.matchAll(/\breturn\s+([^;]+)\s*;?/g));
|
|
4348
|
+
if (!directReturns.length) {
|
|
4349
|
+
return false;
|
|
4350
|
+
}
|
|
4351
|
+
return directReturns.some((match) => {
|
|
4352
|
+
const expression = match[1].trim();
|
|
4353
|
+
if (/[=!<>]=?|&&|\|\||\?/.test(expression)) {
|
|
4354
|
+
return false;
|
|
4355
|
+
}
|
|
4356
|
+
return /^-?\d+$/.test(expression) || /^(routeIndex|resultIndex|targetIndex|index)\b/.test(expression) || /\b(result|options)\.indexOf\s*\(/.test(expression) || /^Number(?:\.parseInt)?\s*\(/.test(expression);
|
|
4357
|
+
});
|
|
4358
|
+
}
|
|
4359
|
+
function startConditionalJumpScriptIsCatchAll(script) {
|
|
4360
|
+
const text5 = script.trim();
|
|
4361
|
+
return /^return\s+true\s*;?\s*$/.test(text5) || /^return\s+Boolean\s*\(\s*true\s*\)\s*;?\s*$/.test(text5);
|
|
4362
|
+
}
|
|
4363
|
+
function validateFlowTemplateStartConditionalJump(value, errors) {
|
|
4364
|
+
const nextErrors = [];
|
|
4365
|
+
const data = isRecord3(value.data) ? value.data : {};
|
|
4366
|
+
const meta = isRecord3(data.meta) ? data.meta : {};
|
|
4367
|
+
const jumps = meta.condational_jump;
|
|
4368
|
+
if (jumps === void 0 || jumps === null || jumps === "") {
|
|
4369
|
+
return;
|
|
4370
|
+
}
|
|
4371
|
+
if (!Array.isArray(jumps)) {
|
|
4372
|
+
nextErrors.push("data.meta.condational_jump must be an array when start conditional routing is configured.");
|
|
4373
|
+
} else if (jumps.length === 0) {
|
|
4374
|
+
return;
|
|
4375
|
+
}
|
|
4376
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes.filter(isRecord3) : [];
|
|
4377
|
+
const firstNodeId = nodes.length ? String(nodes[0].id ?? "").trim() : "";
|
|
4378
|
+
const nodeIds = new Set(nodes.map((node) => String(node.id ?? "").trim()).filter(Boolean));
|
|
4379
|
+
if (Array.isArray(jumps) && jumps.length && !nodes.length) {
|
|
4380
|
+
nextErrors.push("data.meta.condational_jump is configured but data.nodes is empty; start jump targets must point to real nodes or -1.");
|
|
4381
|
+
}
|
|
4382
|
+
if (Array.isArray(jumps) && jumps.length) {
|
|
4383
|
+
nodes.forEach((node, index) => {
|
|
4384
|
+
const id = String(node.id ?? "").trim();
|
|
4385
|
+
if (!id) {
|
|
4386
|
+
nextErrors.push(`data.nodes[${index}].id is required when data.meta.condational_jump is configured.`);
|
|
4387
|
+
}
|
|
4388
|
+
});
|
|
4389
|
+
}
|
|
4390
|
+
let lastJumpScript = "";
|
|
4391
|
+
let lastJumpResult = "";
|
|
4392
|
+
if (Array.isArray(jumps)) {
|
|
4393
|
+
jumps.forEach((jump, index) => {
|
|
4394
|
+
const pathName = `data.meta.condational_jump[${index}]`;
|
|
4395
|
+
if (!isRecord3(jump)) {
|
|
4396
|
+
nextErrors.push(`${pathName} must be an object with name, result, condition_mode, and a boolean condition script.`);
|
|
4397
|
+
return;
|
|
4398
|
+
}
|
|
4399
|
+
const name = typeof jump.name === "string" ? jump.name.trim() : "";
|
|
4400
|
+
if (!name) {
|
|
4401
|
+
nextErrors.push(`${pathName}.name is required so every explicit start route can be audited.`);
|
|
4402
|
+
}
|
|
4403
|
+
const rawResult = jump.result;
|
|
4404
|
+
if (Array.isArray(rawResult) || isRecord3(rawResult) || rawResult === void 0 || rawResult === null || String(rawResult).trim() === "") {
|
|
4405
|
+
nextErrors.push(`${pathName}.result must be a target node id or -1; it must not be empty, an array, an object, or a node name.`);
|
|
4406
|
+
} else {
|
|
4407
|
+
const result = String(rawResult).trim();
|
|
4408
|
+
if (result !== "-1" && !nodeIds.has(result)) {
|
|
4409
|
+
nextErrors.push(`${pathName}.result (${result}) must point to an existing data.nodes[].id or -1 for success end.`);
|
|
4410
|
+
}
|
|
4411
|
+
lastJumpResult = result;
|
|
4412
|
+
}
|
|
4413
|
+
const mode = typeof jump.condition_mode === "string" && jump.condition_mode.trim() ? jump.condition_mode.trim() : "code";
|
|
4414
|
+
let script = "";
|
|
4415
|
+
if (mode === "standard") {
|
|
4416
|
+
if (typeof jump.standard_condition === "string" && jump.standard_condition.trim()) {
|
|
4417
|
+
script = jump.standard_condition.trim();
|
|
4418
|
+
} else {
|
|
4419
|
+
nextErrors.push(`${pathName}.standard_condition is required when condition_mode is standard; condition is ignored by the backend in this mode.`);
|
|
4420
|
+
}
|
|
4421
|
+
} else if (mode === "code") {
|
|
4422
|
+
if (typeof jump.condition === "string" && jump.condition.trim()) {
|
|
4423
|
+
script = jump.condition.trim();
|
|
4424
|
+
} else {
|
|
4425
|
+
nextErrors.push(`${pathName}.condition is required when condition_mode is code or omitted; standard_condition is ignored by the backend in code mode.`);
|
|
4426
|
+
}
|
|
4427
|
+
} else {
|
|
4428
|
+
nextErrors.push(`${pathName}.condition_mode must be code or standard.`);
|
|
4429
|
+
}
|
|
4430
|
+
if (script) {
|
|
4431
|
+
lastJumpScript = script;
|
|
4432
|
+
if (index < jumps.length - 1 && startConditionalJumpScriptIsCatchAll(script)) {
|
|
4433
|
+
nextErrors.push(
|
|
4434
|
+
`${pathName} is a catch-all start route but is not the final item; return true must only appear on the last explicit fallback route.`
|
|
4435
|
+
);
|
|
4436
|
+
}
|
|
4437
|
+
if (startConditionalJumpScriptLooksLikeIndexReturn(script)) {
|
|
4438
|
+
nextErrors.push(
|
|
4439
|
+
`${pathName} must return boolean/truthy for this explicit start edge, not a node-level result index; do not copy node.condational_nodes scripts such as return 0/1/-1 into data.meta.condational_jump.`
|
|
4440
|
+
);
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4443
|
+
});
|
|
4444
|
+
}
|
|
4445
|
+
if (Array.isArray(jumps) && jumps.length && nodes.length) {
|
|
4446
|
+
if (!lastJumpResult || !startConditionalJumpScriptIsCatchAll(lastJumpScript)) {
|
|
4447
|
+
nextErrors.push(
|
|
4448
|
+
"data.meta.condational_jump must end with an explicit catch-all route using condition script return true; this documents the default start path instead of relying on implicit fallback."
|
|
4449
|
+
);
|
|
4450
|
+
}
|
|
4451
|
+
}
|
|
4452
|
+
if (!nextErrors.length) {
|
|
4453
|
+
return;
|
|
4454
|
+
}
|
|
4455
|
+
if (errors) {
|
|
4456
|
+
errors.push(...nextErrors);
|
|
4457
|
+
return;
|
|
4458
|
+
}
|
|
4459
|
+
throw new Error(`flow-template start conditional jump gate failed: ${nextErrors.join("; ")}`);
|
|
4460
|
+
}
|
|
4342
4461
|
function looksLikeParseEvalFunctionBody(script) {
|
|
4343
4462
|
const text5 = script.trim();
|
|
4344
4463
|
if (!text5) {
|
|
@@ -5013,6 +5132,7 @@ function normalizeFlowTemplatePayload(work) {
|
|
|
5013
5132
|
validateFlowTemplateRemoteTemplateRefs({ ...work, data });
|
|
5014
5133
|
validateFlowTemplateProjectAfterCreatePath({ ...work, data });
|
|
5015
5134
|
validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
|
|
5135
|
+
validateFlowTemplateStartConditionalJump({ ...work, data });
|
|
5016
5136
|
validateFlowTemplateCodeModeMessages({ ...work, data });
|
|
5017
5137
|
validateFlowTemplateRuntimeScripts({ ...work, data });
|
|
5018
5138
|
validateFlowTemplateFeishuChatPlugin({ ...work, data });
|
|
@@ -6888,6 +7008,7 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
6888
7008
|
validateFlowTemplateRemoteTemplateRefs(work);
|
|
6889
7009
|
validateFlowTemplateProjectAfterCreatePath(work);
|
|
6890
7010
|
validateFlowTemplateStandardPageCreateFormTemplate(work);
|
|
7011
|
+
validateFlowTemplateStartConditionalJump(work);
|
|
6891
7012
|
validateFlowTemplateCodeModeMessages(work);
|
|
6892
7013
|
validateFlowTemplateRuntimeScripts(work);
|
|
6893
7014
|
validateFlowTemplateFeishuChatPlugin(work);
|
|
@@ -7783,6 +7904,7 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
7783
7904
|
validateFlowTemplateRemoteTemplateRefs(flowWork, errors);
|
|
7784
7905
|
validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
|
|
7785
7906
|
validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
|
|
7907
|
+
validateFlowTemplateStartConditionalJump(flowWork, errors);
|
|
7786
7908
|
validateFlowTemplateCodeModeMessages(flowWork, errors);
|
|
7787
7909
|
validateFlowTemplateRuntimeScripts(flowWork, errors);
|
|
7788
7910
|
validateFlowTemplateFeishuChatPlugin(flowWork, errors);
|
|
@@ -8135,6 +8257,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
8135
8257
|
validateFlowTemplateRemoteTemplateRefs(submit.payload);
|
|
8136
8258
|
validateFlowTemplateProjectAfterCreatePath(submit.payload);
|
|
8137
8259
|
validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
|
|
8260
|
+
validateFlowTemplateStartConditionalJump(submit.payload);
|
|
8138
8261
|
validateFlowTemplateCodeModeMessages(submit.payload);
|
|
8139
8262
|
validateFlowTemplateRuntimeScripts(submit.payload);
|
|
8140
8263
|
validateFlowTemplateFeishuChatPlugin(submit.payload);
|