bpmax-cli 0.2.1-beta.86 → 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 +1256 -34
- 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(" ");
|
|
@@ -5143,6 +5159,60 @@ function matchesBoundary(path29, declared) {
|
|
|
5143
5159
|
}
|
|
5144
5160
|
return path29 === normalized || path29.startsWith(`${normalized}/`);
|
|
5145
5161
|
}
|
|
5162
|
+
var LIST_TEMPLATE_PRESENTATION_PATH = /\/(?:props\/)?(?:width|minWidth|align|headerAlign|showOverflowTooltip|fixed|sortable|className)$/;
|
|
5163
|
+
function isPresentationOnlyChange(changedPaths) {
|
|
5164
|
+
return changedPaths.length > 0 && changedPaths.every((path29) => LIST_TEMPLATE_PRESENTATION_PATH.test(path29));
|
|
5165
|
+
}
|
|
5166
|
+
function isPresentationOnlyListTemplateChange(changedPaths) {
|
|
5167
|
+
return isPresentationOnlyChange([...changedPaths]);
|
|
5168
|
+
}
|
|
5169
|
+
function validateListTemplateColumnWidthEvidence(value, context2) {
|
|
5170
|
+
if (!isRecord5(value)) {
|
|
5171
|
+
throw new Error("[list_template_column_width_report_invalid] Column-width report must be a JSON object.");
|
|
5172
|
+
}
|
|
5173
|
+
if (value.schema_version !== 1 || value.result !== "pass") {
|
|
5174
|
+
throw new Error('[list_template_column_width_report_invalid] Column-width report must use schema_version=1 and result="pass".');
|
|
5175
|
+
}
|
|
5176
|
+
if (value.template_id !== context2.templateId || value.profile !== context2.profile) {
|
|
5177
|
+
throw new Error("[list_template_column_width_report_mismatch] Column-width report is not bound to this template and profile.");
|
|
5178
|
+
}
|
|
5179
|
+
if (value.submit_payload_hash !== context2.payloadHash) {
|
|
5180
|
+
throw new Error("[list_template_column_width_report_mismatch] Column-width report is not bound to this submit payload.");
|
|
5181
|
+
}
|
|
5182
|
+
const columns = Array.isArray(value.columns) ? value.columns.filter(isRecord5) : [];
|
|
5183
|
+
if (!columns.length) {
|
|
5184
|
+
throw new Error("[list_template_column_width_report_invalid] Column-width report must record at least one measured column.");
|
|
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
|
+
}
|
|
5195
|
+
const unmeasured = columns.filter((column) => typeof column.truncated !== "boolean");
|
|
5196
|
+
if (unmeasured.length) {
|
|
5197
|
+
throw new Error(
|
|
5198
|
+
`[list_template_column_width_report_invalid] Every measured column must record truncated: true|false; missing for ${unmeasured.map((column) => String(column.title ?? column.prop ?? "<unknown>")).join(", ")}.`
|
|
5199
|
+
);
|
|
5200
|
+
}
|
|
5201
|
+
const truncated = columns.filter((column) => column.truncated === true);
|
|
5202
|
+
if (truncated.length) {
|
|
5203
|
+
throw new Error(
|
|
5204
|
+
`[list_template_column_width_report_truncated] Rendered columns still truncate their content: ${truncated.map((column) => String(column.title ?? column.prop ?? "<unknown>")).join(", ")}. Increase the width instead of overriding the gate.`
|
|
5205
|
+
);
|
|
5206
|
+
}
|
|
5207
|
+
return {
|
|
5208
|
+
schema_version: 1,
|
|
5209
|
+
kind: "list_template_column_width_evidence",
|
|
5210
|
+
template_id: context2.templateId,
|
|
5211
|
+
profile: context2.profile,
|
|
5212
|
+
submit_payload_hash: context2.payloadHash,
|
|
5213
|
+
measured_columns: columns.length
|
|
5214
|
+
};
|
|
5215
|
+
}
|
|
5146
5216
|
function analyzeListTemplatePermissionBoundary(raw, work, manifest) {
|
|
5147
5217
|
const changedPaths = changedJsonPaths(raw, work);
|
|
5148
5218
|
const permissionRelated = changedPaths.some((path29) => containsPermissionIdentifier(path29) || containsPermissionIdentifier(changedTextFragment(
|
|
@@ -5180,6 +5250,7 @@ function analyzeListTemplatePermissionBoundary(raw, work, manifest) {
|
|
|
5180
5250
|
boundary: {
|
|
5181
5251
|
schema_version: 1,
|
|
5182
5252
|
change_type: "list-template-permission",
|
|
5253
|
+
presentation_only: isPresentationOnlyChange(changedPaths),
|
|
5183
5254
|
allowed_paths: allowedPaths,
|
|
5184
5255
|
allowed_functions: allowedFunctions,
|
|
5185
5256
|
forbidden_paths: forbiddenPaths,
|
|
@@ -6814,6 +6885,7 @@ function validateFlowAppFlowWork(value, errors, warnings) {
|
|
|
6814
6885
|
validateFlowTemplateUrgentReminder(value, errors);
|
|
6815
6886
|
validateFlowTemplateStandardConditionEditorRules(value, errors);
|
|
6816
6887
|
validateFlowTemplateCodeModeMessages(value, errors);
|
|
6888
|
+
validateFlowTemplateMessageCards(value, errors, warnings);
|
|
6817
6889
|
validateFlowTemplateRuntimeScripts(value, errors);
|
|
6818
6890
|
validateFlowTemplateFeishuChatPlugin(value, errors);
|
|
6819
6891
|
validateFlowTemplateFormDrivenCreateBaseline(value, errors, {
|
|
@@ -7133,6 +7205,54 @@ var FLOW_TEMPLATE_RUNTIME_CC_TYPES = /* @__PURE__ */ new Set(["fieldvalue", "mat
|
|
|
7133
7205
|
var FLOW_TEMPLATE_CC_TRIGGER_MODES = /* @__PURE__ */ new Set(["all", "approve", "refuse"]);
|
|
7134
7206
|
var FLOW_TEMPLATE_CC_TRIGGER_TIMINGS = /* @__PURE__ */ new Set(["step_active", "step_finish"]);
|
|
7135
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"]);
|
|
7136
7256
|
function isPositiveIntegerLike(value) {
|
|
7137
7257
|
if (typeof value !== "number" && typeof value !== "string") {
|
|
7138
7258
|
return false;
|
|
@@ -7874,7 +7994,34 @@ function isStaticEmptyMessageReturn(script) {
|
|
|
7874
7994
|
return false;
|
|
7875
7995
|
}
|
|
7876
7996
|
const compact = text5.replace(/\s+/g, " ").trim();
|
|
7877
|
-
|
|
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
|
+
});
|
|
7878
8025
|
}
|
|
7879
8026
|
function looksLikeDynamicMessageSuppression(script) {
|
|
7880
8027
|
if (isStaticEmptyMessageReturn(script)) {
|
|
@@ -8002,13 +8149,13 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8002
8149
|
}
|
|
8003
8150
|
const nodeName = typeof node.name === "string" && node.name.trim() ? node.name.trim() : `nodes[${index}]`;
|
|
8004
8151
|
const nodeId = String(node.id ?? "").trim();
|
|
8005
|
-
const
|
|
8006
|
-
const
|
|
8007
|
-
|
|
8008
|
-
|
|
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);
|
|
8009
8157
|
}
|
|
8010
|
-
|
|
8011
|
-
if (typeof script !== "string") {
|
|
8158
|
+
if (!runtimeCodeMode || typeof script !== "string") {
|
|
8012
8159
|
return;
|
|
8013
8160
|
}
|
|
8014
8161
|
const ackKey = `${nodeId}\0${channel}`;
|
|
@@ -8017,18 +8164,25 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8017
8164
|
if (ack) {
|
|
8018
8165
|
usedAcks.add(ackKey);
|
|
8019
8166
|
nextWarnings.push(
|
|
8020
|
-
`[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}.`
|
|
8021
8168
|
);
|
|
8022
8169
|
return;
|
|
8023
8170
|
}
|
|
8024
|
-
if (
|
|
8171
|
+
if (wouldReachRecipient) {
|
|
8025
8172
|
nextErrors.push(
|
|
8026
|
-
`[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."
|
|
8027
8174
|
);
|
|
8028
8175
|
return;
|
|
8029
8176
|
}
|
|
8030
8177
|
nextWarnings.push(
|
|
8031
|
-
`[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}.`
|
|
8032
8186
|
);
|
|
8033
8187
|
return;
|
|
8034
8188
|
}
|
|
@@ -8038,11 +8192,19 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8038
8192
|
);
|
|
8039
8193
|
}
|
|
8040
8194
|
};
|
|
8195
|
+
const messageModeForGate = resolveMessageChannelMode(
|
|
8196
|
+
node,
|
|
8197
|
+
["message_config_mode", "message_template_mode"],
|
|
8198
|
+
node.message_template,
|
|
8199
|
+
node.message_template_simple
|
|
8200
|
+
);
|
|
8041
8201
|
inspectChannel(
|
|
8042
8202
|
"message",
|
|
8043
8203
|
`${nodeName}.message_template`,
|
|
8044
8204
|
node.message_template,
|
|
8045
|
-
isCodeModeMessage(node, ["message_config_mode", "message_template_mode"])
|
|
8205
|
+
isCodeModeMessage(node, ["message_config_mode", "message_template_mode"]),
|
|
8206
|
+
messageModeForGate === "code",
|
|
8207
|
+
messageWouldReachRecipient
|
|
8046
8208
|
);
|
|
8047
8209
|
if (isCodeModeMessage(node, ["message_config_mode", "message_template_mode"])) {
|
|
8048
8210
|
const simpleTemplate = isRecord6(node.message_template_simple) ? node.message_template_simple : {};
|
|
@@ -8067,7 +8229,14 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8067
8229
|
"cc",
|
|
8068
8230
|
`${nodeName}.cc_message_template`,
|
|
8069
8231
|
node.cc_message_template,
|
|
8070
|
-
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
|
|
8071
8240
|
);
|
|
8072
8241
|
});
|
|
8073
8242
|
for (const [key, ack] of acks) {
|
|
@@ -8092,6 +8261,886 @@ function validateFlowTemplateCodeModeMessages(value, errors, warnings) {
|
|
|
8092
8261
|
}
|
|
8093
8262
|
throw new Error(`flow-template code-mode message gate failed: ${nextErrors.join("; ")}`);
|
|
8094
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
|
+
}
|
|
8095
9144
|
function collectStringValues(value, result = []) {
|
|
8096
9145
|
if (typeof value === "string") {
|
|
8097
9146
|
result.push(value);
|
|
@@ -9949,7 +10998,40 @@ function hasListTemplateOverflowDisclosure(column) {
|
|
|
9949
10998
|
visit(column.createElement);
|
|
9950
10999
|
return disclosed;
|
|
9951
11000
|
}
|
|
9952
|
-
|
|
11001
|
+
var LIST_TEMPLATE_CONTENT_MIN_WIDTH = [
|
|
11002
|
+
// `编码`/`code` only when the column is a document number, not every "code" word:
|
|
11003
|
+
// 门店编码 is an identifier list column and does need room, so include it, but
|
|
11004
|
+
// keep the width below a full date-stamped serial number.
|
|
11005
|
+
{ kind: "document_no", pattern: /(单号|单据号|流水号|订单号|合同号|批次号)/i, minWidth: 180, why: "\u5355\u53F7\u7C7B\u5185\u5BB9\u542B\u65E5\u671F\u6BB5\u6216\u524D\u7F00\uFF0C\u901A\u5E38\u9700\u8981 180px \u4EE5\u4E0A" },
|
|
11006
|
+
{ kind: "identifier", pattern: /(编码|编号|\bno\b|\bsn\b|\bcode\b|\bid\b)/i, minWidth: 130, why: "\u7F16\u7801/\u7F16\u53F7\u7C7B\u5185\u5BB9\u901A\u5E38\u9700\u8981 130px \u4EE5\u4E0A" },
|
|
11007
|
+
{ kind: "date", pattern: /(日期|时间|截止|\bdate\b|\btime\b|_at\b)/i, minWidth: 130, why: "\u65E5\u671F\u5E38\u5E26\u56FE\u6807\u4E0E\u65F6:\u5206\uFF0C\u901A\u5E38\u9700\u8981 130px \u4EE5\u4E0A" },
|
|
11008
|
+
{ kind: "people", pattern: /(负责人|处理人|申请人|创建人|审批人|经办人|owner|assignee|creator|approver|manager)/i, minWidth: 130, why: "\u4EBA\u5458\u5217\u542B\u5934\u50CF\u6216\u201C\u59D3\u540D | \u7EC4\u7EC7\u201D\uFF0C\u901A\u5E38\u9700\u8981 130px \u4EE5\u4E0A" },
|
|
11009
|
+
// Only multi-value shapes are listed: a plain 状态 column renders one short enum
|
|
11010
|
+
// and is usually fine at 110px, so it must not be pulled into this rule.
|
|
11011
|
+
{ kind: "multi_value", pattern: /(包件|范围|标签|多选|\btags?\b|\bscope\b)/i, minWidth: 180, why: "\u591A\u503C\u62FC\u63A5\u5217\u4F1A\u968F\u53D6\u503C\u6570\u91CF\u53D8\u957F\uFF0C\u901A\u5E38\u9700\u8981 180px \u4EE5\u4E0A" }
|
|
11012
|
+
];
|
|
11013
|
+
function listTemplateContentMinWidth(column) {
|
|
11014
|
+
const title = typeof column.title === "string" ? column.title : "";
|
|
11015
|
+
const key = typeof column.key === "string" ? column.key : typeof column.prop === "string" ? column.prop : "";
|
|
11016
|
+
const renderer = textOf2(column.createElement);
|
|
11017
|
+
const probe = `${title} ${key} ${renderer}`;
|
|
11018
|
+
const match = LIST_TEMPLATE_CONTENT_MIN_WIDTH.find((entry) => entry.pattern.test(probe));
|
|
11019
|
+
if (match) {
|
|
11020
|
+
if (/\.join\s*\(|\{\{\s*[^}]*\}\}\s*[,,]/.test(renderer)) {
|
|
11021
|
+
return { minWidth: Math.max(match.minWidth, 180), why: "\u5355\u5143\u683C\u62FC\u63A5\u4E86\u591A\u4E2A\u503C\uFF0C\u5BBD\u5EA6\u4F1A\u968F\u53D6\u503C\u6570\u91CF\u589E\u957F" };
|
|
11022
|
+
}
|
|
11023
|
+
return { minWidth: match.minWidth, why: match.why };
|
|
11024
|
+
}
|
|
11025
|
+
if (/el-avatar/.test(renderer)) {
|
|
11026
|
+
return { minWidth: 130, why: "\u5355\u5143\u683C\u542B\u5934\u50CF\uFF0C\u9700\u8981\u4E3A\u5934\u50CF\u548C\u59D3\u540D\u7559\u51FA 130px \u4EE5\u4E0A" };
|
|
11027
|
+
}
|
|
11028
|
+
return void 0;
|
|
11029
|
+
}
|
|
11030
|
+
function listTemplateUsesFixedWidthOnly(column) {
|
|
11031
|
+
const props = isRecord6(column.props) ? column.props : {};
|
|
11032
|
+
return props.width !== void 0 && props.width !== null && props.width !== "";
|
|
11033
|
+
}
|
|
11034
|
+
function validateListTemplateColumnWidths(columns, errors, warnings = []) {
|
|
9953
11035
|
const recordColumns = columns.filter(isRecord6);
|
|
9954
11036
|
const dataColumns = recordColumns.filter((column) => !isListTemplateUtilityColumn(column));
|
|
9955
11037
|
if (dataColumns.length === 0) {
|
|
@@ -9957,6 +11039,7 @@ function validateListTemplateColumnWidths(columns, errors) {
|
|
|
9957
11039
|
return;
|
|
9958
11040
|
}
|
|
9959
11041
|
let adaptiveColumnCount = 0;
|
|
11042
|
+
const pinnedToTitleFloor = [];
|
|
9960
11043
|
recordColumns.forEach((column, index) => {
|
|
9961
11044
|
const props = isRecord6(column.props) ? column.props : {};
|
|
9962
11045
|
const label = listTemplateColumnLabel(column, index);
|
|
@@ -9983,6 +11066,17 @@ function validateListTemplateColumnWidths(columns, errors) {
|
|
|
9983
11066
|
const requiredWidth = estimatedListTemplateTitleWidth(title);
|
|
9984
11067
|
if (effectiveReadableWidth < requiredWidth) {
|
|
9985
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`);
|
|
11069
|
+
} else if (isDataColumn && effectiveReadableWidth === requiredWidth) {
|
|
11070
|
+
pinnedToTitleFloor.push(label);
|
|
11071
|
+
}
|
|
11072
|
+
}
|
|
11073
|
+
if (isDataColumn && effectiveReadableWidth !== void 0) {
|
|
11074
|
+
const content = listTemplateContentMinWidth(column);
|
|
11075
|
+
if (content && effectiveReadableWidth < content.minWidth) {
|
|
11076
|
+
const hint = listTemplateUsesFixedWidthOnly(column) ? `\uFF1B\u56FA\u5B9A\u5BBD\u5EA6\u5217\u53EF\u6309\u6B64\u4E0B\u9650\u914D\u7F6E\uFF0C\u6216\u6539\u7528 minWidth \u8BA9\u5185\u5BB9\u53C2\u4E0E\u6491\u5F00` : "";
|
|
11077
|
+
warnings.push(
|
|
11078
|
+
`\u5217\u8868\u6A21\u677F\u5217\u201C${label}\u201D\u5F53\u524D\u7EA6 ${effectiveReadableWidth}px\uFF0C\u6309\u5217\u8BED\u4E49\uFF08${content.why}\uFF09\u5185\u5BB9\u53EF\u80FD\u88AB\u622A\u65AD\uFF0C\u5EFA\u8BAE\u81F3\u5C11 ${content.minWidth}px${hint}\u3002\u8FD9\u662F\u6309\u5B57\u6BB5\u8BED\u4E49\u7684\u4F30\u7B97\uFF0C\u8BF7\u4EE5\u771F\u5B9E\u9875\u9762\u6BCF\u5217 scrollWidth == clientWidth \u4E3A\u51C6\u3002`
|
|
11079
|
+
);
|
|
9986
11080
|
}
|
|
9987
11081
|
}
|
|
9988
11082
|
if (isDataColumn && hasWidth && isListTemplateLongTextColumn(column) && !hasListTemplateOverflowDisclosure(column)) {
|
|
@@ -9992,6 +11086,11 @@ function validateListTemplateColumnWidths(columns, errors) {
|
|
|
9992
11086
|
if (adaptiveColumnCount === 0) {
|
|
9993
11087
|
errors.push("\u5217\u8868\u6A21\u677F\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u81EA\u9002\u5E94\u6570\u636E\u5217\uFF1B\u8BF7\u5728\u4E00\u4E2A\u975E\u64CD\u4F5C\u5217\u4E0A\u5220\u9664 props.width\uFF0C\u53EF\u4FDD\u7559 props.minWidth\u3002");
|
|
9994
11088
|
}
|
|
11089
|
+
if (pinnedToTitleFloor.length >= 2) {
|
|
11090
|
+
warnings.push(
|
|
11091
|
+
`\u5217\u8868\u6A21\u677F\u6709 ${pinnedToTitleFloor.length} \u5217\u5BBD\u5EA6\u6B63\u597D\u7B49\u4E8E\u8868\u5934\u4E0B\u9650\uFF08${pinnedToTitleFloor.slice(0, 6).join("\u3001")}${pinnedToTitleFloor.length > 6 ? " \u7B49" : ""}\uFF09\u3002\u6309\u8868\u5934\u4E0B\u9650\u914D\u5BBD\u5EA6\u4F1A\u8BA9\u6BCF\u884C\u5185\u5BB9\u88AB\u7701\u7565\u53F7\u622A\u65AD\uFF1B\u8BF7\u6309\u5B57\u6BB5\u8BED\u4E49\u7ED9\u8DB3\u5BBD\u5EA6\uFF0C\u6216\u6539\u7528\u81EA\u9002\u5E94\u5217\u3002`
|
|
11092
|
+
);
|
|
11093
|
+
}
|
|
9995
11094
|
}
|
|
9996
11095
|
function classifyListTemplateAction(label) {
|
|
9997
11096
|
if (/(删除|移除|作废|delete|remove|discard)/i.test(label)) {
|
|
@@ -10365,6 +11464,67 @@ function validateDeletePermissionGuard(item, errors) {
|
|
|
10365
11464
|
errors.push("list-template delete action must include a permission guard using ctx.$CAN_DELETE or an equivalent project.delete/project.delete.my + owner check.");
|
|
10366
11465
|
}
|
|
10367
11466
|
}
|
|
11467
|
+
var LIST_TEMPLATE_ROW_CONTEXT_PATTERN = /\{\{\s*__id\s*\}\}|ctx\.__id\b|ctx\.\$PROJECT\b|\{\{\s*(?:id|project_id)\s*\}\}/;
|
|
11468
|
+
function listTemplateLinkTargets(node) {
|
|
11469
|
+
const attribute = isRecord6(node.attribute) ? node.attribute : {};
|
|
11470
|
+
const props = isRecord6(attribute.props) ? attribute.props : {};
|
|
11471
|
+
const targets = [];
|
|
11472
|
+
const visit = (value) => {
|
|
11473
|
+
if (value === void 0 || value === null) return;
|
|
11474
|
+
if (typeof value === "string") {
|
|
11475
|
+
if (value.trim()) targets.push(value);
|
|
11476
|
+
return;
|
|
11477
|
+
}
|
|
11478
|
+
if (Array.isArray(value)) {
|
|
11479
|
+
value.forEach(visit);
|
|
11480
|
+
return;
|
|
11481
|
+
}
|
|
11482
|
+
if (!isRecord6(value)) return;
|
|
11483
|
+
if (typeof value.$template === "string") {
|
|
11484
|
+
targets.push(value.$template);
|
|
11485
|
+
return;
|
|
11486
|
+
}
|
|
11487
|
+
Object.values(value).forEach(visit);
|
|
11488
|
+
};
|
|
11489
|
+
visit(props.to);
|
|
11490
|
+
visit(props.href);
|
|
11491
|
+
visit(attribute.to);
|
|
11492
|
+
return targets;
|
|
11493
|
+
}
|
|
11494
|
+
function hardCodedStepNameGuard(text5) {
|
|
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));
|
|
11502
|
+
}
|
|
11503
|
+
function lintListTemplateRowContext(columns, warnings) {
|
|
11504
|
+
for (const column of columns.filter(isRecord6)) {
|
|
11505
|
+
const label = listTemplateColumnLabel(column, columns.indexOf(column));
|
|
11506
|
+
const visit = (value) => {
|
|
11507
|
+
if (value === void 0 || value === null) return;
|
|
11508
|
+
if (Array.isArray(value)) {
|
|
11509
|
+
value.forEach(visit);
|
|
11510
|
+
return;
|
|
11511
|
+
}
|
|
11512
|
+
if (!isRecord6(value)) return;
|
|
11513
|
+
if (value.is === "router-link") {
|
|
11514
|
+
const targets = listTemplateLinkTargets(value);
|
|
11515
|
+
const joined = targets.join("\n");
|
|
11516
|
+
const looksLikeNavigation = /\/(?:w:|projects?(?:\/|$|\?)|\w*_detail(?:\/|$|\?)|projectContinue|project_detail_table|bid_|form_detail)|workspace/.test(joined);
|
|
11517
|
+
if (looksLikeNavigation && !LIST_TEMPLATE_ROW_CONTEXT_PATTERN.test(joined)) {
|
|
11518
|
+
warnings.push(
|
|
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`
|
|
11520
|
+
);
|
|
11521
|
+
}
|
|
11522
|
+
}
|
|
11523
|
+
Object.values(value).forEach(visit);
|
|
11524
|
+
};
|
|
11525
|
+
visit(column.createElement);
|
|
11526
|
+
}
|
|
11527
|
+
}
|
|
10368
11528
|
function validateListTemplateActionGate(value, errors, warnings) {
|
|
10369
11529
|
const nextErrors = [];
|
|
10370
11530
|
const content = parseTemplateContent(value, nextErrors);
|
|
@@ -10387,8 +11547,11 @@ function validateListTemplateActionGate(value, errors, warnings) {
|
|
|
10387
11547
|
lintListTemplateDatasetFieldReferences(value, content, nextErrors);
|
|
10388
11548
|
lintListTemplateNullableDomCoercion(content, nextErrors);
|
|
10389
11549
|
lintListTemplateRuntimeStateConflicts(content, nextErrors);
|
|
10390
|
-
if (warnings)
|
|
10391
|
-
|
|
11550
|
+
if (warnings) {
|
|
11551
|
+
lintListTemplateRowRendererSideEffects(columns, warnings);
|
|
11552
|
+
lintListTemplateRowContext(columns, warnings);
|
|
11553
|
+
}
|
|
11554
|
+
validateListTemplateColumnWidths(columns, nextErrors, warnings);
|
|
10392
11555
|
validateListTemplateIcons(columns, nextErrors);
|
|
10393
11556
|
const operationColumn = columns.filter(isRecord6).find(isListTemplateOperationColumn);
|
|
10394
11557
|
if (!operationColumn) {
|
|
@@ -10416,6 +11579,14 @@ function validateListTemplateActionGate(value, errors, warnings) {
|
|
|
10416
11579
|
else warnings?.push(message);
|
|
10417
11580
|
}
|
|
10418
11581
|
});
|
|
11582
|
+
classified.forEach((item) => {
|
|
11583
|
+
const guards = [...item.inheritedGuards, ...listTemplateNodeGuards(item.node)];
|
|
11584
|
+
if (guards.some((guard) => hardCodedStepNameGuard(guard.text))) {
|
|
11585
|
+
warnings?.push(
|
|
11586
|
+
`list-template \u64CD\u4F5C\u6309\u94AE ${JSON.stringify(item.label.trim() || item.kind)} \u7684\u663E\u793A\u6761\u4EF6\u4F9D\u8D56 current_step_name \u7684\u5B57\u9762\u91CF\u6216\u5B58\u5728\u6027\u5224\u65AD\uFF1B\u73AF\u8282\u6539\u540D\u6216\u589E\u5220\u8282\u70B9\u540E\u8BE5\u6761\u4EF6\u4F1A\u9759\u9ED8\u5931\u6548\u3002\u8BF7\u6539\u7528 status\u3001\u662F\u5426\u5DF2\u5F00\u6807\u3001\u662F\u5426\u5DF2\u53D1\u51FA\u7B49\u8BED\u4E49\u5B57\u6BB5\u3002`
|
|
11587
|
+
);
|
|
11588
|
+
}
|
|
11589
|
+
});
|
|
10419
11590
|
}
|
|
10420
11591
|
if (!nextErrors.length) {
|
|
10421
11592
|
return;
|
|
@@ -10461,11 +11632,11 @@ function lintFlowDetailTemplateWork(work, errors, warnings = []) {
|
|
|
10461
11632
|
warnings.push(...analysis.warnings);
|
|
10462
11633
|
return analysis;
|
|
10463
11634
|
}
|
|
10464
|
-
function normalizePageTemplatePayload(domain, work, options = {}) {
|
|
11635
|
+
function normalizePageTemplatePayload(domain, work, options = {}, warnings = []) {
|
|
10465
11636
|
const definition = CONFIG_DOMAINS[domain];
|
|
10466
11637
|
validatePageTemplateName(work);
|
|
10467
11638
|
if (domain === "list-template") {
|
|
10468
|
-
validateListTemplateActionGate(work);
|
|
11639
|
+
validateListTemplateActionGate(work, void 0, warnings);
|
|
10469
11640
|
}
|
|
10470
11641
|
if (domain === "filter-template") {
|
|
10471
11642
|
const errors = [];
|
|
@@ -10476,16 +11647,16 @@ function normalizePageTemplatePayload(domain, work, options = {}) {
|
|
|
10476
11647
|
}
|
|
10477
11648
|
if (domain === "console-template") {
|
|
10478
11649
|
const errors = [];
|
|
10479
|
-
const
|
|
10480
|
-
lintConsoleTemplateWork(work, errors,
|
|
11650
|
+
const warnings2 = [];
|
|
11651
|
+
lintConsoleTemplateWork(work, errors, warnings2);
|
|
10481
11652
|
if (errors.length) {
|
|
10482
11653
|
throw new Error(`console-template lint failed: ${errors.join("; ")}`);
|
|
10483
11654
|
}
|
|
10484
11655
|
}
|
|
10485
11656
|
if (domain === "step-detail-template") {
|
|
10486
11657
|
const errors = [];
|
|
10487
|
-
const
|
|
10488
|
-
lintStepDetailTemplateWork(work, errors,
|
|
11658
|
+
const warnings2 = [];
|
|
11659
|
+
lintStepDetailTemplateWork(work, errors, warnings2);
|
|
10489
11660
|
if (errors.length) {
|
|
10490
11661
|
throw new Error(`step-detail-template lint failed: ${errors.join("; ")}`);
|
|
10491
11662
|
}
|
|
@@ -11978,6 +13149,7 @@ function validateFlowTemplateNonExemptHardGates(work) {
|
|
|
11978
13149
|
validateFlowTemplateUrgentReminder(work);
|
|
11979
13150
|
validateFlowTemplateRuntimeScripts(work);
|
|
11980
13151
|
validateFlowTemplateFeishuChatPlugin(work);
|
|
13152
|
+
validateFlowTemplateMessageCardHardGate(work);
|
|
11981
13153
|
}
|
|
11982
13154
|
function validateFlowTemplateHardGates(work) {
|
|
11983
13155
|
validateFlowTemplateNonExemptHardGates(work);
|
|
@@ -11998,6 +13170,7 @@ function collectFlowTemplateLintErrors(work) {
|
|
|
11998
13170
|
validateFlowTemplateUrgentReminder(work, errors);
|
|
11999
13171
|
validateFlowTemplateStandardConditionEditorRules(work, errors);
|
|
12000
13172
|
validateFlowTemplateCodeModeMessages(work, errors);
|
|
13173
|
+
validateFlowTemplateMessageCards(work, errors);
|
|
12001
13174
|
validateFlowTemplateRuntimeScripts(work, errors);
|
|
12002
13175
|
validateFlowTemplateFeishuChatPlugin(work, errors);
|
|
12003
13176
|
return errors;
|
|
@@ -15731,6 +16904,7 @@ async function createFlowTemplateFromWork(config, profile, workFile, confirm3, o
|
|
|
15731
16904
|
validateFlowTemplateUrgentReminder(work);
|
|
15732
16905
|
validateFlowTemplateStandardConditionEditorRules(work);
|
|
15733
16906
|
validateFlowTemplateCodeModeMessages(work);
|
|
16907
|
+
validateFlowTemplateMessageCardHardGate(work);
|
|
15734
16908
|
validateFlowTemplateRuntimeScripts(work);
|
|
15735
16909
|
validateFlowTemplateFeishuChatPlugin(work);
|
|
15736
16910
|
validateFlowTemplateFormDrivenCreateBaseline(work, void 0, { context: "flow-template create" });
|
|
@@ -17786,16 +18960,20 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
17786
18960
|
}
|
|
17787
18961
|
const unverified = Array.isArray(impactReport?.unverified_surfaces) ? impactReport.unverified_surfaces.filter((item) => typeof item === "string") : [];
|
|
17788
18962
|
const impactStatus = String(impactReport?.impact_status ?? "not_provided");
|
|
17789
|
-
const
|
|
18963
|
+
const presentationOnly = isPresentationOnlyListTemplateChange(boundary.changed_paths);
|
|
18964
|
+
const validationRequired = boundary.permission_related || !presentationOnly && ["review_recommended", "required_collateral_review"].includes(impactStatus) && (unverified.includes("runtime-script") || unverified.includes("e2e"));
|
|
17790
18965
|
listTemplateSafety = {
|
|
17791
18966
|
schema_version: 1,
|
|
17792
18967
|
permission_related: boundary.permission_related,
|
|
18968
|
+
presentation_only: presentationOnly,
|
|
17793
18969
|
changed_paths: boundary.changed_paths,
|
|
17794
18970
|
boundary: boundary.boundary,
|
|
17795
18971
|
impact_report: impactReport ?? null,
|
|
17796
18972
|
submit_gate: {
|
|
17797
18973
|
validation_required: validationRequired,
|
|
17798
|
-
|
|
18974
|
+
evidence_kind: validationRequired ? "permission_matrix" : presentationOnly ? "column_width_runtime_check" : null,
|
|
18975
|
+
unverified_surfaces: unverified,
|
|
18976
|
+
reason: validationRequired ? "permission or high-risk impact changes have unverified runtime-script/e2e surfaces" : presentationOnly ? "only presentation properties changed; a rendered column-width check is sufficient" : "no high-risk unverified surface detected"
|
|
17799
18977
|
}
|
|
17800
18978
|
};
|
|
17801
18979
|
}
|
|
@@ -17816,6 +18994,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
17816
18994
|
ignoredPreexistingLintErrors = evaluated.ignored;
|
|
17817
18995
|
}
|
|
17818
18996
|
let formTemplateWarnings = [];
|
|
18997
|
+
let listTemplateWarnings = [];
|
|
17819
18998
|
let consoleTemplateWarnings = [];
|
|
17820
18999
|
let formTemplateReferenceAudit;
|
|
17821
19000
|
let flowDetailTemplateWarnings = [];
|
|
@@ -17851,6 +19030,10 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
17851
19030
|
}
|
|
17852
19031
|
}
|
|
17853
19032
|
}
|
|
19033
|
+
if (domain === "list-template" && isRecord6(work)) {
|
|
19034
|
+
listTemplateWarnings = [];
|
|
19035
|
+
validateListTemplateActionGate(work, void 0, listTemplateWarnings);
|
|
19036
|
+
}
|
|
17854
19037
|
if (domain === "form-template" && isRecord6(work)) {
|
|
17855
19038
|
const errors = [];
|
|
17856
19039
|
formTemplateWarnings = [];
|
|
@@ -17944,6 +19127,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
17944
19127
|
if (listTemplateSafety) {
|
|
17945
19128
|
listTemplateSafety.payload_hash = hashJson(payload);
|
|
17946
19129
|
listTemplateSafety.raw_hash = raw === void 0 ? null : hashJson(raw);
|
|
19130
|
+
if (listTemplateWarnings.length) listTemplateSafety.warnings = listTemplateWarnings;
|
|
17947
19131
|
}
|
|
17948
19132
|
if (pageTemplateScopeManifest && isRecord6(raw)) {
|
|
17949
19133
|
pageTemplateScope = await buildPageTemplateScopeArtifact(pageTemplateScopeManifest, raw, work, payload);
|
|
@@ -17996,6 +19180,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
17996
19180
|
...datasetMapping ? { dataset_mapping: datasetMapping } : {},
|
|
17997
19181
|
...flowCategoryReferenceAudit ? { flow_category_reference: flowCategoryReferenceEvidence(flowCategoryReferenceAudit) } : {},
|
|
17998
19182
|
...formTemplateWarnings.length ? { form_template_warnings: formTemplateWarnings } : {},
|
|
19183
|
+
...listTemplateWarnings.length ? { list_template_warnings: listTemplateWarnings } : {},
|
|
17999
19184
|
...consoleTemplateWarnings.length ? {
|
|
18000
19185
|
console_template_warnings: consoleTemplateWarnings,
|
|
18001
19186
|
runtime_proof_required: true,
|
|
@@ -18051,6 +19236,7 @@ async function buildConfigSubmitPayload(domain, workFile, outFile, metaFile, opt
|
|
|
18051
19236
|
} : {},
|
|
18052
19237
|
...datasetFieldWarnings.length ? { warnings: datasetFieldWarnings } : {},
|
|
18053
19238
|
...formTemplateWarnings.length ? { warnings: formTemplateWarnings } : {},
|
|
19239
|
+
...listTemplateWarnings.length ? { warnings: listTemplateWarnings } : {},
|
|
18054
19240
|
...consoleTemplateWarnings.length ? {
|
|
18055
19241
|
warnings: consoleTemplateWarnings,
|
|
18056
19242
|
runtime_proof_required: true,
|
|
@@ -18305,6 +19491,7 @@ async function lintConfigWorkFile(file, options = {}) {
|
|
|
18305
19491
|
validateFlowTemplateUrgentReminder(flowWork, errors);
|
|
18306
19492
|
validateFlowTemplateStandardConditionEditorRules(flowWork, errors);
|
|
18307
19493
|
validateFlowTemplateCodeModeMessages(flowWork, errors, warnings);
|
|
19494
|
+
validateFlowTemplateMessageCards(flowWork, errors, warnings);
|
|
18308
19495
|
validateFlowTemplateRuntimeScripts(flowWork, errors);
|
|
18309
19496
|
validateFlowTemplateFeishuChatPlugin(flowWork, errors);
|
|
18310
19497
|
pluginLint = await runFlowTemplatePluginLint(flowWork, options.pluginLint);
|
|
@@ -18709,8 +19896,27 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
18709
19896
|
evidence_missing: true
|
|
18710
19897
|
};
|
|
18711
19898
|
} else {
|
|
19899
|
+
const changedPaths = Array.isArray(safety.changed_paths) ? safety.changed_paths : [];
|
|
19900
|
+
const unverifiedSurfaces = Array.isArray(gate.unverified_surfaces) ? gate.unverified_surfaces : [];
|
|
18712
19901
|
throw new Error(
|
|
18713
|
-
|
|
19902
|
+
`[list_template_submit_validation_required] This list-template needs a permission/high-risk validation report. Reason: ${String(gate.reason ?? "unspecified")}. Changed paths: ${changedPaths.length ? changedPaths.slice(0, 8).join(", ") : "<none recorded>"}. Unverified surfaces: ${unverifiedSurfaces.length ? unverifiedSurfaces.join(", ") : "<none>"}. Provide --validation-report, or explicitly use --override-reason with a specific audited reason.`
|
|
19903
|
+
);
|
|
19904
|
+
}
|
|
19905
|
+
} else if (safety.presentation_only === true) {
|
|
19906
|
+
if (options.validationReportFile) {
|
|
19907
|
+
listTemplateValidation = validateListTemplateColumnWidthEvidence(
|
|
19908
|
+
await readJsonFile(options.validationReportFile),
|
|
19909
|
+
{ templateId: id, profile: profile.name, payloadHash: hashJson(submit.payload) }
|
|
19910
|
+
);
|
|
19911
|
+
} else if (typeof options.overrideReason === "string" && options.overrideReason.trim().length >= 12) {
|
|
19912
|
+
listTemplateOverride = {
|
|
19913
|
+
used: true,
|
|
19914
|
+
reason: options.overrideReason.trim(),
|
|
19915
|
+
evidence_missing: true
|
|
19916
|
+
};
|
|
19917
|
+
} else {
|
|
19918
|
+
throw new Error(
|
|
19919
|
+
'[list_template_column_width_validation_required] Only presentation properties changed, so a permission matrix is not required. Provide --validation-report with a rendered column-width check (schema_version=1, result="pass", columns with truncated=false), or explicitly use --override-reason with a specific audited reason.'
|
|
18714
19920
|
);
|
|
18715
19921
|
}
|
|
18716
19922
|
}
|
|
@@ -18966,6 +20172,7 @@ async function submitConfigDomain(config, profile, domain, id, submitFile, confi
|
|
|
18966
20172
|
validateFlowTemplateUrgentReminder(gateView);
|
|
18967
20173
|
validateFlowTemplateStandardConditionEditorRules(gateView);
|
|
18968
20174
|
validateFlowTemplateCodeModeMessages(gateView);
|
|
20175
|
+
validateFlowTemplateMessageCardHardGate(gateView);
|
|
18969
20176
|
validateFlowTemplateRuntimeScripts(gateView);
|
|
18970
20177
|
validateFlowTemplateFeishuChatPlugin(gateView);
|
|
18971
20178
|
validateFlowTemplateProjectNameTemplate(gateView);
|
|
@@ -45094,6 +46301,21 @@ function hasExactConfirmEvidence(evidence) {
|
|
|
45094
46301
|
function rowsHaveExecutableTable(text5) {
|
|
45095
46302
|
return extractTaskRows(text5).length > 0;
|
|
45096
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
|
+
}
|
|
46311
|
+
function adjustmentTraceIds(cell) {
|
|
46312
|
+
return idTokens(cell).filter((token) => ADJUSTMENT_ID_TOKEN.test(token));
|
|
46313
|
+
}
|
|
46314
|
+
function nodeTraceIds(cell) {
|
|
46315
|
+
const ids = idTokens(cell).filter((token) => NODE_ID_TOKEN.test(token));
|
|
46316
|
+
if (cell.includes(NODE_TRACE_PHRASE)) ids.push(NODE_TRACE_PHRASE);
|
|
46317
|
+
return ids;
|
|
46318
|
+
}
|
|
45097
46319
|
function validateTaskbookTraceabilityGates(text5) {
|
|
45098
46320
|
const messages = [];
|
|
45099
46321
|
const rows2 = extractTaskRows(text5);
|
|
@@ -45105,13 +46327,13 @@ function validateTaskbookTraceabilityGates(text5) {
|
|
|
45105
46327
|
section: "\u8C03\u6574\u9879 \u2192 \u4EFB\u52A1\u8FFD\u6EAF\u8868",
|
|
45106
46328
|
idLabel: "\u8C03\u6574\u9879\u7F16\u53F7",
|
|
45107
46329
|
sourceLabel: "\u8C03\u6574\u6E05\u5355\u6765\u6E90",
|
|
45108
|
-
|
|
46330
|
+
extract: adjustmentTraceIds
|
|
45109
46331
|
},
|
|
45110
46332
|
{
|
|
45111
46333
|
section: "\u84DD\u56FE\u8282\u70B9 \u2192 \u4EFB\u52A1\u8FFD\u6EAF\u8868",
|
|
45112
46334
|
idLabel: "\u8282\u70B9\u7F16\u53F7",
|
|
45113
46335
|
sourceLabel: "\u8282\u70B9\u6E05\u5355\u6765\u6E90",
|
|
45114
|
-
|
|
46336
|
+
extract: nodeTraceIds
|
|
45115
46337
|
}
|
|
45116
46338
|
];
|
|
45117
46339
|
for (const spec of specs) {
|
|
@@ -45136,7 +46358,7 @@ function validateTaskbookTraceabilityGates(text5) {
|
|
|
45136
46358
|
}
|
|
45137
46359
|
const seenIDs = /* @__PURE__ */ new Set();
|
|
45138
46360
|
for (const [rowIndex, row] of table.rows.entries()) {
|
|
45139
|
-
const ids = (row[spec.idLabel] || "")
|
|
46361
|
+
const ids = spec.extract(row[spec.idLabel] || "");
|
|
45140
46362
|
if (!ids.length) {
|
|
45141
46363
|
if (BLUEPRINT_PLACEHOLDER_PATTERN.test((row[spec.idLabel] || "").trim())) continue;
|
|
45142
46364
|
messages.push(`\u300C${spec.section}\u300D\u7B2C ${rowIndex + 1} \u884C\u7F3A\u5C11\u6709\u6548${spec.idLabel}\u3002`);
|
|
@@ -45156,7 +46378,7 @@ function validateTaskbookTraceabilityGates(text5) {
|
|
|
45156
46378
|
}
|
|
45157
46379
|
const declaredBlock = section.match(/编号清单\s*[::]\s*([^\n]+)/)?.[1] || "";
|
|
45158
46380
|
if (!BLUEPRINT_PLACEHOLDER_PATTERN.test(declaredBlock.trim())) {
|
|
45159
|
-
const declaredIDs = (declaredBlock
|
|
46381
|
+
const declaredIDs = spec.extract(declaredBlock).map((id) => id.toUpperCase());
|
|
45160
46382
|
for (const declared of new Set(declaredIDs)) {
|
|
45161
46383
|
if (!seenIDs.has(declared)) {
|
|
45162
46384
|
messages.push(`\u300C${spec.section}\u300D\u58F0\u660E\u7684${spec.idLabel} ${declared} \u6CA1\u6709\u51FA\u73B0\u5728\u4EFB\u4F55\u4EFB\u52A1\u884C\u4E2D\u3002`);
|
|
@@ -46104,7 +47326,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
|
|
|
46104
47326
|
"## \u8C03\u6574\u9879 \u2192 \u4EFB\u52A1\u8FFD\u6EAF\u8868",
|
|
46105
47327
|
"",
|
|
46106
47328
|
"- \u8C03\u6574\u6E05\u5355\u6765\u6E90\uFF1A`<\u84DD\u56FE\u8C03\u6574\u6E05\u5355\u6587\u4EF6\u8DEF\u5F84>`\uFF0C\u7248\u672C\uFF1A\u5F85\u586B\u5199\u3002",
|
|
46107
|
-
"- \u7F16\u53F7\u6E05\u5355\uFF1A\u5F85\u586B\u5199\u3002\u9010\u4E2A\u5217\u51FA\u8C03\u6574\u6E05\u5355\u91CC\u7684\u6BCF\u4E2A\u7F16\u53F7\
|
|
47329
|
+
"- \u7F16\u53F7\u6E05\u5355\uFF1A\u5F85\u586B\u5199\u3002\u9010\u4E2A\u5217\u51FA\u8C03\u6574\u6E05\u5355\u91CC\u7684\u6BCF\u4E2A\u7F16\u53F7\uFF1B\u7F16\u53F7\u5F62\u5982\u5B57\u6BCD\u52A0\u5E8F\u53F7\uFF0C\u5177\u4F53\u65CF\u522B\u4EE5\u84DD\u56FE\u4E3A\u51C6\u3002",
|
|
46108
47330
|
"",
|
|
46109
47331
|
"| \u8C03\u6574\u9879\u7F16\u53F7 | \u8C03\u6574\u5185\u5BB9 | \u4EFB\u52A1 | \u9A8C\u6536\u8BC1\u636E |",
|
|
46110
47332
|
"|---|---|---|---|",
|
|
@@ -46113,7 +47335,7 @@ function taskbookTemplate(title = "BPMAX AI \u5B9E\u65BD\u7F16\u6392\u4EFB\u52A1
|
|
|
46113
47335
|
"## \u84DD\u56FE\u8282\u70B9 \u2192 \u4EFB\u52A1\u8FFD\u6EAF\u8868",
|
|
46114
47336
|
"",
|
|
46115
47337
|
"- \u8282\u70B9\u6E05\u5355\u6765\u6E90\uFF1A`<\u84DD\u56FE\u76EE\u6807\u6D41\u7A0B\u8282\u70B9\u8868\u6587\u4EF6\u8DEF\u5F84>`\uFF0C\u7248\u672C\uFF1A\u5F85\u586B\u5199\u3002",
|
|
46116
|
-
"- \u7F16\u53F7\u6E05\u5355\uFF1A\u5F85\u586B\u5199\u3002\u9010\u4E2A\u5217\u51FA\u76EE\u6807\u6D41\u7A0B\u8282\u70B9\u8868\u91CC\u7684\u6BCF\u4E2A\u7F16\u53F7\uFF0C\u5305\u62EC\u4E3B\u5E8F\u53F7\u8282\u70B9\
|
|
47338
|
+
"- \u7F16\u53F7\u6E05\u5355\uFF1A\u5F85\u586B\u5199\u3002\u9010\u4E2A\u5217\u51FA\u76EE\u6807\u6D41\u7A0B\u8282\u70B9\u8868\u91CC\u7684\u6BCF\u4E2A\u7F16\u53F7\uFF0C\u5305\u62EC\u4E3B\u5E8F\u53F7\u8282\u70B9\u3001\u5B57\u6BCD\u52A0\u5E8F\u53F7\u7684\u5E76\u884C\u5206\u652F\u8282\u70B9\uFF0C\u4EE5\u53CA\u56FA\u5B9A\u77ED\u8BED\u8282\u70B9\u3002",
|
|
46117
47339
|
"- \u8C03\u6574\u6E05\u5355\u4E0E\u76EE\u6807\u6D41\u7A0B\u8282\u70B9\u8868\u7C92\u5EA6\u4E0D\u540C\uFF1A\u53EA\u6309\u8C03\u6574\u9879\u6253\u52FE\u4F1A\u6F0F\u6389\u8282\u70B9\u8868\u91CC\u7684\u5E76\u884C\u5206\u652F\u548C\u652F\u6491\u8282\u70B9\uFF0C\u4E24\u8005\u5FC5\u987B\u5206\u522B\u8FFD\u6EAF\u3002",
|
|
46118
47340
|
"",
|
|
46119
47341
|
"| \u8282\u70B9\u7F16\u53F7 | \u8282\u70B9\u540D\u79F0 | \u4EFB\u52A1 | \u8868\u5355 | \u8D23\u4EFB\u89D2\u8272 | \u9A8C\u6536\u8BC1\u636E |",
|