@inploi/sdk 2.8.2 → 2.9.0
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/cdn/index.js +1 -1
- package/dist/index.d.mts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as pt}from"./chunk-KC7FKSIJ.mjs";var Y="%c[inploi SDK]",z="color: #65BC67; font-weight: bold;",ve={warn:(...t)=>console.warn(Y,z,...t),error:(...t)=>console.error(Y,z,...t),info:(...t)=>console.info(Y,z,...t),log:(...t)=>console.log(Y,z,...t)},ge={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var dt=t=>t;function fe(t,n){if(!t)throw new Error(n)}function F(t,n){return n in t}var mn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var ut="Unauthenticated",mt="This action is unauthorized.",O=class extends Error{constructor(r,i){super(r);this.status=i,this.name="ErrorWithStatus"}},B=class extends O{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},U=class extends O{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},R=class extends O{constructor(r,i){let c=i?` in ${i}`:"";super(`Schema validation failed${c}`);this.issues=r;this.source=i;this.name="SchemaValidationError",this.status=400}},q=class extends O{constructor(r,i,c){super(r);this.data=c;this.name="ApiError",this.status=i??500}},vt=t=>t instanceof q&&t.data!==void 0,M=class extends O{constructor(r){super("Error parsing response into JSON.");this.response=r;this.name="ParsingError",this.status=r&&r.status>=300?r.status:500,this.contentType=new Headers(r?.headers).get("content-type")??void 0}};async function he(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new M(t);return t.json().catch(()=>{throw new M(t)})}var gt=["message","error","errors","exception","exceptions"];function ft(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of gt)if(F(t,r)){let i=t[r];typeof i=="string"&&n.push(i),Array.isArray(i)&&i.every(c=>typeof c=="string")&&n.push(...i)}F(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&F(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&F(t.integration_response.error,"message")&&typeof t.integration_response.error.message=="string"&&n.push(t.integration_response.error.message)}return n.length===0&&n.push("Unknown error"),[...new Set(n)].join(", ")}function ye(t,n){if(n>=300){let r=ft(t);throw n===404?new B(r):r===ut?new U("You are not authenticated.",n):r===mt?new U(r,n):new q(r,n,t)}}var Pe=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,i={})=>{let c={...i,headers:{...i.headers,...n}},l=await fetch(`${t.baseUrl}${r}`,c);if(l.status===404)throw new B;let d=await he(l);return ye(d,l.status),d}}},ke={NotFound:B,Unauthorised:U,SchemaValidation:R,Api:q,JsonParsing:M};function ht(t){return Object.values(ke).some(n=>t instanceof n)}var Re="2.8.2";var Q={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Ce={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Le=Re;var C="isdk_session",Z=`${C}-candidate_id`,De=`${C}-consent`;var X=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16));var Ne=7*24*60*60*1e3,je=t=>{let n=new Date;return n.setTime(n.getTime()+Ne),`${C}=${t};expires=${n.toUTCString()};path=/`},St=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let i=sessionStorage.getItem(`${C}-session_id`);return typeof i=="string"?i:null},bt=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Z);return typeof t=="string"&&t!==""?t:null}catch{return null}},_t=t=>{if(!(typeof window>"u"))try{t?window.localStorage.setItem(Z,t):window.localStorage.removeItem(Z)}catch{}},Tt=new RegExp(`(?:^|;\\s*)${C}=([^;]+)`),J=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?Tt.exec(n)?.[1]??null:null},Fe=()=>{try{let t=JSON.parse(window.localStorage.getItem(C)??"null");return typeof t!="object"||t===null||!("id"in t)||!("expires"in t)||typeof t.id!="string"||typeof t.expires!="number"?null:t.id!==""&&t.expires>Date.now()?t.id:null}catch{return null}},Oe=()=>J()??(new URL(location.href).searchParams.get("anonymous_id")?null:Fe()),xt=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Be=t=>{if(document.cookie=je(t)+xt(),J()!==t)try{window.localStorage.setItem(C,JSON.stringify({id:t,expires:Date.now()+Ne}))}catch{}},Se=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?J(t)??r.get("anonymous_id"):J()??r.get("anonymous_id")??Fe(),session_id:St(r,typeof window>"u")}},Ue=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=Se().anonymous_id;if(t)return t;let n=X(),r=Se().anonymous_id;return r||(Be(n),n)},Et=t=>typeof t!="object"||t===null?null:{anonymous_id:"anonymous_id"in t&&typeof t.anonymous_id=="string"?t.anonymous_id:null,session_id:"session_id"in t&&typeof t.session_id=="string"?t.session_id:null},It=t=>t==="about:client"?"":t,At={pathname:"/log",method:"POST",schema:{response:D(),body:D()}},qe=({rpcClient:t,logger:n,onEvent:r,talentBank:i,persistence:c="device"})=>{let l=null,d=0,u=0,g=p=>c==="none"?{anonymous_id:null,session_id:p?null:l}:Se(p),I=async(p,y)=>{try{let f={library:{name:"inploi-sdk",version:Le},page:y},A=g(p.request);c==="device"&&p.event==="IDENTIFY"&&!A.anonymous_id&&!p.request&&typeof window<"u"&&(A={...A,anonymous_id:Ue()});let Ie=c==="none"?null:bt();if(p.event==="IDENTIFY"&&i&&(A.anonymous_id||c==="none")){let $=p.properties,me=await i.identify({email:$.email??$.identifier,firstName:$.first_name,lastName:$.last_name,phone:$.phone_number,anonymousId:A.anonymous_id??X(),source:"sdk"});me?.candidateId&&c==="device"&&(Ie=me.candidateId,_t(me.candidateId))}let S={anonymous_id:A.anonymous_id,session_id:A.session_id,candidate_id:Ie,event:p.event,sent_at:new Date().toISOString(),context:f,properties:p.properties,custom_properties:p.customProperties},pe=c==="none"?null:p.request?J(p.request):Oe(),Ae=++d,ct=await t.request(At,{body:S,...p.keepalive&&{keepalive:!0}}),w=Et(ct);if(c==="none")return!p.request&&w?.session_id&&Ae>u&&(u=Ae,w.session_id!==S.session_id&&(l=w.session_id)),S.session_id=p.request?w?.session_id||null:l,r?.(S),{success:!0,data:S};let de=p.request?pe:Oe(),lt=de!==null&&de!==pe,ue=de??pe,we=!lt&&(!ue||!w?.anonymous_id||ue===w.anonymous_id);return we?(w?.anonymous_id&&(S.anonymous_id=w.anonymous_id),w?.session_id&&(S.session_id=w.session_id)):S.anonymous_id=ue,!p.request&&typeof window<"u"&&S.anonymous_id&&(we&&S.session_id&&sessionStorage.setItem(`${C}-session_id`,S.session_id.toString()),Be(S.anonymous_id)),r?.(S),{success:!0,data:S}}catch(f){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:f}}},j=Promise.resolve();return{log:async p=>{fe(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let y="request"in p&&p.request?{href:p.request.url,referrer:It(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(c==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0}),c==="device"||p.request||l||p.keepalive)return I(p,y);let f=()=>I(p,y),A=j.then(f,f);return j=A,A},getHeaders:p=>{let y=new Headers;return c==="none"||!p?.anonymous_id||y.append("Set-Cookie",je(p.anonymous_id)),y},getSessionInfo:g}};import{stringify as wt}from"neoqs";function be(t,n,r){let i=t["~standard"].validate(n);if(i instanceof Promise)throw new TypeError("Async schema");if(i.issues)throw new R(i.issues,r);return i.value}function Pt(t,n,r){try{return{success:!0,output:be(t,n,r)}}catch(i){if(i instanceof R)return{success:!1,issues:i.issues,source:i.source};throw i}}var H=class{constructor(n){if(this.baseUrl=Q[n.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),n.apiKey.type==="secret"){if(typeof window<"u")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",n.apiKey.key)}else this.headers.set("x-publishable-key",n.apiKey.key);this.logger=n.logger,this._environment=n.environment}get environment(){return this._environment}getFetchParams(n,r){let i=r.validateIn??!0,{searchParams:c,body:l}=i?Me(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[g,I]of Object.entries(r.params))u=u.replace(`:${g}`,String(I));return d.pathname=u,n.schema.searchParams&&(d.search=wt(c)),[d.toString(),{method:n.method,body:l?JSON.stringify(l):void 0,headers:this.headers,signal:r.signal,...r.keepalive&&{keepalive:!0}}]}async parseResponse(n,r){let i=await he(r.response);if(ye(i,r.response.status),!(r.validateOut??!0))return i;let l=Pt(n.schema.response,i,"response");if(!l.success)throw new R(l.issues,l.source);return l.output}async request(n,r){try{let i=this.getFetchParams(n,r),c=await fetch(...i);return await this.parseResponse(n,{response:c,validateOut:r.validateOut})}catch(i){throw i instanceof R?this.logger.error(i.message,i.issues):this.logger.error(i),i}}};function D(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function ee(t){return t}function Me(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=be(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=be(t.schema.body,"body"in n?n.body:{})),r}import*as s from"valibot";var kt=["agent","sdk","form","integration","migration"],Rt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Ct=["screening","cv_match","interview","overall"],Lt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],Dt=["job","company"],Ot=["created_at","updated_at"],Nt=["asc","desc"],jt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Ft=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],Bt=["user","system","automation","integration","candidate"],te=s.picklist(kt),P=s.picklist(Rt),E=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ne=s.picklist(Ct),Ge=s.picklist(Lt),Dn=s.picklist(Dt),Ve=s.picklist(Ot),$e=s.picklist(Nt),W=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),re=s.picklist(jt),Je=s.picklist(Ft),He=s.picklist(Bt);var _=s.variant("type",[s.object({type:s.literal("user"),id:s.pipe(s.string(),s.minLength(1)),email:s.pipe(s.string(),s.minLength(1)),name:s.pipe(s.string(),s.minLength(1))}),s.object({type:s.literal("system"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("automation"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("integration"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("candidate"),id:s.pipe(s.string(),s.minLength(1)),email:s.optional(s.string())})]);import*as k from"valibot";var Ut=k.object({total:k.number(),page:k.number(),perPage:k.number(),lastPage:k.number()});function oe(t){return k.object({data:k.array(t),pagination:Ut})}import*as m from"valibot";var K=m.object({id:m.string(),email:m.nullable(m.string()),firstName:m.nullable(m.string()),lastName:m.nullable(m.string()),phone:m.nullable(m.string()),source:m.nullable(te),identifiedAt:m.nullable(m.string()),createdAt:m.string(),updatedAt:m.string()});import*as o from"valibot";import*as v from"valibot";var G=v.pipe(v.string(),v.minLength(1)),We=v.pipe(v.number(),v.integer(),v.minValue(1)),L=v.record(v.string(),v.unknown());import*as T from"valibot";var Ke=T.object({id:T.string(),applicationId:T.string(),status:Ge,scheduledAt:T.nullable(T.string()),completedAt:T.nullable(T.string()),meta:T.nullable(L),createdAt:T.string(),updatedAt:T.string()});var _e=o.object({score:o.number(),reason:o.string(),confidence:o.number()}),Ye=o.object({id:o.string(),candidateId:o.string(),jobId:o.number(),stage:E,stageGroup:P,stageEnteredAt:o.string(),rating:o.nullable(o.number()),disqualifiedAt:o.nullable(o.string()),disqualificationReason:o.nullable(W),disqualificationNote:o.nullable(o.string()),source:re,sourceDetail:o.nullable(o.string()),sessionId:o.nullable(o.number()),externalApplicationId:o.nullable(o.string()),meta:o.nullable(L),context:o.nullable(L),scoredAt:o.nullable(o.string()),createdAt:o.string(),updatedAt:o.string()}),qt=o.object({id:o.string(),applicationId:o.string(),scoreType:ne,score:o.nullable(o.number()),reason:o.nullable(o.string()),categories:o.nullable(o.record(o.string(),_e)),scoredBy:o.nullable(o.string()),createdAt:o.string()}),ie=o.object({...Ye.entries,candidate:o.nullable(K),score:o.nullable(qt),interview:o.nullable(Ke)}),Mt=o.object({...K.entries,applications:o.array(Ye)}),ze=o.object({id:o.string(),applicationId:o.string(),action:Je,fromStage:o.nullable(E),fromStageGroup:o.nullable(P),toStage:o.nullable(E),toStageGroup:o.nullable(P),disqualificationReason:o.nullable(W),disqualificationNote:o.nullable(o.string()),actorId:o.nullable(o.string()),actorType:He,actorEmail:o.nullable(o.string()),actorName:o.nullable(o.string()),meta:o.nullable(L),schemaVersion:o.number(),createdAt:o.string()});import*as h from"valibot";var Qe=h.object({anonymousId:G,email:G,firstName:h.nullish(h.string()),lastName:h.nullish(h.string()),phone:h.nullish(h.string()),source:h.nullish(te)}),Ze=h.object({candidateId:h.string(),isNew:h.boolean()});import*as e from"valibot";var Gt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],ae=e.picklist(Gt),Xe=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),Vt=e.pipe(Xe,e.array(E)),$t=e.pipe(Xe,e.array(P)),et=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),er=e.object({stages:e.optional(Vt),stage_groups:e.optional($t),job_id:e.optional(e.string()),job_ids:e.optional(et),candidate_id:e.optional(e.string()),is_disqualified:e.optional(e.picklist(["true","false"])),created_from:e.optional(e.string()),created_to:e.optional(e.string()),updated_from:e.optional(e.string()),updated_to:e.optional(e.string()),entered_stage_from:e.optional(e.string()),entered_stage_to:e.optional(e.string()),from:e.optional(e.string()),to:e.optional(e.string()),q:e.optional(e.string()),scored:e.optional(e.picklist(["true","false"])),sort:e.optional(Ve),order:e.optional($e),page:e.optional(e.string()),per_page:e.optional(e.string())}),tr=e.pipe(e.object({candidateId:G,jobId:We,meta:e.nullish(L),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(L),source:e.nullish(re),sourceDetail:e.nullish(e.string()),stage:e.nullish(E),stageGroup:e.nullish(P),actor:e.nullish(_)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together")),tt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),nr=e.union([e.object({ok:e.literal(!0),duplicate:e.literal(!1),applicationId:e.string(),candidateId:e.string()}),e.object({ok:e.literal(!0),duplicate:e.literal(!0),existingApplication:tt})]),nt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(tt)}),rr=e.object({applicationId:G,scoreType:ne,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),_e)),scoredBy:e.nullish(e.string()),actor:e.nullish(_)}),or=e.object({scoreId:e.string()}),ir=oe(ie);var sr=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),ar=e.array(ze),se=e.object({stage:e.nullish(E),note:e.nullish(e.string())}),Jt=e.object({stage:e.nullish(E),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Ht=e.variant("action",[e.object({action:e.literal("shortlist"),actor:_,meta:e.nullish(se)}),e.object({action:e.literal("move_to_interview"),actor:_,meta:e.nullish(se)}),e.object({action:e.literal("make_offer"),actor:_,meta:e.nullish(se)}),e.object({action:e.literal("hire"),actor:_,meta:e.nullish(Jt)}),e.object({action:e.literal("withdraw"),actor:_,meta:e.nullish(se)}),e.object({action:e.literal("move_to_stage"),actor:_,meta:e.object({stage:E,stageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:_,meta:e.object({toStage:E,toStageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:_,meta:e.object({reason:W,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:_,meta:e.object({toStage:E,toStageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:_,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),cr=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:Ht}),rt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),lr=e.variant("kind",[e.object({kind:e.literal("updated"),action:ae,application:ie}),e.object({kind:e.literal("skipped"),action:ae,applicationId:e.string(),reason:rt})]),pr=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:ae,application:ie})),skipped:e.array(e.object({kind:e.literal("skipped"),action:ae,applicationId:e.string(),reason:rt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),N=e.pipe(e.number(),e.integer(),e.minValue(0)),Wt=e.object({APPLIED:N,SHORTLISTED:N,INTERVIEWED:N,OFFERED:N,HIRED:N,REJECTED:N,WITHDRAWN:N}),dr=e.object({job_ids:et}),ur=e.object({counts:e.record(e.string(),Wt)});var hr=oe(K);import*as b from"valibot";var Sr=b.object({avg_score:b.nullable(b.number()),p90_score:b.nullable(b.number()),p85_score:b.nullable(b.number()),p80_score:b.nullable(b.number()),total_scores:b.number(),total_shortlists:b.number()});import*as ce from"valibot";var Te=({environment:t,publishableKey:n,logger:r})=>{let i=Ce[t];return{async checkDuplicate(c){try{let l=new URLSearchParams({email:c.email,scope:c.scope});c.scope==="job"&&c.jobId!=null&&l.set("job_id",String(c.jobId));let d=await fetch(`${i}/applications/check-duplicate?${l}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":n}});if(!d.ok)return r.error(`[TalentBankClient] checkDuplicate failed with status ${d.status}`),{isDuplicate:!1};let u=await d.json(),g=ce.safeParse(nt,u);return g.success?g.output:(r.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof u=="object"&&u!=null&&typeof u.isDuplicate=="boolean"?{isDuplicate:u.isDuplicate}:{isDuplicate:!1})}catch(l){return r.error("[TalentBankClient] checkDuplicate failed:",l),{isDuplicate:!1}}},async identify(c){try{if(!c.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let l={email:c.email,firstName:c.firstName,lastName:c.lastName,phone:c.phone,anonymousId:c.anonymousId,source:c.source??"sdk"},d=ce.safeParse(Qe,l);if(!d.success)return r.error("[TalentBankClient] identify received invalid input"),null;let u=await fetch(`${i}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":n},body:JSON.stringify(d.output)});if(!u.ok)return r.error(`[TalentBankClient] identify failed with status ${u.status}`),null;let g=ce.safeParse(Ze,await u.json());return g.success?g.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(l){return r.error("[TalentBankClient] identify failed:",l),null}}}};function Kt({publishableKey:t,env:n,logger:r=ve,onEvent:i,persistence:c}){let l=Pe({baseUrl:Q[n],publishableKey:t}),d=r===!1?ge:r,u=new H({environment:n,apiKey:{type:"publishable",key:t},logger:d}),g=Te({environment:n,publishableKey:t,logger:d}),I=qe({rpcClient:u,logger:d,onEvent:i,talentBank:g,persistence:c});return{register:V=>V({logger:d,apiClient:l,analytics:I,rpcClient:u,publishableKey:t,env:n}),analytics:I,apiClient:l}}function xe(t){let n=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),r=5381;for(let i=0;i<n.length;i++)r=r*33^n.charCodeAt(i);return(r>>>0).toString(36)}function Ee(t,n){return`${De}:${t}:${n}`}function Yt(t,n){if(typeof window>"u")return!1;try{let r=Ee(t,xe(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function zt(t,n){if(!(typeof window>"u"))try{let r=Ee(t,xe(n));window.localStorage.setItem(r,"accepted")}catch{}}function Qt(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}import*as a from"valibot";var ot=["DAILY","WEEKLY","MONTHLY"],Zt=a.record(a.string(),a.union([a.string(),a.array(a.string()),a.object({type:a.literal("provided"),lat:a.number(),lng:a.number(),radius:a.number(),unit:a.optional(a.picklist(["miles","km"])),label:a.optional(a.string())})])),Xt={pathname:"/job/:id",method:"GET",schema:{response:a.object({id:a.number(),external_id:a.nullish(a.string()),city:a.nullish(a.string()),town:a.nullish(a.string()),category:a.nullish(a.string())})}};async function en(t,{contact:n,job:r}){let i={};if(r){let c=await t.request(Xt,{params:{id:r.id}});if((r.id_type==="internal"?String(c.id):c.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let d of["city","town","category"]){let u=c[d]?.trim();u&&(i[d]=[u])}}await t.request(it,{body:{contact:n,alerts:"WEEKLY",filters:i}})}var it={pathname:"/search/save",method:"POST",schema:{response:D(),body:a.object({contact:a.object({email:a.pipe(a.optional(a.string()),a.string(),a.email()),first_name:a.optional(a.string()),last_name:a.optional(a.string())}),alerts:a.pipe(a.optional(a.string()),a.string(),a.picklist(ot)),filters:Zt})}};import*as x from"valibot";var st=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:x.pipe(x.object({country:x.optional(x.array(x.object({value:x.string()})),[])}),x.transform(({country:r})=>r.map(({value:i})=>i))),searchParams:D()}};return t.request(n,{searchParams:{filters:{country:null}}})},le=new WeakMap,tn=t=>(le.has(t)||(le.set(t,void 0),st(t).then(async n=>{let{jobCountryCodes:r}=await import("./sdk.country-codes-W6HRF5SA.mjs");le.set(t,r(n).join(",")||void 0)}).catch(()=>{})),le.get(t)),at=(t,n)=>{let r=new Set,i=[];for(let c=0;c<Math.max(t.length,n.length);c++)for(let l of[t[c],n[c]]){if(!l)continue;let d=l.mapbox_id||l.full_address||[l.name,l.place_formatted].filter(Boolean).join(", ");if(!r.has(d)&&(r.add(d),i.push(l),i.length===5))return i}return i},nn=600,rn=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let i=await t();return r?.throwIfAborted(),i}return new Promise((i,c)=>{let l,d,u,g=!1,I=()=>{g=!0,clearTimeout(u),r?.removeEventListener("abort",j)},j=()=>{I(),c(r?.reason)},V=()=>{I(),l?.status==="fulfilled"&&d?.status==="fulfilled"?i(at(l.value,d.value)):l?.status==="fulfilled"?i(l.value):d?.status==="fulfilled"?i(d.value):l?.status==="rejected"&&c(l.reason)},p=(y,f)=>{g||(y?l=f:d=f,l&&d?V():f.status==="fulfilled"&&f.value.length>0&&(u=setTimeout(V,nn)))};r?.addEventListener("abort",j,{once:!0});for(let y of[!0,!1])t(y?n:void 0).then(f=>p(y,{status:"fulfilled",value:f}),f=>p(y,{status:"rejected",reason:f}))})};export{q as ApiError,H as InploiRpcClient,ot as JOB_ALERT_FREQUENCIES,B as NotFoundError,M as ParsingError,R as SchemaValidationError,ke as SdkError,U as UnauthorisedError,tn as addressSearchCountry,at as blendAddressSuggestions,Ee as consentStorageKey,dt as createPlugin,Te as createTalentBankClient,ee as endpoint,X as generateUUID,Yt as getConsentAcceptance,st as getJobCountries,Ue as getOrCreateAnonymousId,xe as hashConsentConfig,Kt as initialiseSdk,ve as inploiBrandedLogger,vt as isApiErrorWithData,ht as isSdkError,pt as jobCountryCodes,ge as noLogging,Qt as ready,en as saveClosedRoleJobAlerts,it as saveSearchEndpoint,rn as searchAddressSuggestions,zt as setConsentAcceptance,D as typed,Me as validateEndpointInputs};
|
|
1
|
+
import{a as pt}from"./chunk-KC7FKSIJ.mjs";var Y="%c[inploi SDK]",z="color: #65BC67; font-weight: bold;",ge={warn:(...t)=>console.warn(Y,z,...t),error:(...t)=>console.error(Y,z,...t),info:(...t)=>console.info(Y,z,...t),log:(...t)=>console.log(Y,z,...t)},ve={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var dt=t=>t;function fe(t,n){if(!t)throw new Error(n)}function F(t,n){return n in t}var mn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var ut="Unauthenticated",mt="This action is unauthorized.",O=class extends Error{constructor(r,i){super(r);this.status=i,this.name="ErrorWithStatus"}},B=class extends O{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},U=class extends O{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},R=class extends O{constructor(r,i){let c=i?` in ${i}`:"";super(`Schema validation failed${c}`);this.issues=r;this.source=i;this.name="SchemaValidationError",this.status=400}},q=class extends O{constructor(r,i,c){super(r);this.data=c;this.name="ApiError",this.status=i??500}},gt=t=>t instanceof q&&t.data!==void 0,G=class extends O{constructor(r){super("Error parsing response into JSON.");this.response=r;this.name="ParsingError",this.status=r&&r.status>=300?r.status:500,this.contentType=new Headers(r?.headers).get("content-type")??void 0}};async function he(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new G(t);return t.json().catch(()=>{throw new G(t)})}var vt=["message","error","errors","exception","exceptions"];function ft(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of vt)if(F(t,r)){let i=t[r];typeof i=="string"&&n.push(i),Array.isArray(i)&&i.every(c=>typeof c=="string")&&n.push(...i)}F(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&F(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&F(t.integration_response.error,"message")&&typeof t.integration_response.error.message=="string"&&n.push(t.integration_response.error.message)}return n.length===0&&n.push("Unknown error"),[...new Set(n)].join(", ")}function ye(t,n){if(n>=300){let r=ft(t);throw n===404?new B(r):r===ut?new U("You are not authenticated.",n):r===mt?new U(r,n):new q(r,n,t)}}var Pe=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,i={})=>{let c={...i,headers:{...i.headers,...n}},l=await fetch(`${t.baseUrl}${r}`,c);if(l.status===404)throw new B;let d=await he(l);return ye(d,l.status),d}}},ke={NotFound:B,Unauthorised:U,SchemaValidation:R,Api:q,JsonParsing:G};function ht(t){return Object.values(ke).some(n=>t instanceof n)}var Re="2.9.0";var Q={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Ce={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Le=Re;var C="isdk_session",Z=`${C}-candidate_id`,De=`${C}-consent`;var X=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16));var Ne=7*24*60*60*1e3,je=t=>{let n=new Date;return n.setTime(n.getTime()+Ne),`${C}=${t};expires=${n.toUTCString()};path=/`},St=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let i=sessionStorage.getItem(`${C}-session_id`);return typeof i=="string"?i:null},bt=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Z);return typeof t=="string"&&t!==""?t:null}catch{return null}},_t=t=>{if(!(typeof window>"u"))try{t?window.localStorage.setItem(Z,t):window.localStorage.removeItem(Z)}catch{}},Tt=new RegExp(`(?:^|;\\s*)${C}=([^;]+)`),J=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?Tt.exec(n)?.[1]??null:null},Fe=()=>{try{let t=JSON.parse(window.localStorage.getItem(C)??"null");return typeof t!="object"||t===null||!("id"in t)||!("expires"in t)||typeof t.id!="string"||typeof t.expires!="number"?null:t.id!==""&&t.expires>Date.now()?t.id:null}catch{return null}},Oe=()=>J()??(new URL(location.href).searchParams.get("anonymous_id")?null:Fe()),xt=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Be=t=>{if(document.cookie=je(t)+xt(),J()!==t)try{window.localStorage.setItem(C,JSON.stringify({id:t,expires:Date.now()+Ne}))}catch{}},Se=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?J(t)??r.get("anonymous_id"):J()??r.get("anonymous_id")??Fe(),session_id:St(r,typeof window>"u")}},Ue=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=Se().anonymous_id;if(t)return t;let n=X(),r=Se().anonymous_id;return r||(Be(n),n)},Et=t=>typeof t!="object"||t===null?null:{anonymous_id:"anonymous_id"in t&&typeof t.anonymous_id=="string"?t.anonymous_id:null,session_id:"session_id"in t&&typeof t.session_id=="string"?t.session_id:null},It=t=>t==="about:client"?"":t,At={pathname:"/log",method:"POST",schema:{response:D(),body:D()}},qe=({rpcClient:t,logger:n,onEvent:r,talentBank:i,persistence:c="device"})=>{let l=null,d=0,u=0,v=p=>c==="none"?{anonymous_id:null,session_id:p?null:l}:Se(p),I=async(p,y)=>{try{let f={library:{name:"inploi-sdk",version:Le},page:y},A=v(p.request);c==="device"&&p.event==="IDENTIFY"&&!A.anonymous_id&&!p.request&&typeof window<"u"&&(A={...A,anonymous_id:Ue()});let Ie=c==="none"?null:bt();if(p.event==="IDENTIFY"&&i&&(A.anonymous_id||c==="none")){let $=p.properties,me=await i.identify({email:$.email??$.identifier,firstName:$.first_name,lastName:$.last_name,phone:$.phone_number,anonymousId:A.anonymous_id??X(),source:"sdk"});me?.candidateId&&c==="device"&&(Ie=me.candidateId,_t(me.candidateId))}let S={anonymous_id:A.anonymous_id,session_id:A.session_id,candidate_id:Ie,event:p.event,sent_at:new Date().toISOString(),context:f,properties:p.properties,custom_properties:p.customProperties},pe=c==="none"?null:p.request?J(p.request):Oe(),Ae=++d,ct=await t.request(At,{body:S,...p.keepalive&&{keepalive:!0}}),w=Et(ct);if(c==="none")return!p.request&&w?.session_id&&Ae>u&&(u=Ae,w.session_id!==S.session_id&&(l=w.session_id)),S.session_id=p.request?w?.session_id||null:l,r?.(S),{success:!0,data:S};let de=p.request?pe:Oe(),lt=de!==null&&de!==pe,ue=de??pe,we=!lt&&(!ue||!w?.anonymous_id||ue===w.anonymous_id);return we?(w?.anonymous_id&&(S.anonymous_id=w.anonymous_id),w?.session_id&&(S.session_id=w.session_id)):S.anonymous_id=ue,!p.request&&typeof window<"u"&&S.anonymous_id&&(we&&S.session_id&&sessionStorage.setItem(`${C}-session_id`,S.session_id.toString()),Be(S.anonymous_id)),r?.(S),{success:!0,data:S}}catch(f){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:f}}},j=Promise.resolve();return{log:async p=>{fe(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let y="request"in p&&p.request?{href:p.request.url,referrer:It(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(c==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0}),c==="device"||p.request||l||p.keepalive)return I(p,y);let f=()=>I(p,y),A=j.then(f,f);return j=A,A},getHeaders:p=>{let y=new Headers;return c==="none"||!p?.anonymous_id||y.append("Set-Cookie",je(p.anonymous_id)),y},getSessionInfo:v}};import{stringify as wt}from"neoqs";function be(t,n,r){let i=t["~standard"].validate(n);if(i instanceof Promise)throw new TypeError("Async schema");if(i.issues)throw new R(i.issues,r);return i.value}function Pt(t,n,r){try{return{success:!0,output:be(t,n,r)}}catch(i){if(i instanceof R)return{success:!1,issues:i.issues,source:i.source};throw i}}var H=class{constructor(n){if(this.baseUrl=Q[n.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),n.apiKey.type==="secret"){if(typeof window<"u")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",n.apiKey.key)}else this.headers.set("x-publishable-key",n.apiKey.key);this.logger=n.logger,this._environment=n.environment}get environment(){return this._environment}getFetchParams(n,r){let i=r.validateIn??!0,{searchParams:c,body:l}=i?Ge(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[v,I]of Object.entries(r.params))u=u.replace(`:${v}`,String(I));return d.pathname=u,n.schema.searchParams&&(d.search=wt(c)),[d.toString(),{method:n.method,body:l?JSON.stringify(l):void 0,headers:this.headers,signal:r.signal,...r.keepalive&&{keepalive:!0}}]}async parseResponse(n,r){let i=await he(r.response);if(ye(i,r.response.status),!(r.validateOut??!0))return i;let l=Pt(n.schema.response,i,"response");if(!l.success)throw new R(l.issues,l.source);return l.output}async request(n,r){try{let i=this.getFetchParams(n,r),c=await fetch(...i);return await this.parseResponse(n,{response:c,validateOut:r.validateOut})}catch(i){throw i instanceof R?this.logger.error(i.message,i.issues):this.logger.error(i),i}}};function D(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function ee(t){return t}function Ge(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=be(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=be(t.schema.body,"body"in n?n.body:{})),r}import*as s from"valibot";var kt=["agent","sdk","form","integration","migration"],Rt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Ct=["screening","cv_match","interview","overall"],Lt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],Dt=["job","company"],Ot=["created_at","updated_at"],Nt=["asc","desc"],jt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Ft=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],Bt=["user","system","automation","integration","candidate"],te=s.picklist(kt),P=s.picklist(Rt),E=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ne=s.picklist(Ct),Me=s.picklist(Lt),Dn=s.picklist(Dt),Ve=s.picklist(Ot),$e=s.picklist(Nt),W=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),re=s.picklist(jt),Je=s.picklist(Ft),He=s.picklist(Bt);var _=s.variant("type",[s.object({type:s.literal("user"),id:s.pipe(s.string(),s.minLength(1)),email:s.pipe(s.string(),s.minLength(1)),name:s.pipe(s.string(),s.minLength(1))}),s.object({type:s.literal("system"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("automation"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("integration"),id:s.pipe(s.string(),s.minLength(1)),name:s.optional(s.string())}),s.object({type:s.literal("candidate"),id:s.pipe(s.string(),s.minLength(1)),email:s.optional(s.string())})]);import*as k from"valibot";var Ut=k.object({total:k.number(),page:k.number(),perPage:k.number(),lastPage:k.number()});function oe(t){return k.object({data:k.array(t),pagination:Ut})}import*as m from"valibot";var K=m.object({id:m.string(),email:m.nullable(m.string()),firstName:m.nullable(m.string()),lastName:m.nullable(m.string()),phone:m.nullable(m.string()),source:m.nullable(te),identifiedAt:m.nullable(m.string()),createdAt:m.string(),updatedAt:m.string()});import*as o from"valibot";import*as g from"valibot";var M=g.pipe(g.string(),g.minLength(1)),We=g.pipe(g.number(),g.integer(),g.minValue(1)),L=g.record(g.string(),g.unknown());import*as T from"valibot";var Ke=T.object({id:T.string(),applicationId:T.string(),status:Me,scheduledAt:T.nullable(T.string()),completedAt:T.nullable(T.string()),meta:T.nullable(L),createdAt:T.string(),updatedAt:T.string()});var _e=o.object({score:o.number(),reason:o.string(),confidence:o.number()}),Ye=o.object({id:o.string(),candidateId:o.string(),jobId:o.number(),stage:E,stageGroup:P,stageEnteredAt:o.string(),rating:o.nullable(o.number()),disqualifiedAt:o.nullable(o.string()),disqualificationReason:o.nullable(W),disqualificationNote:o.nullable(o.string()),source:re,sourceDetail:o.nullable(o.string()),sessionId:o.nullable(o.number()),externalApplicationId:o.nullable(o.string()),meta:o.nullable(L),context:o.nullable(L),scoredAt:o.nullable(o.string()),createdAt:o.string(),updatedAt:o.string()}),qt=o.object({id:o.string(),applicationId:o.string(),scoreType:ne,score:o.nullable(o.number()),reason:o.nullable(o.string()),categories:o.nullable(o.record(o.string(),_e)),scoredBy:o.nullable(o.string()),createdAt:o.string()}),ie=o.object({...Ye.entries,candidate:o.nullable(K),score:o.nullable(qt),interview:o.nullable(Ke)}),Gt=o.object({...K.entries,applications:o.array(Ye)}),ze=o.object({id:o.string(),applicationId:o.string(),action:Je,fromStage:o.nullable(E),fromStageGroup:o.nullable(P),toStage:o.nullable(E),toStageGroup:o.nullable(P),disqualificationReason:o.nullable(W),disqualificationNote:o.nullable(o.string()),actorId:o.nullable(o.string()),actorType:He,actorEmail:o.nullable(o.string()),actorName:o.nullable(o.string()),meta:o.nullable(L),schemaVersion:o.number(),createdAt:o.string()});import*as h from"valibot";var Qe=h.object({anonymousId:M,email:M,firstName:h.nullish(h.string()),lastName:h.nullish(h.string()),phone:h.nullish(h.string()),source:h.nullish(te)}),Ze=h.object({candidateId:h.string(),isNew:h.boolean()});import*as e from"valibot";var Mt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],ae=e.picklist(Mt),Xe=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),Vt=e.pipe(Xe,e.array(E)),$t=e.pipe(Xe,e.array(P)),et=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),er=e.object({stages:e.optional(Vt),stage_groups:e.optional($t),job_id:e.optional(e.string()),job_ids:e.optional(et),candidate_id:e.optional(e.string()),is_disqualified:e.optional(e.picklist(["true","false"])),created_from:e.optional(e.string()),created_to:e.optional(e.string()),updated_from:e.optional(e.string()),updated_to:e.optional(e.string()),entered_stage_from:e.optional(e.string()),entered_stage_to:e.optional(e.string()),from:e.optional(e.string()),to:e.optional(e.string()),q:e.optional(e.string()),scored:e.optional(e.picklist(["true","false"])),sort:e.optional(Ve),order:e.optional($e),page:e.optional(e.string()),per_page:e.optional(e.string())}),tr=e.pipe(e.object({candidateId:M,jobId:We,meta:e.nullish(L),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(L),source:e.nullish(re),sourceDetail:e.nullish(e.string()),stage:e.nullish(E),stageGroup:e.nullish(P),actor:e.nullish(_)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together")),tt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),nr=e.union([e.object({ok:e.literal(!0),duplicate:e.literal(!1),applicationId:e.string(),candidateId:e.string()}),e.object({ok:e.literal(!0),duplicate:e.literal(!0),existingApplication:tt})]),nt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(tt)}),rr=e.object({applicationId:M,scoreType:ne,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),_e)),scoredBy:e.nullish(e.string()),actor:e.nullish(_)}),or=e.object({scoreId:e.string()}),ir=oe(ie);var sr=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),ar=e.array(ze),se=e.object({stage:e.nullish(E),note:e.nullish(e.string())}),Jt=e.object({stage:e.nullish(E),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Ht=e.variant("action",[e.object({action:e.literal("shortlist"),actor:_,meta:e.nullish(se)}),e.object({action:e.literal("move_to_interview"),actor:_,meta:e.nullish(se)}),e.object({action:e.literal("make_offer"),actor:_,meta:e.nullish(se)}),e.object({action:e.literal("hire"),actor:_,meta:e.nullish(Jt)}),e.object({action:e.literal("withdraw"),actor:_,meta:e.nullish(se)}),e.object({action:e.literal("move_to_stage"),actor:_,meta:e.object({stage:E,stageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:_,meta:e.object({toStage:E,toStageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:_,meta:e.object({reason:W,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:_,meta:e.object({toStage:E,toStageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:_,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),cr=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:Ht}),rt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),lr=e.variant("kind",[e.object({kind:e.literal("updated"),action:ae,application:ie}),e.object({kind:e.literal("skipped"),action:ae,applicationId:e.string(),reason:rt})]),pr=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:ae,application:ie})),skipped:e.array(e.object({kind:e.literal("skipped"),action:ae,applicationId:e.string(),reason:rt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),N=e.pipe(e.number(),e.integer(),e.minValue(0)),Wt=e.object({APPLIED:N,SHORTLISTED:N,INTERVIEWED:N,OFFERED:N,HIRED:N,REJECTED:N,WITHDRAWN:N}),dr=e.object({job_ids:et}),ur=e.object({counts:e.record(e.string(),Wt)});var hr=oe(K);import*as b from"valibot";var Sr=b.object({avg_score:b.nullable(b.number()),p90_score:b.nullable(b.number()),p85_score:b.nullable(b.number()),p80_score:b.nullable(b.number()),total_scores:b.number(),total_shortlists:b.number()});import*as ce from"valibot";var Te=({environment:t,publishableKey:n,logger:r})=>{let i=Ce[t];return{async checkDuplicate(c){try{let l=new URLSearchParams({email:c.email,scope:c.scope});c.scope==="job"&&c.jobId!=null&&l.set("job_id",String(c.jobId));let d=await fetch(`${i}/applications/check-duplicate?${l}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":n}});if(!d.ok)return r.error(`[TalentBankClient] checkDuplicate failed with status ${d.status}`),{isDuplicate:!1};let u=await d.json(),v=ce.safeParse(nt,u);return v.success?v.output:(r.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof u=="object"&&u!=null&&typeof u.isDuplicate=="boolean"?{isDuplicate:u.isDuplicate}:{isDuplicate:!1})}catch(l){return r.error("[TalentBankClient] checkDuplicate failed:",l),{isDuplicate:!1}}},async identify(c){try{if(!c.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let l={email:c.email,firstName:c.firstName,lastName:c.lastName,phone:c.phone,anonymousId:c.anonymousId,source:c.source??"sdk"},d=ce.safeParse(Qe,l);if(!d.success)return r.error("[TalentBankClient] identify received invalid input"),null;let u=await fetch(`${i}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":n},body:JSON.stringify(d.output)});if(!u.ok)return r.error(`[TalentBankClient] identify failed with status ${u.status}`),null;let v=ce.safeParse(Ze,await u.json());return v.success?v.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(l){return r.error("[TalentBankClient] identify failed:",l),null}}}};function Kt({publishableKey:t,env:n,logger:r=ge,onEvent:i,persistence:c}){let l=Pe({baseUrl:Q[n],publishableKey:t}),d=r===!1?ve:r,u=new H({environment:n,apiKey:{type:"publishable",key:t},logger:d}),v=Te({environment:n,publishableKey:t,logger:d}),I=qe({rpcClient:u,logger:d,onEvent:i,talentBank:v,persistence:c});return{register:V=>V({logger:d,apiClient:l,analytics:I,rpcClient:u,publishableKey:t,env:n}),analytics:I,apiClient:l}}function xe(t){let n=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),r=5381;for(let i=0;i<n.length;i++)r=r*33^n.charCodeAt(i);return(r>>>0).toString(36)}function Ee(t,n){return`${De}:${t}:${n}`}function Yt(t,n){if(typeof window>"u")return!1;try{let r=Ee(t,xe(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function zt(t,n){if(!(typeof window>"u"))try{let r=Ee(t,xe(n));window.localStorage.setItem(r,"accepted")}catch{}}function Qt(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}import*as a from"valibot";var ot=["DAILY","WEEKLY","MONTHLY"],Zt=a.record(a.string(),a.union([a.string(),a.array(a.string()),a.object({type:a.literal("provided"),lat:a.number(),lng:a.number(),radius:a.number(),unit:a.optional(a.picklist(["miles","km"])),label:a.optional(a.string())})])),Xt={pathname:"/job/:id",method:"GET",schema:{response:a.object({id:a.number(),external_id:a.nullish(a.string()),city:a.nullish(a.string()),town:a.nullish(a.string()),category:a.nullish(a.string())})}};async function en(t,{contact:n,job:r}){let i={};if(r){let c=await t.request(Xt,{params:{id:r.id}});if((r.id_type==="internal"?String(c.id):c.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let d of["city","town","category"]){let u=c[d]?.trim();u&&(i[d]=[u])}}await t.request(it,{body:{contact:n,alerts:"WEEKLY",filters:i}})}var it={pathname:"/search/save",method:"POST",schema:{response:D(),body:a.object({contact:a.object({email:a.pipe(a.optional(a.string()),a.string(),a.email()),first_name:a.optional(a.string()),last_name:a.optional(a.string())}),alerts:a.pipe(a.optional(a.string()),a.string(),a.picklist(ot)),filters:Zt})}};import*as x from"valibot";var st=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:x.pipe(x.object({country:x.optional(x.array(x.object({value:x.string()})),[])}),x.transform(({country:r})=>r.map(({value:i})=>i))),searchParams:D()}};return t.request(n,{searchParams:{filters:{country:null}}})},le=new WeakMap,tn=t=>(le.has(t)||(le.set(t,void 0),st(t).then(async n=>{let{jobCountryCodes:r}=await import("./sdk.country-codes-W6HRF5SA.mjs");le.set(t,r(n).join(",")||void 0)}).catch(()=>{})),le.get(t)),at=(t,n)=>{let r=new Set,i=[];for(let c=0;c<Math.max(t.length,n.length);c++)for(let l of[t[c],n[c]]){if(!l)continue;let d=l.mapbox_id||l.full_address||[l.name,l.place_formatted].filter(Boolean).join(", ");if(!r.has(d)&&(r.add(d),i.push(l),i.length===5))return i}return i},nn=600,rn=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let i=await t();return r?.throwIfAborted(),i}return new Promise((i,c)=>{let l,d,u,v=!1,I=()=>{v=!0,clearTimeout(u),r?.removeEventListener("abort",j)},j=()=>{I(),c(r?.reason)},V=()=>{I(),l?.status==="fulfilled"&&d?.status==="fulfilled"?i(at(l.value,d.value)):l?.status==="fulfilled"?i(l.value):d?.status==="fulfilled"?i(d.value):l?.status==="rejected"&&c(l.reason)},p=(y,f)=>{v||(y?l=f:d=f,l&&d?V():f.status==="fulfilled"&&f.value.length>0&&(u=setTimeout(V,nn)))};r?.addEventListener("abort",j,{once:!0});for(let y of[!0,!1])t(y?n:void 0).then(f=>p(y,{status:"fulfilled",value:f}),f=>p(y,{status:"rejected",reason:f}))})};export{q as ApiError,H as InploiRpcClient,ot as JOB_ALERT_FREQUENCIES,B as NotFoundError,G as ParsingError,R as SchemaValidationError,ke as SdkError,U as UnauthorisedError,tn as addressSearchCountry,at as blendAddressSuggestions,Ee as consentStorageKey,dt as createPlugin,Te as createTalentBankClient,ee as endpoint,X as generateUUID,Yt as getConsentAcceptance,st as getJobCountries,Ue as getOrCreateAnonymousId,xe as hashConsentConfig,Kt as initialiseSdk,ge as inploiBrandedLogger,gt as isApiErrorWithData,ht as isSdkError,pt as jobCountryCodes,ve as noLogging,Qt as ready,en as saveClosedRoleJobAlerts,it as saveSearchEndpoint,rn as searchAddressSuggestions,zt as setConsentAcceptance,D as typed,Ge as validateEndpointInputs};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|