Defer property assessor email gate
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
import { execFile } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
import { extractHarPhotos } from "../../web-automation/scripts/har-photos.js";
|
||||
import { extractZillowPhotos } from "../../web-automation/scripts/zillow-photos.js";
|
||||
|
||||
export type PhotoSource = "zillow" | "har";
|
||||
|
||||
@@ -21,28 +19,25 @@ export interface PhotoReviewResolution {
|
||||
discoveredListingUrls: Array<{ label: string; url: string }>;
|
||||
}
|
||||
|
||||
function parseJsonOutput(raw: string, context: string): any {
|
||||
const text = raw.trim();
|
||||
if (!text) {
|
||||
throw new Error(`${context} produced no JSON output.`);
|
||||
}
|
||||
return JSON.parse(text);
|
||||
}
|
||||
|
||||
export async function extractPhotoData(
|
||||
source: PhotoSource,
|
||||
url: string
|
||||
): Promise<PhotoExtractionResult> {
|
||||
const scriptMap: Record<PhotoSource, string> = {
|
||||
zillow: "zillow-photos.js",
|
||||
har: "har-photos.js"
|
||||
};
|
||||
const scriptPath = `/Users/stefano/.openclaw/workspace/skills/web-automation/scripts/${scriptMap[source]}`;
|
||||
const { stdout } = await execFileAsync(process.execPath, [scriptPath, url], {
|
||||
timeout: 180000,
|
||||
maxBuffer: 5 * 1024 * 1024
|
||||
});
|
||||
const payload = parseJsonOutput(stdout, scriptMap[source]);
|
||||
if (source === "zillow") {
|
||||
const payload = await extractZillowPhotos(url);
|
||||
return {
|
||||
source,
|
||||
requestedUrl: String(payload.requestedUrl || url),
|
||||
finalUrl: typeof payload.finalUrl === "string" ? payload.finalUrl : undefined,
|
||||
expectedPhotoCount: typeof payload.expectedPhotoCount === "number" ? payload.expectedPhotoCount : null,
|
||||
complete: Boolean(payload.complete),
|
||||
photoCount: Number(payload.photoCount || 0),
|
||||
imageUrls: Array.isArray(payload.imageUrls) ? payload.imageUrls.map(String) : [],
|
||||
notes: Array.isArray(payload.notes) ? payload.notes.map(String) : []
|
||||
};
|
||||
}
|
||||
|
||||
const payload = await extractHarPhotos(url);
|
||||
return {
|
||||
source,
|
||||
requestedUrl: String(payload.requestedUrl || url),
|
||||
|
||||
Reference in New Issue
Block a user