@detiq/crawler 1.0.8 → 1.1.0
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/crawler.js +10 -3
- package/dist/crawler.js.map +2 -2
- package/dist/job-queue.js +34 -1
- package/dist/job-queue.js.map +2 -2
- package/package.json +1 -1
package/dist/job-queue.js
CHANGED
|
@@ -30,7 +30,7 @@ async function notifyAdmins(tenantId, data) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
import { AppBrain, buildArtifactKey, getTenantStorageConfig, uploadScreenshotToTenantStorage, uploadFileToTenantStorage, notifyRunCompletion, recordLLMCall } from "@detiq/app-brain";
|
|
33
|
-
import { generateTaxonomySkillFiles, groupScreensWithAI, generateExecutionPlan, refreshTestCasesSkillFile, refreshTestDataSkillFile, refreshTestScriptSkillFile, refreshRequirementsCoverageSkillFile } from "@detiq/agents";
|
|
33
|
+
import { generateTaxonomySkillFiles, groupScreensWithAI, generateExecutionPlan, refreshTestCasesSkillFile, refreshTestDataSkillFile, refreshTestScriptSkillFile, refreshRequirementsCoverageSkillFile, detectFieldsFromHtml, mergeIntoCatalog } from "@detiq/agents";
|
|
34
34
|
import { crawlProject } from "./crawler.js";
|
|
35
35
|
import { httpCrawl } from "./http-engine.js";
|
|
36
36
|
import { hashContent, normalizeText } from "./incremental-diff.js";
|
|
@@ -519,6 +519,39 @@ async function processJob(jobId, config, opts) {
|
|
|
519
519
|
);
|
|
520
520
|
}
|
|
521
521
|
await generateTaxonomySkillFiles(tenantId, projectId, projectMap.screens, result.apiEndpoints, result.performanceMetrics);
|
|
522
|
+
try {
|
|
523
|
+
const { readFile } = await import("node:fs/promises");
|
|
524
|
+
const { existsSync } = await import("node:fs");
|
|
525
|
+
const screensWithDom = projectMap.screens.filter((s) => s.domSnapshotPath);
|
|
526
|
+
const detectLimit = Math.min(screensWithDom.length, 20);
|
|
527
|
+
let fieldDetectAdded = 0;
|
|
528
|
+
for (let si = 0; si < detectLimit; si++) {
|
|
529
|
+
const screen = screensWithDom[si];
|
|
530
|
+
try {
|
|
531
|
+
let htmlContent = null;
|
|
532
|
+
const domPath = screen.domSnapshotPath;
|
|
533
|
+
if (domPath.startsWith("https://") || domPath.startsWith("http://")) {
|
|
534
|
+
const res = await fetch(domPath);
|
|
535
|
+
if (res.ok) htmlContent = await res.text();
|
|
536
|
+
} else if (existsSync(domPath)) {
|
|
537
|
+
htmlContent = await readFile(domPath, "utf8");
|
|
538
|
+
}
|
|
539
|
+
if (!htmlContent) continue;
|
|
540
|
+
const detected = await detectFieldsFromHtml({ tenantId, projectId, html: htmlContent });
|
|
541
|
+
if (detected.length > 0) {
|
|
542
|
+
const merged = await mergeIntoCatalog({ tenantId, projectId, detected });
|
|
543
|
+
fieldDetectAdded += merged.added;
|
|
544
|
+
}
|
|
545
|
+
} catch (sErr) {
|
|
546
|
+
logger.warn({ screenId: screen.id, err: sErr }, "[field-detect] skipped screen");
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
if (fieldDetectAdded > 0 || detectLimit > 0) {
|
|
550
|
+
logger.info({ screens: detectLimit, added: fieldDetectAdded, projectId }, "[field-detect] catalog populated from crawl");
|
|
551
|
+
}
|
|
552
|
+
} catch (fdErr) {
|
|
553
|
+
logger.warn({ err: fdErr }, "[field-detect] post-crawl field detection failed");
|
|
554
|
+
}
|
|
522
555
|
const tenantStorageCfg = await getTenantStorageConfig(tenantId).catch(() => null);
|
|
523
556
|
if (tenantStorageCfg) {
|
|
524
557
|
let uploaded = 0;
|