bpmax-cli 0.1.44-beta.11 → 0.1.44-beta.12

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
@@ -444,7 +444,7 @@ function normalizePath2(path9) {
444
444
  // package.json
445
445
  var package_default = {
446
446
  name: "bpmax-cli",
447
- version: "0.1.44-beta.11",
447
+ version: "0.1.44-beta.12",
448
448
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
449
449
  type: "module",
450
450
  bin: {
@@ -3106,6 +3106,133 @@ function validateFlowTemplateFormDrivenCreateBaseline(value, errors, options = {
3106
3106
  }
3107
3107
  throw new Error(message);
3108
3108
  }
3109
+ function validateFlowTemplateProjectAfterCreatePath(value, errors) {
3110
+ const data = isRecord3(value.data) ? value.data : {};
3111
+ const meta = isRecord3(data.meta) ? data.meta : {};
3112
+ const script = meta.project_after_create_path;
3113
+ if (script === void 0 || script === null || script === "") {
3114
+ return;
3115
+ }
3116
+ const message = "data.meta.project_after_create_path must be a script string starting with `return` so the project create page receives a route path.";
3117
+ if (typeof script !== "string" || !script.trim().startsWith("return")) {
3118
+ if (errors) {
3119
+ errors.push(message);
3120
+ return;
3121
+ }
3122
+ throw new Error(message);
3123
+ }
3124
+ }
3125
+ function validateFlowTemplateStandardPageCreateFormTemplate(value, errors) {
3126
+ const data = isRecord3(value.data) ? value.data : {};
3127
+ const meta = isRecord3(data.meta) ? data.meta : {};
3128
+ if (meta.project_create_mode !== "standard" || meta.project_create_standard_mode !== "page") {
3129
+ return;
3130
+ }
3131
+ if (!isEmptyTemplateReference(meta.form_template)) {
3132
+ return;
3133
+ }
3134
+ const nodes = Array.isArray(data.nodes) ? data.nodes : [];
3135
+ const nodeNames = nodes.filter(isRecord3).filter((node) => !isEmptyTemplateReference(node.form_template)).map((node, index) => {
3136
+ const name = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
3137
+ return name;
3138
+ });
3139
+ if (nodeNames.length === 0) {
3140
+ return;
3141
+ }
3142
+ const message = `data.meta.form_template is required for standard page project create when node.form_template is configured; project create pages load the create form from meta.form_template, not from node.form_template (${nodeNames.join(", ")}).`;
3143
+ if (errors) {
3144
+ errors.push(message);
3145
+ return;
3146
+ }
3147
+ throw new Error(message);
3148
+ }
3149
+ function looksLikeParseEvalFunctionBody(script) {
3150
+ const text5 = script.trim();
3151
+ if (!text5) {
3152
+ return false;
3153
+ }
3154
+ const firstToken = text5.split(/\s+/, 1)[0] || "";
3155
+ if (/^(return|if|const|let|var|try|for|while|switch|async|await|function|\{)/.test(firstToken)) {
3156
+ return true;
3157
+ }
3158
+ return text5.startsWith("(") && (text5.includes("=>") || text5.includes("function"));
3159
+ }
3160
+ function addCodeModeMessageScriptError(errors, pathName) {
3161
+ errors.push(
3162
+ `${pathName} is code-mode message content but is not a parseEvalFunction body; wrap literal text as a JS return script, for example: return "\u8BF7\u5904\u7406...";`
3163
+ );
3164
+ }
3165
+ function validateCodeModeMessageScript(errors, pathName, value) {
3166
+ if (value === void 0 || value === null || value === "") {
3167
+ return;
3168
+ }
3169
+ if (typeof value !== "string" || !looksLikeParseEvalFunctionBody(value)) {
3170
+ addCodeModeMessageScriptError(errors, pathName);
3171
+ }
3172
+ }
3173
+ function validateCodeModeMessageActionUrl(errors, pathName, value) {
3174
+ if (value === void 0 || value === null || value === "") {
3175
+ return;
3176
+ }
3177
+ if (typeof value !== "string") {
3178
+ errors.push(`${pathName} is code-mode message action URL but is not a string script.`);
3179
+ return;
3180
+ }
3181
+ if (value.includes("${") && !looksLikeParseEvalFunctionBody(value)) {
3182
+ errors.push(
3183
+ `${pathName} contains template interpolation but is not a parseEvalFunction body; use a JS return script such as: return '/projectContinue?id=' + step.project_id + '&step_id=' + step.id;`
3184
+ );
3185
+ }
3186
+ }
3187
+ function validateFlowTemplateCodeModeMessages(value, errors) {
3188
+ const nextErrors = [];
3189
+ const data = isRecord3(value.data) ? value.data : {};
3190
+ const meta = isRecord3(data.meta) ? data.meta : {};
3191
+ if (meta.message_config_mode === "code") {
3192
+ validateCodeModeMessageScript(nextErrors, "data.meta.message_template", meta.message_template);
3193
+ }
3194
+ if (meta.cc_message_config_mode === "code" || meta.project_cc_message_config_mode === "code") {
3195
+ validateCodeModeMessageScript(nextErrors, "data.meta.cc_message_template", meta.cc_message_template);
3196
+ }
3197
+ const nodes = Array.isArray(data.nodes) ? data.nodes : [];
3198
+ nodes.forEach((node, index) => {
3199
+ if (!isRecord3(node)) {
3200
+ return;
3201
+ }
3202
+ const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
3203
+ if (node.message_config_mode === "code") {
3204
+ validateCodeModeMessageScript(nextErrors, `${nodeName}.message_template`, node.message_template);
3205
+ const simpleTemplate = isRecord3(node.message_template_simple) ? node.message_template_simple : {};
3206
+ const actions = Array.isArray(simpleTemplate.actions) ? simpleTemplate.actions : [];
3207
+ actions.forEach((action, actionIndex) => {
3208
+ if (!isRecord3(action)) {
3209
+ return;
3210
+ }
3211
+ validateCodeModeMessageActionUrl(
3212
+ nextErrors,
3213
+ `${nodeName}.message_template_simple.actions[${actionIndex}].url`,
3214
+ action.url
3215
+ );
3216
+ validateCodeModeMessageActionUrl(
3217
+ nextErrors,
3218
+ `${nodeName}.message_template_simple.actions[${actionIndex}].m_url`,
3219
+ action.m_url
3220
+ );
3221
+ });
3222
+ }
3223
+ if (node.cc_message_config_mode === "code" || node.step_cc_message_config_mode === "code") {
3224
+ validateCodeModeMessageScript(nextErrors, `${nodeName}.cc_message_template`, node.cc_message_template);
3225
+ }
3226
+ });
3227
+ if (!nextErrors.length) {
3228
+ return;
3229
+ }
3230
+ if (errors) {
3231
+ errors.push(...nextErrors);
3232
+ return;
3233
+ }
3234
+ throw new Error(`flow-template code-mode message gate failed: ${nextErrors.join("; ")}`);
3235
+ }
3109
3236
  function isEmptyTemplateReference(value) {
3110
3237
  return value === void 0 || value === null || value === "" || value === 0 || value === "0";
3111
3238
  }
@@ -3541,6 +3668,9 @@ function normalizeFlowTemplatePayload(work) {
3541
3668
  }
3542
3669
  data.meta = meta;
3543
3670
  validateFlowTemplateRemoteTemplateRefs({ ...work, data });
3671
+ validateFlowTemplateProjectAfterCreatePath({ ...work, data });
3672
+ validateFlowTemplateStandardPageCreateFormTemplate({ ...work, data });
3673
+ validateFlowTemplateCodeModeMessages({ ...work, data });
3544
3674
  const payload = pickDefined(work, [
3545
3675
  "name",
3546
3676
  "flow_type",
@@ -4756,6 +4886,9 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
4756
4886
  throw new Error("flow-template create requires a work JSON object.");
4757
4887
  }
4758
4888
  validateFlowTemplateRemoteTemplateRefs(work);
4889
+ validateFlowTemplateProjectAfterCreatePath(work);
4890
+ validateFlowTemplateStandardPageCreateFormTemplate(work);
4891
+ validateFlowTemplateCodeModeMessages(work);
4759
4892
  validateFlowTemplateFormDrivenCreateBaseline(work, void 0, { context: "flow-template create" });
4760
4893
  const createShell = {
4761
4894
  name: String(work.name || ""),
@@ -5191,6 +5324,9 @@ async function lintConfigWorkFile(file) {
5191
5324
  if (isFlowTemplateWork(value)) {
5192
5325
  const flowWork = value;
5193
5326
  validateFlowTemplateRemoteTemplateRefs(flowWork, errors);
5327
+ validateFlowTemplateProjectAfterCreatePath(flowWork, errors);
5328
+ validateFlowTemplateStandardPageCreateFormTemplate(flowWork, errors);
5329
+ validateFlowTemplateCodeModeMessages(flowWork, errors);
5194
5330
  if (flowWork.mode === "create") {
5195
5331
  validateFlowTemplateFormDrivenCreateBaseline(flowWork, errors, { context: "flow-template create" });
5196
5332
  } else {
@@ -5421,6 +5557,9 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
5421
5557
  await ensureConfigCapability(profile, `${definition.capability}.export`);
5422
5558
  if (domain === "flow-template") {
5423
5559
  validateFlowTemplateRemoteTemplateRefs(submit.payload);
5560
+ validateFlowTemplateProjectAfterCreatePath(submit.payload);
5561
+ validateFlowTemplateStandardPageCreateFormTemplate(submit.payload);
5562
+ validateFlowTemplateCodeModeMessages(submit.payload);
5424
5563
  validateFlowTemplateStandardFlowType(submit.payload);
5425
5564
  validateFlowTemplateIdentityStandard(id, submit.payload);
5426
5565
  }