fetchfox-sdk 1.0.6 → 1.0.8
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/configure.js +6 -0
- package/src/crawl.js +0 -1
- package/src/detach.js +5 -8
- package/src/extract.js +0 -1
- package/src/index.js +1 -0
- package/src/scrape.js +0 -1
- package/src/urls.js +5 -0
- package/src/urls.js~ +0 -0
package/package.json
CHANGED
package/src/configure.js
CHANGED
|
@@ -24,6 +24,12 @@ export const apiKey = (options) =>
|
|
|
24
24
|
export const host = (options) =>
|
|
25
25
|
options?.host || config.host || safeEnv('FETCHFOX_HOST');
|
|
26
26
|
|
|
27
|
+
export const appHost = (options) =>
|
|
28
|
+
(options?.host || config.host || safeEnv('FETCHFOX_HOST')).replace(
|
|
29
|
+
'api.fetchfox.ai',
|
|
30
|
+
'app.fetchfox.ai'
|
|
31
|
+
);
|
|
32
|
+
|
|
27
33
|
export const ws = (options) =>
|
|
28
34
|
(options?.host || config.host || safeEnv('FETCHFOX_HOST')).replace(
|
|
29
35
|
'http',
|
package/src/crawl.js
CHANGED
package/src/detach.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { io } from 'socket.io-client';
|
|
2
|
-
import { ws } from './configure.js';
|
|
2
|
+
import { ws, appHost } from './configure.js';
|
|
3
3
|
import { jobs } from './jobs.js';
|
|
4
4
|
|
|
5
5
|
class FetchFoxError extends Error {}
|
|
@@ -24,18 +24,18 @@ export const Job = class {
|
|
|
24
24
|
this.#socket = new io(ws());
|
|
25
25
|
this.#socket.on('progress', (data) => {
|
|
26
26
|
this.handleProgress(data);
|
|
27
|
-
console.log('==> socket got progress', data);
|
|
28
27
|
});
|
|
29
|
-
console.log('socket emit sub', this.id);
|
|
30
28
|
this.#socket.emit('sub', this.id);
|
|
31
|
-
|
|
32
|
-
// this.poll();
|
|
33
29
|
}
|
|
34
30
|
|
|
35
31
|
get _finished() {
|
|
36
32
|
return this._completed || this._error;
|
|
37
33
|
}
|
|
38
34
|
|
|
35
|
+
get appUrl() {
|
|
36
|
+
return appHost() + '/jobs/' + this.id;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
39
|
#select(data) {
|
|
40
40
|
const s = {};
|
|
41
41
|
for (const key of [
|
|
@@ -72,7 +72,6 @@ export const Job = class {
|
|
|
72
72
|
|
|
73
73
|
const didUpdate = JSON.stringify(this) != last;
|
|
74
74
|
if (didUpdate) {
|
|
75
|
-
console.log('=> Job progressed:', this);
|
|
76
75
|
this.trigger('progress');
|
|
77
76
|
|
|
78
77
|
if (this.state == 'completed') {
|
|
@@ -97,8 +96,6 @@ export const Job = class {
|
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
trigger(event) {
|
|
100
|
-
console.log('Trigger:', this.id, event);
|
|
101
|
-
|
|
102
99
|
this.checkEvent(event);
|
|
103
100
|
for (const cb of this.#callbacks[event]) {
|
|
104
101
|
cb({ ...this });
|
package/src/extract.js
CHANGED
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from './extract.js';
|
|
|
4
4
|
export * from './jobs.js';
|
|
5
5
|
export * from './user.js';
|
|
6
6
|
export * from './proxy.js';
|
|
7
|
+
export * from './urls.js';
|
|
7
8
|
export { Job } from './detach.js';
|
|
8
9
|
export { call } from './api.js';
|
|
9
10
|
export { configure, host, apiKey } from './configure.js';
|
package/src/scrape.js
CHANGED
package/src/urls.js
ADDED
package/src/urls.js~
ADDED
|
File without changes
|