bpmax-cli 0.2.1-beta.87 → 0.2.1-beta.88
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 +1056 -33
- package/dist/bin.js.map +1 -1
- package/package.json +1 -1
- package/skills/bpmax-blueprint-doc-workflow/SKILL.md +24 -4
- package/skills/bpmax-blueprint-doc-workflow/references/blueprint-structure.md +16 -8
- package/skills/bpmax-blueprint-doc-workflow/references/business-language.md +74 -0
- package/skills/bpmax-blueprint-doc-workflow/references/review-and-confirmation-dialogue.md +70 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-missing-review-record.xml +72 -0
- package/skills/bpmax-blueprint-doc-workflow/references/sample-pass.xml +35 -28
- package/skills/bpmax-blueprint-doc-workflow/references/sample-system-identifier.xml +79 -0
- package/skills/bpmax-blueprint-doc-workflow/scripts/lint_blueprint_doc.py +200 -0
- package/skills/bpmax-flow-template-editor/SKILL.md +3 -0
- package/skills/bpmax-flow-template-editor/references/full-detail-guide.md +4 -0
- package/skills/bpmax-flow-template-editor/references/message-card-professional-standard.md +234 -0
- package/skills/bpmax-flow-template-editor/references/script-review-hard-rules.md +17 -0
- package/skills/bpmax-list-template-editor/SKILL.md +3 -1
package/dist/bin.js
CHANGED
|
@@ -540,7 +540,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
|
|
|
540
540
|
// package.json
|
|
541
541
|
var package_default = {
|
|
542
542
|
name: "bpmax-cli",
|
|
543
|
-
version: "0.2.1-beta.
|
|
543
|
+
version: "0.2.1-beta.88",
|
|
544
544
|
description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
|
|
545
545
|
type: "module",
|
|
546
546
|
bin: {
|
|
@@ -5067,13 +5067,29 @@ function changedJsonPaths(before, after, base = "") {
|
|
|
5067
5067
|
const keys = /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)]);
|
|
5068
5068
|
for (const key of keys) {
|
|
5069
5069
|
const current = `${base}/${pointerSegment2(key)}`;
|
|
5070
|
-
if (!(key in before) || !(key in after))
|
|
5071
|
-
|
|
5070
|
+
if (!(key in before) || !(key in after)) {
|
|
5071
|
+
const added = key in after ? after[key] : before[key];
|
|
5072
|
+
paths.push(...leafPaths(added, current));
|
|
5073
|
+
continue;
|
|
5074
|
+
}
|
|
5075
|
+
paths.push(...changedJsonPaths(before[key], after[key], current));
|
|
5072
5076
|
}
|
|
5073
5077
|
return paths;
|
|
5074
5078
|
}
|
|
5075
5079
|
return [base || "/"];
|
|
5076
5080
|
}
|
|
5081
|
+
function leafPaths(value, base) {
|
|
5082
|
+
if (Array.isArray(value)) {
|
|
5083
|
+
if (!value.length) return [base];
|
|
5084
|
+
return value.flatMap((item, index) => leafPaths(item, `${base}/${index}`));
|
|
5085
|
+
}
|
|
5086
|
+
if (isRecord5(value)) {
|
|
5087
|
+
const keys = Object.keys(value);
|
|
5088
|
+
if (!keys.length) return [base];
|
|
5089
|
+
return keys.flatMap((key) => leafPaths(value[key], `${base}/${pointerSegment2(key)}`));
|
|
5090
|
+
}
|
|
5091
|
+
return [base];
|
|
5092
|
+
}
|
|
5077
5093
|
function textOf(value) {
|
|
5078
5094
|
if (typeof value === "string") return value;
|
|
5079
5095
|
if (Array.isArray(value)) return value.map(textOf).join(" ");
|
|
@@ -5167,6 +5183,15 @@ function validateListTemplateColumnWidthEvidence(value, context2) {
|
|
|
5167
5183
|
if (!columns.length) {
|
|
5168
5184
|
throw new Error("[list_template_column_width_report_invalid] Column-width report must record at least one measured column.");
|
|
5169
5185
|
}
|
|
5186
|
+
const expectedColumns = Number(value.template_data_columns);
|
|
5187
|
+
if (!Number.isSafeInteger(expectedColumns) || expectedColumns <= 0) {
|
|
5188
|
+
throw new Error("[list_template_column_width_report_invalid] Column-width report must declare template_data_columns (the number of data columns in the template).");
|
|
5189
|
+
}
|
|
5190
|
+
if (columns.length < expectedColumns) {
|
|
5191
|
+
throw new Error(
|
|
5192
|
+
`[list_template_column_width_report_incomplete] Column-width report measured ${columns.length} of ${expectedColumns} data columns; measure every data column before submitting.`
|
|
5193
|
+
);
|
|
5194
|
+
}
|
|
5170
5195
|
const unmeasured = columns.filter((column) => typeof column.truncated !== "boolean");
|
|
5171
5196
|
if (unmeasured.length) {
|
|
5172
5197
|
throw new Error(
|
|
@@ -6860,6 +6885,7 @@ function validateFlowAppFlowWork(value, errors, warnings) {
|
|
|
6860
6885
|
validateFlowTemplateUrgentReminder(value, errors);
|
|
6861
6886
|
validateFlowTemplateStandardConditionEditorRules(value, errors);
|
|
6862
6887
|
validateFlowTemplateCodeModeMessages(value, errors);
|
|
6888
|
+
validateFlowTemplateMessageCards(value, errors, warnings);
|
|
6863
6889
|
validateFlowTemplateRuntimeScripts(value, errors);
|
|
6864
6890
|
validateFlowTemplateFeishuChatPlugin(value, errors);
|
|
6865
6891
|
validateFlowTemplateFormDrivenCreateBaseline(value, errors, {
|
|
@@ -7179,6 +7205,54 @@ var FLOW_TEMPLATE_RUNTIME_CC_TYPES = /* @__PURE__ */ new Set(["fieldvalue", "mat
|
|
|
7179
7205
|
var FLOW_TEMPLATE_CC_TRIGGER_MODES = /* @__PURE__ */ new Set(["all", "approve", "refuse"]);
|
|
7180
7206
|
var FLOW_TEMPLATE_CC_TRIGGER_TIMINGS = /* @__PURE__ */ new Set(["step_active", "step_finish"]);
|
|
7181
7207
|
var FLOW_TEMPLATE_MATRIX_FLOW_PATTERN = /^[^:\s]+:[^:\s]*$/;
|
|
7208
|
+
var FLOW_TEMPLATE_MESSAGE_CARD_RULES = {
|
|
7209
|
+
schemaUnsupported: "flow.message.card_schema_unsupported",
|
|
7210
|
+
noBusinessKeys: "flow.message.card_no_business_keys",
|
|
7211
|
+
simpleFieldMissingReturn: "flow.message.simple_field_missing_return",
|
|
7212
|
+
card2Ignored: "flow.message.card2_key_ignored",
|
|
7213
|
+
colorInvalid: "flow.message.card_color_invalid",
|
|
7214
|
+
actionInvalid: "flow.message.action_invalid",
|
|
7215
|
+
actionBtnTypeUnknown: "flow.message.action_btn_type_unknown",
|
|
7216
|
+
titleStatic: "flow.message.card_title_static",
|
|
7217
|
+
titleEmpty: "flow.message.card_title_empty",
|
|
7218
|
+
contentMissing: "flow.message.card_content_missing",
|
|
7219
|
+
contentEmpty: "flow.message.card_content_empty",
|
|
7220
|
+
contentNotString: "flow.message.card_content_not_string",
|
|
7221
|
+
actionsMissing: "flow.message.card_actions_missing",
|
|
7222
|
+
actionTypeUnsupported: "flow.message.action_type_unsupported",
|
|
7223
|
+
modeSimpleUnsupported: "flow.message.config_mode_simple_unsupported",
|
|
7224
|
+
missingForHumanNode: "flow.message.missing_for_human_node",
|
|
7225
|
+
onSystemNode: "flow.message.on_system_node",
|
|
7226
|
+
ccMessageMissing: "flow.message.cc_message_missing"
|
|
7227
|
+
};
|
|
7228
|
+
var FLOW_TEMPLATE_MESSAGE_CARD_COLORS = /* @__PURE__ */ new Set([
|
|
7229
|
+
"wathet",
|
|
7230
|
+
"blue",
|
|
7231
|
+
"turquoise",
|
|
7232
|
+
"green",
|
|
7233
|
+
"yellow",
|
|
7234
|
+
"orange",
|
|
7235
|
+
"red",
|
|
7236
|
+
"carmine",
|
|
7237
|
+
"violet",
|
|
7238
|
+
"purple",
|
|
7239
|
+
"indigo",
|
|
7240
|
+
"grey"
|
|
7241
|
+
]);
|
|
7242
|
+
var FLOW_TEMPLATE_MESSAGE_CARD2_KEYS = /* @__PURE__ */ new Set(["schema", "body", "header", "config"]);
|
|
7243
|
+
var FLOW_TEMPLATE_MESSAGE_CARD2_BUSINESS_KEYS = ["title", "content", "elements", "actions"];
|
|
7244
|
+
var FLOW_TEMPLATE_MESSAGE_BUTTON_TYPES = /* @__PURE__ */ new Set([
|
|
7245
|
+
"default",
|
|
7246
|
+
"primary",
|
|
7247
|
+
"danger",
|
|
7248
|
+
"text",
|
|
7249
|
+
"primary_text",
|
|
7250
|
+
"danger_text",
|
|
7251
|
+
"primary_filled",
|
|
7252
|
+
"danger_filled",
|
|
7253
|
+
"laser"
|
|
7254
|
+
]);
|
|
7255
|
+
var FLOW_TEMPLATE_SIMPLE_BUTTON_TARGETS = /* @__PURE__ */ new Set(["none", "step", "project", "custom"]);
|
|
7182
7256
|
function isPositiveIntegerLike(value) {
|
|
7183
7257
|
if (typeof value !== "number" && typeof value !== "string") {
|
|
7184
7258
|
return false;
|
|
@@ -7920,7 +7994,34 @@ function isStaticEmptyMessageReturn(script) {
|
|
|
7920
7994
|
return false;
|
|
7921
7995
|
}
|
|
7922
7996
|
const compact = text5.replace(/\s+/g, " ").trim();
|
|
7923
|
-
|
|
7997
|
+
if (/^(return (?:""|''|``);?)+$/.test(compact)) {
|
|
7998
|
+
return true;
|
|
7999
|
+
}
|
|
8000
|
+
return /^(?:return|return null|return undefined|return \[\])$/.test(text5.replace(/\s+/g, " ").replace(/;+$/, "").trim());
|
|
8001
|
+
}
|
|
8002
|
+
function isStaticNoBusinessKeyReturn(script) {
|
|
8003
|
+
const program2 = parseMessageScriptProgram(script);
|
|
8004
|
+
if (!program2) {
|
|
8005
|
+
return false;
|
|
8006
|
+
}
|
|
8007
|
+
const bindings = collectMessageBindings(program2);
|
|
8008
|
+
const objects = [];
|
|
8009
|
+
for (const argument of collectMessageReturnArguments(program2)) {
|
|
8010
|
+
resolveMessageReturnObjects(argument, bindings, objects);
|
|
8011
|
+
}
|
|
8012
|
+
if (!objects.length) {
|
|
8013
|
+
return false;
|
|
8014
|
+
}
|
|
8015
|
+
return objects.every((object) => {
|
|
8016
|
+
if (astObjectHasSpread(object)) {
|
|
8017
|
+
return false;
|
|
8018
|
+
}
|
|
8019
|
+
const names = object.properties.filter((property) => property.type === "Property" && !property.computed).map((property) => {
|
|
8020
|
+
const key = property.key;
|
|
8021
|
+
return key.type === "Identifier" ? String(key.name) : String(key.value ?? "");
|
|
8022
|
+
});
|
|
8023
|
+
return !FLOW_TEMPLATE_MESSAGE_CARD2_BUSINESS_KEYS.some((name) => names.includes(name));
|
|
8024
|
+
});
|
|
7924
8025
|
}
|
|
7925
8026
|
function looksLikeDynamicMessageSuppression(script) {
|
|
7926
8027
|
if (isStaticEmptyMessageReturn(script)) {
|
|
@@ -8048,13 +8149,13 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8048
8149
|
}
|
|
8049
8150
|
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
|
|
8050
8151
|
const nodeId = String(node.id ?? "").trim();
|
|
8051
|
-
const
|
|
8052
|
-
const
|
|
8053
|
-
|
|
8054
|
-
|
|
8152
|
+
const messageWouldReachRecipient = flowTemplateNodeHasActualOwner(node) && !flowTemplateNodeIsAutomaticWait(node);
|
|
8153
|
+
const ccWouldReachRecipient = flowTemplateNodeCcRecipientsConfigured(node);
|
|
8154
|
+
const inspectChannel = (channel, pathName, script, validateScriptShape, runtimeCodeMode, wouldReachRecipient) => {
|
|
8155
|
+
if (validateScriptShape) {
|
|
8156
|
+
validateCodeModeMessageScript(nextErrors, pathName, script);
|
|
8055
8157
|
}
|
|
8056
|
-
|
|
8057
|
-
if (typeof script !== "string") {
|
|
8158
|
+
if (!runtimeCodeMode || typeof script !== "string") {
|
|
8058
8159
|
return;
|
|
8059
8160
|
}
|
|
8060
8161
|
const ackKey = `${nodeId}\0${channel}`;
|
|
@@ -8063,18 +8164,25 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8063
8164
|
if (ack) {
|
|
8064
8165
|
usedAcks.add(ackKey);
|
|
8065
8166
|
nextWarnings.push(
|
|
8066
|
-
`[flow.message.suppression_acked] ${pathName} is a static empty return; outbound ${channel} messages are suppressed because ${ack.reason}.`
|
|
8167
|
+
`[flow.message.suppression_acked] ${pathName} is a static empty/no-op return; outbound ${channel} messages are suppressed because ${ack.reason}.`
|
|
8067
8168
|
);
|
|
8068
8169
|
return;
|
|
8069
8170
|
}
|
|
8070
|
-
if (
|
|
8171
|
+
if (wouldReachRecipient) {
|
|
8071
8172
|
nextErrors.push(
|
|
8072
|
-
`[flow.message.suppression_requires_ack] ${pathName} statically returns an empty
|
|
8173
|
+
`[flow.message.suppression_requires_ack] ${pathName} statically returns an empty value (return; / null / undefined / []), ` + (channel === "cc" ? "which disables outbound cc messages for a node that actually has CC recipients configured. " : "which disables outbound message notifications for a node whose owners would receive them. ") + "Add bpmax_lint.suppressed_node_messages[] with node_id, channel, and a non-empty reason. Ordinary and CC channels are independent."
|
|
8073
8174
|
);
|
|
8074
8175
|
return;
|
|
8075
8176
|
}
|
|
8076
8177
|
nextWarnings.push(
|
|
8077
|
-
`[flow.message.suppression_unacked] ${pathName} statically returns an empty
|
|
8178
|
+
`[flow.message.suppression_unacked] ${pathName} statically returns an empty value (return; / null / undefined / []) and will suppress outbound ${channel} messages. Add bpmax_lint.suppressed_node_messages[] if this is intentional.`
|
|
8179
|
+
);
|
|
8180
|
+
return;
|
|
8181
|
+
}
|
|
8182
|
+
if (ack && isStaticNoBusinessKeyReturn(script)) {
|
|
8183
|
+
usedAcks.add(ackKey);
|
|
8184
|
+
nextWarnings.push(
|
|
8185
|
+
`[flow.message.suppression_acked] ${pathName} statically returns an object without title/content/elements/actions; outbound ${channel} messages are suppressed because ${ack.reason}.`
|
|
8078
8186
|
);
|
|
8079
8187
|
return;
|
|
8080
8188
|
}
|
|
@@ -8084,11 +8192,19 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8084
8192
|
);
|
|
8085
8193
|
}
|
|
8086
8194
|
};
|
|
8195
|
+
const messageModeForGate = resolveMessageChannelMode(
|
|
8196
|
+
node,
|
|
8197
|
+
["message_config_mode", "message_template_mode"],
|
|
8198
|
+
node.message_template,
|
|
8199
|
+
node.message_template_simple
|
|
8200
|
+
);
|
|
8087
8201
|
inspectChannel(
|
|
8088
8202
|
"message",
|
|
8089
8203
|
`${nodeName}.message_template`,
|
|
8090
8204
|
node.message_template,
|
|
8091
|
-
isCodeModeMessage(node, ["message_config_mode", "message_template_mode"])
|
|
8205
|
+
isCodeModeMessage(node, ["message_config_mode", "message_template_mode"]),
|
|
8206
|
+
messageModeForGate === "code",
|
|
8207
|
+
messageWouldReachRecipient
|
|
8092
8208
|
);
|
|
8093
8209
|
if (isCodeModeMessage(node, ["message_config_mode", "message_template_mode"])) {
|
|
8094
8210
|
const simpleTemplate = isRecord6(node.message_template_simple) ? node.message_template_simple : {};
|
|
@@ -8113,7 +8229,14 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8113
8229
|
"cc",
|
|
8114
8230
|
`${nodeName}.cc_message_template`,
|
|
8115
8231
|
node.cc_message_template,
|
|
8116
|
-
isCodeModeMessage(node, ["cc_message_config_mode", "step_cc_message_config_mode", "cc_message_template_mode"])
|
|
8232
|
+
isCodeModeMessage(node, ["cc_message_config_mode", "step_cc_message_config_mode", "cc_message_template_mode"]),
|
|
8233
|
+
resolveMessageChannelMode(
|
|
8234
|
+
node,
|
|
8235
|
+
["cc_message_config_mode", "step_cc_message_config_mode", "cc_message_template_mode"],
|
|
8236
|
+
node.cc_message_template,
|
|
8237
|
+
node.step_cc_message_template_simple
|
|
8238
|
+
) === "code",
|
|
8239
|
+
ccWouldReachRecipient
|
|
8117
8240
|
);
|
|
8118
8241
|
});
|
|
8119
8242
|
for (const [key, ack] of acks) {
|
|
@@ -8138,6 +8261,886 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8138
8261
|
}
|
|
8139
8262
|
throw new Error(`flow-template code-mode message gate failed: ${nextErrors.join("; ")}`);
|
|
8140
8263
|
}
|
|
8264
|
+
function resolveMessageChannelMode(value, keys, codeTemplate, simpleTemplate) {
|
|
8265
|
+
if (keys.some((key) => value[key] === "standard")) {
|
|
8266
|
+
return isRecord6(simpleTemplate) ? "standard" : "none";
|
|
8267
|
+
}
|
|
8268
|
+
if (keys.some((key) => value[key] === "simple")) {
|
|
8269
|
+
return isRecord6(simpleTemplate) ? "simple" : "none";
|
|
8270
|
+
}
|
|
8271
|
+
if (isCodeModeMessage(value, keys)) {
|
|
8272
|
+
return typeof codeTemplate === "string" && codeTemplate.trim() ? "code" : "none";
|
|
8273
|
+
}
|
|
8274
|
+
return typeof codeTemplate === "string" && codeTemplate.trim() ? "code" : "none";
|
|
8275
|
+
}
|
|
8276
|
+
function collectMessageSuppressionAckKeys(value) {
|
|
8277
|
+
const lint = isRecord6(value.bpmax_lint) ? value.bpmax_lint : {};
|
|
8278
|
+
const declarations = Array.isArray(lint.suppressed_node_messages) ? lint.suppressed_node_messages : [];
|
|
8279
|
+
const keys = /* @__PURE__ */ new Set();
|
|
8280
|
+
declarations.forEach((declaration) => {
|
|
8281
|
+
if (!isRecord6(declaration)) {
|
|
8282
|
+
return;
|
|
8283
|
+
}
|
|
8284
|
+
const nodeId = String(declaration.node_id ?? "").trim();
|
|
8285
|
+
const channel = String(declaration.channel ?? "").trim();
|
|
8286
|
+
if (nodeId && channel) {
|
|
8287
|
+
keys.add(`${nodeId}\0${channel}`);
|
|
8288
|
+
}
|
|
8289
|
+
});
|
|
8290
|
+
return keys;
|
|
8291
|
+
}
|
|
8292
|
+
function parseMessageScriptProgram(script) {
|
|
8293
|
+
try {
|
|
8294
|
+
return parse2(script, {
|
|
8295
|
+
ecmaVersion: "latest",
|
|
8296
|
+
sourceType: "script",
|
|
8297
|
+
allowAwaitOutsideFunction: true,
|
|
8298
|
+
allowReturnOutsideFunction: true
|
|
8299
|
+
});
|
|
8300
|
+
} catch {
|
|
8301
|
+
return null;
|
|
8302
|
+
}
|
|
8303
|
+
}
|
|
8304
|
+
var MESSAGE_SCRIPT_FUNCTION_TYPES = /* @__PURE__ */ new Set(["FunctionExpression", "FunctionDeclaration", "ArrowFunctionExpression"]);
|
|
8305
|
+
function collectMessageReturnArguments(node, result = []) {
|
|
8306
|
+
if (!node || typeof node.type !== "string") {
|
|
8307
|
+
return result;
|
|
8308
|
+
}
|
|
8309
|
+
if (node.type === "ReturnStatement") {
|
|
8310
|
+
if (node.argument) {
|
|
8311
|
+
result.push(node.argument);
|
|
8312
|
+
}
|
|
8313
|
+
return result;
|
|
8314
|
+
}
|
|
8315
|
+
if (MESSAGE_SCRIPT_FUNCTION_TYPES.has(node.type) || node.type === "ClassDeclaration" || node.type === "ClassExpression") {
|
|
8316
|
+
return result;
|
|
8317
|
+
}
|
|
8318
|
+
for (const [key, child] of Object.entries(node)) {
|
|
8319
|
+
if (key === "type" || key === "start" || key === "end" || key === "loc") {
|
|
8320
|
+
continue;
|
|
8321
|
+
}
|
|
8322
|
+
if (Array.isArray(child)) {
|
|
8323
|
+
child.forEach((item) => {
|
|
8324
|
+
if (item && typeof item === "object" && typeof item.type === "string") {
|
|
8325
|
+
collectMessageReturnArguments(item, result);
|
|
8326
|
+
}
|
|
8327
|
+
});
|
|
8328
|
+
} else if (child && typeof child === "object" && typeof child.type === "string") {
|
|
8329
|
+
collectMessageReturnArguments(child, result);
|
|
8330
|
+
}
|
|
8331
|
+
}
|
|
8332
|
+
return result;
|
|
8333
|
+
}
|
|
8334
|
+
function collectMessageBindings(program2) {
|
|
8335
|
+
const bindings = /* @__PURE__ */ new Map();
|
|
8336
|
+
walkAst(program2, (node) => {
|
|
8337
|
+
if (node.type === "VariableDeclarator" && node.id?.type === "Identifier") {
|
|
8338
|
+
const init = node.init;
|
|
8339
|
+
if (init) {
|
|
8340
|
+
bindings.set(String(node.id.name), init);
|
|
8341
|
+
}
|
|
8342
|
+
return;
|
|
8343
|
+
}
|
|
8344
|
+
if (node.type === "FunctionDeclaration" && node.id?.type === "Identifier") {
|
|
8345
|
+
bindings.set(String(node.id.name), node);
|
|
8346
|
+
}
|
|
8347
|
+
});
|
|
8348
|
+
return bindings;
|
|
8349
|
+
}
|
|
8350
|
+
function astCallIsGlobalMethod(node, objectName, methodName) {
|
|
8351
|
+
const callee = node.callee;
|
|
8352
|
+
if (!callee || callee.type !== "MemberExpression" || callee.computed) {
|
|
8353
|
+
return false;
|
|
8354
|
+
}
|
|
8355
|
+
const object = callee.object;
|
|
8356
|
+
const property = callee.property;
|
|
8357
|
+
return object?.type === "Identifier" && String(object.name) === objectName && property?.type === "Identifier" && String(property.name) === methodName;
|
|
8358
|
+
}
|
|
8359
|
+
function resolveMessageReturnObjects(node, bindings, result = [], depth = 0) {
|
|
8360
|
+
if (!node || depth > 8) {
|
|
8361
|
+
return result;
|
|
8362
|
+
}
|
|
8363
|
+
switch (node.type) {
|
|
8364
|
+
case "ObjectExpression":
|
|
8365
|
+
pushUniqueAstNode(result, node);
|
|
8366
|
+
return result;
|
|
8367
|
+
case "ParenthesizedExpression":
|
|
8368
|
+
return resolveMessageReturnObjects(node.expression, bindings, result, depth + 1);
|
|
8369
|
+
case "Identifier": {
|
|
8370
|
+
const init = bindings.get(String(node.name));
|
|
8371
|
+
return init ? resolveMessageReturnObjects(init, bindings, result, depth + 1) : result;
|
|
8372
|
+
}
|
|
8373
|
+
case "ConditionalExpression":
|
|
8374
|
+
resolveMessageReturnObjects(node.consequent, bindings, result, depth + 1);
|
|
8375
|
+
return resolveMessageReturnObjects(node.alternate, bindings, result, depth + 1);
|
|
8376
|
+
case "LogicalExpression":
|
|
8377
|
+
resolveMessageReturnObjects(node.right, bindings, result, depth + 1);
|
|
8378
|
+
return resolveMessageReturnObjects(node.left, bindings, result, depth + 1);
|
|
8379
|
+
case "SequenceExpression": {
|
|
8380
|
+
const expressions = node.expressions;
|
|
8381
|
+
return expressions.length ? resolveMessageReturnObjects(expressions[expressions.length - 1], bindings, result, depth + 1) : result;
|
|
8382
|
+
}
|
|
8383
|
+
case "CallExpression": {
|
|
8384
|
+
const callee = node.callee;
|
|
8385
|
+
if (astCallIsGlobalMethod(node, "Object", "assign")) {
|
|
8386
|
+
const args = node.arguments ?? [];
|
|
8387
|
+
const merged = [];
|
|
8388
|
+
let unresolvedArgument = false;
|
|
8389
|
+
for (const arg of args) {
|
|
8390
|
+
const fromArgument = [];
|
|
8391
|
+
resolveMessageReturnObjects(arg, bindings, fromArgument, depth + 1);
|
|
8392
|
+
if (!fromArgument.length) {
|
|
8393
|
+
unresolvedArgument = true;
|
|
8394
|
+
}
|
|
8395
|
+
for (const object of fromArgument) {
|
|
8396
|
+
pushUniqueAstNode(merged, object);
|
|
8397
|
+
}
|
|
8398
|
+
}
|
|
8399
|
+
if (merged.length) {
|
|
8400
|
+
const synthetic = mergeObjectExpressions(merged);
|
|
8401
|
+
if (unresolvedArgument) {
|
|
8402
|
+
synthetic.properties.push({
|
|
8403
|
+
type: "SpreadElement",
|
|
8404
|
+
argument: { type: "Identifier", name: "__unresolved_argument__" }
|
|
8405
|
+
});
|
|
8406
|
+
}
|
|
8407
|
+
pushUniqueAstNode(result, synthetic);
|
|
8408
|
+
}
|
|
8409
|
+
return result;
|
|
8410
|
+
}
|
|
8411
|
+
let fn = null;
|
|
8412
|
+
if (MESSAGE_SCRIPT_FUNCTION_TYPES.has(callee.type)) {
|
|
8413
|
+
fn = callee;
|
|
8414
|
+
} else if (callee.type === "Identifier") {
|
|
8415
|
+
const init = bindings.get(String(callee.name));
|
|
8416
|
+
if (init && MESSAGE_SCRIPT_FUNCTION_TYPES.has(init.type)) {
|
|
8417
|
+
fn = init;
|
|
8418
|
+
}
|
|
8419
|
+
}
|
|
8420
|
+
return fn ? resolveMessageFunctionResults(fn, bindings, result, depth + 1) : result;
|
|
8421
|
+
}
|
|
8422
|
+
case "ArrowFunctionExpression":
|
|
8423
|
+
case "FunctionExpression":
|
|
8424
|
+
return resolveMessageFunctionResults(node, bindings, result, depth + 1);
|
|
8425
|
+
default:
|
|
8426
|
+
return result;
|
|
8427
|
+
}
|
|
8428
|
+
}
|
|
8429
|
+
function pushUniqueAstNode(target, node) {
|
|
8430
|
+
if (!target.includes(node)) {
|
|
8431
|
+
target.push(node);
|
|
8432
|
+
}
|
|
8433
|
+
}
|
|
8434
|
+
function mergeObjectExpressions(objects) {
|
|
8435
|
+
const properties = [];
|
|
8436
|
+
for (const object of objects) {
|
|
8437
|
+
for (const property of object.properties ?? []) {
|
|
8438
|
+
if (property.type === "Property" && !property.computed) {
|
|
8439
|
+
const key = property.key;
|
|
8440
|
+
const name = key.type === "Identifier" ? String(key.name) : String(key.value ?? "");
|
|
8441
|
+
for (let index = properties.length - 1; index >= 0; index -= 1) {
|
|
8442
|
+
const existing = properties[index];
|
|
8443
|
+
if (existing.type !== "Property") {
|
|
8444
|
+
continue;
|
|
8445
|
+
}
|
|
8446
|
+
const existingKey = existing.key;
|
|
8447
|
+
const existingName = existingKey.type === "Identifier" ? String(existingKey.name) : String(existingKey.value ?? "");
|
|
8448
|
+
if (existingName === name) {
|
|
8449
|
+
properties.splice(index, 1);
|
|
8450
|
+
}
|
|
8451
|
+
}
|
|
8452
|
+
}
|
|
8453
|
+
properties.push(property);
|
|
8454
|
+
}
|
|
8455
|
+
}
|
|
8456
|
+
return { type: "ObjectExpression", properties };
|
|
8457
|
+
}
|
|
8458
|
+
function resolveMessageFunctionResults(fn, bindings, result, depth) {
|
|
8459
|
+
const body = fn.body;
|
|
8460
|
+
if (!body) {
|
|
8461
|
+
return result;
|
|
8462
|
+
}
|
|
8463
|
+
if (body.type !== "BlockStatement") {
|
|
8464
|
+
return resolveMessageReturnObjects(body, bindings, result, depth + 1);
|
|
8465
|
+
}
|
|
8466
|
+
for (const argument of collectMessageReturnArguments(body)) {
|
|
8467
|
+
resolveMessageReturnObjects(argument, bindings, result, depth + 1);
|
|
8468
|
+
}
|
|
8469
|
+
return result;
|
|
8470
|
+
}
|
|
8471
|
+
function astObjectPropertyValue(node, name) {
|
|
8472
|
+
if (!node || node.type !== "ObjectExpression") {
|
|
8473
|
+
return null;
|
|
8474
|
+
}
|
|
8475
|
+
for (const property of node.properties) {
|
|
8476
|
+
if (property.type !== "Property" || property.computed) {
|
|
8477
|
+
continue;
|
|
8478
|
+
}
|
|
8479
|
+
const key = property.key;
|
|
8480
|
+
const keyName = key.type === "Identifier" ? String(key.name) : String(key.value ?? "");
|
|
8481
|
+
if (keyName === name) {
|
|
8482
|
+
return property.value;
|
|
8483
|
+
}
|
|
8484
|
+
}
|
|
8485
|
+
return null;
|
|
8486
|
+
}
|
|
8487
|
+
function astObjectHasSpread(node) {
|
|
8488
|
+
return node.properties.some((property) => property.type === "SpreadElement");
|
|
8489
|
+
}
|
|
8490
|
+
function astStaticMessageText(node, bindings, depth = 0) {
|
|
8491
|
+
if (!node || depth > 8) {
|
|
8492
|
+
return null;
|
|
8493
|
+
}
|
|
8494
|
+
if (node.type === "Literal" && typeof node.value === "string") {
|
|
8495
|
+
return node.value;
|
|
8496
|
+
}
|
|
8497
|
+
if (node.type === "TemplateLiteral") {
|
|
8498
|
+
const expressions = node.expressions;
|
|
8499
|
+
if (expressions.length) {
|
|
8500
|
+
return null;
|
|
8501
|
+
}
|
|
8502
|
+
return node.quasis.map((quasi) => String(quasi.value?.cooked ?? "")).join("");
|
|
8503
|
+
}
|
|
8504
|
+
if (node.type === "ParenthesizedExpression") {
|
|
8505
|
+
return astStaticMessageText(node.expression, bindings, depth + 1);
|
|
8506
|
+
}
|
|
8507
|
+
if (node.type === "Identifier") {
|
|
8508
|
+
const init = bindings.get(String(node.name));
|
|
8509
|
+
return init ? astStaticMessageText(init, bindings, depth + 1) : null;
|
|
8510
|
+
}
|
|
8511
|
+
if (node.type === "BinaryExpression" && node.operator === "+") {
|
|
8512
|
+
const left = astStaticMessageText(node.left, bindings, depth + 1);
|
|
8513
|
+
const right = astStaticMessageText(node.right, bindings, depth + 1);
|
|
8514
|
+
return left !== null && right !== null ? left + right : null;
|
|
8515
|
+
}
|
|
8516
|
+
if (node.type === "ConditionalExpression") {
|
|
8517
|
+
const consequent = astStaticMessageText(node.consequent, bindings, depth + 1);
|
|
8518
|
+
const alternate = astStaticMessageText(node.alternate, bindings, depth + 1);
|
|
8519
|
+
return consequent !== null && consequent === alternate ? consequent : null;
|
|
8520
|
+
}
|
|
8521
|
+
return null;
|
|
8522
|
+
}
|
|
8523
|
+
function astMessageContentStaticText(node, bindings, depth = 0) {
|
|
8524
|
+
if (!node || depth > 8) {
|
|
8525
|
+
return null;
|
|
8526
|
+
}
|
|
8527
|
+
if (node.type === "ArrayExpression") {
|
|
8528
|
+
const parts = [];
|
|
8529
|
+
for (const element of node.elements) {
|
|
8530
|
+
if (!element || element.type !== "ObjectExpression") {
|
|
8531
|
+
return null;
|
|
8532
|
+
}
|
|
8533
|
+
const bodyNode = astObjectPropertyValue(element, "body");
|
|
8534
|
+
if (!bodyNode) {
|
|
8535
|
+
return null;
|
|
8536
|
+
}
|
|
8537
|
+
const text5 = astStaticMessageText(bodyNode, bindings, depth + 1);
|
|
8538
|
+
if (text5 === null) {
|
|
8539
|
+
return null;
|
|
8540
|
+
}
|
|
8541
|
+
parts.push(text5);
|
|
8542
|
+
}
|
|
8543
|
+
return parts.join("");
|
|
8544
|
+
}
|
|
8545
|
+
return astStaticMessageText(node, bindings, depth + 1);
|
|
8546
|
+
}
|
|
8547
|
+
function simpleMessageFieldStaticText(value) {
|
|
8548
|
+
if (typeof value !== "string") {
|
|
8549
|
+
return null;
|
|
8550
|
+
}
|
|
8551
|
+
if (!value.trim()) {
|
|
8552
|
+
return "";
|
|
8553
|
+
}
|
|
8554
|
+
const templateMatch = value.match(/^\s*return\s+`([\s\S]*?)`\s*;?\s*$/);
|
|
8555
|
+
if (templateMatch) {
|
|
8556
|
+
return templateMatch[1].includes("${") ? null : templateMatch[1];
|
|
8557
|
+
}
|
|
8558
|
+
const quotedMatch = value.match(/^\s*return\s+(['"])([\s\S]*?)\1\s*;?\s*$/);
|
|
8559
|
+
if (quotedMatch) {
|
|
8560
|
+
return quotedMatch[2];
|
|
8561
|
+
}
|
|
8562
|
+
if (/^\s*return\b/.test(value)) {
|
|
8563
|
+
return null;
|
|
8564
|
+
}
|
|
8565
|
+
if (value.includes("${") || /\b(?:ctx|context|step)\s*[.[]/.test(value)) {
|
|
8566
|
+
return null;
|
|
8567
|
+
}
|
|
8568
|
+
return value;
|
|
8569
|
+
}
|
|
8570
|
+
function simpleMessageFieldRuntimeText(value) {
|
|
8571
|
+
if (typeof value !== "string") {
|
|
8572
|
+
return null;
|
|
8573
|
+
}
|
|
8574
|
+
if (!value.trim()) {
|
|
8575
|
+
return "";
|
|
8576
|
+
}
|
|
8577
|
+
if (!simpleMessageFieldHasTopLevelReturn(value)) {
|
|
8578
|
+
return "";
|
|
8579
|
+
}
|
|
8580
|
+
return simpleMessageFieldStaticText(value);
|
|
8581
|
+
}
|
|
8582
|
+
function simpleMessageFieldHasTopLevelReturn(value) {
|
|
8583
|
+
if (!/\breturn\b/.test(value)) {
|
|
8584
|
+
return false;
|
|
8585
|
+
}
|
|
8586
|
+
const program2 = parseMessageScriptProgram(value);
|
|
8587
|
+
return Boolean(program2) && collectMessageReturnArguments(program2).length > 0;
|
|
8588
|
+
}
|
|
8589
|
+
var FLOW_TEMPLATE_GENERIC_TITLE_FRAGMENTS = [
|
|
8590
|
+
"\u65B0\u7684\u6D41\u7A0B\u6D88\u606F",
|
|
8591
|
+
"\u65B0\u6D41\u7A0B\u6D88\u606F",
|
|
8592
|
+
"\u65B0\u7684\u6D88\u606F",
|
|
8593
|
+
"\u65B0\u6D88\u606F",
|
|
8594
|
+
"\u60A8\u6709\u65B0\u6D88\u606F",
|
|
8595
|
+
"\u60A8\u6709\u4E00\u6761\u65B0\u6D88\u606F",
|
|
8596
|
+
"\u60A8\u6709\u4E00\u6761",
|
|
8597
|
+
"\u5F85\u529E\u63D0\u9192",
|
|
8598
|
+
"\u5F85\u529E\u901A\u77E5",
|
|
8599
|
+
"\u4EFB\u52A1\u63D0\u9192",
|
|
8600
|
+
"\u6D41\u7A0B\u901A\u77E5",
|
|
8601
|
+
"\u6D88\u606F\u901A\u77E5",
|
|
8602
|
+
"\u7CFB\u7EDF\u901A\u77E5",
|
|
8603
|
+
"\u5BA1\u6279\u901A\u77E5",
|
|
8604
|
+
"\u5F85\u5904\u7406",
|
|
8605
|
+
"\u5F85\u529E",
|
|
8606
|
+
"\u63D0\u9192",
|
|
8607
|
+
"\u901A\u77E5",
|
|
8608
|
+
"\u6D88\u606F"
|
|
8609
|
+
];
|
|
8610
|
+
function isGenericMessageTitle(text5) {
|
|
8611
|
+
let rest = text5.replace(/\s+/g, "");
|
|
8612
|
+
if (!rest) {
|
|
8613
|
+
return false;
|
|
8614
|
+
}
|
|
8615
|
+
if (/[A-Za-z]{1,5}\d{2,}/.test(rest)) {
|
|
8616
|
+
return false;
|
|
8617
|
+
}
|
|
8618
|
+
for (const fragment of [...FLOW_TEMPLATE_GENERIC_TITLE_FRAGMENTS].sort((a, b) => b.length - a.length)) {
|
|
8619
|
+
rest = rest.split(fragment).join("");
|
|
8620
|
+
}
|
|
8621
|
+
rest = rest.replace(/[::,,。.、/\\|·\-—_()()[\]【】"'“”]/g, "").replace(/\d+/g, "");
|
|
8622
|
+
return !rest;
|
|
8623
|
+
}
|
|
8624
|
+
function pushUniqueMessageFinding(target, message) {
|
|
8625
|
+
if (!target.includes(message)) {
|
|
8626
|
+
target.push(message);
|
|
8627
|
+
}
|
|
8628
|
+
}
|
|
8629
|
+
function analyzeCodeMessageCard(errors, warnings, pathName, script, wouldReachRecipient = true) {
|
|
8630
|
+
const program2 = parseMessageScriptProgram(script);
|
|
8631
|
+
if (!program2) {
|
|
8632
|
+
return;
|
|
8633
|
+
}
|
|
8634
|
+
const bindings = collectMessageBindings(program2);
|
|
8635
|
+
const returnArguments = collectMessageReturnArguments(program2);
|
|
8636
|
+
const objects = [];
|
|
8637
|
+
for (const argument of returnArguments) {
|
|
8638
|
+
resolveMessageReturnObjects(argument, bindings, objects);
|
|
8639
|
+
if (objects.length >= 5) {
|
|
8640
|
+
break;
|
|
8641
|
+
}
|
|
8642
|
+
}
|
|
8643
|
+
const conditionalBranch = returnArguments.length > 1 || objects.length > 1;
|
|
8644
|
+
objects.slice(0, 5).forEach((object, objectIndex) => {
|
|
8645
|
+
const objectPath = objects.length > 1 ? `${pathName} (return branch ${objectIndex + 1})` : pathName;
|
|
8646
|
+
analyzeCodeMessageCardObject(
|
|
8647
|
+
errors,
|
|
8648
|
+
warnings,
|
|
8649
|
+
objectPath,
|
|
8650
|
+
object,
|
|
8651
|
+
bindings,
|
|
8652
|
+
wouldReachRecipient,
|
|
8653
|
+
conditionalBranch
|
|
8654
|
+
);
|
|
8655
|
+
});
|
|
8656
|
+
if (!objects.length) {
|
|
8657
|
+
analyzeJsonParsedCard2Return(errors, pathName, script);
|
|
8658
|
+
}
|
|
8659
|
+
}
|
|
8660
|
+
function analyzeJsonParsedCard2Return(errors, pathName, script) {
|
|
8661
|
+
const parseMatch = script.match(/JSON\.parse\s*\(\s*(['"`])([\s\S]*?)\1\s*\)/);
|
|
8662
|
+
if (!parseMatch) {
|
|
8663
|
+
return;
|
|
8664
|
+
}
|
|
8665
|
+
const literal = parseMatch[2];
|
|
8666
|
+
let payload;
|
|
8667
|
+
try {
|
|
8668
|
+
payload = JSON.parse(literal);
|
|
8669
|
+
} catch {
|
|
8670
|
+
return;
|
|
8671
|
+
}
|
|
8672
|
+
if (!isRecord6(payload)) {
|
|
8673
|
+
return;
|
|
8674
|
+
}
|
|
8675
|
+
if (String(payload.schema ?? "").trim() !== "2.0" && !String(payload.schema ?? "").startsWith("2.")) {
|
|
8676
|
+
return;
|
|
8677
|
+
}
|
|
8678
|
+
if (FLOW_TEMPLATE_MESSAGE_CARD2_BUSINESS_KEYS.some((key) => Object.prototype.hasOwnProperty.call(payload, key))) {
|
|
8679
|
+
return;
|
|
8680
|
+
}
|
|
8681
|
+
pushUniqueMessageFinding(
|
|
8682
|
+
errors,
|
|
8683
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.schemaUnsupported}] ${pathName} returns a Feishu Card 2.0 structure (schema) via JSON.parse. \u540E\u7AEF messageAdaptor \u53EA\u8BA4 title/content/elements/actions/color\uFF1B\u56DB\u4E2A\u4E1A\u52A1\u952E\u5168\u7F3A\uFF0C\u5224\u7A7A\u5931\u8D25\u540E\u6D88\u606F\u4E0D\u4F1A\u53D1\u51FA\u3002\u8BF7\u6539\u56DE title/content/actions/color \u7684 BPMAX \u6D88\u606F\u5BF9\u8C61\u3002`
|
|
8684
|
+
);
|
|
8685
|
+
}
|
|
8686
|
+
function analyzeCodeMessageCardObject(errors, warnings, pathName, object, bindings, wouldReachRecipient = true, conditionalBranch = false) {
|
|
8687
|
+
const props = object.properties;
|
|
8688
|
+
const propertyNames = props.filter((property) => property.type === "Property" && !property.computed).map((property) => {
|
|
8689
|
+
const key = property.key;
|
|
8690
|
+
return key.type === "Identifier" ? String(key.name) : String(key.value ?? "");
|
|
8691
|
+
});
|
|
8692
|
+
const card2Keys = propertyNames.filter((name) => FLOW_TEMPLATE_MESSAGE_CARD2_KEYS.has(name));
|
|
8693
|
+
const presentBusinessKeys = FLOW_TEMPLATE_MESSAGE_CARD2_BUSINESS_KEYS.filter((name) => propertyNames.includes(name));
|
|
8694
|
+
const strongCard2Keys = card2Keys.filter((name) => name === "schema" || name === "body");
|
|
8695
|
+
const canProveAbsence = !astObjectHasSpread(object);
|
|
8696
|
+
const unresolvedAssignArgument = object.properties.some(
|
|
8697
|
+
(property) => property.type === "SpreadElement" && property.argument?.type === "Identifier" && String(property.argument.name) === "__unresolved_argument__"
|
|
8698
|
+
);
|
|
8699
|
+
if (strongCard2Keys.length && canProveAbsence && !presentBusinessKeys.length) {
|
|
8700
|
+
pushUniqueMessageFinding(
|
|
8701
|
+
errors,
|
|
8702
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.schemaUnsupported}] ${pathName} returns a Feishu Card 2.0 structure (${card2Keys.join(", ")}). \u540E\u7AEF messageAdaptor \u53EA\u8BA4 title/content/elements/actions/color\uFF0C\u4F1A\u628A schema/body/header/config \u5168\u90E8\u4E22\u5F03\uFF1B\u56DB\u4E2A\u4E1A\u52A1\u952E\uFF08title/content/elements/actions\uFF09\u5168\u7F3A\uFF0C\u5224\u7A7A\u5931\u8D25\u540E\u6D88\u606F\u4E0D\u4F1A\u53D1\u51FA\uFF08\u540E\u7AEF\u53EA\u6253\u4E00\u6761 warn \u65E5\u5FD7\uFF09\u3002\u8BF7\u6539\u56DE title/content/actions/color \u7684 BPMAX \u6D88\u606F\u5BF9\u8C61\u3002`
|
|
8703
|
+
);
|
|
8704
|
+
return;
|
|
8705
|
+
}
|
|
8706
|
+
if (strongCard2Keys.length && unresolvedAssignArgument && !presentBusinessKeys.length) {
|
|
8707
|
+
pushUniqueMessageFinding(
|
|
8708
|
+
warnings,
|
|
8709
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.schemaUnsupported}] ${pathName} \u51FA\u73B0 Card 2.0 \u9876\u5C42\u952E\uFF08${card2Keys.join(", ")}\uFF09\uFF0C\u4F46 Object.assign \u91CC\u6709\u65E0\u6CD5\u9759\u6001\u89E3\u6790\u7684\u5B9E\u53C2\uFF0C\u65E0\u6CD5\u786E\u8BA4\u8FD0\u884C\u65F6\u4F1A\u5408\u5E76\u51FA\u54EA\u4E2A title/content/actions\uFF1B\u82E5\u6700\u7EC8\u4ECD\u65E0\u56DB\u4E2A\u4E1A\u52A1\u952E\uFF08title/content/elements/actions\uFF09\uFF0C\u540E\u7AEF messageAdaptor \u4F1A\u5224\u7A7A\u5E76\u9759\u9ED8\u4E0D\u53D1\u9001\u3002\u8BF7\u4EBA\u5DE5\u786E\u8BA4\u8BE5\u8FD4\u56DE\u503C\u540C\u65F6\u5E26 title/content/actions\uFF0C\u4E14\u4E0D\u662F\u98DE\u4E66\u539F\u751F Card 2.0 \u7ED3\u6784\u3002`
|
|
8710
|
+
);
|
|
8711
|
+
}
|
|
8712
|
+
if (!presentBusinessKeys.length && canProveAbsence) {
|
|
8713
|
+
pushUniqueMessageFinding(
|
|
8714
|
+
wouldReachRecipient && !conditionalBranch ? errors : warnings,
|
|
8715
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.noBusinessKeys}] ${pathName} \u8FD4\u56DE\u7684\u5BF9\u8C61\u6CA1\u6709 title/content/elements/actions \u4E2D\u4EFB\u4F55\u4E00\u4E2A\u4E1A\u52A1\u952E\uFF08\u73B0\u6709\u952E\uFF1A${propertyNames.length ? propertyNames.join(", ") : "\u7A7A\u5BF9\u8C61"}\uFF09\u3002\u540E\u7AEF messageAdaptor \u7684\u5224\u7A7A\u6761\u4EF6\u662F content || title || elements?.length || actions?.length\uFF0C\u5168\u90E8\u4E3A\u7A7A\u65F6\u53EA\u6253\u4E00\u6761 warn \u65E5\u5FD7\u5E76 return []\uFF0C\u8FD9\u6761\u8FD4\u56DE\u8DEF\u5F84\u4E0A\u7684\u6D88\u606F\u4F1A\u9759\u9ED8\u4E0D\u53D1\u9001\uFF0C\u4E5F\u4E0D\u4F1A\u8865\u9ED8\u8BA4\u6587\u6848\uFF1B\u7AD9\u5185\u5374\u5DF2\u5199\u5165\u5E73\u53F0\u5F85\u529E\u8BB0\u5F55\uFF0C\u5F62\u6210\u300C\u6709\u5F85\u529E\u3001\u6CA1\u6D88\u606F\u300D\u7684\u4E0D\u4E00\u81F4\u3002\u8BF7\u8FD4\u56DE\u5B8C\u6574\u7684 { title, content, actions } \u6D88\u606F\u5BF9\u8C61\u3002`
|
|
8716
|
+
);
|
|
8717
|
+
return;
|
|
8718
|
+
}
|
|
8719
|
+
if (card2Keys.length) {
|
|
8720
|
+
const ignoredKeys = card2Keys.join(", ");
|
|
8721
|
+
pushUniqueMessageFinding(
|
|
8722
|
+
warnings,
|
|
8723
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.card2Ignored}] ${pathName} \u51FA\u73B0 Card 2.0 \u9876\u5C42\u952E\uFF08${ignoredKeys}\uFF09` + (presentBusinessKeys.length ? `\u548C\u4E1A\u52A1\u952E\uFF08${presentBusinessKeys.join(", ")}\uFF09` : "\uFF0C\u4F46\u6CA1\u6709\u4E1A\u52A1\u952E") + "\uFF1B" + (strongCard2Keys.length ? "schema/body \u8BF4\u660E\u4F5C\u8005\u539F\u672C\u9884\u671F\u5199 Card 2.0\uFF0C\u4F46\u540E\u7AEF\u53EA\u6D88\u8D39 title/content/elements/actions/color\uFF0C\u5B9E\u9645\u4F1A\u6309 BPMAX \u6D88\u606F\u5BF9\u8C61\u53D1\u9001\uFF08\u6216\u6309\u5224\u7A7A\u89C4\u5219\u4E22\u5F03\uFF09\u5E76\u5FFD\u7565\u8FD9\u4E9B\u952E\u3002\u8BF7\u5220\u9664\u65E0\u7528\u5B57\u6BB5\uFF0C\u907F\u514D\u8BEF\u4EE5\u4E3A\u8D70\u7684\u662F\u98DE\u4E66\u539F\u751F\u5361\u7247\u3002" : "\u540E\u7AEF\u4F1A\u5FFD\u7565\u8FD9\u4E9B\u952E\uFF0C\u5176\u4F59\u5B57\u6BB5\u4ECD\u6309 BPMAX \u6D88\u606F\u5BF9\u8C61\u53D1\u9001\uFF1B\u5EFA\u8BAE\u5220\u9664\u65E0\u7528\u5B57\u6BB5\u3002")
|
|
8724
|
+
);
|
|
8725
|
+
}
|
|
8726
|
+
const titleNode = astObjectPropertyValue(object, "title");
|
|
8727
|
+
const contentNode = astObjectPropertyValue(object, "content");
|
|
8728
|
+
const actionsNode = astObjectPropertyValue(object, "actions");
|
|
8729
|
+
const colorNode = astObjectPropertyValue(object, "color");
|
|
8730
|
+
if (titleNode) {
|
|
8731
|
+
const titleText = astStaticMessageText(titleNode, bindings);
|
|
8732
|
+
if (titleText !== null && !titleText.trim()) {
|
|
8733
|
+
pushUniqueMessageFinding(
|
|
8734
|
+
warnings,
|
|
8735
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.titleEmpty}] ${pathName} \u7684 title \u89E3\u6790\u4E3A\u7A7A\u6587\u6848\uFF1B\u5361\u7247\u6807\u9898\u4F1A\u662F\u7A7A\u4E32\u6216\u540E\u7AEF\u9ED8\u8BA4\u300C\u65B0\u7684\u6D41\u7A0B\u6D88\u606F\u300D\uFF0C\u6536\u4EF6\u4EBA\u770B\u4E0D\u51FA\u662F\u54EA\u6761\u4E1A\u52A1\u3002\u8BF7\u5199\u5165\u6D41\u7A0B\u540D/\u7F16\u53F7 + \u73AF\u8282\u540D\u3002`
|
|
8736
|
+
);
|
|
8737
|
+
} else if (titleText !== null && titleText.trim() && isGenericMessageTitle(titleText)) {
|
|
8738
|
+
pushUniqueMessageFinding(
|
|
8739
|
+
warnings,
|
|
8740
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.titleStatic}] ${pathName} \u7684 title \u662F\u56FA\u5B9A\u6587\u6848\u201C${titleText.trim().slice(0, 40)}\u201D\uFF0C\u4E14\u53EA\u662F\u6CDB\u5316\u8BCD\uFF0C\u4E0D\u542B\u6D41\u7A0B/\u5355\u636E\u7C7B\u578B\u6216\u4E1A\u52A1\u5BF9\u8C61\uFF1B\u6536\u4EF6\u4EBA\u65E0\u6CD5\u4ECE\u6807\u9898\u5224\u65AD\u662F\u54EA\u6761\u4E1A\u52A1\u3002\u5EFA\u8BAE\u5199\u6210\u300C\u6D41\u7A0B\u7F16\u53F7/\u540D\u79F0 + \u73AF\u8282\u540D\u300D\u6216\u62FC\u63A5\u9879\u76EE\u53D8\u91CF\u3002`
|
|
8741
|
+
);
|
|
8742
|
+
}
|
|
8743
|
+
}
|
|
8744
|
+
if (!contentNode) {
|
|
8745
|
+
if (canProveAbsence) {
|
|
8746
|
+
pushUniqueMessageFinding(
|
|
8747
|
+
warnings,
|
|
8748
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.contentMissing}] ${pathName} \u7F3A\u5C11 content\uFF1B\u6D88\u606F\u5361\u7247\u6CA1\u6709\u6B63\u6587\uFF0C\u6536\u4EF6\u4EBA\u4E0D\u77E5\u9053\u8981\u5904\u7406\u4EC0\u4E48\u3002`
|
|
8749
|
+
);
|
|
8750
|
+
}
|
|
8751
|
+
} else if (contentNode.type === "ArrayExpression" && contentNode.elements.length === 0) {
|
|
8752
|
+
pushUniqueMessageFinding(
|
|
8753
|
+
warnings,
|
|
8754
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.contentMissing}] ${pathName} \u7684 content \u662F\u7A7A\u6570\u7EC4\uFF1B\u6D88\u606F\u5361\u7247\u6CA1\u6709\u6B63\u6587\uFF0C\u6536\u4EF6\u4EBA\u4E0D\u77E5\u9053\u8981\u5904\u7406\u4EC0\u4E48\u3002`
|
|
8755
|
+
);
|
|
8756
|
+
} else if (contentNode.type === "ArrayExpression") {
|
|
8757
|
+
pushUniqueMessageFinding(
|
|
8758
|
+
warnings,
|
|
8759
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.contentNotString}] ${pathName} \u7684 content \u662F\u6570\u7EC4\uFF1Bcode \u6A21\u5F0F\u540E\u7AEF\u628A data.content \u76F4\u63A5\u653E\u8FDB lark_md \u7684 text.content\uFF0C\u6570\u7EC4\u4F1A\u88AB\u6E32\u67D3\u6210 [object Object] \u6216\u6E32\u67D3\u5931\u8D25\u3002\u8BF7\u6539\u6210\u5B57\u7B26\u4E32\uFF08\u591A\u884C\u7528 \\n \u62FC\u63A5\uFF0C\u6216\u7528 elements \u8FFD\u52A0\u6B63\u6587\u5757\uFF09\u3002`
|
|
8760
|
+
);
|
|
8761
|
+
} else {
|
|
8762
|
+
const contentText = astMessageContentStaticText(contentNode, bindings);
|
|
8763
|
+
if (contentText !== null && !contentText.trim()) {
|
|
8764
|
+
pushUniqueMessageFinding(
|
|
8765
|
+
warnings,
|
|
8766
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.contentEmpty}] ${pathName} \u7684 content \u89E3\u6790\u4E3A\u7A7A\u6587\u6848\uFF1B\u5361\u7247\u53EA\u4F1A\u6709\u6807\u9898\u6CA1\u6709\u6B63\u6587\uFF0C\u6536\u4EF6\u4EBA\u770B\u4E0D\u51FA\u8981\u505A\u4EC0\u4E48\u3002`
|
|
8767
|
+
);
|
|
8768
|
+
} else if (contentText !== null && contentText.trim().length < 10) {
|
|
8769
|
+
pushUniqueMessageFinding(
|
|
8770
|
+
warnings,
|
|
8771
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.contentMissing}] ${pathName} \u7684 content \u8FC7\u77ED\uFF08\u53BB\u6389\u7A7A\u767D\u540E\u4E0D\u8DB3 10 \u4E2A\u5B57\u7B26\uFF09\uFF1B\u6D88\u606F\u5361\u7247\u6B63\u6587\u4E0D\u8DB3\u4EE5\u8BF4\u660E\u4E1A\u52A1\u80CC\u666F\u3002`
|
|
8772
|
+
);
|
|
8773
|
+
}
|
|
8774
|
+
}
|
|
8775
|
+
if (!actionsNode) {
|
|
8776
|
+
if (canProveAbsence) {
|
|
8777
|
+
pushUniqueMessageFinding(
|
|
8778
|
+
warnings,
|
|
8779
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionsMissing}] ${pathName} \u6CA1\u6709 actions\uFF1B\u6536\u4EF6\u4EBA\u65E0\u6CD5\u4ECE\u6D88\u606F\u5361\u7247\u4E00\u952E\u8DF3\u8F6C\u5230\u5F85\u529E\u3002`
|
|
8780
|
+
);
|
|
8781
|
+
}
|
|
8782
|
+
} else if (actionsNode.type === "ArrayExpression" && actionsNode.elements.length === 0) {
|
|
8783
|
+
pushUniqueMessageFinding(
|
|
8784
|
+
warnings,
|
|
8785
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionsMissing}] ${pathName} \u7684 actions \u662F\u7A7A\u6570\u7EC4\uFF1B\u6536\u4EF6\u4EBA\u65E0\u6CD5\u4ECE\u6D88\u606F\u5361\u7247\u4E00\u952E\u8DF3\u8F6C\u5230\u5F85\u529E\u3002`
|
|
8786
|
+
);
|
|
8787
|
+
}
|
|
8788
|
+
if (colorNode) {
|
|
8789
|
+
const colorText = astStaticMessageText(colorNode, bindings);
|
|
8790
|
+
if (colorText !== null && !FLOW_TEMPLATE_MESSAGE_CARD_COLORS.has(colorText.trim())) {
|
|
8791
|
+
pushUniqueMessageFinding(
|
|
8792
|
+
errors,
|
|
8793
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.colorInvalid}] ${pathName}.color \u7684\u503C\u201C${colorText.trim()}\u201D\u4E0D\u662F\u540E\u7AEF\u5361\u7247\u652F\u6301\u7684\u6807\u9898\u989C\u8272\uFF1B\u5141\u8BB8\u503C\uFF1A${[...FLOW_TEMPLATE_MESSAGE_CARD_COLORS].join(", ")}\u3002`
|
|
8794
|
+
);
|
|
8795
|
+
}
|
|
8796
|
+
}
|
|
8797
|
+
if (actionsNode?.type === "ArrayExpression") {
|
|
8798
|
+
actionsNode.elements.forEach((element, index) => {
|
|
8799
|
+
if (!element || element.type !== "ObjectExpression") {
|
|
8800
|
+
return;
|
|
8801
|
+
}
|
|
8802
|
+
const actionPath = `${pathName}.actions[${index}]`;
|
|
8803
|
+
const typeNode = astObjectPropertyValue(element, "type");
|
|
8804
|
+
if (typeNode) {
|
|
8805
|
+
const typeText = astStaticMessageText(typeNode, bindings);
|
|
8806
|
+
if (typeText !== null && typeText.trim() && typeText.trim() !== "link") {
|
|
8807
|
+
pushUniqueMessageFinding(
|
|
8808
|
+
warnings,
|
|
8809
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionTypeUnsupported}] ${actionPath}.type \u662F\u201C${typeText.trim()}\u201D\uFF0C\u4E0D\u662F link\u3002\u540E\u7AEF feishu.js \u7EC4\u88C5\u6309\u94AE\u65F6\u4E0D\u8BFB b.type\uFF0C\u6309\u94AE\u4ECD\u4F1A\u53D1\u9001\u5E76\u8DF3\u8F6C\uFF1B\u4F46\u90E8\u5206\u8DF3\u8F6C\u8BED\u4E49\uFF08\u7AD9\u5185\u6D88\u606F\u5361\u7684\u6309\u94AE\u6837\u5F0F/\u70B9\u51FB\u884C\u4E3A\uFF09\u6309 type \u89E3\u91CA\uFF0C\u975E link \u65F6\u70B9\u51FB\u53EF\u80FD\u65E0\u54CD\u5E94\u3002\u5EFA\u8BAE\u786E\u8BA4\u5B9E\u6D4B\u53EF\u70B9\uFF0C\u6216\u6539\u4E3A type: "link"\u3002`
|
|
8810
|
+
);
|
|
8811
|
+
}
|
|
8812
|
+
}
|
|
8813
|
+
const btnTypeNode = astObjectPropertyValue(element, "btnType");
|
|
8814
|
+
if (btnTypeNode) {
|
|
8815
|
+
const btnTypeText = astStaticMessageText(btnTypeNode, bindings);
|
|
8816
|
+
if (btnTypeText !== null && btnTypeText.trim() && !FLOW_TEMPLATE_MESSAGE_BUTTON_TYPES.has(btnTypeText.trim())) {
|
|
8817
|
+
pushUniqueMessageFinding(
|
|
8818
|
+
warnings,
|
|
8819
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionBtnTypeUnknown}] ${actionPath}.btnType \u7684\u503C\u201C${btnTypeText.trim()}\u201D\u4E0D\u5728\u4EA7\u54C1\u63D0\u4F9B\u7684\u6309\u94AE\u6837\u5F0F\u5185\uFF0C\u540E\u7AEF\u4F1A\u628A\u539F\u503C\u76F4\u63A5\u4EA4\u7ED9\u98DE\u4E66\u5361\u7247\uFF0C\u53EF\u80FD\u9000\u5316\u4E3A\u9ED8\u8BA4\u6309\u94AE\u3002`
|
|
8820
|
+
);
|
|
8821
|
+
}
|
|
8822
|
+
}
|
|
8823
|
+
if (astObjectHasSpread(element)) {
|
|
8824
|
+
return;
|
|
8825
|
+
}
|
|
8826
|
+
const urlNode = astObjectPropertyValue(element, "url");
|
|
8827
|
+
const mUrlNode = astObjectPropertyValue(element, "m_url");
|
|
8828
|
+
const inAppLinkNode = astObjectPropertyValue(element, "inAppLink");
|
|
8829
|
+
const hasUsableLink = (node) => {
|
|
8830
|
+
if (!node) {
|
|
8831
|
+
return false;
|
|
8832
|
+
}
|
|
8833
|
+
const text5 = astStaticMessageText(node, bindings);
|
|
8834
|
+
return text5 === null || Boolean(text5.trim());
|
|
8835
|
+
};
|
|
8836
|
+
if (!hasUsableLink(urlNode) && !hasUsableLink(mUrlNode) && !hasUsableLink(inAppLinkNode)) {
|
|
8837
|
+
pushUniqueMessageFinding(
|
|
8838
|
+
errors,
|
|
8839
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionInvalid}] ${actionPath} \u6CA1\u6709\u53EF\u70B9\u51FB\u76EE\u6807\uFF08url \u4E0E m_url \u90FD\u4E3A\u7A7A\uFF09\uFF1B\u6D88\u606F\u5361\u7247\u4F1A\u6E32\u67D3\u6210\u4E00\u4E2A\u70B9\u4E0D\u52A8\u7684\u6309\u94AE\u3002`
|
|
8840
|
+
);
|
|
8841
|
+
}
|
|
8842
|
+
});
|
|
8843
|
+
}
|
|
8844
|
+
}
|
|
8845
|
+
function reportUnsupportedSimpleModeConfig(errors, modePath, templatePath, codeTemplatePresent = false) {
|
|
8846
|
+
pushUniqueMessageFinding(
|
|
8847
|
+
errors,
|
|
8848
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.modeSimpleUnsupported}] ${modePath} \u662F "simple"\uFF0C\u4F46\u540E\u7AEF\u53EA\u8BC6\u522B "standard"\uFF08message.js \u53EA\u5224\u65AD === 'standard'\uFF09\uFF1B${templatePath} \u91CC\u914D\u7F6E\u7684\u5361\u7247\u4E0D\u4F1A\u751F\u6548\uFF0C` + (codeTemplatePresent ? '\u540E\u7AEF\u4F1A\u8F6C\u800C\u6267\u884C code \u6A21\u677F\u3002\u8BF7\u628A\u8BE5\u6A21\u5F0F\u6539\u4E3A "standard"\uFF08\u6216\u663E\u5F0F\u6539\u6210 "code" \u5E76\u5220\u6389 simple \u6A21\u677F\uFF09\u3002' : '\u6536\u4EF6\u4EBA\u53EA\u4F1A\u6536\u5230\u540E\u7AEF\u9ED8\u8BA4\u6D88\u606F\u3002\u8BF7\u628A\u8BE5\u6A21\u5F0F\u6539\u4E3A "standard"\u3002')
|
|
8849
|
+
);
|
|
8850
|
+
}
|
|
8851
|
+
function analyzeSimpleMessageCard(errors, warnings, pathName, template) {
|
|
8852
|
+
const hasBusinessKey = FLOW_TEMPLATE_MESSAGE_CARD2_BUSINESS_KEYS.some(
|
|
8853
|
+
(key) => Object.prototype.hasOwnProperty.call(template, key)
|
|
8854
|
+
);
|
|
8855
|
+
const card2Keys = [...FLOW_TEMPLATE_MESSAGE_CARD2_KEYS].filter((key) => Object.prototype.hasOwnProperty.call(template, key));
|
|
8856
|
+
const strongCard2Keys = card2Keys.filter((key) => key === "schema" || key === "body");
|
|
8857
|
+
if (strongCard2Keys.length && !hasBusinessKey) {
|
|
8858
|
+
pushUniqueMessageFinding(
|
|
8859
|
+
errors,
|
|
8860
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.schemaUnsupported}] ${pathName} \u51FA\u73B0 Card 2.0 \u9876\u5C42\u952E\uFF08${card2Keys.join(", ")}\uFF09\uFF0C\u4E14\u6CA1\u6709 title/content/actions\uFF1B\u540E\u7AEF messageAdaptor \u4F1A\u56E0\u4E3A\u56DB\u4E2A\u4E1A\u52A1\u952E\u5168\u7A7A\u800C\u4E22\u5F03\u8BE5\u7ED3\u6784\uFF0C\u6D88\u606F\u4E0D\u4F1A\u53D1\u51FA\u3002\u6807\u51C6\u6A21\u677F\u53EA\u652F\u6301 title/title_color/content/actions\u3002`
|
|
8861
|
+
);
|
|
8862
|
+
return;
|
|
8863
|
+
}
|
|
8864
|
+
if (card2Keys.length) {
|
|
8865
|
+
pushUniqueMessageFinding(
|
|
8866
|
+
warnings,
|
|
8867
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.card2Ignored}] ${pathName} \u540C\u65F6\u51FA\u73B0 Card 2.0 \u9876\u5C42\u952E\uFF08${card2Keys.join(", ")}\uFF09\u548C\u4E1A\u52A1\u952E\uFF1B\u540E\u7AEF messageAdaptor \u4F1A\u5FFD\u7565\u8FD9\u4E9B\u591A\u4F59\u952E\uFF0C\u5176\u4F59 title/title_color/content/actions \u4ECD\u4F1A\u6B63\u5E38\u53D1\u9001\uFF1B\u5EFA\u8BAE\u5220\u9664\u65E0\u7528\u5B57\u6BB5\u3002`
|
|
8868
|
+
);
|
|
8869
|
+
}
|
|
8870
|
+
const title = template.title;
|
|
8871
|
+
const titleText = simpleMessageFieldRuntimeText(title);
|
|
8872
|
+
const hasTitleField = Object.prototype.hasOwnProperty.call(template, "title");
|
|
8873
|
+
if (typeof title === "string" && title.trim() && !simpleMessageFieldHasTopLevelReturn(title)) {
|
|
8874
|
+
pushUniqueMessageFinding(
|
|
8875
|
+
warnings,
|
|
8876
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.simpleFieldMissingReturn}] ${pathName}.title \u4E0D\u662F return \u8BED\u53E5\uFF08\u5F53\u524D\u5199\u6CD5\u201C${title.trim().slice(0, 40)}\u201D\uFF09\uFF0C\u540E\u7AEF parseTemplateString \u628A\u5B83\u5F53\u51FD\u6570\u4F53\u6267\u884C\uFF0C\u6CA1\u6709 return \u65F6\u5F97\u5230 undefined\uFF0C\u8FD0\u884C\u65F6\u6807\u9898\u5B9E\u9645\u4E3A\u7A7A\u4E32\uFF0C\u4F1A\u843D\u5230\u9ED8\u8BA4\u6807\u9898\u300C\u65B0\u7684\u6D41\u7A0B\u6D88\u606F\u300D\uFF0C\u6536\u4EF6\u4EBA\u770B\u4E0D\u51FA\u662F\u54EA\u6761\u4E1A\u52A1\u3002\u8BF7\u6539\u6210 return "..." \u6216 return \u6A21\u677F\u5B57\u7B26\u4E32\u3002`
|
|
8877
|
+
);
|
|
8878
|
+
}
|
|
8879
|
+
if (hasTitleField && titleText !== null && !titleText.trim()) {
|
|
8880
|
+
pushUniqueMessageFinding(
|
|
8881
|
+
warnings,
|
|
8882
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.titleEmpty}] ${pathName}.title \u4E3A\u7A7A\uFF1B\u540E\u7AEF\u4F1A\u7528\u9ED8\u8BA4\u6807\u9898\u300C\u65B0\u7684\u6D41\u7A0B\u6D88\u606F\u300D\u515C\u5E95\uFF0C\u6536\u4EF6\u4EBA\u770B\u4E0D\u51FA\u662F\u54EA\u6761\u4E1A\u52A1\u3002`
|
|
8883
|
+
);
|
|
8884
|
+
} else if (titleText !== null && titleText.trim() && isGenericMessageTitle(titleText)) {
|
|
8885
|
+
pushUniqueMessageFinding(
|
|
8886
|
+
warnings,
|
|
8887
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.titleStatic}] ${pathName}.title \u662F\u56FA\u5B9A\u6587\u6848\u201C${titleText.trim().slice(0, 40)}\u201D\uFF0C\u4E14\u53EA\u662F\u6CDB\u5316\u8BCD\uFF0C\u4E0D\u542B\u6D41\u7A0B/\u5355\u636E\u7C7B\u578B\u6216\u4E1A\u52A1\u5BF9\u8C61\uFF1B\u6536\u4EF6\u4EBA\u65E0\u6CD5\u4ECE\u6807\u9898\u5224\u65AD\u662F\u54EA\u6761\u4E1A\u52A1\u3002\u5EFA\u8BAE\u5199\u6210\u300C\u6D41\u7A0B\u7F16\u53F7/\u540D\u79F0 + \u73AF\u8282\u540D\u300D\u6216\u63D2\u5165\u9879\u76EE\u53D8\u91CF\u3002`
|
|
8888
|
+
);
|
|
8889
|
+
}
|
|
8890
|
+
const contentItems = Array.isArray(template.content) ? template.content : [];
|
|
8891
|
+
const firstContent = contentItems.length && isRecord6(contentItems[0]) ? contentItems[0] : null;
|
|
8892
|
+
const body = firstContent?.body;
|
|
8893
|
+
if (typeof body === "string" && body.trim() && !simpleMessageFieldHasTopLevelReturn(body)) {
|
|
8894
|
+
pushUniqueMessageFinding(
|
|
8895
|
+
warnings,
|
|
8896
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.simpleFieldMissingReturn}] ${pathName}.content[0].body \u4E0D\u662F return \u8BED\u53E5\uFF08\u5F53\u524D\u5199\u6CD5\u201C${body.trim().slice(0, 40)}\u201D\uFF09\uFF0C\u540E\u7AEF\u628A\u5B83\u5F53\u51FD\u6570\u4F53\u6267\u884C\uFF0C\u8FD0\u884C\u65F6\u6B63\u6587\u5B9E\u9645\u4E3A\u7A7A\u4E32\uFF0C\u4F1A\u843D\u5230\u9ED8\u8BA4\u6B63\u6587\uFF1B\u7F16\u8F91\u5668\u91CC\u770B\u5230\u7684\u6587\u5B57\u4E0D\u4F1A\u53D1\u7ED9\u6536\u4EF6\u4EBA\u3002\u8BF7\u6539\u6210 return "..." \u6216 return \u6A21\u677F\u5B57\u7B26\u4E32\u3002`
|
|
8897
|
+
);
|
|
8898
|
+
}
|
|
8899
|
+
const bodyText = typeof body === "string" ? simpleMessageFieldRuntimeText(body) : null;
|
|
8900
|
+
if (!firstContent || typeof body !== "string" || bodyText === "") {
|
|
8901
|
+
pushUniqueMessageFinding(
|
|
8902
|
+
warnings,
|
|
8903
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.contentEmpty}] ${pathName}.content[0].body \u4E3A\u7A7A\uFF1B\u540E\u7AEF\u4F1A\u7528\u9ED8\u8BA4\u6B63\u6587\u300C"\u9879\u76EE\u540D"\u9879\u76EE"\u73AF\u8282\u540D"\u73AF\u8282\u9700\u8981\u4F60\u5904\u7406\u300D\u515C\u5E95\uFF0C\u6536\u4EF6\u4EBA\u770B\u4E0D\u51FA\u5177\u4F53\u4E1A\u52A1\u3002`
|
|
8904
|
+
);
|
|
8905
|
+
} else if (bodyText !== null && bodyText.trim().length < 10) {
|
|
8906
|
+
pushUniqueMessageFinding(
|
|
8907
|
+
warnings,
|
|
8908
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.contentMissing}] ${pathName}.content[0].body \u8FC7\u77ED\uFF08\u53BB\u6389\u7A7A\u767D\u540E\u4E0D\u8DB3 10 \u4E2A\u5B57\u7B26\uFF09\uFF1B\u6D88\u606F\u5361\u7247\u6B63\u6587\u4E0D\u8DB3\u4EE5\u8BF4\u660E\u4E1A\u52A1\u80CC\u666F\u3002`
|
|
8909
|
+
);
|
|
8910
|
+
}
|
|
8911
|
+
const actions = Array.isArray(template.actions) ? template.actions : [];
|
|
8912
|
+
if (!actions.length) {
|
|
8913
|
+
pushUniqueMessageFinding(
|
|
8914
|
+
warnings,
|
|
8915
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionsMissing}] ${pathName}.actions \u4E3A\u7A7A\uFF1B\u6536\u4EF6\u4EBA\u65E0\u6CD5\u4ECE\u6D88\u606F\u5361\u7247\u4E00\u952E\u8DF3\u8F6C\u5230\u5F85\u529E\u3002`
|
|
8916
|
+
);
|
|
8917
|
+
}
|
|
8918
|
+
const titleColor = template.title_color;
|
|
8919
|
+
if (typeof titleColor === "string" && titleColor.trim() && !FLOW_TEMPLATE_MESSAGE_CARD_COLORS.has(titleColor.trim())) {
|
|
8920
|
+
pushUniqueMessageFinding(
|
|
8921
|
+
errors,
|
|
8922
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.colorInvalid}] ${pathName}.title_color \u7684\u503C\u201C${titleColor.trim()}\u201D\u4E0D\u662F\u540E\u7AEF\u5361\u7247\u652F\u6301\u7684\u6807\u9898\u989C\u8272\uFF1B\u5141\u8BB8\u503C\uFF1A${[...FLOW_TEMPLATE_MESSAGE_CARD_COLORS].join(", ")}\u3002`
|
|
8923
|
+
);
|
|
8924
|
+
}
|
|
8925
|
+
actions.forEach((action, index) => {
|
|
8926
|
+
if (!isRecord6(action)) {
|
|
8927
|
+
return;
|
|
8928
|
+
}
|
|
8929
|
+
const actionPath = `${pathName}.actions[${index}]`;
|
|
8930
|
+
const typeText = typeof action.type === "string" ? action.type.trim() : "";
|
|
8931
|
+
if (typeText && typeText !== "link" && !FLOW_TEMPLATE_SIMPLE_BUTTON_TARGETS.has(typeText)) {
|
|
8932
|
+
pushUniqueMessageFinding(
|
|
8933
|
+
errors,
|
|
8934
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionInvalid}] ${actionPath}.type \u662F\u201C${typeText}\u201D\uFF0C\u6807\u51C6\u6A21\u677F\u6309\u94AE\u7C7B\u578B\u53EA\u80FD\u662F ${[...FLOW_TEMPLATE_SIMPLE_BUTTON_TARGETS].join("/")}/link\u3002`
|
|
8935
|
+
);
|
|
8936
|
+
}
|
|
8937
|
+
if (typeof action.style === "string" && action.style.trim() && !FLOW_TEMPLATE_MESSAGE_BUTTON_TYPES.has(action.style.trim())) {
|
|
8938
|
+
pushUniqueMessageFinding(
|
|
8939
|
+
warnings,
|
|
8940
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionBtnTypeUnknown}] ${actionPath}.style \u7684\u503C\u201C${action.style.trim()}\u201D\u4E0D\u5728\u4EA7\u54C1\u63D0\u4F9B\u7684\u6309\u94AE\u6837\u5F0F\u5185\uFF0C\u540E\u7AEF\u4F1A\u628A\u539F\u503C\u76F4\u63A5\u4EA4\u7ED9\u98DE\u4E66\u5361\u7247\uFF0C\u53EF\u80FD\u9000\u5316\u4E3A\u9ED8\u8BA4\u6309\u94AE\u3002`
|
|
8941
|
+
);
|
|
8942
|
+
}
|
|
8943
|
+
const needsTarget = typeText === "step" || typeText === "project" || typeText === "custom";
|
|
8944
|
+
const urlText = simpleMessageFieldRuntimeText(action.url);
|
|
8945
|
+
const mUrlText = simpleMessageFieldRuntimeText(action.m_url);
|
|
8946
|
+
const hasUrl = action.url !== void 0 && action.url !== null && (urlText === null || Boolean(urlText.trim()));
|
|
8947
|
+
const hasMUrl = action.m_url !== void 0 && action.m_url !== null && (mUrlText === null || Boolean(mUrlText.trim()));
|
|
8948
|
+
if (needsTarget && !hasUrl && !hasMUrl) {
|
|
8949
|
+
pushUniqueMessageFinding(
|
|
8950
|
+
errors,
|
|
8951
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.actionInvalid}] ${actionPath} \u6CA1\u6709\u53EF\u70B9\u51FB\u76EE\u6807\uFF08url \u4E0E m_url \u90FD\u4E3A\u7A7A\uFF09\uFF1B\u6D88\u606F\u5361\u7247\u4F1A\u6E32\u67D3\u6210\u4E00\u4E2A\u70B9\u4E0D\u52A8\u7684\u6309\u94AE\u3002`
|
|
8952
|
+
);
|
|
8953
|
+
}
|
|
8954
|
+
});
|
|
8955
|
+
}
|
|
8956
|
+
function simpleMessageTemplateHasVisibleContent(template) {
|
|
8957
|
+
const isConfiguredField = (value) => {
|
|
8958
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
8959
|
+
return false;
|
|
8960
|
+
}
|
|
8961
|
+
const staticText = simpleMessageFieldRuntimeText(value);
|
|
8962
|
+
return staticText === null || Boolean(staticText.trim());
|
|
8963
|
+
};
|
|
8964
|
+
if (isConfiguredField(template.title)) {
|
|
8965
|
+
return true;
|
|
8966
|
+
}
|
|
8967
|
+
const contentItems = Array.isArray(template.content) ? template.content : [];
|
|
8968
|
+
return contentItems.some((item) => isRecord6(item) && isConfiguredField(item.body));
|
|
8969
|
+
}
|
|
8970
|
+
function simpleMessageTemplateHasConfiguredContent(template) {
|
|
8971
|
+
const isWritten = (value) => typeof value === "string" && Boolean(value.trim());
|
|
8972
|
+
if (isWritten(template.title)) {
|
|
8973
|
+
return true;
|
|
8974
|
+
}
|
|
8975
|
+
const contentItems = Array.isArray(template.content) ? template.content : [];
|
|
8976
|
+
return contentItems.some((item) => isRecord6(item) && isWritten(item.body));
|
|
8977
|
+
}
|
|
8978
|
+
function flowTemplateNodeMessageConfigured(node) {
|
|
8979
|
+
const code = typeof node.message_template === "string" ? node.message_template.trim() : "";
|
|
8980
|
+
if (code) {
|
|
8981
|
+
return true;
|
|
8982
|
+
}
|
|
8983
|
+
return isRecord6(node.message_template_simple) && simpleMessageTemplateHasVisibleContent(node.message_template_simple);
|
|
8984
|
+
}
|
|
8985
|
+
function flowTemplateNodeCcMessageConfigured(node) {
|
|
8986
|
+
const code = typeof node.cc_message_template === "string" ? node.cc_message_template.trim() : "";
|
|
8987
|
+
if (code) {
|
|
8988
|
+
return true;
|
|
8989
|
+
}
|
|
8990
|
+
return isRecord6(node.step_cc_message_template_simple) && simpleMessageTemplateHasVisibleContent(node.step_cc_message_template_simple);
|
|
8991
|
+
}
|
|
8992
|
+
function flowTemplateNodeCcRecipientsConfigured(node) {
|
|
8993
|
+
const ccType = typeof node.cc_type === "string" ? node.cc_type.trim() : "";
|
|
8994
|
+
if (ccType === "fieldvalue") {
|
|
8995
|
+
return isUsableFlowTemplateScript(node.cc_user_by_script);
|
|
8996
|
+
}
|
|
8997
|
+
if (ccType === "matrix") {
|
|
8998
|
+
const matrix = isRecord6(node.cc_matrix) ? node.cc_matrix : {};
|
|
8999
|
+
return isUsableFlowTemplateScript(matrix.script);
|
|
9000
|
+
}
|
|
9001
|
+
if (ccType === "role") {
|
|
9002
|
+
return Array.isArray(node.cc_user_role) && node.cc_user_role.some(isNonEmptyFlowTemplateIdentifier);
|
|
9003
|
+
}
|
|
9004
|
+
if (ccType === "user") {
|
|
9005
|
+
return Array.isArray(node.cc_user) && node.cc_user.some(isNonEmptyFlowTemplateIdentifier);
|
|
9006
|
+
}
|
|
9007
|
+
return false;
|
|
9008
|
+
}
|
|
9009
|
+
function flowTemplateNodeIsAutomaticWait(node) {
|
|
9010
|
+
const autoTrigger = node.auto_trigger_flows;
|
|
9011
|
+
return isRecord6(autoTrigger) && Array.isArray(autoTrigger.flows) && autoTrigger.flows.length > 0 && autoTrigger.manual_end === false;
|
|
9012
|
+
}
|
|
9013
|
+
function analyzeFlowTemplateMessageCardRules(value) {
|
|
9014
|
+
const errors = [];
|
|
9015
|
+
const warnings = [];
|
|
9016
|
+
const data = isRecord6(value.data) ? value.data : {};
|
|
9017
|
+
const meta = isRecord6(data.meta) ? data.meta : {};
|
|
9018
|
+
const nodes = Array.isArray(data.nodes) ? data.nodes : [];
|
|
9019
|
+
const metaMessage = meta.message_template;
|
|
9020
|
+
if (resolveMessageChannelMode(meta, ["message_config_mode", "message_template_mode"], metaMessage, null) === "code" && typeof metaMessage === "string" && metaMessage.trim() && !isStaticEmptyMessageReturn(metaMessage)) {
|
|
9021
|
+
analyzeCodeMessageCard(errors, warnings, "data.meta.message_template", metaMessage);
|
|
9022
|
+
}
|
|
9023
|
+
const metaCcMessage = meta.cc_message_template;
|
|
9024
|
+
const metaCcReachable = isUsableFlowTemplateScript(meta.cc_user_by_script);
|
|
9025
|
+
if (metaCcReachable && resolveMessageChannelMode(meta, ["cc_message_config_mode", "project_cc_message_config_mode"], metaCcMessage, null) === "code" && typeof metaCcMessage === "string" && metaCcMessage.trim() && !isStaticEmptyMessageReturn(metaCcMessage)) {
|
|
9026
|
+
analyzeCodeMessageCard(errors, warnings, "data.meta.cc_message_template", metaCcMessage);
|
|
9027
|
+
}
|
|
9028
|
+
const metaEndSimple = meta.notify_project_owner_on_end_message_template_simple;
|
|
9029
|
+
const endNotifyEnabled = Boolean(meta.enable_notify_project_owner_on_end);
|
|
9030
|
+
if (endNotifyEnabled && meta.notify_project_owner_on_end_message_config_mode === "standard" && isRecord6(metaEndSimple)) {
|
|
9031
|
+
analyzeSimpleMessageCard(
|
|
9032
|
+
errors,
|
|
9033
|
+
warnings,
|
|
9034
|
+
"data.meta.notify_project_owner_on_end_message_template_simple",
|
|
9035
|
+
metaEndSimple
|
|
9036
|
+
);
|
|
9037
|
+
}
|
|
9038
|
+
const metaCcSimple = meta.project_cc_message_template_simple;
|
|
9039
|
+
if (metaCcReachable && meta.project_cc_message_config_mode === "standard" && isRecord6(metaCcSimple)) {
|
|
9040
|
+
analyzeSimpleMessageCard(errors, warnings, "data.meta.project_cc_message_template_simple", metaCcSimple);
|
|
9041
|
+
}
|
|
9042
|
+
if (metaCcReachable && meta.project_cc_message_config_mode === "simple" && isRecord6(metaCcSimple) && simpleMessageTemplateHasConfiguredContent(metaCcSimple)) {
|
|
9043
|
+
reportUnsupportedSimpleModeConfig(
|
|
9044
|
+
errors,
|
|
9045
|
+
"data.meta.project_cc_message_config_mode",
|
|
9046
|
+
"data.meta.project_cc_message_template_simple",
|
|
9047
|
+
Boolean(String(meta.cc_message_template ?? "").trim())
|
|
9048
|
+
);
|
|
9049
|
+
}
|
|
9050
|
+
if (endNotifyEnabled && meta.notify_project_owner_on_end_message_config_mode === "simple" && isRecord6(metaEndSimple) && simpleMessageTemplateHasConfiguredContent(metaEndSimple)) {
|
|
9051
|
+
reportUnsupportedSimpleModeConfig(
|
|
9052
|
+
errors,
|
|
9053
|
+
"data.meta.notify_project_owner_on_end_message_config_mode",
|
|
9054
|
+
"data.meta.notify_project_owner_on_end_message_template_simple",
|
|
9055
|
+
Boolean(String(meta.notify_project_owner_on_end_message_tempalte ?? "").trim())
|
|
9056
|
+
);
|
|
9057
|
+
}
|
|
9058
|
+
const ackedChannels = collectMessageSuppressionAckKeys(value);
|
|
9059
|
+
nodes.forEach((node, index) => {
|
|
9060
|
+
if (!isRecord6(node)) {
|
|
9061
|
+
return;
|
|
9062
|
+
}
|
|
9063
|
+
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
|
|
9064
|
+
const nodeId = String(node.id ?? "").trim();
|
|
9065
|
+
const hasOwner = flowTemplateNodeHasActualOwner(node);
|
|
9066
|
+
const messageWouldReachRecipient = hasOwner && !flowTemplateNodeIsAutomaticWait(node);
|
|
9067
|
+
const ccWouldReachRecipient = flowTemplateNodeCcRecipientsConfigured(node);
|
|
9068
|
+
const messageSuppressed = Boolean(nodeId) && ackedChannels.has(`${nodeId}\0message`);
|
|
9069
|
+
const ccSuppressed = Boolean(nodeId) && ackedChannels.has(`${nodeId}\0cc`);
|
|
9070
|
+
const messageScript = node.message_template;
|
|
9071
|
+
const messageSimple = node.message_template_simple;
|
|
9072
|
+
if (!messageSuppressed) {
|
|
9073
|
+
const messageMode = resolveMessageChannelMode(
|
|
9074
|
+
node,
|
|
9075
|
+
["message_config_mode", "message_template_mode"],
|
|
9076
|
+
messageScript,
|
|
9077
|
+
messageSimple
|
|
9078
|
+
);
|
|
9079
|
+
if (messageMode === "code" && typeof messageScript === "string" && messageScript.trim() && !isStaticEmptyMessageReturn(messageScript)) {
|
|
9080
|
+
analyzeCodeMessageCard(errors, warnings, `${nodeName}.message_template`, messageScript, messageWouldReachRecipient);
|
|
9081
|
+
} else if (messageMode === "standard" && isRecord6(messageSimple)) {
|
|
9082
|
+
analyzeSimpleMessageCard(errors, warnings, `${nodeName}.message_template_simple`, messageSimple);
|
|
9083
|
+
} else if (messageMode === "simple" && isRecord6(messageSimple) && simpleMessageTemplateHasConfiguredContent(messageSimple)) {
|
|
9084
|
+
reportUnsupportedSimpleModeConfig(
|
|
9085
|
+
errors,
|
|
9086
|
+
`${nodeName}.message_config_mode`,
|
|
9087
|
+
`${nodeName}.message_template_simple`,
|
|
9088
|
+
typeof messageScript === "string" && Boolean(messageScript.trim())
|
|
9089
|
+
);
|
|
9090
|
+
}
|
|
9091
|
+
}
|
|
9092
|
+
const ccScript = node.cc_message_template;
|
|
9093
|
+
const ccSimple = node.step_cc_message_template_simple;
|
|
9094
|
+
if (!ccSuppressed) {
|
|
9095
|
+
const ccMode = resolveMessageChannelMode(
|
|
9096
|
+
node,
|
|
9097
|
+
["cc_message_config_mode", "step_cc_message_config_mode", "cc_message_template_mode"],
|
|
9098
|
+
ccScript,
|
|
9099
|
+
ccSimple
|
|
9100
|
+
);
|
|
9101
|
+
if (ccMode === "code" && typeof ccScript === "string" && ccScript.trim() && !isStaticEmptyMessageReturn(ccScript)) {
|
|
9102
|
+
analyzeCodeMessageCard(errors, warnings, `${nodeName}.cc_message_template`, ccScript, ccWouldReachRecipient);
|
|
9103
|
+
} else if (ccMode === "standard" && isRecord6(ccSimple)) {
|
|
9104
|
+
analyzeSimpleMessageCard(errors, warnings, `${nodeName}.step_cc_message_template_simple`, ccSimple);
|
|
9105
|
+
} else if (ccMode === "simple" && isRecord6(ccSimple) && simpleMessageTemplateHasConfiguredContent(ccSimple)) {
|
|
9106
|
+
reportUnsupportedSimpleModeConfig(
|
|
9107
|
+
errors,
|
|
9108
|
+
`${nodeName}.step_cc_message_config_mode`,
|
|
9109
|
+
`${nodeName}.step_cc_message_template_simple`,
|
|
9110
|
+
typeof ccScript === "string" && Boolean(ccScript.trim())
|
|
9111
|
+
);
|
|
9112
|
+
}
|
|
9113
|
+
}
|
|
9114
|
+
if (hasOwner && !flowTemplateNodeIsAutomaticWait(node) && !flowTemplateNodeMessageConfigured(node)) {
|
|
9115
|
+
warnings.push(
|
|
9116
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.missingForHumanNode}] ${nodeName} \u6709\u771F\u5B9E\u529E\u7406\u4EBA\uFF0C\u4F46\u6CA1\u6709\u53EF\u7528\u7684\u6D88\u606F\u6A21\u677F\uFF1Amessage_template \u4E3A\u7A7A\uFF0Cmessage_template_simple \u4E5F\u7F3A\u5931\u6216\u53EA\u6709\u524D\u7AEF\u9ED8\u8BA4\u7A7A\u9AA8\u67B6\uFF08title \u4E0E content[0].body \u90FD\u4E3A\u7A7A\uFF09\uFF1B\u529E\u7406\u4EBA\u53EA\u4F1A\u6536\u5230\u540E\u7AEF\u9ED8\u8BA4\u6D88\u606F\uFF0C\u7F3A\u5C11\u4E1A\u52A1\u4E0A\u4E0B\u6587\u548C\u8DF3\u8F6C\u6309\u94AE\u3002`
|
|
9117
|
+
);
|
|
9118
|
+
}
|
|
9119
|
+
if (!hasOwner && typeof messageScript === "string" && messageScript.trim()) {
|
|
9120
|
+
warnings.push(
|
|
9121
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.onSystemNode}] ${nodeName} \u6CA1\u6709\u771F\u5B9E\u529E\u7406\u4EBA\uFF0C\u5374\u914D\u7F6E\u4E86 message_template\uFF1B\u8BE5\u8282\u70B9\u6CA1\u6709\u53EF\u53D1\u9001\u7684\u6536\u4EF6\u4EBA\uFF0C\u8FD9\u6BB5\u6D88\u606F\u591A\u534A\u662F\u8BEF\u914D\u3002`
|
|
9122
|
+
);
|
|
9123
|
+
}
|
|
9124
|
+
if (flowTemplateNodeCcRecipientsConfigured(node) && !flowTemplateNodeCcMessageConfigured(node)) {
|
|
9125
|
+
warnings.push(
|
|
9126
|
+
`[${FLOW_TEMPLATE_MESSAGE_CARD_RULES.ccMessageMissing}] ${nodeName} \u914D\u7F6E\u4E86\u6284\u9001\u63A5\u6536\u4EBA\uFF0C\u4F46 cc_message_template \u4E0E step_cc_message_template_simple \u90FD\u4E3A\u7A7A\uFF1B\u6284\u9001\u4EBA\u4F1A\u6536\u5230\u540E\u7AEF\u9ED8\u8BA4\u6D88\u606F\uFF0C\u7F3A\u5C11\u4E1A\u52A1\u4E0A\u4E0B\u6587\u548C\u8DF3\u8F6C\u6309\u94AE\u3002`
|
|
9127
|
+
);
|
|
9128
|
+
}
|
|
9129
|
+
});
|
|
9130
|
+
return { errors, warnings };
|
|
9131
|
+
}
|
|
9132
|
+
function validateFlowTemplateMessageCardHardGate(work) {
|
|
9133
|
+
const analysis = analyzeFlowTemplateMessageCardRules(work);
|
|
9134
|
+
if (!analysis.errors.length) {
|
|
9135
|
+
return;
|
|
9136
|
+
}
|
|
9137
|
+
throw new Error(`flow-template message card gate failed: ${analysis.errors.join("; ")}`);
|
|
9138
|
+
}
|
|
9139
|
+
function validateFlowTemplateMessageCards(work, errors, warnings = []) {
|
|
9140
|
+
const analysis = analyzeFlowTemplateMessageCardRules(work);
|
|
9141
|
+
errors.push(...analysis.errors);
|
|
9142
|
+
warnings.push(...analysis.warnings);
|
|
9143
|
+
}
|
|
8141
9144
|
function collectStringValues(value, result = []) {
|
|
8142
9145
|
if (typeof value === "string") {
|
|
8143
9146
|
result.push(value);
|
|
@@ -10063,7 +11066,7 @@ function validateListTemplateColumnWidths(columns, errors, warnings = []) {
|
|
|
10063
11066
|
const requiredWidth = estimatedListTemplateTitleWidth(title);
|
|
10064
11067
|
if (effectiveReadableWidth < requiredWidth) {
|
|
10065
11068
|
errors.push(`\u5217\u8868\u6A21\u677F\u5217\u201C${label}\u201D\u5BBD\u5EA6\u8FC7\u5C0F\uFF0C\u6807\u9898\u5B8C\u6574\u5C55\u793A\u81F3\u5C11\u9700\u8981\u7EA6 ${requiredWidth}px\u3002`);
|
|
10066
|
-
} else if (
|
|
11069
|
+
} else if (isDataColumn && effectiveReadableWidth === requiredWidth) {
|
|
10067
11070
|
pinnedToTitleFloor.push(label);
|
|
10068
11071
|
}
|
|
10069
11072
|
}
|
|
@@ -10489,11 +11492,13 @@ function listTemplateLinkTargets(node) {
|
|
|
10489
11492
|
return targets;
|
|
10490
11493
|
}
|
|
10491
11494
|
function hardCodedStepNameGuard(text5) {
|
|
10492
|
-
|
|
10493
|
-
|
|
10494
|
-
if (
|
|
10495
|
-
if (
|
|
10496
|
-
|
|
11495
|
+
const code = text5.replace(/\/\*[\s\S]*?\*\//g, " ").replace(/(^|[^:])\/\/[^\n]*/g, "$1 ");
|
|
11496
|
+
const STEP_NAME = /(?<![.\w])ctx\.current_(?:flow_)?step_name\b/;
|
|
11497
|
+
if (!STEP_NAME.test(code)) return false;
|
|
11498
|
+
if (/ctx\.current_(?:flow_)?step_name\b\s*(?:===|==|!==|!=)\s*['"`]/.test(code)) return true;
|
|
11499
|
+
if (/['"`][^'"`]*['"`]\s*(?:===|==|!==|!=)\s*ctx\.current_(?:flow_)?step_name\b/.test(code)) return true;
|
|
11500
|
+
if (/ctx\.current_(?:flow_)?step_name\b[^\n]{0,40}?\.includes\s*\(/.test(code)) return true;
|
|
11501
|
+
return Boolean(/!{1,2}\s*ctx\.current_(?:flow_)?step_name\b/.test(code));
|
|
10497
11502
|
}
|
|
10498
11503
|
function lintListTemplateRowContext(columns, warnings) {
|
|
10499
11504
|
for (const column of columns.filter(isRecord6)) {
|
|
@@ -10508,7 +11513,7 @@ function lintListTemplateRowContext(columns, warnings) {
|
|
|
10508
11513
|
if (value.is === "router-link") {
|
|
10509
11514
|
const targets = listTemplateLinkTargets(value);
|
|
10510
11515
|
const joined = targets.join("\n");
|
|
10511
|
-
const looksLikeNavigation = /\/(?:w:|
|
|
11516
|
+
const looksLikeNavigation = /\/(?:w:|projects?(?:\/|$|\?)|\w*_detail(?:\/|$|\?)|projectContinue|project_detail_table|bid_|form_detail)|workspace/.test(joined);
|
|
10512
11517
|
if (looksLikeNavigation && !LIST_TEMPLATE_ROW_CONTEXT_PATTERN.test(joined)) {
|
|
10513
11518
|
warnings.push(
|
|
10514
11519
|
`\u5217\u8868\u6A21\u677F\u5217\u201C${label}\u201D\u7684\u4E0B\u94BB\u94FE\u63A5\u6CA1\u6709\u643A\u5E26\u884C\u4E0A\u4E0B\u6587\uFF08\u672A\u89C1 {{__id}} \u6216 ctx.__id\uFF09\uFF1A\u6BCF\u884C\u90FD\u4F1A\u8DF3\u5230\u540C\u4E00\u4E2A\u5168\u5C40\u9875\u9762\u3002\u82E5\u662F\u884C\u5185\u4E0B\u94BB\uFF0C\u8BF7\u628A\u884C id \u6216\u4E1A\u52A1\u7F16\u53F7\u5E26\u8FDB\u76EE\u6807 URL\uFF1B\u786E\u5B9E\u662F\u5168\u5C40\u52A8\u4F5C\u8BF7\u5728\u94FE\u63A5\u6587\u6848\u548C skill \u5907\u6CE8\u4E2D\u663E\u5F0F\u8BF4\u660E\u3002`
|
|
@@ -10627,11 +11632,11 @@ function lintFlowDetailTemplateWork(work, errors, warnings = []) {
|
|
|
10627
11632
|
warnings.push(...analysis.warnings);
|
|
10628
11633
|
return analysis;
|
|
10629
11634
|
}
|
|
10630
|
-
function normalizePageTemplatePayload(domain, work, options = {}) {
|
|
11635
|
+
function normalizePageTemplatePayload(domain, work, options = {}, warnings = []) {
|
|
10631
11636
|
const definition = CONFIG_DOMAINS[domain];
|
|
10632
11637
|
validatePageTemplateName(work);
|
|
10633
11638
|
if (domain === "list-template") {
|
|
10634
|
-
validateListTemplateActionGate(work);
|
|
11639
|
+
validateListTemplateActionGate(work, void 0, warnings);
|
|
10635
11640
|
}
|
|
10636
11641
|
if (domain === "filter-template") {
|
|
10637
11642
|
const errors = [];
|
|
@@ -10642,16 +11647,16 @@ function normalizePageTemplatePayload(domain, work, options = {}) {
|
|
|
10642
11647
|
}
|
|
10643
11648
|
if (domain === "console-template") {
|
|
10644
11649
|
const errors = [];
|
|
10645
|
-
const
|
|
10646
|
-
lintConsoleTemplateWork(work, errors,
|
|
11650
|
+
const warnings2 = [];
|
|
11651
|
+
lintConsoleTemplateWork(work, errors, warnings2);
|
|
10647
11652
|
if (errors.length) {
|
|
10648
11653
|
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
10649
11654
|
}
|
|
10650
11655
|
}
|
|
10651
11656
|
if (domain === "step-detail-template") {
|
|
10652
11657
|
const errors = [];
|
|
10653
|
-
const
|
|
10654
|
-
lintStepDetailTemplateWork(work, errors,
|
|
11658
|
+
const warnings2 = [];
|
|
11659
|
+
lintStepDetailTemplateWork(work, errors, warnings2);
|
|
10655
11660
|
if (errors.length) {
|
|
10656
11661
|
throw new Error(`step-detail-template lint failed: ${errors.join("; ")}`);
|
|
10657
11662
|
}
|
|
@@ -12144,6 +13149,7 @@ function validateFlowTemplateNonExemptHardGates(work) {
|
|
|
12144
13149
|
validateFlowTemplateUrgentReminder(work);
|
|
12145
13150
|
validateFlowTemplateRuntimeScripts(work);
|
|
12146
13151
|
validateFlowTemplateFeishuChatPlugin(work);
|
|
13152
|
+
validateFlowTemplateMessageCardHardGate(work);
|
|
12147
13153
|
}
|
|
12148
13154
|
function validateFlowTemplateHardGates(work) {
|
|
12149
13155
|
validateFlowTemplateNonExemptHardGates(work);
|
|
@@ -12164,6 +13170,7 @@ function collectFlowTemplateLintErrors(work) {
|
|
|
12164
13170
|
validateFlowTemplateUrgentReminder(work, errors);
|
|
12165
13171
|
validateFlowTemplateStandardConditionEditorRules(work, errors);
|
|
12166
13172
|
validateFlowTemplateCodeModeMessages(work, errors);
|
|
13173
|
+
validateFlowTemplateMessageCards(work, errors);
|
|
12167
13174
|
validateFlowTemplateRuntimeScripts(work, errors);
|
|
12168
13175
|
validateFlowTemplateFeishuChatPlugin(work, errors);
|
|
12169
13176
|
return errors;
|
|
@@ -15897,6 +16904,7 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
15897
16904
|
validateFlowTemplateUrgentReminder(work);
|
|
15898
16905
|
validateFlowTemplateStandardConditionEditorRules(work);
|
|
15899
16906
|
validateFlowTemplateCodeModeMessages(work);
|
|
16907
|
+
validateFlowTemplateMessageCardHardGate(work);
|
|
15900
16908
|
validateFlowTemplateRuntimeScripts(work);
|
|
15901
16909
|
validateFlowTemplateFeishuChatPlugin(work);
|
|
15902
16910
|
validateFlowTemplateFormDrivenCreateBaseline(work, void 0, { context: "flow-template create" });
|
|
@@ -17986,6 +18994,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
17986
18994
|
ignoredPreexistingLintErrors = evaluated.ignored;
|
|
17987
18995
|
}
|
|
17988
18996
|
let formTemplateWarnings = [];
|
|
18997
|
+
let listTemplateWarnings = [];
|
|
17989
18998
|
let consoleTemplateWarnings = [];
|
|
17990
18999
|
let formTemplateReferenceAudit;
|
|
17991
19000
|
let flowDetailTemplateWarnings = [];
|
|
@@ -18021,6 +19030,10 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
18021
19030
|
}
|
|
18022
19031
|
}
|
|
18023
19032
|
}
|
|
19033
|
+
if (domain === "list-template" && isRecord6(work)) {
|
|
19034
|
+
listTemplateWarnings = [];
|
|
19035
|
+
validateListTemplateActionGate(work, void 0, listTemplateWarnings);
|
|
19036
|
+
}
|
|
18024
19037
|
if (domain === "form-template" && isRecord6(work)) {
|
|
18025
19038
|
const errors = [];
|
|
18026
19039
|
formTemplateWarnings = [];
|
|
@@ -18114,6 +19127,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
18114
19127
|
if (listTemplateSafety) {
|
|
18115
19128
|
listTemplateSafety.payload_hash = hashJson(payload);
|
|
18116
19129
|
listTemplateSafety.raw_hash = raw === void 0 ? null : hashJson(raw);
|
|
19130
|
+
if (listTemplateWarnings.length) listTemplateSafety.warnings = listTemplateWarnings;
|
|
18117
19131
|
}
|
|
18118
19132
|
if (pageTemplateScopeManifest && isRecord6(raw)) {
|
|
18119
19133
|
pageTemplateScope = await buildPageTemplateScopeArtifact(pageTemplateScopeManifest, raw, work, payload);
|
|
@@ -18166,6 +19180,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
18166
19180
|
...datasetMapping ? { dataset_mapping: datasetMapping } : {},
|
|
18167
19181
|
...flowCategoryReferenceAudit ? { flow_category_reference: flowCategoryReferenceEvidence(flowCategoryReferenceAudit) } : {},
|
|
18168
19182
|
...formTemplateWarnings.length ? { form_template_warnings: formTemplateWarnings } : {},
|
|
19183
|
+
...listTemplateWarnings.length ? { list_template_warnings: listTemplateWarnings } : {},
|
|
18169
19184
|
...consoleTemplateWarnings.length ? {
|
|
18170
19185
|
console_template_warnings: consoleTemplateWarnings,
|
|
18171
19186
|
runtime_proof_required: true,
|
|
@@ -18221,6 +19236,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
18221
19236
|
} : {},
|
|
18222
19237
|
...datasetFieldWarnings.length ? { warnings: datasetFieldWarnings } : {},
|
|
18223
19238
|
...formTemplateWarnings.length ? { warnings: formTemplateWarnings } : {},
|
|
19239
|
+
...listTemplateWarnings.length ? { warnings: listTemplateWarnings } : {},
|
|
18224
19240
|
...consoleTemplateWarnings.length ? {
|
|
18225
19241
|
warnings: consoleTemplateWarnings,
|
|
18226
19242
|
runtime_proof_required: true,
|
|
@@ -18475,6 +19491,7 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
18475
19491
|
validateFlowTemplateUrgentReminder(flowWork, errors);
|
|
18476
19492
|
validateFlowTemplateStandardConditionEditorRules(flowWork, errors);
|
|
18477
19493
|
validateFlowTemplateCodeModeMessages(flowWork, errors, warnings);
|
|
19494
|
+
validateFlowTemplateMessageCards(flowWork, errors, warnings);
|
|
18478
19495
|
validateFlowTemplateRuntimeScripts(flowWork, errors);
|
|
18479
19496
|
validateFlowTemplateFeishuChatPlugin(flowWork, errors);
|
|
18480
19497
|
pluginLint = await runFlowTemplatePluginLint(flowWork, options.pluginLint);
|
|
@@ -19155,6 +20172,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
19155
20172
|
validateFlowTemplateUrgentReminder(gateView);
|
|
19156
20173
|
validateFlowTemplateStandardConditionEditorRules(gateView);
|
|
19157
20174
|
validateFlowTemplateCodeModeMessages(gateView);
|
|
20175
|
+
validateFlowTemplateMessageCardHardGate(gateView);
|
|
19158
20176
|
validateFlowTemplateRuntimeScripts(gateView);
|
|
19159
20177
|
validateFlowTemplateFeishuChatPlugin(gateView);
|
|
19160
20178
|
validateFlowTemplateProjectNameTemplate(gateView);
|
|
@@ -45283,13 +46301,18 @@ function hasExactConfirmEvidence(evidence) {
|
|
|
45283
46301
|
function rowsHaveExecutableTable(text5) {
|
|
45284
46302
|
return extractTaskRows(text5).length > 0;
|
|
45285
46303
|
}
|
|
46304
|
+
var ADJUSTMENT_ID_TOKEN = /^(?!T\d)[A-Z]\d+$/i;
|
|
46305
|
+
var NODE_ID_TOKEN = /^(?:(?!T\d)[A-Z]\d+|0\d|\d{2})$/i;
|
|
46306
|
+
var NODE_TRACE_PHRASE = "\u7CFB\u7EDF\u52A8\u4F5C";
|
|
46307
|
+
function idTokens(cell) {
|
|
46308
|
+
const withoutNotes = cell.replace(/[((][^))]*[))]/g, " ");
|
|
46309
|
+
return withoutNotes.split(/[、,,;;\s/|]+/).map((token) => token.trim().replace(/[。.]$/, "")).filter(Boolean);
|
|
46310
|
+
}
|
|
45286
46311
|
function adjustmentTraceIds(cell) {
|
|
45287
|
-
return
|
|
46312
|
+
return idTokens(cell).filter((token) => ADJUSTMENT_ID_TOKEN.test(token));
|
|
45288
46313
|
}
|
|
45289
|
-
var ADJUSTMENT_TRACE_ID_PATTERN = /\b(?!T\d)[A-Z]\d+\b/gi;
|
|
45290
|
-
var NODE_TRACE_PHRASE = "\u7CFB\u7EDF\u52A8\u4F5C";
|
|
45291
46314
|
function nodeTraceIds(cell) {
|
|
45292
|
-
const ids =
|
|
46315
|
+
const ids = idTokens(cell).filter((token) => NODE_ID_TOKEN.test(token));
|
|
45293
46316
|
if (cell.includes(NODE_TRACE_PHRASE)) ids.push(NODE_TRACE_PHRASE);
|
|
45294
46317
|
return ids;
|
|
45295
46318
|
}
|