ilml-plugin-linkedin 1.16.0 → 1.17.1
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 +6 -0
- package/dist/applyQueue.mjs +12 -12
- package/dist/connect.mjs +68 -68
- package/dist/daily.mjs +7 -7
- package/dist/enrichProfile.mjs +15 -15
- package/dist/enrichProfiles.mjs +54 -54
- package/dist/funnelRunner.mjs +60 -60
- package/dist/migrationCli.mjs +5 -5
- package/dist/profileHistory.mjs +2 -2
- package/dist/quota.mjs +11 -11
- package/dist/run.mjs +65 -65
- package/dist/scout.mjs +5 -5
- package/dist/syncAll.mjs +102 -102
- package/dist/syncConnections.mjs +30 -29
- package/dist/verifyAbout.mjs +20 -20
- package/dist/version.mjs +1 -1
- package/dist/viewers.mjs +4 -4
- package/dist/visit.mjs +45 -45
- package/dist/warmScan.mjs +2 -2
- package/ilml-plugin.json +1 -1
- package/package.json +1 -1
package/dist/migrationCli.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ke=Object.defineProperty;var P=(e,o)=>{for(var n in o)ke(e,n,{get:o[n],enumerable:!0})};import"dotenv/config";import"dotenv/config";import*as i from"fs";import*as z from"os";import*as l from"path";import{fileURLToPath as uo}from"url";var q={};P(q,{NAME:()=>Ae,VERSION:()=>we,up:()=>Ee});import*as A from"fs";import*as J from"path";var we=1,Ae="normalize-jobs-and-questions",$e=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],je=50;function V(e){return A.existsSync(e)?JSON.parse(A.readFileSync(e,"utf-8")):null}function W(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{A.writeFileSync(t,n)}catch(s){try{A.unlinkSync(t)}catch{}throw s}try{A.renameSync(t,e)}catch(s){try{A.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Ee(e,o){let n=J.join(e,"jobs.json"),t=J.join(o,"scouted-jobs.json"),s=J.join(e,"application-questions.json"),r=V(n)||{},c=V(t)||{},O=0,u=[];for(let f of Object.keys(r)){if(!c[f])continue;let b=c[f],d=r[f];for(let I of $e)b[I]!=null&&d[I]==null&&(d[I]=b[I]);u.push(f),O++}O>0?(W(n,r),console.log(` Phase 1: Merged ${O} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let p=V(s);if(p&&Array.isArray(p.applications)){let f={},b=0;for(let d of p.applications){let I=d.jobId||"unknown";f[I]||(f[I]={applications:[]});let T=(d.questions||[]).map(g=>{let v={type:g.type||"input",question:g.question||"",answer:g.answer||""};return g.options&&(g.options.length<=je?v.options=g.options:(v.optionsOmitted=!0,b++)),g.page&&(v.page=g.page),g.wasPreFilled&&(v.wasPreFilled=!0),g.wasRetry&&(v.wasRetry=!0),v});f[I].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||T.length,questions:T})}W(s,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 c[f];W(t,c),console.log(` Phase 3: Removed ${u.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 Y={};P(Y,{NAME:()=>Ie,VERSION:()=>Oe,up:()=>De});import*as $ from"fs";import*as X from"path";var Oe=2,Ie="reset-unread-flags";function Re(e){return $.existsSync(e)?JSON.parse($.readFileSync(e,"utf-8")):null}function Ne(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{$.writeFileSync(t,n)}catch(s){try{$.unlinkSync(t)}catch{}throw s}try{$.renameSync(t,e)}catch(s){try{$.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function De(e){let o=X.join(e,"conversations.json"),n=Re(o);if(!n){console.log(" conversations.json not found \u2014 nothing to reset.");return}let t=0;for(let s of Object.keys(n))n[s].unread===!0&&(n[s].unread=!1,t++);if(t===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}Ne(o,n),console.log(` Reset unread=false on ${t} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var G={};P(G,{NAME:()=>Ce,VERSION:()=>Te,up:()=>Me});import*as j from"fs";import*as Z from"path";var Te=3,Ce="recompute-last-message-by",xe=new Set(["draft","confirmed","rejected","needs_review"]);function _e(e){return j.existsSync(e)?JSON.parse(j.readFileSync(e,"utf-8")):null}function Fe(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{j.writeFileSync(t,n)}catch(s){try{j.unlinkSync(t)}catch{}throw s}try{j.renameSync(t,e)}catch(s){try{j.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}function Le(e,o){if(!e||e.length===0)return"them";let n=e.filter(r=>!xe.has(r.status));if(n.length===0)return"them";let t=n.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,c)=>c.t-r.t).map(r=>r.m),s=t.length>0?t:[...n].reverse();for(let r of s){let c=r.sender;if(c===o)return"me";if(c!=="Unknown"&&c!=="")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 s=0,r=0,c=0;for(let O of Object.keys(n)){let u=n[O];if(!u||typeof u!="object")continue;Object.prototype.hasOwnProperty.call(u,"_cardSynced")&&(delete u._cardSynced,r++);let p=Array.isArray(u.messages)?u.messages:[],f=Le(p,t),b=f==="me"?"awaiting_reply":"unanswered_by_us";u.lastMessageBy!==f&&c++,u.lastMessageBy=f,u.conversationStatus=b,s++}if(s===0){console.log(" No conversations to recompute.");return}Fe(o,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${c} had stale lastMessageBy (now corrected).`),r>0&&console.log(` Cleaned ${r} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var H={};P(H,{NAME:()=>Je,VERSION:()=>Pe,up:()=>We});import*as E from"fs";import*as ee from"path";var Pe=4,Je="split-connection-timestamps",Ue=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(s){try{E.unlinkSync(t)}catch{}throw s}try{E.renameSync(t,e)}catch(s){try{E.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function We(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,s=0;for(let r of Object.keys(n)){let c=n[r];!c||typeof c!="object"||(s++,Ue.has(c.connectionStatus)&&c.connectionDate&&!c.requestedConnectionAt&&(c.requestedConnectionAt=c.connectionDate,c.connectionDate=null,t++))}if(t===0){console.log(` Scanned ${s} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}Ve(o,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${t} still-pending people (of ${s} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}import{getPluginConfig as qe}from"@ilivemylife/graph-sdk";var Ye=await qe();for(let[e,o]of Object.entries(Ye))process.env[e]===void 0&&(process.env[e]=o);var Io=process.env.LINKEDIN_NAME,C=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Ro=Object.freeze(new Set([C.DRAFT,C.CONFIRMED,C.NEEDS_REVIEW])),No=Object.freeze(new Set([C.DRAFT,C.CONFIRMED,C.REJECTED,C.NEEDS_REVIEW]));import"dotenv/config";import*as y from"path";import{fileURLToPath as Ge}from"url";var He=Ge(import.meta.url),ze=y.dirname(y.dirname(He)),x=process.env.DATA_DIR?y.resolve(process.env.DATA_DIR,"collected-profiles"):y.join(ze,"collected-profiles"),_o=y.join(x,"people.json"),Fo=y.join(x,"jobs.json"),Lo=y.join(x,"quota.json"),Mo=y.join(x,"conversations.json"),Po=y.join(x,"sync-state.json"),Jo=y.join(x,"application-questions.json"),Uo=y.join(x,"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 k from"path";import{fileURLToPath as no}from"url";var to=no(import.meta.url),so=k.dirname(k.dirname(to)),L=process.env.DATA_DIR?k.resolve(process.env.DATA_DIR,"market-research"):k.join(so,"market-research"),Go=k.join(L,"scouted-jobs.json"),Ho=k.join(L,"discovered-people.json"),zo=k.join(L,"visit-log.json"),Ko=k.join(L,"companies.json"),Qo=k.join(L,"job-decisions.json");function te(){ro=null,io=null,co=null,lo=null,ao=null}var ro=null;var io=null;var co=null;var lo=null;var ao=null;var fo=uo(import.meta.url),po=l.dirname(fo),ho=l.dirname(l.dirname(po));function mo(e){return e&&(e==="~"?z.homedir():e.startsWith("~/")||e.startsWith("~\\")?l.join(z.homedir(),e.slice(2)):e)}var S=process.env.DATA_DIR?l.resolve(mo(process.env.DATA_DIR)):ho,N=l.join(S,"collected-profiles"),D=l.join(S,"market-research"),m=l.join(S,".schema-version"),se=[l.join(N,".schema-version"),l.join(D,".schema-version")],U=4,R=[{version:1,module:q},{version:2,module:Y},{version:3,module:G},{version:4,module:H}];(function(){R.sort((t,s)=>t.version-s.version);let o=new Set;for(let t of R){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 s=t.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=R.length?R[R.length-1].version:0;if(n!==U)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${U}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<R.length;t++){let s=t+1;if(R[t].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${t} but found v${R[t].version}`)}})();function le(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
1
|
+
var ke=Object.defineProperty;var P=(e,o)=>{for(var n in o)ke(e,n,{get:o[n],enumerable:!0})};import"dotenv/config";import"dotenv/config";import*as i from"fs";import*as K from"os";import*as l from"path";import{fileURLToPath as uo}from"url";var q={};P(q,{NAME:()=>Ae,VERSION:()=>we,up:()=>Ee});import*as A from"fs";import*as J 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 W(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{A.writeFileSync(t,n)}catch(s){try{A.unlinkSync(t)}catch{}throw s}try{A.renameSync(t,e)}catch(s){try{A.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Ee(e,o){let n=J.join(e,"jobs.json"),t=J.join(o,"scouted-jobs.json"),s=J.join(e,"application-questions.json"),r=V(n)||{},c=V(t)||{},I=0,u=[];for(let f of Object.keys(r)){if(!c[f])continue;let b=c[f],d=r[f];for(let O of je)b[O]!=null&&d[O]==null&&(d[O]=b[O]);u.push(f),I++}I>0?(W(n,r),console.log(` Phase 1: Merged ${I} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let p=V(s);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 T=(d.questions||[]).map(g=>{let v={type:g.type||"input",question:g.question||"",answer:g.answer||""};return g.options&&(g.options.length<=$e?v.options=g.options:(v.optionsOmitted=!0,b++)),g.page&&(v.page=g.page),g.wasPreFilled&&(v.wasPreFilled=!0),g.wasRetry&&(v.wasRetry=!0),v});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||T.length,questions:T})}W(s,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 c[f];W(t,c),console.log(` Phase 3: Removed ${u.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 Y={};P(Y,{NAME:()=>Oe,VERSION:()=>Ie,up:()=>De});import*as j from"fs";import*as X from"path";var Ie=2,Oe="reset-unread-flags";function Re(e){return j.existsSync(e)?JSON.parse(j.readFileSync(e,"utf-8")):null}function Ne(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{j.writeFileSync(t,n)}catch(s){try{j.unlinkSync(t)}catch{}throw s}try{j.renameSync(t,e)}catch(s){try{j.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function De(e){let o=X.join(e,"conversations.json"),n=Re(o);if(!n){console.log(" conversations.json not found \u2014 nothing to reset.");return}let t=0;for(let s of Object.keys(n))n[s].unread===!0&&(n[s].unread=!1,t++);if(t===0){console.log(" No stale unread flags found \u2014 nothing to do.");return}Ne(o,n),console.log(` Reset unread=false on ${t} conversations. Run 'ilml linkedin sync-all' to re-establish real unread state from LinkedIn.`)}var G={};P(G,{NAME:()=>Ce,VERSION:()=>Te,up:()=>Me});import*as $ from"fs";import*as Z from"path";var Te=3,Ce="recompute-last-message-by",xe=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(s){try{$.unlinkSync(t)}catch{}throw s}try{$.renameSync(t,e)}catch(s){try{$.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}function Le(e,o){if(!e||e.length===0)return"them";let n=e.filter(r=>!xe.has(r.status));if(n.length===0)return"them";let t=n.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,c)=>c.t-r.t).map(r=>r.m),s=t.length>0?t:[...n].reverse();for(let r of s){let c=r.sender;if(c===o)return"me";if(c!=="Unknown"&&c!=="")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 s=0,r=0,c=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,r++);let p=Array.isArray(u.messages)?u.messages:[],f=Le(p,t),b=f==="me"?"awaiting_reply":"unanswered_by_us";u.lastMessageBy!==f&&c++,u.lastMessageBy=f,u.conversationStatus=b,s++}if(s===0){console.log(" No conversations to recompute.");return}Fe(o,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${c} had stale lastMessageBy (now corrected).`),r>0&&console.log(` Cleaned ${r} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var H={};P(H,{NAME:()=>Je,VERSION:()=>Pe,up:()=>We});import*as E from"fs";import*as ee from"path";var Pe=4,Je="split-connection-timestamps",Ue=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(s){try{E.unlinkSync(t)}catch{}throw s}try{E.renameSync(t,e)}catch(s){try{E.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function We(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,s=0;for(let r of Object.keys(n)){let c=n[r];!c||typeof c!="object"||(s++,Ue.has(c.connectionStatus)&&c.connectionDate&&!c.requestedConnectionAt&&(c.requestedConnectionAt=c.connectionDate,c.connectionDate=null,t++))}if(t===0){console.log(` Scanned ${s} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}Ve(o,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${t} still-pending people (of ${s} scanned).`),console.log(' connectionDate now means "accepted on" only; requestedConnectionAt means "requested on".')}import{getPluginConfig as qe}from"@ilivemylife/graph-sdk";var Ye=await qe();for(let[e,o]of Object.entries(Ye))process.env[e]===void 0&&(process.env[e]=o);var Oo=process.env.LINKEDIN_NAME,C=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Ro=Object.freeze(new Set([C.DRAFT,C.CONFIRMED,C.NEEDS_REVIEW])),No=Object.freeze(new Set([C.DRAFT,C.CONFIRMED,C.REJECTED,C.NEEDS_REVIEW]));import"dotenv/config";import*as y from"path";import{fileURLToPath as Ge}from"url";var He=Ge(import.meta.url),Ke=y.dirname(y.dirname(He)),x=process.env.DATA_DIR?y.resolve(process.env.DATA_DIR,"collected-profiles"):y.join(Ke,"collected-profiles"),_o=y.join(x,"people.json"),Fo=y.join(x,"jobs.json"),Lo=y.join(x,"quota.json"),Mo=y.join(x,"conversations.json"),Po=y.join(x,"sync-state.json"),Jo=y.join(x,"application-questions.json"),Uo=y.join(x,"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),ze=null,Qe=null,Xe=null,Ze=null,eo=null,oo=null;function ne(){ze=null,Qe=null,Xe=null,Ze=null,eo=null,oo=null}import"dotenv/config";import*as k from"path";import{fileURLToPath as no}from"url";var to=no(import.meta.url),so=k.dirname(k.dirname(to)),L=process.env.DATA_DIR?k.resolve(process.env.DATA_DIR,"market-research"):k.join(so,"market-research"),Go=k.join(L,"scouted-jobs.json"),Ho=k.join(L,"discovered-people.json"),Ko=k.join(L,"visit-log.json"),zo=k.join(L,"companies.json"),Qo=k.join(L,"job-decisions.json");function te(){ro=null,io=null,co=null,lo=null,ao=null}var ro=null;var io=null;var co=null;var lo=null;var ao=null;var fo=uo(import.meta.url),po=l.dirname(fo),ho=l.dirname(l.dirname(po));function mo(e){return e&&(e==="~"?K.homedir():e.startsWith("~/")||e.startsWith("~\\")?l.join(K.homedir(),e.slice(2)):e)}var S=process.env.DATA_DIR?l.resolve(mo(process.env.DATA_DIR)):ho,N=l.join(S,"collected-profiles"),D=l.join(S,"market-research"),m=l.join(S,".schema-version"),se=[l.join(N,".schema-version"),l.join(D,".schema-version")],U=4,R=[{version:1,module:q},{version:2,module:Y},{version:3,module:G},{version:4,module:H}];(function(){R.sort((t,s)=>t.version-s.version);let o=new Set;for(let t of R){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 s=t.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=R.length?R[R.length-1].version:0;if(n!==U)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${U}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<R.length;t++){let s=t+1;if(R[t].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${t} but found v${R[t].version}`)}})();function le(){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
3
|
`),process.exit(1));try{i.mkdirSync(S,{recursive:!0})}catch(o){o.code!=="EEXIST"&&(console.error(`
|
|
4
4
|
[FATAL] Cannot create DATA_DIR (${S}): ${o.message}`),console.error(` Fix the path or permissions and try again.
|
|
@@ -16,7 +16,7 @@ var ke=Object.defineProperty;var P=(e,o)=>{for(var n in o)ke(e,n,{get:o[n],enume
|
|
|
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(r=>r.schema.version);if(new Set(n).size>1){console.error(`
|
|
18
18
|
[FATAL] Legacy .schema-version files disagree:`);for(let r of e)console.error(` ${r.file}: v${r.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,s=m+".tmp";try{i.writeFileSync(s,JSON.stringify(t,null,2)),i.renameSync(s,m)}catch(r){try{i.unlinkSync(s)}catch{}throw r}for(let r of se)if(i.existsSync(r))try{i.unlinkSync(r)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${m}`)}function yo(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 B(e){let o=i.readFileSync(e,"utf-8");return o.charCodeAt(0)===65279&&(o=o.slice(1)),JSON.parse(o)}function
|
|
19
|
+
`),process.exit(1)}let t=e[0].schema,s=m+".tmp";try{i.writeFileSync(s,JSON.stringify(t,null,2)),i.renameSync(s,m)}catch(r){try{i.unlinkSync(s)}catch{}throw r}for(let r of se)if(i.existsSync(r))try{i.unlinkSync(r)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${m}`)}function yo(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 B(e){let o=i.readFileSync(e,"utf-8");return o.charCodeAt(0)===65279&&(o=o.slice(1)),JSON.parse(o)}function z(){if(go(),!i.existsSync(m))return{version:0,migrations:[]};let e;try{e=B(m)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
|
|
20
20
|
[FATAL] ${m} 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
21
|
`),process.exit(1)}let o=yo(e);return o===null&&(console.error(`
|
|
22
22
|
[FATAL] ${m} 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.
|
|
@@ -29,7 +29,7 @@ var ke=Object.defineProperty;var P=(e,o)=>{for(var n in o)ke(e,n,{get:o[n],enume
|
|
|
29
29
|
Done. Removed ${n} orphan .tmp + ${t} pre-rollback snapshot(s).`),console.log(` NOTE: .pre-vNNN.backup files are kept \u2014 they're needed for 'rollback-data'.
|
|
30
30
|
`)}function Ao(){let e=[];for(let o of[N,D]){if(!i.existsSync(o))continue;let n=i.readdirSync(o).filter(t=>{let s=t.toLowerCase();return s.endsWith(".json")&&!s.includes(".backup")});for(let t of n){let s=l.join(o,t);try{B(s)}catch(r){e.push({dir:l.basename(o),file:t,err:r.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function ce(e,o){let n=o+".tmp";try{i.copyFileSync(e,n),fe(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 s=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 s.code=t.code,s}throw t}}function me(){console.log(`
|
|
31
31
|
\u{1F4E6} Migration status
|
|
32
|
-
`);let e=
|
|
32
|
+
`);let e=z();if(console.log(` Data root: ${S}`),console.log(` Schema file: ${m}${i.existsSync(m)?"":" (not yet created \u2014 fresh install)"}`),console.log(` Current version: v${e.version}`),e.migrations?.length){console.log(" Applied migrations:");for(let r of e.migrations){if(!r||typeof r!="object"){console.log(` (malformed entry: ${JSON.stringify(r)})`);continue}let c=String(r.version??"?").padStart(3,"0");console.log(` v${c} \u2014 ${r.name??"(no name)"} (at ${r.appliedAt??"?"})`)}}e.rolledBackAt&&console.log(` Last rollback: ${e.rolledBackAt}`);for(let[r,c]of[["collected-profiles",N],["market-research",D]]){if(!i.existsSync(c))continue;let I=i.readdirSync(c).filter(u=>/\.pre-v\d+\.backup$/.test(u));if(I.length){let u=[...new Set(I.map(p=>p.match(/\.pre-v(\d+)\.backup$/)[1]))].sort();console.log(` Pre-migration backups in ${r}/: ${u.map(p=>`v${p} (${I.filter(f=>f.includes(`pre-v${p}`)).length} files)`).join(", ")}`)}}let o=de();o.length>0&&console.log(` Pre-rollback snapshots: ${o.length} file(s) (run 'data-cleanup' to remove)`);let n=pe();if(n.length>0){console.log(` Orphan .tmp files: ${n.length} (will be cleaned on next plugin run, or now via 'data-cleanup')`);for(let r of n)console.log(` ${l.basename(r.dir)}/${r.file}`)}console.log(),console.log(` Latest available schema: v${U}`);let t=R.filter(r=>r.version>e.version);t.length?(console.log(` Pending: ${t.map(r=>`v${String(r.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 s=Ao();if(s.ok)console.log(" Data integrity: \u2713 all JSON files parse cleanly");else{console.log(` Data integrity: \u2717 ${s.broken.length} file(s) corrupted:`);for(let r of s.broken)console.log(` ${r.dir}/${r.file}: ${r.err}`);console.log(" Migrations will refuse to run until these are repaired.")}console.log()}async function ge({confirmed:e=!1}={}){let n=z().version;if(n===0){console.log(`
|
|
33
33
|
No migrations applied \u2014 nothing to roll back.
|
|
34
34
|
`);return}let t=!1,s=`.pre-v${String(n).padStart(3,"0")}.backup`,r=ie(N,s),c=ie(D,s);if(r.length+c.length===0&&(console.error(`
|
|
35
35
|
[ERROR] No backup files (${s}) found in either data directory.`),console.error(` Cannot roll back v${n} \u2014 backups may have been deleted.
|
|
@@ -50,7 +50,7 @@ var ke=Object.defineProperty;var P=(e,o)=>{for(var n in o)ke(e,n,{get:o[n],enume
|
|
|
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
51
|
`),process.exit(1)}b.length===0&&(console.error(`
|
|
52
52
|
[ERROR] No backup files found to restore. Aborting.
|
|
53
|
-
`),process.exit(1));let
|
|
53
|
+
`),process.exit(1));let O=new Date().toISOString(),T=z();T.version=n-1,T.migrations=(T.migrations||[]).filter(a=>a&&Number.isInteger(a.version)&&a.version<n),T.rolledBackAt=O,So(T);let g=0,v=[];for(let{backupPath:a,originalPath:F,fileName:h}of b)try{ce(a,F),g++}catch(w){v.push({fileName:h,err:w.message})}if(v.length>0){console.error(`
|
|
54
54
|
[WARNING] ${v.length} file(s) could not be restored:`);for(let a of v)console.error(` ${a.fileName}: ${a.err}`);console.error(`
|
|
55
55
|
Schema has been lowered to v${n-1} but data is in a mixed state:`),console.error(` ${g} 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${n} 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 *${s} files back over their originals, then`),console.error(" re-run 'rollback-data --confirm' to redo the rollback. Pre-rollback snapshots"),console.error(` (*${u}) are still on disk if you'd rather restore the v${n} state.
|
|
56
56
|
`),process.exit(1)}try{ne()}catch{}try{te()}catch{}M(),t=!1,console.log(`
|
|
@@ -58,5 +58,5 @@ var ke=Object.defineProperty;var P=(e,o)=>{for(var n in o)ke(e,n,{get:o[n],enume
|
|
|
58
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${n} 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
60
|
`),console.log(` If something looks wrong, your pre-rollback snapshot is in *${u} files`),console.log(` \u2014 copy them back manually to undo this rollback.
|
|
61
|
-
`)}var Se=process.argv.slice(2),ye=Se[0]
|
|
61
|
+
`)}var Se=process.argv.slice(2),ye=Se[0],jo=Se.includes("--confirm");async function $o(){switch(ye){case"status":me();break;case"rollback-data":await ge({confirmed:jo});break;case"data-cleanup":he();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(ye?1:0)}}$o().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 p from"fs";import*as g from"path";import{getPluginConfig as _}from"@ilivemylife/graph-sdk";var T=await _();for(let[e,o]of Object.entries(T))process.env[e]===void 0&&(process.env[e]=o);var Y=process.env.LINKEDIN_NAME,
|
|
1
|
+
import"dotenv/config";import*as p from"fs";import*as g from"path";import{getPluginConfig as _}from"@ilivemylife/graph-sdk";var T=await _();for(let[e,o]of Object.entries(T))process.env[e]===void 0&&(process.env[e]=o);var Y=process.env.LINKEDIN_NAME,m=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Q=Object.freeze(new Set([m.DRAFT,m.CONFIRMED,m.NEEDS_REVIEW])),B=Object.freeze(new Set([m.DRAFT,m.CONFIRMED,m.REJECTED,m.NEEDS_REVIEW]));import"dotenv/config";import*as i from"fs";import*as l from"path";import{fileURLToPath as x}from"url";var k=x(import.meta.url),R=l.dirname(l.dirname(k)),u=process.env.DATA_DIR?l.resolve(process.env.DATA_DIR,"collected-profiles"):l.join(R,"collected-profiles"),v=l.join(u,"people.json"),Z=l.join(u,"jobs.json"),ee=l.join(u,"quota.json"),ne=l.join(u,"conversations.json"),oe=l.join(u,"sync-state.json"),te=l.join(u,"application-questions.json"),N=l.join(u,"profile-history"),E=(e,o)=>{let t=parseInt(e,10);return Number.isInteger(t)&&t>=0?t:o},se=E(process.env.CONNECT_MAX_DAILY,20),re=E(process.env.CONNECT_MAX_WEEKLY,100),j=null;function L(){i.existsSync(u)||i.mkdirSync(u,{recursive:!0})}function I(e,o){if(!i.existsSync(e))return null;try{let t=JSON.parse(i.readFileSync(e,"utf-8"));try{i.copyFileSync(e,e+".backup")}catch{}return t}catch(t){console.error(`[!] ${o} is corrupted: ${t.message}`),console.error(` File: ${l.resolve(e)}`);let s=e+".backup";if(i.existsSync(s))try{let n=JSON.parse(i.readFileSync(s,"utf-8"));console.error(` Restored from ${s}`);try{i.copyFileSync(s,e)}catch{}return n}catch{console.error(" Backup also corrupted!")}console.error(` Starting with empty data. Old file preserved as ${e}.corrupted`);try{i.copyFileSync(e,e+".corrupted")}catch{}return null}}function h(e){if(!e)return null;let o=e.match(/\/in\/([^/?#]+)/);return o?o[1].toLowerCase():null}function M(e){let o=h(e);return o?l.join(N,`${o}.json`):null}function $(e){let o=M(e);return o?I(o,`profile-history/${h(e)}.json`)||[]:[]}function S(){return j||(L(),j=I(v,"people.json")||{},j)}var A=process.argv.slice(2),J=A.includes("--all"),w=A.find(e=>e.startsWith("--since="))?.split("=")[1]||null,d=A.find(e=>e.startsWith("--field="))?.split("=")[1]||null,O=A.find(e=>!e.startsWith("--"))||null,P=process.env.DATA_DIR?g.resolve(process.env.DATA_DIR,"collected-profiles"):g.join(process.cwd(),"collected-profiles"),y=g.join(P,"profile-history");function F(){return p.existsSync(y)?p.readdirSync(y).filter(e=>e.endsWith(".json")).map(e=>e.replace(/\.json$/,"")):[]}function V(e){let o=S();for(let t of Object.keys(o))if(h(t)===e)return t;return null}function W(e){let o=e.startsWith("http")?h(e):e.toLowerCase();if(!o){console.log("Could not derive slug");return}let t=V(o),s=S(),n=t?s[t]:null,a=t?$(t):(()=>{let r=g.join(y,`${o}.json`);return p.existsSync(r)?JSON.parse(p.readFileSync(r,"utf-8")):[]})();console.log(`
|
|
2
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(` ${n?.name||"(unknown)"} \u2014 ${o}`),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
3
|
`),n&&(console.log("CURRENT:"),console.log(` title: ${n.title||"(null)"}`),console.log(` location: ${n.location||"(null)"}`),console.log(` currentCompany: ${n.currentCompany||"(null)"}`),console.log(` connectionDeg: ${n.connectionDegree||"(null)"}`),console.log(` openToWork: ${n.openToWork}`),console.log(` hiring: ${n.hiring}`),console.log(` lastUpdated: ${n.lastUpdated||"(null)"}`),console.log(` lastSnapshotAt: ${n.lastSnapshotAt||"(null)"}`)),console.log(`
|
|
4
4
|
HISTORY (${a.length} snapshot${a.length===1?"":"s"}):
|
|
5
5
|
`);for(let r of a){if(console.log(` ${r.capturedAt} changed: [${(r.changedFields||[]).join(", ")}]`),r.snapshot)for(let c of r.changedFields||[]){let f=r.snapshot[c],C=n?n[c]:"?",D=b=>Array.isArray(b)?b.join(", "):b??"(null)";console.log(` ${c.padEnd(18)} OLD: ${D(f)}`),console.log(` ${" ".repeat(18)} NEW: ${D(C)}`)}console.log()}}function q(){let e=F();console.log(`
|
|
6
6
|
${e.length} profiles have history files:
|
|
7
|
-
`);let o=S(),t=[];for(let s of e){let n=Object.keys(o).find(f=>
|
|
7
|
+
`);let o=S(),t=[];for(let s of e){let n=Object.keys(o).find(f=>h(f)===s),a=n?o[n]:null,r=g.join(y,`${s}.json`),c=JSON.parse(p.readFileSync(r,"utf-8"));t.push({slug:s,name:a?.name||"(unknown)",snapshots:c.length,mostRecentChange:c[0]?.capturedAt||null,mostRecentFields:c[0]?.changedFields?.join(", ")||""})}t.sort((s,n)=>(n.mostRecentChange||"").localeCompare(s.mostRecentChange||""));for(let s of t)console.log(` ${s.mostRecentChange?.slice(0,10)||"----------"} ${s.snapshots}\xD7 ${s.name.padEnd(28)} [${s.mostRecentFields}]`)}function U(){let e=F(),o=new Date(w).getTime(),t=S(),s=[];for(let n of e){let a=g.join(y,`${n}.json`),r=JSON.parse(p.readFileSync(a,"utf-8"));for(let c of r){if(new Date(c.capturedAt).getTime()<o||d&&!(c.changedFields||[]).includes(d))continue;let f=Object.keys(t).find(C=>h(C)===n);s.push({date:c.capturedAt,slug:n,name:(f?t[f]:null)?.name||"(unknown)",fields:(c.changedFields||[]).join(", "),...d?{oldValue:c.snapshot?.[d],newValue:(f?t[f]:null)?.[d]}:{}})}}s.sort((n,a)=>a.date.localeCompare(n.date)),console.log(`
|
|
8
8
|
${s.length} change events since ${w}${d?` (field=${d})`:""}:
|
|
9
9
|
`);for(let n of s)if(console.log(` ${n.date.slice(0,10)} ${n.name.padEnd(28)} [${n.fields}]`),d){let a=r=>Array.isArray(r)?r.join(", "):r??"(null)";console.log(` OLD: ${a(n.oldValue)}`),console.log(` NEW: ${a(n.newValue)}`)}}O?W(O):J?q():w?U():(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,4 +1,4 @@
|
|
|
1
|
-
var xe=Object.defineProperty;var U=(e,o)=>{for(var n in o)xe(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 zo=process.env.LINKEDIN_NAME,N=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),Ko=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.NEEDS_REVIEW])),Xo=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.REJECTED,N.NEEDS_REVIEW]));import"dotenv/config";import*as d from"fs";import*as h from"path";import{fileURLToPath as Me}from"url";var Pe=Me(import.meta.url),Je=h.dirname(h.dirname(Pe)),E=process.env.DATA_DIR?h.resolve(process.env.DATA_DIR,"collected-profiles"):h.join(Je,"collected-profiles"),Ue=h.join(E,"people.json"),tn=h.join(E,"jobs.json"),Ve=h.join(E,"quota.json"),sn=h.join(E,"conversations.json"),rn=h.join(E,"sync-state.json"),cn=h.join(E,"application-questions.json"),ln=h.join(E,"profile-history"),ce=(e,o)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:o},re=ce(process.env.CONNECT_MAX_DAILY,20),ie=ce(process.env.CONNECT_MAX_WEEKLY,100),M=null,Be=null,T=null,qe=null,We=null,Ge=null;function le(){M=null,Be=null,T=null,qe=null,We=null,Ge=null}function ae(){d.existsSync(E)||d.mkdirSync(E,{recursive:!0})}function ue(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 s=JSON.parse(d.readFileSync(t,"utf-8"));console.error(` Restored from ${t}`);try{d.copyFileSync(t,e)}catch{}return s}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 G(e){if(!e)return null;let o=e.match(/\/in\/([^/?#]+)/);return o?o[1].toLowerCase():null}function fe(){return M||(ae(),M=ue(Ue,"people.json")||{},M)}function Y(){return T||(ae(),T=ue(Ve,"quota.json"),(!T||!T.connections)&&(T={connections:[]}),T)}function He(){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 pe(){let e=He(),o=Ye(),n=e.filter(s=>s.date===o).length,t=e.length;return{daily:{sent:n,max:re,remaining:re-n},weekly:{sent:t,max:ie,remaining:ie-t}}}import"dotenv/config";import*as i from"fs";import*as oe from"os";import*as u from"path";import{fileURLToPath as Oo}from"url";var z={};U(z,{NAME:()=>ze,VERSION:()=>Qe,up:()=>Ze});import*as S from"fs";import*as V from"path";var Qe=1,ze="normalize-jobs-and-questions",Ke=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Xe=50;function H(e){return S.existsSync(e)?JSON.parse(S.readFileSync(e,"utf-8")):null}function Q(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{S.writeFileSync(t,n)}catch(s){try{S.unlinkSync(t)}catch{}throw s}try{S.renameSync(t,e)}catch(s){try{S.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Ze(e,o){let n=V.join(e,"jobs.json"),t=V.join(o,"scouted-jobs.json"),s=V.join(e,"application-questions.json"),r=H(n)||{},c=H(t)||{},a=0,l=[];for(let f of Object.keys(r)){if(!c[f])continue;let k=c[f],g=r[f];for(let I of Ke)k[I]!=null&&g[I]==null&&(g[I]=k[I]);l.push(f),a++}a>0?(Q(n,r),console.log(` Phase 1: Merged ${a} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let p=H(s);if(p&&Array.isArray(p.applications)){let f={},k=0;for(let g of p.applications){let I=g.jobId||"unknown";f[I]||(f[I]={applications:[]});let se=(g.questions||[]).map($=>{let L={type:$.type||"input",question:$.question||"",answer:$.answer||""};return $.options&&($.options.length<=Xe?L.options=$.options:(L.optionsOmitted=!0,k++)),$.page&&(L.page=$.page),$.wasPreFilled&&(L.wasPreFilled=!0),$.wasRetry&&(L.wasRetry=!0),L});f[I].applications.push({applicationId:g.applicationId,date:g.date,result:g.result||"submitted",formPages:g.formPages||null,duration:g.duration||null,retries:g.retries||0,failedField:g.failedField||null,questionCount:g.questionCount||se.length,questions:se})}Q(s,f),console.log(` Phase 2: Rekeyed ${p.applications.length} applications by jobId (${Object.keys(f).length} unique jobs)`),k>0&&console.log(` Phase 2: Stripped bloated options from ${k} 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(l.length>0){for(let f of l)delete c[f];Q(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 K={};U(K,{NAME:()=>oo,VERSION:()=>eo,up:()=>so});import*as b from"fs";import*as de 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(s){try{b.unlinkSync(t)}catch{}throw s}try{b.renameSync(t,e)}catch(s){try{b.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function so(e){let o=de.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 s of Object.keys(n))n[s].unread===!0&&(n[s].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 X={};U(X,{NAME:()=>io,VERSION:()=>ro,up:()=>fo});import*as v from"fs";import*as he from"path";var ro=3,io="recompute-last-message-by",co=new Set(["draft","confirmed","rejected","needs_review"]);function lo(e){return v.existsSync(e)?JSON.parse(v.readFileSync(e,"utf-8")):null}function ao(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{v.writeFileSync(t,n)}catch(s){try{v.unlinkSync(t)}catch{}throw s}try{v.renameSync(t,e)}catch(s){try{v.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}function uo(e,o){if(!e||e.length===0)return"them";let n=e.filter(r=>!co.has(r.status));if(n.length===0)return"them";let t=n.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,c)=>c.t-r.t).map(r=>r.m),s=t.length>0?t:[...n].reverse();for(let r of s){let c=r.sender;if(c===o)return"me";if(c!=="Unknown"&&c!=="")return"them"}return"them"}async function fo(e){let o=he.join(e,"conversations.json"),n=lo(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 s=0,r=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,r++);let p=Array.isArray(l.messages)?l.messages:[],f=uo(p,t),k=f==="me"?"awaiting_reply":"unanswered_by_us";l.lastMessageBy!==f&&c++,l.lastMessageBy=f,l.conversationStatus=k,s++}if(s===0){console.log(" No conversations to recompute.");return}ao(o,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${c} had stale lastMessageBy (now corrected).`),r>0&&console.log(` Cleaned ${r} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var Z={};U(Z,{NAME:()=>ho,VERSION:()=>po,up:()=>So});import*as w from"fs";import*as ge from"path";var po=4,ho="split-connection-timestamps",go=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function mo(e){if(!w.existsSync(e))return null;let o=w.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{w.writeFileSync(t,n)}catch(s){try{w.unlinkSync(t)}catch{}throw s}try{w.renameSync(t,e)}catch(s){try{w.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function So(e){let o=ge.join(e,"people.json"),n=mo(o);if(!n||typeof n!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let t=0,s=0;for(let r of Object.keys(n)){let c=n[r];!c||typeof c!="object"||(s++,go.has(c.connectionStatus)&&c.connectionDate&&!c.requestedConnectionAt&&(c.requestedConnectionAt=c.connectionDate,c.connectionDate=null,t++))}if(t===0){console.log(` Scanned ${s} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}yo(o,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${t} still-pending people (of ${s} 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 vo=bo(import.meta.url),wo=y.dirname(y.dirname(vo)),P=process.env.DATA_DIR?y.resolve(process.env.DATA_DIR,"market-research"):y.join(wo,"market-research"),pn=y.join(P,"scouted-jobs.json"),dn=y.join(P,"discovered-people.json"),hn=y.join(P,"visit-log.json"),gn=y.join(P,"companies.json"),mn=y.join(P,"job-decisions.json");function me(){ko=null,$o=null,Ao=null,jo=null,Eo=null}var ko=null;var $o=null;var Ao=null;var jo=null;var Eo=null;var Io=Oo(import.meta.url),To=u.dirname(Io),Do=u.dirname(u.dirname(To));function Ro(e){return e&&(e==="~"?oe.homedir():e.startsWith("~/")||e.startsWith("~\\")?u.join(oe.homedir(),e.slice(2)):e)}var A=process.env.DATA_DIR?u.resolve(Ro(process.env.DATA_DIR)):Do,_=u.join(A,"collected-profiles"),x=u.join(A,"market-research"),m=u.join(A,".schema-version"),ye=[u.join(_,".schema-version"),u.join(x,".schema-version")],D=4,O=[{version:1,module:z},{version:2,module:K},{version:3,module:X},{version:4,module:Z}];(function(){O.sort((t,s)=>t.version-s.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 s=t.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=O.length?O[O.length-1].version:0;if(n!==D)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${D}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<O.length;t++){let s=t+1;if(O[t].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${t} but found v${O[t].version}`)}})();function we(){process.env.DATA_DIR!==void 0&&process.env.DATA_DIR.trim()===""&&process.env.DATA_DIR.length>0&&(console.error(`
|
|
1
|
+
var xe=Object.defineProperty;var V=(e,o)=>{for(var n in o)xe(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,N=Object.freeze({DRAFT:"draft",CONFIRMED:"confirmed",REJECTED:"rejected",NEEDS_REVIEW:"needs_review",SENT:"sent"}),zo=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.NEEDS_REVIEW])),Xo=Object.freeze(new Set([N.DRAFT,N.CONFIRMED,N.REJECTED,N.NEEDS_REVIEW]));import"dotenv/config";import*as d from"fs";import*as h from"path";import{fileURLToPath as Me}from"url";var Pe=Me(import.meta.url),Je=h.dirname(h.dirname(Pe)),E=process.env.DATA_DIR?h.resolve(process.env.DATA_DIR,"collected-profiles"):h.join(Je,"collected-profiles"),Ue=h.join(E,"people.json"),tn=h.join(E,"jobs.json"),Ve=h.join(E,"quota.json"),sn=h.join(E,"conversations.json"),rn=h.join(E,"sync-state.json"),cn=h.join(E,"application-questions.json"),ln=h.join(E,"profile-history"),ae=(e,o)=>{let n=parseInt(e,10);return Number.isInteger(n)&&n>=0?n:o},ce=ae(process.env.CONNECT_MAX_DAILY,20),le=ae(process.env.CONNECT_MAX_WEEKLY,100),M=null,Be=null,T=null,qe=null,We=null,Ge=null;function ue(){M=null,Be=null,T=null,qe=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 s=JSON.parse(d.readFileSync(t,"utf-8"));console.error(` Restored from ${t}`);try{d.copyFileSync(t,e)}catch{}return s}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(Ue,"people.json")||{},M)}function H(){return T||(fe(),T=pe(Ve,"quota.json"),(!T||!T.connections)&&(T={connections:[]}),T)}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(s=>s.date===o).length,t=e.length;return{daily:{sent:n,max:ce,remaining:ce-n},weekly:{sent:t,max:le,remaining:le-t}}}import"dotenv/config";import*as i from"fs";import*as ne from"os";import*as u from"path";import{fileURLToPath as Oo}from"url";var z={};V(z,{NAME:()=>Ke,VERSION:()=>Qe,up:()=>Ze});import*as S from"fs";import*as B from"path";var Qe=1,Ke="normalize-jobs-and-questions",ze=["description","techStack","jobTags","seniority","employmentType","industries","jobFunction","postedTime","applicantCount","companySize","workplaceType","contractType","isEasyApply","applyType","companyUrl","scoutedAt","lastSeen"],Xe=50;function Q(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(s){try{S.unlinkSync(t)}catch{}throw s}try{S.renameSync(t,e)}catch(s){try{S.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function Ze(e,o){let n=B.join(e,"jobs.json"),t=B.join(o,"scouted-jobs.json"),s=B.join(e,"application-questions.json"),r=Q(n)||{},c=Q(t)||{},a=0,l=[];for(let f of Object.keys(r)){if(!c[f])continue;let k=c[f],g=r[f];for(let I of ze)k[I]!=null&&g[I]==null&&(g[I]=k[I]);l.push(f),a++}a>0?(K(n,r),console.log(` Phase 1: Merged ${a} scouted jobs into jobs.json`)):console.log(" Phase 1: No overlapping jobs to merge");let p=Q(s);if(p&&Array.isArray(p.applications)){let f={},k=0;for(let g of p.applications){let I=g.jobId||"unknown";f[I]||(f[I]={applications:[]});let ie=(g.questions||[]).map($=>{let L={type:$.type||"input",question:$.question||"",answer:$.answer||""};return $.options&&($.options.length<=Xe?L.options=$.options:(L.optionsOmitted=!0,k++)),$.page&&(L.page=$.page),$.wasPreFilled&&(L.wasPreFilled=!0),$.wasRetry&&(L.wasRetry=!0),L});f[I].applications.push({applicationId:g.applicationId,date:g.date,result:g.result||"submitted",formPages:g.formPages||null,duration:g.duration||null,retries:g.retries||0,failedField:g.failedField||null,questionCount:g.questionCount||ie.length,questions:ie})}K(s,f),console.log(` Phase 2: Rekeyed ${p.applications.length} applications by jobId (${Object.keys(f).length} unique jobs)`),k>0&&console.log(` Phase 2: Stripped bloated options from ${k} 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(l.length>0){for(let f of l)delete c[f];K(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={};V(X,{NAME:()=>oo,VERSION:()=>eo,up:()=>so});import*as b from"fs";import*as ge 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(s){try{b.unlinkSync(t)}catch{}throw s}try{b.renameSync(t,e)}catch(s){try{b.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function so(e){let o=ge.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 s of Object.keys(n))n[s].unread===!0&&(n[s].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={};V(Z,{NAME:()=>io,VERSION:()=>ro,up:()=>fo});import*as v from"fs";import*as me from"path";var ro=3,io="recompute-last-message-by",co=new Set(["draft","confirmed","rejected","needs_review"]);function lo(e){return v.existsSync(e)?JSON.parse(v.readFileSync(e,"utf-8")):null}function ao(e,o){let n=JSON.stringify(o,null,2),t=e+".tmp";try{v.writeFileSync(t,n)}catch(s){try{v.unlinkSync(t)}catch{}throw s}try{v.renameSync(t,e)}catch(s){try{v.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}function uo(e,o){if(!e||e.length===0)return"them";let n=e.filter(r=>!co.has(r.status));if(n.length===0)return"them";let t=n.map(r=>({m:r,t:Date.parse(r.time)})).filter(r=>Number.isFinite(r.t)).sort((r,c)=>c.t-r.t).map(r=>r.m),s=t.length>0?t:[...n].reverse();for(let r of s){let c=r.sender;if(c===o)return"me";if(c!=="Unknown"&&c!=="")return"them"}return"them"}async function fo(e){let o=me.join(e,"conversations.json"),n=lo(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 s=0,r=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,r++);let p=Array.isArray(l.messages)?l.messages:[],f=uo(p,t),k=f==="me"?"awaiting_reply":"unanswered_by_us";l.lastMessageBy!==f&&c++,l.lastMessageBy=f,l.conversationStatus=k,s++}if(s===0){console.log(" No conversations to recompute.");return}ao(o,n),console.log(` Recomputed lastMessageBy + conversationStatus on ${s} conversations.`),console.log(` ${c} had stale lastMessageBy (now corrected).`),r>0&&console.log(` Cleaned ${r} leftover _cardSynced flags.`),console.log(" Re-run 'ilml linkedin enrich' if you want actionNeeded / summary / autoTags to also update.")}var ee={};V(ee,{NAME:()=>ho,VERSION:()=>po,up:()=>So});import*as w from"fs";import*as ye from"path";var po=4,ho="split-connection-timestamps",go=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]);function mo(e){if(!w.existsSync(e))return null;let o=w.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{w.writeFileSync(t,n)}catch(s){try{w.unlinkSync(t)}catch{}throw s}try{w.renameSync(t,e)}catch(s){try{w.unlinkSync(t)}catch{}if(s.code==="EPERM"||s.code==="EBUSY"){let r=new Error(`File locked: ${e} (${s.code}). On Windows usually antivirus / file explorer / open editor. Close it and re-run.`);throw r.code=s.code,r}throw s}}async function So(e){let o=ye.join(e,"people.json"),n=mo(o);if(!n||typeof n!="object"){console.log(" people.json not found \u2014 nothing to migrate.");return}let t=0,s=0;for(let r of Object.keys(n)){let c=n[r];!c||typeof c!="object"||(s++,go.has(c.connectionStatus)&&c.connectionDate&&!c.requestedConnectionAt&&(c.requestedConnectionAt=c.connectionDate,c.connectionDate=null,t++))}if(t===0){console.log(` Scanned ${s} people \u2014 none needed the connectionDate\u2192requestedConnectionAt move.`);return}yo(o,n),console.log(` Moved connectionDate \u2192 requestedConnectionAt on ${t} still-pending people (of ${s} 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 vo=bo(import.meta.url),wo=y.dirname(y.dirname(vo)),P=process.env.DATA_DIR?y.resolve(process.env.DATA_DIR,"market-research"):y.join(wo,"market-research"),pn=y.join(P,"scouted-jobs.json"),dn=y.join(P,"discovered-people.json"),hn=y.join(P,"visit-log.json"),gn=y.join(P,"companies.json"),mn=y.join(P,"job-decisions.json");function Se(){ko=null,$o=null,Ao=null,jo=null,Eo=null}var ko=null;var $o=null;var Ao=null;var jo=null;var Eo=null;var Io=Oo(import.meta.url),To=u.dirname(Io),Do=u.dirname(u.dirname(To));function Ro(e){return e&&(e==="~"?ne.homedir():e.startsWith("~/")||e.startsWith("~\\")?u.join(ne.homedir(),e.slice(2)):e)}var A=process.env.DATA_DIR?u.resolve(Ro(process.env.DATA_DIR)):Do,_=u.join(A,"collected-profiles"),x=u.join(A,"market-research"),m=u.join(A,".schema-version"),be=[u.join(_,".schema-version"),u.join(x,".schema-version")],D=4,O=[{version:1,module:z},{version:2,module:X},{version:3,module:Z},{version:4,module:ee}];(function(){O.sort((t,s)=>t.version-s.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 s=t.module;if(!s||typeof s.up!="function")throw new Error(`MIGRATION_REGISTRY: v${t.version} module is missing up()`);if(s.VERSION!==void 0&&s.VERSION!==t.version)throw new Error(`MIGRATION_REGISTRY: v${t.version} entry does not match module VERSION (${s.VERSION}). Drift between registry and module \u2014 pick one source of truth.`)}let n=O.length?O[O.length-1].version:0;if(n!==D)throw new Error(`MIGRATION_REGISTRY: highest version v${n} but CURRENT_SCHEMA_VERSION=${D}. Forgot to bump CURRENT_SCHEMA_VERSION when adding the new migration?`);for(let t=0;t<O.length;t++){let s=t+1;if(O[t].version!==s)throw new Error(`MIGRATION_REGISTRY: gap detected \u2014 expected v${s} at position ${t} but found v${O[t].version}`)}})();function $e(){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
3
|
`),process.exit(1));try{i.mkdirSync(A,{recursive:!0})}catch(o){o.code!=="EEXIST"&&(console.error(`
|
|
4
4
|
[FATAL] Cannot create DATA_DIR (${A}): ${o.message}`),console.error(` Fix the path or permissions and try again.
|
|
@@ -11,16 +11,16 @@ var xe=Object.defineProperty;var U=(e,o)=>{for(var n in o)xe(e,n,{get:o[n],enume
|
|
|
11
11
|
`),process.exit(1))}}var C=u.join(A,".migration-lock");function No(){let e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()},null,2);try{return i.writeFileSync(C,e,{flag:"wx"}),!0}catch(t){if(t.code!=="EEXIST")throw t}let o;try{o=JSON.parse(i.readFileSync(C,"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 s=24*60*60*1e3,r=1/0;if(o.startedAt){let c=Date.parse(o.startedAt);Number.isNaN(c)||(r=Date.now()-c)}t&&r<s&&(console.error(`
|
|
12
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: ${C}
|
|
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&&r>=s&&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=C+".tmp";try{return i.writeFileSync(n,e),i.renameSync(n,C),!0}catch(t){try{i.unlinkSync(n)}catch{}throw new Error(`Failed to take over stale migration lock: ${t.message}`)}}function
|
|
14
|
+
`),process.exit(1)),t&&r>=s&&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=C+".tmp";try{return i.writeFileSync(n,e),i.renameSync(n,C),!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(C,"utf-8")).pid!==process.pid)return;i.unlinkSync(C)}catch{}}var ve=!1;function Co(){if(ve)return;ve=!0;let e=()=>{try{te()}catch{}process.exit(1)};for(let o of["SIGINT","SIGTERM","SIGHUP"])try{process.on(o,e)}catch{}}function _o(){if(i.existsSync(m))return;let e=[],o=[];for(let r of be)if(i.existsSync(r))try{e.push({file:r,schema:q(r)})}catch(c){o.push({file:r,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 r of o)console.error(` ${r.file}: ${r.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(r=>r.schema.version);if(new Set(n).size>1){console.error(`
|
|
18
18
|
[FATAL] Legacy .schema-version files disagree:`);for(let r of e)console.error(` ${r.file}: v${r.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,s=m+".tmp";try{i.writeFileSync(s,JSON.stringify(t,null,2)),i.renameSync(s,m)}catch(r){try{i.unlinkSync(s)}catch{}throw r}for(let r of
|
|
19
|
+
`),process.exit(1)}let t=e[0].schema,s=m+".tmp";try{i.writeFileSync(s,JSON.stringify(t,null,2)),i.renameSync(s,m)}catch(r){try{i.unlinkSync(s)}catch{}throw r}for(let r of be)if(i.existsSync(r))try{i.unlinkSync(r)}catch{}console.log(` Consolidated legacy .schema-version files \u2192 ${m}`)}function xo(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 q(e){let o=i.readFileSync(e,"utf-8");return o.charCodeAt(0)===65279&&(o=o.slice(1)),JSON.parse(o)}function we(){if(_o(),!i.existsSync(m))return{version:0,migrations:[]};let e;try{e=q(m)}catch(n){if(n.code==="ENOENT")return{version:0,migrations:[]};console.error(`
|
|
20
20
|
[FATAL] ${m} 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
21
|
`),process.exit(1)}let o=xo(e);return o===null&&(console.error(`
|
|
22
22
|
[FATAL] ${m} 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
|
|
23
|
+
`),process.exit(1)),o}function Ae(e){try{i.chmodSync(e,384)}catch{}}function Fo(e){if($e(),i.existsSync(m))try{if(i.lstatSync(m).isSymbolicLink())throw new Error(`SCHEMA_FILE is a symbolic link: ${m}. 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=m+".tmp";try{i.writeFileSync(o,JSON.stringify(e,null,2)),Ae(o),i.renameSync(o,m)}catch(n){try{i.unlinkSync(o)}catch{}throw n}}function ke(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}}),s=0,r=0,c=[];for(let a of t){let l=u.join(e,a),p=u.join(e,a+n);if(i.existsSync(p)){r++;continue}try{Ee(l,p),s++}catch(f){c.push({file:a,err:f.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(s>0||r>0){let a=r>0?` (${r} pre-existing backup(s) preserved)`:"";console.log(` Backed up ${s} files in ${u.basename(e)}/ (${n})${a}`)}}var oe=!1;async function je(){if(oe)return;$e(),Uo();let o=we().version;if(o===D){oe=!0;return}Co(),No(),process.on("exit",te),o>D&&(console.error(`
|
|
24
24
|
[FATAL] Your data schema is at v${o}, but this plugin build only understands up to v${D}.`),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
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${D}.
|
|
26
26
|
`),process.exit(1)),console.log(`
|
|
@@ -28,21 +28,21 @@ var xe=Object.defineProperty;var U=(e,o)=>{for(var n in o)xe(e,n,{get:o[n],enume
|
|
|
28
28
|
[FATAL] Cannot migrate \u2014 current data is corrupted:`);for(let s of n.broken)console.error(` ${s.dir}/${s.file}: ${s.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
30
|
`),process.exit(1)}let t=O.filter(s=>s.version>o);for(let s of t){console.log(`
|
|
31
|
-
Running migration v${String(s.version).padStart(3,"0")}...`);let r=`v${String(s.version).padStart(3,"0")}`,c=`.pre-${r}.backup`;try{
|
|
31
|
+
Running migration v${String(s.version).padStart(3,"0")}...`);let r=`v${String(s.version).padStart(3,"0")}`,c=`.pre-${r}.backup`;try{ke(_,s.version),ke(x,s.version)}catch(l){console.error(`
|
|
32
32
|
[FATAL] Pre-migration backup failed for ${r}: ${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
33
|
`),process.exit(1)}let a=s.module;try{await a.up(_,x)}catch(l){console.error(`
|
|
34
34
|
[FATAL] Migration ${r} failed: ${l.message}`),console.error(` Attempting auto-rollback from ${c} files...`);try{let p=Bo(c);p.ok?(console.error(` \u2713 Auto-rollback restored ${p.restored} files. Schema stays at v${o}.`),console.error(` The migration will be retried on next plugin command. Fix the root cause first.
|
|
35
35
|
`)):(console.error(` [!] Auto-rollback INCOMPLETE: ${p.error}`),console.error(` Manual recovery: copy *${c} files back over the originals.
|
|
36
36
|
`))}catch(p){console.error(` [!] Auto-rollback CRASHED while restoring: ${p.message}`),console.error(` Manual recovery: copy *${c} files back over the originals.
|
|
37
|
-
`)}process.exit(1)}try{let l=new Date().toISOString(),p={version:s.version,name:a.NAME||r,appliedAt:l},f=
|
|
37
|
+
`)}process.exit(1)}try{let l=new Date().toISOString(),p={version:s.version,name:a.NAME||r,appliedAt:l},f=we();f.version=s.version,f.migratedAt=l,f.migrations=f.migrations||[],f.migrations.push(p),Fo(f)}catch(l){console.error(`
|
|
38
38
|
[FATAL] Migration ${r} applied successfully but schema version file could NOT be updated: ${l.message}`),console.error(` Your data is in the v${s.version} state but .schema-version still shows v${o}.`),console.error(` On next plugin command the runner will try to re-apply ${r}. 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 ${r} complete`)}try{
|
|
39
|
+
`),process.exit(1)}console.log(` \u2713 Migration ${r} complete`)}try{ue()}catch{}try{Se()}catch{}oe=!0,te(),console.log(`
|
|
40
40
|
\u2713 Schema is now at v${D}
|
|
41
|
-
`)}var Lo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function Mo(e){let o=e.toLowerCase();return Lo.some(n=>n.test(o))}var Po=6e4;function Jo(){let e=Date.now(),o=[];for(let n of[A,_,x]){if(!i.existsSync(n))continue;let t;try{t=i.readdirSync(n)}catch{continue}for(let s of t){if(!Mo(s))continue;let r=u.join(n,s);try{let c=i.statSync(r);if(!c.isFile()||e-c.mtimeMs<Po)continue;o.push({dir:n,file:s,fullPath:r})}catch{}}}return o}function Uo({verbose:e=!1}={}){let o=Jo();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(s){console.warn(` [!] Could not remove orphan ${t.fullPath}: ${s.message}`)}return!e&&n>0&&console.log(` Cleaned up ${n} orphan .tmp file(s) from previous run.`),n}function Vo(){let e=[];for(let o of[_,x]){if(!i.existsSync(o))continue;let n=i.readdirSync(o).filter(t=>{let s=t.toLowerCase();return s.endsWith(".json")&&!s.includes(".backup")});for(let t of n){let s=u.join(o,t);try{
|
|
41
|
+
`)}var Lo=[/\.json\.tmp$/,/\.schema-version\.tmp$/,/\.backup\.tmp$/];function Mo(e){let o=e.toLowerCase();return Lo.some(n=>n.test(o))}var Po=6e4;function Jo(){let e=Date.now(),o=[];for(let n of[A,_,x]){if(!i.existsSync(n))continue;let t;try{t=i.readdirSync(n)}catch{continue}for(let s of t){if(!Mo(s))continue;let r=u.join(n,s);try{let c=i.statSync(r);if(!c.isFile()||e-c.mtimeMs<Po)continue;o.push({dir:n,file:s,fullPath:r})}catch{}}}return o}function Uo({verbose:e=!1}={}){let o=Jo();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(s){console.warn(` [!] Could not remove orphan ${t.fullPath}: ${s.message}`)}return!e&&n>0&&console.log(` Cleaned up ${n} orphan .tmp file(s) from previous run.`),n}function Vo(){let e=[];for(let o of[_,x]){if(!i.existsSync(o))continue;let n=i.readdirSync(o).filter(t=>{let s=t.toLowerCase();return s.endsWith(".json")&&!s.includes(".backup")});for(let t of n){let s=u.join(o,t);try{q(s)}catch(r){e.push({dir:u.basename(o),file:t,err:r.message})}}}return e.length===0?{ok:!0}:{ok:!1,broken:e}}function Bo(e){let o=[],n=[];for(let r of[_,x]){if(!i.existsSync(r))continue;let c=i.readdirSync(r).filter(a=>a.endsWith(e));for(let a of c){let l=u.join(r,a),p=a.slice(0,-e.length),f=u.join(r,p);try{p.toLowerCase().endsWith(".json")?q(l):i.accessSync(l,i.constants.R_OK),o.push({backupPath:l,originalPath:f,fileName:a,dir:r})}catch(k){n.push(`${u.basename(r)}/${a}: ${k.message}`)}}}if(n.length>0)return{ok:!1,error:n.join("; "),restored:0};let t=0,s=[];for(let{backupPath:r,originalPath:c,fileName:a,dir:l}of o)try{Ee(r,c),t++}catch(p){s.push(`${u.basename(l)}/${a}: ${p.message}`)}return s.length>0?{ok:!1,error:s.join("; "),restored:t}:{ok:!0,restored:t}}function Ee(e,o){let n=o+".tmp";try{i.copyFileSync(e,n),Ae(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 s=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 s.code=t.code,s}throw t}}var De=process.argv.includes("--json"),Re=new Set(["connected"]),Ne=new Set(["pending","sent_without_note","sent_with_note","sent_without_note_upsell"]),se=["founder","investor","hiring_manager","peer"],qo=new Date().toISOString().split("T")[0];function Ce(e){if(!e)return 1/0;let o=new Date(e+"T00:00:00Z").getTime(),n=new Date(qo+"T00:00:00Z").getTime();return Math.round((n-o)/864e5)}function Wo(e,o,n=20){return o?"\u2588".repeat(Math.max(0,Math.round(e/o*n))):""}De||await je();var Go=H(),G=Go.connections||[],j=he(),re=de(),J=new Map;for(let[e,o]of Object.entries(re)){let n=Y(o.profileUrl||e);n&&!J.has(n)&&J.set(n,o)}for(let e of Object.values(re))for(let o of e.aliases||[])o&&!J.has(o)&&J.set(o,e);var Yo=G.filter(e=>Ce(e.date)<=7),R={},W={};for(let e of Yo){R[e.date]=(R[e.date]||0)+1;let o=e.source||"unknown";W[o]=(W[o]||0)+1}var F={},Oe=new Set;for(let e of G){let o=e.source||"unknown",n=Y(e.profileUrl),t=`${o}|${n}`;if(n&&Oe.has(t))continue;n&&Oe.add(t),F[o]||={sent:0,accepted:0,awaiting:0,stale:0,unknown:0};let s=F[o];s.sent++;let c=(n?J.get(n):null)?.connectionStatus;Re.has(c)?s.accepted++:Ne.has(c)?(s.awaiting++,Ce(e.date)>14&&s.stale++):s.unknown++}var U={};for(let e of se)U[e]=0;for(let e of Object.values(re)){let o=e.category;if(!se.includes(o))continue;let n=e.connectionStatus;Re.has(n)||Ne.has(n)||e.connectionDegree!=="1st"&&U[o]++}var _e=Object.values(U).reduce((e,o)=>e+o,0);De&&(console.log(JSON.stringify({state:j,byDay:R,bySource7d:W,acceptance:F,feederPool:{...U,total:_e},totalLogged:G.length},null,2)),process.exit(0));var Ie=(e,o)=>o?`${Math.round(e/o*100)}%`:"\u2014";console.log(`
|
|
42
42
|
=== LinkedIn Connection Quota ===
|
|
43
|
-
`);console.log("State");console.log(` Today: ${j.daily.sent} / ${j.daily.max} (${j.daily.remaining} left)`);console.log(` Week: ${j.weekly.sent} / ${j.weekly.max} (${j.weekly.remaining} left) \u2014 rolling 7 days`);console.log(` Log: ${
|
|
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} ${Wo(R[o],e).padEnd(20)} ${R[o]}`);console.log(""),console.log(" by source (7d): "+Object.entries(
|
|
43
|
+
`);console.log("State");console.log(` Today: ${j.daily.sent} / ${j.daily.max} (${j.daily.remaining} left)`);console.log(` Week: ${j.weekly.sent} / ${j.weekly.max} (${j.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} ${Wo(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
|
|
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)+Ie(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)+Ie(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 se)console.log(` ${e.padEnd(16)} ${U[e]}`);console.log(` ${"TOTAL".padEnd(16)} ${_e}`);console.log(` \u2192 these could absorb idle daily quota once the category feeder is wired.
|
|
47
47
|
`);j.daily.sent===0&&j.daily.remaining>0&&(console.log(`\u26A0 Today's quota is idle (0/${j.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
|
`));
|