@mendable/firecrawl-js 1.18.0-beta.4 → 1.18.0-beta.5
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/index.cjs +24 -16
- package/dist/index.js +25 -17
- package/package.json +1 -1
- package/src/index.ts +31 -18
package/dist/index.cjs
CHANGED
|
@@ -862,23 +862,31 @@ var FirecrawlApp = class {
|
|
|
862
862
|
if (!response.success || "error" in response) {
|
|
863
863
|
return { success: false, error: "error" in response ? response.error : "Unknown error" };
|
|
864
864
|
}
|
|
865
|
-
if (response.id) {
|
|
866
|
-
|
|
867
|
-
let researchStatus;
|
|
868
|
-
do {
|
|
869
|
-
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
870
|
-
if ("error" in researchStatus && !researchStatus.success) {
|
|
871
|
-
return researchStatus;
|
|
872
|
-
}
|
|
873
|
-
if (researchStatus.status === "completed" && researchStatus.data) {
|
|
874
|
-
return researchStatus;
|
|
875
|
-
} else if (researchStatus.status === "failed") {
|
|
876
|
-
throw new FirecrawlError(`Research job failed. Error: ${researchStatus.error}`, 500);
|
|
877
|
-
}
|
|
878
|
-
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
879
|
-
} while (researchStatus.status !== "completed");
|
|
865
|
+
if (!response.id) {
|
|
866
|
+
throw new FirecrawlError(`Failed to start research. No job ID returned.`, 500);
|
|
880
867
|
}
|
|
881
|
-
|
|
868
|
+
const jobId = response.id;
|
|
869
|
+
let researchStatus;
|
|
870
|
+
do {
|
|
871
|
+
console.log("Checking research status...");
|
|
872
|
+
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
873
|
+
console.log("Research status:", researchStatus);
|
|
874
|
+
if ("error" in researchStatus && !researchStatus.success) {
|
|
875
|
+
return researchStatus;
|
|
876
|
+
}
|
|
877
|
+
if (researchStatus.status === "completed") {
|
|
878
|
+
return researchStatus;
|
|
879
|
+
}
|
|
880
|
+
if (researchStatus.status === "failed") {
|
|
881
|
+
throw new FirecrawlError(
|
|
882
|
+
`Research job ${researchStatus.status}. Error: ${researchStatus.error}`,
|
|
883
|
+
500
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
887
|
+
} while (researchStatus.status === "processing");
|
|
888
|
+
console.log("Research status finished:", researchStatus);
|
|
889
|
+
return { success: false, error: "Research job terminated unexpectedly" };
|
|
882
890
|
} catch (error) {
|
|
883
891
|
throw new FirecrawlError(error.message, 500, error.response?.data?.details);
|
|
884
892
|
}
|
package/dist/index.js
CHANGED
|
@@ -826,23 +826,31 @@ var FirecrawlApp = class {
|
|
|
826
826
|
if (!response.success || "error" in response) {
|
|
827
827
|
return { success: false, error: "error" in response ? response.error : "Unknown error" };
|
|
828
828
|
}
|
|
829
|
-
if (response.id) {
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
}
|
|
844
|
-
|
|
845
|
-
|
|
829
|
+
if (!response.id) {
|
|
830
|
+
throw new FirecrawlError(`Failed to start research. No job ID returned.`, 500);
|
|
831
|
+
}
|
|
832
|
+
const jobId = response.id;
|
|
833
|
+
let researchStatus;
|
|
834
|
+
do {
|
|
835
|
+
console.log("Checking research status...");
|
|
836
|
+
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
837
|
+
console.log("Research status:", researchStatus);
|
|
838
|
+
if ("error" in researchStatus && !researchStatus.success) {
|
|
839
|
+
return researchStatus;
|
|
840
|
+
}
|
|
841
|
+
if (researchStatus.status === "completed") {
|
|
842
|
+
return researchStatus;
|
|
843
|
+
}
|
|
844
|
+
if (researchStatus.status === "failed") {
|
|
845
|
+
throw new FirecrawlError(
|
|
846
|
+
`Research job ${researchStatus.status}. Error: ${researchStatus.error}`,
|
|
847
|
+
500
|
|
848
|
+
);
|
|
849
|
+
}
|
|
850
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
851
|
+
} while (researchStatus.status === "processing");
|
|
852
|
+
console.log("Research status finished:", researchStatus);
|
|
853
|
+
return { success: false, error: "Research job terminated unexpectedly" };
|
|
846
854
|
} catch (error) {
|
|
847
855
|
throw new FirecrawlError(error.message, 500, error.response?.data?.details);
|
|
848
856
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1362,25 +1362,38 @@ export default class FirecrawlApp {
|
|
|
1362
1362
|
return { success: false, error: 'error' in response ? response.error : 'Unknown error' };
|
|
1363
1363
|
}
|
|
1364
1364
|
|
|
1365
|
-
if (response.id) {
|
|
1366
|
-
|
|
1367
|
-
let researchStatus;
|
|
1368
|
-
do {
|
|
1369
|
-
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
1370
|
-
|
|
1371
|
-
if ('error' in researchStatus && !researchStatus.success) {
|
|
1372
|
-
return researchStatus;
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
if (researchStatus.status === "completed" && researchStatus.data) {
|
|
1376
|
-
return researchStatus;
|
|
1377
|
-
} else if (researchStatus.status === "failed") {
|
|
1378
|
-
throw new FirecrawlError(`Research job failed. Error: ${researchStatus.error}`, 500);
|
|
1379
|
-
}
|
|
1380
|
-
await new Promise(resolve => setTimeout(resolve, 1000)); // Polling interval
|
|
1381
|
-
} while (researchStatus.status !== "completed");
|
|
1365
|
+
if (!response.id) {
|
|
1366
|
+
throw new FirecrawlError(`Failed to start research. No job ID returned.`, 500);
|
|
1382
1367
|
}
|
|
1383
|
-
|
|
1368
|
+
|
|
1369
|
+
const jobId = response.id;
|
|
1370
|
+
let researchStatus;
|
|
1371
|
+
|
|
1372
|
+
do {
|
|
1373
|
+
console.log("Checking research status...");
|
|
1374
|
+
researchStatus = await this.__checkDeepResearchStatus(jobId);
|
|
1375
|
+
console.log("Research status:", researchStatus);
|
|
1376
|
+
|
|
1377
|
+
if ('error' in researchStatus && !researchStatus.success) {
|
|
1378
|
+
return researchStatus;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
if (researchStatus.status === "completed") {
|
|
1382
|
+
return researchStatus;
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
if (researchStatus.status === "failed") {
|
|
1386
|
+
throw new FirecrawlError(
|
|
1387
|
+
`Research job ${researchStatus.status}. Error: ${researchStatus.error}`,
|
|
1388
|
+
500
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
1393
|
+
} while (researchStatus.status === "processing");
|
|
1394
|
+
console.log("Research status finished:", researchStatus);
|
|
1395
|
+
|
|
1396
|
+
return { success: false, error: "Research job terminated unexpectedly" };
|
|
1384
1397
|
} catch (error: any) {
|
|
1385
1398
|
throw new FirecrawlError(error.message, 500, error.response?.data?.details);
|
|
1386
1399
|
}
|