n8n-nodes-seo-scanner 1.2.35 → 1.2.37
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/LICENSE +21 -0
- package/README.md +140 -82
- package/dist/SeoScanner.node.js +350 -1
- package/dist/SeoScanner.node.js.map +1 -1
- package/dist/nodes/SeoScanner/SeoScanner.node.js +350 -1
- package/dist/nodes/SeoScanner/seoScanner.svg +154 -6
- package/dist/nodes/SeoScanner/uopix-logo.svg +154 -0
- package/dist/nodes/SeoScanner/uopix-mark.svg +154 -0
- package/package.json +12 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OXSR
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,82 +1,140 @@
|
|
|
1
|
-
# n8n-nodes-seo-scanner
|
|
2
|
-
|
|
3
|
-
Nodo
|
|
4
|
-
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
##
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
1
|
+
# n8n-nodes-seo-scanner
|
|
2
|
+
|
|
3
|
+
Nodo comunitario de n8n para auditorias SEO tecnicas con marca UOPIX. Analiza una URL, puede rastrear paginas internas del mismo dominio y devuelve un JSON estructurado con problemas, avisos, checks correctos, recomendaciones y un informe HTML tipo dashboard.
|
|
4
|
+
|
|
5
|
+
## Que hace
|
|
6
|
+
|
|
7
|
+
- Audita una pagina web a partir de una URL absoluta.
|
|
8
|
+
- Puede rastrear URLs internas descubiertas en enlaces y sitemaps.
|
|
9
|
+
- Permite forzar paginas obligatorias, excluir patrones y silenciar fallos concretos.
|
|
10
|
+
- Detecta problemas SEO tecnicos, accesibilidad basica, enlaces rotos, headers de seguridad y metadatos sociales.
|
|
11
|
+
- Puede renderizar JavaScript con Puppeteer para webs React, Vue, Angular u otras SPAs.
|
|
12
|
+
- Genera un informe HTML listo para responder desde un Webhook de n8n.
|
|
13
|
+
- Puede enviar el resultado final a una API externa mediante callback.
|
|
14
|
+
- Soporta salida en ingles o espanol para los textos generados y el informe HTML.
|
|
15
|
+
|
|
16
|
+
## Comprobaciones principales
|
|
17
|
+
|
|
18
|
+
- Estado HTTP, HTTPS y redirecciones.
|
|
19
|
+
- Title, meta description, viewport, robots y canonical.
|
|
20
|
+
- H1, estructura de headings y conteo aproximado de palabras.
|
|
21
|
+
- Imagenes sin `alt`, enlaces internos y externos, y enlaces rotos.
|
|
22
|
+
- Open Graph, JSON-LD, favicon, charset y atributo `lang`.
|
|
23
|
+
- Hreflang, idioma detectado y coherencia basica multidioma.
|
|
24
|
+
- Robots.txt, sitemap, DNS, CDN, SSL y geolocalizacion tecnica.
|
|
25
|
+
- Headers de seguridad y buenas practicas web.
|
|
26
|
+
- CMS, plugins y tecnologias detectadas cuando hay senales suficientes.
|
|
27
|
+
- Score 0-100, resumen por severidad y recomendaciones accionables.
|
|
28
|
+
|
|
29
|
+
## Instalacion desde GitHub
|
|
30
|
+
|
|
31
|
+
En una instalacion local de n8n:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
cd ~/.n8n/nodes
|
|
35
|
+
npm install github:OXSR/n8n-nodes-seo-scanner
|
|
36
|
+
n8n start
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
En Windows PowerShell:
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
New-Item -ItemType Directory -Force "$env:USERPROFILE\.n8n\nodes"
|
|
43
|
+
Set-Location "$env:USERPROFILE\.n8n\nodes"
|
|
44
|
+
npm install github:OXSR/n8n-nodes-seo-scanner
|
|
45
|
+
n8n start
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Tambien puedes cargarlo como extension local durante el desarrollo:
|
|
49
|
+
|
|
50
|
+
```powershell
|
|
51
|
+
cd C:\Users\oriol\.n8n\custom\n8n-nodes-seo-scanner
|
|
52
|
+
npm install
|
|
53
|
+
npm run build
|
|
54
|
+
$env:N8N_CUSTOM_EXTENSIONS="C:\Users\oriol\.n8n\custom\n8n-nodes-seo-scanner"
|
|
55
|
+
n8n start
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Despues de instalar o actualizar el nodo, reinicia n8n y recarga el editor.
|
|
59
|
+
|
|
60
|
+
## Uso en n8n
|
|
61
|
+
|
|
62
|
+
1. Anade el nodo **SEO UOPIX** al workflow.
|
|
63
|
+
2. Introduce la **URL de la pagina** que quieres analizar.
|
|
64
|
+
3. Activa **Escanear todo el sitio** si quieres analizar tambien paginas internas.
|
|
65
|
+
4. Ajusta el limite de paginas, timeout, user-agent, idioma de salida y opciones de detalle.
|
|
66
|
+
5. Ejecuta el nodo y usa la salida JSON en tus siguientes pasos.
|
|
67
|
+
|
|
68
|
+
Campos utiles:
|
|
69
|
+
|
|
70
|
+
- **URL de la pagina**: URL absoluta, por ejemplo `https://example.com/pagina`.
|
|
71
|
+
- **Escanear todo el sitio**: rastrea URLs internas del dominio.
|
|
72
|
+
- **Limite de paginas a escanear**: controla el tamano del crawl.
|
|
73
|
+
- **Paginas obligatorias a escanear**: URLs del mismo dominio que siempre se incluyen.
|
|
74
|
+
- **Excluir URLs que contengan**: patrones para no rastrear rutas concretas.
|
|
75
|
+
- **Ignorar fallos / paginas**: filtra mensajes o URLs conocidas.
|
|
76
|
+
- **Usar JavaScript Rendering**: usa Puppeteer para contenido renderizado por cliente.
|
|
77
|
+
- **Output Language**: `English` o `Spanish`.
|
|
78
|
+
- **Generar informe HTML**: agrega `html` y `reportHtml` a la salida.
|
|
79
|
+
- **Enviar resultados a API externa**: hace POST a una URL de callback al terminar.
|
|
80
|
+
|
|
81
|
+
## Salida
|
|
82
|
+
|
|
83
|
+
La salida principal incluye:
|
|
84
|
+
|
|
85
|
+
- `mainPage`: analisis completo de la URL principal.
|
|
86
|
+
- `internalPages`: analisis de paginas internas cuando el crawl esta activo.
|
|
87
|
+
- `internalScanSummary`: resumen del rastreo interno.
|
|
88
|
+
- `severitySummary`: conteos por severidad.
|
|
89
|
+
- `issues`, `warnings`, `passed` y `recommendations`.
|
|
90
|
+
- `score`: puntuacion SEO de 0 a 100.
|
|
91
|
+
- `html` y `reportHtml`: informe HTML cuando esta activado.
|
|
92
|
+
|
|
93
|
+
El export JSON no se traduce por diseno: mantiene nombres de campo estables para automatizaciones.
|
|
94
|
+
|
|
95
|
+
## Informe HTML
|
|
96
|
+
|
|
97
|
+
Para servir el informe desde n8n:
|
|
98
|
+
|
|
99
|
+
1. Crea un workflow con **Webhook** -> **SEO UOPIX** -> **Respond to Webhook**.
|
|
100
|
+
2. En **SEO UOPIX**, activa **Generar informe HTML**.
|
|
101
|
+
3. En **Respond to Webhook**, usa:
|
|
102
|
+
- **Respond With**: `Text`
|
|
103
|
+
- **Response Body**: `{{ $json.html }}`
|
|
104
|
+
4. Activa el workflow y abre la URL del webhook.
|
|
105
|
+
|
|
106
|
+
Si tu version de n8n muestra el HTML dentro de un iframe con sandbox y ves una pantalla en blanco, puedes usar `N8N_INSECURE_DISABLE_WEBHOOK_IFRAME_SANDBOX=true` en entornos self-hosted controlados.
|
|
107
|
+
|
|
108
|
+
## Credenciales UOPIX
|
|
109
|
+
|
|
110
|
+
El nodo incluye credenciales **SEO UOPIX API**:
|
|
111
|
+
|
|
112
|
+
- `API Key`: clave personal generada en UOPIX.
|
|
113
|
+
- `App Base URL`: URL base que valida la API key, por defecto `https://uopix.com`.
|
|
114
|
+
|
|
115
|
+
Estas credenciales se usan cuando el flujo necesita validar o consumir usos de API asociados a UOPIX.
|
|
116
|
+
|
|
117
|
+
## Desarrollo
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
npm install
|
|
121
|
+
npm run build
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Archivos principales:
|
|
125
|
+
|
|
126
|
+
- `nodes/SeoScanner/SeoScanner.node.ts`: definicion del nodo y ejecucion.
|
|
127
|
+
- `nodes/SeoScanner/analyzeUtils.ts`: analisis SEO de pagina.
|
|
128
|
+
- `nodes/SeoScanner/reportUtils.ts`: salida e informe HTML.
|
|
129
|
+
- `nodes/SeoScanner/uopix-mark.svg`: icono del nodo.
|
|
130
|
+
- `dist/nodes/SeoScanner`: build que carga n8n.
|
|
131
|
+
|
|
132
|
+
Antes de publicar cambios:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npm run build
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Licencia
|
|
139
|
+
|
|
140
|
+
MIT
|
package/dist/SeoScanner.node.js
CHANGED
|
@@ -50,6 +50,7 @@ const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
|
|
|
50
50
|
const GOOGLEBOT_UA = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
|
|
51
51
|
const DEFAULT_APP_BASE_URL = 'https://uopix.com';
|
|
52
52
|
const MAX_VISUAL_PREVIEW_PAGES = 12;
|
|
53
|
+
const NODE_ENGINE_VERSION = 'seo-uopix-node/1.2.36';
|
|
53
54
|
const NON_PAGE_EXTENSIONS_REGEX = /\.(?:jpg|jpeg|png|gif|webp|svg|pdf|doc|docx|xls|xlsx|ppt|pptx|zip|rar|7z|mp3|mp4|avi|mov|webm|css|js|json|xml|woff|woff2|ttf|eot|ico)(?:$|\?)/i;
|
|
54
55
|
function asDataObject(value) {
|
|
55
56
|
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
@@ -57,6 +58,127 @@ function asDataObject(value) {
|
|
|
57
58
|
function readString(value) {
|
|
58
59
|
return typeof value === 'string' ? value.trim() : '';
|
|
59
60
|
}
|
|
61
|
+
function hasOwnKey(record, key) {
|
|
62
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
63
|
+
}
|
|
64
|
+
function valueShape(value) {
|
|
65
|
+
if (value === null)
|
|
66
|
+
return 'null';
|
|
67
|
+
if (Array.isArray(value))
|
|
68
|
+
return `array(${value.length})`;
|
|
69
|
+
if (typeof value === 'string')
|
|
70
|
+
return `string(${value.length})`;
|
|
71
|
+
if (typeof value === 'object')
|
|
72
|
+
return `object(${Object.keys(value).length})`;
|
|
73
|
+
return typeof value;
|
|
74
|
+
}
|
|
75
|
+
function sampleObjectKeys(value, limit = 16) {
|
|
76
|
+
return Object.keys(asDataObject(value)).slice(0, limit);
|
|
77
|
+
}
|
|
78
|
+
function parseMaybeJson(value) {
|
|
79
|
+
if (typeof value !== 'string')
|
|
80
|
+
return value;
|
|
81
|
+
const trimmed = value.trim();
|
|
82
|
+
if (!trimmed || (!trimmed.startsWith('{') && !trimmed.startsWith('[')))
|
|
83
|
+
return value;
|
|
84
|
+
try {
|
|
85
|
+
return JSON.parse(trimmed);
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function appendFootprintingCandidates(value, output, seen = new Set(), depth = 0) {
|
|
92
|
+
const parsed = parseMaybeJson(value);
|
|
93
|
+
if (!parsed || seen.has(parsed) || depth > 7)
|
|
94
|
+
return;
|
|
95
|
+
seen.add(parsed);
|
|
96
|
+
if (Array.isArray(parsed)) {
|
|
97
|
+
parsed.slice(0, 20).forEach((item) => appendFootprintingCandidates(item, output, seen, depth + 1));
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const record = asDataObject(parsed);
|
|
101
|
+
if (Object.keys(record).length === 0)
|
|
102
|
+
return;
|
|
103
|
+
output.push(record);
|
|
104
|
+
for (const key of [
|
|
105
|
+
'json',
|
|
106
|
+
'body',
|
|
107
|
+
'data',
|
|
108
|
+
'payload',
|
|
109
|
+
'response',
|
|
110
|
+
'output',
|
|
111
|
+
'item',
|
|
112
|
+
'items',
|
|
113
|
+
'parsed',
|
|
114
|
+
'result',
|
|
115
|
+
'results',
|
|
116
|
+
'scan',
|
|
117
|
+
'scanResult',
|
|
118
|
+
'rawWhatWeb',
|
|
119
|
+
'whatWeb',
|
|
120
|
+
'whatweb',
|
|
121
|
+
'whatWebScan',
|
|
122
|
+
'whatwebScan',
|
|
123
|
+
'whatWebResult',
|
|
124
|
+
'whatwebResult',
|
|
125
|
+
'whatWebResults',
|
|
126
|
+
'whatwebResults',
|
|
127
|
+
'webSummary',
|
|
128
|
+
'webSummaries',
|
|
129
|
+
]) {
|
|
130
|
+
if (hasOwnKey(record, key))
|
|
131
|
+
appendFootprintingCandidates(record[key], output, seen, depth + 1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function looksLikeFootprintingRecord(record) {
|
|
135
|
+
return [
|
|
136
|
+
'webSummary',
|
|
137
|
+
'webSummaries',
|
|
138
|
+
'rawWhatWeb',
|
|
139
|
+
'whatWeb',
|
|
140
|
+
'whatweb',
|
|
141
|
+
'whatWebScan',
|
|
142
|
+
'whatwebScan',
|
|
143
|
+
'whatWebResult',
|
|
144
|
+
'whatwebResult',
|
|
145
|
+
'whatWebResults',
|
|
146
|
+
'whatwebResults',
|
|
147
|
+
'nodeBuild',
|
|
148
|
+
'parsed',
|
|
149
|
+
'technologies',
|
|
150
|
+
'fingerprintRisk',
|
|
151
|
+
'cms',
|
|
152
|
+
'securityHeaders',
|
|
153
|
+
'exposedHeaders',
|
|
154
|
+
'analyticsAndTracking',
|
|
155
|
+
'wordpress',
|
|
156
|
+
'wordpressPlugins',
|
|
157
|
+
'prestashop',
|
|
158
|
+
'prestashopModules',
|
|
159
|
+
'plugins',
|
|
160
|
+
'raw',
|
|
161
|
+
].some((key) => hasOwnKey(record, key));
|
|
162
|
+
}
|
|
163
|
+
function collectFootprintingPayloads(inputItems) {
|
|
164
|
+
const candidates = [];
|
|
165
|
+
for (const item of inputItems)
|
|
166
|
+
appendFootprintingCandidates(item.json, candidates);
|
|
167
|
+
const seen = new Set();
|
|
168
|
+
const results = [];
|
|
169
|
+
for (const candidate of candidates) {
|
|
170
|
+
if (!looksLikeFootprintingRecord(candidate))
|
|
171
|
+
continue;
|
|
172
|
+
const signature = JSON.stringify(sampleObjectKeys(candidate, 24));
|
|
173
|
+
if (seen.has(signature))
|
|
174
|
+
continue;
|
|
175
|
+
seen.add(signature);
|
|
176
|
+
results.push(candidate);
|
|
177
|
+
if (results.length >= 5)
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
return results;
|
|
181
|
+
}
|
|
60
182
|
function readBoolean(value) {
|
|
61
183
|
if (typeof value === 'boolean')
|
|
62
184
|
return value;
|
|
@@ -303,6 +425,152 @@ function buildErrorOutput(params) {
|
|
|
303
425
|
json.licenseValid = params.licenseValid;
|
|
304
426
|
return { json, pairedItem: { item: 0 } };
|
|
305
427
|
}
|
|
428
|
+
const PERSIST_TEXT_LIMIT = 320;
|
|
429
|
+
const PERSIST_PAGE_SCALAR_KEYS = [
|
|
430
|
+
'url',
|
|
431
|
+
'finalUrl',
|
|
432
|
+
'title',
|
|
433
|
+
'metaDescription',
|
|
434
|
+
'statusCode',
|
|
435
|
+
'responseTimeMs',
|
|
436
|
+
'timeToFirstByteMs',
|
|
437
|
+
'htmlSizeBytes',
|
|
438
|
+
'wordCount',
|
|
439
|
+
'score',
|
|
440
|
+
'https',
|
|
441
|
+
'htmlLang',
|
|
442
|
+
'canonical',
|
|
443
|
+
'canonicalOk',
|
|
444
|
+
'metaDescriptionOk',
|
|
445
|
+
'h1Count',
|
|
446
|
+
'imagesTotal',
|
|
447
|
+
'imagesWithoutAlt',
|
|
448
|
+
'linksInternal',
|
|
449
|
+
'linksExternal',
|
|
450
|
+
'robotsTxtFetched',
|
|
451
|
+
'robotsTxtBlocked',
|
|
452
|
+
'sitemapInSitemap',
|
|
453
|
+
'sitemapStatus',
|
|
454
|
+
'sitemapSource',
|
|
455
|
+
'sitemapStatusMessage',
|
|
456
|
+
];
|
|
457
|
+
const PERSIST_GEO_ISSUE_EXTRA_KEYS = ['plainDetails', 'why', 'where', 'technicalDetails', 'evidence'];
|
|
458
|
+
function isPersistScalar(value) {
|
|
459
|
+
return value === null
|
|
460
|
+
|| typeof value === 'string'
|
|
461
|
+
|| typeof value === 'number'
|
|
462
|
+
|| typeof value === 'boolean';
|
|
463
|
+
}
|
|
464
|
+
function persistText(value, limit = PERSIST_TEXT_LIMIT) {
|
|
465
|
+
const text = readString(value);
|
|
466
|
+
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
467
|
+
}
|
|
468
|
+
function persistScalarRecord(value) {
|
|
469
|
+
const record = asDataObject(value);
|
|
470
|
+
const output = {};
|
|
471
|
+
for (const [key, fieldValue] of Object.entries(record)) {
|
|
472
|
+
if (isPersistScalar(fieldValue))
|
|
473
|
+
output[key] = fieldValue;
|
|
474
|
+
}
|
|
475
|
+
return output;
|
|
476
|
+
}
|
|
477
|
+
function persistIssueList(value, extraKeys = []) {
|
|
478
|
+
if (!Array.isArray(value))
|
|
479
|
+
return [];
|
|
480
|
+
const issues = [];
|
|
481
|
+
for (const raw of value) {
|
|
482
|
+
const item = asDataObject(raw);
|
|
483
|
+
const message = persistText(item.message);
|
|
484
|
+
if (!message)
|
|
485
|
+
continue;
|
|
486
|
+
const issue = { message };
|
|
487
|
+
const recommendation = persistText(item.recommendation);
|
|
488
|
+
if (recommendation)
|
|
489
|
+
issue.recommendation = recommendation;
|
|
490
|
+
for (const key of extraKeys) {
|
|
491
|
+
const text = persistText(item[key]);
|
|
492
|
+
if (text)
|
|
493
|
+
issue[key] = text;
|
|
494
|
+
}
|
|
495
|
+
issues.push(issue);
|
|
496
|
+
}
|
|
497
|
+
return issues;
|
|
498
|
+
}
|
|
499
|
+
function persistProblems(value, extraKeys = []) {
|
|
500
|
+
const problems = asDataObject(value);
|
|
501
|
+
return {
|
|
502
|
+
critical: persistIssueList(problems.critical, extraKeys),
|
|
503
|
+
important: persistIssueList(problems.important, extraKeys),
|
|
504
|
+
warning: persistIssueList(problems.warning, extraKeys),
|
|
505
|
+
info: persistIssueList(problems.info, extraKeys),
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
function persistPassed(value) {
|
|
509
|
+
if (!Array.isArray(value))
|
|
510
|
+
return [];
|
|
511
|
+
return value
|
|
512
|
+
.map((item) => persistText(item, 160))
|
|
513
|
+
.filter((item) => item.length > 0);
|
|
514
|
+
}
|
|
515
|
+
function persistPage(value) {
|
|
516
|
+
const page = asDataObject(value);
|
|
517
|
+
if (Object.keys(page).length === 0)
|
|
518
|
+
return null;
|
|
519
|
+
const output = {};
|
|
520
|
+
for (const key of PERSIST_PAGE_SCALAR_KEYS) {
|
|
521
|
+
if (isPersistScalar(page[key]) && page[key] !== undefined)
|
|
522
|
+
output[key] = page[key];
|
|
523
|
+
}
|
|
524
|
+
output.problemsBySeverity = persistProblems(page.problemsBySeverity);
|
|
525
|
+
output.passed = persistPassed(page.passed);
|
|
526
|
+
output.severitySummary = persistScalarRecord(page.severitySummary);
|
|
527
|
+
return output;
|
|
528
|
+
}
|
|
529
|
+
function buildPersistSnapshotPayload(output) {
|
|
530
|
+
const payload = {};
|
|
531
|
+
const mainPage = persistPage(output.mainPage);
|
|
532
|
+
if (mainPage)
|
|
533
|
+
payload.mainPage = mainPage;
|
|
534
|
+
const internalPages = (Array.isArray(output.internalPages) ? output.internalPages : [])
|
|
535
|
+
.map(persistPage)
|
|
536
|
+
.filter((page) => page !== null);
|
|
537
|
+
if (internalPages.length > 0)
|
|
538
|
+
payload.internalPages = internalPages;
|
|
539
|
+
payload.summary = persistScalarRecord(output.summary);
|
|
540
|
+
if (typeof output.scannedUrls === 'number')
|
|
541
|
+
payload.scannedUrls = output.scannedUrls;
|
|
542
|
+
const geoSource = asDataObject(output.geo);
|
|
543
|
+
if (Object.keys(geoSource).length > 0) {
|
|
544
|
+
const geo = persistScalarRecord(geoSource);
|
|
545
|
+
if (geoSource.summary)
|
|
546
|
+
geo.summary = persistScalarRecord(geoSource.summary);
|
|
547
|
+
if (geoSource.problemsBySeverity)
|
|
548
|
+
geo.problemsBySeverity = persistProblems(geoSource.problemsBySeverity, PERSIST_GEO_ISSUE_EXTRA_KEYS);
|
|
549
|
+
if (geoSource.passed)
|
|
550
|
+
geo.passed = persistPassed(geoSource.passed);
|
|
551
|
+
const geoPages = (Array.isArray(geoSource.pages) ? geoSource.pages : [])
|
|
552
|
+
.map((rawPage) => {
|
|
553
|
+
const record = asDataObject(rawPage);
|
|
554
|
+
if (Object.keys(record).length === 0)
|
|
555
|
+
return null;
|
|
556
|
+
const geoPage = persistScalarRecord(record);
|
|
557
|
+
geoPage.problemsBySeverity = persistProblems(record.problemsBySeverity, PERSIST_GEO_ISSUE_EXTRA_KEYS);
|
|
558
|
+
geoPage.passed = persistPassed(record.passed);
|
|
559
|
+
return geoPage;
|
|
560
|
+
})
|
|
561
|
+
.filter((page) => page !== null);
|
|
562
|
+
if (geoPages.length > 0)
|
|
563
|
+
geo.pages = geoPages;
|
|
564
|
+
payload.geo = geo;
|
|
565
|
+
}
|
|
566
|
+
const apiUsage = persistScalarRecord(output.apiUsage);
|
|
567
|
+
if (Object.keys(apiUsage).length > 0)
|
|
568
|
+
payload.apiUsage = apiUsage;
|
|
569
|
+
const scanLimit = persistScalarRecord(output.scanLimit);
|
|
570
|
+
if (Object.keys(scanLimit).length > 0)
|
|
571
|
+
payload.scanLimit = scanLimit;
|
|
572
|
+
return payload;
|
|
573
|
+
}
|
|
306
574
|
function getIncomingWebhookPayload(input) {
|
|
307
575
|
const root = asDataObject(input);
|
|
308
576
|
const body = asDataObject(root.body);
|
|
@@ -336,6 +604,7 @@ function getIncomingWebhookPayload(input) {
|
|
|
336
604
|
apiInternalPageLimitLabel: readString(source.apiInternalPageLimitLabel),
|
|
337
605
|
requestedInternalPageLimit: readNumber(source.requestedInternalPageLimit),
|
|
338
606
|
apiCreditsRemaining: readNullableNumber(source.apiCreditsRemaining),
|
|
607
|
+
persist: readBoolean(source.persist),
|
|
339
608
|
outputLanguage: readString(source.outputLanguage) || readString(source.language) || readString(source.lang),
|
|
340
609
|
};
|
|
341
610
|
}
|
|
@@ -344,7 +613,7 @@ class SeoScanner {
|
|
|
344
613
|
this.description = {
|
|
345
614
|
displayName: 'SEO UOPIX',
|
|
346
615
|
name: 'seoScanner',
|
|
347
|
-
icon: 'file:
|
|
616
|
+
icon: 'file:uopix-mark.svg',
|
|
348
617
|
group: ['transform'],
|
|
349
618
|
version: 1,
|
|
350
619
|
description: 'Escaneo SEO técnico completo de una página web. Opción de escanear también enlaces internos.',
|
|
@@ -485,6 +754,13 @@ class SeoScanner {
|
|
|
485
754
|
default: false,
|
|
486
755
|
description: 'Genera un informe HTML (dashboard) con los fallos y recomendaciones. Salida: json.html y json.reportHtml. Para verlo en el navegador: conecta a Respond to Webhook (Respond With = Text, Response Body = {{ $json.html }}) y abre la URL del webhook.',
|
|
487
756
|
},
|
|
757
|
+
{
|
|
758
|
+
displayName: 'Guardar en dashboard UOPIX',
|
|
759
|
+
name: 'persistToDashboard',
|
|
760
|
+
type: 'boolean',
|
|
761
|
+
default: false,
|
|
762
|
+
description: 'Si está activado (persist), guarda un snapshot ligero del escaneo en tu dashboard de UOPIX: aparece en el historial, tendencias y comparativas con badge "API". No consume créditos adicionales y nunca almacena el informe HTML. También se puede activar enviando persist=true en el payload de entrada.',
|
|
763
|
+
},
|
|
488
764
|
{
|
|
489
765
|
displayName: 'Usar JavaScript Rendering',
|
|
490
766
|
name: 'useJsRendering',
|
|
@@ -596,8 +872,17 @@ class SeoScanner {
|
|
|
596
872
|
};
|
|
597
873
|
}
|
|
598
874
|
async execute() {
|
|
875
|
+
const executionStartedAt = Date.now();
|
|
599
876
|
const inputItems = this.getInputData();
|
|
600
877
|
const incoming = getIncomingWebhookPayload(inputItems?.[0]?.json);
|
|
878
|
+
const footprintingPayloads = collectFootprintingPayloads(inputItems);
|
|
879
|
+
if (footprintingPayloads.length > 0) {
|
|
880
|
+
console.log('[seo-scanner] footprinting input candidates detected', {
|
|
881
|
+
count: footprintingPayloads.length,
|
|
882
|
+
shapes: footprintingPayloads.map((payload) => valueShape(payload)),
|
|
883
|
+
keySamples: footprintingPayloads.map((payload) => sampleObjectKeys(payload)),
|
|
884
|
+
});
|
|
885
|
+
}
|
|
601
886
|
let credentials = {};
|
|
602
887
|
try {
|
|
603
888
|
credentials = await this.getCredentials('seoScannerApi');
|
|
@@ -1497,6 +1782,10 @@ class SeoScanner {
|
|
|
1497
1782
|
output.reportHtml = htmlReportStr;
|
|
1498
1783
|
output.html = htmlReportStr;
|
|
1499
1784
|
}
|
|
1785
|
+
if (footprintingPayloads.length > 0) {
|
|
1786
|
+
output.whatwebResult = footprintingPayloads[0];
|
|
1787
|
+
output.whatwebResults = footprintingPayloads;
|
|
1788
|
+
}
|
|
1500
1789
|
const sendToExternalApi = (this.getNodeParameter('sendToExternalApi', 0) ?? false) || hasIncomingCallback;
|
|
1501
1790
|
if (sendToExternalApi) {
|
|
1502
1791
|
let callbackUrl = '';
|
|
@@ -1522,6 +1811,13 @@ class SeoScanner {
|
|
|
1522
1811
|
apiTokenExt = incoming.apiToken;
|
|
1523
1812
|
if (callbackUrl && reportId) {
|
|
1524
1813
|
try {
|
|
1814
|
+
if (footprintingPayloads.length > 0) {
|
|
1815
|
+
console.log('[seo-scanner] attaching footprinting payloads to external callback', {
|
|
1816
|
+
reportId,
|
|
1817
|
+
count: footprintingPayloads.length,
|
|
1818
|
+
keySamples: footprintingPayloads.map((payload) => sampleObjectKeys(payload)),
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1525
1821
|
const callbackBody = {
|
|
1526
1822
|
reportId,
|
|
1527
1823
|
data: output,
|
|
@@ -1543,16 +1839,69 @@ class SeoScanner {
|
|
|
1543
1839
|
const responseText = await callbackResponse.text().catch(() => '');
|
|
1544
1840
|
throw new Error(`La API externa devolvió HTTP ${callbackResponse.status}${responseText ? `: ${responseText.slice(0, 500)}` : ''}`);
|
|
1545
1841
|
}
|
|
1842
|
+
console.log('[seo-scanner] external callback sent', {
|
|
1843
|
+
reportId,
|
|
1844
|
+
status: callbackResponse.status,
|
|
1845
|
+
hasFootprintingPayloads: footprintingPayloads.length > 0,
|
|
1846
|
+
});
|
|
1546
1847
|
output.externalApiSent = true;
|
|
1547
1848
|
output.externalApiUrl = callbackUrl;
|
|
1548
1849
|
output.externalApiKeyUsed = Boolean(apiTokenExt);
|
|
1549
1850
|
}
|
|
1550
1851
|
catch (callbackErr) {
|
|
1852
|
+
console.warn('[seo-scanner] external callback failed', {
|
|
1853
|
+
reportId,
|
|
1854
|
+
hasFootprintingPayloads: footprintingPayloads.length > 0,
|
|
1855
|
+
error: callbackErr instanceof Error ? callbackErr.message : String(callbackErr),
|
|
1856
|
+
});
|
|
1551
1857
|
output.externalApiSent = false;
|
|
1552
1858
|
output.externalApiError = callbackErr instanceof Error ? callbackErr.message : String(callbackErr);
|
|
1553
1859
|
}
|
|
1554
1860
|
}
|
|
1555
1861
|
}
|
|
1862
|
+
let persistToDashboard = false;
|
|
1863
|
+
try {
|
|
1864
|
+
persistToDashboard = (this.getNodeParameter('persistToDashboard', 0) ?? false);
|
|
1865
|
+
}
|
|
1866
|
+
catch { }
|
|
1867
|
+
if (incoming.persist !== undefined)
|
|
1868
|
+
persistToDashboard = incoming.persist;
|
|
1869
|
+
if (persistToDashboard && !apiToken && !hasIncomingCallback) {
|
|
1870
|
+
try {
|
|
1871
|
+
const persistResponse = await fetch(`${appBaseUrl.replace(/\/+$/, '')}/api/n8n/persist-scan`, {
|
|
1872
|
+
method: 'POST',
|
|
1873
|
+
headers: {
|
|
1874
|
+
'Accept': 'application/json',
|
|
1875
|
+
'Content-Type': 'application/json',
|
|
1876
|
+
'X-API-Key': apiKey,
|
|
1877
|
+
},
|
|
1878
|
+
body: JSON.stringify({
|
|
1879
|
+
url: baseUrl,
|
|
1880
|
+
data: buildPersistSnapshotPayload(output),
|
|
1881
|
+
scannedUrls: output.scannedUrls,
|
|
1882
|
+
scanDurationMs: Date.now() - executionStartedAt,
|
|
1883
|
+
engineVersion: NODE_ENGINE_VERSION,
|
|
1884
|
+
}),
|
|
1885
|
+
});
|
|
1886
|
+
const persistBody = asDataObject(await persistResponse.json().catch(() => ({})));
|
|
1887
|
+
if (!persistResponse.ok || persistBody.ok !== true) {
|
|
1888
|
+
throw new Error(readString(persistBody.error) || `La app devolvió HTTP ${persistResponse.status}`);
|
|
1889
|
+
}
|
|
1890
|
+
output.persist = {
|
|
1891
|
+
saved: true,
|
|
1892
|
+
snapshotId: readString(persistBody.snapshotId),
|
|
1893
|
+
reportUrl: readString(persistBody.reportUrl),
|
|
1894
|
+
};
|
|
1895
|
+
console.log('[seo-scanner] persist snapshot saved', {
|
|
1896
|
+
snapshotId: readString(persistBody.snapshotId),
|
|
1897
|
+
});
|
|
1898
|
+
}
|
|
1899
|
+
catch (persistErr) {
|
|
1900
|
+
const persistMsg = persistErr instanceof Error ? persistErr.message : String(persistErr);
|
|
1901
|
+
console.warn('[seo-scanner] persist snapshot failed', { error: persistMsg });
|
|
1902
|
+
output.persist = { saved: false, error: persistMsg };
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1556
1905
|
return [[{ json: output, pairedItem: { item: 0 } }]];
|
|
1557
1906
|
}
|
|
1558
1907
|
catch (e) {
|