seo-intel 1.5.23 → 1.5.24

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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.24 (2026-05-16)
4
+
5
+ ### Dashboard — projects with owned subdomains + sitemap data no longer vanish
6
+ - Fixed: clicking **Analyse** (or any dashboard refresh) made projects with crawled sitemaps disappear from the panel list. The render-time "merge owned subdomains into target" pass deleted `domains` rows without first clearing the new `sitemap_urls` FK, hit `FOREIGN KEY constraint failed`, and the project was silently dropped from the rendered HTML.
7
+ - The merge now clears `sitemap_urls` for owned subdomains inside the savepoint (rollback at end of render still restores everything — on-disk data is never mutated).
8
+ - Wrapped the merge in try/catch so the savepoint always releases — future tables that add a `domain_id` FK can't poison subsequent renders.
9
+ - Fixed: `getSchemaBreakdown` crashed on extractions whose `schema_types` JSON contained a nested array (e.g. `[..., ["SoftwareApplication","WebAPI"], ...]`). Now flattens one level and skips non-string entries instead of throwing.
10
+
3
11
  ## 1.5.23 (2026-04-23)
4
12
 
5
13
  ### Technical Audit — extended-data checks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "seo-intel",
3
- "version": "1.5.23",
3
+ "version": "1.5.24",
4
4
  "description": "Local Ahrefs-style SEO competitor intelligence. Crawl → SQLite → cloud analysis.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -61,17 +61,28 @@ export function gatherProjectData(db, project, config) {
61
61
  const hasOwned = ownedDomains.length > 0;
62
62
  if (hasOwned) {
63
63
  db.prepare('SAVEPOINT owned_merge').run();
64
- const targetDomainId = db.prepare(
65
- `SELECT id FROM domains WHERE project = ? AND domain = ?`
66
- ).get(project, targetDomain)?.id;
67
- if (targetDomainId) {
68
- for (const ownedDomain of ownedDomains) {
69
- const ownedRow = db.prepare(`SELECT id FROM domains WHERE project = ? AND domain = ?`).get(project, ownedDomain);
70
- if (ownedRow && ownedRow.id !== targetDomainId) {
71
- db.prepare(`UPDATE pages SET domain_id = ? WHERE domain_id = ?`).run(targetDomainId, ownedRow.id);
72
- db.prepare(`DELETE FROM domains WHERE id = ?`).run(ownedRow.id);
64
+ try {
65
+ const targetDomainId = db.prepare(
66
+ `SELECT id FROM domains WHERE project = ? AND domain = ?`
67
+ ).get(project, targetDomain)?.id;
68
+ if (targetDomainId) {
69
+ for (const ownedDomain of ownedDomains) {
70
+ const ownedRow = db.prepare(`SELECT id FROM domains WHERE project = ? AND domain = ?`).get(project, ownedDomain);
71
+ if (ownedRow && ownedRow.id !== targetDomainId) {
72
+ db.prepare(`UPDATE pages SET domain_id = ? WHERE domain_id = ?`).run(targetDomainId, ownedRow.id);
73
+ // Clear FK-bearing rows for the owned subdomain inside the savepoint so
74
+ // DELETE FROM domains doesn't trip the FOREIGN KEY constraint. Rollback
75
+ // at the end of gather restores everything.
76
+ db.prepare(`DELETE FROM sitemap_urls WHERE domain_id = ?`).run(ownedRow.id);
77
+ db.prepare(`DELETE FROM domains WHERE id = ?`).run(ownedRow.id);
78
+ }
73
79
  }
74
80
  }
81
+ } catch (e) {
82
+ // Always release the savepoint so a partial merge can't poison the next render.
83
+ try { db.prepare('ROLLBACK TO owned_merge').run(); } catch {}
84
+ try { db.prepare('RELEASE owned_merge').run(); } catch {}
85
+ throw e;
75
86
  }
76
87
  }
77
88
 
@@ -6695,8 +6706,12 @@ function getSchemaBreakdown(db, project) {
6695
6706
  for (const r of rows) {
6696
6707
  let types = [];
6697
6708
  try { types = JSON.parse(r.schema_types); } catch {}
6709
+ if (!Array.isArray(types)) continue;
6698
6710
  if (!schemas[r.domain]) schemas[r.domain] = { role: r.role, types: new Set() };
6699
- for (const t of types) {
6711
+ // Flatten one level extractor occasionally produces nested arrays like
6712
+ // [..., ["SoftwareApplication","WebAPI"], ...]. Skip anything that isn't a string.
6713
+ for (const t of types.flat()) {
6714
+ if (typeof t !== 'string') continue;
6700
6715
  const key = t.trim();
6701
6716
  if (key.length < 2) continue;
6702
6717
  schemas[r.domain].types.add(key);