peopledatalabs
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -1,2 +0,2 @@ | ||
import e from"axios";function t(){return t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},t.apply(this,arguments)}var n=function(e,t,n,i,a){return new Promise(function(s,r){var o={};if(e||(o.message="Missing "+(i||"Params"),o.status=400,r(o)),"search"===a&&(e.searchQuery||(o.message="Missing searchQuery",o.status=400,r(o))),"retrieve"===a&&(e.id||(o.message="Missing id",o.status=400,r(o))),"autocomplete"===a){var c=e.field,u=["company","country","industry","location","major","region","role","school","sub_role","skill","title"];c?-1===u.indexOf(c)&&(o.message="field should be one of: "+u,o.status=400,r(o)):(o.message="Missing field",o.status=400,r(o))}"jobTitle"===a&&(e.jobTitle||(o.message="Missing jobTitle",o.status=400,r(o))),"skill"===a&&(e.skill||(o.message="Missing skill",o.status=400,r(o))),t||(o.message="Missing API Base Path",o.status=400,r(o)),n&&64===n.length||(o.message="Invalid API Key",o.status=401,r(o)),s()})},i=function(e){var t={400:"Request contained either missing or invalid parameters",401:"Request contained a missing or invalid key",402:"Payment Required, You have hit your account maximum (all matches used)",404:"No records were found matching your request",405:"Request method is not allowed on the requested resource",429:"An error occurred due to requests hitting the API too quick",500:"The server encountered an unexpected condition which prevented it from fulfilling the request"};if(e.response){var n=e.response.status,i=n>=500&&n<600?500:n;return{status:i,message:t[i]}}return{status:500,message:t[500]}},a=function(e){var n={rateLimitRemaining:e.headers["x-ratelimit-remaining"]?JSON.parse(e.headers["x-ratelimit-remaining"].replace(/'/g,'"')):void 0,rateLimitReset:e.headers["x-ratelimit-reset"]||void 0,rateLimitLimit:e.headers["x-ratelimit-limit"]?JSON.parse(e.headers["x-ratelimit-limit"].replace(/'/g,'"')):void 0,totalLimitOveragesRemaining:e.headers["x-totallimit-overages-remaining"]?Number(e.headers["x-totallimit-overages-remaining"]):void 0,totalLimitPurchasedRemaining:e.headers["x-totallimit-purchased-remaining"]?Number(e.headers["x-totallimit-purchased-remaining"]):void 0,totalLimitRemaining:e.headers["x-totallimit-remaining"]?Number(e.headers["x-totallimit-remaining"]):void 0,callCreditsType:e.headers["x-call-credits-type"]||void 0,callCreditsSpent:e.headers["x-call-credits-spent"]?Number(e.headers["x-call-credits-spent"]):void 0,lifetimeUsed:e.headers["x-lifetime-used"]?Number(e.headers["x-lifetime-used"]):void 0};return Array.isArray(e.data)?{items:e.data,rateLimit:n}:t({},e.data,{rateLimit:n})},s=function(s,r,o,c){return new Promise(function(u,l){n(o,s,r,null,"cleaner").then(function(){e.get(s+"/"+c+"/clean",{params:t({api_key:r},o),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(a(e))}).catch(function(e){l(i(e))})}).catch(function(e){l(e)})})},r=function(s,r,o,c,u){return new Promise(function(l,h){n(c,s,o,null,"enrichment").then(function(){var n=c.sandbox&&"person"===u?r+"/"+u+"/enrich":s+"/"+u+"/enrich",d=c;delete d.sandbox,e.get(n,{params:t({api_key:o},d),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(a(e))}).catch(function(e){h(i(e))})}).catch(function(e){h(e)})})},o=function(t,s,r,o,c,u){return new Promise(function(l,h){n(c,t,r,null,"search").then(function(){var n,d=c.pretty,p=c.sandbox,m=((n={titlecase:c.titlecase||!1,dataset:c.dataset||"all",scroll_token:c.scroll_token||null,size:c.size||10})["sql"===o?"sql":"query"]=c.searchQuery,n.pretty=d||!1,n);e.post(p&&"person"===u?s+"/person/search":t+"/"+u+"/search",m,{headers:{"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":r,"User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(a(e))}).catch(function(e){h(i(e))})}).catch(function(e){h(e)})})},c=function(c){var u=this,l=c.apiKey,h=c.basePath,d=c.sandboxBasePath,p=c.version;this.apiKey=void 0,this.basePath=void 0,this.sandboxBasePath=void 0,this.person=void 0,this.company=void 0,this.school=void 0,this.location=void 0,this.autocomplete=void 0,this.skill=void 0,this.jobTitle=void 0,this.apiKey=l,this.basePath=h||"https://api.peopledatalabs.com/"+(p||"v5"),this.sandboxBasePath=d||"https://sandbox.api.peopledatalabs.com/"+(p||"v5"),this.person={enrichment:function(e){return r(u.basePath,u.sandboxBasePath,u.apiKey,e,"person")},search:{elastic:function(e){return o(u.basePath,u.sandboxBasePath,u.apiKey,"elastic",e,"person")},sql:function(e){return o(u.basePath,u.sandboxBasePath,u.apiKey,"sql",e,"person")}},bulk:function(t){return function(t,s,r){var o={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":s,"User-Agent":"PDL-JS-SDK"};return new Promise(function(c,u){n(r,t,s,"Records","bulk").then(function(){e.post(t+"/person/bulk",r,{headers:o}).then(function(e){c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,t)},identify:function(s){return function(s,r,o,c){return new Promise(function(u,l){n(c,s,o,null,"identify").then(function(){var n=c.sandbox?r+"/person/identify":s+"/person/identify",h=c;delete h.sandbox,e.get(n,{params:t({api_key:o},h),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(a(e))}).catch(function(e){l(i(e))})}).catch(function(e){l(e)})})}(u.basePath,u.sandboxBasePath,u.apiKey,s)},retrieve:function(s){return function(s,r,o){return new Promise(function(c,u){n(o,s,r,"ID","retrieve").then(function(){e.get(s+"/person/retrieve/"+o.id,{params:t({api_key:r},o),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,s)}},this.company={enrichment:function(e){return r(u.basePath,u.sandboxBasePath,u.apiKey,e,"company")},search:{elastic:function(e){return o(u.basePath,u.sandboxBasePath,u.apiKey,"elastic",e,"company")},sql:function(e){return o(u.basePath,u.sandboxBasePath,u.apiKey,"sql",e,"company")}},cleaner:function(e){return s(u.basePath,u.apiKey,e,"company")}},this.school={cleaner:function(e){return s(u.basePath,u.apiKey,e,"school")}},this.location={cleaner:function(e){return s(u.basePath,u.apiKey,e,"location")}},this.autocomplete=function(s){return function(s,r,o){return new Promise(function(c,u){n(o,s,r,null,"autocomplete").then(function(){e.get(s+"/autocomplete",{params:t({api_key:r},{field:o.field,text:o.text||"",size:o.size||10,pretty:o.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,s)},this.jobTitle=function(s){return function(s,r,o){return new Promise(function(c,u){n(o,s,r,null,"jobTitle").then(function(){e.get(s+"/job_title/enrich",{params:t({api_key:r},{job_title:o.jobTitle,pretty:o.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,s)},this.skill=function(s){return function(s,r,o){return new Promise(function(c,u){n(o,s,r,null,"skill").then(function(){e.get(s+"/skill/enrich",{params:t({api_key:r},{skill:o.skill,pretty:o.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,s)}};export{c as default}; | ||
import e from"axios";function t(){return t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},t.apply(this,arguments)}var n=function(e,t,n,i,a){return new Promise(function(s,r){var o={};if(e||(o.message="Missing "+(i||"Params"),o.status=400,r(o)),"search"===a&&(e.searchQuery||(o.message="Missing searchQuery",o.status=400,r(o))),"retrieve"===a&&(e.id||(o.message="Missing id",o.status=400,r(o))),"autocomplete"===a){var c=e.field,u=["company","country","industry","location","major","region","role","school","sub_role","skill","title"];c?-1===u.indexOf(c)&&(o.message="field should be one of: "+u,o.status=400,r(o)):(o.message="Missing field",o.status=400,r(o))}"jobTitle"===a&&(e.jobTitle||(o.message="Missing jobTitle",o.status=400,r(o))),"skill"===a&&(e.skill||(o.message="Missing skill",o.status=400,r(o))),t||(o.message="Missing API Base Path",o.status=400,r(o)),n&&64===n.length||(o.message="Invalid API Key",o.status=401,r(o)),s()})},i=function(e){var t={400:"Request contained either missing or invalid parameters",401:"Request contained a missing or invalid key",402:"Payment Required, You have hit your account maximum (all matches used)",404:"No records were found matching your request",405:"Request method is not allowed on the requested resource",429:"An error occurred due to requests hitting the API too quick",500:"The server encountered an unexpected condition which prevented it from fulfilling the request"};if(e.response){var n=e.response.status,i=n>=500&&n<600?500:n;return{status:i,message:t[i]}}return{status:500,message:t[500]}},a=function(e){var n={rateLimitRemaining:e.headers["x-ratelimit-remaining"]?JSON.parse(e.headers["x-ratelimit-remaining"].replace(/'/g,'"')):void 0,rateLimitReset:e.headers["x-ratelimit-reset"]||void 0,rateLimitLimit:e.headers["x-ratelimit-limit"]?JSON.parse(e.headers["x-ratelimit-limit"].replace(/'/g,'"')):void 0,totalLimitOveragesRemaining:e.headers["x-totallimit-overages-remaining"]?Number(e.headers["x-totallimit-overages-remaining"]):void 0,totalLimitPurchasedRemaining:e.headers["x-totallimit-purchased-remaining"]?Number(e.headers["x-totallimit-purchased-remaining"]):void 0,totalLimitRemaining:e.headers["x-totallimit-remaining"]?Number(e.headers["x-totallimit-remaining"]):void 0,callCreditsType:e.headers["x-call-credits-type"]||void 0,callCreditsSpent:e.headers["x-call-credits-spent"]?Number(e.headers["x-call-credits-spent"]):void 0,lifetimeUsed:e.headers["x-lifetime-used"]?Number(e.headers["x-lifetime-used"]):void 0};return Array.isArray(e.data)?{items:e.data,rateLimit:n}:t({},e.data,{rateLimit:n})},s=function(s,r,o,c){return new Promise(function(u,l){n(o,s,r,null,"cleaner").then(function(){e.get(s+"/"+c+"/clean",{params:t({api_key:r},o),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(a(e))}).catch(function(e){l(i(e))})}).catch(function(e){l(e)})})},r=function(s,r,o,c,u){return new Promise(function(l,h){n(c,s,o,null,"enrichment").then(function(){var n=c.sandbox&&"person"===u?r+"/"+u+"/enrich":s+"/"+u+"/enrich",d=c;delete d.sandbox,Object.entries(d).forEach(function(e){var t=e[1];"object"==typeof t&&(d[e[0]]=JSON.stringify(t))}),e.get(n,{params:t({api_key:o},d),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(a(e))}).catch(function(e){h(i(e))})}).catch(function(e){h(e)})})},o=function(t,s,r,o,c,u){return new Promise(function(l,h){n(c,t,r,null,"search").then(function(){var n,d=c.pretty,p=c.sandbox,f=((n={titlecase:c.titlecase||!1,dataset:c.dataset||"all",scroll_token:c.scroll_token||null,size:c.size||10})["sql"===o?"sql":"query"]=c.searchQuery,n.pretty=d||!1,n);e.post(p&&"person"===u?s+"/person/search":t+"/"+u+"/search",f,{headers:{"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":r,"User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(a(e))}).catch(function(e){h(i(e))})}).catch(function(e){h(e)})})},c=function(c){var u=this,l=c.apiKey,h=c.basePath,d=c.sandboxBasePath,p=c.version;this.apiKey=void 0,this.basePath=void 0,this.sandboxBasePath=void 0,this.person=void 0,this.company=void 0,this.school=void 0,this.location=void 0,this.autocomplete=void 0,this.skill=void 0,this.jobTitle=void 0,this.apiKey=l,this.basePath=h||"https://api.peopledatalabs.com/"+(p||"v5"),this.sandboxBasePath=d||"https://sandbox.api.peopledatalabs.com/"+(p||"v5"),this.person={enrichment:function(e){return r(u.basePath,u.sandboxBasePath,u.apiKey,e,"person")},search:{elastic:function(e){return o(u.basePath,u.sandboxBasePath,u.apiKey,"elastic",e,"person")},sql:function(e){return o(u.basePath,u.sandboxBasePath,u.apiKey,"sql",e,"person")}},bulk:function(t){return function(t,s,r){var o={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":s,"User-Agent":"PDL-JS-SDK"};return new Promise(function(c,u){n(r,t,s,"Records","bulk").then(function(){e.post(t+"/person/bulk",r,{headers:o}).then(function(e){c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,t)},identify:function(s){return function(s,r,o,c){return new Promise(function(u,l){n(c,s,o,null,"identify").then(function(){var n=c.sandbox?r+"/person/identify":s+"/person/identify",h=c;delete h.sandbox,Object.entries(h).forEach(function(e){var t=e[1];"object"==typeof t&&(h[e[0]]=JSON.stringify(t))}),e.get(n,{params:t({api_key:o},h),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(a(e))}).catch(function(e){l(i(e))})}).catch(function(e){l(e)})})}(u.basePath,u.sandboxBasePath,u.apiKey,s)},retrieve:function(s){return function(s,r,o){return new Promise(function(c,u){n(o,s,r,"ID","retrieve").then(function(){e.get(s+"/person/retrieve/"+o.id,{params:t({api_key:r},o),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,s)}},this.company={enrichment:function(e){return r(u.basePath,u.sandboxBasePath,u.apiKey,e,"company")},search:{elastic:function(e){return o(u.basePath,u.sandboxBasePath,u.apiKey,"elastic",e,"company")},sql:function(e){return o(u.basePath,u.sandboxBasePath,u.apiKey,"sql",e,"company")}},cleaner:function(e){return s(u.basePath,u.apiKey,e,"company")}},this.school={cleaner:function(e){return s(u.basePath,u.apiKey,e,"school")}},this.location={cleaner:function(e){return s(u.basePath,u.apiKey,e,"location")}},this.autocomplete=function(s){return function(s,r,o){return new Promise(function(c,u){n(o,s,r,null,"autocomplete").then(function(){e.get(s+"/autocomplete",{params:t({api_key:r},{field:o.field,text:o.text||"",size:o.size||10,pretty:o.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,s)},this.jobTitle=function(s){return function(s,r,o){return new Promise(function(c,u){n(o,s,r,null,"jobTitle").then(function(){e.get(s+"/job_title/enrich",{params:t({api_key:r},{job_title:o.jobTitle,pretty:o.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,s)},this.skill=function(s){return function(s,r,o){return new Promise(function(c,u){n(o,s,r,null,"skill").then(function(){e.get(s+"/skill/enrich",{params:t({api_key:r},{skill:o.skill,pretty:o.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(a(e))}).catch(function(e){u(i(e))})}).catch(function(e){u(e)})})}(u.basePath,u.apiKey,s)}};export{c as default}; | ||
//# sourceMappingURL=index.m.js.map |
@@ -1,2 +0,2 @@ | ||
import e from"axios";function t(){return t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},t.apply(this,arguments)}const s=(e,t,s,a,i)=>new Promise((n,r)=>{const o={};if(e||(o.message=`Missing ${a||"Params"}`,o.status=400,r(o)),"search"===i){const{searchQuery:t}=e;t||(o.message="Missing searchQuery",o.status=400,r(o))}if("retrieve"===i){const{id:t}=e;t||(o.message="Missing id",o.status=400,r(o))}if("autocomplete"===i){const{field:t}=e,s=["company","country","industry","location","major","region","role","school","sub_role","skill","title"];t?-1===s.indexOf(t)&&(o.message=`field should be one of: ${s}`,o.status=400,r(o)):(o.message="Missing field",o.status=400,r(o))}if("jobTitle"===i){const{jobTitle:t}=e;t||(o.message="Missing jobTitle",o.status=400,r(o))}if("skill"===i){const{skill:t}=e;t||(o.message="Missing skill",o.status=400,r(o))}t||(o.message="Missing API Base Path",o.status=400,r(o)),s&&64===s.length||(o.message="Invalid API Key",o.status=401,r(o)),n()}),a=e=>{const t={400:"Request contained either missing or invalid parameters",401:"Request contained a missing or invalid key",402:"Payment Required, You have hit your account maximum (all matches used)",404:"No records were found matching your request",405:"Request method is not allowed on the requested resource",429:"An error occurred due to requests hitting the API too quick",500:"The server encountered an unexpected condition which prevented it from fulfilling the request"};if(e.response){const{status:s}=e.response,a=s>=500&&s<600?500:s;return{status:a,message:t[a]}}return{status:500,message:t[500]}},i=e=>{const s={rateLimitRemaining:e.headers["x-ratelimit-remaining"]?JSON.parse(e.headers["x-ratelimit-remaining"].replace(/'/g,'"')):void 0,rateLimitReset:e.headers["x-ratelimit-reset"]||void 0,rateLimitLimit:e.headers["x-ratelimit-limit"]?JSON.parse(e.headers["x-ratelimit-limit"].replace(/'/g,'"')):void 0,totalLimitOveragesRemaining:e.headers["x-totallimit-overages-remaining"]?Number(e.headers["x-totallimit-overages-remaining"]):void 0,totalLimitPurchasedRemaining:e.headers["x-totallimit-purchased-remaining"]?Number(e.headers["x-totallimit-purchased-remaining"]):void 0,totalLimitRemaining:e.headers["x-totallimit-remaining"]?Number(e.headers["x-totallimit-remaining"]):void 0,callCreditsType:e.headers["x-call-credits-type"]||void 0,callCreditsSpent:e.headers["x-call-credits-spent"]?Number(e.headers["x-call-credits-spent"]):void 0,lifetimeUsed:e.headers["x-lifetime-used"]?Number(e.headers["x-lifetime-used"]):void 0};return Array.isArray(e.data)?{items:e.data,rateLimit:s}:t({},e.data,{rateLimit:s})};var n=(n,r,o,h)=>new Promise((l,c)=>{s(o,n,r,null,"cleaner").then(()=>{e.get(`${n}/${h}/clean`,{params:t({api_key:r},o),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(i(e))}).catch(e=>{c(a(e))})}).catch(e=>{c(e)})}),r=(n,r,o,h,l)=>new Promise((c,d)=>{s(h,n,o,null,"enrichment").then(()=>{const s=h.sandbox&&"person"===l?`${r}/${l}/enrich`:`${n}/${l}/enrich`,p=h;delete p.sandbox,e.get(s,{params:t({api_key:o},p),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(i(e))}).catch(e=>{d(a(e))})}).catch(e=>{d(e)})}),o=(t,n,r,o,h,l)=>new Promise((c,d)=>{s(h,t,r,null,"search").then(()=>{const{dataset:s,searchQuery:p,size:m,scroll_token:u,titlecase:g,pretty:y,sandbox:b}=h;e.post(b&&"person"===l?`${n}/person/search`:`${t}/${l}/search`,{titlecase:g||!1,dataset:s||"all",scroll_token:u||null,size:m||10,["sql"===o?"sql":"query"]:p,pretty:y||!1},{headers:{"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":r,"User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(i(e))}).catch(e=>{d(a(e))})}).catch(e=>{d(e)})});class h{constructor({apiKey:h,basePath:l,sandboxBasePath:c,version:d}){this.apiKey=void 0,this.basePath=void 0,this.sandboxBasePath=void 0,this.person=void 0,this.company=void 0,this.school=void 0,this.location=void 0,this.autocomplete=void 0,this.skill=void 0,this.jobTitle=void 0,this.apiKey=h,this.basePath=l||`https://api.peopledatalabs.com/${d||"v5"}`,this.sandboxBasePath=c||`https://sandbox.api.peopledatalabs.com/${d||"v5"}`,this.person={enrichment:e=>r(this.basePath,this.sandboxBasePath,this.apiKey,e,"person"),search:{elastic:e=>o(this.basePath,this.sandboxBasePath,this.apiKey,"elastic",e,"person"),sql:e=>o(this.basePath,this.sandboxBasePath,this.apiKey,"sql",e,"person")},bulk:t=>((t,n,r)=>{const o={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":n,"User-Agent":"PDL-JS-SDK"};return new Promise((h,l)=>{s(r,t,n,"Records","bulk").then(()=>{e.post(`${t}/person/bulk`,r,{headers:o}).then(e=>{h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})})})(this.basePath,this.apiKey,t),identify:n=>((n,r,o,h)=>new Promise((l,c)=>{s(h,n,o,null,"identify").then(()=>{const s=h.sandbox?`${r}/person/identify`:`${n}/person/identify`,d=h;delete d.sandbox,e.get(s,{params:t({api_key:o},d),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(i(e))}).catch(e=>{c(a(e))})}).catch(e=>{c(e)})}))(this.basePath,this.sandboxBasePath,this.apiKey,n),retrieve:n=>((n,r,o)=>new Promise((h,l)=>{s(o,n,r,"ID","retrieve").then(()=>{e.get(`${n}/person/retrieve/${o.id}`,{params:t({api_key:r},o),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})}))(this.basePath,this.apiKey,n)},this.company={enrichment:e=>r(this.basePath,this.sandboxBasePath,this.apiKey,e,"company"),search:{elastic:e=>o(this.basePath,this.sandboxBasePath,this.apiKey,"elastic",e,"company"),sql:e=>o(this.basePath,this.sandboxBasePath,this.apiKey,"sql",e,"company")},cleaner:e=>n(this.basePath,this.apiKey,e,"company")},this.school={cleaner:e=>n(this.basePath,this.apiKey,e,"school")},this.location={cleaner:e=>n(this.basePath,this.apiKey,e,"location")},this.autocomplete=n=>((n,r,o)=>new Promise((h,l)=>{s(o,n,r,null,"autocomplete").then(()=>{const{field:s,text:c,size:d,pretty:p}=o;e.get(`${n}/autocomplete`,{params:t({api_key:r},{field:s,text:c||"",size:d||10,pretty:p||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})}))(this.basePath,this.apiKey,n),this.jobTitle=n=>((n,r,o)=>new Promise((h,l)=>{s(o,n,r,null,"jobTitle").then(()=>{const{jobTitle:s,pretty:c}=o;e.get(`${n}/job_title/enrich`,{params:t({api_key:r},{job_title:s,pretty:c||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})}))(this.basePath,this.apiKey,n),this.skill=n=>((n,r,o)=>new Promise((h,l)=>{s(o,n,r,null,"skill").then(()=>{const{skill:s,pretty:c}=o;e.get(`${n}/skill/enrich`,{params:t({api_key:r},{skill:s,pretty:c||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})}))(this.basePath,this.apiKey,n)}}export{h as default}; | ||
import e from"axios";function t(){return t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var s=arguments[t];for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(e[a]=s[a])}return e},t.apply(this,arguments)}const s=(e,t,s,a,i)=>new Promise((n,r)=>{const o={};if(e||(o.message=`Missing ${a||"Params"}`,o.status=400,r(o)),"search"===i){const{searchQuery:t}=e;t||(o.message="Missing searchQuery",o.status=400,r(o))}if("retrieve"===i){const{id:t}=e;t||(o.message="Missing id",o.status=400,r(o))}if("autocomplete"===i){const{field:t}=e,s=["company","country","industry","location","major","region","role","school","sub_role","skill","title"];t?-1===s.indexOf(t)&&(o.message=`field should be one of: ${s}`,o.status=400,r(o)):(o.message="Missing field",o.status=400,r(o))}if("jobTitle"===i){const{jobTitle:t}=e;t||(o.message="Missing jobTitle",o.status=400,r(o))}if("skill"===i){const{skill:t}=e;t||(o.message="Missing skill",o.status=400,r(o))}t||(o.message="Missing API Base Path",o.status=400,r(o)),s&&64===s.length||(o.message="Invalid API Key",o.status=401,r(o)),n()}),a=e=>{const t={400:"Request contained either missing or invalid parameters",401:"Request contained a missing or invalid key",402:"Payment Required, You have hit your account maximum (all matches used)",404:"No records were found matching your request",405:"Request method is not allowed on the requested resource",429:"An error occurred due to requests hitting the API too quick",500:"The server encountered an unexpected condition which prevented it from fulfilling the request"};if(e.response){const{status:s}=e.response,a=s>=500&&s<600?500:s;return{status:a,message:t[a]}}return{status:500,message:t[500]}},i=e=>{const s={rateLimitRemaining:e.headers["x-ratelimit-remaining"]?JSON.parse(e.headers["x-ratelimit-remaining"].replace(/'/g,'"')):void 0,rateLimitReset:e.headers["x-ratelimit-reset"]||void 0,rateLimitLimit:e.headers["x-ratelimit-limit"]?JSON.parse(e.headers["x-ratelimit-limit"].replace(/'/g,'"')):void 0,totalLimitOveragesRemaining:e.headers["x-totallimit-overages-remaining"]?Number(e.headers["x-totallimit-overages-remaining"]):void 0,totalLimitPurchasedRemaining:e.headers["x-totallimit-purchased-remaining"]?Number(e.headers["x-totallimit-purchased-remaining"]):void 0,totalLimitRemaining:e.headers["x-totallimit-remaining"]?Number(e.headers["x-totallimit-remaining"]):void 0,callCreditsType:e.headers["x-call-credits-type"]||void 0,callCreditsSpent:e.headers["x-call-credits-spent"]?Number(e.headers["x-call-credits-spent"]):void 0,lifetimeUsed:e.headers["x-lifetime-used"]?Number(e.headers["x-lifetime-used"]):void 0};return Array.isArray(e.data)?{items:e.data,rateLimit:s}:t({},e.data,{rateLimit:s})};var n=(n,r,o,h)=>new Promise((l,c)=>{s(o,n,r,null,"cleaner").then(()=>{e.get(`${n}/${h}/clean`,{params:t({api_key:r},o),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(i(e))}).catch(e=>{c(a(e))})}).catch(e=>{c(e)})}),r=(n,r,o,h,l)=>new Promise((c,d)=>{s(h,n,o,null,"enrichment").then(()=>{const s=h.sandbox&&"person"===l?`${r}/${l}/enrich`:`${n}/${l}/enrich`,p=h;delete p.sandbox,Object.entries(p).forEach(([e,t])=>{"object"==typeof t&&(p[e]=JSON.stringify(t))}),e.get(s,{params:t({api_key:o},p),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(i(e))}).catch(e=>{d(a(e))})}).catch(e=>{d(e)})}),o=(t,n,r,o,h,l)=>new Promise((c,d)=>{s(h,t,r,null,"search").then(()=>{const{dataset:s,searchQuery:p,size:m,scroll_token:u,titlecase:g,pretty:y,sandbox:b}=h;e.post(b&&"person"===l?`${n}/person/search`:`${t}/${l}/search`,{titlecase:g||!1,dataset:s||"all",scroll_token:u||null,size:m||10,["sql"===o?"sql":"query"]:p,pretty:y||!1},{headers:{"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":r,"User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(i(e))}).catch(e=>{d(a(e))})}).catch(e=>{d(e)})});class h{constructor({apiKey:h,basePath:l,sandboxBasePath:c,version:d}){this.apiKey=void 0,this.basePath=void 0,this.sandboxBasePath=void 0,this.person=void 0,this.company=void 0,this.school=void 0,this.location=void 0,this.autocomplete=void 0,this.skill=void 0,this.jobTitle=void 0,this.apiKey=h,this.basePath=l||`https://api.peopledatalabs.com/${d||"v5"}`,this.sandboxBasePath=c||`https://sandbox.api.peopledatalabs.com/${d||"v5"}`,this.person={enrichment:e=>r(this.basePath,this.sandboxBasePath,this.apiKey,e,"person"),search:{elastic:e=>o(this.basePath,this.sandboxBasePath,this.apiKey,"elastic",e,"person"),sql:e=>o(this.basePath,this.sandboxBasePath,this.apiKey,"sql",e,"person")},bulk:t=>((t,n,r)=>{const o={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":n,"User-Agent":"PDL-JS-SDK"};return new Promise((h,l)=>{s(r,t,n,"Records","bulk").then(()=>{e.post(`${t}/person/bulk`,r,{headers:o}).then(e=>{h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})})})(this.basePath,this.apiKey,t),identify:n=>((n,r,o,h)=>new Promise((l,c)=>{s(h,n,o,null,"identify").then(()=>{const s=h.sandbox?`${r}/person/identify`:`${n}/person/identify`,d=h;delete d.sandbox,Object.entries(d).forEach(([e,t])=>{"object"==typeof t&&(d[e]=JSON.stringify(t))}),e.get(s,{params:t({api_key:o},d),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(i(e))}).catch(e=>{c(a(e))})}).catch(e=>{c(e)})}))(this.basePath,this.sandboxBasePath,this.apiKey,n),retrieve:n=>((n,r,o)=>new Promise((h,l)=>{s(o,n,r,"ID","retrieve").then(()=>{e.get(`${n}/person/retrieve/${o.id}`,{params:t({api_key:r},o),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})}))(this.basePath,this.apiKey,n)},this.company={enrichment:e=>r(this.basePath,this.sandboxBasePath,this.apiKey,e,"company"),search:{elastic:e=>o(this.basePath,this.sandboxBasePath,this.apiKey,"elastic",e,"company"),sql:e=>o(this.basePath,this.sandboxBasePath,this.apiKey,"sql",e,"company")},cleaner:e=>n(this.basePath,this.apiKey,e,"company")},this.school={cleaner:e=>n(this.basePath,this.apiKey,e,"school")},this.location={cleaner:e=>n(this.basePath,this.apiKey,e,"location")},this.autocomplete=n=>((n,r,o)=>new Promise((h,l)=>{s(o,n,r,null,"autocomplete").then(()=>{const{field:s,text:c,size:d,pretty:p}=o;e.get(`${n}/autocomplete`,{params:t({api_key:r},{field:s,text:c||"",size:d||10,pretty:p||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})}))(this.basePath,this.apiKey,n),this.jobTitle=n=>((n,r,o)=>new Promise((h,l)=>{s(o,n,r,null,"jobTitle").then(()=>{const{jobTitle:s,pretty:c}=o;e.get(`${n}/job_title/enrich`,{params:t({api_key:r},{job_title:s,pretty:c||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})}))(this.basePath,this.apiKey,n),this.skill=n=>((n,r,o)=>new Promise((h,l)=>{s(o,n,r,null,"skill").then(()=>{const{skill:s,pretty:c}=o;e.get(`${n}/skill/enrich`,{params:t({api_key:r},{skill:s,pretty:c||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(e=>{var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&h(i(e))}).catch(e=>{l(a(e))})}).catch(e=>{l(e)})}))(this.basePath,this.apiKey,n)}}export{h as default}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("axios")):"function"==typeof define&&define.amd?define(["axios"],t):(e||self).peopledatalabs=t(e.axios)}(this,function(e){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/t(e);function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},i.apply(this,arguments)}var a=function(e,t,n,i,a){return new Promise(function(s,o){var r={};if(e||(r.message="Missing "+(i||"Params"),r.status=400,o(r)),"search"===a&&(e.searchQuery||(r.message="Missing searchQuery",r.status=400,o(r))),"retrieve"===a&&(e.id||(r.message="Missing id",r.status=400,o(r))),"autocomplete"===a){var c=e.field,u=["company","country","industry","location","major","region","role","school","sub_role","skill","title"];c?-1===u.indexOf(c)&&(r.message="field should be one of: "+u,r.status=400,o(r)):(r.message="Missing field",r.status=400,o(r))}"jobTitle"===a&&(e.jobTitle||(r.message="Missing jobTitle",r.status=400,o(r))),"skill"===a&&(e.skill||(r.message="Missing skill",r.status=400,o(r))),t||(r.message="Missing API Base Path",r.status=400,o(r)),n&&64===n.length||(r.message="Invalid API Key",r.status=401,o(r)),s()})},s=function(e){var t={400:"Request contained either missing or invalid parameters",401:"Request contained a missing or invalid key",402:"Payment Required, You have hit your account maximum (all matches used)",404:"No records were found matching your request",405:"Request method is not allowed on the requested resource",429:"An error occurred due to requests hitting the API too quick",500:"The server encountered an unexpected condition which prevented it from fulfilling the request"};if(e.response){var n=e.response.status,i=n>=500&&n<600?500:n;return{status:i,message:t[i]}}return{status:500,message:t[500]}},o=function(e){var t={rateLimitRemaining:e.headers["x-ratelimit-remaining"]?JSON.parse(e.headers["x-ratelimit-remaining"].replace(/'/g,'"')):void 0,rateLimitReset:e.headers["x-ratelimit-reset"]||void 0,rateLimitLimit:e.headers["x-ratelimit-limit"]?JSON.parse(e.headers["x-ratelimit-limit"].replace(/'/g,'"')):void 0,totalLimitOveragesRemaining:e.headers["x-totallimit-overages-remaining"]?Number(e.headers["x-totallimit-overages-remaining"]):void 0,totalLimitPurchasedRemaining:e.headers["x-totallimit-purchased-remaining"]?Number(e.headers["x-totallimit-purchased-remaining"]):void 0,totalLimitRemaining:e.headers["x-totallimit-remaining"]?Number(e.headers["x-totallimit-remaining"]):void 0,callCreditsType:e.headers["x-call-credits-type"]||void 0,callCreditsSpent:e.headers["x-call-credits-spent"]?Number(e.headers["x-call-credits-spent"]):void 0,lifetimeUsed:e.headers["x-lifetime-used"]?Number(e.headers["x-lifetime-used"]):void 0};return Array.isArray(e.data)?{items:e.data,rateLimit:t}:i({},e.data,{rateLimit:t})},r=function(e,t,r,c){return new Promise(function(u,l){a(r,e,t,null,"cleaner").then(function(){n.default.get(e+"/"+c+"/clean",{params:i({api_key:t},r),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(o(e))}).catch(function(e){l(s(e))})}).catch(function(e){l(e)})})},c=function(e,t,r,c,u){return new Promise(function(l,d){a(c,e,r,null,"enrichment").then(function(){var a=c.sandbox&&"person"===u?t+"/"+u+"/enrich":e+"/"+u+"/enrich",h=c;delete h.sandbox,n.default.get(a,{params:i({api_key:r},h),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(o(e))}).catch(function(e){d(s(e))})}).catch(function(e){d(e)})})},u=function(e,t,i,r,c,u){return new Promise(function(l,d){a(c,e,i,null,"search").then(function(){var a,h=c.pretty,p=c.sandbox,f=((a={titlecase:c.titlecase||!1,dataset:c.dataset||"all",scroll_token:c.scroll_token||null,size:c.size||10})["sql"===r?"sql":"query"]=c.searchQuery,a.pretty=h||!1,a);n.default.post(p&&"person"===u?t+"/person/search":e+"/"+u+"/search",f,{headers:{"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":i,"User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(o(e))}).catch(function(e){d(s(e))})}).catch(function(e){d(e)})})};return function(e){var t=this,l=e.apiKey,d=e.basePath,h=e.sandboxBasePath,p=e.version;this.apiKey=void 0,this.basePath=void 0,this.sandboxBasePath=void 0,this.person=void 0,this.company=void 0,this.school=void 0,this.location=void 0,this.autocomplete=void 0,this.skill=void 0,this.jobTitle=void 0,this.apiKey=l,this.basePath=d||"https://api.peopledatalabs.com/"+(p||"v5"),this.sandboxBasePath=h||"https://sandbox.api.peopledatalabs.com/"+(p||"v5"),this.person={enrichment:function(e){return c(t.basePath,t.sandboxBasePath,t.apiKey,e,"person")},search:{elastic:function(e){return u(t.basePath,t.sandboxBasePath,t.apiKey,"elastic",e,"person")},sql:function(e){return u(t.basePath,t.sandboxBasePath,t.apiKey,"sql",e,"person")}},bulk:function(e){return function(e,t,i){var r={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":t,"User-Agent":"PDL-JS-SDK"};return new Promise(function(c,u){a(i,e,t,"Records","bulk").then(function(){n.default.post(e+"/person/bulk",i,{headers:r}).then(function(e){c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)},identify:function(e){return function(e,t,r,c){return new Promise(function(u,l){a(c,e,r,null,"identify").then(function(){var a=c.sandbox?t+"/person/identify":e+"/person/identify",d=c;delete d.sandbox,n.default.get(a,{params:i({api_key:r},d),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(o(e))}).catch(function(e){l(s(e))})}).catch(function(e){l(e)})})}(t.basePath,t.sandboxBasePath,t.apiKey,e)},retrieve:function(e){return function(e,t,r){return new Promise(function(c,u){a(r,e,t,"ID","retrieve").then(function(){n.default.get(e+"/person/retrieve/"+r.id,{params:i({api_key:t},r),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)}},this.company={enrichment:function(e){return c(t.basePath,t.sandboxBasePath,t.apiKey,e,"company")},search:{elastic:function(e){return u(t.basePath,t.sandboxBasePath,t.apiKey,"elastic",e,"company")},sql:function(e){return u(t.basePath,t.sandboxBasePath,t.apiKey,"sql",e,"company")}},cleaner:function(e){return r(t.basePath,t.apiKey,e,"company")}},this.school={cleaner:function(e){return r(t.basePath,t.apiKey,e,"school")}},this.location={cleaner:function(e){return r(t.basePath,t.apiKey,e,"location")}},this.autocomplete=function(e){return function(e,t,r){return new Promise(function(c,u){a(r,e,t,null,"autocomplete").then(function(){n.default.get(e+"/autocomplete",{params:i({api_key:t},{field:r.field,text:r.text||"",size:r.size||10,pretty:r.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)},this.jobTitle=function(e){return function(e,t,r){return new Promise(function(c,u){a(r,e,t,null,"jobTitle").then(function(){n.default.get(e+"/job_title/enrich",{params:i({api_key:t},{job_title:r.jobTitle,pretty:r.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)},this.skill=function(e){return function(e,t,r){return new Promise(function(c,u){a(r,e,t,null,"skill").then(function(){n.default.get(e+"/skill/enrich",{params:i({api_key:t},{skill:r.skill,pretty:r.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)}}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("axios")):"function"==typeof define&&define.amd?define(["axios"],t):(e||self).peopledatalabs=t(e.axios)}(this,function(e){function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=/*#__PURE__*/t(e);function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},i.apply(this,arguments)}var a=function(e,t,n,i,a){return new Promise(function(s,o){var r={};if(e||(r.message="Missing "+(i||"Params"),r.status=400,o(r)),"search"===a&&(e.searchQuery||(r.message="Missing searchQuery",r.status=400,o(r))),"retrieve"===a&&(e.id||(r.message="Missing id",r.status=400,o(r))),"autocomplete"===a){var c=e.field,u=["company","country","industry","location","major","region","role","school","sub_role","skill","title"];c?-1===u.indexOf(c)&&(r.message="field should be one of: "+u,r.status=400,o(r)):(r.message="Missing field",r.status=400,o(r))}"jobTitle"===a&&(e.jobTitle||(r.message="Missing jobTitle",r.status=400,o(r))),"skill"===a&&(e.skill||(r.message="Missing skill",r.status=400,o(r))),t||(r.message="Missing API Base Path",r.status=400,o(r)),n&&64===n.length||(r.message="Invalid API Key",r.status=401,o(r)),s()})},s=function(e){var t={400:"Request contained either missing or invalid parameters",401:"Request contained a missing or invalid key",402:"Payment Required, You have hit your account maximum (all matches used)",404:"No records were found matching your request",405:"Request method is not allowed on the requested resource",429:"An error occurred due to requests hitting the API too quick",500:"The server encountered an unexpected condition which prevented it from fulfilling the request"};if(e.response){var n=e.response.status,i=n>=500&&n<600?500:n;return{status:i,message:t[i]}}return{status:500,message:t[500]}},o=function(e){var t={rateLimitRemaining:e.headers["x-ratelimit-remaining"]?JSON.parse(e.headers["x-ratelimit-remaining"].replace(/'/g,'"')):void 0,rateLimitReset:e.headers["x-ratelimit-reset"]||void 0,rateLimitLimit:e.headers["x-ratelimit-limit"]?JSON.parse(e.headers["x-ratelimit-limit"].replace(/'/g,'"')):void 0,totalLimitOveragesRemaining:e.headers["x-totallimit-overages-remaining"]?Number(e.headers["x-totallimit-overages-remaining"]):void 0,totalLimitPurchasedRemaining:e.headers["x-totallimit-purchased-remaining"]?Number(e.headers["x-totallimit-purchased-remaining"]):void 0,totalLimitRemaining:e.headers["x-totallimit-remaining"]?Number(e.headers["x-totallimit-remaining"]):void 0,callCreditsType:e.headers["x-call-credits-type"]||void 0,callCreditsSpent:e.headers["x-call-credits-spent"]?Number(e.headers["x-call-credits-spent"]):void 0,lifetimeUsed:e.headers["x-lifetime-used"]?Number(e.headers["x-lifetime-used"]):void 0};return Array.isArray(e.data)?{items:e.data,rateLimit:t}:i({},e.data,{rateLimit:t})},r=function(e,t,r,c){return new Promise(function(u,l){a(r,e,t,null,"cleaner").then(function(){n.default.get(e+"/"+c+"/clean",{params:i({api_key:t},r),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(o(e))}).catch(function(e){l(s(e))})}).catch(function(e){l(e)})})},c=function(e,t,r,c,u){return new Promise(function(l,d){a(c,e,r,null,"enrichment").then(function(){var a=c.sandbox&&"person"===u?t+"/"+u+"/enrich":e+"/"+u+"/enrich",h=c;delete h.sandbox,Object.entries(h).forEach(function(e){var t=e[1];"object"==typeof t&&(h[e[0]]=JSON.stringify(t))}),n.default.get(a,{params:i({api_key:r},h),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(o(e))}).catch(function(e){d(s(e))})}).catch(function(e){d(e)})})},u=function(e,t,i,r,c,u){return new Promise(function(l,d){a(c,e,i,null,"search").then(function(){var a,h=c.pretty,f=c.sandbox,p=((a={titlecase:c.titlecase||!1,dataset:c.dataset||"all",scroll_token:c.scroll_token||null,size:c.size||10})["sql"===r?"sql":"query"]=c.searchQuery,a.pretty=h||!1,a);n.default.post(f&&"person"===u?t+"/person/search":e+"/"+u+"/search",p,{headers:{"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":i,"User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&l(o(e))}).catch(function(e){d(s(e))})}).catch(function(e){d(e)})})};return function(e){var t=this,l=e.apiKey,d=e.basePath,h=e.sandboxBasePath,f=e.version;this.apiKey=void 0,this.basePath=void 0,this.sandboxBasePath=void 0,this.person=void 0,this.company=void 0,this.school=void 0,this.location=void 0,this.autocomplete=void 0,this.skill=void 0,this.jobTitle=void 0,this.apiKey=l,this.basePath=d||"https://api.peopledatalabs.com/"+(f||"v5"),this.sandboxBasePath=h||"https://sandbox.api.peopledatalabs.com/"+(f||"v5"),this.person={enrichment:function(e){return c(t.basePath,t.sandboxBasePath,t.apiKey,e,"person")},search:{elastic:function(e){return u(t.basePath,t.sandboxBasePath,t.apiKey,"elastic",e,"person")},sql:function(e){return u(t.basePath,t.sandboxBasePath,t.apiKey,"sql",e,"person")}},bulk:function(e){return function(e,t,i){var r={"Content-Type":"application/json","Accept-Encoding":"gzip","X-Api-Key":t,"User-Agent":"PDL-JS-SDK"};return new Promise(function(c,u){a(i,e,t,"Records","bulk").then(function(){n.default.post(e+"/person/bulk",i,{headers:r}).then(function(e){c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)},identify:function(e){return function(e,t,r,c){return new Promise(function(u,l){a(c,e,r,null,"identify").then(function(){var a=c.sandbox?t+"/person/identify":e+"/person/identify",d=c;delete d.sandbox,Object.entries(d).forEach(function(e){var t=e[1];"object"==typeof t&&(d[e[0]]=JSON.stringify(t))}),n.default.get(a,{params:i({api_key:r},d),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&u(o(e))}).catch(function(e){l(s(e))})}).catch(function(e){l(e)})})}(t.basePath,t.sandboxBasePath,t.apiKey,e)},retrieve:function(e){return function(e,t,r){return new Promise(function(c,u){a(r,e,t,"ID","retrieve").then(function(){n.default.get(e+"/person/retrieve/"+r.id,{params:i({api_key:t},r),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)}},this.company={enrichment:function(e){return c(t.basePath,t.sandboxBasePath,t.apiKey,e,"company")},search:{elastic:function(e){return u(t.basePath,t.sandboxBasePath,t.apiKey,"elastic",e,"company")},sql:function(e){return u(t.basePath,t.sandboxBasePath,t.apiKey,"sql",e,"company")}},cleaner:function(e){return r(t.basePath,t.apiKey,e,"company")}},this.school={cleaner:function(e){return r(t.basePath,t.apiKey,e,"school")}},this.location={cleaner:function(e){return r(t.basePath,t.apiKey,e,"location")}},this.autocomplete=function(e){return function(e,t,r){return new Promise(function(c,u){a(r,e,t,null,"autocomplete").then(function(){n.default.get(e+"/autocomplete",{params:i({api_key:t},{field:r.field,text:r.text||"",size:r.size||10,pretty:r.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)},this.jobTitle=function(e){return function(e,t,r){return new Promise(function(c,u){a(r,e,t,null,"jobTitle").then(function(){n.default.get(e+"/job_title/enrich",{params:i({api_key:t},{job_title:r.jobTitle,pretty:r.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)},this.skill=function(e){return function(e,t,r){return new Promise(function(c,u){a(r,e,t,null,"skill").then(function(){n.default.get(e+"/skill/enrich",{params:i({api_key:t},{skill:r.skill,pretty:r.pretty||!1}),headers:{"Accept-Encoding":"gzip","User-Agent":"PDL-JS-SDK"}}).then(function(e){var t;200===(null==e||null==(t=e.data)?void 0:t.status)&&c(o(e))}).catch(function(e){u(s(e))})}).catch(function(e){u(e)})})}(t.basePath,t.apiKey,e)}}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "peopledatalabs", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "JavaScript client with TypeScript support for the People Data Labs API", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
216936
767