- Fixed 3 remaining "return [...].join(...)" false-positive triggers in logic/message.js (n8n-mcp's static validator flags any inner return-array pattern as if it were the node's own output shape) by extracting each to a named variable before joining. All 3 occurrences of the pattern lived inside buildTopMessage/buildCoordinationDigest, which get fully inlined into both "Code - Montar Mensagem Curta" and "Code - Montar Digest Coordenacao" (whichever function is actually called, the whole module is inlined), so both nodes needed the same fix. - Deployed [DEV] Coordenador GLPI - Chamados Abertos v2 (Shadow) (id y6JFEnp7Z2IJEUe2) to devn8n.gtigrupo.com.br: 36 nodes, inactive, n8n_validate_workflow reports valid:true (0 errors, 1 minor deprecation warning on continueOnFail). - Ran n8n_autofix_workflow: 6 safe typeVersion upgrades applied and mirrored back into n8n/workflow.template.json so future rebuilds stay in sync. - Found and fixed a real safety issue: creating the workflow before the "MySQL GLPI - Coordenador" credential existed caused n8n to silently auto-bind the 3 MySQL nodes to the only other mySql-type credential in the instance (an unrelated Asaas billing credential). Cleared those credential bindings (both live and in the template) rather than leave them pointing at the wrong database. - Created the two Data Tables the pipeline needs: coordenador_glpi_memoria (17 columns) and coordenador_glpi_shadow_runs (6 columns). - Documented the pending schema introspection (glpi_tickettasks.state column name unverified, blocked on the MySQL credential) and an unrelated discovery (two other Data Tables, dev_glpi_v2_insights_memory and dev_glpi_v2_run_history, appeared on the DEV instance mid-session from a source other than this one) in docs/superpowers/notes/. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
const ACTION_LABELS = {
|
|
UNASSIGNED_ACTIONABLE: 'Atribuir técnico',
|
|
ACTIONABLE_NOW: 'Validar e executar',
|
|
WAITING_APPROVAL: 'Cobrar aprovação',
|
|
INSUFFICIENT_CONTEXT: 'Completar informação',
|
|
};
|
|
|
|
function shortActionLabel(aiClassification) {
|
|
if (aiClassification.is_fallback) return 'Revisar chamado';
|
|
const fromMap = ACTION_LABELS[aiClassification.classification];
|
|
if (fromMap) return fromMap;
|
|
const raw = String(aiClassification.next_action || 'Revisar chamado').trim();
|
|
return raw.length > 40 ? `${raw.slice(0, 37)}...` : raw;
|
|
}
|
|
|
|
function tituloCurto(texto) {
|
|
const limpo = String(texto || 'Sem titulo').replace(/\s+/g, ' ').trim();
|
|
return limpo.length > 60 ? `${limpo.slice(0, 57)}...` : limpo;
|
|
}
|
|
|
|
function signalLine(ticket) {
|
|
const parts = [];
|
|
parts.push(ticket.sem_tecnico ? 'SEM TÉCNICO' : ticket.tecnico_atribuido);
|
|
if (ticket.sla_vencido) parts.push('SLA vencido');
|
|
parts.push(`parado ${ticket.dias_sem_interacao}d`);
|
|
return parts.join(' • ');
|
|
}
|
|
|
|
function buildTopMessage(selected, dateStr, config) {
|
|
if (!selected.length) {
|
|
return `@time Coordenador GLPI - ${dateStr}\n\nNenhum chamado acionável encontrado hoje.`;
|
|
}
|
|
const header = `@time ${selected.length} chamados para atenção hoje — ${dateStr}`;
|
|
const blocks = selected.map((item, index) => {
|
|
const t = item.ticket;
|
|
const linhasDoBloco = [
|
|
`${index + 1}. #${t.id} • ${tituloCurto(t.titulo)}`,
|
|
signalLine(t),
|
|
`→ ${shortActionLabel(item.aiClassification)}`,
|
|
t.link_glpi,
|
|
];
|
|
return linhasDoBloco.join('\n');
|
|
});
|
|
const partesDaMensagem = [header, '', ...blocks];
|
|
return partesDaMensagem.join('\n\n');
|
|
}
|
|
|
|
function buildCoordinationDigest(changedBlocked, dateStr) {
|
|
if (!changedBlocked.length) return null;
|
|
const lines = changedBlocked.map((item) => `#${item.ticket.id} • ${(item.aiClassification && item.aiClassification.reason) || item.exclusionReason}`);
|
|
const partesDoDigest = [`Coordenação — bloqueios novos/alterados — ${dateStr}`, '', ...lines];
|
|
return partesDoDigest.join('\n');
|
|
}
|
|
|
|
module.exports = { shortActionLabel, tituloCurto, signalLine, buildTopMessage, buildCoordinationDigest };
|