fetchfox-sdk 1.0.6 → 1.0.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fetchfox-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "AI scraper",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
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/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/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/urls.js ADDED
@@ -0,0 +1,5 @@
1
+ import { call } from './api.js';
2
+
3
+ export const urls = {
4
+ list: async (params) => call('GET', '/api/urls', params),
5
+ };
package/src/urls.js~ ADDED
File without changes