mcp-scraper 0.90.0 → 0.90.2

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.
@@ -1 +1 @@
1
- import{a as O,b as y,c as D,d as g,f as A,g as _}from"./chunk-PHBU6X5B.js";import"./chunk-XG6GCEUE.js";import{u as k}from"./chunk-M7EXIKT7.js";import"./chunk-M5QHXNFZ.js";import{b as f,c as H}from"./chunk-7AC66V3T.js";import{a as m,b}from"./chunk-YEFXVTMJ.js";import{a as v}from"./chunk-4FROKQJN.js";import{b as M}from"./chunk-DKQZNSYM.js";import"./chunk-2TZBO52D.js";import"./chunk-2PXP7TMY.js";import{Mb as l,Qb as p,Sb as d,Ua as u,gb as h,ib as c,na as o}from"./chunk-7BEWBRMT.js";var P=2,w=0;function C(e){if(!e||typeof e!="object")return 0;let t=e;return typeof t.totalQuestions=="number"?t.totalQuestions:Array.isArray(t.flat)?t.flat.length:0}function R(e){return m.paa_base+Math.max(1,e)*m.paa}async function N(e){w++;try{let t=typeof e.options=="string"?JSON.parse(e.options):e.options,r={value:null},i=await M({op:t.serpOnly?"serp":"paa",userId:Number(e.user_id),headlessSentOut:r},()=>k({...t,\u006b\u0065\u0072\u006e\u0065\u006cApiKey:v(),headless:!0,format:"json",outputDir:"/tmp/paa-output-api",onAttemptEvent:A(e.id,e.user_id)}));await h(e.id,i);let s=await o(e.id,e.user_id);if(typeof t.billingHoldMc=="number"&&t.billingDebitKey){let n=t.serpOnly?b(r.value):R(C(i));await d(Number(e.user_id),t.billingDebitKey,n,t.serpOnly?"serp_refund":"paa_refund",t.serpOnly?"SERP search settlement":"PAA harvest settlement",t.serpOnly?"serp_search":"paa_harvest")}else if(!t.serpOnly&&typeof t.billingHoldMc=="number"){let n=R(C(i)),a=t.billingHoldMc-n;a>0?await l(e.user_id,a,"paa_refund","overestimate refund"):a<0&&await p(e.user_id,-a,"paa",t.query??e.query)}else if(t.serpOnly&&typeof t.billingHoldMc=="number"){let n=b(r.value),a=t.billingHoldMc-n;a>0?await l(e.user_id,a,"serp_refund","headless-mode pricing settle"):a<0&&await p(e.user_id,-a,"serp",t.query??e.query)}e.callback_url&&await _(e.callback_url,{job_id:e.id,status:"done",result:H(i),attempts:f(s)})}catch(t){console.error("[harvest/worker] failed",{jobId:e.id,error:t instanceof Error?t.message:String(t)});let r=O(t),i=typeof e.options=="string"?JSON.parse(e.options):e.options,s=typeof i.billingHoldMc=="number"&&i.billingHoldMc>0;await c(e.id,y(r),g(r,{chargeStatus:s?"refund_pending":"not_charged"}));let n=await o(e.id,e.user_id);try{s&&(i.billingDebitKey?await d(Number(e.user_id),i.billingDebitKey,0,i.serpOnly?"serp_refund":"paa_refund","failed call",i.serpOnly?"serp_search":"paa_harvest"):await l(e.user_id,i.billingHoldMc,"refund","failed call"),await c(e.id,y(r),g(r,{chargeStatus:"refunded"})))}catch{}e.callback_url&&await _(e.callback_url,{job_id:e.id,status:"failed",...D(r),attempts:f(n)})}finally{w--}}async function x(){let e=await u();if(!e)return{claimed:!1};let t=Date.now();return await N(e),{claimed:!0,jobId:e.id,completed:!0,durationMs:Date.now()-t}}async function W(e){let t=[];for(let r=0;r<e.maxJobs&&!(Date.now()>=e.deadlineMs);r++){let i=await x();if(t.push(i),!i.claimed)break}return t}function B(){setInterval(async()=>{if(w>=P)return;let e=await u();e&&N(e)},2e3),console.log(`[worker] started \u2014 polling every 2s, max ${P} concurrent`)}export{W as drainQueue,B as startWorker,x as tickOnce};
1
+ import{a as O,b as y,c as D,d as g,f as A,g as _}from"./chunk-PHBU6X5B.js";import"./chunk-XG6GCEUE.js";import{w as k}from"./chunk-GW6ITK76.js";import"./chunk-M5QHXNFZ.js";import{b as f,c as H}from"./chunk-7AC66V3T.js";import{a as m,b}from"./chunk-YEFXVTMJ.js";import{a as v}from"./chunk-4FROKQJN.js";import{b as M}from"./chunk-DKQZNSYM.js";import"./chunk-2TZBO52D.js";import"./chunk-2PXP7TMY.js";import{Mb as l,Qb as p,Sb as d,Ua as u,gb as h,ib as c,na as o}from"./chunk-7BEWBRMT.js";var P=2,w=0;function C(e){if(!e||typeof e!="object")return 0;let t=e;return typeof t.totalQuestions=="number"?t.totalQuestions:Array.isArray(t.flat)?t.flat.length:0}function R(e){return m.paa_base+Math.max(1,e)*m.paa}async function N(e){w++;try{let t=typeof e.options=="string"?JSON.parse(e.options):e.options,r={value:null},i=await M({op:t.serpOnly?"serp":"paa",userId:Number(e.user_id),headlessSentOut:r},()=>k({...t,\u006b\u0065\u0072\u006e\u0065\u006cApiKey:v(),headless:!0,format:"json",outputDir:"/tmp/paa-output-api",onAttemptEvent:A(e.id,e.user_id)}));await h(e.id,i);let s=await o(e.id,e.user_id);if(typeof t.billingHoldMc=="number"&&t.billingDebitKey){let n=t.serpOnly?b(r.value):R(C(i));await d(Number(e.user_id),t.billingDebitKey,n,t.serpOnly?"serp_refund":"paa_refund",t.serpOnly?"SERP search settlement":"PAA harvest settlement",t.serpOnly?"serp_search":"paa_harvest")}else if(!t.serpOnly&&typeof t.billingHoldMc=="number"){let n=R(C(i)),a=t.billingHoldMc-n;a>0?await l(e.user_id,a,"paa_refund","overestimate refund"):a<0&&await p(e.user_id,-a,"paa",t.query??e.query)}else if(t.serpOnly&&typeof t.billingHoldMc=="number"){let n=b(r.value),a=t.billingHoldMc-n;a>0?await l(e.user_id,a,"serp_refund","headless-mode pricing settle"):a<0&&await p(e.user_id,-a,"serp",t.query??e.query)}e.callback_url&&await _(e.callback_url,{job_id:e.id,status:"done",result:H(i),attempts:f(s)})}catch(t){console.error("[harvest/worker] failed",{jobId:e.id,error:t instanceof Error?t.message:String(t)});let r=O(t),i=typeof e.options=="string"?JSON.parse(e.options):e.options,s=typeof i.billingHoldMc=="number"&&i.billingHoldMc>0;await c(e.id,y(r),g(r,{chargeStatus:s?"refund_pending":"not_charged"}));let n=await o(e.id,e.user_id);try{s&&(i.billingDebitKey?await d(Number(e.user_id),i.billingDebitKey,0,i.serpOnly?"serp_refund":"paa_refund","failed call",i.serpOnly?"serp_search":"paa_harvest"):await l(e.user_id,i.billingHoldMc,"refund","failed call"),await c(e.id,y(r),g(r,{chargeStatus:"refunded"})))}catch{}e.callback_url&&await _(e.callback_url,{job_id:e.id,status:"failed",...D(r),attempts:f(n)})}finally{w--}}async function x(){let e=await u();if(!e)return{claimed:!1};let t=Date.now();return await N(e),{claimed:!0,jobId:e.id,completed:!0,durationMs:Date.now()-t}}async function W(e){let t=[];for(let r=0;r<e.maxJobs&&!(Date.now()>=e.deadlineMs);r++){let i=await x();if(t.push(i),!i.claimed)break}return t}function B(){setInterval(async()=>{if(w>=P)return;let e=await u();e&&N(e)},2e3),console.log(`[worker] started \u2014 polling every 2s, max ${P} concurrent`)}export{W as drainQueue,B as startWorker,x as tickOnce};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-scraper",
3
- "version": "0.90.0",
3
+ "version": "0.90.2",
4
4
  "description": "MCP server for MCP Scraper web intelligence tools",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -1 +0,0 @@
1
- var o="0.90.0";export{o as a};