fetchfox-sdk 1.0.30 → 1.0.31
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/package.json +1 -1
- package/src/agent.js +1 -1
- package/src/crawl.js +1 -1
- package/src/detach.js +6 -4
- package/src/extract.js +1 -1
- package/src/index.js +1 -0
- package/src/plan.js +11 -0
- package/src/scrape.js +1 -1
- package/src/visit.js +1 -1
package/package.json
CHANGED
package/src/agent.js
CHANGED
|
@@ -7,5 +7,5 @@ export async function agent(args) {
|
|
|
7
7
|
|
|
8
8
|
agent.detach = async (args) => {
|
|
9
9
|
const data = await call('POST', '/api/agent', { ...args, detach: true });
|
|
10
|
-
return new Job(data.jobId, { ...args,
|
|
10
|
+
return new Job(data.jobId, { ...args, method: 'agent' });
|
|
11
11
|
};
|
package/src/crawl.js
CHANGED
|
@@ -7,5 +7,5 @@ export async function crawl(args) {
|
|
|
7
7
|
|
|
8
8
|
crawl.detach = async (args) => {
|
|
9
9
|
const data = await call('POST', '/api/crawl', { ...args, detach: true });
|
|
10
|
-
return new Job(data.jobId, { ...args,
|
|
10
|
+
return new Job(data.jobId, { ...args, method: 'crawl' });
|
|
11
11
|
};
|
package/src/detach.js
CHANGED
|
@@ -17,7 +17,7 @@ export const Job = class {
|
|
|
17
17
|
|
|
18
18
|
constructor(id, options) {
|
|
19
19
|
this.id = id;
|
|
20
|
-
this.
|
|
20
|
+
this.method = options?.method;
|
|
21
21
|
this.#callbacks = {
|
|
22
22
|
item: [],
|
|
23
23
|
completed: [],
|
|
@@ -73,9 +73,11 @@ export const Job = class {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
get appUrl() {
|
|
76
|
-
return [
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
return [
|
|
77
|
+
appHost(),
|
|
78
|
+
this.method == 'agent' ? 'agents' : 'jobs',
|
|
79
|
+
this.id,
|
|
80
|
+
].join('/');
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
#select(data) {
|
package/src/extract.js
CHANGED
|
@@ -7,5 +7,5 @@ export async function extract(args) {
|
|
|
7
7
|
|
|
8
8
|
extract.detach = async (args) => {
|
|
9
9
|
const data = await call('POST', '/api/extract', { ...args, detach: true });
|
|
10
|
-
return new Job(data.jobId, { ...args,
|
|
10
|
+
return new Job(data.jobId, { ...args, method: 'extract' });
|
|
11
11
|
};
|
package/src/index.js
CHANGED
package/src/plan.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { call } from './api.js';
|
|
2
|
+
import { Job } from './detach.js';
|
|
3
|
+
|
|
4
|
+
export async function plan(args) {
|
|
5
|
+
return call('POST', '/api/plan', args);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
plan.detach = async (args) => {
|
|
9
|
+
const data = await call('POST', '/api/plan', { ...args, detach: true });
|
|
10
|
+
return new Job(data.jobId, { ...args, method: 'plan' });
|
|
11
|
+
};
|
package/src/scrape.js
CHANGED
|
@@ -7,5 +7,5 @@ export async function scrape(args) {
|
|
|
7
7
|
|
|
8
8
|
scrape.detach = async (args) => {
|
|
9
9
|
const data = await call('POST', '/api/scrape', { ...args, detach: true });
|
|
10
|
-
return new Job(data.jobId, { ...args,
|
|
10
|
+
return new Job(data.jobId, { ...args, method: 'scrape' });
|
|
11
11
|
};
|
package/src/visit.js
CHANGED
|
@@ -7,5 +7,5 @@ export async function visit(args) {
|
|
|
7
7
|
|
|
8
8
|
visit.detach = async (args) => {
|
|
9
9
|
const data = await call('POST', '/api/visit', { ...args, detach: true });
|
|
10
|
-
return new Job(data.jobId, { ...args,
|
|
10
|
+
return new Job(data.jobId, { ...args, method: 'visit' });
|
|
11
11
|
};
|