@inploi/sdk 3.1.0 → 3.1.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/cdn/index.js +1 -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 +8 -3
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as dt}from"./chunk-KC7FKSIJ.mjs";var Q="%c[inploi SDK]",Z="color: #65BC67; font-weight: bold;",ve={warn:(...t)=>console.warn(Q,Z,...t),error:(...t)=>console.error(Q,Z,...t),info:(...t)=>console.info(Q,Z,...t),log:(...t)=>console.log(Q,Z,...t)},fe={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var ut=t=>t;function he(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"}},U=class extends O{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},B=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 ye(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 Se(t,n){if(n>=300){let r=ht(t);throw n===404?new U(r):r===mt?new B("You are not authenticated.",n):r===gt?new B(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,o={})=>{let l={...o,headers:{...o.headers,...n}},c=await fetch(`${t.baseUrl}${r}`,l);if(c.status===404)throw new U;let d=await ye(c);return Se(d,c.status),d}}},Re={NotFound:U,Unauthorised:B,SchemaValidation:P,Api:q,JsonParsing:G};function yt(t){return Object.values(Re).some(n=>t instanceof n)}var ke="3.1.0";var X={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=ke;var R="isdk_session",Oe=`${R}-candidate_id`,De=`${R}-consent`;var ee=new Map,be={get:t=>{if(ee.has(t))return ee.get(t)??null;try{return window.sessionStorage.getItem(t)}catch{return null}},set:(t,n)=>{try{window.sessionStorage.setItem(t,n),ee.delete(t)}catch{ee.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 je=7*24*60*60*1e3,Fe=t=>{let n=new Date;return n.setTime(n.getTime()+je),`${R}=${t};expires=${n.toUTCString()};path=/`},bt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let o=be.get(`${R}-session_id`);return typeof o=="string"?o:null},_t=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Oe);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},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}},Ne=()=>W()??(new URL(location.href).searchParams.get("anonymous_id")?null:Ue()),At=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Be=t=>{if(document.cookie=Fe(t)+At(),W()!==t)try{window.localStorage.setItem(R,JSON.stringify({id:t,expires:Date.now()+je}))}catch{}},_e=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")??Ue(),session_id:bt(r,typeof window>"u")}},qe=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=_e().anonymous_id;if(t)return t;let n=K(),r=_e().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()}},Ge=({rpcClient:t,logger:n,onEvent:r,persistence:o="device",siteKind:l})=>{let c=null,d=null,u=0,h=0,E=p=>o==="none"?{anonymous_id:null,session_id:p?null:c}:_e(p),N=async(p,m,Y)=>{try{let j={library:{name:"inploi-sdk",version:Le},page:m},V=E(p.request),z=o==="none"?null:_t(),g={anonymous_id:V.anonymous_id,session_id:V.session_id,candidate_id:z,event:p.event,sent_at:new Date().toISOString(),context:j,properties:p.properties,custom_properties:{...p.customProperties,...Y}},ue=o==="none"?null:p.request?W(p.request):Ne(),Ie=++u,lt=await t.request(It,{body:g,...p.keepalive&&{keepalive:!0}}),x=Et(lt);if(o==="none")return!p.request&&x?.session_id&&Ie>h&&(h=Ie,x.session_id!==g.session_id&&(c=x.session_id)),g.session_id=p.request?x?.session_id||null:c,r?.(g),{success:!0,data:g};let me=p.request?ue:Ne(),pt=me!==null&&me!==ue,ge=me??ue,we=!pt&&(!ge||!x?.anonymous_id||ge===x.anonymous_id);return we?(x?.anonymous_id&&(g.anonymous_id=x.anonymous_id),x?.session_id&&(g.session_id=x.session_id)):g.anonymous_id=ge,!p.request&&typeof window<"u"&&g.anonymous_id&&(we&&g.session_id&&be.set(`${R}-session_id`,g.session_id.toString()),Be(g.anonymous_id)),r?.(g),{success:!0,data:g}}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=>{he(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let m="request"in p&&p.request?{href:p.request.url,referrer:xt(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(p.page_context==="no_query"){let z=new URL(m.href),g=m.referrer?new URL(m.referrer):void 0;m={href:z.origin+z.pathname,referrer:g?g.origin+g.pathname:""}}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,m,Y);let j=()=>N(p,m,Y),V=L.then(j,j);return L=V,V},supportsNoQueryPageContext:!0,getHeaders:p=>{let m=new Headers;return o==="none"||!p?.anonymous_id||m.append("Set-Cookie",Fe(p.anonymous_id)),m},getSessionInfo:E,getOrCreateAnonymousId:()=>o==="none"?d??(d=K()):qe()}};import{stringify as wt}from"neoqs";function Te(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:Te(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=X[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?Me(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[h,E]of Object.entries(r.params))u=u.replace(`:${h}`,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 ye(r.response);if(Se(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 te(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}function Rt({publishableKey:t,env:n,logger:r=ve,onEvent:o,persistence:l,siteKind:c}){let d=Pe({baseUrl:X[n],publishableKey:t}),u=r===!1?fe:r,h=new J({environment:n,apiKey:{type:"publishable",key:t},logger:u}),E=Ge({rpcClient:h,logger:u,onEvent:o,persistence:l,siteKind:c});return{register:L=>L({logger:u,apiClient:d,analytics:E,rpcClient:h,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_RESULTS:"A search whose results returned, zero included; once per distinct query, filters, place and order.",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 Ae(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 Ee(t,n){return`${De}:${t}:${n}`}function Ct(t,n){if(typeof window>"u")return!1;try{let r=Ee(t,Ae(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function Lt(t,n){if(!(typeof window>"u"))try{let r=Ee(t,Ae(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"],Ut=["created_at","updated_at"],Bt=["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"],ne=s.picklist(Ot),I=s.picklist(Dt),A=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),re=s.picklist(Nt),Ve=s.picklist(jt),Yn=s.picklist(Ft),Ke=s.picklist(Ut),We=s.picklist(Bt),$=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),oe=s.picklist(qt),Je=s.picklist(Gt),$e=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 ie(t){return w.object({data:w.array(t),pagination:Vt})}import*as v from"valibot";var H=v.object({id:v.string(),email:v.nullable(v.string()),firstName:v.nullable(v.string()),lastName:v.nullable(v.string()),phone:v.nullable(v.string()),source:v.nullable(ne),identifiedAt:v.nullable(v.string()),createdAt:v.string(),updatedAt:v.string()});import*as i from"valibot";import*as f from"valibot";var M=f.pipe(f.string(),f.minLength(1)),He=f.pipe(f.number(),f.integer(),f.minValue(1)),k=f.record(f.string(),f.unknown());import*as _ from"valibot";var Ye=_.object({id:_.string(),applicationId:_.string(),status:Ve,scheduledAt:_.nullable(_.string()),completedAt:_.nullable(_.string()),meta:_.nullable(k),createdAt:_.string(),updatedAt:_.string()});var xe=i.object({score:i.number(),reason:i.string(),confidence:i.number()}),ze=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:oe,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:re,score:i.nullable(i.number()),reason:i.nullable(i.string()),categories:i.nullable(i.record(i.string(),xe)),scoredBy:i.nullable(i.string()),createdAt:i.string()}),se=i.object({...ze.entries,candidate:i.nullable(H),score:i.nullable(Kt),interview:i.nullable(Ye)}),Wt=i.object({...H.entries,applications:i.array(ze)}),Qe=i.object({id:i.string(),applicationId:i.string(),action:Je,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:$e,actorEmail:i.nullable(i.string()),actorName:i.nullable(i.string()),meta:i.nullable(k),schemaVersion:i.number(),createdAt:i.string()});import*as y from"valibot";var Ze=y.object({anonymousId:M,email:M,firstName:y.nullish(y.string()),lastName:y.nullish(y.string()),phone:y.nullish(y.string()),source:y.nullish(ne)}),Xe=y.object({candidateId:y.string(),isNew:y.boolean()});import*as e from"valibot";var Jt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],ce=e.picklist(Jt),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(A)),Ht=e.pipe(et,e.array(I)),tt=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(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(Ke),order:e.optional(We),page:e.optional(e.string()),per_page:e.optional(e.string())}),hr=e.pipe(e.object({candidateId:M,jobId:He,meta:e.nullish(k),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(k),source:e.nullish(oe),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")),nt=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:nt})]),rt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(nt)}),Sr=e.object({applicationId:M,scoreType:re,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)}),br=e.object({scoreId:e.string()}),_r=ie(se);var Tr=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),Ar=e.array(Qe),ae=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(ae)}),e.object({action:e.literal("move_to_interview"),actor:b,meta:e.nullish(ae)}),e.object({action:e.literal("make_offer"),actor:b,meta:e.nullish(ae)}),e.object({action:e.literal("hire"),actor:b,meta:e.nullish(Yt)}),e.object({action:e.literal("withdraw"),actor:b,meta:e.nullish(ae)}),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}),ot=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),xr=e.variant("kind",[e.object({kind:e.literal("updated"),action:ce,application:se}),e.object({kind:e.literal("skipped"),action:ce,applicationId:e.string(),reason:ot})]),Ir=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:ce,application:se})),skipped:e.array(e.object({kind:e.literal("skipped"),action:ce,applicationId:e.string(),reason:ot})),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:tt}),Pr=e.object({counts:e.record(e.string(),Qt)});var Or=ie(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 le from"valibot";var Zt=({environment:t,publishableKey:n,logger:r})=>{let o=Ce[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(),h=le.safeParse(rt,u);return h.success?h.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=le.safeParse(Ze,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 h=le.safeParse(Xe,await u.json());return h.success?h.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 it=["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(st,{body:{contact:n,alerts:"WEEKLY",filters:o}})}var st={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(it)),filters:en})}};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:o})=>o))),searchParams:C()}};return t.request(n,{searchParams:{filters:{country:null}}})},pe=new WeakMap,rn=t=>(pe.has(t)||(pe.set(t,void 0),at(t).then(async n=>{let{jobCountryCodes:r}=await import("./sdk.country-codes-W6HRF5SA.mjs");pe.set(t,r(n).join(",")||void 0)}).catch(()=>{})),pe.get(t)),ct=(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,h=!1,E=()=>{h=!0,clearTimeout(u),r?.removeEventListener("abort",N)},N=()=>{E(),l(r?.reason)},L=()=>{E(),c?.status==="fulfilled"&&d?.status==="fulfilled"?o(ct(c.value,d.value)):c?.status==="fulfilled"?o(c.value):d?.status==="fulfilled"?o(d.value):c?.status==="rejected"&&l(c.reason)},de=(p,m)=>{h||(p?c=m:d=m,c&&d?L():m.status==="fulfilled"&&m.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(m=>de(p,{status:"fulfilled",value:m}),m=>de(p,{status:"rejected",reason:m}))})};export{kt as ANALYTICS_EVENTS,q as ApiError,J as InploiRpcClient,it as JOB_ALERT_FREQUENCIES,U as NotFoundError,G as ParsingError,P as SchemaValidationError,Re as SdkError,B as UnauthorisedError,rn as addressSearchCountry,ct as blendAddressSuggestions,Ee as consentStorageKey,ut as createPlugin,Zt as createTalentBankClient,te as endpoint,K as generateUUID,Ct as getConsentAcceptance,at as getJobCountries,qe as getOrCreateAnonymousId,Ae as hashConsentConfig,Rt as initialiseSdk,ve as inploiBrandedLogger,vt as isApiErrorWithData,yt as isSdkError,dt as jobCountryCodes,fe as noLogging,Xt as ready,nn as saveClosedRoleJobAlerts,st as saveSearchEndpoint,sn as searchAddressSuggestions,Lt as setConsentAcceptance,C as typed,Me as validateEndpointInputs};
|
|
1
|
+
import{a as Tt}from"./chunk-KC7FKSIJ.mjs";var te="%c[inploi SDK]",ne="color: #65BC67; font-weight: bold;",fe={warn:(...t)=>console.warn(te,ne,...t),error:(...t)=>console.error(te,ne,...t),info:(...t)=>console.info(te,ne,...t),log:(...t)=>console.log(te,ne,...t)},ye={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Et=t=>t;function Se(t,n){if(!t)throw new Error(n)}function M(t,n){return n in t}var Hn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var xt="Unauthenticated",It="This action is unauthorized.",O=class extends Error{constructor(r,i){super(r);this.status=i,this.name="ErrorWithStatus"}},G=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}},w=class extends O{constructor(r,i){let l=i?` in ${i}`:"";super(`Schema validation failed${l}`);this.issues=r;this.source=i;this.name="SchemaValidationError",this.status=400}},V=class extends O{constructor(r,i,l){super(r);this.data=l;this.name="ApiError",this.status=i??500}},Rt=t=>t instanceof V&&t.data!==void 0,$=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 be(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new $(t);return t.json().catch(()=>{throw new $(t)})}var wt=["message","error","errors","exception","exceptions"];function Pt(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of wt)if(M(t,r)){let i=t[r];typeof i=="string"&&n.push(i),Array.isArray(i)&&i.every(l=>typeof l=="string")&&n.push(...i)}M(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&M(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&M(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 _e(t,n){if(n>=300){let r=Pt(t);throw n===404?new G(r):r===xt?new q("You are not authenticated.",n):r===It?new q(r,n):new V(r,n,t)}}var je=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,i={})=>{let l={...i,headers:{...i.headers,...n}},c=await fetch(`${t.baseUrl}${r}`,l);if(c.status===404)throw new G;let d=await be(c);return _e(d,c.status),d}}},Ne={NotFound:G,Unauthorised:q,SchemaValidation:w,Api:V,JsonParsing:$};function kt(t){return Object.values(Ne).some(n=>t instanceof n)}var Fe="3.1.1";var re={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Ue={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Be=Fe;var P="isdk_session",Me=`${P}-candidate_id`,Ge=`${P}-consent`;var oe=new Map,Ae={get:t=>{if(oe.has(t))return oe.get(t)??null;try{return window.sessionStorage.getItem(t)}catch{return null}},set:(t,n)=>{try{window.sessionStorage.setItem(t,n),oe.delete(t)}catch{oe.set(t,n)}}};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 Ve=7*24*60*60*1e3,$e=t=>{let n=new Date;return n.setTime(n.getTime()+Ve),`${P}=${t};expires=${n.toUTCString()};path=/`},Lt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let i=Ae.get(`${P}-session_id`);return typeof i=="string"?i:null},Dt=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Me);return typeof t=="string"&&t!==""?t:null}catch{return null}},Ot=new RegExp(`(?:^|;\\s*)${P}=([^;]+)`),Y=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?Ot.exec(n)?.[1]??null:null},He=()=>{try{let t=JSON.parse(window.localStorage.getItem(P)??"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}},qe=()=>Y()??(new URL(location.href).searchParams.get("anonymous_id")?null:He()),jt=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Ke=t=>{if(document.cookie=$e(t)+jt(),Y()!==t)try{window.localStorage.setItem(P,JSON.stringify({id:t,expires:Date.now()+Ve}))}catch{}},Te=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?Y(t)??r.get("anonymous_id"):Y()??r.get("anonymous_id")??He(),session_id:Lt(r,typeof window>"u")}},We=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=Te().anonymous_id;if(t)return t;let n=J(),r=Te().anonymous_id;return r||(Ke(n),n)},Nt=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},Ft=t=>t==="about:client"?"":t,Ut={pathname:"/log",method:"POST",schema:{response:C(),body:C()}},Je=({rpcClient:t,logger:n,onEvent:r,persistence:i="device",siteKind:l})=>{let c=null,d=null,u=0,S=0,E=p=>i==="none"?{anonymous_id:null,session_id:p?null:c}:Te(p),U=async(p,h,X)=>{try{let B={library:{name:"inploi-sdk",version:Be},page:h},W=E(p.request),ee=i==="none"?null:Dt(),f={anonymous_id:W.anonymous_id,session_id:W.session_id,candidate_id:ee,event:p.event,sent_at:new Date().toISOString(),context:B,properties:p.properties,custom_properties:{...p.customProperties,...X}},ve=i==="none"?null:p.request?Y(p.request):qe(),De=++u,_t=await t.request(Ut,{body:f,...p.keepalive&&{keepalive:!0}}),x=Nt(_t);if(i==="none")return!p.request&&x?.session_id&&De>S&&(S=De,x.session_id!==f.session_id&&(c=x.session_id)),f.session_id=p.request?x?.session_id||null:c,r?.(f),{success:!0,data:f};let ge=p.request?ve:qe(),At=ge!==null&&ge!==ve,he=ge??ve,Oe=!At&&(!he||!x?.anonymous_id||he===x.anonymous_id);return Oe?(x?.anonymous_id&&(f.anonymous_id=x.anonymous_id),x?.session_id&&(f.session_id=x.session_id)):f.anonymous_id=he,!p.request&&typeof window<"u"&&f.anonymous_id&&(Oe&&f.session_id&&Ae.set(`${P}-session_id`,f.session_id.toString()),Ke(f.anonymous_id)),r?.(f),{success:!0,data:f}}catch(B){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:B}}},D=Promise.resolve();return{log:async p=>{Se(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let h="request"in p&&p.request?{href:p.request.url,referrer:Ft(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(p.page_context==="no_query"){let ee=new URL(h.href),f=h.referrer?new URL(h.referrer):void 0;h={href:ee.origin+ee.pathname,referrer:f?f.origin+f.pathname:""}}i==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0});let X={event_id:J(),consent_lane:i,site_kind:l};if(i==="device"||p.request||c||p.keepalive)return U(p,h,X);let B=()=>U(p,h,X),W=D.then(B,B);return D=W,W},supportsNoQueryPageContext:!0,getHeaders:p=>{let h=new Headers;return i==="none"||!p?.anonymous_id||h.append("Set-Cookie",$e(p.anonymous_id)),h},getSessionInfo:E,getOrCreateAnonymousId:()=>i==="none"?d??(d=J()):We()}};import{stringify as Bt}from"neoqs";function Ee(t,n,r){let i=t["~standard"].validate(n);if(i instanceof Promise)throw new TypeError("Async schema");if(i.issues)throw new w(i.issues,r);return i.value}function Mt(t,n,r){try{return{success:!0,output:Ee(t,n,r)}}catch(i){if(i instanceof w)return{success:!1,issues:i.issues,source:i.source};throw i}}var z=class{constructor(n){if(this.baseUrl=re[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:l,body:c}=i?Ye(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[S,E]of Object.entries(r.params))u=u.replace(`:${S}`,String(E));return d.pathname=u,n.schema.searchParams&&(d.search=Bt(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 i=await be(r.response);if(_e(i,r.response.status),!(r.validateOut??!0))return i;let c=Mt(n.schema.response,i,"response");if(!c.success)throw new w(c.issues,c.source);return c.output}async request(n,r){try{let i=this.getFetchParams(n,r),l=await fetch(...i);return await this.parseResponse(n,{response:l,validateOut:r.validateOut})}catch(i){throw i instanceof w?this.logger.error(i.message,i.issues):this.logger.error(i),i}}};function C(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function ie(t){return t}function Ye(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=Ee(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=Ee(t.schema.body,"body"in n?n.body:{})),r}function Gt({publishableKey:t,env:n,logger:r=fe,onEvent:i,persistence:l,siteKind:c}){let d=je({baseUrl:re[n],publishableKey:t}),u=r===!1?ye:r,S=new z({environment:n,apiKey:{type:"publishable",key:t},logger:u}),E=Je({rpcClient:S,logger:u,onEvent:i,persistence:l,siteKind:c});return{register:D=>D({logger:u,apiClient:d,analytics:E,rpcClient:S,publishableKey:t,env:n}),analytics:E,apiClient:d}}var qt={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_RESULTS:"A search whose results returned, zero included; once per distinct query, filters, place and order.",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 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 Ie(t,n){return`${Ge}:${t}:${n}`}function Vt(t,n){if(typeof window>"u")return!1;try{let r=Ie(t,xe(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function $t(t,n){if(!(typeof window>"u"))try{let r=Ie(t,xe(n));window.localStorage.setItem(r,"accepted")}catch{}}import*as s from"valibot";var Ht=["agent","sdk","form","integration","migration"],Kt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Wt=["screening","cv_match","interview","overall"],Jt=["PENDING","IN_PROGRESS","COMPLETED","CANCELLED"],Yt=["agent"],zt=["job","company"],Qt=["created_at","updated_at","score","interview_score"],Zt=["asc","desc"],Xt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],en=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written","ats_submission_attempted","ats_submission_succeeded","ats_submission_failed","ats_retry_payload_purged"],tn=["pending","submitted","failed","not_required"],nn=["user","system","automation","integration","candidate"],se=s.picklist(Ht),I=s.picklist(Kt),T=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ae=s.picklist(Wt),ze=s.picklist(Jt),Qe=s.picklist(Yt),xr=s.picklist(zt),Ze=s.picklist(Qt),Xe=s.picklist(Zt),Q=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ce=s.picklist(Xt),et=s.picklist(en),tt=s.picklist(nn),j=s.picklist(tn);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 R from"valibot";var rn=R.object({total:R.number(),page:R.number(),perPage:R.number(),lastPage:R.number()});function nt(t){return R.object({data:R.array(t),pagination:rn})}import*as y from"valibot";var Re=y.object({id:y.string(),email:y.nullable(y.string()),firstName:y.nullable(y.string()),lastName:y.nullable(y.string()),phone:y.nullable(y.string()),source:y.nullable(se),identifiedAt:y.nullable(y.string()),createdAt:y.string(),updatedAt:y.string()});import*as o from"valibot";import*as g from"valibot";var L=g.pipe(g.string(),g.minLength(1)),Z=g.pipe(g.number(),g.integer(),g.minValue(1)),k=g.record(g.string(),g.unknown()),on="(?!\\.{1,2}(?:/|$))[A-Za-z0-9._-]{1,128}",kr=g.pipe(g.string(),g.regex(new RegExp(`^${on}$`)));import*as b from"valibot";var rt=b.object({id:b.string(),applicationId:b.string(),status:ze,conductedBy:Qe,agentInterviewId:b.nullable(b.string()),generatedScore:b.nullable(b.number()),completedAt:b.nullable(b.string()),meta:b.nullable(k),createdAt:b.string(),updatedAt:b.string()});var sn=o.object({quote:o.string(),source:o.picklist(["cv","answer"])}),we=o.object({score:o.number(),reason:o.string(),confidence:o.number(),share:o.optional(o.number()),evidence:o.optional(o.array(sn))}),Pe=o.object({categoryId:o.string(),answerKey:o.string(),reason:o.picklist(["unanswered","unrecognised"])}),ot=o.object({id:o.string(),candidateId:o.string(),jobId:o.number(),stage:T,stageGroup:I,stageEnteredAt:o.string(),rating:o.nullable(o.number()),disqualifiedAt:o.nullable(o.string()),disqualificationReason:o.nullable(Q),disqualificationNote:o.nullable(o.string()),source:ce,sourceDetail:o.nullable(o.string()),sessionId:o.nullable(o.number()),externalApplicationId:o.nullable(o.string()),meta:o.nullable(k),context:o.nullable(k),scoredAt:o.nullable(o.string()),atsSubmissionStatus:o.optional(o.nullable(j)),atsSubmissionAttempts:o.optional(o.number()),atsNextAttemptAt:o.optional(o.nullable(o.string())),atsSubmittedAt:o.optional(o.nullable(o.string())),atsLastErrorCode:o.optional(o.nullable(o.string())),atsLastErrorMessage:o.optional(o.nullable(o.string())),createdAt:o.string(),updatedAt:o.string()}),an=o.object({id:o.string(),applicationId:o.string(),scoreType:ae,score:o.nullable(o.number()),reason:o.nullable(o.string()),categories:o.nullable(o.record(o.string(),we)),leftOut:o.optional(o.array(Pe)),scoredBy:o.nullable(o.string()),createdAt:o.string()}),N=o.object({...ot.entries,candidate:o.nullable(Re),score:o.nullable(an),interview:o.nullable(rt)}),Br=o.object({...Re.entries,applications:o.array(ot)}),it=o.object({id:o.string(),applicationId:o.string(),action:et,fromStage:o.nullable(T),fromStageGroup:o.nullable(I),toStage:o.nullable(T),toStageGroup:o.nullable(I),disqualificationReason:o.nullable(Q),disqualificationNote:o.nullable(o.string()),actorId:o.nullable(o.string()),actorType:tt,actorEmail:o.nullable(o.string()),actorName:o.nullable(o.string()),meta:o.nullable(k),schemaVersion:o.number(),createdAt:o.string()});import*as v from"valibot";var st=v.object({anonymousId:L,email:L,firstName:v.nullish(v.string()),lastName:v.nullish(v.string()),phone:v.nullish(v.string()),source:v.nullish(se),updateExisting:v.optional(v.boolean())}),ke=v.object({candidateId:v.string(),isNew:v.boolean()}),Vr=v.union([v.object({ok:v.literal(!0)}),ke]);import*as e from"valibot";var cn=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],pe=e.picklist(cn),Ce=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),ln=e.pipe(Ce,e.array(T)),pn=e.pipe(Ce,e.array(I)),at=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),dn=e.pipe(Ce,e.array(j)),ct=e.object({stages:e.optional(ln),stage_groups:e.optional(pn),job_id:e.optional(e.string()),job_ids:e.optional(at),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"])),ats_submission_status:e.optional(dn),sort:e.optional(Ze),order:e.optional(Xe),page:e.optional(e.string()),per_page:e.optional(e.string())}),H=e.pipe(L,e.maxLength(255)),un=e.object({status:e.picklist(["pending","not_required"]),integrationId:e.nullish(H)}),Yr=e.pipe(e.object({candidateId:L,jobId:Z,meta:e.nullish(k),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),externalJobId:e.nullish(e.pipe(L,e.maxLength(255))),context:e.nullish(k),source:e.nullish(ce),sourceDetail:e.nullish(e.string()),stage:e.nullish(T),stageGroup:e.nullish(I),actor:e.nullish(_),atsSubmission:e.nullish(un),duplicateScope:e.nullish(e.picklist(["job","attempt"]))}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together"),e.check(t=>t.duplicateScope!=="attempt"||typeof t.meta?.attempt_id=="string"&&t.meta.attempt_id!=="","duplicateScope attempt needs meta.attempt_id")),lt=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),zr=e.union([e.object({ok:e.literal(!0),duplicate:e.literal(!1),applicationId:e.string(),candidateId:e.string(),atsHeld:e.optional(e.boolean())}),e.object({ok:e.literal(!0),duplicate:e.literal(!0),existingApplication:lt,atsHeld:e.optional(e.boolean())})]),pt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(lt)}),mn=Date.UTC(1e4,0,1),vn=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/),e.check(t=>{let[n,r,i]=t.slice(0,10).split("-").map(Number),l=new Date(Date.UTC(n,r-1,i)),c=Date.parse(t);return l.getUTCMonth()===r-1&&l.getUTCDate()===i&&c>=0&&c<mn},"must be a real time")),Le=e.pipe(e.string(),e.regex(/^[A-Za-z0-9_.:-]{1,100}$/)),Qr=e.object({status:e.picklist(["pending","submitted","failed"]),nextAttemptAt:e.nullish(vn),errorCode:e.nullish(Le),errorMessage:e.nullish(e.pipe(e.string(),e.maxLength(1e4))),externalApplicationId:e.nullish(H),externalRunId:e.nullish(H),integrationId:e.nullish(H),answeredPending:e.optional(e.boolean())}),gn=e.picklist(["invalid_transition","next_attempt_required","retry_hold_expired"]),Zr=e.variant("kind",[e.object({kind:e.literal("recorded"),application:N}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(j),to:j,reason:gn})]),hn=e.object({integrationId:e.string(),state:e.picklist(["closed","open","half_open"]),coolingUntil:e.nullable(e.string()),transientCount:e.number(),held:e.boolean()}),Xr=e.object({groups:e.array(e.object({integrationId:e.nullable(e.string()),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),count:e.number(),retryable:e.number(),sendable:e.optional(e.number()),nextRetryUntil:e.optional(e.nullable(e.string()))})),oldestPendingAgeSeconds:e.nullable(e.number()),breakers:e.array(hn),restoreHold:e.optional(e.boolean())}),eo=e.object({status:e.picklist(["pending","failed"]),integrationId:e.nullable(H),errorCode:e.nullable(Le)}),to=e.object({rows:e.array(e.object({id:e.string(),jobId:e.number(),status:e.picklist(["pending","failed"]),errorCode:e.nullable(e.string()),errorMessage:e.nullable(e.string()),attempts:e.number(),nextAttemptAt:e.nullable(e.string()),payloadHeld:e.boolean(),receivedAt:e.nullable(e.string()),retryUntil:e.nullable(e.string()),updatedAt:e.string()})),truncated:e.boolean()}),no=e.object({actor:_,expectedAtsLogCount:e.optional(e.pipe(e.number(),e.integer(),e.minValue(0)))}),fn=e.picklist(["invalid_transition","retry_payload_missing","retry_hold_expired","stale"]),ro=e.variant("kind",[e.object({kind:e.literal("retried"),application:N}),e.object({kind:e.literal("rejected"),applicationId:e.string(),from:e.nullable(j),reason:fn})]),oo=e.object({status:e.optional(e.picklist(["pending","failed"])),integrationId:e.nullable(H),errorCode:e.nullable(Le),actor:_}),io=e.object({retried:e.number()});var so=e.object({integrationId:e.string(),wasOpen:e.boolean()}),ao=e.object({integrationId:e.string(),wasHeld:e.boolean()}),co=e.object({applicationId:L,scoreType:ae,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),we)),leftOut:e.nullish(e.array(Pe)),scoredBy:e.nullish(e.string()),actor:e.nullish(_),idempotencyKey:e.nullish(e.pipe(e.string(),e.maxLength(255)))}),lo=e.object({scoreId:e.string()}),po=nt(N);var uo=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),mo=e.array(it),le=e.object({stage:e.nullish(T),note:e.nullish(e.string())}),yn=e.object({stage:e.nullish(T),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Sn=e.variant("action",[e.object({action:e.literal("shortlist"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("move_to_interview"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("make_offer"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("hire"),actor:_,meta:e.nullish(yn)}),e.object({action:e.literal("withdraw"),actor:_,meta:e.nullish(le)}),e.object({action:e.literal("move_to_stage"),actor:_,meta:e.object({stage:T,stageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:_,meta:e.object({toStage:T,toStageGroup:I,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:_,meta:e.object({reason:Q,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:_,meta:e.object({toStage:T,toStageGroup:I,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)))})})]),vo=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:Sn}),dt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),go=e.variant("kind",[e.object({kind:e.literal("updated"),action:pe,application:N}),e.object({kind:e.literal("skipped"),action:pe,applicationId:e.string(),reason:dt})]),ho=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:pe,application:N})),skipped:e.array(e.object({kind:e.literal("skipped"),action:pe,applicationId:e.string(),reason:dt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),m=e.pipe(e.number(),e.integer(),e.minValue(0)),ut=e.object({APPLIED:m,SHORTLISTED:m,INTERVIEWED:m,OFFERED:m,HIRED:m,REJECTED:m,WITHDRAWN:m}),fo=e.object({job_ids:at}),yo=e.object({counts:e.record(e.string(),ut)}),So=e.omit(ct,["sort","order","page","per_page"]),bo=e.object({counts:ut}),mt=92,bn=864e5,K=e.pipe(e.string(),e.regex(/^\d{4}-\d{2}-\d{2}$/),e.check(t=>{let n=new Date(`${t}T00:00:00Z`);return!Number.isNaN(n.getTime())&&n.toISOString().slice(0,10)===t},"must be a real calendar day"));function vt({from:t,to:n}){let r=(Date.parse(`${n}T00:00:00Z`)-Date.parse(`${t}T00:00:00Z`))/bn+1;return r>=1&&r<=mt}var gt=`to must be on or after from, and the range must span at most ${mt} days`,_o=e.pipe(e.object({from:K,to:K}),e.check(vt,gt)),_n=e.object({job_id:Z,date:K,received:m,scored:m,shortlisted:m}),Ao=e.object({rows:e.array(_n)}),An=5e3,Tn=e.pipe(e.object({from:K,to:K,jobIds:e.optional(e.pipe(e.array(Z),e.maxLength(An)))}),e.check(vt,gt)),To=e.pipe(e.object({from:e.string(),to:e.string(),job_ids:e.optional(e.string())}),e.transform(({from:t,to:n,job_ids:r})=>({from:t,to:n,jobIds:r===void 0?void 0:r===""?[]:r.split(",").map(i=>/^\d+$/.test(i.trim())?Number(i):Number.NaN)})),Tn),ht=e.pipe(e.array(m),e.length(5)),En=e.object({received:m,scored:m,shortlisted:m,histogram:e.pipe(e.array(m),e.length(101)),median_lag_minutes:e.nullable(e.number()),scored_same_day:m}),xn=e.object({job_id:Z,received:m,scored:m,shortlisted:m,score_sum:e.number(),bands:ht}),In=e.object({date:K,received:m,scored:m,score_sum:e.number(),bands:ht,scored_on_day:m}),Rn=e.object({id:e.string(),label:e.nullable(e.string()),sum:e.number(),count:m}),wn=e.object({template_id:e.string(),scored:m,criteria:e.array(Rn)}),Eo=e.object({totals:En,by_job:e.array(xn),by_day:e.array(In),criteria:e.array(wn)});var xo=e.object({...e.omit(ct,["page","per_page"]).entries,per_group:e.optional(e.string())}),F=e.object({data:e.array(N),total:m}),Io=e.object({board:e.object({APPLIED:F,SHORTLISTED:F,INTERVIEWED:F,OFFERED:F,HIRED:F,REJECTED:F,WITHDRAWN:F})});import*as de from"valibot";var Pn=({environment:t,publishableKey:n,logger:r})=>{let i=Ue[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(`${i}/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(),S=de.safeParse(pt,u);return S.success?S.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=de.safeParse(st,c);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 S=de.safeParse(ke,await u.json());return S.success?S.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return r.error("[TalentBankClient] identify failed:",c),null}}}};function kn(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 ft=["DAILY","WEEKLY","MONTHLY"],Cn=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())})])),Ln={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 Dn(t,{contact:n,job:r}){let i={};if(r){let l=await t.request(Ln,{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&&(i[d]=[u])}}await t.request(yt,{body:{contact:n,alerts:"WEEKLY",filters:i}})}var yt={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(ft)),filters:Cn})}};import*as A from"valibot";var St=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:A.pipe(A.object({country:A.optional(A.array(A.object({value:A.string()})),[])}),A.transform(({country:r})=>r.map(({value:i})=>i))),searchParams:C()}};return t.request(n,{searchParams:{filters:{country:null}}})},ue=new WeakMap,On=t=>(ue.has(t)||(ue.set(t,void 0),St(t).then(async n=>{let{jobCountryCodes:r}=await import("./sdk.country-codes-W6HRF5SA.mjs");ue.set(t,r(n).join(",")||void 0)}).catch(()=>{})),ue.get(t)),bt=(t,n)=>{let r=new Set,i=[];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),i.push(c),i.length===5))return i}return i},jn=600,Nn=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let i=await t();return r?.throwIfAborted(),i}return new Promise((i,l)=>{let c,d,u,S=!1,E=()=>{S=!0,clearTimeout(u),r?.removeEventListener("abort",U)},U=()=>{E(),l(r?.reason)},D=()=>{E(),c?.status==="fulfilled"&&d?.status==="fulfilled"?i(bt(c.value,d.value)):c?.status==="fulfilled"?i(c.value):d?.status==="fulfilled"?i(d.value):c?.status==="rejected"&&l(c.reason)},me=(p,h)=>{S||(p?c=h:d=h,c&&d?D():h.status==="fulfilled"&&h.value.length>0&&(u=setTimeout(D,jn)))};r?.addEventListener("abort",U,{once:!0});for(let p of[!0,!1])t(p?n:void 0).then(h=>me(p,{status:"fulfilled",value:h}),h=>me(p,{status:"rejected",reason:h}))})};export{qt as ANALYTICS_EVENTS,V as ApiError,z as InploiRpcClient,ft as JOB_ALERT_FREQUENCIES,G as NotFoundError,$ as ParsingError,w as SchemaValidationError,Ne as SdkError,q as UnauthorisedError,On as addressSearchCountry,bt as blendAddressSuggestions,Ie as consentStorageKey,Et as createPlugin,Pn as createTalentBankClient,ie as endpoint,J as generateUUID,Vt as getConsentAcceptance,St as getJobCountries,We as getOrCreateAnonymousId,xe as hashConsentConfig,Gt as initialiseSdk,fe as inploiBrandedLogger,Rt as isApiErrorWithData,kt as isSdkError,Tt as jobCountryCodes,ye as noLogging,kn as ready,Dn as saveClosedRoleJobAlerts,yt as saveSearchEndpoint,Nn as searchAddressSuggestions,$t as setConsentAcceptance,C as typed,Ye as validateEndpointInputs};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|