ilml-plugin-linkedin 1.20.11 → 1.20.13
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/CHANGELOG.md +16 -0
- package/dist/applyQueue.mjs +26 -26
- package/dist/connect.mjs +52 -52
- package/dist/daily.mjs +33 -33
- package/dist/enrichProfile.mjs +16 -16
- package/dist/enrichProfiles.mjs +51 -51
- package/dist/funnelRunner.mjs +44 -44
- package/dist/messageBot.mjs +40 -40
- package/dist/migrationCli.mjs +43 -43
- package/dist/profileHistory.mjs +8 -8
- package/dist/quota.mjs +32 -32
- package/dist/readPost.mjs +9 -9
- package/dist/run.mjs +69 -66
- package/dist/scout.mjs +40 -39
- package/dist/src/saveLoginState.mjs +4 -4
- package/dist/syncAll.mjs +87 -87
- package/dist/syncConnections.mjs +30 -30
- package/dist/verifyAbout.mjs +19 -19
- package/dist/version.mjs +1 -1
- package/dist/viewers.mjs +43 -43
- package/dist/visit.mjs +50 -50
- package/dist/warmScan.mjs +3 -3
- package/ilml-plugin.json +11 -2
- package/package.json +2 -2
package/dist/migrationCli.mjs
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
var ve=Object.defineProperty;var U=(e,o)=>{for(var n in o)ve(e,n,{get:o[n],enumerable:!0})};import"dotenv/config";import"dotenv/config";import*as i from"fs";import*as H from"os";import*as c from"path";import{fileURLToPath as uo}from"url";var W={};U(W,{NAME:()=>Ae,VERSION:()=>we,up:()=>Ee});import*as A from"fs";import*as P from"path";var we=1,Ae="normalize-jobs-and-questions",je=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],$e=50;function V(e){return A.existsSync(e)?JSON.parse(A.readFileSync(e,"utf-8")):null}function q(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{A.writeFileSync(t,n)}catch(r){try{A.unlinkSync(t)}catch{}throw r}try{A.renameSync(t,e)}catch(r){try{A.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Ee(e,o){let n=P.join(e,"jobs.json"),t=P.join(o,"scouted-jobs.json"),r=P.join(e,"application-questions.json"),s=V(n)||{},l=V(t)||{},I=0,u=[];for(let f of Object.keys(s)){if(!l[f])continue;let b=l[f],d=s[f];for(let O of je)b[O]!=null&&d[O]==null&&(d[O]=b[O]);u.push(f),I++}I>0?(q(n,s),console.log(` Phase 1: Merged ${I} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let p=V(r);if(p&&Array.isArray(p.applications)){let f={},b=0;for(let d of p.applications){let O=d.jobId||"unknown";f[O]||(f[O]={applications:[]});let D=(d.questions||[]).map(g=>{let k={type:g.type||"input",question:g.question||"",answer:g.answer||""};return g.options&&(g.options.length<=$e?k.options=g.options:(k.optionsOmitted=!0,b++)),g.page&&(k.page=g.page),g.wasPreFilled&&(k.wasPreFilled=!0),g.wasRetry&&(k.wasRetry=!0),k});f[O].applications.push({applicationId:d.applicationId,date:d.date,result:d.result||"submitted",formPages:d.formPages||null,duration:d.duration||null,retries:d.retries||0,failedField:d.failedField||null,questionCount:d.questionCount||D.length,questions:D})}q(r,f),console.log(` Phase 2: Rekeyed ${p.applications.length} applications by jobId (${Object.keys(f).length} unique jobs)`),b>0&&console.log(` Phase 2: Stripped bloated options from ${b} questions`)}else p&&!p.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(u.length>0){for(let f of u)delete l[f];q(t,l),console.log(` Phase 3: Removed ${u.length} merged entries from scouted-jobs.json (${Object.keys(l).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var G={};U(G,{NAME:()=>Oe,VERSION:()=>Ie,up:()=>Ne});import*as j from"fs";import*as X from"path";var Ie=2,Oe="reset-unread-flags";function Ce(e){return j.existsSync(e)?JSON.parse(j.readFileSync(e,"utf-8")):null}function Re(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{j.writeFileSync(t,n)}catch(r){try{j.unlinkSync(t)}catch{}throw r}try{j.renameSync(t,e)}catch(r){try{j.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Ne(e){let o=X.join(e,"conversations.json"),n=Ce(o);if(!n){console.log(" conversations.json not found \u2014 nothing to reset.");return}let t=0;for(let r of Object.keys(n))n[r].unread===!0&&(n[r].unread=!1,t++);if(t===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}Re(o,n),console.log(` Reset unread=false on ${t} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Y={};U(Y,{NAME:()=>xe,VERSION:()=>De,up:()=>Me});import*as $ from"fs";import*as Z from"path";var De=3,xe="recompute-last-message-by",Te=new Set(["draft","confirmed","rejected","needs_review"]);function _e(e){return $.existsSync(e)?JSON.parse($.readFileSync(e,"utf-8")):null}function Fe(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{$.writeFileSync(t,n)}catch(r){try{$.unlinkSync(t)}catch{}throw r}try{$.renameSync(t,e)}catch(r){try{$.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}function Le(e,o){if(!e||e.length===0)return"them";let n=e.filter(s=>!Te.has(s.status));if(n.length===0)return"them";let t=n.map(s=>({m:s,t:Date.parse(s.time)})).filter(s=>Number.isFinite(s.t)).sort((s,l)=>l.t-s.t).map(s=>s.m),r=t.length>0?t:[...n].reverse();for(let s of r){let l=s.sender;if(l===o)return"me";if(l!=="Unknown"&&l!=="")return"them"}return"them"}async function Me(e){let o=Z.join(e,"conversations.json"),n=_e(o);if(!n){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let t=process.env.LINKEDIN_NAME;if(!t||typeof t!="string"||!t.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let r=0,s=0,l=0;for(let I of Object.keys(n)){let u=n[I];if(!u||typeof u!="object")continue;Object.prototype.hasOwnProperty.call(u,"_cardSynced")&&(delete u._cardSynced,s++);let p=Array.isArray(u.messages)?u.messages:[],f=Le(p,t),b=f==="me"?"awaiting_reply":"unanswered_by_us";u.lastMessageBy!==f&&l++,u.lastMessageBy=f,u.conversationStatus=b,r++}if(r===0){console.log(" No conversations to recompute.");return}Fe(o,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${l} had stale lastMessageBy (now corrected).`),s>0&&console.log(` Cleaned ${s} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var z={};U(z,{NAME:()=>Pe,VERSION:()=>Ue,up:()=>qe});import*as E from"fs";import*as ee from"path";var Ue=4,Pe="split-connection-timestamps",Je=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function Be(e){if(!E.existsSync(e))return null;let o=E.readFileSync(e,"utf-8");return o.charCodeAt(0)===65279&&(o=o.slice(1)),JSON.parse(o)}function Ve(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{E.writeFileSync(t,n)}catch(r){try{E.unlinkSync(t)}catch{}throw r}try{E.renameSync(t,e)}catch(r){try{E.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function qe(e){let o=ee.join(e,"people.json"),n=Be(o);if(!n||typeof n!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let t=0,r=0;for(let s of Object.keys(n)){let l=n[s];!l||typeof l!="object"||(r++,Je.has(l.connectionStatus)&&l.connectionDate&&!l.requestedConnectionAt&&(l.requestedConnectionAt=l.connectionDate,l.connectionDate=null,t++))}if(t===0){console.log(` Scanned ${r} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}Ve(o,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${t} still-pending people (of ${r} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}import{getPluginConfig as We}from"@ilivemylife/graph-sdk";var Ge=await We();for(let[e,o]of Object.entries(Ge))process.env[e]===void 0&&(process.env[e]=o);var Oo=process.env.LINKEDIN_NAME,x=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Co=Object.freeze(new Set([x.DRAFT,x.CONFIRMED,x.NEEDS_REVIEW])),Ro=Object.freeze(new Set([x.DRAFT,x.CONFIRMED,x.REJECTED,x.NEEDS_REVIEW]));import"dotenv/config";import*as y from"path";import{fileURLToPath as Ye}from"url";var ze=Ye(import.meta.url),He=y.dirname(y.dirname(ze)),T=process.env.DATA_DIR?y.resolve(process.env.DATA_DIR,"collected-profiles"):y.join(He,"collected-profiles"),_o=y.join(T,"people.json"),Fo=y.join(T,"jobs.json"),Lo=y.join(T,"quota.json"),Mo=y.join(T,"conversations.json"),Uo=y.join(T,"sync-state.json"),Po=y.join(T,"application-questions.json"),Jo=y.join(T,"profile-history"),oe=(e,o)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:o},Bo=oe(process.env.CONNECT_MAX_DAILY,20),Vo=oe(process.env.CONNECT_MAX_WEEKLY,100),Ke=null,Qe=null,Xe=null,Ze=null,eo=null,oo=null;function ne(){Ke=null,Qe=null,Xe=null,Ze=null,eo=null,oo=null}import"dotenv/config";import*as v from"path";import{fileURLToPath as no}from"url";var to=no(import.meta.url),ro=v.dirname(v.dirname(to)),L=process.env.DATA_DIR?v.resolve(process.env.DATA_DIR,"market-research"):v.join(ro,"market-research"),Qo=v.join(L,"scouted-jobs.json"),Xo=v.join(L,"discovered-people.json"),Zo=v.join(L,"visit-log.json"),en=v.join(L,"companies.json"),on=v.join(L,"job-decisions.json");function te(){so=null,io=null,lo=null,co=null,ao=null}var so=null;var io=null;var lo=null;var co=null;var ao=null;var fo=uo(import.meta.url),po=c.dirname(fo),mo=c.dirname(c.dirname(po));function ho(e){return e&&(e==="~"?H.homedir():e.startsWith("~/")||e.startsWith("~\\")?c.join(H.homedir(),e.slice(2)):e)}var S=process.env.DATA_DIR?c.resolve(ho(process.env.DATA_DIR)):mo,R=c.join(S,"collected-profiles"),N=c.join(S,"market-research"),h=c.join(S,".schema-version"),re=[c.join(R,".schema-version"),c.join(N,".schema-version")],J=4,C=[{version:1,module:W},{version:2,module:G},{version:3,module:Y},{version:4,module:z}];(function(){C.sort((t,r)=>t.version-r.version);let o=new Set;for(let t of C){if(!Number.isInteger(t.version)||t.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(t.version)} (must be positive integer)`);if(o.has(t.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${t.version}`);o.add(t.version);let r=t.module;if(!r||typeof r.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(r.VERSION!==void 0&&r.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${r.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=C.length?C[C.length-1].version:0;if(n!==J)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${J}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<C.length;t++){let r=t+1;if(C[t].version!==r)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${r} at position ${t} but found v${C[t].version}`)}})();function ce(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
1
|
+
var Ee=Object.defineProperty;var P=(e,n)=>{for(var o in n)Ee(e,o,{get:n[o],enumerable:!0})};import"dotenv/config";import"dotenv/config";import*as i from"fs";import*as K from"os";import*as c from"path";import{fileURLToPath as go}from"url";var W={};P(W,{NAME:()=>$e,VERSION:()=>je,up:()=>Ce});import*as E from"fs";import*as U from"path";var je=1,$e="normalize-jobs-and-questions",Ie=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Oe=50;function V(e){return E.existsSync(e)?JSON.parse(E.readFileSync(e,"utf-8")):null}function q(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{E.writeFileSync(t,o)}catch(r){try{E.unlinkSync(t)}catch{}throw r}try{E.renameSync(t,e)}catch(r){try{E.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Ce(e,n){let o=U.join(e,"jobs.json"),t=U.join(n,"scouted-jobs.json"),r=U.join(e,"application-questions.json"),s=V(o)||{},l=V(t)||{},g=0,a=[];for(let p of Object.keys(s)){if(!l[p])continue;let k=l[p],d=s[p];for(let O of Ie)k[O]!=null&&d[O]==null&&(d[O]=k[O]);a.push(p),g++}g>0?(q(o,s),console.log(` Phase 1: Merged ${g} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let f=V(r);if(f&&Array.isArray(f.applications)){let p={},k=0;for(let d of f.applications){let O=d.jobId||"unknown";p[O]||(p[O]={applications:[]});let N=(d.questions||[]).map(y=>{let v={type:y.type||"input",question:y.question||"",answer:y.answer||""};return y.options&&(y.options.length<=Oe?v.options=y.options:(v.optionsOmitted=!0,k++)),y.page&&(v.page=y.page),y.wasPreFilled&&(v.wasPreFilled=!0),y.wasRetry&&(v.wasRetry=!0),v});p[O].applications.push({applicationId:d.applicationId,date:d.date,result:d.result||"submitted",formPages:d.formPages||null,duration:d.duration||null,retries:d.retries||0,failedField:d.failedField||null,questionCount:d.questionCount||N.length,questions:N})}q(r,p),console.log(` Phase 2: Rekeyed ${f.applications.length} applications by jobId (${Object.keys(p).length} unique jobs)`),k>0&&console.log(` Phase 2: Stripped bloated options from ${k} questions`)}else f&&!f.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(a.length>0){for(let p of a)delete l[p];q(t,l),console.log(` Phase 3: Removed ${a.length} merged entries from scouted-jobs.json (${Object.keys(l).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var G={};P(G,{NAME:()=>_e,VERSION:()=>Re,up:()=>Te});import*as j from"fs";import*as X from"path";var Re=2,_e="reset-unread-flags";function Ne(e){return j.existsSync(e)?JSON.parse(j.readFileSync(e,"utf-8")):null}function De(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{j.writeFileSync(t,o)}catch(r){try{j.unlinkSync(t)}catch{}throw r}try{j.renameSync(t,e)}catch(r){try{j.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Te(e){let n=X.join(e,"conversations.json"),o=Ne(n);if(!o){console.log(" conversations.json not found \u2014 nothing to reset.");return}let t=0;for(let r of Object.keys(o))o[r].unread===!0&&(o[r].unread=!1,t++);if(t===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}De(n,o),console.log(` Reset unread=false on ${t} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Y={};P(Y,{NAME:()=>Fe,VERSION:()=>xe,up:()=>Je});import*as $ from"fs";import*as Z from"path";var xe=3,Fe="recompute-last-message-by",Le=new Set(["draft","confirmed","rejected","needs_review"]);function Me(e){return $.existsSync(e)?JSON.parse($.readFileSync(e,"utf-8")):null}function Pe(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{$.writeFileSync(t,o)}catch(r){try{$.unlinkSync(t)}catch{}throw r}try{$.renameSync(t,e)}catch(r){try{$.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}function Ue(e,n){if(!e||e.length===0)return"them";let o=e.filter(s=>!Le.has(s.status));if(o.length===0)return"them";let t=o.map(s=>({m:s,t:Date.parse(s.time)})).filter(s=>Number.isFinite(s.t)).sort((s,l)=>l.t-s.t).map(s=>s.m),r=t.length>0?t:[...o].reverse();for(let s of r){let l=s.sender;if(l===n)return"me";if(l!=="Unknown"&&l!=="")return"them"}return"them"}async function Je(e){let n=Z.join(e,"conversations.json"),o=Me(n);if(!o){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let t=process.env.LINKEDIN_NAME;if(!t||typeof t!="string"||!t.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let r=0,s=0,l=0;for(let g of Object.keys(o)){let a=o[g];if(!a||typeof a!="object")continue;Object.prototype.hasOwnProperty.call(a,"_cardSynced")&&(delete a._cardSynced,s++);let f=Array.isArray(a.messages)?a.messages:[],p=Ue(f,t),k=p==="me"?"awaiting_reply":"unanswered_by_us";a.lastMessageBy!==p&&l++,a.lastMessageBy=p,a.conversationStatus=k,r++}if(r===0){console.log(" No conversations to recompute.");return}Pe(n,o),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${l} had stale lastMessageBy (now corrected).`),s>0&&console.log(` Cleaned ${s} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var H={};P(H,{NAME:()=>Ve,VERSION:()=>Be,up:()=>Ye});import*as I from"fs";import*as ee from"path";var Be=4,Ve="split-connection-timestamps",qe=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function We(e){if(!I.existsSync(e))return null;let n=I.readFileSync(e,"utf-8");return n.charCodeAt(0)===65279&&(n=n.slice(1)),JSON.parse(n)}function Ge(e,n){let o=JSON.stringify(n,null,2),t=e+".tmp";try{I.writeFileSync(t,o)}catch(r){try{I.unlinkSync(t)}catch{}throw r}try{I.renameSync(t,e)}catch(r){try{I.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Ye(e){let n=ee.join(e,"people.json"),o=We(n);if(!o||typeof o!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let t=0,r=0;for(let s of Object.keys(o)){let l=o[s];!l||typeof l!="object"||(r++,qe.has(l.connectionStatus)&&l.connectionDate&&!l.requestedConnectionAt&&(l.requestedConnectionAt=l.connectionDate,l.connectionDate=null,t++))}if(t===0){console.log(` Scanned ${r} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}Ge(n,o),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${t} still-pending people (of ${r} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}import{getPluginConfig as ze}from"@ilivemylife/graph-sdk";var He={day:"r86400","24h":"r86400",today:"r86400",week:"r604800","7d":"r604800",month:"r2592000","30d":"r2592000"},oe=e=>/^(1|true|yes|on)$/i.test(String(e??"").trim());function Ke(e){return String(e??"").split(/[,\s|]+/).map(n=>n.trim()).filter(Boolean)}function ne(e=process.env){let n=(e.JOB_SEARCH_KEYWORDS||"").trim();if(!n)return null;let o=new URLSearchParams;o.set("keywords",n);let t=(e.JOB_SEARCH_LOCATION||"").trim();t&&o.set("location",t);let r=(e.JOB_SEARCH_GEO_ID||"").trim();r&&o.set("geoId",r);let s=parseInt(e.JOB_SEARCH_RADIUS_MILES,10);Number.isFinite(s)&&s>0&&o.set("distance",String(s)),oe(e.JOB_SEARCH_EASY_APPLY)&&o.set("f_AL","true"),oe(e.JOB_SEARCH_IN_NETWORK)&&o.set("f_JIYN","true");let l=Ke(e.JOB_SEARCH_COMPANY_IDS);l.length&&o.set("f_C",l.join(","));let g=(e.JOB_SEARCH_DATE_POSTED||"").trim().toLowerCase();g&&o.set("f_TPR",He[g]||g),o.set("origin","JOB_SEARCH_PAGE_JOB_FILTER");let a="https://www.linkedin.com/jobs/search/?"+o.toString(),f=(e.JOB_SEARCH_EXTRA_PARAMS||"").trim().replace(/^[?&]+/,"");return f&&(a+="&"+f),a}var Qe=await ze();for(let[e,n]of Object.entries(Qe))process.env[e]===void 0&&(process.env[e]=n);var te=ne(process.env);te&&(process.env.LINKEDIN_SEARCH_URL=te);var xo=process.env.LINKEDIN_NAME,D=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Fo=Object.freeze(new Set([D.DRAFT,D.CONFIRMED,D.NEEDS_REVIEW])),Lo=Object.freeze(new Set([D.DRAFT,D.CONFIRMED,D.REJECTED,D.NEEDS_REVIEW]));import"dotenv/config";import*as S from"path";import{fileURLToPath as Xe}from"url";var Ze=Xe(import.meta.url),eo=S.dirname(S.dirname(Ze)),T=process.env.DATA_DIR?S.resolve(process.env.DATA_DIR,"collected-profiles"):S.join(eo,"collected-profiles"),Bo=S.join(T,"people.json"),Vo=S.join(T,"jobs.json"),qo=S.join(T,"quota.json"),Wo=S.join(T,"conversations.json"),Go=S.join(T,"sync-state.json"),Yo=S.join(T,"application-questions.json"),Ho=S.join(T,"profile-history"),re=(e,n)=>{let o=parseInt(e,10);return Number.isInteger(o)&&o>=0?o:n},Ko=re(process.env.CONNECT_MAX_DAILY,20),zo=re(process.env.CONNECT_MAX_WEEKLY,100),oo=null,no=null,to=null,ro=null,so=null,io=null;function se(){oo=null,no=null,to=null,ro=null,so=null,io=null}import"dotenv/config";import*as w from"path";import{fileURLToPath as lo}from"url";var co=lo(import.meta.url),ao=w.dirname(w.dirname(co)),L=process.env.DATA_DIR?w.resolve(process.env.DATA_DIR,"market-research"):w.join(ao,"market-research"),rn=w.join(L,"scouted-jobs.json"),sn=w.join(L,"discovered-people.json"),ln=w.join(L,"visit-log.json"),cn=w.join(L,"companies.json"),an=w.join(L,"job-decisions.json");function ie(){uo=null,fo=null,po=null,mo=null,ho=null}var uo=null;var fo=null;var po=null;var mo=null;var ho=null;var yo=go(import.meta.url),So=c.dirname(yo),bo=c.dirname(c.dirname(So));function ko(e){return e&&(e==="~"?K.homedir():e.startsWith("~/")||e.startsWith("~\\")?c.join(K.homedir(),e.slice(2)):e)}var b=process.env.DATA_DIR?c.resolve(ko(process.env.DATA_DIR)):bo,R=c.join(b,"collected-profiles"),_=c.join(b,"market-research"),h=c.join(b,".schema-version"),le=[c.join(R,".schema-version"),c.join(_,".schema-version")],J=4,C=[{version:1,module:W},{version:2,module:G},{version:3,module:Y},{version:4,module:H}];(function(){C.sort((t,r)=>t.version-r.version);let n=new Set;for(let t of C){if(!Number.isInteger(t.version)||t.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(t.version)} (must be positive integer)`);if(n.has(t.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${t.version}`);n.add(t.version);let r=t.module;if(!r||typeof r.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(r.VERSION!==void 0&&r.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${r.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let o=C.length?C[C.length-1].version:0;if(o!==J)throw new Error(`MIGRATION_REGISTRY: highest version v${o} but CURRENT_SCHEMA_VERSION=${J}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<C.length;t++){let r=t+1;if(C[t].version!==r)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${r} at position ${t} but found v${C[t].version}`)}})();function fe(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
2
2
|
[FATAL] DATA_DIR is set to whitespace ("${process.env.DATA_DIR}"). Either unset it or set a real path.
|
|
3
|
-
`),process.exit(1));try{i.mkdirSync(
|
|
4
|
-
[FATAL] Cannot create DATA_DIR (${
|
|
5
|
-
`),process.exit(1))}let e;try{e=i.statSync(
|
|
6
|
-
[FATAL] DATA_DIR (${
|
|
3
|
+
`),process.exit(1));try{i.mkdirSync(b,{recursive:!0})}catch(n){n.code!=="EEXIST"&&(console.error(`
|
|
4
|
+
[FATAL] Cannot create DATA_DIR (${b}): ${n.message}`),console.error(` Fix the path or permissions and try again.
|
|
5
|
+
`),process.exit(1))}let e;try{e=i.statSync(b)}catch(n){console.error(`
|
|
6
|
+
[FATAL] DATA_DIR (${b}) is not accessible: ${n.message}
|
|
7
7
|
`),process.exit(1)}e.isDirectory()||(console.error(`
|
|
8
|
-
[FATAL] DATA_DIR (${
|
|
9
|
-
`),process.exit(1));for(let
|
|
10
|
-
[FATAL] Data subdirectory is a symbolic link: ${
|
|
11
|
-
`),process.exit(1))}}var
|
|
12
|
-
[FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${
|
|
8
|
+
[FATAL] DATA_DIR (${b}) exists but is NOT a directory.`),console.error(` Looks like a typo \u2014 your DATA_DIR points at a file. Fix the path and try again.
|
|
9
|
+
`),process.exit(1));for(let n of[R,_]){let o;try{o=i.lstatSync(n)}catch(t){if(t.code==="ENOENT")continue;throw t}o.isSymbolicLink()&&(console.error(`
|
|
10
|
+
[FATAL] Data subdirectory is a symbolic link: ${n}`),console.error(" Refusing to follow \u2014 backup code would copy whatever the link points at."),console.error(` If this is intentional, replace the symlink with the real directory.
|
|
11
|
+
`),process.exit(1))}}var x=c.join(b,".migration-lock");function pe(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return i.writeFileSync(x,e,{flag:"wx"}),!0}catch(t){if(t.code!=="EEXIST")throw t}let n;try{n=JSON.parse(i.readFileSync(x,"utf-8"))}catch{n=null}if(n&&Number.isInteger(n.pid)){let t=!1;try{process.kill(n.pid,0),t=!0}catch(l){l.code==="EPERM"&&(t=!0)}let r=24*60*60*1e3,s=1/0;if(n.startedAt){let l=Date.parse(n.startedAt);Number.isNaN(l)||(s=Date.now()-l)}t&&s<r&&(console.error(`
|
|
12
|
+
[FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${n.pid}`),console.error(` Started at: ${n.startedAt||"(unknown)"}`),console.error(` Lock file: ${x}
|
|
13
13
|
`),console.error(" Wait for it to finish, or if you're sure it's not actually running,"),console.error(` delete the lock file manually and re-run.
|
|
14
|
-
`),process.exit(1)),t&&s>=r&&console.log(` Lock holder PID ${
|
|
15
|
-
[FATAL] Legacy .schema-version file(s) corrupted \u2014 cannot determine current schema version:`);for(let s of
|
|
14
|
+
`),process.exit(1)),t&&s>=r&&console.log(` Lock holder PID ${n.pid} is alive but lock is older than 24h \u2014 assuming PID reuse, taking over.`)}console.log(` Stale migration lock from PID ${n?.pid??"?"} found \u2014 taking over.`);let o=x+".tmp";try{return i.writeFileSync(o,e),i.renameSync(o,x),!0}catch(t){try{i.unlinkSync(o)}catch{}throw new Error(`Failed to take over stale migration lock: ${t.message}`)}}function M(){try{if(JSON.parse(i.readFileSync(x,"utf-8")).pid!==process.pid)return;i.unlinkSync(x)}catch{}}var ce=!1;function de(){if(ce)return;ce=!0;let e=()=>{try{M()}catch{}process.exit(1)};for(let n of["SIGINT","SIGTERM","SIGHUP"])try{process.on(n,e)}catch{}}function vo(){if(i.existsSync(h))return;let e=[],n=[];for(let s of le)if(i.existsSync(s))try{e.push({file:s,schema:B(s)})}catch(l){n.push({file:s,err:l.message})}if(n.length>0){console.error(`
|
|
15
|
+
[FATAL] Legacy .schema-version file(s) corrupted \u2014 cannot determine current schema version:`);for(let s of n)console.error(` ${s.file}: ${s.err}`);console.error(`
|
|
16
16
|
Repair the file(s) (likely just an integer 'version' field \u2014 see another working DATA_DIR`),console.error(` or default to {"version":1,"migrations":[]} if you're sure you're on schema v1) and try again.
|
|
17
|
-
`),process.exit(1)}if(e.length===0)return;let
|
|
17
|
+
`),process.exit(1)}if(e.length===0)return;let o=e.map(s=>s.schema.version);if(new Set(o).size>1){console.error(`
|
|
18
18
|
[FATAL] Legacy .schema-version files disagree:`);for(let s of e)console.error(` ${s.file}: v${s.schema.version}`);console.error(" This means a previous migration crashed between writing the two files."),console.error(` Reconcile manually (delete the wrong one, keep the right one), then re-run.
|
|
19
|
-
`),process.exit(1)}let t=e[0].schema,r=h+".tmp";try{i.writeFileSync(r,JSON.stringify(t,null,2)),i.renameSync(r,h)}catch(s){try{i.unlinkSync(r)}catch{}throw s}for(let s of
|
|
20
|
-
[FATAL] ${h} is not valid JSON: ${
|
|
21
|
-
`),process.exit(1)}let
|
|
19
|
+
`),process.exit(1)}let t=e[0].schema,r=h+".tmp";try{i.writeFileSync(r,JSON.stringify(t,null,2)),i.renameSync(r,h)}catch(s){try{i.unlinkSync(r)}catch{}throw s}for(let s of le)if(i.existsSync(s))try{i.unlinkSync(s)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${h}`)}function wo(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let n=Number(e.version);return!Number.isFinite(n)||n<0||!Number.isInteger(n)?null:(e.version=n,Array.isArray(e.migrations)||(e.migrations=[]),e)}function B(e){let n=i.readFileSync(e,"utf-8");return n.charCodeAt(0)===65279&&(n=n.slice(1)),JSON.parse(n)}function z(){if(vo(),!i.existsSync(h))return{version:0,migrations:[]};let e;try{e=B(h)}catch(o){if(o.code==="ENOENT")return{version:0,migrations:[]};console.error(`
|
|
20
|
+
[FATAL] ${h} is not valid JSON: ${o.message}`),console.error(" Refusing to proceed \u2014 silently treating it as 'fresh install' would re-apply"),console.error(" every migration on top of already-migrated data and corrupt it."),console.error(' Repair the file (set it to {"version":N,"migrations":[...]} matching your real state)'),console.error(` or restore from the *.pre-vNNN.backup files if you have them.
|
|
21
|
+
`),process.exit(1)}let n=wo(e);return n===null&&(console.error(`
|
|
22
22
|
[FATAL] ${h} has invalid structure:`),console.error(` ${JSON.stringify(e)?.slice(0,200)||"(unparseable)"}`),console.error(' Expected shape: { "version": <integer>, "migrations": [...] }'),console.error(` Repair the file or restore from a backup.
|
|
23
|
-
`),process.exit(1)),
|
|
23
|
+
`),process.exit(1)),n}function me(e){try{i.chmodSync(e,384)}catch{}}function Ao(e){if(fe(),i.existsSync(h))try{if(i.lstatSync(h).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${h}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(o){if(o.message?.includes("symbolic link"))throw o}let n=h+".tmp";try{i.writeFileSync(n,JSON.stringify(e,null,2)),me(n),i.renameSync(n,h)}catch(o){try{i.unlinkSync(n)}catch{}throw o}}function ae(e,n){return i.existsSync(e)?i.readdirSync(e).filter(o=>o.endsWith(n)):[]}var Eo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function jo(e){let n=e.toLowerCase();return Eo.some(o=>o.test(n))}var $o=6e4;function he(){let e=Date.now(),n=[];for(let o of[b,R,_]){if(!i.existsSync(o))continue;let t;try{t=i.readdirSync(o)}catch{continue}for(let r of t){if(!jo(r))continue;let s=c.join(o,r);try{let l=i.statSync(s);if(!l.isFile()||e-l.mtimeMs<$o)continue;n.push({dir:o,file:r,fullPath:s})}catch{}}}return n}function Io({verbose:e=!1}={}){let n=he();if(n.length===0)return e&&console.log(" No orphan .tmp files found."),0;let o=0;for(let t of n)try{i.unlinkSync(t.fullPath),o++,e&&console.log(` Removed orphan: ${c.basename(t.dir)}/${t.file}`)}catch(r){console.warn(` [!] Could not remove orphan ${t.fullPath}: ${r.message}`)}return!e&&o>0&&console.log(` Cleaned up ${o} orphan .tmp file(s) from previous run.`),o}function ge(){let e=[];for(let n of[R,_])if(i.existsSync(n))for(let o of i.readdirSync(n))/\.pre-rollback-v\d+\.backup$/.test(o)&&e.push({dir:n,file:o,fullPath:c.join(n,o)});return e}function ye({removePreRollback:e=!0}={}){if(console.log(`
|
|
24
24
|
\u{1F4E6} Data cleanup
|
|
25
|
-
`),!i.existsSync(
|
|
26
|
-
`);return}
|
|
25
|
+
`),!i.existsSync(b)){console.log(` DATA_DIR not yet created (${b}) \u2014 nothing to clean.
|
|
26
|
+
`);return}fe();let n=!1;try{de(),pe(),n=!0,process.on("exit",()=>{n&&M()})}catch(r){console.error(`
|
|
27
27
|
[ERROR] Could not acquire cleanup lock: ${r.message}
|
|
28
|
-
`),process.exit(1)}let
|
|
29
|
-
Done. Removed ${
|
|
30
|
-
`)}function
|
|
28
|
+
`),process.exit(1)}let o=Io({verbose:!0}),t=0;if(e){let r=ge();if(r.length===0)console.log(" No pre-rollback snapshots found.");else for(let s of r)try{i.unlinkSync(s.fullPath),t++,console.log(` Removed pre-rollback snapshot: ${c.basename(s.dir)}/${s.file}`)}catch(l){console.warn(` [!] Could not remove ${s.fullPath}: ${l.message}`)}}n&&(M(),n=!1),console.log(`
|
|
29
|
+
Done. Removed ${o} orphan .tmp + ${t} pre-rollback snapshot(s).`),console.log(` NOTE: .pre-vNNN.backup files are kept \u2014 they're needed for 'rollback-data'.
|
|
30
|
+
`)}function Oo(){let e=[];for(let n of[R,_]){if(!i.existsSync(n))continue;let o=i.readdirSync(n).filter(t=>{let r=t.toLowerCase();return r.endsWith(".json")&&!r.includes(".backup")});for(let t of o){let r=c.join(n,t);try{B(r)}catch(s){e.push({dir:c.basename(n),file:t,err:s.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function ue(e,n){let o=n+".tmp";try{i.copyFileSync(e,o),me(o)}catch(t){try{i.unlinkSync(o)}catch{}throw t}try{i.renameSync(o,n)}catch(t){try{i.unlinkSync(o)}catch{}if(t.code==="EPERM"||t.code==="EBUSY"){let r=new Error(`File locked: ${n} (${t.code}). On Windows this is usually antivirus / Search Indexer / the file open in another app. Close anything that might be holding it and re-run.`);throw r.code=t.code,r}throw t}}function Se(){console.log(`
|
|
31
31
|
\u{1F4E6} Migration status
|
|
32
|
-
`);let e=
|
|
32
|
+
`);let e=z();if(console.log(` Data root: ${b}`),console.log(` Schema file: ${h}${i.existsSync(h)?"":" (not yet created \u2014 fresh install)"}`),console.log(` Current version: v${e.version}`),e.migrations?.length){console.log(" Applied migrations:");for(let s of e.migrations){if(!s||typeof s!="object"){console.log(` (malformed entry: ${JSON.stringify(s)})`);continue}let l=String(s.version??"?").padStart(3,"0");console.log(` v${l} \u2014 ${s.name??"(no name)"} (at ${s.appliedAt??"?"})`)}}e.rolledBackAt&&console.log(` Last rollback: ${e.rolledBackAt}`);for(let[s,l]of[["collected-profiles",R],["market-research",_]]){if(!i.existsSync(l))continue;let g=i.readdirSync(l).filter(a=>/\.pre-v\d+\.backup$/.test(a));if(g.length){let a=[...new Set(g.map(f=>f.match(/\.pre-v(\d+)\.backup$/)[1]))].sort();console.log(` Pre-migration backups in ${s}/: ${a.map(f=>`v${f} (${g.filter(p=>p.includes(`pre-v${f}`)).length} files)`).join(", ")}`)}}let n=ge();n.length>0&&console.log(` Pre-rollback snapshots: ${n.length} file(s) (run 'data-cleanup' to remove)`);let o=he();if(o.length>0){console.log(` Orphan .tmp files: ${o.length} (will be cleaned on next plugin run, or now via 'data-cleanup')`);for(let s of o)console.log(` ${c.basename(s.dir)}/${s.file}`)}console.log(),console.log(` Latest available schema: v${J}`);let t=C.filter(s=>s.version>e.version);t.length?(console.log(` Pending: ${t.map(s=>`v${String(s.version).padStart(3,"0")}`).join(", ")}`),console.log(" Run any plugin command (e.g. 'ilml linkedin today') to apply pending migrations.")):console.log(" \u2713 Up to date."),console.log();let r=Oo();if(r.ok)console.log(" Data integrity: \u2713 all JSON files parse cleanly");else{console.log(` Data integrity: \u2717 ${r.broken.length} file(s) corrupted:`);for(let s of r.broken)console.log(` ${s.dir}/${s.file}: ${s.err}`);console.log(" Migrations will refuse to run until these are repaired.")}console.log()}async function be({confirmed:e=!1}={}){let o=z().version;if(o===0){console.log(`
|
|
33
33
|
No migrations applied \u2014 nothing to roll back.
|
|
34
|
-
`);return}let t=!1,r=`.pre-v${String(
|
|
35
|
-
[ERROR] No backup files (${r}) found in either data directory.`),console.error(` Cannot roll back v${
|
|
34
|
+
`);return}let t=!1,r=`.pre-v${String(o).padStart(3,"0")}.backup`,s=ae(R,r),l=ae(_,r);if(s.length+l.length===0&&(console.error(`
|
|
35
|
+
[ERROR] No backup files (${r}) found in either data directory.`),console.error(` Cannot roll back v${o} \u2014 backups may have been deleted.
|
|
36
36
|
`),process.exit(1)),!e){console.log(`
|
|
37
37
|
\u26A0 rollback-data ONLY rolls back DATA, NOT the plugin code.
|
|
38
38
|
`),console.log(" The full rollback is a TWO-STEP procedure. Doing only step 1 leaves you"),console.log(` in a broken state where the next plugin run will re-apply the migration.
|
|
39
|
-
`),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(` STEP 1 (this command): roll back DATA schema v${
|
|
40
|
-
`),console.log(" Between step 1 and step 2: DO NOT run any 'ilml linkedin' command."),console.log(` The current plugin (CURRENT_SCHEMA_VERSION=${J}) will see your data on v${
|
|
41
|
-
`),console.log(" This step 1 will also:"),console.log(" - OVERWRITE current data with the pre-migration backup"),console.log(` (${s.length} files in collected-profiles/, ${l.length} in market-research/)`),console.log(` - Permanently LOSE any data changes made after migration v${
|
|
39
|
+
`),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(` STEP 1 (this command): roll back DATA schema v${o} \u2192 v${o-1}`),console.log(" STEP 2 (you, after): roll back CODE ilml plugin install linkedin@<previous>"),console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
40
|
+
`),console.log(" Between step 1 and step 2: DO NOT run any 'ilml linkedin' command."),console.log(` The current plugin (CURRENT_SCHEMA_VERSION=${J}) will see your data on v${o-1}`),console.log(` and immediately re-apply migration v${o}, undoing this rollback.
|
|
41
|
+
`),console.log(" This step 1 will also:"),console.log(" - OVERWRITE current data with the pre-migration backup"),console.log(` (${s.length} files in collected-profiles/, ${l.length} in market-research/)`),console.log(` - Permanently LOSE any data changes made after migration v${o}`),console.log(" (new conversations synced, drafts written, notes added \u2014 all gone)"),console.log(` - Snapshot current state to *.pre-rollback-v${String(o).padStart(3,"0")}.backup before overwriting
|
|
42
42
|
`),console.log(" If you only need to inspect old data without downgrading the plugin,"),console.log(" copy your DATA_DIR somewhere else and use that copy instead \u2014 leaves your"),console.log(` live setup untouched.
|
|
43
43
|
`),console.log(" Proceed with step 1? Re-run with --confirm:"),console.log(" npm run rollback:data -- --confirm"),console.log(` ilml linkedin rollback-data --confirm
|
|
44
|
-
`);return}
|
|
45
|
-
[FATAL] ${
|
|
46
|
-
Aborting rollback \u2014 without a complete snapshot of your CURRENT state, a`),console.error(' "change your mind" recovery would silently lose the data you have NOW.'),console.error(` Your current data is unchanged. Pre-rollback snapshots created so far: *${
|
|
47
|
-
`),process.exit(1)}console.log(` Snapshotted ${
|
|
48
|
-
[ERROR] ${d.length} backup file(s) are corrupted or unreadable:`);for(let
|
|
49
|
-
Aborting rollback BEFORE touching any original file \u2014`),console.error(" partial restore would leave the DB in an inconsistent state."),console.error(` Your current data is unchanged. Pre-rollback snapshots: *${
|
|
44
|
+
`);return}de(),pe(),t=!0,process.on("exit",()=>{t&&M()});let a=`.pre-rollback-v${String(o).padStart(3,"0")}.backup`,f=[],p=0;for(let u of[R,_]){if(!i.existsSync(u))continue;let F;try{F=i.readdirSync(u).filter(m=>{let A=m.toLowerCase();if(A.includes(".backup")||A===".schema-version"||A.endsWith(".tmp"))return!1;try{return i.statSync(c.join(u,m)).isFile()}catch{return!1}})}catch(m){f.push(`${c.basename(u)}: ${m.message}`);continue}for(let m of F)try{ue(c.join(u,m),c.join(u,m+a)),p++}catch(A){f.push(`${c.basename(u)}/${m}: ${A.message}`)}}if(f.length>0){console.error(`
|
|
45
|
+
[FATAL] ${f.length} file(s) could not be snapshotted:`);for(let u of f)console.error(` ${u}`);console.error(`
|
|
46
|
+
Aborting rollback \u2014 without a complete snapshot of your CURRENT state, a`),console.error(' "change your mind" recovery would silently lose the data you have NOW.'),console.error(` Your current data is unchanged. Pre-rollback snapshots created so far: *${a}`),console.error(" (run 'data-cleanup' to remove them, or retry the rollback once the underlying"),console.error(` issue is resolved \u2014 usually a transient file lock from antivirus or an editor).
|
|
47
|
+
`),process.exit(1)}console.log(` Snapshotted ${p} files \u2192 *${a} (in case you change your mind)`);let k=[],d=[];for(let[u,F]of[[R,s],[_,l]])for(let m of F){let A=c.join(u,m),Q=m.slice(0,-r.length),we=c.join(u,Q);try{Q.toLowerCase().endsWith(".json")?B(A):i.accessSync(A,i.constants.R_OK),k.push({backupPath:A,originalPath:we,fileName:m})}catch(Ae){d.push({file:m,dir:c.basename(u),err:Ae.message})}}if(d.length>0){console.error(`
|
|
48
|
+
[ERROR] ${d.length} backup file(s) are corrupted or unreadable:`);for(let u of d)console.error(` ${u.dir}/${u.file}: ${u.err}`);console.error(`
|
|
49
|
+
Aborting rollback BEFORE touching any original file \u2014`),console.error(" partial restore would leave the DB in an inconsistent state."),console.error(` Your current data is unchanged. Pre-rollback snapshots: *${a}
|
|
50
50
|
`),console.error(" Options:"),console.error(" - Restore the corrupted backup(s) from another source and re-run rollback"),console.error(` - Or accept the new schema and don't roll back
|
|
51
|
-
`),process.exit(1)}
|
|
51
|
+
`),process.exit(1)}k.length===0&&(console.error(`
|
|
52
52
|
[ERROR] No backup files found to restore. Aborting.
|
|
53
|
-
`),process.exit(1));let O=new Date().toISOString(),
|
|
54
|
-
[WARNING] ${
|
|
55
|
-
Schema has been lowered to v${
|
|
56
|
-
`),process.exit(1)}try{
|
|
57
|
-
\u2713 STEP 1 DONE. Restored ${
|
|
58
|
-
`),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(" \u26A0 STEP 2 REQUIRED \u2014 DO NOT RUN ANY 'ilml linkedin' COMMAND UNTIL"),console.log(` YOU DOWNGRADE THE PLUGIN CODE, or migration v${
|
|
53
|
+
`),process.exit(1));let O=new Date().toISOString(),N=z();N.version=o-1,N.migrations=(N.migrations||[]).filter(u=>u&&Number.isInteger(u.version)&&u.version<o),N.rolledBackAt=O,Ao(N);let y=0,v=[];for(let{backupPath:u,originalPath:F,fileName:m}of k)try{ue(u,F),y++}catch(A){v.push({fileName:m,err:A.message})}if(v.length>0){console.error(`
|
|
54
|
+
[WARNING] ${v.length} file(s) could not be restored:`);for(let u of v)console.error(` ${u.fileName}: ${u.err}`);console.error(`
|
|
55
|
+
Schema has been lowered to v${o-1} but data is in a mixed state:`),console.error(` ${y} files restored from backup`),console.error(` ${v.length} files still in their post-migration form`),console.error(` The next plugin run will detect pending migration v${o} and re-apply it,`),console.error(" re-converging the data \u2014 but if you intended to roll back, that's not what you want."),console.error(` Manual fix: copy the missing *${r} files back over their originals, then`),console.error(" re-run 'rollback-data --confirm' to redo the rollback. Pre-rollback snapshots"),console.error(` (*${a}) are still on disk if you'd rather restore the v${o} state.
|
|
56
|
+
`),process.exit(1)}try{se()}catch{}try{ie()}catch{}M(),t=!1,console.log(`
|
|
57
|
+
\u2713 STEP 1 DONE. Restored ${y} files. Data schema is now at v${o-1}.
|
|
58
|
+
`),console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"),console.log(" \u26A0 STEP 2 REQUIRED \u2014 DO NOT RUN ANY 'ilml linkedin' COMMAND UNTIL"),console.log(` YOU DOWNGRADE THE PLUGIN CODE, or migration v${o} will be re-applied`),console.log(" and this rollback will be silently undone."),console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
|
|
59
59
|
`),console.log(" Run NOW (or as soon as possible):"),console.log(` ilml plugin install linkedin@<previous-version>
|
|
60
|
-
`),console.log(` If something looks wrong, your pre-rollback snapshot is in *${
|
|
61
|
-
`)}var
|
|
60
|
+
`),console.log(` If something looks wrong, your pre-rollback snapshot is in *${a} files`),console.log(` \u2014 copy them back manually to undo this rollback.
|
|
61
|
+
`)}var ve=process.argv.slice(2),ke=ve[0],Co=ve.includes("--confirm");async function Ro(){switch(ke){case"status":Se();break;case"rollback-data":await be({confirmed:Co});break;case"data-cleanup":ye();break;default:console.log("Usage:"),console.log(" node migrationCli.mjs status Show schema state + leftover files"),console.log(" node migrationCli.mjs data-cleanup Remove .tmp orphans + pre-rollback snapshots"),console.log(" node migrationCli.mjs rollback-data Preview data rollback (read-only)"),console.log(" node migrationCli.mjs rollback-data --confirm Actually roll back data"),console.log(""),console.log("Note: rollback-data only touches DATA. To roll back the plugin code as well,"),console.log("also run: ilml plugin install linkedin@<previous-version>"),process.exit(ke?1:0)}}Ro().catch(e=>{console.error(`
|
|
62
62
|
[ERROR]`,e.message),process.env.VERBOSE&&console.error(e.stack),process.exit(1)});
|
package/dist/profileHistory.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import"dotenv/config";import*as
|
|
2
|
-
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`),console.log(` ${
|
|
3
|
-
`),
|
|
4
|
-
HISTORY (${
|
|
5
|
-
`);for(let r of
|
|
1
|
+
import"dotenv/config";import*as f from"fs";import*as g from"path";import{getPluginConfig as N}from"@ilivemylife/graph-sdk";var x={day:"r86400","24h":"r86400",today:"r86400",week:"r604800","7d":"r604800",month:"r2592000","30d":"r2592000"},D=e=>/^(1|true|yes|on)$/i.test(String(e??"").trim());function k(e){return String(e??"").split(/[,\s|]+/).map(t=>t.trim()).filter(Boolean)}function O(e=process.env){let t=(e.JOB_SEARCH_KEYWORDS||"").trim();if(!t)return null;let n=new URLSearchParams;n.set("keywords",t);let s=(e.JOB_SEARCH_LOCATION||"").trim();s&&n.set("location",s);let o=(e.JOB_SEARCH_GEO_ID||"").trim();o&&n.set("geoId",o);let l=parseInt(e.JOB_SEARCH_RADIUS_MILES,10);Number.isFinite(l)&&l>0&&n.set("distance",String(l)),D(e.JOB_SEARCH_EASY_APPLY)&&n.set("f_AL","true"),D(e.JOB_SEARCH_IN_NETWORK)&&n.set("f_JIYN","true");let r=k(e.JOB_SEARCH_COMPANY_IDS);r.length&&n.set("f_C",r.join(","));let i=(e.JOB_SEARCH_DATE_POSTED||"").trim().toLowerCase();i&&n.set("f_TPR",x[i]||i),n.set("origin","JOB_SEARCH_PAGE_JOB_FILTER");let u="https://www.linkedin.com/jobs/search/?"+n.toString(),h=(e.JOB_SEARCH_EXTRA_PARAMS||"").trim().replace(/^[?&]+/,"");return h&&(u+="&"+h),u}var v=await N();for(let[e,t]of Object.entries(v))process.env[e]===void 0&&(process.env[e]=t);var b=O(process.env);b&&(process.env.LINKEDIN_SEARCH_URL=b);var Z=process.env.LINKEDIN_NAME,S=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),ee=Object.freeze(new Set([S.DRAFT,S.CONFIRMED,S.NEEDS_REVIEW])),ne=Object.freeze(new Set([S.DRAFT,S.CONFIRMED,S.REJECTED,S.NEEDS_REVIEW]));import"dotenv/config";import*as c from"fs";import*as a from"path";import{fileURLToPath as L}from"url";var J=L(import.meta.url),P=a.dirname(a.dirname(J)),p=process.env.DATA_DIR?a.resolve(process.env.DATA_DIR,"collected-profiles"):a.join(P,"collected-profiles"),M=a.join(p,"people.json"),ie=a.join(p,"jobs.json"),le=a.join(p,"quota.json"),ce=a.join(p,"conversations.json"),ae=a.join(p,"sync-state.json"),ue=a.join(p,"application-questions.json"),H=a.join(p,"profile-history"),I=(e,t)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:t},pe=I(process.env.CONNECT_MAX_DAILY,20),fe=I(process.env.CONNECT_MAX_WEEKLY,100),A=null;function U(){c.existsSync(p)||c.mkdirSync(p,{recursive:!0})}function R(e,t){if(!c.existsSync(e))return null;try{let n=JSON.parse(c.readFileSync(e,"utf-8"));try{c.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${t} is corrupted: ${n.message}`),console.error(` File: ${a.resolve(e)}`);let s=e+".backup";if(c.existsSync(s))try{let o=JSON.parse(c.readFileSync(s,"utf-8"));console.error(` Restored from ${s}`);try{c.copyFileSync(s,e)}catch{}return o}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{c.copyFileSync(e,e+".corrupted")}catch{}return null}}function m(e){if(!e)return null;let t=e.match(/\/in\/([^/?#]+)/);return t?t[1].toLowerCase():null}function W(e){let t=m(e);return t?a.join(H,`${t}.json`):null}function $(e){let t=W(e);return t?R(t,`profile-history/${m(e)}.json`)||[]:[]}function y(){return A||(U(),A=R(M,"people.json")||{},A)}var C=process.argv.slice(2),B=C.includes("--all"),E=C.find(e=>e.startsWith("--since="))?.split("=")[1]||null,d=C.find(e=>e.startsWith("--field="))?.split("=")[1]||null,T=C.find(e=>!e.startsWith("--"))||null,V=process.env.DATA_DIR?g.resolve(process.env.DATA_DIR,"collected-profiles"):g.join(process.cwd(),"collected-profiles"),j=g.join(V,"profile-history");function F(){return f.existsSync(j)?f.readdirSync(j).filter(e=>e.endsWith(".json")).map(e=>e.replace(/\.json$/,"")):[]}function q(e){let t=y();for(let n of Object.keys(t))if(m(n)===e)return n;return null}function Y(e){let t=e.startsWith("http")?m(e):e.toLowerCase();if(!t){console.log("Could not derive slug");return}let n=q(t),s=y(),o=n?s[n]:null,l=n?$(n):(()=>{let r=g.join(j,`${t}.json`);return f.existsSync(r)?JSON.parse(f.readFileSync(r,"utf-8")):[]})();console.log(`
|
|
2
|
+
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550`),console.log(` ${o?.name||"(unknown)"} \u2014 ${t}`),console.log(`\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
3
|
+
`),o&&(console.log("CURRENT:"),console.log(` title: ${o.title||"(null)"}`),console.log(` location: ${o.location||"(null)"}`),console.log(` currentCompany: ${o.currentCompany||"(null)"}`),console.log(` connectionDeg: ${o.connectionDegree||"(null)"}`),console.log(` openToWork: ${o.openToWork}`),console.log(` hiring: ${o.hiring}`),console.log(` lastUpdated: ${o.lastUpdated||"(null)"}`),console.log(` lastSnapshotAt: ${o.lastSnapshotAt||"(null)"}`)),console.log(`
|
|
4
|
+
HISTORY (${l.length} snapshot${l.length===1?"":"s"}):
|
|
5
|
+
`);for(let r of l){if(console.log(` ${r.capturedAt} changed: [${(r.changedFields||[]).join(", ")}]`),r.snapshot)for(let i of r.changedFields||[]){let u=r.snapshot[i],h=o?o[i]:"?",w=_=>Array.isArray(_)?_.join(", "):_??"(null)";console.log(` ${i.padEnd(18)} OLD: ${w(u)}`),console.log(` ${" ".repeat(18)} NEW: ${w(h)}`)}console.log()}}function Q(){let e=F();console.log(`
|
|
6
6
|
${e.length} profiles have history files:
|
|
7
|
-
`);let
|
|
8
|
-
${s.length} change events since ${
|
|
9
|
-
`);for(let
|
|
7
|
+
`);let t=y(),n=[];for(let s of e){let o=Object.keys(t).find(u=>m(u)===s),l=o?t[o]:null,r=g.join(j,`${s}.json`),i=JSON.parse(f.readFileSync(r,"utf-8"));n.push({slug:s,name:l?.name||"(unknown)",snapshots:i.length,mostRecentChange:i[0]?.capturedAt||null,mostRecentFields:i[0]?.changedFields?.join(", ")||""})}n.sort((s,o)=>(o.mostRecentChange||"").localeCompare(s.mostRecentChange||""));for(let s of n)console.log(` ${s.mostRecentChange?.slice(0,10)||"----------"} ${s.snapshots}\xD7 ${s.name.padEnd(28)} [${s.mostRecentFields}]`)}function K(){let e=F(),t=new Date(E).getTime(),n=y(),s=[];for(let o of e){let l=g.join(j,`${o}.json`),r=JSON.parse(f.readFileSync(l,"utf-8"));for(let i of r){if(new Date(i.capturedAt).getTime()<t||d&&!(i.changedFields||[]).includes(d))continue;let u=Object.keys(n).find(h=>m(h)===o);s.push({date:i.capturedAt,slug:o,name:(u?n[u]:null)?.name||"(unknown)",fields:(i.changedFields||[]).join(", "),...d?{oldValue:i.snapshot?.[d],newValue:(u?n[u]:null)?.[d]}:{}})}}s.sort((o,l)=>l.date.localeCompare(o.date)),console.log(`
|
|
8
|
+
${s.length} change events since ${E}${d?` (field=${d})`:""}:
|
|
9
|
+
`);for(let o of s)if(console.log(` ${o.date.slice(0,10)} ${o.name.padEnd(28)} [${o.fields}]`),d){let l=r=>Array.isArray(r)?r.join(", "):r??"(null)";console.log(` OLD: ${l(o.oldValue)}`),console.log(` NEW: ${l(o.newValue)}`)}}T?Y(T):B?Q():E?K():(console.log("Usage:"),console.log(" node profileHistory.mjs <slug-or-url>"),console.log(" node profileHistory.mjs --all"),console.log(" node profileHistory.mjs --since=YYYY-MM-DD [--field=NAME]"));
|
package/dist/quota.mjs
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
var _e=Object.defineProperty;var B=(e,o)=>{for(var n in o)_e(e,n,{get:o[n],enumerable:!0})};import{getPluginConfig as Fe}from"@ilivemylife/graph-sdk";var Le=await Fe();for(let[e,o]of Object.entries(Le))process.env[e]===void 0&&(process.env[e]=o);var Ko=process.env.LINKEDIN_NAME,D=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Qo=Object.freeze(new Set([D.DRAFT,D.CONFIRMED,D.NEEDS_REVIEW])),Xo=Object.freeze(new Set([D.DRAFT,D.CONFIRMED,D.REJECTED,D.NEEDS_REVIEW]));import"dotenv/config";import*as d from"fs";import*as h from"path";import{fileURLToPath as Me}from"url";var Ue=Me(import.meta.url),Pe=h.dirname(h.dirname(Ue)),E=process.env.DATA_DIR?h.resolve(process.env.DATA_DIR,"collected-profiles"):h.join(Pe,"collected-profiles"),Je=h.join(E,"people.json"),tn=h.join(E,"jobs.json"),Be=h.join(E,"quota.json"),rn=h.join(E,"conversations.json"),sn=h.join(E,"sync-state.json"),ln=h.join(E,"application-questions.json"),cn=h.join(E,"profile-history"),ae=(e,o)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:o},le=ae(process.env.CONNECT_MAX_DAILY,20),ce=ae(process.env.CONNECT_MAX_WEEKLY,100),M=null,qe=null,C=null,Ve=null,We=null,Ge=null;function ue(){M=null,qe=null,C=null,Ve=null,We=null,Ge=null}function fe(){d.existsSync(E)||d.mkdirSync(E,{recursive:!0})}function pe(e,o){if(!d.existsSync(e))return null;try{let n=JSON.parse(d.readFileSync(e,"utf-8"));try{d.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${o} is corrupted: ${n.message}`),console.error(` File: ${h.resolve(e)}`);let t=e+".backup";if(d.existsSync(t))try{let r=JSON.parse(d.readFileSync(t,"utf-8"));console.error(` Restored from ${t}`);try{d.copyFileSync(t,e)}catch{}return r}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{d.copyFileSync(e,e+".corrupted")}catch{}return null}}function Ye(){return new Date().toISOString().split("T")[0]}function Y(e){if(!e)return null;let o=e.match(/\/in\/([^/?#]+)/);return o?o[1].toLowerCase():null}function de(){return M||(fe(),M=pe(Je,"people.json")||{},M)}function H(){return C||(fe(),C=pe(Be,"quota.json"),(!C||!C.connections)&&(C={connections:[]}),C)}function He(){let e=H(),o=new Date;o.setDate(o.getDate()-7);let n=o.toISOString().split("T")[0];return e.connections.filter(t=>t.date>=n)}function he(){let e=He(),o=Ye(),n=e.filter(r=>r.date===o).length,t=e.length;return{daily:{sent:n,max:le,remaining:le-n},weekly:{sent:t,max:ce,remaining:ce-t}}}import"dotenv/config";import*as i from"fs";import*as ne from"os";import*as u from"path";import{fileURLToPath as Io}from"url";var Q={};B(Q,{NAME:()=>Ke,VERSION:()=>ze,up:()=>Ze});import*as S from"fs";import*as q from"path";var ze=1,Ke="normalize-jobs-and-questions",Qe=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Xe=50;function z(e){return S.existsSync(e)?JSON.parse(S.readFileSync(e,"utf-8")):null}function K(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{S.writeFileSync(t,n)}catch(r){try{S.unlinkSync(t)}catch{}throw r}try{S.renameSync(t,e)}catch(r){try{S.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Ze(e,o){let n=q.join(e,"jobs.json"),t=q.join(o,"scouted-jobs.json"),r=q.join(e,"application-questions.json"),s=z(n)||{},l=z(t)||{},a=0,c=[];for(let f of Object.keys(s)){if(!l[f])continue;let v=l[f],m=s[f];for(let O of Qe)v[O]!=null&&m[O]==null&&(m[O]=v[O]);c.push(f),a++}a>0?(K(n,s),console.log(` Phase 1: Merged ${a} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let p=z(r);if(p&&Array.isArray(p.applications)){let f={},v=0;for(let m of p.applications){let O=m.jobId||"unknown";f[O]||(f[O]={applications:[]});let ie=(m.questions||[]).map(A=>{let L={type:A.type||"input",question:A.question||"",answer:A.answer||""};return A.options&&(A.options.length<=Xe?L.options=A.options:(L.optionsOmitted=!0,v++)),A.page&&(L.page=A.page),A.wasPreFilled&&(L.wasPreFilled=!0),A.wasRetry&&(L.wasRetry=!0),L});f[O].applications.push({applicationId:m.applicationId,date:m.date,result:m.result||"submitted",formPages:m.formPages||null,duration:m.duration||null,retries:m.retries||0,failedField:m.failedField||null,questionCount:m.questionCount||ie.length,questions:ie})}K(r,f),console.log(` Phase 2: Rekeyed ${p.applications.length} applications by jobId (${Object.keys(f).length} unique jobs)`),v>0&&console.log(` Phase 2: Stripped bloated options from ${v} questions`)}else p&&!p.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(c.length>0){for(let f of c)delete l[f];K(t,l),console.log(` Phase 3: Removed ${c.length} merged entries from scouted-jobs.json (${Object.keys(l).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var X={};B(X,{NAME:()=>oo,VERSION:()=>eo,up:()=>ro});import*as b from"fs";import*as me from"path";var eo=2,oo="reset-unread-flags";function no(e){return b.existsSync(e)?JSON.parse(b.readFileSync(e,"utf-8")):null}function to(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{b.writeFileSync(t,n)}catch(r){try{b.unlinkSync(t)}catch{}throw r}try{b.renameSync(t,e)}catch(r){try{b.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function ro(e){let o=me.join(e,"conversations.json"),n=no(o);if(!n){console.log(" conversations.json not found \u2014 nothing to reset.");return}let t=0;for(let r of Object.keys(n))n[r].unread===!0&&(n[r].unread=!1,t++);if(t===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}to(o,n),console.log(` Reset unread=false on ${t} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Z={};B(Z,{NAME:()=>io,VERSION:()=>so,up:()=>fo});import*as w from"fs";import*as ge from"path";var so=3,io="recompute-last-message-by",lo=new Set(["draft","confirmed","rejected","needs_review"]);function co(e){return w.existsSync(e)?JSON.parse(w.readFileSync(e,"utf-8")):null}function ao(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{w.writeFileSync(t,n)}catch(r){try{w.unlinkSync(t)}catch{}throw r}try{w.renameSync(t,e)}catch(r){try{w.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}function uo(e,o){if(!e||e.length===0)return"them";let n=e.filter(s=>!lo.has(s.status));if(n.length===0)return"them";let t=n.map(s=>({m:s,t:Date.parse(s.time)})).filter(s=>Number.isFinite(s.t)).sort((s,l)=>l.t-s.t).map(s=>s.m),r=t.length>0?t:[...n].reverse();for(let s of r){let l=s.sender;if(l===o)return"me";if(l!=="Unknown"&&l!=="")return"them"}return"them"}async function fo(e){let o=ge.join(e,"conversations.json"),n=co(o);if(!n){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let t=process.env.LINKEDIN_NAME;if(!t||typeof t!="string"||!t.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let r=0,s=0,l=0;for(let a of Object.keys(n)){let c=n[a];if(!c||typeof c!="object")continue;Object.prototype.hasOwnProperty.call(c,"_cardSynced")&&(delete c._cardSynced,s++);let p=Array.isArray(c.messages)?c.messages:[],f=uo(p,t),v=f==="me"?"awaiting_reply":"unanswered_by_us";c.lastMessageBy!==f&&l++,c.lastMessageBy=f,c.conversationStatus=v,r++}if(r===0){console.log(" No conversations to recompute.");return}ao(o,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${l} had stale lastMessageBy (now corrected).`),s>0&&console.log(` Cleaned ${s} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var ee={};B(ee,{NAME:()=>ho,VERSION:()=>po,up:()=>So});import*as k from"fs";import*as ye from"path";var po=4,ho="split-connection-timestamps",mo=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function go(e){if(!k.existsSync(e))return null;let o=k.readFileSync(e,"utf-8");return o.charCodeAt(0)===65279&&(o=o.slice(1)),JSON.parse(o)}function yo(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{k.writeFileSync(t,n)}catch(r){try{k.unlinkSync(t)}catch{}throw r}try{k.renameSync(t,e)}catch(r){try{k.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function So(e){let o=ye.join(e,"people.json"),n=go(o);if(!n||typeof n!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let t=0,r=0;for(let s of Object.keys(n)){let l=n[s];!l||typeof l!="object"||(r++,mo.has(l.connectionStatus)&&l.connectionDate&&!l.requestedConnectionAt&&(l.requestedConnectionAt=l.connectionDate,l.connectionDate=null,t++))}if(t===0){console.log(` Scanned ${r} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}yo(o,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${t} still-pending people (of ${r} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}import"dotenv/config";import*as y from"path";import{fileURLToPath as bo}from"url";var wo=bo(import.meta.url),ko=y.dirname(y.dirname(wo)),U=process.env.DATA_DIR?y.resolve(process.env.DATA_DIR,"market-research"):y.join(ko,"market-research"),gn=y.join(U,"scouted-jobs.json"),yn=y.join(U,"discovered-people.json"),Sn=y.join(U,"visit-log.json"),bn=y.join(U,"companies.json"),wn=y.join(U,"job-decisions.json");function Se(){vo=null,Ao=null,$o=null,jo=null,Eo=null}var vo=null;var Ao=null;var $o=null;var jo=null;var Eo=null;var Oo=Io(import.meta.url),Co=u.dirname(Oo),To=u.dirname(u.dirname(Co));function Ro(e){return e&&(e==="~"?ne.homedir():e.startsWith("~/")||e.startsWith("~\\")?u.join(ne.homedir(),e.slice(2)):e)}var $=process.env.DATA_DIR?u.resolve(Ro(process.env.DATA_DIR)):To,x=u.join($,"collected-profiles"),_=u.join($,"market-research"),g=u.join($,".schema-version"),be=[u.join(x,".schema-version"),u.join(_,".schema-version")],T=4,I=[{version:1,module:Q},{version:2,module:X},{version:3,module:Z},{version:4,module:ee}];(function(){I.sort((t,r)=>t.version-r.version);let o=new Set;for(let t of I){if(!Number.isInteger(t.version)||t.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(t.version)} (must be positive integer)`);if(o.has(t.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${t.version}`);o.add(t.version);let r=t.module;if(!r||typeof r.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(r.VERSION!==void 0&&r.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${r.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=I.length?I[I.length-1].version:0;if(n!==T)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${T}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<I.length;t++){let r=t+1;if(I[t].version!==r)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${r} at position ${t} but found v${I[t].version}`)}})();function Ae(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
1
|
+
var Me=Object.defineProperty;var B=(e,o)=>{for(var n in o)Me(e,n,{get:o[n],enumerable:!0})};import{getPluginConfig as Je}from"@ilivemylife/graph-sdk";var Pe={day:"r86400","24h":"r86400",today:"r86400",week:"r604800","7d":"r604800",month:"r2592000","30d":"r2592000"},ce=e=>/^(1|true|yes|on)$/i.test(String(e??"").trim());function Ue(e){return String(e??"").split(/[,\s|]+/).map(o=>o.trim()).filter(Boolean)}function le(e=process.env){let o=(e.JOB_SEARCH_KEYWORDS||"").trim();if(!o)return null;let n=new URLSearchParams;n.set("keywords",o);let t=(e.JOB_SEARCH_LOCATION||"").trim();t&&n.set("location",t);let r=(e.JOB_SEARCH_GEO_ID||"").trim();r&&n.set("geoId",r);let s=parseInt(e.JOB_SEARCH_RADIUS_MILES,10);Number.isFinite(s)&&s>0&&n.set("distance",String(s)),ce(e.JOB_SEARCH_EASY_APPLY)&&n.set("f_AL","true"),ce(e.JOB_SEARCH_IN_NETWORK)&&n.set("f_JIYN","true");let c=Ue(e.JOB_SEARCH_COMPANY_IDS);c.length&&n.set("f_C",c.join(","));let a=(e.JOB_SEARCH_DATE_POSTED||"").trim().toLowerCase();a&&n.set("f_TPR",Pe[a]||a),n.set("origin","JOB_SEARCH_PAGE_JOB_FILTER");let l="https://www.linkedin.com/jobs/search/?"+n.toString(),f=(e.JOB_SEARCH_EXTRA_PARAMS||"").trim().replace(/^[?&]+/,"");return f&&(l+="&"+f),l}var Be=await Je();for(let[e,o]of Object.entries(Be))process.env[e]===void 0&&(process.env[e]=o);var ae=le(process.env);ae&&(process.env.LINKEDIN_SEARCH_URL=ae);var tn=process.env.LINKEDIN_NAME,T=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),rn=Object.freeze(new Set([T.DRAFT,T.CONFIRMED,T.NEEDS_REVIEW])),sn=Object.freeze(new Set([T.DRAFT,T.CONFIRMED,T.REJECTED,T.NEEDS_REVIEW]));import"dotenv/config";import*as d from"fs";import*as h from"path";import{fileURLToPath as qe}from"url";var Ve=qe(import.meta.url),We=h.dirname(h.dirname(Ve)),j=process.env.DATA_DIR?h.resolve(process.env.DATA_DIR,"collected-profiles"):h.join(We,"collected-profiles"),Ge=h.join(j,"people.json"),fn=h.join(j,"jobs.json"),He=h.join(j,"quota.json"),pn=h.join(j,"conversations.json"),dn=h.join(j,"sync-state.json"),hn=h.join(j,"application-questions.json"),mn=h.join(j,"profile-history"),pe=(e,o)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:o},ue=pe(process.env.CONNECT_MAX_DAILY,20),fe=pe(process.env.CONNECT_MAX_WEEKLY,100),M=null,Ye=null,C=null,Ke=null,ze=null,Qe=null;function de(){M=null,Ye=null,C=null,Ke=null,ze=null,Qe=null}function he(){d.existsSync(j)||d.mkdirSync(j,{recursive:!0})}function me(e,o){if(!d.existsSync(e))return null;try{let n=JSON.parse(d.readFileSync(e,"utf-8"));try{d.copyFileSync(e,e+".backup")}catch{}return n}catch(n){console.error(`[!] ${o} is corrupted: ${n.message}`),console.error(` File: ${h.resolve(e)}`);let t=e+".backup";if(d.existsSync(t))try{let r=JSON.parse(d.readFileSync(t,"utf-8"));console.error(` Restored from ${t}`);try{d.copyFileSync(t,e)}catch{}return r}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{d.copyFileSync(e,e+".corrupted")}catch{}return null}}function Xe(){return new Date().toISOString().split("T")[0]}function H(e){if(!e)return null;let o=e.match(/\/in\/([^/?#]+)/);return o?o[1].toLowerCase():null}function ge(){return M||(he(),M=me(Ge,"people.json")||{},M)}function Y(){return C||(he(),C=me(He,"quota.json"),(!C||!C.connections)&&(C={connections:[]}),C)}function Ze(){let e=Y(),o=new Date;o.setDate(o.getDate()-7);let n=o.toISOString().split("T")[0];return e.connections.filter(t=>t.date>=n)}function ye(){let e=Ze(),o=Xe(),n=e.filter(r=>r.date===o).length,t=e.length;return{daily:{sent:n,max:ue,remaining:ue-n},weekly:{sent:t,max:fe,remaining:fe-t}}}import"dotenv/config";import*as i from"fs";import*as ne from"os";import*as u from"path";import{fileURLToPath as To}from"url";var Q={};B(Q,{NAME:()=>oo,VERSION:()=>eo,up:()=>ro});import*as S from"fs";import*as q from"path";var eo=1,oo="normalize-jobs-and-questions",no=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],to=50;function K(e){return S.existsSync(e)?JSON.parse(S.readFileSync(e,"utf-8")):null}function z(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{S.writeFileSync(t,n)}catch(r){try{S.unlinkSync(t)}catch{}throw r}try{S.renameSync(t,e)}catch(r){try{S.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function ro(e,o){let n=q.join(e,"jobs.json"),t=q.join(o,"scouted-jobs.json"),r=q.join(e,"application-questions.json"),s=K(n)||{},c=K(t)||{},a=0,l=[];for(let p of Object.keys(s)){if(!c[p])continue;let v=c[p],m=s[p];for(let I of no)v[I]!=null&&m[I]==null&&(m[I]=v[I]);l.push(p),a++}a>0?(z(n,s),console.log(` Phase 1: Merged ${a} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let f=K(r);if(f&&Array.isArray(f.applications)){let p={},v=0;for(let m of f.applications){let I=m.jobId||"unknown";p[I]||(p[I]={applications:[]});let ie=(m.questions||[]).map(A=>{let L={type:A.type||"input",question:A.question||"",answer:A.answer||""};return A.options&&(A.options.length<=to?L.options=A.options:(L.optionsOmitted=!0,v++)),A.page&&(L.page=A.page),A.wasPreFilled&&(L.wasPreFilled=!0),A.wasRetry&&(L.wasRetry=!0),L});p[I].applications.push({applicationId:m.applicationId,date:m.date,result:m.result||"submitted",formPages:m.formPages||null,duration:m.duration||null,retries:m.retries||0,failedField:m.failedField||null,questionCount:m.questionCount||ie.length,questions:ie})}z(r,p),console.log(` Phase 2: Rekeyed ${f.applications.length} applications by jobId (${Object.keys(p).length} unique jobs)`),v>0&&console.log(` Phase 2: Stripped bloated options from ${v} questions`)}else f&&!f.applications?console.log(" Phase 2: application-questions.json already in keyed format"):console.log(" Phase 2: No application-questions.json found");if(l.length>0){for(let p of l)delete c[p];z(t,c),console.log(` Phase 3: Removed ${l.length} merged entries from scouted-jobs.json (${Object.keys(c).length} remaining)`)}else console.log(" Phase 3: No entries to remove from scouted-jobs.json")}var X={};B(X,{NAME:()=>io,VERSION:()=>so,up:()=>ao});import*as b from"fs";import*as Se from"path";var so=2,io="reset-unread-flags";function co(e){return b.existsSync(e)?JSON.parse(b.readFileSync(e,"utf-8")):null}function lo(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{b.writeFileSync(t,n)}catch(r){try{b.unlinkSync(t)}catch{}throw r}try{b.renameSync(t,e)}catch(r){try{b.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function ao(e){let o=Se.join(e,"conversations.json"),n=co(o);if(!n){console.log(" conversations.json not found \u2014 nothing to reset.");return}let t=0;for(let r of Object.keys(n))n[r].unread===!0&&(n[r].unread=!1,t++);if(t===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}lo(o,n),console.log(` Reset unread=false on ${t} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var Z={};B(Z,{NAME:()=>fo,VERSION:()=>uo,up:()=>yo});import*as w from"fs";import*as be from"path";var uo=3,fo="recompute-last-message-by",po=new Set(["draft","confirmed","rejected","needs_review"]);function ho(e){return w.existsSync(e)?JSON.parse(w.readFileSync(e,"utf-8")):null}function mo(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{w.writeFileSync(t,n)}catch(r){try{w.unlinkSync(t)}catch{}throw r}try{w.renameSync(t,e)}catch(r){try{w.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}function go(e,o){if(!e||e.length===0)return"them";let n=e.filter(s=>!po.has(s.status));if(n.length===0)return"them";let t=n.map(s=>({m:s,t:Date.parse(s.time)})).filter(s=>Number.isFinite(s.t)).sort((s,c)=>c.t-s.t).map(s=>s.m),r=t.length>0?t:[...n].reverse();for(let s of r){let c=s.sender;if(c===o)return"me";if(c!=="Unknown"&&c!=="")return"them"}return"them"}async function yo(e){let o=be.join(e,"conversations.json"),n=ho(o);if(!n){console.log(" conversations.json not found \u2014 nothing to recompute.");return}let t=process.env.LINKEDIN_NAME;if(!t||typeof t!="string"||!t.trim())throw new Error(`LINKEDIN_NAME env var is not set. Migration v003 needs your display name to determine which messages are yours vs theirs. Set LINKEDIN_NAME in your .env (or run "ilml plugin config linkedin set LINKEDIN_NAME 'Your Name'") and retry.`);let r=0,s=0,c=0;for(let a of Object.keys(n)){let l=n[a];if(!l||typeof l!="object")continue;Object.prototype.hasOwnProperty.call(l,"_cardSynced")&&(delete l._cardSynced,s++);let f=Array.isArray(l.messages)?l.messages:[],p=go(f,t),v=p==="me"?"awaiting_reply":"unanswered_by_us";l.lastMessageBy!==p&&c++,l.lastMessageBy=p,l.conversationStatus=v,r++}if(r===0){console.log(" No conversations to recompute.");return}mo(o,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${r} conversations.`),console.log(` ${c} had stale lastMessageBy (now corrected).`),s>0&&console.log(` Cleaned ${s} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var ee={};B(ee,{NAME:()=>bo,VERSION:()=>So,up:()=>Ao});import*as k from"fs";import*as we from"path";var So=4,bo="split-connection-timestamps",wo=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function ko(e){if(!k.existsSync(e))return null;let o=k.readFileSync(e,"utf-8");return o.charCodeAt(0)===65279&&(o=o.slice(1)),JSON.parse(o)}function vo(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{k.writeFileSync(t,n)}catch(r){try{k.unlinkSync(t)}catch{}throw r}try{k.renameSync(t,e)}catch(r){try{k.unlinkSync(t)}catch{}if(r.code==="EPERM"||r.code==="EBUSY"){let s=new Error(`File locked: ${e} (${r.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw s.code=r.code,s}throw r}}async function Ao(e){let o=we.join(e,"people.json"),n=ko(o);if(!n||typeof n!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let t=0,r=0;for(let s of Object.keys(n)){let c=n[s];!c||typeof c!="object"||(r++,wo.has(c.connectionStatus)&&c.connectionDate&&!c.requestedConnectionAt&&(c.requestedConnectionAt=c.connectionDate,c.connectionDate=null,t++))}if(t===0){console.log(` Scanned ${r} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}vo(o,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${t} still-pending people (of ${r} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}import"dotenv/config";import*as y from"path";import{fileURLToPath as Eo}from"url";var $o=Eo(import.meta.url),jo=y.dirname(y.dirname($o)),P=process.env.DATA_DIR?y.resolve(process.env.DATA_DIR,"market-research"):y.join(jo,"market-research"),An=y.join(P,"scouted-jobs.json"),En=y.join(P,"discovered-people.json"),$n=y.join(P,"visit-log.json"),jn=y.join(P,"companies.json"),On=y.join(P,"job-decisions.json");function ke(){Oo=null,Io=null,Co=null,_o=null,Ro=null}var Oo=null;var Io=null;var Co=null;var _o=null;var Ro=null;var Do=To(import.meta.url),No=u.dirname(Do),xo=u.dirname(u.dirname(No));function Fo(e){return e&&(e==="~"?ne.homedir():e.startsWith("~/")||e.startsWith("~\\")?u.join(ne.homedir(),e.slice(2)):e)}var E=process.env.DATA_DIR?u.resolve(Fo(process.env.DATA_DIR)):xo,N=u.join(E,"collected-profiles"),x=u.join(E,"market-research"),g=u.join(E,".schema-version"),ve=[u.join(N,".schema-version"),u.join(x,".schema-version")],_=4,O=[{version:1,module:Q},{version:2,module:X},{version:3,module:Z},{version:4,module:ee}];(function(){O.sort((t,r)=>t.version-r.version);let o=new Set;for(let t of O){if(!Number.isInteger(t.version)||t.version<1)throw new Error(`MIGRATION_REGISTRY: invalid version ${JSON.stringify(t.version)} (must be positive integer)`);if(o.has(t.version))throw new Error(`MIGRATION_REGISTRY: duplicate version v${t.version}`);o.add(t.version);let r=t.module;if(!r||typeof r.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(r.VERSION!==void 0&&r.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${r.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=O.length?O[O.length-1].version:0;if(n!==_)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${_}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<O.length;t++){let r=t+1;if(O[t].version!==r)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${r} at position ${t} but found v${O[t].version}`)}})();function je(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
2
2
|
[FATAL] DATA_DIR is set to whitespace ("${process.env.DATA_DIR}"). Either unset it or set a real path.
|
|
3
|
-
`),process.exit(1));try{i.mkdirSync(
|
|
4
|
-
[FATAL] Cannot create DATA_DIR (${
|
|
5
|
-
`),process.exit(1))}let e;try{e=i.statSync(
|
|
6
|
-
[FATAL] DATA_DIR (${
|
|
3
|
+
`),process.exit(1));try{i.mkdirSync(E,{recursive:!0})}catch(o){o.code!=="EEXIST"&&(console.error(`
|
|
4
|
+
[FATAL] Cannot create DATA_DIR (${E}): ${o.message}`),console.error(` Fix the path or permissions and try again.
|
|
5
|
+
`),process.exit(1))}let e;try{e=i.statSync(E)}catch(o){console.error(`
|
|
6
|
+
[FATAL] DATA_DIR (${E}) is not accessible: ${o.message}
|
|
7
7
|
`),process.exit(1)}e.isDirectory()||(console.error(`
|
|
8
|
-
[FATAL] DATA_DIR (${
|
|
9
|
-
`),process.exit(1));for(let o of[x
|
|
8
|
+
[FATAL] DATA_DIR (${E}) exists but is NOT a directory.`),console.error(` Looks like a typo \u2014 your DATA_DIR points at a file. Fix the path and try again.
|
|
9
|
+
`),process.exit(1));for(let o of[N,x]){let n;try{n=i.lstatSync(o)}catch(t){if(t.code==="ENOENT")continue;throw t}n.isSymbolicLink()&&(console.error(`
|
|
10
10
|
[FATAL] Data subdirectory is a symbolic link: ${o}`),console.error(" Refusing to follow \u2014 backup code would copy whatever the link points at."),console.error(` If this is intentional, replace the symlink with the real directory.
|
|
11
|
-
`),process.exit(1))}}var
|
|
12
|
-
[FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${o.pid}`),console.error(` Started at: ${o.startedAt||"(unknown)"}`),console.error(` Lock file: ${
|
|
11
|
+
`),process.exit(1))}}var D=u.join(E,".migration-lock");function Lo(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return i.writeFileSync(D,e,{flag:"wx"}),!0}catch(t){if(t.code!=="EEXIST")throw t}let o;try{o=JSON.parse(i.readFileSync(D,"utf-8"))}catch{o=null}if(o&&Number.isInteger(o.pid)){let t=!1;try{process.kill(o.pid,0),t=!0}catch(c){c.code==="EPERM"&&(t=!0)}let r=24*60*60*1e3,s=1/0;if(o.startedAt){let c=Date.parse(o.startedAt);Number.isNaN(c)||(s=Date.now()-c)}t&&s<r&&(console.error(`
|
|
12
|
+
[FATAL] Another plugin process is currently running migrations:`),console.error(` PID: ${o.pid}`),console.error(` Started at: ${o.startedAt||"(unknown)"}`),console.error(` Lock file: ${D}
|
|
13
13
|
`),console.error(" Wait for it to finish, or if you're sure it's not actually running,"),console.error(` delete the lock file manually and re-run.
|
|
14
|
-
`),process.exit(1)),t&&s>=r&&console.log(` Lock holder PID ${o.pid} is alive but lock is older than 24h \u2014 assuming PID reuse, taking over.`)}console.log(` Stale migration lock from PID ${o?.pid??"?"} found \u2014 taking over.`);let n=
|
|
14
|
+
`),process.exit(1)),t&&s>=r&&console.log(` Lock holder PID ${o.pid} is alive but lock is older than 24h \u2014 assuming PID reuse, taking over.`)}console.log(` Stale migration lock from PID ${o?.pid??"?"} found \u2014 taking over.`);let n=D+".tmp";try{return i.writeFileSync(n,e),i.renameSync(n,D),!0}catch(t){try{i.unlinkSync(n)}catch{}throw new Error(`Failed to take over stale migration lock: ${t.message}`)}}function te(){try{if(JSON.parse(i.readFileSync(D,"utf-8")).pid!==process.pid)return;i.unlinkSync(D)}catch{}}var Ae=!1;function Mo(){if(Ae)return;Ae=!0;let e=()=>{try{te()}catch{}process.exit(1)};for(let o of["SIGINT","SIGTERM","SIGHUP"])try{process.on(o,e)}catch{}}function Po(){if(i.existsSync(g))return;let e=[],o=[];for(let s of ve)if(i.existsSync(s))try{e.push({file:s,schema:V(s)})}catch(c){o.push({file:s,err:c.message})}if(o.length>0){console.error(`
|
|
15
15
|
[FATAL] Legacy .schema-version file(s) corrupted \u2014 cannot determine current schema version:`);for(let s of o)console.error(` ${s.file}: ${s.err}`);console.error(`
|
|
16
16
|
Repair the file(s) (likely just an integer 'version' field \u2014 see another working DATA_DIR`),console.error(` or default to {"version":1,"migrations":[]} if you're sure you're on schema v1) and try again.
|
|
17
17
|
`),process.exit(1)}if(e.length===0)return;let n=e.map(s=>s.schema.version);if(new Set(n).size>1){console.error(`
|
|
18
18
|
[FATAL] Legacy .schema-version files disagree:`);for(let s of e)console.error(` ${s.file}: v${s.schema.version}`);console.error(" This means a previous migration crashed between writing the two files."),console.error(` Reconcile manually (delete the wrong one, keep the right one), then re-run.
|
|
19
|
-
`),process.exit(1)}let t=e[0].schema,r=g+".tmp";try{i.writeFileSync(r,JSON.stringify(t,null,2)),i.renameSync(r,g)}catch(s){try{i.unlinkSync(r)}catch{}throw s}for(let s of
|
|
19
|
+
`),process.exit(1)}let t=e[0].schema,r=g+".tmp";try{i.writeFileSync(r,JSON.stringify(t,null,2)),i.renameSync(r,g)}catch(s){try{i.unlinkSync(r)}catch{}throw s}for(let s of ve)if(i.existsSync(s))try{i.unlinkSync(s)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${g}`)}function Uo(e){if(e===null||typeof e!="object"||Array.isArray(e))return null;let o=Number(e.version);return!Number.isFinite(o)||o<0||!Number.isInteger(o)?null:(e.version=o,Array.isArray(e.migrations)||(e.migrations=[]),e)}function V(e){let o=i.readFileSync(e,"utf-8");return o.charCodeAt(0)===65279&&(o=o.slice(1)),JSON.parse(o)}function Ee(){if(Po(),!i.existsSync(g))return{version:0,migrations:[]};let e;try{e=V(g)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
|
|
20
20
|
[FATAL] ${g} is not valid JSON: ${n.message}`),console.error(" Refusing to proceed \u2014 silently treating it as 'fresh install' would re-apply"),console.error(" every migration on top of already-migrated data and corrupt it."),console.error(' Repair the file (set it to {"version":N,"migrations":[...]} matching your real state)'),console.error(` or restore from the *.pre-vNNN.backup files if you have them.
|
|
21
|
-
`),process.exit(1)}let o=
|
|
21
|
+
`),process.exit(1)}let o=Uo(e);return o===null&&(console.error(`
|
|
22
22
|
[FATAL] ${g} has invalid structure:`),console.error(` ${JSON.stringify(e)?.slice(0,200)||"(unparseable)"}`),console.error(' Expected shape: { "version": <integer>, "migrations": [...] }'),console.error(` Repair the file or restore from a backup.
|
|
23
|
-
`),process.exit(1)),o}function
|
|
24
|
-
[FATAL] Your data schema is at v${o}, but this plugin build only understands up to v${
|
|
25
|
-
`),console.error(" Options:"),console.error(" A) Re-install the newer plugin version that produced this schema, then"),console.error(" (if you really want to downgrade) run 'rollback-data --confirm' first,"),console.error(" then re-install the older plugin version."),console.error(` B) Manually restore your data from the *.pre-vNNN.backup files matching v${
|
|
23
|
+
`),process.exit(1)),o}function Oe(e){try{i.chmodSync(e,384)}catch{}}function Jo(e){if(je(),i.existsSync(g))try{if(i.lstatSync(g).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${g}. Refusing to write through it (potential symlink attack). Remove the link and re-run.`)}catch(n){if(n.message?.includes("symbolic link"))throw n}let o=g+".tmp";try{i.writeFileSync(o,JSON.stringify(e,null,2)),Oe(o),i.renameSync(o,g)}catch(n){try{i.unlinkSync(o)}catch{}throw n}}function $e(e,o){if(!i.existsSync(e))return;let n=`.pre-v${String(o).padStart(3,"0")}.backup`,t=i.readdirSync(e).filter(a=>{let l=a.toLowerCase();if(l.includes(".backup")||l===".schema-version"||l.endsWith(".tmp"))return!1;try{return i.statSync(u.join(e,a)).isFile()}catch{return!1}}),r=0,s=0,c=[];for(let a of t){let l=u.join(e,a),f=u.join(e,a+n);if(i.existsSync(f)){s++;continue}try{Ce(l,f),r++}catch(p){c.push({file:a,err:p.message})}}if(c.length>0){let a=new Error(`Failed to back up ${c.length} file(s) in ${u.basename(e)}/: `+c.map(l=>`${l.file} (${l.err})`).join(", "));throw a.code="BACKUP_INCOMPLETE",a}if(r>0||s>0){let a=s>0?` (${s} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${r} files in ${u.basename(e)}/ (${n})${a}`)}}var oe=!1;async function Ie(){if(oe)return;je(),Go();let o=Ee().version;if(o===_){oe=!0;return}Mo(),Lo(),process.on("exit",te),o>_&&(console.error(`
|
|
24
|
+
[FATAL] Your data schema is at v${o}, but this plugin build only understands up to v${_}.`),console.error(" This usually means you downgraded the plugin without rolling back data."),console.error(` Operating on the newer-format data with this build would risk corrupting it.
|
|
25
|
+
`),console.error(" Options:"),console.error(" A) Re-install the newer plugin version that produced this schema, then"),console.error(" (if you really want to downgrade) run 'rollback-data --confirm' first,"),console.error(" then re-install the older plugin version."),console.error(` B) Manually restore your data from the *.pre-vNNN.backup files matching v${_}.
|
|
26
26
|
`),process.exit(1)),console.log(`
|
|
27
|
-
\u{1F4E6} Schema migration: v${o} \u2192 v${
|
|
27
|
+
\u{1F4E6} Schema migration: v${o} \u2192 v${_}`);let n=Ho();if(!n.ok){console.error(`
|
|
28
28
|
[FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let r of n.broken)console.error(` ${r.dir}/${r.file}: ${r.err}`);console.error(`
|
|
29
29
|
Migration ABORTED. No backups taken, no files modified.`),console.error(" Repair the file(s) above (restore from your own backup, or fix manually)"),console.error(` and try again. To inspect: 'ilml linkedin migrate-status'.
|
|
30
|
-
`),process.exit(1)}let t=
|
|
31
|
-
Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,
|
|
32
|
-
[FATAL] Pre-migration backup failed for ${s}: ${
|
|
33
|
-
`),process.exit(1)}let a=r.module;try{await a.up(x
|
|
34
|
-
[FATAL] Migration ${s} failed: ${
|
|
35
|
-
`)):(console.error(` [!] Auto-rollback INCOMPLETE: ${
|
|
36
|
-
`))}catch(
|
|
37
|
-
`)}process.exit(1)}try{let
|
|
38
|
-
[FATAL] Migration ${s} applied successfully but schema version file could NOT be updated: ${
|
|
39
|
-
`),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{
|
|
40
|
-
\u2713 Schema is now at v${
|
|
41
|
-
`)}var
|
|
30
|
+
`),process.exit(1)}let t=O.filter(r=>r.version>o);for(let r of t){console.log(`
|
|
31
|
+
Running migration v${String(r.version).padStart(3,"0")}...`);let s=`v${String(r.version).padStart(3,"0")}`,c=`.pre-${s}.backup`;try{$e(N,r.version),$e(x,r.version)}catch(l){console.error(`
|
|
32
|
+
[FATAL] Pre-migration backup failed for ${s}: ${l.message}`),console.error(" Migration NOT applied. Repair the underlying issue (disk space, permissions, locked files)"),console.error(` and re-run the plugin command.
|
|
33
|
+
`),process.exit(1)}let a=r.module;try{await a.up(N,x)}catch(l){console.error(`
|
|
34
|
+
[FATAL] Migration ${s} failed: ${l.message}`),console.error(` Attempting auto-rollback from ${c} files...`);try{let f=Yo(c);f.ok?(console.error(` \u2713 Auto-rollback restored ${f.restored} files. Schema stays at v${o}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
|
|
35
|
+
`)):(console.error(` [!] Auto-rollback INCOMPLETE: ${f.error}`),console.error(` Manual recovery: copy *${c} files back over the originals.
|
|
36
|
+
`))}catch(f){console.error(` [!] Auto-rollback CRASHED while restoring: ${f.message}`),console.error(` Manual recovery: copy *${c} files back over the originals.
|
|
37
|
+
`)}process.exit(1)}try{let l=new Date().toISOString(),f={version:r.version,name:a.NAME||s,appliedAt:l},p=Ee();p.version=r.version,p.migratedAt=l,p.migrations=p.migrations||[],p.migrations.push(f),Jo(p)}catch(l){console.error(`
|
|
38
|
+
[FATAL] Migration ${s} applied successfully but schema version file could NOT be updated: ${l.message}`),console.error(` Your data is in the v${r.version} state but .schema-version still shows v${o}.`),console.error(` On next plugin command the runner will try to re-apply ${s}. If that migration is`),console.error(` idempotent (most are), it will succeed harmlessly. If you're unsure, run 'data-cleanup' and contact support.
|
|
39
|
+
`),process.exit(1)}console.log(` \u2713 Migration ${s} complete`)}try{de()}catch{}try{ke()}catch{}oe=!0,te(),console.log(`
|
|
40
|
+
\u2713 Schema is now at v${_}
|
|
41
|
+
`)}var Bo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function qo(e){let o=e.toLowerCase();return Bo.some(n=>n.test(o))}var Vo=6e4;function Wo(){let e=Date.now(),o=[];for(let n of[E,N,x]){if(!i.existsSync(n))continue;let t;try{t=i.readdirSync(n)}catch{continue}for(let r of t){if(!qo(r))continue;let s=u.join(n,r);try{let c=i.statSync(s);if(!c.isFile()||e-c.mtimeMs<Vo)continue;o.push({dir:n,file:r,fullPath:s})}catch{}}}return o}function Go({verbose:e=!1}={}){let o=Wo();if(o.length===0)return e&&console.log(" No orphan .tmp files found."),0;let n=0;for(let t of o)try{i.unlinkSync(t.fullPath),n++,e&&console.log(` Removed orphan: ${u.basename(t.dir)}/${t.file}`)}catch(r){console.warn(` [!] Could not remove orphan ${t.fullPath}: ${r.message}`)}return!e&&n>0&&console.log(` Cleaned up ${n} orphan .tmp file(s) from previous run.`),n}function Ho(){let e=[];for(let o of[N,x]){if(!i.existsSync(o))continue;let n=i.readdirSync(o).filter(t=>{let r=t.toLowerCase();return r.endsWith(".json")&&!r.includes(".backup")});for(let t of n){let r=u.join(o,t);try{V(r)}catch(s){e.push({dir:u.basename(o),file:t,err:s.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function Yo(e){let o=[],n=[];for(let s of[N,x]){if(!i.existsSync(s))continue;let c=i.readdirSync(s).filter(a=>a.endsWith(e));for(let a of c){let l=u.join(s,a),f=a.slice(0,-e.length),p=u.join(s,f);try{f.toLowerCase().endsWith(".json")?V(l):i.accessSync(l,i.constants.R_OK),o.push({backupPath:l,originalPath:p,fileName:a,dir:s})}catch(v){n.push(`${u.basename(s)}/${a}: ${v.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let t=0,r=[];for(let{backupPath:s,originalPath:c,fileName:a,dir:l}of o)try{Ce(s,c),t++}catch(f){r.push(`${u.basename(l)}/${a}: ${f.message}`)}return r.length>0?{ok:!1,error:r.join("; "),restored:t}:{ok:!0,restored:t}}function Ce(e,o){let n=o+".tmp";try{i.copyFileSync(e,n),Oe(n)}catch(t){try{i.unlinkSync(n)}catch{}throw t}try{i.renameSync(n,o)}catch(t){try{i.unlinkSync(n)}catch{}if(t.code==="EPERM"||t.code==="EBUSY"){let r=new Error(`File locked: ${o} (${t.code}). On Windows this is usually antivirus / Search Indexer / the file open in another app. Close anything that might be holding it and re-run.`);throw r.code=t.code,r}throw t}}var De=process.argv.includes("--json"),Ne=new Set(["connected"]),xe=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]),re=["founder","investor","hiring_manager","peer"],Ko=new Date().toISOString().split("T")[0];function Fe(e){if(!e)return 1/0;let o=new Date(e+"T00:00:00Z").getTime(),n=new Date(Ko+"T00:00:00Z").getTime();return Math.round((n-o)/864e5)}function zo(e,o,n=20){return o?"\u2588".repeat(Math.max(0,Math.round(e/o*n))):""}De||await Ie();var Qo=Y(),G=Qo.connections||[],$=ye(),se=ge(),U=new Map;for(let[e,o]of Object.entries(se)){let n=H(o.profileUrl||e);n&&!U.has(n)&&U.set(n,o)}for(let e of Object.values(se))for(let o of e.aliases||[])o&&!U.has(o)&&U.set(o,e);var Xo=G.filter(e=>Fe(e.date)<=7),R={},W={};for(let e of Xo){R[e.date]=(R[e.date]||0)+1;let o=e.source||"unknown";W[o]=(W[o]||0)+1}var F={},_e=new Set;for(let e of G){let o=e.source||"unknown",n=H(e.profileUrl),t=`${o}|${n}`;if(n&&_e.has(t))continue;n&&_e.add(t),F[o]||={sent:0,accepted:0,awaiting:0,stale:0,unknown:0};let r=F[o];r.sent++;let c=(n?U.get(n):null)?.connectionStatus;Ne.has(c)?r.accepted++:xe.has(c)?(r.awaiting++,Fe(e.date)>14&&r.stale++):r.unknown++}var J={};for(let e of re)J[e]=0;for(let e of Object.values(se)){let o=e.category;if(!re.includes(o))continue;let n=e.connectionStatus;Ne.has(n)||xe.has(n)||e.connectionDegree!=="1st"&&J[o]++}var Le=Object.values(J).reduce((e,o)=>e+o,0);De&&(console.log(JSON.stringify({state:$,byDay:R,bySource7d:W,acceptance:F,feederPool:{...J,total:Le},totalLogged:G.length},null,2)),process.exit(0));var Re=(e,o)=>o?`${Math.round(e/o*100)}%`:"\u2014";console.log(`
|
|
42
42
|
=== LinkedIn Connection Quota ===
|
|
43
|
-
`);console.log("State");console.log(` Today: ${
|
|
44
|
-
`);if(Object.keys(R).length){let e=Math.max(...Object.values(R));console.log("Last 7 days");for(let o of Object.keys(R).sort())console.log(` ${o} ${
|
|
43
|
+
`);console.log("State");console.log(` Today: ${$.daily.sent} / ${$.daily.max} (${$.daily.remaining} left)`);console.log(` Week: ${$.weekly.sent} / ${$.weekly.max} (${$.weekly.remaining} left) \u2014 rolling 7 days`);console.log(` Log: ${G.length} requests recorded all-time
|
|
44
|
+
`);if(Object.keys(R).length){let e=Math.max(...Object.values(R));console.log("Last 7 days");for(let o of Object.keys(R).sort())console.log(` ${o} ${zo(R[o],e).padEnd(20)} ${R[o]}`);console.log(""),console.log(" by source (7d): "+Object.entries(W).map(([o,n])=>`${o}=${n}`).join(", ")+`
|
|
45
45
|
`)}else console.log(`Last 7 days: no connection requests sent.
|
|
46
|
-
`);var
|
|
47
|
-
`)
|
|
46
|
+
`);var Te=Object.keys(F).sort((e,o)=>F[o].sent-F[e].sent);if(Te.length){console.log("Acceptance (all-time, unique profiles)"),console.log(" "+"Source".padEnd(24)+"Sent".padStart(6)+"Accept".padStart(8)+"Rate".padStart(7)+"Await".padStart(7)+"Stale>14d".padStart(11));let e={sent:0,accepted:0,awaiting:0,stale:0};for(let o of Te){let n=F[o];e.sent+=n.sent,e.accepted+=n.accepted,e.awaiting+=n.awaiting,e.stale+=n.stale,console.log(" "+o.padEnd(24)+String(n.sent).padStart(6)+String(n.accepted).padStart(8)+Re(n.accepted,n.sent).padStart(7)+String(n.awaiting).padStart(7)+String(n.stale).padStart(11))}console.log(" "+"\u2500".repeat(63)),console.log(" "+"TOTAL".padEnd(24)+String(e.sent).padStart(6)+String(e.accepted).padStart(8)+Re(e.accepted,e.sent).padStart(7)+String(e.awaiting).padStart(7)+String(e.stale).padStart(11)),console.log(" (Accept = they connected \xB7 Await = request still open \xB7 Stale>14d = open >2wk, likely won't)"),console.log(" Acceptance is read from your last `sync` \u2014 run `ilml linkedin sync` to refresh accepted status.\n")}console.log("Feeder pool \u2014 high-value people not yet connected");for(let e of re)console.log(` ${e.padEnd(16)} ${J[e]}`);console.log(` ${"TOTAL".padEnd(16)} ${Le}`);console.log(` \u2192 these could absorb idle daily quota once the category feeder is wired.
|
|
47
|
+
`);$.daily.sent===0&&$.daily.remaining>0&&(console.log(`\u26A0 Today's quota is idle (0/${$.daily.max}). Recruiter auto-connect is off and no`),console.log(` other feeder is wired yet \u2014 run the funnel manually or build the category feeder.
|
|
48
48
|
`));
|