@inploi/sdk 2.9.1 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/cdn/index.js +1 -1
- package/dist/index.d.mts +7 -0
- package/dist/index.d.ts +7 -0
- 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 +1 -1
package/README.md
CHANGED
|
@@ -49,8 +49,9 @@ Job-alert subscriptions remain independent server writes. The default,
|
|
|
49
49
|
|
|
50
50
|
This option covers analytics only. Hosts own consent changes, clearing previously
|
|
51
51
|
stored identifiers, experiment cookies and rollout seeds, and replacing their SDK
|
|
52
|
-
instance when the persistence choice changes.
|
|
53
|
-
`getOrCreateAnonymousId`
|
|
52
|
+
instance when the persistence choice changes. The agent widgets' visitor id follows it: they call
|
|
53
|
+
`analytics.getOrCreateAnonymousId()` when the host's SDK has it, which with `none` keeps one id for the page in
|
|
54
|
+
memory. The module-level `getOrCreateAnonymousId` always stores; plugins' other storage is outside this option.
|
|
54
55
|
|
|
55
56
|
## Plugins
|
|
56
57
|
|
package/cdn/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This is an inploi sdk script. Learn more at https://inploi.com
|
|
2
2
|
|
|
3
|
-
"use strict";(()=>{var Qn=Object.defineProperty,et=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var fn=Object.getOwnPropertySymbols;var tt=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var yn=(e,t,n)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))tt.call(t,n)&&yn(e,n,t[n]);if(fn)for(var n of fn(t))rt.call(t,n)&&yn(e,n,t[n]);return e},G=(e,t)=>et(e,nt(t));var it=(e,t)=>()=>(e&&(t=e(e=0)),t);var C=(e,t,n)=>new Promise((r,s)=>{var o=u=>{try{c(n.next(u))}catch(f){s(f)}},a=u=>{try{c(n.throw(u))}catch(f){s(f)}},c=u=>u.done?r(u.value):Promise.resolve(u.value).then(o,a);c((n=n.apply(e,t)).next())});var Vn=it(()=>{"use strict"});function Ge(e,t){if(!e)throw new Error(t)}function oe(e,t){return t in e}var pr=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var xe="%c[inploi SDK]",we="color: #65BC67; font-weight: bold;",Be={warn:(...e)=>console.warn(xe,we,...e),error:(...e)=>console.error(xe,we,...e),info:(...e)=>console.info(xe,we,...e),log:(...e)=>console.log(xe,we,...e)},ze={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var st="Unauthenticated",ot="This action is unauthorized.",ne=class extends Error{constructor(n,r){super(n);this.status=r,this.name="ErrorWithStatus"}},ye=class extends ne{constructor(t){super(t!=null?t:"Not found"),this.name="NotFoundError",this.status=404}},me=class extends ne{constructor(t,n){super(t!=null?t:"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=n!=null?n:401}},ee=class extends ne{constructor(n,r){let s=r?` in ${r}`:"";super(`Schema validation failed${s}`);this.issues=n;this.source=r;this.name="SchemaValidationError",this.status=400}},Ee=class extends ne{constructor(n,r,s){super(n);this.data=s;this.name="ApiError",this.status=r!=null?r:500}};var de=class extends ne{constructor(n){var r;super("Error parsing response into JSON.");this.response=n;this.name="ParsingError",this.status=n&&n.status>=300?n.status:500,this.contentType=(r=new Headers(n==null?void 0:n.headers).get("content-type"))!=null?r:void 0}};function Ue(e){return C(this,null,function*(){let t=new Headers(e.headers).get("content-type"),n=t==null?void 0:t.replace(/;.*/,"").trim().toLowerCase();if(n&&n!=="application/json"&&!n.endsWith("+json"))throw new de(e);return e.json().catch(()=>{throw new de(e)})})}var ut=["message","error","errors","exception","exceptions"];function at(e){let t=[];if(typeof e=="object"&&e!==null){for(let n of ut)if(oe(e,n)){let r=e[n];typeof r=="string"&&t.push(r),Array.isArray(r)&&r.every(s=>typeof s=="string")&&t.push(...r)}oe(e,"integration_response")&&typeof e.integration_response=="object"&&e.integration_response!==null&&oe(e.integration_response,"error")&&typeof e.integration_response.error=="object"&&e.integration_response.error!==null&&oe(e.integration_response.error,"message")&&typeof e.integration_response.error.message=="string"&&t.push(e.integration_response.error.message)}return t.length===0&&t.push("Unknown error"),[...new Set(t)].join(", ")}function Ve(e,t){if(t>=300){let n=at(e);throw t===404?new ye(n):n===st?new me("You are not authenticated.",t):n===ot?new me(n,t):new Ee(n,t,e)}}var mn=e=>{let t={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(s,...o)=>C(void 0,[s,...o],function*(n,r={}){let a=G(O({},r),{headers:O(O({},r.headers),t)}),c=yield fetch(`${e.baseUrl}${n}`,a);if(c.status===404)throw new ye;let u=yield Ue(c);return Ve(u,c.status),u})}};var dn="2.9.1";var Se={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},hn={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},vn=dn;var X="isdk_session",Ae=`${X}-candidate_id`,ct=`${X}-consent`;var Ke="RFC3986",He={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:e=>String(e)},pt="RFC1738";var ft=Array.isArray,z=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var Je=1024,yt=(e,t,n,r,s)=>{if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),n==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});let a="";for(let c=0;c<o.length;c+=Je){let u=o.length>=Je?o.slice(c,c+Je):o,f=[];for(let d=0;d<u.length;++d){let y=u.charCodeAt(d);if(y===45||y===46||y===95||y===126||y>=48&&y<=57||y>=65&&y<=90||y>=97&&y<=122||s===pt&&(y===40||y===41)){f[f.length]=u.charAt(d);continue}if(y<128){f[f.length]=z[y];continue}if(y<2048){f[f.length]=z[192|y>>6]+z[128|y&63];continue}if(y<55296||y>=57344){f[f.length]=z[224|y>>12]+z[128|y>>6&63]+z[128|y&63];continue}d+=1,y=65536+((y&1023)<<10|u.charCodeAt(d)&1023),f[f.length]=z[240|y>>18]+z[128|y>>12&63]+z[128|y>>6&63]+z[128|y&63]}a+=f.join("")}return a};function mt(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function gn(e,t){if(ft(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var Er=Array.isArray;var dt=Object.prototype.hasOwnProperty,bn={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},U=Array.isArray,ht=Array.prototype.push,kn=function(e,t){ht.apply(e,U(t)?t:[t])},vt=Date.prototype.toISOString,j={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:yt,encodeValuesOnly:!1,format:Ke,formatter:He[Ke],indices:!1,serializeDate(e){return vt.call(e)},skipNulls:!1,strictNullHandling:!1};function gt(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var We={};function _n(e,t,n,r,s,o,a,c,u,f,d,y,p,v,w,T,S,P){let b=e,R=P,Y=0,pe=!1;for(;(R=R.get(We))!==void 0&&!pe;){let D=R.get(e);if(Y+=1,typeof D!="undefined"){if(D===Y)throw new RangeError("Cyclic object value");pe=!0}typeof R.get(We)=="undefined"&&(Y=0)}if(typeof f=="function"?b=f(t,b):b instanceof Date?b=p==null?void 0:p(b):n==="comma"&&U(b)&&(b=gn(b,function(D){return D instanceof Date?p==null?void 0:p(D):D})),b===null){if(o)return u&&!T?u(t,j.encoder,S,"key",v):t;b=""}if(gt(b)||mt(b)){if(u){let D=T?t:u(t,j.encoder,S,"key",v);return[(w==null?void 0:w(D))+"="+(w==null?void 0:w(u(b,j.encoder,S,"value",v)))]}return[(w==null?void 0:w(t))+"="+(w==null?void 0:w(String(b)))]}let fe=[];if(typeof b=="undefined")return fe;let x;if(n==="comma"&&U(b))T&&u&&(b=gn(b,u)),x=[{value:b.length>0?b.join(",")||null:void 0}];else if(U(f))x=f;else{let D=Object.keys(b);x=d?D.sort(d):D}let Z=c?String(t).replace(/\./g,"%2E"):String(t),se=r&&U(b)&&b.length===1?Z+"[]":Z;if(s&&U(b)&&b.length===0)return se+"[]";for(let D=0;D<x.length;++D){let K=x[D],Q=typeof K=="object"&&typeof K.value!="undefined"?K.value:b[K];if(a&&Q===null)continue;let H=y&&c?K.replace(/\./g,"%2E"):K,Zn=U(b)?typeof n=="function"?n(se,H):se:se+(y?"."+H:"["+H+"]");P.set(e,Y);let pn=new WeakMap;pn.set(We,P),kn(fe,_n(Q,Zn,n,r,s,o,a,c,n==="comma"&&T&&U(b)?null:u,f,d,y,p,v,w,T,S,pn))}return fe}function bt(e=j){if(typeof e.allowEmptyArrays!="undefined"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys!="undefined"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder!="undefined"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");let t=e.charset||j.charset;if(typeof e.charset!="undefined"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=Ke;if(typeof e.format!="undefined"){if(!dt.call(He,e.format))throw new TypeError("Unknown format option provided.");n=e.format}let r=He[n],s=j.filter;(typeof e.filter=="function"||U(e.filter))&&(s=e.filter);let o;if(e.arrayFormat&&e.arrayFormat in bn?o=e.arrayFormat:"indices"in e?o=e.indices?"indices":"repeat":o=j.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof e.allowDots=="undefined"?e.encodeDotInKeys?!0:j.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:j.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:j.allowEmptyArrays,arrayFormat:o,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:j.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter=="undefined"?j.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:j.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:j.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:j.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:j.encodeValuesOnly,filter:s,format:n,formatter:r,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:j.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:j.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:j.strictNullHandling}}function xn(e,t={}){let n=e,r=bt(t),s,o;typeof r.filter=="function"?(o=r.filter,n=o("",n)):U(r.filter)&&(o=r.filter,s=o);let a=[];if(typeof n!="object"||n===null)return"";let c=bn[r.arrayFormat],u=c==="comma"&&r.commaRoundTrip;s||(s=Object.keys(n)),r.sort&&s.sort(r.sort);let f=new WeakMap;for(let p=0;p<s.length;++p){let v=s[p];r.skipNulls&&n[v]===null||kn(a,_n(n[v],v,c,u,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,f))}let d=a.join(r.delimiter),y=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?y+="utf8=%26%2310003%3B&":y+="utf8=%E2%9C%93&"),d.length>0?y+d:""}function Xe(e,t,n){let r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Async schema");if(r.issues)throw new ee(r.issues,n);return r.value}function kt(e,t,n){try{return{success:!0,output:Xe(e,t,n)}}catch(r){if(r instanceof ee)return{success:!1,issues:r.issues,source:r.source};throw r}}var he=class{constructor(t){if(this.baseUrl=Se[t.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),t.apiKey.type==="secret"){if(typeof window!="undefined")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",t.apiKey.key)}else this.headers.set("x-publishable-key",t.apiKey.key);this.logger=t.logger,this._environment=t.environment}get environment(){return this._environment}getFetchParams(t,n){var u;let r=(u=n.validateIn)!=null?u:!0,{searchParams:s,body:o}=r?wn(t,n):n,a=new URL(this.baseUrl),c=t.pathname;if("params"in n&&n.params)for(let[f,d]of Object.entries(n.params))c=c.replace(`:${f}`,String(d));return a.pathname=c,t.schema.searchParams&&(a.search=xn(s)),[a.toString(),O({method:t.method,body:o?JSON.stringify(o):void 0,headers:this.headers,signal:n.signal},n.keepalive&&{keepalive:!0})]}parseResponse(t,n){return C(this,null,function*(){var a;let r=yield Ue(n.response);if(Ve(r,n.response.status),!((a=n.validateOut)!=null?a:!0))return r;let o=kt(t.schema.response,r,"response");if(!o.success)throw new ee(o.issues,o.source);return o.output})}request(t,n){return C(this,null,function*(){try{let r=this.getFetchParams(t,n),s=yield fetch(...r);return yield this.parseResponse(t,{response:s,validateOut:n.validateOut})}catch(r){throw r instanceof ee?this.logger.error(r.message,r.issues):this.logger.error(r),r}})}};function te(){return{"~standard":{vendor:"inploi",version:1,validate:e=>({value:e})}}}function wn(e,t){let n={searchParams:void 0,body:void 0,validateIn:!1};return e.schema.searchParams&&(n.searchParams=Xe(e.schema.searchParams,"searchParams"in t?t.searchParams:{})),e.schema.body&&(n.body=Xe(e.schema.body,"body"in t?t.body:{})),n}var V,_t={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function An(e){var t,n,r;return!e&&!V?_t:{lang:(t=e==null?void 0:e.lang)!=null?t:V==null?void 0:V.lang,message:e==null?void 0:e.message,abortEarly:(n=e==null?void 0:e.abortEarly)!=null?n:V==null?void 0:V.abortEarly,abortPipeEarly:(r=e==null?void 0:e.abortPipeEarly)!=null?r:V==null?void 0:V.abortPipeEarly}}var $e;function xt(e){return $e==null?void 0:$e.get(e)}var Ye;function wt(e){return Ye==null?void 0:Ye.get(e)}var Ze;function Et(e,t){var n;return(n=Ze==null?void 0:Ze.get(e))==null?void 0:n.get(t)}function re(e){var n,r,s;let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(s=e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))!=null?s:"null":t}function I(e,t,n,r,s){var y,p,v,w,T,S,P,b;let o=s&&"input"in s?s.input:n.value,a=(p=(y=s==null?void 0:s.expected)!=null?y:e.expects)!=null?p:null,c=(v=s==null?void 0:s.received)!=null?v:re(o),u={kind:e.kind,type:e.type,input:o,expected:a,received:c,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},f=e.kind==="schema",d=(b=(P=(S=(T=(w=s==null?void 0:s.message)!=null?w:e.message)!=null?T:Et(e.reference,u.lang))!=null?S:f?wt(u.lang):null)!=null?P:r.message)!=null?b:xt(u.lang);d!==void 0&&(u.message=typeof d=="function"?d(u):d),f&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}var En=new WeakMap;function N(e){let t=En.get(e);return t||(t={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},An())}},En.set(e,t)),t}function St(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Qe(e,t){var r;let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:(r=n[0])!=null?r:"never"}var At=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu,jr=new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$","u");function en(e,t){return{kind:"validation",type:"check",reference:en,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&I(this,"input",n,r),n}}}function nn(e){return{kind:"validation",type:"email",reference:nn,expects:null,async:!1,requirement:At,message:e,"~run"(t,n){return t.typed&&!this.requirement.test(t.value)&&I(this,"email",t,n),t}}}function ue(e){return{kind:"validation",type:"integer",reference:ue,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&I(this,"integer",t,n),t}}}function Ie(e,t){return{kind:"validation",type:"max_length",reference:Ie,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(n,r){return n.typed&&n.value.length>this.requirement&&I(this,"length",n,r,{received:`${n.value.length}`}),n}}}function tn(e,t){return{kind:"validation",type:"max_value",reference:tn,async:!1,expects:`<=${e instanceof Date?e.toJSON():re(e)}`,requirement:e,message:t,"~run"(n,r){return n.typed&&!(n.value<=this.requirement)&&I(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():re(n.value)}),n}}}function L(e,t){return{kind:"validation",type:"min_length",reference:L,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,r){return n.typed&&n.value.length<this.requirement&&I(this,"length",n,r,{received:`${n.value.length}`}),n}}}function ae(e,t){return{kind:"validation",type:"min_value",reference:ae,async:!1,expects:`>=${e instanceof Date?e.toJSON():re(e)}`,requirement:e,message:t,"~run"(n,r){return n.typed&&!(n.value>=this.requirement)&&I(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():re(n.value)}),n}}}function Te(e){return{kind:"transformation",type:"transform",reference:Te,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function Pe(){return{kind:"transformation",type:"trim",reference:Pe,async:!1,"~run"(e){return e.value=e.value.trim(),e}}}var It={abortEarly:!0};function Tt(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function Re(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function F(e,t){return{kind:"schema",type:"array",reference:F,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){var o;let s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let a=0;a<s.length;a++){let c=s[a],u=this.item["~run"]({value:c},r);if(u.issues){let f={type:"array",origin:"value",input:s,key:a,value:c};for(let d of u.issues)d.path?d.path.unshift(f):d.path=[f],(o=n.issues)==null||o.push(d);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else I(this,"type",n,r);return n}}}function ve(e){return{kind:"schema",type:"boolean",reference:ve,expects:"boolean",async:!1,message:e,get"~standard"(){return N(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:I(this,"type",t,n),t}}}function _(e,t){return{kind:"schema",type:"literal",reference:_,expects:re(e),async:!1,literal:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:I(this,"type",n,r),n}}}function m(e,t){return{kind:"schema",type:"nullable",reference:m,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return N(this)},"~run"(n,r){return n.value===null&&(this.default!==void 0&&(n.value=Re(this,n,r)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function h(e,t){return{kind:"schema",type:"nullish",reference:h,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return N(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=Re(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function k(e){return{kind:"schema",type:"number",reference:k,expects:"number",async:!1,message:e,get"~standard"(){return N(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:I(this,"type",t,n),t}}}function l(e,t){return{kind:"schema",type:"object",reference:l,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){var o;let s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(let a in this.entries){let c=this.entries[a];if(a in s||(c.type==="exact_optional"||c.type==="optional"||c.type==="nullish")&&c.default!==void 0){let u=a in s?s[a]:Re(c),f=c["~run"]({value:u},r);if(f.issues){let d={type:"object",origin:"value",input:s,key:a,value:u};for(let y of f.issues)y.path?y.path.unshift(d):y.path=[d],(o=n.issues)==null||o.push(y);if(n.issues||(n.issues=f.issues),r.abortEarly){n.typed=!1;break}}f.typed||(n.typed=!1),n.value[a]=f.value}else if(c.fallback!==void 0)n.value[a]=Tt(c);else if(c.type!=="exact_optional"&&c.type!=="optional"&&c.type!=="nullish"&&(I(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:s,key:a,value:s[a]}]}),r.abortEarly))break}}else I(this,"type",n,r);return n}}}function g(e,t){return{kind:"schema",type:"optional",reference:g,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return N(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=Re(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function A(e,t){return{kind:"schema",type:"picklist",reference:A,expects:Qe(e.map(re),"|"),async:!1,options:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){return this.options.includes(n.value)?n.typed=!0:I(this,"type",n,r),n}}}function J(e,t,n){return{kind:"schema",type:"record",reference:J,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return N(this)},"~run"(r,s){var a,c;let o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(let u in o)if(St(o,u)){let f=o[u],d=this.key["~run"]({value:u},s);if(d.issues){let p={type:"object",origin:"key",input:o,key:u,value:f};for(let v of d.issues)v.path=[p],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=d.issues),s.abortEarly){r.typed=!1;break}}let y=this.value["~run"]({value:f},s);if(y.issues){let p={type:"object",origin:"value",input:o,key:u,value:f};for(let v of y.issues)v.path?v.path.unshift(p):v.path=[p],(c=r.issues)==null||c.push(v);if(r.issues||(r.issues=y.issues),s.abortEarly){r.typed=!1;break}}(!d.typed||!y.typed)&&(r.typed=!1),d.typed&&(r.value[d.value]=y.value)}}else I(this,"type",r,s);return r}}}function i(e){return{kind:"schema",type:"string",reference:i,expects:"string",async:!1,message:e,get"~standard"(){return N(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:I(this,"type",t,n),t}}}function Sn(e){let t;if(e)for(let n of e)if(t)for(let r of n.issues)t.push(r);else t=n.issues;return t}function ge(e,t){return{kind:"schema",type:"union",reference:ge,expects:Qe(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){let s,o,a;for(let c of this.options){let u=c["~run"]({value:n.value},r);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{s=u;break}else a?a.push(u):a=[u]}if(s)return s;if(o){if(o.length===1)return o[0];I(this,"type",n,r,{issues:Sn(o)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];I(this,"type",n,r,{issues:Sn(a)})}return n}}}function rn(){return{kind:"schema",type:"unknown",reference:rn,expects:"unknown",async:!1,get"~standard"(){return N(this)},"~run"(e){return e.typed=!0,e}}}function le(e,t,n){return{kind:"schema",type:"variant",reference:le,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return N(this)},"~run"(r,s){let o=r.value;if(o&&typeof o=="object"){let a,c=0,u=this.key,f=[],d=(y,p)=>{for(let v of y.options){if(v.type==="variant")d(v,new Set(p).add(v.key));else{let w=!0,T=0;for(let S of p){let P=v.entries[S];if(S in o?P["~run"]({typed:!1,value:o[S]},It).issues:P.type!=="exact_optional"&&P.type!=="optional"&&P.type!=="nullish"){w=!1,u!==S&&(c<T||c===T&&S in o&&!(u in o))&&(c=T,u=S,f=[]),u===S&&f.push(v.entries[S].expects);break}T++}if(w){let S=v["~run"]({value:o},s);(!a||!a.typed&&S.typed)&&(a=S)}}if(a&&!a.issues)break}};if(d(this,new Set([this.key])),a)return a;I(this,"type",r,s,{input:o[u],expected:Qe(f,"|"),path:[{type:"object",origin:"value",input:o,key:u,value:o[u]}]})}else I(this,"type",r,s);return r}}}function E(...e){return G(O({},e[0]),{pipe:e,get"~standard"(){return N(this)},"~run"(t,n){for(let r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}})}function De(e,t,n){let r=e["~run"]({value:t},An(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var Pt=["agent","sdk","form","integration","migration"],Rt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Dt=["screening","cv_match","interview","overall"],jt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],Ot=["job","company"],Ct=["created_at","updated_at"],Nt=["asc","desc"],Lt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Ft=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],qt=["user","system","automation","integration","candidate"],je=A(Pt),W=A(Rt),M=E(i(),Pe(),L(1),Ie(100)),Oe=A(Dt),In=A(jt),Cr=A(Ot),Tn=A(Ct),Pn=A(Nt),be=E(i(),Pe(),L(1),Ie(100)),Ce=A(Lt),Rn=A(Ft),Dn=A(qt);var q=le("type",[l({type:_("user"),id:E(i(),L(1)),email:E(i(),L(1)),name:E(i(),L(1))}),l({type:_("system"),id:E(i(),L(1)),name:g(i())}),l({type:_("automation"),id:E(i(),L(1)),name:g(i())}),l({type:_("integration"),id:E(i(),L(1)),name:g(i())}),l({type:_("candidate"),id:E(i(),L(1)),email:g(i())})]);var Mt=l({total:k(),page:k(),perPage:k(),lastPage:k()});function Ne(e){return l({data:F(e),pagination:Mt})}var ke=l({id:i(),email:m(i()),firstName:m(i()),lastName:m(i()),phone:m(i()),source:m(je),identifiedAt:m(i()),createdAt:i(),updatedAt:i()});var ce=E(i(),L(1)),jn=E(k(),ue(),ae(1)),$=J(i(),rn());var On=l({id:i(),applicationId:i(),status:In,scheduledAt:m(i()),completedAt:m(i()),meta:m($),createdAt:i(),updatedAt:i()});var sn=l({score:k(),reason:i(),confidence:k()}),Cn=l({id:i(),candidateId:i(),jobId:k(),stage:M,stageGroup:W,stageEnteredAt:i(),rating:m(k()),disqualifiedAt:m(i()),disqualificationReason:m(be),disqualificationNote:m(i()),source:Ce,sourceDetail:m(i()),sessionId:m(k()),externalApplicationId:m(i()),meta:m($),context:m($),scoredAt:m(i()),createdAt:i(),updatedAt:i()}),Gt=l({id:i(),applicationId:i(),scoreType:Oe,score:m(k()),reason:m(i()),categories:m(J(i(),sn)),scoredBy:m(i()),createdAt:i()}),Le=l(G(O({},Cn.entries),{candidate:m(ke),score:m(Gt),interview:m(On)})),Bt=l(G(O({},ke.entries),{applications:F(Cn)})),Nn=l({id:i(),applicationId:i(),action:Rn,fromStage:m(M),fromStageGroup:m(W),toStage:m(M),toStageGroup:m(W),disqualificationReason:m(be),disqualificationNote:m(i()),actorId:m(i()),actorType:Dn,actorEmail:m(i()),actorName:m(i()),meta:m($),schemaVersion:k(),createdAt:i()});var Ln=l({anonymousId:ce,email:ce,firstName:h(i()),lastName:h(i()),phone:h(i()),source:h(je)}),Fn=l({candidateId:i(),isNew:ve()});var zt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],qe=A(zt),qn=E(i(),Te(e=>e.split(",").map(t=>t.trim()).filter(t=>t.length>0))),Ut=E(qn,F(M)),Vt=E(qn,F(W)),Mn=E(i(),Te(e=>e.split(",").map(t=>Number(t.trim())).filter(t=>Number.isInteger(t)&&t>0))),ti=l({stages:g(Ut),stage_groups:g(Vt),job_id:g(i()),job_ids:g(Mn),candidate_id:g(i()),is_disqualified:g(A(["true","false"])),created_from:g(i()),created_to:g(i()),updated_from:g(i()),updated_to:g(i()),entered_stage_from:g(i()),entered_stage_to:g(i()),from:g(i()),to:g(i()),q:g(i()),scored:g(A(["true","false"])),sort:g(Tn),order:g(Pn),page:g(i()),per_page:g(i())}),ri=E(l({candidateId:ce,jobId:jn,meta:h($),sessionId:h(k()),externalApplicationId:h(i()),context:h($),source:h(Ce),sourceDetail:h(i()),stage:h(M),stageGroup:h(W),actor:h(q)}),en(e=>e.stage==null==(e.stageGroup==null),"stage and stageGroup must be supplied together")),Gn=l({id:i(),stageGroup:i(),createdAt:i()}),ii=ge([l({ok:_(!0),duplicate:_(!1),applicationId:i(),candidateId:i()}),l({ok:_(!0),duplicate:_(!0),existingApplication:Gn})]),Bn=l({isDuplicate:ve(),existingApplication:g(Gn)}),si=l({applicationId:ce,scoreType:Oe,score:k(),reason:h(i()),categories:h(J(i(),sn)),scoredBy:h(i()),actor:h(q)}),oi=l({scoreId:i()}),ui=Ne(Le);var ai=A(["already_in_target_stage","not_in_source_stage","disqualified"]),li=F(Nn),Fe=l({stage:h(M),note:h(i())}),Jt=l({stage:h(M),startDate:h(i()),note:h(i())}),Wt=le("action",[l({action:_("shortlist"),actor:q,meta:h(Fe)}),l({action:_("move_to_interview"),actor:q,meta:h(Fe)}),l({action:_("make_offer"),actor:q,meta:h(Fe)}),l({action:_("hire"),actor:q,meta:h(Jt)}),l({action:_("withdraw"),actor:q,meta:h(Fe)}),l({action:_("move_to_stage"),actor:q,meta:l({stage:M,stageGroup:W,note:h(i())})}),l({action:_("stage_transition"),actor:q,meta:l({toStage:M,toStageGroup:W,note:h(i())})}),l({action:_("disqualify"),actor:q,meta:l({reason:be,note:h(i())})}),l({action:_("reinstate"),actor:q,meta:l({toStage:M,toStageGroup:W,note:h(i())})}),l({action:_("rate"),actor:q,meta:l({rating:m(E(k(),ue(),ae(1),tn(5)))})})]),ci=l({applicationIds:E(F(i()),L(1)),body:Wt}),zn=A(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),pi=le("kind",[l({kind:_("updated"),action:qe,application:Le}),l({kind:_("skipped"),action:qe,applicationId:i(),reason:zn})]),fi=l({updated:F(l({kind:_("updated"),action:qe,application:Le})),skipped:F(l({kind:_("skipped"),action:qe,applicationId:i(),reason:zn})),failed:F(l({applicationId:i(),error:i()}))}),ie=E(k(),ue(),ae(0)),Kt=l({APPLIED:ie,SHORTLISTED:ie,INTERVIEWED:ie,OFFERED:ie,HIRED:ie,REJECTED:ie,WITHDRAWN:ie}),yi=l({job_ids:Mn}),mi=l({counts:J(i(),Kt)});var bi=Ne(ke);var _i=l({avg_score:m(k()),p90_score:m(k()),p85_score:m(k()),p80_score:m(k()),total_scores:k(),total_shortlists:k()});var on=({environment:e,publishableKey:t,logger:n})=>{let r=hn[e];return{checkDuplicate(o){return C(this,null,function*(){try{let a=new URLSearchParams({email:o.email,scope:o.scope});o.scope==="job"&&o.jobId!=null&&a.set("job_id",String(o.jobId));let c=yield fetch(`${r}/applications/check-duplicate?${a}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":t}});if(!c.ok)return n.error(`[TalentBankClient] checkDuplicate failed with status ${c.status}`),{isDuplicate:!1};let u=yield c.json(),f=De(Bn,u);return f.success?f.output:(n.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(a){return n.error("[TalentBankClient] checkDuplicate failed:",a),{isDuplicate:!1}}})},identify(o){return C(this,null,function*(){var a;try{if(!o.anonymousId)return n.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let c={email:o.email,firstName:o.firstName,lastName:o.lastName,phone:o.phone,anonymousId:o.anonymousId,source:(a=o.source)!=null?a:"sdk"},u=De(Ln,c);if(!u.success)return n.error("[TalentBankClient] identify received invalid input"),null;let f=yield fetch(`${r}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":t},body:JSON.stringify(u.output)});if(!f.ok)return n.error(`[TalentBankClient] identify failed with status ${f.status}`),null;let d=De(Fn,yield f.json());return d.success?d.output:(n.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return n.error("[TalentBankClient] identify failed:",c),null}})}}};var Me=()=>typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16));function un(e){if(typeof document!="undefined"){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",e,{once:!0});return}Promise.resolve().then(e)}}var Un=["DAILY","WEEKLY","MONTHLY"],Ht=J(i(),ge([i(),F(i()),l({type:_("provided"),lat:k(),lng:k(),radius:k(),unit:g(A(["miles","km"])),label:g(i())})])),Vi={pathname:"/job/:id",method:"GET",schema:{response:l({id:k(),external_id:h(i()),city:h(i()),town:h(i()),category:h(i())})}};var Xt={pathname:"/search/save",method:"POST",schema:{response:te(),body:l({contact:l({email:E(g(i()),i(),nn()),first_name:g(i()),last_name:g(i())}),alerts:E(g(i()),i(),A(Un)),filters:Ht})}};Vn();var Kn=7*24*60*60*1e3,Hn=e=>{let t=new Date;return t.setTime(t.getTime()+Kn),`${X}=${e};expires=${t.toUTCString()};path=/`},$t=(e,t)=>{let n=e.get("session_id");if(t||n)return n;let r=sessionStorage.getItem(`${X}-session_id`);return typeof r=="string"?r:null},Yt=()=>{if(typeof window=="undefined")return null;try{let e=window.localStorage.getItem(Ae);return typeof e=="string"&&e!==""?e:null}catch(e){return null}},Zt=e=>{if(typeof window!="undefined")try{e?window.localStorage.setItem(Ae,e):window.localStorage.removeItem(Ae)}catch(t){}},Qt=new RegExp(`(?:^|;\\s*)${X}=([^;]+)`),_e=e=>{var n,r;let t=e?e.headers.get("cookie"):document.cookie;return t&&(r=(n=Qt.exec(t))==null?void 0:n[1])!=null?r:null},Xn=()=>{var e;try{let t=JSON.parse((e=window.localStorage.getItem(X))!=null?e:"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(t){return null}},Wn=()=>{var e;return(e=_e())!=null?e:new URL(location.href).searchParams.get("anonymous_id")?null:Xn()},er=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",$n=e=>{if(document.cookie=Hn(e)+er(),_e()!==e)try{window.localStorage.setItem(X,JSON.stringify({id:e,expires:Date.now()+Kn}))}catch(t){}},cn=e=>{var r,s,o;let t=e?e.url:location.href,{searchParams:n}=new URL(t);return{anonymous_id:e?(r=_e(e))!=null?r:n.get("anonymous_id"):(o=(s=_e())!=null?s:n.get("anonymous_id"))!=null?o:Xn(),session_id:$t(n,typeof window=="undefined")}},Jn=()=>{if(typeof window=="undefined")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let e=cn().anonymous_id;if(e)return e;let t=Me(),n=cn().anonymous_id;return n||($n(t),t)},nr=e=>typeof e!="object"||e===null?null:{anonymous_id:"anonymous_id"in e&&typeof e.anonymous_id=="string"?e.anonymous_id:null,session_id:"session_id"in e&&typeof e.session_id=="string"?e.session_id:null},tr=e=>e==="about:client"?"":e,rr={pathname:"/log",method:"POST",schema:{response:te(),body:te()}},Yn=({rpcClient:e,logger:t,onEvent:n,talentBank:r,persistence:s="device"})=>{let o=null,a=0,c=0,u=p=>s==="none"?{anonymous_id:null,session_id:p?null:o}:cn(p),f=(p,v)=>C(void 0,null,function*(){var w,T;try{let S={library:{name:"inploi-sdk",version:vn},page:v},P=u(p.request);s==="device"&&p.event==="IDENTIFY"&&!P.anonymous_id&&!p.request&&typeof window!="undefined"&&(P=G(O({},P),{anonymous_id:Jn()}));let b=s==="none"?null:Yt();if(p.event==="IDENTIFY"&&r&&(P.anonymous_id||s==="none")){let Q=p.properties,H=yield r.identify({email:(w=Q.email)!=null?w:Q.identifier,firstName:Q.first_name,lastName:Q.last_name,phone:Q.phone_number,anonymousId:(T=P.anonymous_id)!=null?T:Me(),source:"sdk"});H!=null&&H.candidateId&&s==="device"&&(b=H.candidateId,Zt(H.candidateId))}let R={anonymous_id:P.anonymous_id,session_id:P.session_id,candidate_id:b,event:p.event,sent_at:new Date().toISOString(),context:S,properties:p.properties,custom_properties:p.customProperties},Y=s==="none"?null:p.request?_e(p.request):Wn(),pe=++a,fe=yield e.request(rr,O({body:R},p.keepalive&&{keepalive:!0})),x=nr(fe);if(s==="none")return!p.request&&(x!=null&&x.session_id)&&pe>c&&(c=pe,x.session_id!==R.session_id&&(o=x.session_id)),R.session_id=p.request?(x==null?void 0:x.session_id)||null:o,n==null||n(R),{success:!0,data:R};let Z=p.request?Y:Wn(),se=Z!==null&&Z!==Y,D=Z!=null?Z:Y,K=!se&&(!D||!(x!=null&&x.anonymous_id)||D===x.anonymous_id);return K?(x!=null&&x.anonymous_id&&(R.anonymous_id=x.anonymous_id),x!=null&&x.session_id&&(R.session_id=x.session_id)):R.anonymous_id=D,!p.request&&typeof window!="undefined"&&R.anonymous_id&&(K&&R.session_id&&sessionStorage.setItem(`${X}-session_id`,R.session_id.toString()),$n(R.anonymous_id)),n==null||n(R),{success:!0,data:R}}catch(S){return t.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:S}}}),d=Promise.resolve();return{log:p=>C(void 0,null,function*(){Ge(p.request||typeof window!="undefined","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:tr(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(s==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p=G(O({},p),{keepalive:!0})),s==="device"||p.request||o||p.keepalive)return f(p,v);let w=()=>f(p,v),T=d.then(w,w);return d=T,T}),getHeaders:p=>{let v=new Headers;return s==="none"||!(p!=null&&p.anonymous_id)||v.append("Set-Cookie",Hn(p.anonymous_id)),v},getSessionInfo:u}};function ln({publishableKey:e,env:t,logger:n=Be,onEvent:r,persistence:s}){let o=mn({baseUrl:Se[t],publishableKey:e}),a=n===!1?ze:n,c=new he({environment:t,apiKey:{type:"publishable",key:e},logger:a}),u=on({environment:t,publishableKey:e,logger:a}),f=Yn({rpcClient:c,logger:a,onEvent:r,talentBank:u,persistence:s});return{register:y=>y({logger:a,apiClient:o,analytics:f,rpcClient:c,publishableKey:e,env:t}),analytics:f,apiClient:o}}typeof window.inploi!="object"&&(window.inploi={});window.process=window.process||{};window.process.env=window.process.env||{};window.process.env.NODE_ENV="production";window.inploi.initialiseSdk=ln;window.inploi.ready=un;})();
|
|
3
|
+
"use strict";(()=>{var Qn=Object.defineProperty,et=Object.defineProperties;var nt=Object.getOwnPropertyDescriptors;var mn=Object.getOwnPropertySymbols;var tt=Object.prototype.hasOwnProperty,rt=Object.prototype.propertyIsEnumerable;var dn=(e,t,n)=>t in e?Qn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,j=(e,t)=>{for(var n in t||(t={}))tt.call(t,n)&&dn(e,n,t[n]);if(mn)for(var n of mn(t))rt.call(t,n)&&dn(e,n,t[n]);return e},G=(e,t)=>et(e,nt(t));var it=(e,t)=>()=>(e&&(t=e(e=0)),t);var O=(e,t,n)=>new Promise((r,s)=>{var o=u=>{try{p(n.next(u))}catch(f){s(f)}},a=u=>{try{p(n.throw(u))}catch(f){s(f)}},p=u=>u.done?r(u.value):Promise.resolve(u.value).then(o,a);p((n=n.apply(e,t)).next())});var Wn=it(()=>{"use strict"});function Be(e,t){if(!e)throw new Error(t)}function ae(e,t){return t in e}var pr=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var Ee="%c[inploi SDK]",Se="color: #65BC67; font-weight: bold;",ze={warn:(...e)=>console.warn(Ee,Se,...e),error:(...e)=>console.error(Ee,Se,...e),info:(...e)=>console.info(Ee,Se,...e),log:(...e)=>console.log(Ee,Se,...e)},Ue={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var st="Unauthenticated",ot="This action is unauthorized.",te=class extends Error{constructor(n,r){super(n);this.status=r,this.name="ErrorWithStatus"}},me=class extends te{constructor(t){super(t!=null?t:"Not found"),this.name="NotFoundError",this.status=404}},de=class extends te{constructor(t,n){super(t!=null?t:"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=n!=null?n:401}},Z=class extends te{constructor(n,r){let s=r?` in ${r}`:"";super(`Schema validation failed${s}`);this.issues=n;this.source=r;this.name="SchemaValidationError",this.status=400}},Ae=class extends te{constructor(n,r,s){super(n);this.data=s;this.name="ApiError",this.status=r!=null?r:500}};var he=class extends te{constructor(n){var r;super("Error parsing response into JSON.");this.response=n;this.name="ParsingError",this.status=n&&n.status>=300?n.status:500,this.contentType=(r=new Headers(n==null?void 0:n.headers).get("content-type"))!=null?r:void 0}};function Ve(e){return O(this,null,function*(){let t=new Headers(e.headers).get("content-type"),n=t==null?void 0:t.replace(/;.*/,"").trim().toLowerCase();if(n&&n!=="application/json"&&!n.endsWith("+json"))throw new he(e);return e.json().catch(()=>{throw new he(e)})})}var ut=["message","error","errors","exception","exceptions"];function at(e){let t=[];if(typeof e=="object"&&e!==null){for(let n of ut)if(ae(e,n)){let r=e[n];typeof r=="string"&&t.push(r),Array.isArray(r)&&r.every(s=>typeof s=="string")&&t.push(...r)}ae(e,"integration_response")&&typeof e.integration_response=="object"&&e.integration_response!==null&&ae(e.integration_response,"error")&&typeof e.integration_response.error=="object"&&e.integration_response.error!==null&&ae(e.integration_response.error,"message")&&typeof e.integration_response.error.message=="string"&&t.push(e.integration_response.error.message)}return t.length===0&&t.push("Unknown error"),[...new Set(t)].join(", ")}function Je(e,t){if(t>=300){let n=at(e);throw t===404?new me(n):n===st?new de("You are not authenticated.",t):n===ot?new de(n,t):new Ae(n,t,e)}}var hn=e=>{let t={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(s,...o)=>O(void 0,[s,...o],function*(n,r={}){let a=G(j({},r),{headers:j(j({},r.headers),t)}),p=yield fetch(`${e.baseUrl}${n}`,a);if(p.status===404)throw new me;let u=yield Ve(p);return Je(u,p.status),u})}};var vn="2.10.0";var Ie={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},gn={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},bn=vn;var $="isdk_session",Te=`${$}-candidate_id`,ct=`${$}-consent`;var He="RFC3986",Xe={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:e=>String(e)},pt="RFC1738";var ft=Array.isArray,V=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var We=1024,yt=(e,t,n,r,s)=>{if(e.length===0)return e;let o=e;if(typeof e=="symbol"?o=Symbol.prototype.toString.call(e):typeof e!="string"&&(o=String(e)),n==="iso-8859-1")return escape(o).replace(/%u[0-9a-f]{4}/gi,function(p){return"%26%23"+parseInt(p.slice(2),16)+"%3B"});let a="";for(let p=0;p<o.length;p+=We){let u=o.length>=We?o.slice(p,p+We):o,f=[];for(let d=0;d<u.length;++d){let y=u.charCodeAt(d);if(y===45||y===46||y===95||y===126||y>=48&&y<=57||y>=65&&y<=90||y>=97&&y<=122||s===pt&&(y===40||y===41)){f[f.length]=u.charAt(d);continue}if(y<128){f[f.length]=V[y];continue}if(y<2048){f[f.length]=V[192|y>>6]+V[128|y&63];continue}if(y<55296||y>=57344){f[f.length]=V[224|y>>12]+V[128|y>>6&63]+V[128|y&63];continue}d+=1,y=65536+((y&1023)<<10|u.charCodeAt(d)&1023),f[f.length]=V[240|y>>18]+V[128|y>>12&63]+V[128|y>>6&63]+V[128|y&63]}a+=f.join("")}return a};function mt(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function kn(e,t){if(ft(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var Er=Array.isArray;var dt=Object.prototype.hasOwnProperty,_n={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},J=Array.isArray,ht=Array.prototype.push,xn=function(e,t){ht.apply(e,J(t)?t:[t])},vt=Date.prototype.toISOString,R={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:yt,encodeValuesOnly:!1,format:He,formatter:Xe[He],indices:!1,serializeDate(e){return vt.call(e)},skipNulls:!1,strictNullHandling:!1};function gt(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var Ke={};function wn(e,t,n,r,s,o,a,p,u,f,d,y,E,l,k,T,x,C){let h=e,Q=C,P=0,oe=!1;for(;(Q=Q.get(Ke))!==void 0&&!oe;){let D=Q.get(e);if(P+=1,typeof D!="undefined"){if(D===P)throw new RangeError("Cyclic object value");oe=!0}typeof Q.get(Ke)=="undefined"&&(P=0)}if(typeof f=="function"?h=f(t,h):h instanceof Date?h=E==null?void 0:E(h):n==="comma"&&J(h)&&(h=kn(h,function(D){return D instanceof Date?E==null?void 0:E(D):D})),h===null){if(o)return u&&!T?u(t,R.encoder,x,"key",l):t;h=""}if(gt(h)||mt(h)){if(u){let D=T?t:u(t,R.encoder,x,"key",l);return[(k==null?void 0:k(D))+"="+(k==null?void 0:k(u(h,R.encoder,x,"value",l)))]}return[(k==null?void 0:k(t))+"="+(k==null?void 0:k(String(h)))]}let ue=[];if(typeof h=="undefined")return ue;let ee;if(n==="comma"&&J(h))T&&u&&(h=kn(h,u)),ee=[{value:h.length>0?h.join(",")||null:void 0}];else if(J(f))ee=f;else{let D=Object.keys(h);ee=d?D.sort(d):D}let S=p?String(t).replace(/\./g,"%2E"):String(t),z=r&&J(h)&&h.length===1?S+"[]":S;if(s&&J(h)&&h.length===0)return z+"[]";for(let D=0;D<ee.length;++D){let U=ee[D],ye=typeof U=="object"&&typeof U.value!="undefined"?U.value:h[U];if(a&&ye===null)continue;let X=y&&p?U.replace(/\./g,"%2E"):U,ne=J(h)?typeof n=="function"?n(z,X):z:z+(y?"."+X:"["+X+"]");C.set(e,P);let yn=new WeakMap;yn.set(Ke,C),xn(ue,wn(ye,ne,n,r,s,o,a,p,n==="comma"&&T&&J(h)?null:u,f,d,y,E,l,k,T,x,yn))}return ue}function bt(e=R){if(typeof e.allowEmptyArrays!="undefined"&&typeof e.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof e.encodeDotInKeys!="undefined"&&typeof e.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(e.encoder!==null&&typeof e.encoder!="undefined"&&typeof e.encoder!="function")throw new TypeError("Encoder has to be a function.");let t=e.charset||R.charset;if(typeof e.charset!="undefined"&&e.charset!=="utf-8"&&e.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let n=He;if(typeof e.format!="undefined"){if(!dt.call(Xe,e.format))throw new TypeError("Unknown format option provided.");n=e.format}let r=Xe[n],s=R.filter;(typeof e.filter=="function"||J(e.filter))&&(s=e.filter);let o;if(e.arrayFormat&&e.arrayFormat in _n?o=e.arrayFormat:"indices"in e?o=e.indices?"indices":"repeat":o=R.arrayFormat,"commaRoundTrip"in e&&typeof e.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");let a=typeof e.allowDots=="undefined"?e.encodeDotInKeys?!0:R.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:R.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:R.allowEmptyArrays,arrayFormat:o,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:R.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter=="undefined"?R.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:R.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:R.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:R.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:R.encodeValuesOnly,filter:s,format:n,formatter:r,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:R.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:R.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:R.strictNullHandling}}function En(e,t={}){let n=e,r=bt(t),s,o;typeof r.filter=="function"?(o=r.filter,n=o("",n)):J(r.filter)&&(o=r.filter,s=o);let a=[];if(typeof n!="object"||n===null)return"";let p=_n[r.arrayFormat],u=p==="comma"&&r.commaRoundTrip;s||(s=Object.keys(n)),r.sort&&s.sort(r.sort);let f=new WeakMap;for(let E=0;E<s.length;++E){let l=s[E];r.skipNulls&&n[l]===null||xn(a,wn(n[l],l,p,u,r.allowEmptyArrays,r.strictNullHandling,r.skipNulls,r.encodeDotInKeys,r.encode?r.encoder:null,r.filter,r.sort,r.allowDots,r.serializeDate,r.format,r.formatter,r.encodeValuesOnly,r.charset,f))}let d=a.join(r.delimiter),y=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?y+="utf8=%26%2310003%3B&":y+="utf8=%E2%9C%93&"),d.length>0?y+d:""}function $e(e,t,n){let r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Async schema");if(r.issues)throw new Z(r.issues,n);return r.value}function kt(e,t,n){try{return{success:!0,output:$e(e,t,n)}}catch(r){if(r instanceof Z)return{success:!1,issues:r.issues,source:r.source};throw r}}var ve=class{constructor(t){if(this.baseUrl=Ie[t.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),t.apiKey.type==="secret"){if(typeof window!="undefined")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",t.apiKey.key)}else this.headers.set("x-publishable-key",t.apiKey.key);this.logger=t.logger,this._environment=t.environment}get environment(){return this._environment}getFetchParams(t,n){var u;let r=(u=n.validateIn)!=null?u:!0,{searchParams:s,body:o}=r?Sn(t,n):n,a=new URL(this.baseUrl),p=t.pathname;if("params"in n&&n.params)for(let[f,d]of Object.entries(n.params))p=p.replace(`:${f}`,String(d));return a.pathname=p,t.schema.searchParams&&(a.search=En(s)),[a.toString(),j({method:t.method,body:o?JSON.stringify(o):void 0,headers:this.headers,signal:n.signal},n.keepalive&&{keepalive:!0})]}parseResponse(t,n){return O(this,null,function*(){var a;let r=yield Ve(n.response);if(Je(r,n.response.status),!((a=n.validateOut)!=null?a:!0))return r;let o=kt(t.schema.response,r,"response");if(!o.success)throw new Z(o.issues,o.source);return o.output})}request(t,n){return O(this,null,function*(){try{let r=this.getFetchParams(t,n),s=yield fetch(...r);return yield this.parseResponse(t,{response:s,validateOut:n.validateOut})}catch(r){throw r instanceof Z?this.logger.error(r.message,r.issues):this.logger.error(r),r}})}};function re(){return{"~standard":{vendor:"inploi",version:1,validate:e=>({value:e})}}}function Sn(e,t){let n={searchParams:void 0,body:void 0,validateIn:!1};return e.schema.searchParams&&(n.searchParams=$e(e.schema.searchParams,"searchParams"in t?t.searchParams:{})),e.schema.body&&(n.body=$e(e.schema.body,"body"in t?t.body:{})),n}var W,_t={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function Tn(e){var t,n,r;return!e&&!W?_t:{lang:(t=e==null?void 0:e.lang)!=null?t:W==null?void 0:W.lang,message:e==null?void 0:e.message,abortEarly:(n=e==null?void 0:e.abortEarly)!=null?n:W==null?void 0:W.abortEarly,abortPipeEarly:(r=e==null?void 0:e.abortPipeEarly)!=null?r:W==null?void 0:W.abortPipeEarly}}var Ye;function xt(e){return Ye==null?void 0:Ye.get(e)}var Ze;function wt(e){return Ze==null?void 0:Ze.get(e)}var Qe;function Et(e,t){var n;return(n=Qe==null?void 0:Qe.get(e))==null?void 0:n.get(t)}function ie(e){var n,r,s;let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(s=e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))!=null?s:"null":t}function I(e,t,n,r,s){var y,E,l,k,T,x,C,h;let o=s&&"input"in s?s.input:n.value,a=(E=(y=s==null?void 0:s.expected)!=null?y:e.expects)!=null?E:null,p=(l=s==null?void 0:s.received)!=null?l:ie(o),u={kind:e.kind,type:e.type,input:o,expected:a,received:p,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${p}`,requirement:e.requirement,path:s==null?void 0:s.path,issues:s==null?void 0:s.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},f=e.kind==="schema",d=(h=(C=(x=(T=(k=s==null?void 0:s.message)!=null?k:e.message)!=null?T:Et(e.reference,u.lang))!=null?x:f?wt(u.lang):null)!=null?C:r.message)!=null?h:xt(u.lang);d!==void 0&&(u.message=typeof d=="function"?d(u):d),f&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}var An=new WeakMap;function N(e){let t=An.get(e);return t||(t={version:1,vendor:"valibot",validate(n){return e["~run"]({value:n},Tn())}},An.set(e,t)),t}function St(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function en(e,t){var r;let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:(r=n[0])!=null?r:"never"}var At=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu,jr=new RegExp("^(?:[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|(?![\\p{Emoji_Modifier_Base}\\u{1F1E6}-\\u{1F1FF}])\\p{Emoji_Presentation}))*)+$","u");function nn(e,t){return{kind:"validation",type:"check",reference:nn,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&I(this,"input",n,r),n}}}function tn(e){return{kind:"validation",type:"email",reference:tn,expects:null,async:!1,requirement:At,message:e,"~run"(t,n){return t.typed&&!this.requirement.test(t.value)&&I(this,"email",t,n),t}}}function le(e){return{kind:"validation",type:"integer",reference:le,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&I(this,"integer",t,n),t}}}function Pe(e,t){return{kind:"validation",type:"max_length",reference:Pe,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(n,r){return n.typed&&n.value.length>this.requirement&&I(this,"length",n,r,{received:`${n.value.length}`}),n}}}function rn(e,t){return{kind:"validation",type:"max_value",reference:rn,async:!1,expects:`<=${e instanceof Date?e.toJSON():ie(e)}`,requirement:e,message:t,"~run"(n,r){return n.typed&&!(n.value<=this.requirement)&&I(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():ie(n.value)}),n}}}function L(e,t){return{kind:"validation",type:"min_length",reference:L,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,r){return n.typed&&n.value.length<this.requirement&&I(this,"length",n,r,{received:`${n.value.length}`}),n}}}function ce(e,t){return{kind:"validation",type:"min_value",reference:ce,async:!1,expects:`>=${e instanceof Date?e.toJSON():ie(e)}`,requirement:e,message:t,"~run"(n,r){return n.typed&&!(n.value>=this.requirement)&&I(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():ie(n.value)}),n}}}function Re(e){return{kind:"transformation",type:"transform",reference:Re,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function De(){return{kind:"transformation",type:"trim",reference:De,async:!1,"~run"(e){return e.value=e.value.trim(),e}}}var It={abortEarly:!0};function Tt(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function je(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function F(e,t){return{kind:"schema",type:"array",reference:F,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){var o;let s=n.value;if(Array.isArray(s)){n.typed=!0,n.value=[];for(let a=0;a<s.length;a++){let p=s[a],u=this.item["~run"]({value:p},r);if(u.issues){let f={type:"array",origin:"value",input:s,key:a,value:p};for(let d of u.issues)d.path?d.path.unshift(f):d.path=[f],(o=n.issues)==null||o.push(d);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else I(this,"type",n,r);return n}}}function ge(e){return{kind:"schema",type:"boolean",reference:ge,expects:"boolean",async:!1,message:e,get"~standard"(){return N(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:I(this,"type",t,n),t}}}function _(e,t){return{kind:"schema",type:"literal",reference:_,expects:ie(e),async:!1,literal:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:I(this,"type",n,r),n}}}function m(e,t){return{kind:"schema",type:"nullable",reference:m,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return N(this)},"~run"(n,r){return n.value===null&&(this.default!==void 0&&(n.value=je(this,n,r)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function v(e,t){return{kind:"schema",type:"nullish",reference:v,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return N(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=je(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function b(e){return{kind:"schema",type:"number",reference:b,expects:"number",async:!1,message:e,get"~standard"(){return N(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:I(this,"type",t,n),t}}}function c(e,t){return{kind:"schema",type:"object",reference:c,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){var o;let s=n.value;if(s&&typeof s=="object"){n.typed=!0,n.value={};for(let a in this.entries){let p=this.entries[a];if(a in s||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let u=a in s?s[a]:je(p),f=p["~run"]({value:u},r);if(f.issues){let d={type:"object",origin:"value",input:s,key:a,value:u};for(let y of f.issues)y.path?y.path.unshift(d):y.path=[d],(o=n.issues)==null||o.push(y);if(n.issues||(n.issues=f.issues),r.abortEarly){n.typed=!1;break}}f.typed||(n.typed=!1),n.value[a]=f.value}else if(p.fallback!==void 0)n.value[a]=Tt(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(I(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:s,key:a,value:s[a]}]}),r.abortEarly))break}}else I(this,"type",n,r);return n}}}function g(e,t){return{kind:"schema",type:"optional",reference:g,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return N(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=je(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function A(e,t){return{kind:"schema",type:"picklist",reference:A,expects:en(e.map(ie),"|"),async:!1,options:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){return this.options.includes(n.value)?n.typed=!0:I(this,"type",n,r),n}}}function K(e,t,n){return{kind:"schema",type:"record",reference:K,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return N(this)},"~run"(r,s){var a,p;let o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(let u in o)if(St(o,u)){let f=o[u],d=this.key["~run"]({value:u},s);if(d.issues){let E={type:"object",origin:"key",input:o,key:u,value:f};for(let l of d.issues)l.path=[E],(a=r.issues)==null||a.push(l);if(r.issues||(r.issues=d.issues),s.abortEarly){r.typed=!1;break}}let y=this.value["~run"]({value:f},s);if(y.issues){let E={type:"object",origin:"value",input:o,key:u,value:f};for(let l of y.issues)l.path?l.path.unshift(E):l.path=[E],(p=r.issues)==null||p.push(l);if(r.issues||(r.issues=y.issues),s.abortEarly){r.typed=!1;break}}(!d.typed||!y.typed)&&(r.typed=!1),d.typed&&(r.value[d.value]=y.value)}}else I(this,"type",r,s);return r}}}function i(e){return{kind:"schema",type:"string",reference:i,expects:"string",async:!1,message:e,get"~standard"(){return N(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:I(this,"type",t,n),t}}}function In(e){let t;if(e)for(let n of e)if(t)for(let r of n.issues)t.push(r);else t=n.issues;return t}function be(e,t){return{kind:"schema",type:"union",reference:be,expects:en(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return N(this)},"~run"(n,r){let s,o,a;for(let p of this.options){let u=p["~run"]({value:n.value},r);if(u.typed)if(u.issues)o?o.push(u):o=[u];else{s=u;break}else a?a.push(u):a=[u]}if(s)return s;if(o){if(o.length===1)return o[0];I(this,"type",n,r,{issues:In(o)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];I(this,"type",n,r,{issues:In(a)})}return n}}}function sn(){return{kind:"schema",type:"unknown",reference:sn,expects:"unknown",async:!1,get"~standard"(){return N(this)},"~run"(e){return e.typed=!0,e}}}function pe(e,t,n){return{kind:"schema",type:"variant",reference:pe,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return N(this)},"~run"(r,s){let o=r.value;if(o&&typeof o=="object"){let a,p=0,u=this.key,f=[],d=(y,E)=>{for(let l of y.options){if(l.type==="variant")d(l,new Set(E).add(l.key));else{let k=!0,T=0;for(let x of E){let C=l.entries[x];if(x in o?C["~run"]({typed:!1,value:o[x]},It).issues:C.type!=="exact_optional"&&C.type!=="optional"&&C.type!=="nullish"){k=!1,u!==x&&(p<T||p===T&&x in o&&!(u in o))&&(p=T,u=x,f=[]),u===x&&f.push(l.entries[x].expects);break}T++}if(k){let x=l["~run"]({value:o},s);(!a||!a.typed&&x.typed)&&(a=x)}}if(a&&!a.issues)break}};if(d(this,new Set([this.key])),a)return a;I(this,"type",r,s,{input:o[u],expected:en(f,"|"),path:[{type:"object",origin:"value",input:o,key:u,value:o[u]}]})}else I(this,"type",r,s);return r}}}function w(...e){return G(j({},e[0]),{pipe:e,get"~standard"(){return N(this)},"~run"(t,n){for(let r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}})}function Oe(e,t,n){let r=e["~run"]({value:t},Tn(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var Pt=["agent","sdk","form","integration","migration"],Rt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Dt=["screening","cv_match","interview","overall"],jt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],Ot=["job","company"],Ct=["created_at","updated_at"],Nt=["asc","desc"],Lt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Ft=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],qt=["user","system","automation","integration","candidate"],Ce=A(Pt),H=A(Rt),M=w(i(),De(),L(1),Pe(100)),Ne=A(Dt),Pn=A(jt),Cr=A(Ot),Rn=A(Ct),Dn=A(Nt),ke=w(i(),De(),L(1),Pe(100)),Le=A(Lt),jn=A(Ft),On=A(qt);var q=pe("type",[c({type:_("user"),id:w(i(),L(1)),email:w(i(),L(1)),name:w(i(),L(1))}),c({type:_("system"),id:w(i(),L(1)),name:g(i())}),c({type:_("automation"),id:w(i(),L(1)),name:g(i())}),c({type:_("integration"),id:w(i(),L(1)),name:g(i())}),c({type:_("candidate"),id:w(i(),L(1)),email:g(i())})]);var Mt=c({total:b(),page:b(),perPage:b(),lastPage:b()});function Fe(e){return c({data:F(e),pagination:Mt})}var _e=c({id:i(),email:m(i()),firstName:m(i()),lastName:m(i()),phone:m(i()),source:m(Ce),identifiedAt:m(i()),createdAt:i(),updatedAt:i()});var fe=w(i(),L(1)),Cn=w(b(),le(),ce(1)),Y=K(i(),sn());var Nn=c({id:i(),applicationId:i(),status:Pn,scheduledAt:m(i()),completedAt:m(i()),meta:m(Y),createdAt:i(),updatedAt:i()});var on=c({score:b(),reason:i(),confidence:b()}),Ln=c({id:i(),candidateId:i(),jobId:b(),stage:M,stageGroup:H,stageEnteredAt:i(),rating:m(b()),disqualifiedAt:m(i()),disqualificationReason:m(ke),disqualificationNote:m(i()),source:Le,sourceDetail:m(i()),sessionId:m(b()),externalApplicationId:m(i()),meta:m(Y),context:m(Y),scoredAt:m(i()),createdAt:i(),updatedAt:i()}),Gt=c({id:i(),applicationId:i(),scoreType:Ne,score:m(b()),reason:m(i()),categories:m(K(i(),on)),scoredBy:m(i()),createdAt:i()}),qe=c(G(j({},Ln.entries),{candidate:m(_e),score:m(Gt),interview:m(Nn)})),Bt=c(G(j({},_e.entries),{applications:F(Ln)})),Fn=c({id:i(),applicationId:i(),action:jn,fromStage:m(M),fromStageGroup:m(H),toStage:m(M),toStageGroup:m(H),disqualificationReason:m(ke),disqualificationNote:m(i()),actorId:m(i()),actorType:On,actorEmail:m(i()),actorName:m(i()),meta:m(Y),schemaVersion:b(),createdAt:i()});var qn=c({anonymousId:fe,email:fe,firstName:v(i()),lastName:v(i()),phone:v(i()),source:v(Ce)}),Mn=c({candidateId:i(),isNew:ge()});var zt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],Ge=A(zt),Gn=w(i(),Re(e=>e.split(",").map(t=>t.trim()).filter(t=>t.length>0))),Ut=w(Gn,F(M)),Vt=w(Gn,F(H)),Bn=w(i(),Re(e=>e.split(",").map(t=>Number(t.trim())).filter(t=>Number.isInteger(t)&&t>0))),ti=c({stages:g(Ut),stage_groups:g(Vt),job_id:g(i()),job_ids:g(Bn),candidate_id:g(i()),is_disqualified:g(A(["true","false"])),created_from:g(i()),created_to:g(i()),updated_from:g(i()),updated_to:g(i()),entered_stage_from:g(i()),entered_stage_to:g(i()),from:g(i()),to:g(i()),q:g(i()),scored:g(A(["true","false"])),sort:g(Rn),order:g(Dn),page:g(i()),per_page:g(i())}),ri=w(c({candidateId:fe,jobId:Cn,meta:v(Y),sessionId:v(b()),externalApplicationId:v(i()),context:v(Y),source:v(Le),sourceDetail:v(i()),stage:v(M),stageGroup:v(H),actor:v(q)}),nn(e=>e.stage==null==(e.stageGroup==null),"stage and stageGroup must be supplied together")),zn=c({id:i(),stageGroup:i(),createdAt:i()}),ii=be([c({ok:_(!0),duplicate:_(!1),applicationId:i(),candidateId:i()}),c({ok:_(!0),duplicate:_(!0),existingApplication:zn})]),Un=c({isDuplicate:ge(),existingApplication:g(zn)}),si=c({applicationId:fe,scoreType:Ne,score:b(),reason:v(i()),categories:v(K(i(),on)),scoredBy:v(i()),actor:v(q)}),oi=c({scoreId:i()}),ui=Fe(qe);var ai=A(["already_in_target_stage","not_in_source_stage","disqualified"]),li=F(Fn),Me=c({stage:v(M),note:v(i())}),Jt=c({stage:v(M),startDate:v(i()),note:v(i())}),Wt=pe("action",[c({action:_("shortlist"),actor:q,meta:v(Me)}),c({action:_("move_to_interview"),actor:q,meta:v(Me)}),c({action:_("make_offer"),actor:q,meta:v(Me)}),c({action:_("hire"),actor:q,meta:v(Jt)}),c({action:_("withdraw"),actor:q,meta:v(Me)}),c({action:_("move_to_stage"),actor:q,meta:c({stage:M,stageGroup:H,note:v(i())})}),c({action:_("stage_transition"),actor:q,meta:c({toStage:M,toStageGroup:H,note:v(i())})}),c({action:_("disqualify"),actor:q,meta:c({reason:ke,note:v(i())})}),c({action:_("reinstate"),actor:q,meta:c({toStage:M,toStageGroup:H,note:v(i())})}),c({action:_("rate"),actor:q,meta:c({rating:m(w(b(),le(),ce(1),rn(5)))})})]),ci=c({applicationIds:w(F(i()),L(1)),body:Wt}),Vn=A(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),pi=pe("kind",[c({kind:_("updated"),action:Ge,application:qe}),c({kind:_("skipped"),action:Ge,applicationId:i(),reason:Vn})]),fi=c({updated:F(c({kind:_("updated"),action:Ge,application:qe})),skipped:F(c({kind:_("skipped"),action:Ge,applicationId:i(),reason:Vn})),failed:F(c({applicationId:i(),error:i()}))}),se=w(b(),le(),ce(0)),Kt=c({APPLIED:se,SHORTLISTED:se,INTERVIEWED:se,OFFERED:se,HIRED:se,REJECTED:se,WITHDRAWN:se}),yi=c({job_ids:Bn}),mi=c({counts:K(i(),Kt)});var bi=Fe(_e);var _i=c({avg_score:m(b()),p90_score:m(b()),p85_score:m(b()),p80_score:m(b()),total_scores:b(),total_shortlists:b()});var un=({environment:e,publishableKey:t,logger:n})=>{let r=gn[e];return{checkDuplicate(o){return O(this,null,function*(){try{let a=new URLSearchParams({email:o.email,scope:o.scope});o.scope==="job"&&o.jobId!=null&&a.set("job_id",String(o.jobId));let p=yield fetch(`${r}/applications/check-duplicate?${a}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":t}});if(!p.ok)return n.error(`[TalentBankClient] checkDuplicate failed with status ${p.status}`),{isDuplicate:!1};let u=yield p.json(),f=Oe(Un,u);return f.success?f.output:(n.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(a){return n.error("[TalentBankClient] checkDuplicate failed:",a),{isDuplicate:!1}}})},identify(o){return O(this,null,function*(){var a;try{if(!o.anonymousId)return n.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let p={email:o.email,firstName:o.firstName,lastName:o.lastName,phone:o.phone,anonymousId:o.anonymousId,source:(a=o.source)!=null?a:"sdk"},u=Oe(qn,p);if(!u.success)return n.error("[TalentBankClient] identify received invalid input"),null;let f=yield fetch(`${r}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":t},body:JSON.stringify(u.output)});if(!f.ok)return n.error(`[TalentBankClient] identify failed with status ${f.status}`),null;let d=Oe(Mn,yield f.json());return d.success?d.output:(n.error("[TalentBankClient] identify returned an invalid response"),null)}catch(p){return n.error("[TalentBankClient] identify failed:",p),null}})}}};var xe=()=>typeof crypto!="undefined"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16));function an(e){if(typeof document!="undefined"){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",e,{once:!0});return}Promise.resolve().then(e)}}var Jn=["DAILY","WEEKLY","MONTHLY"],Ht=K(i(),be([i(),F(i()),c({type:_("provided"),lat:b(),lng:b(),radius:b(),unit:g(A(["miles","km"])),label:g(i())})])),Vi={pathname:"/job/:id",method:"GET",schema:{response:c({id:b(),external_id:v(i()),city:v(i()),town:v(i()),category:v(i())})}};var Xt={pathname:"/search/save",method:"POST",schema:{response:re(),body:c({contact:c({email:w(g(i()),i(),tn()),first_name:g(i()),last_name:g(i())}),alerts:w(g(i()),i(),A(Jn)),filters:Ht})}};Wn();var Hn=7*24*60*60*1e3,Xn=e=>{let t=new Date;return t.setTime(t.getTime()+Hn),`${$}=${e};expires=${t.toUTCString()};path=/`},$t=(e,t)=>{let n=e.get("session_id");if(t||n)return n;let r=sessionStorage.getItem(`${$}-session_id`);return typeof r=="string"?r:null},Yt=()=>{if(typeof window=="undefined")return null;try{let e=window.localStorage.getItem(Te);return typeof e=="string"&&e!==""?e:null}catch(e){return null}},Zt=e=>{if(typeof window!="undefined")try{e?window.localStorage.setItem(Te,e):window.localStorage.removeItem(Te)}catch(t){}},Qt=new RegExp(`(?:^|;\\s*)${$}=([^;]+)`),we=e=>{var n,r;let t=e?e.headers.get("cookie"):document.cookie;return t&&(r=(n=Qt.exec(t))==null?void 0:n[1])!=null?r:null},$n=()=>{var e;try{let t=JSON.parse((e=window.localStorage.getItem($))!=null?e:"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(t){return null}},Kn=()=>{var e;return(e=we())!=null?e:new URL(location.href).searchParams.get("anonymous_id")?null:$n()},er=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",Yn=e=>{if(document.cookie=Xn(e)+er(),we()!==e)try{window.localStorage.setItem($,JSON.stringify({id:e,expires:Date.now()+Hn}))}catch(t){}},fn=e=>{var r,s,o;let t=e?e.url:location.href,{searchParams:n}=new URL(t);return{anonymous_id:e?(r=we(e))!=null?r:n.get("anonymous_id"):(o=(s=we())!=null?s:n.get("anonymous_id"))!=null?o:$n(),session_id:$t(n,typeof window=="undefined")}},cn=()=>{if(typeof window=="undefined")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let e=fn().anonymous_id;if(e)return e;let t=xe(),n=fn().anonymous_id;return n||(Yn(t),t)},nr=e=>typeof e!="object"||e===null?null:{anonymous_id:"anonymous_id"in e&&typeof e.anonymous_id=="string"?e.anonymous_id:null,session_id:"session_id"in e&&typeof e.session_id=="string"?e.session_id:null},tr=e=>e==="about:client"?"":e,rr={pathname:"/log",method:"POST",schema:{response:re(),body:re()}},Zn=({rpcClient:e,logger:t,onEvent:n,talentBank:r,persistence:s="device"})=>{let o=null,a=null,p=0,u=0,f=l=>s==="none"?{anonymous_id:null,session_id:l?null:o}:fn(l),d=(l,k)=>O(void 0,null,function*(){var T,x;try{let C={library:{name:"inploi-sdk",version:bn},page:k},h=f(l.request);s==="device"&&l.event==="IDENTIFY"&&!h.anonymous_id&&!l.request&&typeof window!="undefined"&&(h=G(j({},h),{anonymous_id:cn()}));let Q=s==="none"?null:Yt();if(l.event==="IDENTIFY"&&r&&(h.anonymous_id||s==="none")){let X=l.properties,ne=yield r.identify({email:(T=X.email)!=null?T:X.identifier,firstName:X.first_name,lastName:X.last_name,phone:X.phone_number,anonymousId:(x=h.anonymous_id)!=null?x:xe(),source:"sdk"});ne!=null&&ne.candidateId&&s==="device"&&(Q=ne.candidateId,Zt(ne.candidateId))}let P={anonymous_id:h.anonymous_id,session_id:h.session_id,candidate_id:Q,event:l.event,sent_at:new Date().toISOString(),context:C,properties:l.properties,custom_properties:l.customProperties},oe=s==="none"?null:l.request?we(l.request):Kn(),ue=++p,ee=yield e.request(rr,j({body:P},l.keepalive&&{keepalive:!0})),S=nr(ee);if(s==="none")return!l.request&&(S!=null&&S.session_id)&&ue>u&&(u=ue,S.session_id!==P.session_id&&(o=S.session_id)),P.session_id=l.request?(S==null?void 0:S.session_id)||null:o,n==null||n(P),{success:!0,data:P};let z=l.request?oe:Kn(),D=z!==null&&z!==oe,U=z!=null?z:oe,ye=!D&&(!U||!(S!=null&&S.anonymous_id)||U===S.anonymous_id);return ye?(S!=null&&S.anonymous_id&&(P.anonymous_id=S.anonymous_id),S!=null&&S.session_id&&(P.session_id=S.session_id)):P.anonymous_id=U,!l.request&&typeof window!="undefined"&&P.anonymous_id&&(ye&&P.session_id&&sessionStorage.setItem(`${$}-session_id`,P.session_id.toString()),Yn(P.anonymous_id)),n==null||n(P),{success:!0,data:P}}catch(C){return t.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:C}}}),y=Promise.resolve();return{log:l=>O(void 0,null,function*(){Be(l.request||typeof window!="undefined","Cannot log on the server without a request. Please pass a request to `log`.");let k="request"in l&&l.request?{href:l.request.url,referrer:tr(l.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(s==="none"&&l.event==="FLOW_NODE"&&l.properties&&"trigger"in l.properties&&(l.properties.trigger==="pagehide"||l.properties.trigger==="hidden")&&(l=G(j({},l),{keepalive:!0})),s==="device"||l.request||o||l.keepalive)return d(l,k);let T=()=>d(l,k),x=y.then(T,T);return y=x,x}),getHeaders:l=>{let k=new Headers;return s==="none"||!(l!=null&&l.anonymous_id)||k.append("Set-Cookie",Xn(l.anonymous_id)),k},getSessionInfo:f,getOrCreateAnonymousId:()=>s==="none"?a!=null?a:a=xe():cn()}};function pn({publishableKey:e,env:t,logger:n=ze,onEvent:r,persistence:s}){let o=hn({baseUrl:Ie[t],publishableKey:e}),a=n===!1?Ue:n,p=new ve({environment:t,apiKey:{type:"publishable",key:e},logger:a}),u=un({environment:t,publishableKey:e,logger:a}),f=Zn({rpcClient:p,logger:a,onEvent:r,talentBank:u,persistence:s});return{register:y=>y({logger:a,apiClient:o,analytics:f,rpcClient:p,publishableKey:e,env:t}),analytics:f,apiClient:o}}typeof window.inploi!="object"&&(window.inploi={});window.process=window.process||{};window.process.env=window.process.env||{};window.process.env.NODE_ENV="production";window.inploi.initialiseSdk=pn;window.inploi.ready=an;})();
|
package/dist/index.d.mts
CHANGED
|
@@ -341,6 +341,13 @@ type AnalyticsService = {
|
|
|
341
341
|
/** From a log payload data, generate headers to use in server environments to update the anonymous_id */
|
|
342
342
|
getHeaders: (payload?: TrackPayload) => Headers;
|
|
343
343
|
getSessionInfo: typeof getSessionInfo;
|
|
344
|
+
/**
|
|
345
|
+
* The visitor id for agent conversations. With device persistence it is `getOrCreateAnonymousId`'s stored id; with
|
|
346
|
+
* none it lives in this instance only, so a visitor who refused storage keeps one id for the page and nothing is stored.
|
|
347
|
+
* Optional: plugins run beside the host's own SDK, and a host before 2.10 hands analytics without it. Plugins call
|
|
348
|
+
* `analytics.getOrCreateAnonymousId?.() ?? getOrCreateAnonymousId()`, so such a host keeps the stored id until it updates.
|
|
349
|
+
*/
|
|
350
|
+
getOrCreateAnonymousId?: () => string;
|
|
344
351
|
};
|
|
345
352
|
declare const getSessionInfo: (request?: Request) => {
|
|
346
353
|
anonymous_id: string | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -341,6 +341,13 @@ type AnalyticsService = {
|
|
|
341
341
|
/** From a log payload data, generate headers to use in server environments to update the anonymous_id */
|
|
342
342
|
getHeaders: (payload?: TrackPayload) => Headers;
|
|
343
343
|
getSessionInfo: typeof getSessionInfo;
|
|
344
|
+
/**
|
|
345
|
+
* The visitor id for agent conversations. With device persistence it is `getOrCreateAnonymousId`'s stored id; with
|
|
346
|
+
* none it lives in this instance only, so a visitor who refused storage keeps one id for the page and nothing is stored.
|
|
347
|
+
* Optional: plugins run beside the host's own SDK, and a host before 2.10 hands analytics without it. Plugins call
|
|
348
|
+
* `analytics.getOrCreateAnonymousId?.() ?? getOrCreateAnonymousId()`, so such a host keeps the stored id until it updates.
|
|
349
|
+
*/
|
|
350
|
+
getOrCreateAnonymousId?: () => string;
|
|
344
351
|
};
|
|
345
352
|
declare const getSessionInfo: (request?: Request) => {
|
|
346
353
|
anonymous_id: string | null;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Ct=Object.create;var X=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var Dt=Object.getPrototypeOf,Nt=Object.prototype.hasOwnProperty;var jt=(t,n)=>()=>(t&&(n=t(t=0)),n);var Me=(t,n)=>{for(var r in n)X(t,r,{get:n[r],enumerable:!0})},Ge=(t,n,r,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of Ot(n))!Nt.call(t,a)&&a!==r&&X(t,a,{get:()=>n[a],enumerable:!(o=Lt(n,a))||o.enumerable});return t};var x=(t,n,r)=>(r=t!=null?Ct(Dt(t)):{},Ge(n||!t||!t.__esModule?X(r,"default",{value:t,enumerable:!0}):r,t)),Ft=t=>Ge(X({},"__esModule",{value:!0}),t);var Et={};Me(Et,{jobCountryCodes:()=>De});var kt,Sn,M,_n,Tn,De,Ne=jt(()=>{"use strict";kt={uk:"gb","great britain":"gb",england:"gb",scotland:"gb",wales:"gb","northern ireland":"gb",lincolnshire:"gb",surrey:"gb","republic of ireland":"ie",eire:"ie","hong kong sar":"hk","united states of america":"us",turkey:"tr","czech republic":"cz",burma:"mm",kosovo:"xk",xk:"xk"},Sn=`adand aeare afafg agatg aiaia alalb amarm aoago aqata ararg asasm ataut auaus awabw axala azaze babih bbbrb bdbgd bebel
|
|
2
2
|
bfbfa bgbgr bhbhr bibdi bjben blblm bmbmu bnbrn bobol bqbes brbra bsbhs btbtn bvbvt bwbwa byblr bzblz cacan cccck cdcod
|
|
3
3
|
cfcaf cgcog chche ciciv ckcok clchl cmcmr cnchn cocol crcri cucub cvcpv cwcuw cxcxr cycyp czcze dedeu djdji dkdnk dmdma
|
|
4
4
|
dodom dzdza ececu eeest egegy ehesh ereri esesp eteth fifin fjfji fkflk fmfsm fofro frfra gagab gbgbr gdgrd gegeo gfguf
|
|
@@ -10,5 +10,5 @@ ncncl nener nfnfk ngnga ninic nlnld nonor npnpl nrnru nuniu nznzl omomn papan pe
|
|
|
10
10
|
pnpcn prpri pspse ptprt pwplw pypry qaqat rereu rorou rssrb rurus rwrwa sasau sbslb scsyc sdsdn seswe sgsgp shshn sisvn
|
|
11
11
|
sjsjm sksvk slsle smsmr snsen sosom srsur ssssd ststp svslv sxsxm sysyr szswz tctca tdtcd tfatf tgtgo ththa tjtjk tktkl
|
|
12
12
|
tltls tmtkm tntun toton trtur tttto tvtuv twtwn tztza uaukr uguga umumi ususa uyury uzuzb vavat vcvct veven vgvgb vivir
|
|
13
|
-
vnvnm vuvut wfwlf wswsm yeyem ytmyt zazaf zmzmb zwzwe`,Sn=()=>{if(M)return M;M=new Map;let t=new Intl.DisplayNames(["en"],{type:"region",fallback:"none"});for(let n of bn.split(/\s+/)){let r=n.slice(0,2),o=t.of(r.toUpperCase());o&&M.set(o.toLowerCase(),r),M.set(r,r),M.set(n.slice(2),r)}return M},_n=t=>{let n=t.trim().toLowerCase();if(Object.prototype.hasOwnProperty.call(wt,n))return wt[n];let r=/^[a-z]{2}-[a-z0-9]{1,3}$/.test(n)?n.slice(0,2):n;return Sn().get(r)},De=t=>[...new Set(t.flatMap(r=>_n(r)??[]))].sort()});var xn={};Ue(xn,{ApiError:()=>B,InploiRpcClient:()=>$,JOB_ALERT_FREQUENCIES:()=>Ce,NotFoundError:()=>j,ParsingError:()=>q,SchemaValidationError:()=>P,SdkError:()=>ke,UnauthorisedError:()=>F,addressSearchCountry:()=>Et,blendAddressSuggestions:()=>je,consentStorageKey:()=>fe,createPlugin:()=>Ge,createTalentBankClient:()=>ge,endpoint:()=>Y,generateUUID:()=>W,getConsentAcceptance:()=>St,getJobCountries:()=>Ne,getOrCreateAnonymousId:()=>Ie,hashConsentConfig:()=>ve,initialiseSdk:()=>bt,inploiBrandedLogger:()=>ne,isApiErrorWithData:()=>Ve,isSdkError:()=>ze,jobCountryCodes:()=>De,noLogging:()=>re,ready:()=>Tt,saveClosedRoleJobAlerts:()=>xt,saveSearchEndpoint:()=>Le,searchAddressSuggestions:()=>It,setConsentAcceptance:()=>_t,typed:()=>D,validateEndpointInputs:()=>Pe});module.exports=jt(xn);var ee="%c[inploi SDK]",te="color: #65BC67; font-weight: bold;",ne={warn:(...t)=>console.warn(ee,te,...t),error:(...t)=>console.error(ee,te,...t),info:(...t)=>console.info(ee,te,...t),log:(...t)=>console.log(ee,te,...t)},re={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Ge=t=>t;function Te(t,n){if(!t)throw new Error(n)}function V(t,n){return n in t}var Dn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var Ft="Unauthenticated",Bt="This action is unauthorized.",N=class extends Error{constructor(r,o){super(r);this.status=o,this.name="ErrorWithStatus"}},j=class extends N{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},F=class extends N{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},P=class extends N{constructor(r,o){let a=o?` in ${o}`:"";super(`Schema validation failed${a}`);this.issues=r;this.source=o;this.name="SchemaValidationError",this.status=400}},B=class extends N{constructor(r,o,a){super(r);this.data=a;this.name="ApiError",this.status=o??500}},Ve=t=>t instanceof B&&t.data!==void 0,q=class extends N{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 xe(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new q(t);return t.json().catch(()=>{throw new q(t)})}var qt=["message","error","errors","exception","exceptions"];function Ut(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of qt)if(V(t,r)){let o=t[r];typeof o=="string"&&n.push(o),Array.isArray(o)&&o.every(a=>typeof a=="string")&&n.push(...o)}V(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&V(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&V(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 we(t,n){if(n>=300){let r=Ut(t);throw n===404?new j(r):r===Ft?new F("You are not authenticated.",n):r===Bt?new F(r,n):new B(r,n,t)}}var $e=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,o={})=>{let a={...o,headers:{...o.headers,...n}},l=await fetch(`${t.baseUrl}${r}`,a);if(l.status===404)throw new j;let d=await xe(l);return we(d,l.status),d}}},ke={NotFound:j,Unauthorised:F,SchemaValidation:P,Api:B,JsonParsing:q};function ze(t){return Object.values(ke).some(n=>t instanceof n)}var Je="2.9.1";var oe={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},He={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},We=Je;var L="isdk_session",ie=`${L}-candidate_id`,Ke=`${L}-consent`;var W=()=>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 Qe=7*24*60*60*1e3,Ze=t=>{let n=new Date;return n.setTime(n.getTime()+Qe),`${L}=${t};expires=${n.toUTCString()};path=/`},Gt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let o=sessionStorage.getItem(`${L}-session_id`);return typeof o=="string"?o:null},Vt=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(ie);return typeof t=="string"&&t!==""?t:null}catch{return null}},$t=t=>{if(!(typeof window>"u"))try{t?window.localStorage.setItem(ie,t):window.localStorage.removeItem(ie)}catch{}},zt=new RegExp(`(?:^|;\\s*)${L}=([^;]+)`),K=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?zt.exec(n)?.[1]??null:null},Xe=()=>{try{let t=JSON.parse(window.localStorage.getItem(L)??"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}},Ye=()=>K()??(new URL(location.href).searchParams.get("anonymous_id")?null:Xe()),Jt=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",et=t=>{if(document.cookie=Ze(t)+Jt(),K()!==t)try{window.localStorage.setItem(L,JSON.stringify({id:t,expires:Date.now()+Qe}))}catch{}},Ee=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?K(t)??r.get("anonymous_id"):K()??r.get("anonymous_id")??Xe(),session_id:Gt(r,typeof window>"u")}},Ie=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=Ee().anonymous_id;if(t)return t;let n=W(),r=Ee().anonymous_id;return r||(et(n),n)},Ht=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},Wt=t=>t==="about:client"?"":t,Kt={pathname:"/log",method:"POST",schema:{response:D(),body:D()}},tt=({rpcClient:t,logger:n,onEvent:r,talentBank:o,persistence:a="device"})=>{let l=null,d=0,u=0,v=p=>a==="none"?{anonymous_id:null,session_id:p?null:l}:Ee(p),E=async(p,y)=>{try{let f={library:{name:"inploi-sdk",version:We},page:y},I=v(p.request);a==="device"&&p.event==="IDENTIFY"&&!I.anonymous_id&&!p.request&&typeof window<"u"&&(I={...I,anonymous_id:Ie()});let Fe=a==="none"?null:Vt();if(p.event==="IDENTIFY"&&o&&(I.anonymous_id||a==="none")){let H=p.properties,_e=await o.identify({email:H.email??H.identifier,firstName:H.first_name,lastName:H.last_name,phone:H.phone_number,anonymousId:I.anonymous_id??W(),source:"sdk"});_e?.candidateId&&a==="device"&&(Fe=_e.candidateId,$t(_e.candidateId))}let b={anonymous_id:I.anonymous_id,session_id:I.session_id,candidate_id:Fe,event:p.event,sent_at:new Date().toISOString(),context:f,properties:p.properties,custom_properties:p.customProperties},ye=a==="none"?null:p.request?K(p.request):Ye(),Be=++d,At=await t.request(Kt,{body:b,...p.keepalive&&{keepalive:!0}}),A=Ht(At);if(a==="none")return!p.request&&A?.session_id&&Be>u&&(u=Be,A.session_id!==b.session_id&&(l=A.session_id)),b.session_id=p.request?A?.session_id||null:l,r?.(b),{success:!0,data:b};let be=p.request?ye:Ye(),Pt=be!==null&&be!==ye,Se=be??ye,qe=!Pt&&(!Se||!A?.anonymous_id||Se===A.anonymous_id);return qe?(A?.anonymous_id&&(b.anonymous_id=A.anonymous_id),A?.session_id&&(b.session_id=A.session_id)):b.anonymous_id=Se,!p.request&&typeof window<"u"&&b.anonymous_id&&(qe&&b.session_id&&sessionStorage.setItem(`${L}-session_id`,b.session_id.toString()),et(b.anonymous_id)),r?.(b),{success:!0,data:b}}catch(f){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:f}}},G=Promise.resolve();return{log:async p=>{Te(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let y="request"in p&&p.request?{href:p.request.url,referrer:Wt(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(a==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0}),a==="device"||p.request||l||p.keepalive)return E(p,y);let f=()=>E(p,y),I=G.then(f,f);return G=I,I},getHeaders:p=>{let y=new Headers;return a==="none"||!p?.anonymous_id||y.append("Set-Cookie",Ze(p.anonymous_id)),y},getSessionInfo:v}};var nt=require("neoqs");function Ae(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 Yt(t,n,r){try{return{success:!0,output:Ae(t,n,r)}}catch(o){if(o instanceof P)return{success:!1,issues:o.issues,source:o.source};throw o}}var $=class{constructor(n){if(this.baseUrl=oe[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:a,body:l}=o?Pe(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[v,E]of Object.entries(r.params))u=u.replace(`:${v}`,String(E));return d.pathname=u,n.schema.searchParams&&(d.search=(0,nt.stringify)(a)),[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 o=await xe(r.response);if(we(o,r.response.status),!(r.validateOut??!0))return o;let l=Yt(n.schema.response,o,"response");if(!l.success)throw new P(l.issues,l.source);return l.output}async request(n,r){try{let o=this.getFetchParams(n,r),a=await fetch(...o);return await this.parseResponse(n,{response:a,validateOut:r.validateOut})}catch(o){throw o instanceof P?this.logger.error(o.message,o.issues):this.logger.error(o),o}}};function D(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function Y(t){return t}function Pe(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=Ae(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=Ae(t.schema.body,"body"in n?n.body:{})),r}var s=w(require("valibot"),1),Qt=["agent","sdk","form","integration","migration"],Zt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var Xt=["screening","cv_match","interview","overall"],en=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],tn=["job","company"],nn=["created_at","updated_at"],rn=["asc","desc"],on=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],sn=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],an=["user","system","automation","integration","candidate"],se=s.picklist(Qt),R=s.picklist(Zt),k=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ae=s.picklist(Xt),rt=s.picklist(en),Zn=s.picklist(tn),ot=s.picklist(nn),it=s.picklist(rn),Q=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ce=s.picklist(on),st=s.picklist(sn),at=s.picklist(an);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())})]);var C=w(require("valibot"),1),cn=C.object({total:C.number(),page:C.number(),perPage:C.number(),lastPage:C.number()});function le(t){return C.object({data:C.array(t),pagination:cn})}var m=w(require("valibot"),1);var Z=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(se),identifiedAt:m.nullable(m.string()),createdAt:m.string(),updatedAt:m.string()});var i=w(require("valibot"),1);var g=w(require("valibot"),1),z=g.pipe(g.string(),g.minLength(1)),ct=g.pipe(g.number(),g.integer(),g.minValue(1)),O=g.record(g.string(),g.unknown());var T=w(require("valibot"),1);var lt=T.object({id:T.string(),applicationId:T.string(),status:rt,scheduledAt:T.nullable(T.string()),completedAt:T.nullable(T.string()),meta:T.nullable(O),createdAt:T.string(),updatedAt:T.string()});var Re=i.object({score:i.number(),reason:i.string(),confidence:i.number()}),pt=i.object({id:i.string(),candidateId:i.string(),jobId:i.number(),stage:k,stageGroup:R,stageEnteredAt:i.string(),rating:i.nullable(i.number()),disqualifiedAt:i.nullable(i.string()),disqualificationReason:i.nullable(Q),disqualificationNote:i.nullable(i.string()),source:ce,sourceDetail:i.nullable(i.string()),sessionId:i.nullable(i.number()),externalApplicationId:i.nullable(i.string()),meta:i.nullable(O),context:i.nullable(O),scoredAt:i.nullable(i.string()),createdAt:i.string(),updatedAt:i.string()}),ln=i.object({id:i.string(),applicationId:i.string(),scoreType:ae,score:i.nullable(i.number()),reason:i.nullable(i.string()),categories:i.nullable(i.record(i.string(),Re)),scoredBy:i.nullable(i.string()),createdAt:i.string()}),pe=i.object({...pt.entries,candidate:i.nullable(Z),score:i.nullable(ln),interview:i.nullable(lt)}),pn=i.object({...Z.entries,applications:i.array(pt)}),dt=i.object({id:i.string(),applicationId:i.string(),action:st,fromStage:i.nullable(k),fromStageGroup:i.nullable(R),toStage:i.nullable(k),toStageGroup:i.nullable(R),disqualificationReason:i.nullable(Q),disqualificationNote:i.nullable(i.string()),actorId:i.nullable(i.string()),actorType:at,actorEmail:i.nullable(i.string()),actorName:i.nullable(i.string()),meta:i.nullable(O),schemaVersion:i.number(),createdAt:i.string()});var h=w(require("valibot"),1);var ut=h.object({anonymousId:z,email:z,firstName:h.nullish(h.string()),lastName:h.nullish(h.string()),phone:h.nullish(h.string()),source:h.nullish(se)}),mt=h.object({candidateId:h.string(),isNew:h.boolean()});var e=w(require("valibot"),1);var dn=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],ue=e.picklist(dn),gt=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),un=e.pipe(gt,e.array(k)),mn=e.pipe(gt,e.array(R)),vt=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),br=e.object({stages:e.optional(un),stage_groups:e.optional(mn),job_id:e.optional(e.string()),job_ids:e.optional(vt),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(ot),order:e.optional(it),page:e.optional(e.string()),per_page:e.optional(e.string())}),Sr=e.pipe(e.object({candidateId:z,jobId:ct,meta:e.nullish(O),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(O),source:e.nullish(ce),sourceDetail:e.nullish(e.string()),stage:e.nullish(k),stageGroup:e.nullish(R),actor:e.nullish(_)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together")),ft=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),_r=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:ft})]),ht=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(ft)}),Tr=e.object({applicationId:z,scoreType:ae,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),Re)),scoredBy:e.nullish(e.string()),actor:e.nullish(_)}),xr=e.object({scoreId:e.string()}),wr=le(pe);var kr=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),Er=e.array(dt),de=e.object({stage:e.nullish(k),note:e.nullish(e.string())}),gn=e.object({stage:e.nullish(k),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),vn=e.variant("action",[e.object({action:e.literal("shortlist"),actor:_,meta:e.nullish(de)}),e.object({action:e.literal("move_to_interview"),actor:_,meta:e.nullish(de)}),e.object({action:e.literal("make_offer"),actor:_,meta:e.nullish(de)}),e.object({action:e.literal("hire"),actor:_,meta:e.nullish(gn)}),e.object({action:e.literal("withdraw"),actor:_,meta:e.nullish(de)}),e.object({action:e.literal("move_to_stage"),actor:_,meta:e.object({stage:k,stageGroup:R,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:_,meta:e.object({toStage:k,toStageGroup:R,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:k,toStageGroup:R,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)))})})]),Ir=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:vn}),yt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),Ar=e.variant("kind",[e.object({kind:e.literal("updated"),action:ue,application:pe}),e.object({kind:e.literal("skipped"),action:ue,applicationId:e.string(),reason:yt})]),Pr=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:ue,application:pe})),skipped:e.array(e.object({kind:e.literal("skipped"),action:ue,applicationId:e.string(),reason:yt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),U=e.pipe(e.number(),e.integer(),e.minValue(0)),fn=e.object({APPLIED:U,SHORTLISTED:U,INTERVIEWED:U,OFFERED:U,HIRED:U,REJECTED:U,WITHDRAWN:U}),Rr=e.object({job_ids:vt}),Cr=e.object({counts:e.record(e.string(),fn)});var jr=le(Z);var S=w(require("valibot"),1),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()});var me=w(require("valibot"));var ge=({environment:t,publishableKey:n,logger:r})=>{let o=He[t];return{async checkDuplicate(a){try{let l=new URLSearchParams({email:a.email,scope:a.scope});a.scope==="job"&&a.jobId!=null&&l.set("job_id",String(a.jobId));let d=await fetch(`${o}/applications/check-duplicate?${l}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":n}});if(!d.ok)return r.error(`[TalentBankClient] checkDuplicate failed with status ${d.status}`),{isDuplicate:!1};let u=await d.json(),v=me.safeParse(ht,u);return v.success?v.output:(r.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof u=="object"&&u!=null&&typeof u.isDuplicate=="boolean"?{isDuplicate:u.isDuplicate}:{isDuplicate:!1})}catch(l){return r.error("[TalentBankClient] checkDuplicate failed:",l),{isDuplicate:!1}}},async identify(a){try{if(!a.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let l={email:a.email,firstName:a.firstName,lastName:a.lastName,phone:a.phone,anonymousId:a.anonymousId,source:a.source??"sdk"},d=me.safeParse(ut,l);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 v=me.safeParse(mt,await u.json());return v.success?v.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(l){return r.error("[TalentBankClient] identify failed:",l),null}}}};function bt({publishableKey:t,env:n,logger:r=ne,onEvent:o,persistence:a}){let l=$e({baseUrl:oe[n],publishableKey:t}),d=r===!1?re:r,u=new $({environment:n,apiKey:{type:"publishable",key:t},logger:d}),v=ge({environment:n,publishableKey:t,logger:d}),E=tt({rpcClient:u,logger:d,onEvent:o,talentBank:v,persistence:a});return{register:J=>J({logger:d,apiClient:l,analytics:E,rpcClient:u,publishableKey:t,env:n}),analytics:E,apiClient:l}}function ve(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 fe(t,n){return`${Ke}:${t}:${n}`}function St(t,n){if(typeof window>"u")return!1;try{let r=fe(t,ve(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function _t(t,n){if(!(typeof window>"u"))try{let r=fe(t,ve(n));window.localStorage.setItem(r,"accepted")}catch{}}function Tt(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}var c=w(require("valibot"));var Ce=["DAILY","WEEKLY","MONTHLY"],hn=c.record(c.string(),c.union([c.string(),c.array(c.string()),c.object({type:c.literal("provided"),lat:c.number(),lng:c.number(),radius:c.number(),unit:c.optional(c.picklist(["miles","km"])),label:c.optional(c.string())})])),yn={pathname:"/job/:id",method:"GET",schema:{response:c.object({id:c.number(),external_id:c.nullish(c.string()),city:c.nullish(c.string()),town:c.nullish(c.string()),category:c.nullish(c.string())})}};async function xt(t,{contact:n,job:r}){let o={};if(r){let a=await t.request(yn,{params:{id:r.id}});if((r.id_type==="internal"?String(a.id):a.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let d of["city","town","category"]){let u=a[d]?.trim();u&&(o[d]=[u])}}await t.request(Le,{body:{contact:n,alerts:"WEEKLY",filters:o}})}var Le={pathname:"/search/save",method:"POST",schema:{response:D(),body:c.object({contact:c.object({email:c.pipe(c.optional(c.string()),c.string(),c.email()),first_name:c.optional(c.string()),last_name:c.optional(c.string())}),alerts:c.pipe(c.optional(c.string()),c.string(),c.picklist(Ce)),filters:hn})}};var x=w(require("valibot"));var Ne=async t=>{let n={method:"GET",pathname:"/search/filters",schema:{response:x.pipe(x.object({country:x.optional(x.array(x.object({value:x.string()})),[])}),x.transform(({country:r})=>r.map(({value:o})=>o))),searchParams:D()}};return t.request(n,{searchParams:{filters:{country:null}}})},he=new WeakMap,Et=t=>(he.has(t)||(he.set(t,void 0),Ne(t).then(async n=>{let{jobCountryCodes:r}=await Promise.resolve().then(()=>(Oe(),kt));he.set(t,r(n).join(",")||void 0)}).catch(()=>{})),he.get(t)),je=(t,n)=>{let r=new Set,o=[];for(let a=0;a<Math.max(t.length,n.length);a++)for(let l of[t[a],n[a]]){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),o.push(l),o.length===5))return o}return o},Tn=600,It=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let o=await t();return r?.throwIfAborted(),o}return new Promise((o,a)=>{let l,d,u,v=!1,E=()=>{v=!0,clearTimeout(u),r?.removeEventListener("abort",G)},G=()=>{E(),a(r?.reason)},J=()=>{E(),l?.status==="fulfilled"&&d?.status==="fulfilled"?o(je(l.value,d.value)):l?.status==="fulfilled"?o(l.value):d?.status==="fulfilled"?o(d.value):l?.status==="rejected"&&a(l.reason)},p=(y,f)=>{v||(y?l=f:d=f,l&&d?J():f.status==="fulfilled"&&f.value.length>0&&(u=setTimeout(J,Tn)))};r?.addEventListener("abort",G,{once:!0});for(let y of[!0,!1])t(y?n:void 0).then(f=>p(y,{status:"fulfilled",value:f}),f=>p(y,{status:"rejected",reason:f}))})};Oe();0&&(module.exports={ApiError,InploiRpcClient,JOB_ALERT_FREQUENCIES,NotFoundError,ParsingError,SchemaValidationError,SdkError,UnauthorisedError,addressSearchCountry,blendAddressSuggestions,consentStorageKey,createPlugin,createTalentBankClient,endpoint,generateUUID,getConsentAcceptance,getJobCountries,getOrCreateAnonymousId,hashConsentConfig,initialiseSdk,inploiBrandedLogger,isApiErrorWithData,isSdkError,jobCountryCodes,noLogging,ready,saveClosedRoleJobAlerts,saveSearchEndpoint,searchAddressSuggestions,setConsentAcceptance,typed,validateEndpointInputs});
|
|
13
|
+
vnvnm vuvut wfwlf wswsm yeyem ytmyt zazaf zmzmb zwzwe`,_n=()=>{if(M)return M;M=new Map;let t=new Intl.DisplayNames(["en"],{type:"region",fallback:"none"});for(let n of Sn.split(/\s+/)){let r=n.slice(0,2),o=t.of(r.toUpperCase());o&&M.set(o.toLowerCase(),r),M.set(r,r),M.set(n.slice(2),r)}return M},Tn=t=>{let n=t.trim().toLowerCase();if(Object.prototype.hasOwnProperty.call(kt,n))return kt[n];let r=/^[a-z]{2}-[a-z0-9]{1,3}$/.test(n)?n.slice(0,2):n;return _n().get(r)},De=t=>[...new Set(t.flatMap(r=>Tn(r)??[]))].sort()});var wn={};Me(wn,{ApiError:()=>B,InploiRpcClient:()=>J,JOB_ALERT_FREQUENCIES:()=>Le,NotFoundError:()=>j,ParsingError:()=>q,SchemaValidationError:()=>A,SdkError:()=>Ie,UnauthorisedError:()=>F,addressSearchCountry:()=>It,blendAddressSuggestions:()=>Fe,consentStorageKey:()=>he,createPlugin:()=>Ve,createTalentBankClient:()=>ve,endpoint:()=>Y,generateUUID:()=>z,getConsentAcceptance:()=>_t,getJobCountries:()=>je,getOrCreateAnonymousId:()=>se,hashConsentConfig:()=>fe,initialiseSdk:()=>St,inploiBrandedLogger:()=>ne,isApiErrorWithData:()=>$e,isSdkError:()=>Je,jobCountryCodes:()=>De,noLogging:()=>re,ready:()=>xt,saveClosedRoleJobAlerts:()=>wt,saveSearchEndpoint:()=>Oe,searchAddressSuggestions:()=>At,setConsentAcceptance:()=>Tt,typed:()=>L,validateEndpointInputs:()=>Re});module.exports=Ft(wn);var ee="%c[inploi SDK]",te="color: #65BC67; font-weight: bold;",ne={warn:(...t)=>console.warn(ee,te,...t),error:(...t)=>console.error(ee,te,...t),info:(...t)=>console.info(ee,te,...t),log:(...t)=>console.log(ee,te,...t)},re={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Ve=t=>t;function we(t,n){if(!t)throw new Error(n)}function $(t,n){return n in t}var Dn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var Bt="Unauthenticated",qt="This action is unauthorized.",N=class extends Error{constructor(r,o){super(r);this.status=o,this.name="ErrorWithStatus"}},j=class extends N{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},F=class extends N{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},A=class extends N{constructor(r,o){let a=o?` in ${o}`:"";super(`Schema validation failed${a}`);this.issues=r;this.source=o;this.name="SchemaValidationError",this.status=400}},B=class extends N{constructor(r,o,a){super(r);this.data=a;this.name="ApiError",this.status=o??500}},$e=t=>t instanceof B&&t.data!==void 0,q=class extends N{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 ke(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new q(t);return t.json().catch(()=>{throw new q(t)})}var Ut=["message","error","errors","exception","exceptions"];function Mt(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of Ut)if($(t,r)){let o=t[r];typeof o=="string"&&n.push(o),Array.isArray(o)&&o.every(a=>typeof a=="string")&&n.push(...o)}$(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&$(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&$(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 Ee(t,n){if(n>=300){let r=Mt(t);throw n===404?new j(r):r===Bt?new F("You are not authenticated.",n):r===qt?new F(r,n):new B(r,n,t)}}var ze=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,o={})=>{let a={...o,headers:{...o.headers,...n}},l=await fetch(`${t.baseUrl}${r}`,a);if(l.status===404)throw new j;let d=await ke(l);return Ee(d,l.status),d}}},Ie={NotFound:j,Unauthorised:F,SchemaValidation:A,Api:B,JsonParsing:q};function Je(t){return Object.values(Ie).some(n=>t instanceof n)}var He="2.10.0";var oe={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},We={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Ke=He;var C="isdk_session",ie=`${C}-candidate_id`,Ye=`${C}-consent`;var z=()=>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 Ze=7*24*60*60*1e3,Xe=t=>{let n=new Date;return n.setTime(n.getTime()+Ze),`${C}=${t};expires=${n.toUTCString()};path=/`},Vt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let o=sessionStorage.getItem(`${C}-session_id`);return typeof o=="string"?o:null},$t=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(ie);return typeof t=="string"&&t!==""?t:null}catch{return null}},zt=t=>{if(!(typeof window>"u"))try{t?window.localStorage.setItem(ie,t):window.localStorage.removeItem(ie)}catch{}},Jt=new RegExp(`(?:^|;\\s*)${C}=([^;]+)`),K=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?Jt.exec(n)?.[1]??null:null},et=()=>{try{let t=JSON.parse(window.localStorage.getItem(C)??"null");return typeof t!="object"||t===null||!("id"in t)||!("expires"in t)||typeof t.id!="string"||typeof t.expires!="number"?null:t.id!==""&&t.expires>Date.now()?t.id:null}catch{return null}},Qe=()=>K()??(new URL(location.href).searchParams.get("anonymous_id")?null:et()),Ht=()=>location.protocol==="https:"&&window.self!==window.top?";SameSite=None;Secure;Partitioned":"",tt=t=>{if(document.cookie=Xe(t)+Ht(),K()!==t)try{window.localStorage.setItem(C,JSON.stringify({id:t,expires:Date.now()+Ze}))}catch{}},Ae=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:t?K(t)??r.get("anonymous_id"):K()??r.get("anonymous_id")??et(),session_id:Vt(r,typeof window>"u")}},se=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=Ae().anonymous_id;if(t)return t;let n=z(),r=Ae().anonymous_id;return r||(tt(n),n)},Wt=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},Kt=t=>t==="about:client"?"":t,Yt={pathname:"/log",method:"POST",schema:{response:L(),body:L()}},nt=({rpcClient:t,logger:n,onEvent:r,talentBank:o,persistence:a="device"})=>{let l=null,d=null,u=0,f=0,k=p=>a==="none"?{anonymous_id:null,session_id:p?null:l}:Ae(p),G=async(p,v)=>{try{let V={library:{name:"inploi-sdk",version:Ke},page:v},E=k(p.request);a==="device"&&p.event==="IDENTIFY"&&!E.anonymous_id&&!p.request&&typeof window<"u"&&(E={...E,anonymous_id:se()});let Be=a==="none"?null:$t();if(p.event==="IDENTIFY"&&o&&(E.anonymous_id||a==="none")){let W=p.properties,xe=await o.identify({email:W.email??W.identifier,firstName:W.first_name,lastName:W.last_name,phone:W.phone_number,anonymousId:E.anonymous_id??z(),source:"sdk"});xe?.candidateId&&a==="device"&&(Be=xe.candidateId,zt(xe.candidateId))}let y={anonymous_id:E.anonymous_id,session_id:E.session_id,candidate_id:Be,event:p.event,sent_at:new Date().toISOString(),context:V,properties:p.properties,custom_properties:p.customProperties},Se=a==="none"?null:p.request?K(p.request):Qe(),qe=++u,Pt=await t.request(Yt,{body:y,...p.keepalive&&{keepalive:!0}}),I=Wt(Pt);if(a==="none")return!p.request&&I?.session_id&&qe>f&&(f=qe,I.session_id!==y.session_id&&(l=I.session_id)),y.session_id=p.request?I?.session_id||null:l,r?.(y),{success:!0,data:y};let _e=p.request?Se:Qe(),Rt=_e!==null&&_e!==Se,Te=_e??Se,Ue=!Rt&&(!Te||!I?.anonymous_id||Te===I.anonymous_id);return Ue?(I?.anonymous_id&&(y.anonymous_id=I.anonymous_id),I?.session_id&&(y.session_id=I.session_id)):y.anonymous_id=Te,!p.request&&typeof window<"u"&&y.anonymous_id&&(Ue&&y.session_id&&sessionStorage.setItem(`${C}-session_id`,y.session_id.toString()),tt(y.anonymous_id)),r?.(y),{success:!0,data:y}}catch(V){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:V}}},D=Promise.resolve();return{log:async p=>{we(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:Kt(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(a==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0}),a==="device"||p.request||l||p.keepalive)return G(p,v);let V=()=>G(p,v),E=D.then(V,V);return D=E,E},getHeaders:p=>{let v=new Headers;return a==="none"||!p?.anonymous_id||v.append("Set-Cookie",Xe(p.anonymous_id)),v},getSessionInfo:k,getOrCreateAnonymousId:()=>a==="none"?d??(d=z()):se()}};var rt=require("neoqs");function Pe(t,n,r){let o=t["~standard"].validate(n);if(o instanceof Promise)throw new TypeError("Async schema");if(o.issues)throw new A(o.issues,r);return o.value}function Qt(t,n,r){try{return{success:!0,output:Pe(t,n,r)}}catch(o){if(o instanceof A)return{success:!1,issues:o.issues,source:o.source};throw o}}var J=class{constructor(n){if(this.baseUrl=oe[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:a,body:l}=o?Re(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[f,k]of Object.entries(r.params))u=u.replace(`:${f}`,String(k));return d.pathname=u,n.schema.searchParams&&(d.search=(0,rt.stringify)(a)),[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 o=await ke(r.response);if(Ee(o,r.response.status),!(r.validateOut??!0))return o;let l=Qt(n.schema.response,o,"response");if(!l.success)throw new A(l.issues,l.source);return l.output}async request(n,r){try{let o=this.getFetchParams(n,r),a=await fetch(...o);return await this.parseResponse(n,{response:a,validateOut:r.validateOut})}catch(o){throw o instanceof A?this.logger.error(o.message,o.issues):this.logger.error(o),o}}};function L(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function Y(t){return t}function Re(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=Pe(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=Pe(t.schema.body,"body"in n?n.body:{})),r}var s=x(require("valibot"),1),Zt=["agent","sdk","form","integration","migration"],Xt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var en=["screening","cv_match","interview","overall"],tn=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],nn=["job","company"],rn=["created_at","updated_at"],on=["asc","desc"],sn=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],an=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],cn=["user","system","automation","integration","candidate"],ae=s.picklist(Zt),P=s.picklist(Xt),w=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),ce=s.picklist(en),ot=s.picklist(tn),Xn=s.picklist(nn),it=s.picklist(rn),st=s.picklist(on),Q=s.pipe(s.string(),s.trim(),s.minLength(1),s.maxLength(100)),le=s.picklist(sn),at=s.picklist(an),ct=s.picklist(cn);var S=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())})]);var R=x(require("valibot"),1),ln=R.object({total:R.number(),page:R.number(),perPage:R.number(),lastPage:R.number()});function pe(t){return R.object({data:R.array(t),pagination:ln})}var m=x(require("valibot"),1);var Z=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(ae),identifiedAt:m.nullable(m.string()),createdAt:m.string(),updatedAt:m.string()});var i=x(require("valibot"),1);var g=x(require("valibot"),1),H=g.pipe(g.string(),g.minLength(1)),lt=g.pipe(g.number(),g.integer(),g.minValue(1)),O=g.record(g.string(),g.unknown());var _=x(require("valibot"),1);var pt=_.object({id:_.string(),applicationId:_.string(),status:ot,scheduledAt:_.nullable(_.string()),completedAt:_.nullable(_.string()),meta:_.nullable(O),createdAt:_.string(),updatedAt:_.string()});var Ce=i.object({score:i.number(),reason:i.string(),confidence:i.number()}),dt=i.object({id:i.string(),candidateId:i.string(),jobId:i.number(),stage:w,stageGroup:P,stageEnteredAt:i.string(),rating:i.nullable(i.number()),disqualifiedAt:i.nullable(i.string()),disqualificationReason:i.nullable(Q),disqualificationNote:i.nullable(i.string()),source:le,sourceDetail:i.nullable(i.string()),sessionId:i.nullable(i.number()),externalApplicationId:i.nullable(i.string()),meta:i.nullable(O),context:i.nullable(O),scoredAt:i.nullable(i.string()),createdAt:i.string(),updatedAt:i.string()}),pn=i.object({id:i.string(),applicationId:i.string(),scoreType:ce,score:i.nullable(i.number()),reason:i.nullable(i.string()),categories:i.nullable(i.record(i.string(),Ce)),scoredBy:i.nullable(i.string()),createdAt:i.string()}),de=i.object({...dt.entries,candidate:i.nullable(Z),score:i.nullable(pn),interview:i.nullable(pt)}),dn=i.object({...Z.entries,applications:i.array(dt)}),ut=i.object({id:i.string(),applicationId:i.string(),action:at,fromStage:i.nullable(w),fromStageGroup:i.nullable(P),toStage:i.nullable(w),toStageGroup:i.nullable(P),disqualificationReason:i.nullable(Q),disqualificationNote:i.nullable(i.string()),actorId:i.nullable(i.string()),actorType:ct,actorEmail:i.nullable(i.string()),actorName:i.nullable(i.string()),meta:i.nullable(O),schemaVersion:i.number(),createdAt:i.string()});var h=x(require("valibot"),1);var mt=h.object({anonymousId:H,email:H,firstName:h.nullish(h.string()),lastName:h.nullish(h.string()),phone:h.nullish(h.string()),source:h.nullish(ae)}),gt=h.object({candidateId:h.string(),isNew:h.boolean()});var e=x(require("valibot"),1);var un=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],me=e.picklist(un),vt=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),mn=e.pipe(vt,e.array(w)),gn=e.pipe(vt,e.array(P)),ft=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),Sr=e.object({stages:e.optional(mn),stage_groups:e.optional(gn),job_id:e.optional(e.string()),job_ids:e.optional(ft),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(it),order:e.optional(st),page:e.optional(e.string()),per_page:e.optional(e.string())}),_r=e.pipe(e.object({candidateId:H,jobId:lt,meta:e.nullish(O),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(O),source:e.nullish(le),sourceDetail:e.nullish(e.string()),stage:e.nullish(w),stageGroup:e.nullish(P),actor:e.nullish(S)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together")),ht=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),Tr=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:ht})]),yt=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(ht)}),xr=e.object({applicationId:H,scoreType:ce,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),Ce)),scoredBy:e.nullish(e.string()),actor:e.nullish(S)}),wr=e.object({scoreId:e.string()}),kr=pe(de);var Er=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),Ir=e.array(ut),ue=e.object({stage:e.nullish(w),note:e.nullish(e.string())}),vn=e.object({stage:e.nullish(w),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),fn=e.variant("action",[e.object({action:e.literal("shortlist"),actor:S,meta:e.nullish(ue)}),e.object({action:e.literal("move_to_interview"),actor:S,meta:e.nullish(ue)}),e.object({action:e.literal("make_offer"),actor:S,meta:e.nullish(ue)}),e.object({action:e.literal("hire"),actor:S,meta:e.nullish(vn)}),e.object({action:e.literal("withdraw"),actor:S,meta:e.nullish(ue)}),e.object({action:e.literal("move_to_stage"),actor:S,meta:e.object({stage:w,stageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:S,meta:e.object({toStage:w,toStageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:S,meta:e.object({reason:Q,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:S,meta:e.object({toStage:w,toStageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:S,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),Ar=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:fn}),bt=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),Pr=e.variant("kind",[e.object({kind:e.literal("updated"),action:me,application:de}),e.object({kind:e.literal("skipped"),action:me,applicationId:e.string(),reason:bt})]),Rr=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:me,application:de})),skipped:e.array(e.object({kind:e.literal("skipped"),action:me,applicationId:e.string(),reason:bt})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),U=e.pipe(e.number(),e.integer(),e.minValue(0)),hn=e.object({APPLIED:U,SHORTLISTED:U,INTERVIEWED:U,OFFERED:U,HIRED:U,REJECTED:U,WITHDRAWN:U}),Cr=e.object({job_ids:ft}),Lr=e.object({counts:e.record(e.string(),hn)});var Fr=pe(Z);var b=x(require("valibot"),1),qr=b.object({avg_score:b.nullable(b.number()),p90_score:b.nullable(b.number()),p85_score:b.nullable(b.number()),p80_score:b.nullable(b.number()),total_scores:b.number(),total_shortlists:b.number()});var ge=x(require("valibot"));var ve=({environment:t,publishableKey:n,logger:r})=>{let o=We[t];return{async checkDuplicate(a){try{let l=new URLSearchParams({email:a.email,scope:a.scope});a.scope==="job"&&a.jobId!=null&&l.set("job_id",String(a.jobId));let d=await fetch(`${o}/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=ge.safeParse(yt,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(a){try{if(!a.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let l={email:a.email,firstName:a.firstName,lastName:a.lastName,phone:a.phone,anonymousId:a.anonymousId,source:a.source??"sdk"},d=ge.safeParse(mt,l);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=ge.safeParse(gt,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 St({publishableKey:t,env:n,logger:r=ne,onEvent:o,persistence:a}){let l=ze({baseUrl:oe[n],publishableKey:t}),d=r===!1?re:r,u=new J({environment:n,apiKey:{type:"publishable",key:t},logger:d}),f=ve({environment:n,publishableKey:t,logger:d}),k=nt({rpcClient:u,logger:d,onEvent:o,talentBank:f,persistence:a});return{register:D=>D({logger:d,apiClient:l,analytics:k,rpcClient:u,publishableKey:t,env:n}),analytics:k,apiClient:l}}function fe(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 he(t,n){return`${Ye}:${t}:${n}`}function _t(t,n){if(typeof window>"u")return!1;try{let r=he(t,fe(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function Tt(t,n){if(!(typeof window>"u"))try{let r=he(t,fe(n));window.localStorage.setItem(r,"accepted")}catch{}}function xt(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}var c=x(require("valibot"));var Le=["DAILY","WEEKLY","MONTHLY"],yn=c.record(c.string(),c.union([c.string(),c.array(c.string()),c.object({type:c.literal("provided"),lat:c.number(),lng:c.number(),radius:c.number(),unit:c.optional(c.picklist(["miles","km"])),label:c.optional(c.string())})])),bn={pathname:"/job/:id",method:"GET",schema:{response:c.object({id:c.number(),external_id:c.nullish(c.string()),city:c.nullish(c.string()),town:c.nullish(c.string()),category:c.nullish(c.string())})}};async function wt(t,{contact:n,job:r}){let o={};if(r){let a=await t.request(bn,{params:{id:r.id}});if((r.id_type==="internal"?String(a.id):a.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let d of["city","town","category"]){let u=a[d]?.trim();u&&(o[d]=[u])}}await t.request(Oe,{body:{contact:n,alerts:"WEEKLY",filters:o}})}var Oe={pathname:"/search/save",method:"POST",schema:{response:L(),body:c.object({contact:c.object({email:c.pipe(c.optional(c.string()),c.string(),c.email()),first_name:c.optional(c.string()),last_name:c.optional(c.string())}),alerts:c.pipe(c.optional(c.string()),c.string(),c.picklist(Le)),filters:yn})}};var T=x(require("valibot"));var je=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:L()}};return t.request(n,{searchParams:{filters:{country:null}}})},ye=new WeakMap,It=t=>(ye.has(t)||(ye.set(t,void 0),je(t).then(async n=>{let{jobCountryCodes:r}=await Promise.resolve().then(()=>(Ne(),Et));ye.set(t,r(n).join(",")||void 0)}).catch(()=>{})),ye.get(t)),Fe=(t,n)=>{let r=new Set,o=[];for(let a=0;a<Math.max(t.length,n.length);a++)for(let l of[t[a],n[a]]){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),o.push(l),o.length===5))return o}return o},xn=600,At=async(t,n,r)=>{if(r?.throwIfAborted(),!n){let o=await t();return r?.throwIfAborted(),o}return new Promise((o,a)=>{let l,d,u,f=!1,k=()=>{f=!0,clearTimeout(u),r?.removeEventListener("abort",G)},G=()=>{k(),a(r?.reason)},D=()=>{k(),l?.status==="fulfilled"&&d?.status==="fulfilled"?o(Fe(l.value,d.value)):l?.status==="fulfilled"?o(l.value):d?.status==="fulfilled"?o(d.value):l?.status==="rejected"&&a(l.reason)},be=(p,v)=>{f||(p?l=v:d=v,l&&d?D():v.status==="fulfilled"&&v.value.length>0&&(u=setTimeout(D,xn)))};r?.addEventListener("abort",G,{once:!0});for(let p of[!0,!1])t(p?n:void 0).then(v=>be(p,{status:"fulfilled",value:v}),v=>be(p,{status:"rejected",reason:v}))})};Ne();0&&(module.exports={ApiError,InploiRpcClient,JOB_ALERT_FREQUENCIES,NotFoundError,ParsingError,SchemaValidationError,SdkError,UnauthorisedError,addressSearchCountry,blendAddressSuggestions,consentStorageKey,createPlugin,createTalentBankClient,endpoint,generateUUID,getConsentAcceptance,getJobCountries,getOrCreateAnonymousId,hashConsentConfig,initialiseSdk,inploiBrandedLogger,isApiErrorWithData,isSdkError,jobCountryCodes,noLogging,ready,saveClosedRoleJobAlerts,saveSearchEndpoint,searchAddressSuggestions,setConsentAcceptance,typed,validateEndpointInputs});
|
|
14
14
|
//# sourceMappingURL=index.js.map
|