@inploi/sdk 2.10.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/cdn/index.js +1 -1
- package/dist/index.d.mts +98 -73
- package/dist/index.d.ts +98 -73
- 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 +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as dt}from"./chunk-KC7FKSIJ.mjs";var z="%c[inploi SDK]",Q="color: #65BC67; font-weight: bold;",ve={warn:(...t)=>console.warn(z,Q,...t),error:(...t)=>console.error(z,Q,...t),info:(...t)=>console.info(z,Q,...t),log:(...t)=>console.log(z,Q,...t)},fe={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var ut=t=>t;function he(t,n){if(!t)throw new Error(n)}function B(t,n){return n in t}var gn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var mt="Unauthenticated",gt="This action is unauthorized.",O=class extends Error{constructor(r,i){super(r);this.status=i,this.name="ErrorWithStatus"}},U=class extends O{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},q=class extends O{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},k=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}},G=class extends O{constructor(r,i,c){super(r);this.data=c;this.name="ApiError",this.status=i??500}},vt=t=>t instanceof G&&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 ye(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 ft=["message","error","errors","exception","exceptions"];function ht(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of ft)if(B(t,r)){let i=t[r];typeof i=="string"&&n.push(i),Array.isArray(i)&&i.every(c=>typeof c=="string")&&n.push(...i)}B(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&B(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&B(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 Se(t,n){if(n>=300){let r=ht(t);throw n===404?new U(r):r===mt?new q("You are not authenticated.",n):r===gt?new q(r,n):new G(r,n,t)}}var Re=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 U;let d=await ye(l);return Se(d,l.status),d}}},Ce={NotFound:U,Unauthorised:q,SchemaValidation:k,Api:G,JsonParsing:M};function yt(t){return Object.values(Ce).some(n=>t instanceof n)}var Le="2.10.0";var Z={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},De={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Oe=Le;var R="isdk_session",X=`${R}-candidate_id`,Ne=`${R}-consent`;var J=()=>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 Fe=7*24*60*60*1e3,Be=t=>{let n=new Date;return n.setTime(n.getTime()+Fe),`${R}=${t};expires=${n.toUTCString()};path=/`},bt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let i=sessionStorage.getItem(`${R}-session_id`);return typeof i=="string"?i:null},_t=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(X);return typeof t=="string"&&t!==""?t:null}catch{return null}},Tt=t=>{if(!(typeof window>"u"))try{t?window.localStorage.setItem(X,t):window.localStorage.removeItem(X)}catch{}},xt=new RegExp(`(?:^|;\\s*)${R}=([^;]+)`),H=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?xt.exec(n)?.[1]??null:null},Ue=()=>{try{let t=JSON.parse(window.localStorage.getItem(R)??"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}},je=()=>H()??(new URL(location.href).searchParams.get("anonymous_id")?null:Ue()),Et=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",qe=t=>{if(document.cookie=Be(t)+Et(),H()!==t)try{window.localStorage.setItem(R,JSON.stringify({id:t,expires:Date.now()+Fe}))}catch{}},be=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?H(t)??r.get("anonymous_id"):H()??r.get("anonymous_id")??Ue(),session_id:bt(r,typeof window>"u")}},_e=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=be().anonymous_id;if(t)return t;let n=J(),r=be().anonymous_id;return r||(qe(n),n)},It=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},At=t=>t==="about:client"?"":t,wt={pathname:"/log",method:"POST",schema:{response:L(),body:L()}},Ge=({rpcClient:t,logger:n,onEvent:r,talentBank:i,persistence:c="device"})=>{let l=null,d=null,u=0,f=0,E=p=>c==="none"?{anonymous_id:null,session_id:p?null:l}:be(p),j=async(p,v)=>{try{let F={library:{name:"inploi-sdk",version:Oe},page:v},I=E(p.request);c==="device"&&p.event==="IDENTIFY"&&!I.anonymous_id&&!p.request&&typeof window<"u"&&(I={...I,anonymous_id:_e()});let we=c==="none"?null:_t();if(p.event==="IDENTIFY"&&i&&(I.anonymous_id||c==="none")){let $=p.properties,ge=await i.identify({email:$.email??$.identifier,firstName:$.first_name,lastName:$.last_name,phone:$.phone_number,anonymousId:I.anonymous_id??J(),source:"sdk"});ge?.candidateId&&c==="device"&&(we=ge.candidateId,Tt(ge.candidateId))}let y={anonymous_id:I.anonymous_id,session_id:I.session_id,candidate_id:we,event:p.event,sent_at:new Date().toISOString(),context:F,properties:p.properties,custom_properties:p.customProperties},de=c==="none"?null:p.request?H(p.request):je(),Pe=++u,lt=await t.request(wt,{body:y,...p.keepalive&&{keepalive:!0}}),A=It(lt);if(c==="none")return!p.request&&A?.session_id&&Pe>f&&(f=Pe,A.session_id!==y.session_id&&(l=A.session_id)),y.session_id=p.request?A?.session_id||null:l,r?.(y),{success:!0,data:y};let ue=p.request?de:je(),pt=ue!==null&&ue!==de,me=ue??de,ke=!pt&&(!me||!A?.anonymous_id||me===A.anonymous_id);return ke?(A?.anonymous_id&&(y.anonymous_id=A.anonymous_id),A?.session_id&&(y.session_id=A.session_id)):y.anonymous_id=me,!p.request&&typeof window<"u"&&y.anonymous_id&&(ke&&y.session_id&&sessionStorage.setItem(`${R}-session_id`,y.session_id.toString()),qe(y.anonymous_id)),r?.(y),{success:!0,data:y}}catch(F){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:F}}},D=Promise.resolve();return{log:async p=>{he(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let v="request"in p&&p.request?{href:p.request.url,referrer:At(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 j(p,v);let F=()=>j(p,v),I=D.then(F,F);return D=I,I},getHeaders:p=>{let v=new Headers;return c==="none"||!p?.anonymous_id||v.append("Set-Cookie",Be(p.anonymous_id)),v},getSessionInfo:E,getOrCreateAnonymousId:()=>c==="none"?d??(d=J()):_e()}};import{stringify as Pt}from"neoqs";function Te(t,n,r){let i=t["~standard"].validate(n);if(i instanceof Promise)throw new TypeError("Async schema");if(i.issues)throw new k(i.issues,r);return i.value}function kt(t,n,r){try{return{success:!0,output:Te(t,n,r)}}catch(i){if(i instanceof k)return{success:!1,issues:i.issues,source:i.source};throw i}}var W=class{constructor(n){if(this.baseUrl=Z[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[f,E]of Object.entries(r.params))u=u.replace(`:${f}`,String(E));return d.pathname=u,n.schema.searchParams&&(d.search=Pt(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 ye(r.response);if(Se(i,r.response.status),!(r.validateOut??!0))return i;let l=kt(n.schema.response,i,"response");if(!l.success)throw new k(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 k?this.logger.error(i.message,i.issues):this.logger.error(i),i}}};function L(){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=Te(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=Te(t.schema.body,"body"in n?n.body:{})),r}import*as s from"valibot";var Rt=["agent","sdk","form","integration","migration"],Ct=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Lt=["screening","cv_match","interview","overall"],Dt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],Ot=["job","company"],Nt=["created_at","updated_at"],jt=["asc","desc"],Ft=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Bt=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],Ut=["user","system","automation","integration","candidate"],te=s.picklist(Rt),w=s.picklist(Ct),x=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ne=s.picklist(Lt),Ve=s.picklist(Dt),On=s.picklist(Ot),$e=s.picklist(Nt),Je=s.picklist(jt),K=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),re=s.picklist(Ft),He=s.picklist(Bt),We=s.picklist(Ut);var b=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 P from"valibot";var qt=P.object({total:P.number(),page:P.number(),perPage:P.number(),lastPage:P.number()});function oe(t){return P.object({data:P.array(t),pagination:qt})}import*as m from"valibot";var Y=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 V=g.pipe(g.string(),g.minLength(1)),Ke=g.pipe(g.number(),g.integer(),g.minValue(1)),C=g.record(g.string(),g.unknown());import*as _ from"valibot";var Ye=_.object({id:_.string(),applicationId:_.string(),status:Ve,scheduledAt:_.nullable(_.string()),completedAt:_.nullable(_.string()),meta:_.nullable(C),createdAt:_.string(),updatedAt:_.string()});var xe=o.object({score:o.number(),reason:o.string(),confidence:o.number()}),ze=o.object({id:o.string(),candidateId:o.string(),jobId:o.number(),stage:x,stageGroup:w,stageEnteredAt:o.string(),rating:o.nullable(o.number()),disqualifiedAt:o.nullable(o.string()),disqualificationReason:o.nullable(K),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(C),context:o.nullable(C),scoredAt:o.nullable(o.string()),createdAt:o.string(),updatedAt:o.string()}),Gt=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(),xe)),scoredBy:o.nullable(o.string()),createdAt:o.string()}),ie=o.object({...ze.entries,candidate:o.nullable(Y),score:o.nullable(Gt),interview:o.nullable(Ye)}),Mt=o.object({...Y.entries,applications:o.array(ze)}),Qe=o.object({id:o.string(),applicationId:o.string(),action:He,fromStage:o.nullable(x),fromStageGroup:o.nullable(w),toStage:o.nullable(x),toStageGroup:o.nullable(w),disqualificationReason:o.nullable(K),disqualificationNote:o.nullable(o.string()),actorId:o.nullable(o.string()),actorType:We,actorEmail:o.nullable(o.string()),actorName:o.nullable(o.string()),meta:o.nullable(C),schemaVersion:o.number(),createdAt:o.string()});import*as h from"valibot";var Ze=h.object({anonymousId:V,email:V,firstName:h.nullish(h.string()),lastName:h.nullish(h.string()),phone:h.nullish(h.string()),source:h.nullish(te)}),Xe=h.object({candidateId:h.string(),isNew:h.boolean()});import*as e from"valibot";var Vt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],ae=e.picklist(Vt),et=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),$t=e.pipe(et,e.array(x)),Jt=e.pipe(et,e.array(w)),tt=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),tr=e.object({stages:e.optional($t),stage_groups:e.optional(Jt),job_id:e.optional(e.string()),job_ids:e.optional(tt),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($e),order:e.optional(Je),page:e.optional(e.string()),per_page:e.optional(e.string())}),nr=e.pipe(e.object({candidateId:V,jobId:Ke,meta:e.nullish(C),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(C),source:e.nullish(re),sourceDetail:e.nullish(e.string()),stage:e.nullish(x),stageGroup:e.nullish(w),actor:e.nullish(b)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together")),nt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),rr=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:nt})]),rt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(nt)}),or=e.object({applicationId:V,scoreType:ne,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),xe)),scoredBy:e.nullish(e.string()),actor:e.nullish(b)}),ir=e.object({scoreId:e.string()}),sr=oe(ie);var ar=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),cr=e.array(Qe),se=e.object({stage:e.nullish(x),note:e.nullish(e.string())}),Ht=e.object({stage:e.nullish(x),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Wt=e.variant("action",[e.object({action:e.literal("shortlist"),actor:b,meta:e.nullish(se)}),e.object({action:e.literal("move_to_interview"),actor:b,meta:e.nullish(se)}),e.object({action:e.literal("make_offer"),actor:b,meta:e.nullish(se)}),e.object({action:e.literal("hire"),actor:b,meta:e.nullish(Ht)}),e.object({action:e.literal("withdraw"),actor:b,meta:e.nullish(se)}),e.object({action:e.literal("move_to_stage"),actor:b,meta:e.object({stage:x,stageGroup:w,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:b,meta:e.object({toStage:x,toStageGroup:w,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:b,meta:e.object({reason:K,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:b,meta:e.object({toStage:x,toStageGroup:w,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:b,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),lr=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:Wt}),ot=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),pr=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:ot})]),dr=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:ot})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),N=e.pipe(e.number(),e.integer(),e.minValue(0)),Kt=e.object({APPLIED:N,SHORTLISTED:N,INTERVIEWED:N,OFFERED:N,HIRED:N,REJECTED:N,WITHDRAWN:N}),ur=e.object({job_ids:tt}),mr=e.object({counts:e.record(e.string(),Kt)});var yr=oe(Y);import*as S from"valibot";var br=S.object({avg_score:S.nullable(S.number()),p90_score:S.nullable(S.number()),p85_score:S.nullable(S.number()),p80_score:S.nullable(S.number()),total_scores:S.number(),total_shortlists:S.number()});import*as ce from"valibot";var Ee=({environment:t,publishableKey:n,logger:r})=>{let i=De[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(),f=ce.safeParse(rt,u);return f.success?f.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(Ze,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 f=ce.safeParse(Xe,await u.json());return f.success?f.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(l){return r.error("[TalentBankClient] identify failed:",l),null}}}};function Yt({publishableKey:t,env:n,logger:r=ve,onEvent:i,persistence:c}){let l=Re({baseUrl:Z[n],publishableKey:t}),d=r===!1?fe:r,u=new W({environment:n,apiKey:{type:"publishable",key:t},logger:d}),f=Ee({environment:n,publishableKey:t,logger:d}),E=Ge({rpcClient:u,logger:d,onEvent:i,talentBank:f,persistence:c});return{register:D=>D({logger:d,apiClient:l,analytics:E,rpcClient:u,publishableKey:t,env:n}),analytics:E,apiClient:l}}function Ie(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 Ae(t,n){return`${Ne}:${t}:${n}`}function zt(t,n){if(typeof window>"u")return!1;try{let r=Ae(t,Ie(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function Qt(t,n){if(!(typeof window>"u"))try{let r=Ae(t,Ie(n));window.localStorage.setItem(r,"accepted")}catch{}}function Zt(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 it=["DAILY","WEEKLY","MONTHLY"],Xt=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())})])),en={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 tn(t,{contact:n,job:r}){let i={};if(r){let c=await t.request(en,{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(st,{body:{contact:n,alerts:"WEEKLY",filters:i}})}var st={pathname:"/search/save",method:"POST",schema:{response:L(),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(it)),filters:Xt})}};import*as T from"valibot";var at=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:T.pipe(T.object({country:T.optional(T.array(T.object({value:T.string()})),[])}),T.transform(({country:r})=>r.map(({value:i})=>i))),searchParams:L()}};return t.request(n,{searchParams:{filters:{country:null}}})},le=new WeakMap,nn=t=>(le.has(t)||(le.set(t,void 0),at(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)),ct=(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},rn=600,on=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,f=!1,E=()=>{f=!0,clearTimeout(u),r?.removeEventListener("abort",j)},j=()=>{E(),c(r?.reason)},D=()=>{E(),l?.status==="fulfilled"&&d?.status==="fulfilled"?i(ct(l.value,d.value)):l?.status==="fulfilled"?i(l.value):d?.status==="fulfilled"?i(d.value):l?.status==="rejected"&&c(l.reason)},pe=(p,v)=>{f||(p?l=v:d=v,l&&d?D():v.status==="fulfilled"&&v.value.length>0&&(u=setTimeout(D,rn)))};r?.addEventListener("abort",j,{once:!0});for(let p of[!0,!1])t(p?n:void 0).then(v=>pe(p,{status:"fulfilled",value:v}),v=>pe(p,{status:"rejected",reason:v}))})};export{G as ApiError,W as InploiRpcClient,it as JOB_ALERT_FREQUENCIES,U as NotFoundError,M as ParsingError,k as SchemaValidationError,Ce as SdkError,q as UnauthorisedError,nn as addressSearchCountry,ct as blendAddressSuggestions,Ae as consentStorageKey,ut as createPlugin,Ee as createTalentBankClient,ee as endpoint,J as generateUUID,zt as getConsentAcceptance,at as getJobCountries,_e as getOrCreateAnonymousId,Ie as hashConsentConfig,Yt as initialiseSdk,ve as inploiBrandedLogger,vt as isApiErrorWithData,yt as isSdkError,dt as jobCountryCodes,fe as noLogging,Zt as ready,tn as saveClosedRoleJobAlerts,st as saveSearchEndpoint,on as searchAddressSuggestions,Qt as setConsentAcceptance,L as typed,Me as validateEndpointInputs};
|
|
1
|
+
import{a as dt}from"./chunk-KC7FKSIJ.mjs";var z="%c[inploi SDK]",Q="color: #65BC67; font-weight: bold;",ge={warn:(...t)=>console.warn(z,Q,...t),error:(...t)=>console.error(z,Q,...t),info:(...t)=>console.info(z,Q,...t),log:(...t)=>console.log(z,Q,...t)},ve={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var ut=t=>t;function fe(t,n){if(!t)throw new Error(n)}function F(t,n){return n in t}var vn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var mt="Unauthenticated",gt="This action is unauthorized.",O=class extends Error{constructor(r,o){super(r);this.status=o,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}},P=class extends O{constructor(r,o){let l=o?` in ${o}`:"";super(`Schema validation failed${l}`);this.issues=r;this.source=o;this.name="SchemaValidationError",this.status=400}},q=class extends O{constructor(r,o,l){super(r);this.data=l;this.name="ApiError",this.status=o??500}},vt=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 ft=["message","error","errors","exception","exceptions"];function ht(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of ft)if(F(t,r)){let o=t[r];typeof o=="string"&&n.push(o),Array.isArray(o)&&o.every(l=>typeof l=="string")&&n.push(...o)}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=ht(t);throw n===404?new B(r):r===mt?new U("You are not authenticated.",n):r===gt?new U(r,n):new q(r,n,t)}}var we=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,o={})=>{let l={...o,headers:{...o.headers,...n}},c=await fetch(`${t.baseUrl}${r}`,l);if(c.status===404)throw new B;let d=await he(c);return ye(d,c.status),d}}},Pe={NotFound:B,Unauthorised:U,SchemaValidation:P,Api:q,JsonParsing:G};function yt(t){return Object.values(Pe).some(n=>t instanceof n)}var Re="3.0.1";var Z={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},ke={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Ce=Re;var R="isdk_session",Le=`${R}-candidate_id`,Oe=`${R}-consent`;var X=new Map,Se={get:t=>{if(X.has(t))return X.get(t)??null;try{return window.sessionStorage.getItem(t)}catch{return null}},set:(t,n)=>{try{window.sessionStorage.setItem(t,n),X.delete(t)}catch{X.set(t,n)}}};var K=()=>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),`${R}=${t};expires=${n.toUTCString()};path=/`},bt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let o=Se.get(`${R}-session_id`);return typeof o=="string"?o:null},_t=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Le);return typeof t=="string"&&t!==""?t:null}catch{return null}},Tt=new RegExp(`(?:^|;\\s*)${R}=([^;]+)`),W=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(R)??"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}},De=()=>W()??(new URL(location.href).searchParams.get("anonymous_id")?null:Fe()),At=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Be=t=>{if(document.cookie=je(t)+At(),W()!==t)try{window.localStorage.setItem(R,JSON.stringify({id:t,expires:Date.now()+Ne}))}catch{}},be=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?W(t)??r.get("anonymous_id"):W()??r.get("anonymous_id")??Fe(),session_id:bt(r,typeof window>"u")}},Ue=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=be().anonymous_id;if(t)return t;let n=K(),r=be().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},xt=t=>t==="about:client"?"":t,It={pathname:"/log",method:"POST",schema:{response:C(),body:C()}},qe=({rpcClient:t,logger:n,onEvent:r,persistence:o="device",siteKind:l})=>{let c=null,d=null,u=0,f=0,E=p=>o==="none"?{anonymous_id:null,session_id:p?null:c}:be(p),N=async(p,v,Y)=>{try{let j={library:{name:"inploi-sdk",version:Ce},page:v},V=E(p.request),ct=o==="none"?null:_t(),y={anonymous_id:V.anonymous_id,session_id:V.session_id,candidate_id:ct,event:p.event,sent_at:new Date().toISOString(),context:j,properties:p.properties,custom_properties:{...p.customProperties,...Y}},de=o==="none"?null:p.request?W(p.request):De(),xe=++u,lt=await t.request(It,{body:y,...p.keepalive&&{keepalive:!0}}),x=Et(lt);if(o==="none")return!p.request&&x?.session_id&&xe>f&&(f=xe,x.session_id!==y.session_id&&(c=x.session_id)),y.session_id=p.request?x?.session_id||null:c,r?.(y),{success:!0,data:y};let ue=p.request?de:De(),pt=ue!==null&&ue!==de,me=ue??de,Ie=!pt&&(!me||!x?.anonymous_id||me===x.anonymous_id);return Ie?(x?.anonymous_id&&(y.anonymous_id=x.anonymous_id),x?.session_id&&(y.session_id=x.session_id)):y.anonymous_id=me,!p.request&&typeof window<"u"&&y.anonymous_id&&(Ie&&y.session_id&&Se.set(`${R}-session_id`,y.session_id.toString()),Be(y.anonymous_id)),r?.(y),{success:!0,data:y}}catch(j){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:j}}},L=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 v="request"in p&&p.request?{href:p.request.url,referrer:xt(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};o==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0});let Y={event_id:K(),consent_lane:o,site_kind:l};if(o==="device"||p.request||c||p.keepalive)return N(p,v,Y);let j=()=>N(p,v,Y),V=L.then(j,j);return L=V,V},getHeaders:p=>{let v=new Headers;return o==="none"||!p?.anonymous_id||v.append("Set-Cookie",je(p.anonymous_id)),v},getSessionInfo:E,getOrCreateAnonymousId:()=>o==="none"?d??(d=K()):Ue()}};import{stringify as wt}from"neoqs";function _e(t,n,r){let o=t["~standard"].validate(n);if(o instanceof Promise)throw new TypeError("Async schema");if(o.issues)throw new P(o.issues,r);return o.value}function Pt(t,n,r){try{return{success:!0,output:_e(t,n,r)}}catch(o){if(o instanceof P)return{success:!1,issues:o.issues,source:o.source};throw o}}var J=class{constructor(n){if(this.baseUrl=Z[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 o=r.validateIn??!0,{searchParams:l,body:c}=o?Ge(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[f,E]of Object.entries(r.params))u=u.replace(`:${f}`,String(E));return d.pathname=u,n.schema.searchParams&&(d.search=wt(l)),[d.toString(),{method:n.method,body:c?JSON.stringify(c):void 0,headers:this.headers,signal:r.signal,...r.keepalive&&{keepalive:!0}}]}async parseResponse(n,r){let o=await he(r.response);if(ye(o,r.response.status),!(r.validateOut??!0))return o;let c=Pt(n.schema.response,o,"response");if(!c.success)throw new P(c.issues,c.source);return c.output}async request(n,r){try{let o=this.getFetchParams(n,r),l=await fetch(...o);return await this.parseResponse(n,{response:l,validateOut:r.validateOut})}catch(o){throw o instanceof P?this.logger.error(o.message,o.issues):this.logger.error(o),o}}};function C(){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=_e(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=_e(t.schema.body,"body"in n?n.body:{})),r}function Rt({publishableKey:t,env:n,logger:r=ge,onEvent:o,persistence:l,siteKind:c}){let d=we({baseUrl:Z[n],publishableKey:t}),u=r===!1?ve:r,f=new J({environment:n,apiKey:{type:"publishable",key:t},logger:u}),E=qe({rpcClient:f,logger:u,onEvent:o,persistence:l,siteKind:c});return{register:L=>L({logger:u,apiClient:d,analytics:E,rpcClient:f,publishableKey:t,env:n}),analytics:E,apiClient:d}}var kt={VIEW_PAGE:"A careers-site page shown (not a job page).",VIEW_JOB:"A job's own page shown; one per job id the page names.",PAGE_ENGAGEMENT:"A page view's attention summary, sent when the view is hidden or left.",VIEW_SEARCH:"A job search seen for two seconds.",SEARCH_SETTLE:"A searched query or filter with results, unchanged for five seconds.",SEARCH_PAGINATE:"A move to another page of search results.",SEARCH_JOB_CLICK:"A job opened from search results.",SAVE_JOB:"A job saved or unsaved by the candidate.",LINK_CLICK:"A tracked link clicked.",INTERACTION:"A tagged interaction (`tag` names it).",FLOW_START:"An application flow started.",FLOW_INTERACT:"The candidate's first answer in a flow.",FLOW_END:"An application flow ended.",FLOW_NODE:"The candidate's path through an application, summarised when it pauses or ends.",FLOW_SUBMIT:"An application submitted, with the outcome.",FLOW_REDIRECT:"A flow sent the candidate to an external apply page.",FEEDBACK:"A rating or comment.",ADDRESS_SHADOW_COMPARED:"Engineering telemetry: the address lookup's shadow comparison.",SUBMIT_FORM:"Declared but sent by nothing."};function Te(t){let n=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),r=5381;for(let o=0;o<n.length;o++)r=r*33^n.charCodeAt(o);return(r>>>0).toString(36)}function Ae(t,n){return`${Oe}:${t}:${n}`}function Ct(t,n){if(typeof window>"u")return!1;try{let r=Ae(t,Te(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function Lt(t,n){if(!(typeof window>"u"))try{let r=Ae(t,Te(n));window.localStorage.setItem(r,"accepted")}catch{}}import*as s from"valibot";var Ot=["agent","sdk","form","integration","migration"],Dt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Nt=["screening","cv_match","interview","overall"],jt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],Ft=["job","company"],Bt=["created_at","updated_at"],Ut=["asc","desc"],qt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Gt=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],Mt=["user","system","automation","integration","candidate"],te=s.picklist(Ot),I=s.picklist(Dt),A=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ne=s.picklist(Nt),Me=s.picklist(jt),Yn=s.picklist(Ft),Ve=s.picklist(Bt),Ke=s.picklist(Ut),$=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),re=s.picklist(qt),We=s.picklist(Gt),Je=s.picklist(Mt);var b=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 w from"valibot";var Vt=w.object({total:w.number(),page:w.number(),perPage:w.number(),lastPage:w.number()});function oe(t){return w.object({data:w.array(t),pagination:Vt})}import*as m from"valibot";var H=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 i from"valibot";import*as g from"valibot";var M=g.pipe(g.string(),g.minLength(1)),$e=g.pipe(g.number(),g.integer(),g.minValue(1)),k=g.record(g.string(),g.unknown());import*as _ from"valibot";var He=_.object({id:_.string(),applicationId:_.string(),status:Me,scheduledAt:_.nullable(_.string()),completedAt:_.nullable(_.string()),meta:_.nullable(k),createdAt:_.string(),updatedAt:_.string()});var Ee=i.object({score:i.number(),reason:i.string(),confidence:i.number()}),Ye=i.object({id:i.string(),candidateId:i.string(),jobId:i.number(),stage:A,stageGroup:I,stageEnteredAt:i.string(),rating:i.nullable(i.number()),disqualifiedAt:i.nullable(i.string()),disqualificationReason:i.nullable($),disqualificationNote:i.nullable(i.string()),source:re,sourceDetail:i.nullable(i.string()),sessionId:i.nullable(i.number()),externalApplicationId:i.nullable(i.string()),meta:i.nullable(k),context:i.nullable(k),scoredAt:i.nullable(i.string()),createdAt:i.string(),updatedAt:i.string()}),Kt=i.object({id:i.string(),applicationId:i.string(),scoreType:ne,score:i.nullable(i.number()),reason:i.nullable(i.string()),categories:i.nullable(i.record(i.string(),Ee)),scoredBy:i.nullable(i.string()),createdAt:i.string()}),ie=i.object({...Ye.entries,candidate:i.nullable(H),score:i.nullable(Kt),interview:i.nullable(He)}),Wt=i.object({...H.entries,applications:i.array(Ye)}),ze=i.object({id:i.string(),applicationId:i.string(),action:We,fromStage:i.nullable(A),fromStageGroup:i.nullable(I),toStage:i.nullable(A),toStageGroup:i.nullable(I),disqualificationReason:i.nullable($),disqualificationNote:i.nullable(i.string()),actorId:i.nullable(i.string()),actorType:Je,actorEmail:i.nullable(i.string()),actorName:i.nullable(i.string()),meta:i.nullable(k),schemaVersion:i.number(),createdAt:i.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 Jt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],ae=e.picklist(Jt),Xe=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),$t=e.pipe(Xe,e.array(A)),Ht=e.pipe(Xe,e.array(I)),et=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),fr=e.object({stages:e.optional($t),stage_groups:e.optional(Ht),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(Ke),page:e.optional(e.string()),per_page:e.optional(e.string())}),hr=e.pipe(e.object({candidateId:M,jobId:$e,meta:e.nullish(k),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(k),source:e.nullish(re),sourceDetail:e.nullish(e.string()),stage:e.nullish(A),stageGroup:e.nullish(I),actor:e.nullish(b)}),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()}),yr=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)}),Sr=e.object({applicationId:M,scoreType:ne,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),Ee)),scoredBy:e.nullish(e.string()),actor:e.nullish(b)}),br=e.object({scoreId:e.string()}),_r=oe(ie);var Tr=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),Ar=e.array(ze),se=e.object({stage:e.nullish(A),note:e.nullish(e.string())}),Yt=e.object({stage:e.nullish(A),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),zt=e.variant("action",[e.object({action:e.literal("shortlist"),actor:b,meta:e.nullish(se)}),e.object({action:e.literal("move_to_interview"),actor:b,meta:e.nullish(se)}),e.object({action:e.literal("make_offer"),actor:b,meta:e.nullish(se)}),e.object({action:e.literal("hire"),actor:b,meta:e.nullish(Yt)}),e.object({action:e.literal("withdraw"),actor:b,meta:e.nullish(se)}),e.object({action:e.literal("move_to_stage"),actor:b,meta:e.object({stage:A,stageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:b,meta:e.object({toStage:A,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:b,meta:e.object({reason:$,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:b,meta:e.object({toStage:A,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:b,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),Er=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:zt}),rt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),xr=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})]),Ir=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()}))}),D=e.pipe(e.number(),e.integer(),e.minValue(0)),Qt=e.object({APPLIED:D,SHORTLISTED:D,INTERVIEWED:D,OFFERED:D,HIRED:D,REJECTED:D,WITHDRAWN:D}),wr=e.object({job_ids:et}),Pr=e.object({counts:e.record(e.string(),Qt)});var Or=oe(H);import*as S from"valibot";var Nr=S.object({avg_score:S.nullable(S.number()),p90_score:S.nullable(S.number()),p85_score:S.nullable(S.number()),p80_score:S.nullable(S.number()),total_scores:S.number(),total_shortlists:S.number()});import*as ce from"valibot";var Zt=({environment:t,publishableKey:n,logger:r})=>{let o=ke[t];return{async checkDuplicate(l){try{let c=new URLSearchParams({email:l.email,scope:l.scope});l.scope==="job"&&l.jobId!=null&&c.set("job_id",String(l.jobId));let d=await fetch(`${o}/applications/check-duplicate?${c}`,{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(),f=ce.safeParse(nt,u);return f.success?f.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(c){return r.error("[TalentBankClient] checkDuplicate failed:",c),{isDuplicate:!1}}},async identify(l){try{if(!l.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let c={email:l.email,firstName:l.firstName,lastName:l.lastName,phone:l.phone,anonymousId:l.anonymousId,source:l.source??"sdk"},d=ce.safeParse(Qe,c);if(!d.success)return r.error("[TalentBankClient] identify received invalid input"),null;let u=await fetch(`${o}/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 f=ce.safeParse(Ze,await u.json());return f.success?f.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return r.error("[TalentBankClient] identify failed:",c),null}}}};function Xt(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"],en=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())})])),tn={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 nn(t,{contact:n,job:r}){let o={};if(r){let l=await t.request(tn,{params:{id:r.id}});if((r.id_type==="internal"?String(l.id):l.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let d of["city","town","category"]){let u=l[d]?.trim();u&&(o[d]=[u])}}await t.request(it,{body:{contact:n,alerts:"WEEKLY",filters:o}})}var it={pathname:"/search/save",method:"POST",schema:{response:C(),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:en})}};import*as T from"valibot";var st=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:T.pipe(T.object({country:T.optional(T.array(T.object({value:T.string()})),[])}),T.transform(({country:r})=>r.map(({value:o})=>o))),searchParams:C()}};return t.request(n,{searchParams:{filters:{country:null}}})},le=new WeakMap,rn=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,o=[];for(let l=0;l<Math.max(t.length,n.length);l++)for(let c of[t[l],n[l]]){if(!c)continue;let d=c.mapbox_id||c.full_address||[c.name,c.place_formatted].filter(Boolean).join(", ");if(!r.has(d)&&(r.add(d),o.push(c),o.length===5))return o}return o},on=600,sn=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let o=await t();return r?.throwIfAborted(),o}return new Promise((o,l)=>{let c,d,u,f=!1,E=()=>{f=!0,clearTimeout(u),r?.removeEventListener("abort",N)},N=()=>{E(),l(r?.reason)},L=()=>{E(),c?.status==="fulfilled"&&d?.status==="fulfilled"?o(at(c.value,d.value)):c?.status==="fulfilled"?o(c.value):d?.status==="fulfilled"?o(d.value):c?.status==="rejected"&&l(c.reason)},pe=(p,v)=>{f||(p?c=v:d=v,c&&d?L():v.status==="fulfilled"&&v.value.length>0&&(u=setTimeout(L,on)))};r?.addEventListener("abort",N,{once:!0});for(let p of[!0,!1])t(p?n:void 0).then(v=>pe(p,{status:"fulfilled",value:v}),v=>pe(p,{status:"rejected",reason:v}))})};export{kt as ANALYTICS_EVENTS,q as ApiError,J as InploiRpcClient,ot as JOB_ALERT_FREQUENCIES,B as NotFoundError,G as ParsingError,P as SchemaValidationError,Pe as SdkError,U as UnauthorisedError,rn as addressSearchCountry,at as blendAddressSuggestions,Ae as consentStorageKey,ut as createPlugin,Zt as createTalentBankClient,ee as endpoint,K as generateUUID,Ct as getConsentAcceptance,st as getJobCountries,Ue as getOrCreateAnonymousId,Te as hashConsentConfig,Rt as initialiseSdk,ge as inploiBrandedLogger,vt as isApiErrorWithData,yt as isSdkError,dt as jobCountryCodes,ve as noLogging,Xt as ready,nn as saveClosedRoleJobAlerts,it as saveSearchEndpoint,sn as searchAddressSuggestions,Lt as setConsentAcceptance,C as typed,Ge as validateEndpointInputs};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|