@inploi/sdk 2.3.2 → 2.4.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 CHANGED
@@ -29,6 +29,14 @@ const sdk = initialiseSdk({
29
29
 
30
30
  ## Plugins
31
31
 
32
+ The root exports `saveSearchEndpoint`, `JobAlertsFilters` and
33
+ `JOB_ALERT_FREQUENCIES` for the shared job-alert contract. Widgets can call
34
+ `saveClosedRoleJobAlerts(rpcClient, { contact, job? })` after explicit opt-in;
35
+ it verifies a known job's identity, uses its available city/town/category as
36
+ filters and saves weekly alerts. Lookup failures propagate to the caller.
37
+ RPC responses reject non-success HTTP status codes before validating the response
38
+ schema, including endpoints with a type-only response schema.
39
+
32
40
  You can write custom plugins via the `createPlugin` function. The plugin will have two dependencies injected: a `logger` service and a an `apiClient` service, which can be used to make requests to the inploi API.
33
41
 
34
42
  Example:
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 Un=Object.defineProperty,zn=Object.defineProperties;var Kn=Object.getOwnPropertyDescriptors;var cn=Object.getOwnPropertySymbols;var Hn=Object.prototype.hasOwnProperty,Jn=Object.prototype.propertyIsEnumerable;var pn=(e,t,n)=>t in e?Un(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,F=(e,t)=>{for(var n in t||(t={}))Hn.call(t,n)&&pn(e,n,t[n]);if(cn)for(var n of cn(t))Jn.call(t,n)&&pn(e,n,t[n]);return e},V=(e,t)=>zn(e,Kn(t));var C=(e,t,n)=>new Promise((r,o)=>{var i=u=>{try{l(n.next(u))}catch(f){o(f)}},a=u=>{try{l(n.throw(u))}catch(f){o(f)}},l=u=>u.done?r(u.value):Promise.resolve(u.value).then(i,a);l((n=n.apply(e,t)).next())});function Ce(e,t){if(!e)throw new Error(t)}function Z(e,t){return t in e}var Xt=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var he="%c[inploi SDK]",me="color: #65BC67; font-weight: bold;",Ne={warn:(...e)=>console.warn(he,me,...e),error:(...e)=>console.error(he,me,...e),info:(...e)=>console.info(he,me,...e),log:(...e)=>console.log(he,me,...e)},Le={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Wn="Unauthenticated",Xn="This action is unauthorized.",J=class extends Error{constructor(n,r){super(n);this.status=r,this.name="ErrorWithStatus"}},ie=class extends J{constructor(t){super(t!=null?t:"Not found"),this.name="NotFoundError",this.status=404}},se=class extends J{constructor(t,n){super(t!=null?t:"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=n!=null?n:401}},K=class extends J{constructor(n,r){let o=r?` in ${r}`:"";super(`Schema validation failed${o}`);this.issues=n;this.source=r;this.name="SchemaValidationError",this.status=400}},de=class extends J{constructor(n,r,o){super(n);this.data=o;this.name="ApiError",this.status=r!=null?r:500}};var oe=class extends J{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 Fe(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 oe(e);return e.json().catch(()=>{throw new oe(e)})})}var $n=["message","error","errors","exception","exceptions"];function Yn(e){let t=[];if(typeof e=="object"&&e!==null){for(let n of $n)if(Z(e,n)){let r=e[n];typeof r=="string"&&t.push(r),Array.isArray(r)&&r.every(o=>typeof o=="string")&&t.push(...r)}Z(e,"integration_response")&&typeof e.integration_response=="object"&&e.integration_response!==null&&Z(e.integration_response,"error")&&typeof e.integration_response.error=="object"&&e.integration_response.error!==null&&Z(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 qe(e,t){if(t>=300){let n=Yn(e);throw t===404?new ie(n):n===Wn?new se("You are not authenticated.",t):n===Xn?new se(n,t):new de(n,t,e)}}var fn=e=>{let t={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(o,...i)=>C(void 0,[o,...i],function*(n,r={}){let a=V(F({},r),{headers:F(F({},r.headers),t)}),l=yield fetch(`${e.baseUrl}${n}`,a);if(l.status===404)throw new ie;let u=yield Fe(l);return qe(u,l.status),u})}};var yn="2.3.2";var ve={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"},mn=yn;var W="isdk_session",ge=`${W}-candidate_id`,Qn=`${W}-consent`;var Be="RFC3986",Ve={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:e=>String(e)},et="RFC1738";var nt=Array.isArray,q=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var Me=1024,tt=(e,t,n,r,o)=>{if(e.length===0)return e;let i=e;if(typeof e=="symbol"?i=Symbol.prototype.toString.call(e):typeof e!="string"&&(i=String(e)),n==="iso-8859-1")return escape(i).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});let a="";for(let l=0;l<i.length;l+=Me){let u=i.length>=Me?i.slice(l,l+Me):i,f=[];for(let h=0;h<u.length;++h){let c=u.charCodeAt(h);if(c===45||c===46||c===95||c===126||c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||o===et&&(c===40||c===41)){f[f.length]=u.charAt(h);continue}if(c<128){f[f.length]=q[c];continue}if(c<2048){f[f.length]=q[192|c>>6]+q[128|c&63];continue}if(c<55296||c>=57344){f[f.length]=q[224|c>>12]+q[128|c>>6&63]+q[128|c&63];continue}h+=1,c=65536+((c&1023)<<10|u.charCodeAt(h)&1023),f[f.length]=q[240|c>>18]+q[128|c>>12&63]+q[128|c>>6&63]+q[128|c&63]}a+=f.join("")}return a};function rt(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function dn(e,t){if(nt(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var ur=Array.isArray;var it=Object.prototype.hasOwnProperty,vn={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},M=Array.isArray,st=Array.prototype.push,gn=function(e,t){st.apply(e,M(t)?t:[t])},ot=Date.prototype.toISOString,A={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:tt,encodeValuesOnly:!1,format:Be,formatter:Ve[Be],indices:!1,serializeDate(e){return ot.call(e)},skipNulls:!1,strictNullHandling:!1};function ut(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var Ge={};function bn(e,t,n,r,o,i,a,l,u,f,h,c,_,m,x,S,w,L){let v=e,pe=L,fe=0,on=!1;for(;(pe=pe.get(Ge))!==void 0&&!on;){let P=pe.get(e);if(fe+=1,typeof P!="undefined"){if(P===fe)throw new RangeError("Cyclic object value");on=!0}typeof pe.get(Ge)=="undefined"&&(fe=0)}if(typeof f=="function"?v=f(t,v):v instanceof Date?v=_==null?void 0:_(v):n==="comma"&&M(v)&&(v=dn(v,function(P){return P instanceof Date?_==null?void 0:_(P):P})),v===null){if(i)return u&&!S?u(t,A.encoder,w,"key",m):t;v=""}if(ut(v)||rt(v)){if(u){let P=S?t:u(t,A.encoder,w,"key",m);return[(x==null?void 0:x(P))+"="+(x==null?void 0:x(u(v,A.encoder,w,"value",m)))]}return[(x==null?void 0:x(t))+"="+(x==null?void 0:x(String(v)))]}let Re=[];if(typeof v=="undefined")return Re;let re;if(n==="comma"&&M(v))S&&u&&(v=dn(v,u)),re=[{value:v.length>0?v.join(",")||null:void 0}];else if(M(f))re=f;else{let P=Object.keys(v);re=h?P.sort(h):P}let un=l?String(t).replace(/\./g,"%2E"):String(t),ye=r&&M(v)&&v.length===1?un+"[]":un;if(o&&M(v)&&v.length===0)return ye+"[]";for(let P=0;P<re.length;++P){let Y=re[P],an=typeof Y=="object"&&typeof Y.value!="undefined"?Y.value:v[Y];if(a&&an===null)continue;let Oe=c&&l?Y.replace(/\./g,"%2E"):Y,Vn=M(v)?typeof n=="function"?n(ye,Oe):ye:ye+(c?"."+Oe:"["+Oe+"]");L.set(e,fe);let ln=new WeakMap;ln.set(Ge,L),gn(Re,bn(an,Vn,n,r,o,i,a,l,n==="comma"&&S&&M(v)?null:u,f,h,c,_,m,x,S,w,ln))}return Re}function at(e=A){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||A.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=Be;if(typeof e.format!="undefined"){if(!it.call(Ve,e.format))throw new TypeError("Unknown format option provided.");n=e.format}let r=Ve[n],o=A.filter;(typeof e.filter=="function"||M(e.filter))&&(o=e.filter);let i;if(e.arrayFormat&&e.arrayFormat in vn?i=e.arrayFormat:"indices"in e?i=e.indices?"indices":"repeat":i=A.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:A.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:A.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:A.allowEmptyArrays,arrayFormat:i,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:A.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter=="undefined"?A.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:A.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:A.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:A.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:A.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:A.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:A.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:A.strictNullHandling}}function kn(e,t={}){let n=e,r=at(t),o,i;typeof r.filter=="function"?(i=r.filter,n=i("",n)):M(r.filter)&&(i=r.filter,o=i);let a=[];if(typeof n!="object"||n===null)return"";let l=vn[r.arrayFormat],u=l==="comma"&&r.commaRoundTrip;o||(o=Object.keys(n)),r.sort&&o.sort(r.sort);let f=new WeakMap;for(let _=0;_<o.length;++_){let m=o[_];r.skipNulls&&n[m]===null||gn(a,bn(n[m],m,l,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 h=a.join(r.delimiter),c=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?c+="utf8=%26%2310003%3B&":c+="utf8=%E2%9C%93&"),h.length>0?c+h:""}function Ue(e,t,n){let r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Async schema");if(r.issues)throw new K(r.issues,n);return r.value}function lt(e,t,n){try{return{success:!0,output:Ue(e,t,n)}}catch(r){if(r instanceof K)return{success:!1,issues:r.issues,source:r.source};throw r}}var ue=class{constructor(t){if(this.baseUrl=ve[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:o,body:i}=r?xn(t,n):n,a=new URL(this.baseUrl),l=t.pathname;if("params"in n&&n.params)for(let[f,h]of Object.entries(n.params))l=l.replace(`:${f}`,String(h));return a.pathname=l,t.schema.searchParams&&(a.search=kn(o)),[a.toString(),{method:t.method,body:i?JSON.stringify(i):void 0,headers:this.headers,signal:n.signal}]}parseResponse(t,n){return C(this,null,function*(){var a;let r=yield Fe(n.response);if(!((a=n.validateOut)!=null?a:!0))return r;let i=lt(t.schema.response,r,"response");if(!i.success)throw qe(r,n.response.status),new K(i.issues,i.source);return i.output})}request(t,n){return C(this,null,function*(){try{let r=this.getFetchParams(t,n),o=yield fetch(...r);return yield this.parseResponse(t,{response:o,validateOut:n.validateOut})}catch(r){throw r instanceof K?this.logger.error(r.message,r.issues):this.logger.error(r),r}})}};function be(){return{"~standard":{vendor:"inploi",version:1,validate:e=>({value:e})}}}function xn(e,t){let n={searchParams:void 0,body:void 0,validateIn:!1};return e.schema.searchParams&&(n.searchParams=Ue(e.schema.searchParams,"searchParams"in t?t.searchParams:{})),e.schema.body&&(n.body=Ue(e.schema.body,"body"in t?t.body:{})),n}var U;function En(e){var t,n,r;return{lang:(t=e==null?void 0:e.lang)!=null?t:U==null?void 0:U.lang,message:e==null?void 0:e.message,abortEarly:(n=e==null?void 0:e.abortEarly)!=null?n:U==null?void 0:U.abortEarly,abortPipeEarly:(r=e==null?void 0:e.abortPipeEarly)!=null?r:U==null?void 0:U.abortPipeEarly}}var ze;function ct(e){return ze==null?void 0:ze.get(e)}var Ke;function pt(e){return Ke==null?void 0:Ke.get(e)}var He;function ft(e,t){var n;return(n=He==null?void 0:He.get(e))==null?void 0:n.get(t)}function X(e){var n,r,o;let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(o=e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))!=null?o:"null":t}function I(e,t,n,r,o){var c,_,m,x,S,w,L,v;let i=o&&"input"in o?o.input:n.value,a=(_=(c=o==null?void 0:o.expected)!=null?c:e.expects)!=null?_:null,l=(m=o==null?void 0:o.received)!=null?m:X(i),u={kind:e.kind,type:e.type,input:i,expected:a,received:l,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:o==null?void 0:o.path,issues:o==null?void 0:o.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},f=e.kind==="schema",h=(v=(L=(w=(S=(x=o==null?void 0:o.message)!=null?x:e.message)!=null?S:ft(e.reference,u.lang))!=null?w:f?pt(u.lang):null)!=null?L:r.message)!=null?v:ct(u.lang);h!==void 0&&(u.message=typeof h=="function"?h(u):h),f&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function D(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},En())}}}function yt(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Je(e,t){var r;let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:(r=n[0])!=null?r:"never"}var vr=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 We(e,t){return{kind:"validation",type:"check",reference:We,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 Q(e){return{kind:"validation",type:"integer",reference:Q,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 ke(e,t){return{kind:"validation",type:"max_length",reference:ke,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 Xe(e,t){return{kind:"validation",type:"max_value",reference:Xe,async:!1,expects:`<=${e instanceof Date?e.toJSON():X(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():X(n.value)}),n}}}function j(e,t){return{kind:"validation",type:"min_length",reference:j,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 ee(e,t){return{kind:"validation",type:"min_value",reference:ee,async:!1,expects:`>=${e instanceof Date?e.toJSON():X(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():X(n.value)}),n}}}function xe(e){return{kind:"transformation",type:"transform",reference:xe,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function _e(){return{kind:"transformation",type:"trim",reference:_e,async:!1,"~run"(e){return e.value=e.value.trim(),e}}}function ht(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function Ee(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function R(e,t){return{kind:"schema",type:"array",reference:R,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return D(this)},"~run"(n,r){var i;let o=n.value;if(Array.isArray(o)){n.typed=!0,n.value=[];for(let a=0;a<o.length;a++){let l=o[a],u=this.item["~run"]({value:l},r);if(u.issues){let f={type:"array",origin:"value",input:o,key:a,value:l};for(let h of u.issues)h.path?h.path.unshift(f):h.path=[f],(i=n.issues)==null||i.push(h);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 ae(e){return{kind:"schema",type:"boolean",reference:ae,expects:"boolean",async:!1,message:e,get"~standard"(){return D(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:I(this,"type",t,n),t}}}function k(e,t){return{kind:"schema",type:"literal",reference:k,expects:X(e),async:!1,literal:e,message:t,get"~standard"(){return D(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:I(this,"type",n,r),n}}}function y(e,t){return{kind:"schema",type:"nullable",reference:y,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return D(this)},"~run"(n,r){return n.value===null&&(this.default!==void 0&&(n.value=Ee(this,n,r)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function d(e,t){return{kind:"schema",type:"nullish",reference:d,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return D(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=Ee(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function g(e){return{kind:"schema",type:"number",reference:g,expects:"number",async:!1,message:e,get"~standard"(){return D(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:I(this,"type",t,n),t}}}function p(e,t){return{kind:"schema",type:"object",reference:p,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return D(this)},"~run"(n,r){var i;let o=n.value;if(o&&typeof o=="object"){n.typed=!0,n.value={};for(let a in this.entries){let l=this.entries[a];if(a in o||(l.type==="exact_optional"||l.type==="optional"||l.type==="nullish")&&l.default!==void 0){let u=a in o?o[a]:Ee(l),f=l["~run"]({value:u},r);if(f.issues){let h={type:"object",origin:"value",input:o,key:a,value:u};for(let c of f.issues)c.path?c.path.unshift(h):c.path=[h],(i=n.issues)==null||i.push(c);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(l.fallback!==void 0)n.value[a]=ht(l);else if(l.type!=="exact_optional"&&l.type!=="optional"&&l.type!=="nullish"&&(I(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:o,key:a,value:o[a]}]}),r.abortEarly))break}}else I(this,"type",n,r);return n}}}function b(e,t){return{kind:"schema",type:"optional",reference:b,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return D(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=Ee(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function T(e,t){return{kind:"schema",type:"picklist",reference:T,expects:Je(e.map(X),"|"),async:!1,options:e,message:t,get"~standard"(){return D(this)},"~run"(n,r){return this.options.includes(n.value)?n.typed=!0:I(this,"type",n,r),n}}}function H(e,t,n){return{kind:"schema",type:"record",reference:H,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return D(this)},"~run"(r,o){var a,l;let i=r.value;if(i&&typeof i=="object"){r.typed=!0,r.value={};for(let u in i)if(yt(i,u)){let f=i[u],h=this.key["~run"]({value:u},o);if(h.issues){let _={type:"object",origin:"key",input:i,key:u,value:f};for(let m of h.issues)m.path=[_],(a=r.issues)==null||a.push(m);if(r.issues||(r.issues=h.issues),o.abortEarly){r.typed=!1;break}}let c=this.value["~run"]({value:f},o);if(c.issues){let _={type:"object",origin:"value",input:i,key:u,value:f};for(let m of c.issues)m.path?m.path.unshift(_):m.path=[_],(l=r.issues)==null||l.push(m);if(r.issues||(r.issues=c.issues),o.abortEarly){r.typed=!1;break}}(!h.typed||!c.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=c.value)}}else I(this,"type",r,o);return r}}}function s(e){return{kind:"schema",type:"string",reference:s,expects:"string",async:!1,message:e,get"~standard"(){return D(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:I(this,"type",t,n),t}}}function _n(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function $e(e,t){return{kind:"schema",type:"union",reference:$e,expects:Je(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return D(this)},"~run"(n,r){let o,i,a;for(let l of this.options){let u=l["~run"]({value:n.value},r);if(u.typed)if(u.issues)i?i.push(u):i=[u];else{o=u;break}else a?a.push(u):a=[u]}if(o)return o;if(i){if(i.length===1)return i[0];I(this,"type",n,r,{issues:_n(i)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];I(this,"type",n,r,{issues:_n(a)})}return n}}}function Ye(){return{kind:"schema",type:"unknown",reference:Ye,expects:"unknown",async:!1,get"~standard"(){return D(this)},"~run"(e){return e.typed=!0,e}}}function ne(e,t,n){return{kind:"schema",type:"variant",reference:ne,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return D(this)},"~run"(r,o){let i=r.value;if(i&&typeof i=="object"){let a,l=0,u=this.key,f=[],h=(c,_)=>{for(let m of c.options){if(m.type==="variant")h(m,new Set(_).add(m.key));else{let x=!0,S=0;for(let w of _){let L=m.entries[w];if(w in i?L["~run"]({typed:!1,value:i[w]},{abortEarly:!0}).issues:L.type!=="exact_optional"&&L.type!=="optional"&&L.type!=="nullish"){x=!1,u!==w&&(l<S||l===S&&w in i&&!(u in i))&&(l=S,u=w,f=[]),u===w&&f.push(m.entries[w].expects);break}S++}if(x){let w=m["~run"]({value:i},o);(!a||!a.typed&&w.typed)&&(a=w)}}if(a&&!a.issues)break}};if(h(this,new Set([this.key])),a)return a;I(this,"type",r,o,{input:i[u],expected:Je(f,"|"),path:[{type:"object",origin:"value",input:i,key:u,value:i[u]}]})}else I(this,"type",r,o);return r}}}function E(...e){return V(F({},e[0]),{pipe:e,get"~standard"(){return D(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 Se(e,t,n){let r=e["~run"]({value:t},En(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var mt=["agent","sdk","form","integration","migration"],dt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var vt=["screening","cv_match","interview","overall"],gt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],bt=["job","company"],kt=["created_at","updated_at"],xt=["asc","desc"],_t=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Et=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],St=["user","system","automation","integration","candidate"],we=T(mt),B=T(dt),N=E(s(),_e(),j(1),ke(100)),Ae=T(vt),Sn=T(gt),br=T(bt),wn=T(kt),An=T(xt),le=E(s(),_e(),j(1),ke(100)),Ie=T(_t),In=T(Et),Tn=T(St);var O=ne("type",[p({type:k("user"),id:E(s(),j(1)),email:E(s(),j(1)),name:E(s(),j(1))}),p({type:k("system"),id:E(s(),j(1)),name:b(s())}),p({type:k("automation"),id:E(s(),j(1)),name:b(s())}),p({type:k("integration"),id:E(s(),j(1)),name:b(s())}),p({type:k("candidate"),id:E(s(),j(1)),email:b(s())})]);var wt=p({total:g(),page:g(),perPage:g(),lastPage:g()});function Te(e){return p({data:R(e),pagination:wt})}var ce=p({id:s(),email:y(s()),firstName:y(s()),lastName:y(s()),phone:y(s()),source:y(we),identifiedAt:y(s()),createdAt:s(),updatedAt:s()});var te=E(s(),j(1)),Pn=E(g(),Q(),ee(1)),z=H(s(),Ye());var Dn=p({id:s(),applicationId:s(),status:Sn,scheduledAt:y(s()),completedAt:y(s()),meta:y(z),createdAt:s(),updatedAt:s()});var Ze=p({score:g(),reason:s(),confidence:g()}),jn=p({id:s(),candidateId:s(),jobId:g(),stage:N,stageGroup:B,stageEnteredAt:s(),rating:y(g()),disqualifiedAt:y(s()),disqualificationReason:y(le),disqualificationNote:y(s()),source:Ie,sourceDetail:y(s()),sessionId:y(g()),externalApplicationId:y(s()),meta:y(z),context:y(z),scoredAt:y(s()),createdAt:s(),updatedAt:s()}),At=p({id:s(),applicationId:s(),scoreType:Ae,score:y(g()),reason:y(s()),categories:y(H(s(),Ze)),scoredBy:y(s()),createdAt:s()}),Pe=p(V(F({},jn.entries),{candidate:y(ce),score:y(At),interview:y(Dn)})),It=p(V(F({},ce.entries),{applications:R(jn)})),Rn=p({id:s(),applicationId:s(),action:In,fromStage:y(N),fromStageGroup:y(B),toStage:y(N),toStageGroup:y(B),disqualificationReason:y(le),disqualificationNote:y(s()),actorId:y(s()),actorType:Tn,actorEmail:y(s()),actorName:y(s()),meta:y(z),schemaVersion:g(),createdAt:s()});var On=p({anonymousId:te,email:te,firstName:d(s()),lastName:d(s()),phone:d(s()),source:d(we)}),Cn=p({candidateId:s(),isNew:ae()});var Tt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],je=T(Tt),Nn=E(s(),xe(e=>e.split(",").map(t=>t.trim()).filter(t=>t.length>0))),Pt=E(Nn,R(N)),Dt=E(Nn,R(B)),Ln=E(s(),xe(e=>e.split(",").map(t=>Number(t.trim())).filter(t=>Number.isInteger(t)&&t>0))),Br=p({stages:b(Pt),stage_groups:b(Dt),job_id:b(s()),job_ids:b(Ln),candidate_id:b(s()),is_disqualified:b(T(["true","false"])),created_from:b(s()),created_to:b(s()),updated_from:b(s()),updated_to:b(s()),entered_stage_from:b(s()),entered_stage_to:b(s()),from:b(s()),to:b(s()),q:b(s()),scored:b(T(["true","false"])),sort:b(wn),order:b(An),page:b(s()),per_page:b(s())}),Vr=E(p({candidateId:te,jobId:Pn,meta:d(z),sessionId:d(g()),externalApplicationId:d(s()),context:d(z),source:d(Ie),sourceDetail:d(s()),stage:d(N),stageGroup:d(B),actor:d(O)}),We(e=>e.stage==null==(e.stageGroup==null),"stage and stageGroup must be supplied together")),Fn=p({id:s(),stageGroup:s(),createdAt:s()}),Ur=$e([p({ok:k(!0),duplicate:k(!1),applicationId:s(),candidateId:s()}),p({ok:k(!0),duplicate:k(!0),existingApplication:Fn})]),qn=p({isDuplicate:ae(),existingApplication:b(Fn)}),zr=p({applicationId:te,scoreType:Ae,score:g(),reason:d(s()),categories:d(H(s(),Ze)),scoredBy:d(s()),actor:d(O)}),Kr=p({scoreId:s()}),Hr=Te(Pe);var Jr=T(["already_in_target_stage","not_in_source_stage","disqualified"]),Wr=R(Rn),De=p({stage:d(N),note:d(s())}),jt=p({stage:d(N),startDate:d(s()),note:d(s())}),Rt=ne("action",[p({action:k("shortlist"),actor:O,meta:d(De)}),p({action:k("move_to_interview"),actor:O,meta:d(De)}),p({action:k("make_offer"),actor:O,meta:d(De)}),p({action:k("hire"),actor:O,meta:d(jt)}),p({action:k("withdraw"),actor:O,meta:d(De)}),p({action:k("move_to_stage"),actor:O,meta:p({stage:N,stageGroup:B,note:d(s())})}),p({action:k("stage_transition"),actor:O,meta:p({toStage:N,toStageGroup:B,note:d(s())})}),p({action:k("disqualify"),actor:O,meta:p({reason:le,note:d(s())})}),p({action:k("reinstate"),actor:O,meta:p({toStage:N,toStageGroup:B,note:d(s())})}),p({action:k("rate"),actor:O,meta:p({rating:y(E(g(),Q(),ee(1),Xe(5)))})})]),Xr=p({applicationIds:E(R(s()),j(1)),body:Rt}),Mn=T(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),$r=ne("kind",[p({kind:k("updated"),action:je,application:Pe}),p({kind:k("skipped"),action:je,applicationId:s(),reason:Mn})]),Yr=p({updated:R(p({kind:k("updated"),action:je,application:Pe})),skipped:R(p({kind:k("skipped"),action:je,applicationId:s(),reason:Mn})),failed:R(p({applicationId:s(),error:s()}))}),$=E(g(),Q(),ee(0)),Ot=p({APPLIED:$,SHORTLISTED:$,INTERVIEWED:$,OFFERED:$,HIRED:$,REJECTED:$,WITHDRAWN:$}),Zr=p({job_ids:Ln}),Qr=p({counts:H(s(),Ot)});var ii=Te(ce);var oi=p({avg_score:y(g()),p90_score:y(g()),p85_score:y(g()),p80_score:y(g()),total_scores:g(),total_shortlists:g()});var Qe=({environment:e,publishableKey:t,logger:n})=>{let r=hn[e];return{checkDuplicate(i){return C(this,null,function*(){try{let a=new URLSearchParams({email:i.email,scope:i.scope});i.scope==="job"&&i.jobId!=null&&a.set("job_id",String(i.jobId));let l=yield fetch(`${r}/applications/check-duplicate?${a}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":t}});if(!l.ok)return n.error(`[TalentBankClient] checkDuplicate failed with status ${l.status}`),{isDuplicate:!1};let u=yield l.json(),f=Se(qn,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(i){return C(this,null,function*(){var a;try{if(!i.anonymousId)return n.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let l={email:i.email,firstName:i.firstName,lastName:i.lastName,phone:i.phone,anonymousId:i.anonymousId,source:(a=i.source)!=null?a:"sdk"},u=Se(On,l);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 h=Se(Cn,yield f.json());return h.success?h.output:(n.error("[TalentBankClient] identify returned an invalid response"),null)}catch(l){return n.error("[TalentBankClient] identify failed:",l),null}})}}};var en=()=>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 nn(e){if(typeof document!="undefined"){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",e,{once:!0});return}Promise.resolve().then(e)}}var rn=e=>{let t=new Date;return t.setTime(t.getTime()+7*24*60*60*1e3),`${W}=${e};expires=${t.toUTCString()};path=/`},Nt=(e,t)=>{let n=e.get("session_id");if(t||n)return n;let r=sessionStorage.getItem(`${W}-session_id`);return typeof r=="string"?r:null},Lt=()=>{if(typeof window=="undefined")return null;try{let e=window.localStorage.getItem(ge);return typeof e=="string"&&e!==""?e:null}catch(e){return null}},Ft=e=>{if(typeof window!="undefined")try{e?window.localStorage.setItem(ge,e):window.localStorage.removeItem(ge)}catch(t){}},qt=new RegExp(`${W}=([^;]+)`),sn=e=>{let t=e?e.url:location.href,{searchParams:n}=new URL(t),r=n.get("anonymous_id"),o=Nt(n,typeof window=="undefined");if(r)return{anonymous_id:r,session_id:o};let i=e?e.headers.get("cookie"):document.cookie;if(i){let a=qt.exec(i),l=a==null?void 0:a[1];return{anonymous_id:l!=null?l:null,session_id:o}}return{anonymous_id:r,session_id:o}},Gn=()=>{if(typeof window=="undefined")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let e=sn().anonymous_id;if(e)return e;let t=en();return document.cookie=rn(t),t},Mt=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},Gt=e=>e==="about:client"?"":e,Bt={pathname:"/log",method:"POST",schema:{response:be(),body:be()}},Bn=({rpcClient:e,logger:t,onEvent:n,talentBank:r})=>({log:i=>C(void 0,null,function*(){var l;Ce(i.request||typeof window!="undefined","Cannot log on the server without a request. Please pass a request to `log`.");let a="request"in i&&i.request?{href:i.request.url,referrer:Gt(i.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};try{let u={library:{name:"inploi-sdk",version:mn},page:a},f=sn(i.request);i.event==="IDENTIFY"&&!f.anonymous_id&&!i.request&&typeof window!="undefined"&&(f=V(F({},f),{anonymous_id:Gn()}));let h=Lt();if(i.event==="IDENTIFY"&&r&&f.anonymous_id){let x=i.properties,S=yield r.identify({email:(l=x.email)!=null?l:x.identifier,firstName:x.first_name,lastName:x.last_name,phone:x.phone_number,anonymousId:f.anonymous_id,source:"sdk"});S!=null&&S.candidateId&&(h=S.candidateId,Ft(S.candidateId))}let c={anonymous_id:f.anonymous_id,session_id:f.session_id,candidate_id:h,event:i.event,sent_at:new Date().toISOString(),context:u,properties:i.properties,custom_properties:i.customProperties},_=yield e.request(Bt,{body:c}),m=Mt(_);return m!=null&&m.anonymous_id&&(c.anonymous_id=m.anonymous_id),m!=null&&m.session_id&&(c.session_id=m.session_id),typeof window!="undefined"&&c.anonymous_id&&(c.session_id&&sessionStorage.setItem(`${W}-session_id`,c.session_id.toString()),document.cookie=rn(c.anonymous_id)),n==null||n(c),{success:!0,data:c}}catch(u){return t.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:u}}}),getHeaders:i=>{let a=new Headers;return i!=null&&i.anonymous_id&&a.append("Set-Cookie",rn(i.anonymous_id)),a},getSessionInfo:sn});function tn({publishableKey:e,env:t,logger:n=Ne,onEvent:r}){let o=fn({baseUrl:ve[t],publishableKey:e}),i=n===!1?Le:n,a=new ue({environment:t,apiKey:{type:"publishable",key:e},logger:i}),l=Qe({environment:t,publishableKey:e,logger:i}),u=Bn({rpcClient:a,logger:i,onEvent:r,talentBank:l});return{register:h=>h({logger:i,apiClient:o,analytics:u,rpcClient:a,publishableKey:e,env:t}),analytics:u,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=tn;window.inploi.ready=nn;})();
3
+ "use strict";(()=>{var Wn=Object.defineProperty,Hn=Object.defineProperties;var Xn=Object.getOwnPropertyDescriptors;var pn=Object.getOwnPropertySymbols;var Yn=Object.prototype.hasOwnProperty,$n=Object.prototype.propertyIsEnumerable;var fn=(e,t,n)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))Yn.call(t,n)&&fn(e,n,t[n]);if(pn)for(var n of pn(t))$n.call(t,n)&&fn(e,n,t[n]);return e},U=(e,t)=>Hn(e,Xn(t));var N=(e,t,n)=>new Promise((r,o)=>{var s=u=>{try{l(n.next(u))}catch(f){o(f)}},a=u=>{try{l(n.throw(u))}catch(f){o(f)}},l=u=>u.done?r(u.value):Promise.resolve(u.value).then(s,a);l((n=n.apply(e,t)).next())});function Le(e,t){if(!e)throw new Error(t)}function Z(e,t){return t in e}var er=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var de="%c[inploi SDK]",ve="color: #65BC67; font-weight: bold;",Fe={warn:(...e)=>console.warn(de,ve,...e),error:(...e)=>console.error(de,ve,...e),info:(...e)=>console.info(de,ve,...e),log:(...e)=>console.log(de,ve,...e)},qe={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Zn="Unauthenticated",Qn="This action is unauthorized.",W=class extends Error{constructor(n,r){super(n);this.status=r,this.name="ErrorWithStatus"}},se=class extends W{constructor(t){super(t!=null?t:"Not found"),this.name="NotFoundError",this.status=404}},oe=class extends W{constructor(t,n){super(t!=null?t:"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=n!=null?n:401}},K=class extends W{constructor(n,r){let o=r?` in ${r}`:"";super(`Schema validation failed${o}`);this.issues=n;this.source=r;this.name="SchemaValidationError",this.status=400}},ge=class extends W{constructor(n,r,o){super(n);this.data=o;this.name="ApiError",this.status=r!=null?r:500}};var ue=class extends W{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 Me(e){return N(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 ue(e);return e.json().catch(()=>{throw new ue(e)})})}var et=["message","error","errors","exception","exceptions"];function nt(e){let t=[];if(typeof e=="object"&&e!==null){for(let n of et)if(Z(e,n)){let r=e[n];typeof r=="string"&&t.push(r),Array.isArray(r)&&r.every(o=>typeof o=="string")&&t.push(...r)}Z(e,"integration_response")&&typeof e.integration_response=="object"&&e.integration_response!==null&&Z(e.integration_response,"error")&&typeof e.integration_response.error=="object"&&e.integration_response.error!==null&&Z(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 Ge(e,t){if(t>=300){let n=nt(e);throw t===404?new se(n):n===Zn?new oe("You are not authenticated.",t):n===Qn?new oe(n,t):new ge(n,t,e)}}var yn=e=>{let t={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(o,...s)=>N(void 0,[o,...s],function*(n,r={}){let a=U(C({},r),{headers:C(C({},r.headers),t)}),l=yield fetch(`${e.baseUrl}${n}`,a);if(l.status===404)throw new se;let u=yield Me(l);return Ge(u,l.status),u})}};var hn="2.4.0";var be={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},mn={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},dn=hn;var H="isdk_session",ke=`${H}-candidate_id`,rt=`${H}-consent`;var Ue="RFC3986",Je={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:e=>String(e)},it="RFC1738";var st=Array.isArray,M=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var Be=1024,ot=(e,t,n,r,o)=>{if(e.length===0)return e;let s=e;if(typeof e=="symbol"?s=Symbol.prototype.toString.call(e):typeof e!="string"&&(s=String(e)),n==="iso-8859-1")return escape(s).replace(/%u[0-9a-f]{4}/gi,function(l){return"%26%23"+parseInt(l.slice(2),16)+"%3B"});let a="";for(let l=0;l<s.length;l+=Be){let u=s.length>=Be?s.slice(l,l+Be):s,f=[];for(let h=0;h<u.length;++h){let p=u.charCodeAt(h);if(p===45||p===46||p===95||p===126||p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||o===it&&(p===40||p===41)){f[f.length]=u.charAt(h);continue}if(p<128){f[f.length]=M[p];continue}if(p<2048){f[f.length]=M[192|p>>6]+M[128|p&63];continue}if(p<55296||p>=57344){f[f.length]=M[224|p>>12]+M[128|p>>6&63]+M[128|p&63];continue}h+=1,p=65536+((p&1023)<<10|u.charCodeAt(h)&1023),f[f.length]=M[240|p>>18]+M[128|p>>12&63]+M[128|p>>6&63]+M[128|p&63]}a+=f.join("")}return a};function ut(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function vn(e,t){if(st(e)){let n=[];for(let r=0;r<e.length;r+=1)n.push(t(e[r]));return n}return t(e)}var fr=Array.isArray;var at=Object.prototype.hasOwnProperty,gn={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},G=Array.isArray,lt=Array.prototype.push,bn=function(e,t){lt.apply(e,G(t)?t:[t])},ct=Date.prototype.toISOString,P={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ot,encodeValuesOnly:!1,format:Ue,formatter:Je[Ue],indices:!1,serializeDate(e){return ct.call(e)},skipNulls:!1,strictNullHandling:!1};function pt(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||typeof e=="symbol"||typeof e=="bigint"}var Ve={};function kn(e,t,n,r,o,s,a,l,u,f,h,p,x,k,A,S,g,w){let b=e,ye=w,he=0,un=!1;for(;(ye=ye.get(Ve))!==void 0&&!un;){let D=ye.get(e);if(he+=1,typeof D!="undefined"){if(D===he)throw new RangeError("Cyclic object value");un=!0}typeof ye.get(Ve)=="undefined"&&(he=0)}if(typeof f=="function"?b=f(t,b):b instanceof Date?b=x==null?void 0:x(b):n==="comma"&&G(b)&&(b=vn(b,function(D){return D instanceof Date?x==null?void 0:x(D):D})),b===null){if(s)return u&&!S?u(t,P.encoder,g,"key",k):t;b=""}if(pt(b)||ut(b)){if(u){let D=S?t:u(t,P.encoder,g,"key",k);return[(A==null?void 0:A(D))+"="+(A==null?void 0:A(u(b,P.encoder,g,"value",k)))]}return[(A==null?void 0:A(t))+"="+(A==null?void 0:A(String(b)))]}let Ce=[];if(typeof b=="undefined")return Ce;let ie;if(n==="comma"&&G(b))S&&u&&(b=vn(b,u)),ie=[{value:b.length>0?b.join(",")||null:void 0}];else if(G(f))ie=f;else{let D=Object.keys(b);ie=h?D.sort(h):D}let an=l?String(t).replace(/\./g,"%2E"):String(t),me=r&&G(b)&&b.length===1?an+"[]":an;if(o&&G(b)&&b.length===0)return me+"[]";for(let D=0;D<ie.length;++D){let $=ie[D],ln=typeof $=="object"&&typeof $.value!="undefined"?$.value:b[$];if(a&&ln===null)continue;let Ne=p&&l?$.replace(/\./g,"%2E"):$,Kn=G(b)?typeof n=="function"?n(me,Ne):me:me+(p?"."+Ne:"["+Ne+"]");w.set(e,he);let cn=new WeakMap;cn.set(Ve,w),bn(Ce,kn(ln,Kn,n,r,o,s,a,l,n==="comma"&&S&&G(b)?null:u,f,h,p,x,k,A,S,g,cn))}return Ce}function ft(e=P){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||P.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=Ue;if(typeof e.format!="undefined"){if(!at.call(Je,e.format))throw new TypeError("Unknown format option provided.");n=e.format}let r=Je[n],o=P.filter;(typeof e.filter=="function"||G(e.filter))&&(o=e.filter);let s;if(e.arrayFormat&&e.arrayFormat in gn?s=e.arrayFormat:"indices"in e?s=e.indices?"indices":"repeat":s=P.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:P.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:P.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:P.allowEmptyArrays,arrayFormat:s,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:P.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter=="undefined"?P.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:P.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:P.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:P.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:P.encodeValuesOnly,filter:o,format:n,formatter:r,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:P.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:P.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:P.strictNullHandling}}function _n(e,t={}){let n=e,r=ft(t),o,s;typeof r.filter=="function"?(s=r.filter,n=s("",n)):G(r.filter)&&(s=r.filter,o=s);let a=[];if(typeof n!="object"||n===null)return"";let l=gn[r.arrayFormat],u=l==="comma"&&r.commaRoundTrip;o||(o=Object.keys(n)),r.sort&&o.sort(r.sort);let f=new WeakMap;for(let x=0;x<o.length;++x){let k=o[x];r.skipNulls&&n[k]===null||bn(a,kn(n[k],k,l,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 h=a.join(r.delimiter),p=r.addQueryPrefix===!0?"?":"";return r.charsetSentinel&&(r.charset==="iso-8859-1"?p+="utf8=%26%2310003%3B&":p+="utf8=%E2%9C%93&"),h.length>0?p+h:""}function ze(e,t,n){let r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Async schema");if(r.issues)throw new K(r.issues,n);return r.value}function yt(e,t,n){try{return{success:!0,output:ze(e,t,n)}}catch(r){if(r instanceof K)return{success:!1,issues:r.issues,source:r.source};throw r}}var ae=class{constructor(t){if(this.baseUrl=be[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:o,body:s}=r?xn(t,n):n,a=new URL(this.baseUrl),l=t.pathname;if("params"in n&&n.params)for(let[f,h]of Object.entries(n.params))l=l.replace(`:${f}`,String(h));return a.pathname=l,t.schema.searchParams&&(a.search=_n(o)),[a.toString(),C({method:t.method,body:s?JSON.stringify(s):void 0,headers:this.headers,signal:n.signal},n.keepalive&&{keepalive:!0})]}parseResponse(t,n){return N(this,null,function*(){var a;let r=yield Me(n.response);if(Ge(r,n.response.status),!((a=n.validateOut)!=null?a:!0))return r;let s=yt(t.schema.response,r,"response");if(!s.success)throw new K(s.issues,s.source);return s.output})}request(t,n){return N(this,null,function*(){try{let r=this.getFetchParams(t,n),o=yield fetch(...r);return yield this.parseResponse(t,{response:o,validateOut:n.validateOut})}catch(r){throw r instanceof K?this.logger.error(r.message,r.issues):this.logger.error(r),r}})}};function Q(){return{"~standard":{vendor:"inploi",version:1,validate:e=>({value:e})}}}function xn(e,t){let n={searchParams:void 0,body:void 0,validateIn:!1};return e.schema.searchParams&&(n.searchParams=ze(e.schema.searchParams,"searchParams"in t?t.searchParams:{})),e.schema.body&&(n.body=ze(e.schema.body,"body"in t?t.body:{})),n}var J;function wn(e){var t,n,r;return{lang:(t=e==null?void 0:e.lang)!=null?t:J==null?void 0:J.lang,message:e==null?void 0:e.message,abortEarly:(n=e==null?void 0:e.abortEarly)!=null?n:J==null?void 0:J.abortEarly,abortPipeEarly:(r=e==null?void 0:e.abortPipeEarly)!=null?r:J==null?void 0:J.abortPipeEarly}}var Ke;function ht(e){return Ke==null?void 0:Ke.get(e)}var We;function mt(e){return We==null?void 0:We.get(e)}var He;function dt(e,t){var n;return(n=He==null?void 0:He.get(e))==null?void 0:n.get(t)}function X(e){var n,r,o;let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(o=e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))!=null?o:"null":t}function T(e,t,n,r,o){var p,x,k,A,S,g,w,b;let s=o&&"input"in o?o.input:n.value,a=(x=(p=o==null?void 0:o.expected)!=null?p:e.expects)!=null?x:null,l=(k=o==null?void 0:o.received)!=null?k:X(s),u={kind:e.kind,type:e.type,input:s,expected:a,received:l,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${l}`,requirement:e.requirement,path:o==null?void 0:o.path,issues:o==null?void 0:o.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},f=e.kind==="schema",h=(b=(w=(g=(S=(A=o==null?void 0:o.message)!=null?A:e.message)!=null?S:dt(e.reference,u.lang))!=null?g:f?mt(u.lang):null)!=null?w:r.message)!=null?b:ht(u.lang);h!==void 0&&(u.message=typeof h=="function"?h(u):h),f&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function R(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},wn())}}}function vt(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function Xe(e,t){var r;let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:(r=n[0])!=null?r:"never"}var gt=/^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu,xr=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 Ye(e,t){return{kind:"validation",type:"check",reference:Ye,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&T(this,"input",n,r),n}}}function $e(e){return{kind:"validation",type:"email",reference:$e,expects:null,async:!1,requirement:gt,message:e,"~run"(t,n){return t.typed&&!this.requirement.test(t.value)&&T(this,"email",t,n),t}}}function ee(e){return{kind:"validation",type:"integer",reference:ee,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&T(this,"integer",t,n),t}}}function _e(e,t){return{kind:"validation",type:"max_length",reference:_e,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(n,r){return n.typed&&n.value.length>this.requirement&&T(this,"length",n,r,{received:`${n.value.length}`}),n}}}function Ze(e,t){return{kind:"validation",type:"max_value",reference:Ze,async:!1,expects:`<=${e instanceof Date?e.toJSON():X(e)}`,requirement:e,message:t,"~run"(n,r){return n.typed&&!(n.value<=this.requirement)&&T(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():X(n.value)}),n}}}function j(e,t){return{kind:"validation",type:"min_length",reference:j,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(n,r){return n.typed&&n.value.length<this.requirement&&T(this,"length",n,r,{received:`${n.value.length}`}),n}}}function ne(e,t){return{kind:"validation",type:"min_value",reference:ne,async:!1,expects:`>=${e instanceof Date?e.toJSON():X(e)}`,requirement:e,message:t,"~run"(n,r){return n.typed&&!(n.value>=this.requirement)&&T(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():X(n.value)}),n}}}function xe(e){return{kind:"transformation",type:"transform",reference:xe,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function Ee(){return{kind:"transformation",type:"trim",reference:Ee,async:!1,"~run"(e){return e.value=e.value.trim(),e}}}function bt(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function we(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function O(e,t){return{kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return R(this)},"~run"(n,r){var s;let o=n.value;if(Array.isArray(o)){n.typed=!0,n.value=[];for(let a=0;a<o.length;a++){let l=o[a],u=this.item["~run"]({value:l},r);if(u.issues){let f={type:"array",origin:"value",input:o,key:a,value:l};for(let h of u.issues)h.path?h.path.unshift(f):h.path=[f],(s=n.issues)==null||s.push(h);if(n.issues||(n.issues=u.issues),r.abortEarly){n.typed=!1;break}}u.typed||(n.typed=!1),n.value.push(u.value)}}else T(this,"type",n,r);return n}}}function le(e){return{kind:"schema",type:"boolean",reference:le,expects:"boolean",async:!1,message:e,get"~standard"(){return R(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:T(this,"type",t,n),t}}}function _(e,t){return{kind:"schema",type:"literal",reference:_,expects:X(e),async:!1,literal:e,message:t,get"~standard"(){return R(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:T(this,"type",n,r),n}}}function y(e,t){return{kind:"schema",type:"nullable",reference:y,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return R(this)},"~run"(n,r){return n.value===null&&(this.default!==void 0&&(n.value=we(this,n,r)),n.value===null)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function m(e,t){return{kind:"schema",type:"nullish",reference:m,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return R(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=we(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function v(e){return{kind:"schema",type:"number",reference:v,expects:"number",async:!1,message:e,get"~standard"(){return R(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:T(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 R(this)},"~run"(n,r){var s;let o=n.value;if(o&&typeof o=="object"){n.typed=!0,n.value={};for(let a in this.entries){let l=this.entries[a];if(a in o||(l.type==="exact_optional"||l.type==="optional"||l.type==="nullish")&&l.default!==void 0){let u=a in o?o[a]:we(l),f=l["~run"]({value:u},r);if(f.issues){let h={type:"object",origin:"value",input:o,key:a,value:u};for(let p of f.issues)p.path?p.path.unshift(h):p.path=[h],(s=n.issues)==null||s.push(p);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(l.fallback!==void 0)n.value[a]=bt(l);else if(l.type!=="exact_optional"&&l.type!=="optional"&&l.type!=="nullish"&&(T(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:o,key:a,value:o[a]}]}),r.abortEarly))break}}else T(this,"type",n,r);return n}}}function d(e,t){return{kind:"schema",type:"optional",reference:d,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return R(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=we(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function I(e,t){return{kind:"schema",type:"picklist",reference:I,expects:Xe(e.map(X),"|"),async:!1,options:e,message:t,get"~standard"(){return R(this)},"~run"(n,r){return this.options.includes(n.value)?n.typed=!0:T(this,"type",n,r),n}}}function B(e,t,n){return{kind:"schema",type:"record",reference:B,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return R(this)},"~run"(r,o){var a,l;let s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(let u in s)if(vt(s,u)){let f=s[u],h=this.key["~run"]({value:u},o);if(h.issues){let x={type:"object",origin:"key",input:s,key:u,value:f};for(let k of h.issues)k.path=[x],(a=r.issues)==null||a.push(k);if(r.issues||(r.issues=h.issues),o.abortEarly){r.typed=!1;break}}let p=this.value["~run"]({value:f},o);if(p.issues){let x={type:"object",origin:"value",input:s,key:u,value:f};for(let k of p.issues)k.path?k.path.unshift(x):k.path=[x],(l=r.issues)==null||l.push(k);if(r.issues||(r.issues=p.issues),o.abortEarly){r.typed=!1;break}}(!h.typed||!p.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=p.value)}}else T(this,"type",r,o);return r}}}function i(e){return{kind:"schema",type:"string",reference:i,expects:"string",async:!1,message:e,get"~standard"(){return R(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:T(this,"type",t,n),t}}}function En(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function ce(e,t){return{kind:"schema",type:"union",reference:ce,expects:Xe(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return R(this)},"~run"(n,r){let o,s,a;for(let l of this.options){let u=l["~run"]({value:n.value},r);if(u.typed)if(u.issues)s?s.push(u):s=[u];else{o=u;break}else a?a.push(u):a=[u]}if(o)return o;if(s){if(s.length===1)return s[0];T(this,"type",n,r,{issues:En(s)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];T(this,"type",n,r,{issues:En(a)})}return n}}}function Qe(){return{kind:"schema",type:"unknown",reference:Qe,expects:"unknown",async:!1,get"~standard"(){return R(this)},"~run"(e){return e.typed=!0,e}}}function te(e,t,n){return{kind:"schema",type:"variant",reference:te,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return R(this)},"~run"(r,o){let s=r.value;if(s&&typeof s=="object"){let a,l=0,u=this.key,f=[],h=(p,x)=>{for(let k of p.options){if(k.type==="variant")h(k,new Set(x).add(k.key));else{let A=!0,S=0;for(let g of x){let w=k.entries[g];if(g in s?w["~run"]({typed:!1,value:s[g]},{abortEarly:!0}).issues:w.type!=="exact_optional"&&w.type!=="optional"&&w.type!=="nullish"){A=!1,u!==g&&(l<S||l===S&&g in s&&!(u in s))&&(l=S,u=g,f=[]),u===g&&f.push(k.entries[g].expects);break}S++}if(A){let g=k["~run"]({value:s},o);(!a||!a.typed&&g.typed)&&(a=g)}}if(a&&!a.issues)break}};if(h(this,new Set([this.key])),a)return a;T(this,"type",r,o,{input:s[u],expected:Xe(f,"|"),path:[{type:"object",origin:"value",input:s,key:u,value:s[u]}]})}else T(this,"type",r,o);return r}}}function E(...e){return U(C({},e[0]),{pipe:e,get"~standard"(){return R(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 Se(e,t,n){let r=e["~run"]({value:t},wn(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var kt=["agent","sdk","form","integration","migration"],_t=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var xt=["screening","cv_match","interview","overall"],Et=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],wt=["job","company"],St=["created_at","updated_at"],At=["asc","desc"],It=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Tt=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],Pt=["user","system","automation","integration","candidate"],Ae=I(kt),V=I(_t),F=E(i(),Ee(),j(1),_e(100)),Ie=I(xt),Sn=I(Et),wr=I(wt),An=I(St),In=I(At),pe=E(i(),Ee(),j(1),_e(100)),Te=I(It),Tn=I(Tt),Pn=I(Pt);var L=te("type",[c({type:_("user"),id:E(i(),j(1)),email:E(i(),j(1)),name:E(i(),j(1))}),c({type:_("system"),id:E(i(),j(1)),name:d(i())}),c({type:_("automation"),id:E(i(),j(1)),name:d(i())}),c({type:_("integration"),id:E(i(),j(1)),name:d(i())}),c({type:_("candidate"),id:E(i(),j(1)),email:d(i())})]);var Dt=c({total:v(),page:v(),perPage:v(),lastPage:v()});function Pe(e){return c({data:O(e),pagination:Dt})}var fe=c({id:i(),email:y(i()),firstName:y(i()),lastName:y(i()),phone:y(i()),source:y(Ae),identifiedAt:y(i()),createdAt:i(),updatedAt:i()});var re=E(i(),j(1)),Dn=E(v(),ee(),ne(1)),z=B(i(),Qe());var Rn=c({id:i(),applicationId:i(),status:Sn,scheduledAt:y(i()),completedAt:y(i()),meta:y(z),createdAt:i(),updatedAt:i()});var en=c({score:v(),reason:i(),confidence:v()}),jn=c({id:i(),candidateId:i(),jobId:v(),stage:F,stageGroup:V,stageEnteredAt:i(),rating:y(v()),disqualifiedAt:y(i()),disqualificationReason:y(pe),disqualificationNote:y(i()),source:Te,sourceDetail:y(i()),sessionId:y(v()),externalApplicationId:y(i()),meta:y(z),context:y(z),scoredAt:y(i()),createdAt:i(),updatedAt:i()}),Rt=c({id:i(),applicationId:i(),scoreType:Ie,score:y(v()),reason:y(i()),categories:y(B(i(),en)),scoredBy:y(i()),createdAt:i()}),De=c(U(C({},jn.entries),{candidate:y(fe),score:y(Rt),interview:y(Rn)})),jt=c(U(C({},fe.entries),{applications:O(jn)})),On=c({id:i(),applicationId:i(),action:Tn,fromStage:y(F),fromStageGroup:y(V),toStage:y(F),toStageGroup:y(V),disqualificationReason:y(pe),disqualificationNote:y(i()),actorId:y(i()),actorType:Pn,actorEmail:y(i()),actorName:y(i()),meta:y(z),schemaVersion:v(),createdAt:i()});var Cn=c({anonymousId:re,email:re,firstName:m(i()),lastName:m(i()),phone:m(i()),source:m(Ae)}),Nn=c({candidateId:i(),isNew:le()});var Ot=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],je=I(Ot),Ln=E(i(),xe(e=>e.split(",").map(t=>t.trim()).filter(t=>t.length>0))),Ct=E(Ln,O(F)),Nt=E(Ln,O(V)),Fn=E(i(),xe(e=>e.split(",").map(t=>Number(t.trim())).filter(t=>Number.isInteger(t)&&t>0))),Kr=c({stages:d(Ct),stage_groups:d(Nt),job_id:d(i()),job_ids:d(Fn),candidate_id:d(i()),is_disqualified:d(I(["true","false"])),created_from:d(i()),created_to:d(i()),updated_from:d(i()),updated_to:d(i()),entered_stage_from:d(i()),entered_stage_to:d(i()),from:d(i()),to:d(i()),q:d(i()),scored:d(I(["true","false"])),sort:d(An),order:d(In),page:d(i()),per_page:d(i())}),Wr=E(c({candidateId:re,jobId:Dn,meta:m(z),sessionId:m(v()),externalApplicationId:m(i()),context:m(z),source:m(Te),sourceDetail:m(i()),stage:m(F),stageGroup:m(V),actor:m(L)}),Ye(e=>e.stage==null==(e.stageGroup==null),"stage and stageGroup must be supplied together")),qn=c({id:i(),stageGroup:i(),createdAt:i()}),Hr=ce([c({ok:_(!0),duplicate:_(!1),applicationId:i(),candidateId:i()}),c({ok:_(!0),duplicate:_(!0),existingApplication:qn})]),Mn=c({isDuplicate:le(),existingApplication:d(qn)}),Xr=c({applicationId:re,scoreType:Ie,score:v(),reason:m(i()),categories:m(B(i(),en)),scoredBy:m(i()),actor:m(L)}),Yr=c({scoreId:i()}),$r=Pe(De);var Zr=I(["already_in_target_stage","not_in_source_stage","disqualified"]),Qr=O(On),Re=c({stage:m(F),note:m(i())}),Lt=c({stage:m(F),startDate:m(i()),note:m(i())}),Ft=te("action",[c({action:_("shortlist"),actor:L,meta:m(Re)}),c({action:_("move_to_interview"),actor:L,meta:m(Re)}),c({action:_("make_offer"),actor:L,meta:m(Re)}),c({action:_("hire"),actor:L,meta:m(Lt)}),c({action:_("withdraw"),actor:L,meta:m(Re)}),c({action:_("move_to_stage"),actor:L,meta:c({stage:F,stageGroup:V,note:m(i())})}),c({action:_("stage_transition"),actor:L,meta:c({toStage:F,toStageGroup:V,note:m(i())})}),c({action:_("disqualify"),actor:L,meta:c({reason:pe,note:m(i())})}),c({action:_("reinstate"),actor:L,meta:c({toStage:F,toStageGroup:V,note:m(i())})}),c({action:_("rate"),actor:L,meta:c({rating:y(E(v(),ee(),ne(1),Ze(5)))})})]),ei=c({applicationIds:E(O(i()),j(1)),body:Ft}),Gn=I(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),ni=te("kind",[c({kind:_("updated"),action:je,application:De}),c({kind:_("skipped"),action:je,applicationId:i(),reason:Gn})]),ti=c({updated:O(c({kind:_("updated"),action:je,application:De})),skipped:O(c({kind:_("skipped"),action:je,applicationId:i(),reason:Gn})),failed:O(c({applicationId:i(),error:i()}))}),Y=E(v(),ee(),ne(0)),qt=c({APPLIED:Y,SHORTLISTED:Y,INTERVIEWED:Y,OFFERED:Y,HIRED:Y,REJECTED:Y,WITHDRAWN:Y}),ri=c({job_ids:Fn}),ii=c({counts:B(i(),qt)});var li=Pe(fe);var pi=c({avg_score:y(v()),p90_score:y(v()),p85_score:y(v()),p80_score:y(v()),total_scores:v(),total_shortlists:v()});var nn=({environment:e,publishableKey:t,logger:n})=>{let r=mn[e];return{checkDuplicate(s){return N(this,null,function*(){try{let a=new URLSearchParams({email:s.email,scope:s.scope});s.scope==="job"&&s.jobId!=null&&a.set("job_id",String(s.jobId));let l=yield fetch(`${r}/applications/check-duplicate?${a}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":t}});if(!l.ok)return n.error(`[TalentBankClient] checkDuplicate failed with status ${l.status}`),{isDuplicate:!1};let u=yield l.json(),f=Se(Mn,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(s){return N(this,null,function*(){var a;try{if(!s.anonymousId)return n.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let l={email:s.email,firstName:s.firstName,lastName:s.lastName,phone:s.phone,anonymousId:s.anonymousId,source:(a=s.source)!=null?a:"sdk"},u=Se(Cn,l);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 h=Se(Nn,yield f.json());return h.success?h.output:(n.error("[TalentBankClient] identify returned an invalid response"),null)}catch(l){return n.error("[TalentBankClient] identify failed:",l),null}})}}};var tn=()=>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 rn(e){if(typeof document!="undefined"){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",e,{once:!0});return}Promise.resolve().then(e)}}var Vn=["DAILY","WEEKLY","MONTHLY"],Mt=B(i(),ce([i(),O(i()),c({type:_("provided"),lat:v(),lng:v(),radius:v(),unit:d(I(["miles","km"])),label:d(i())})])),Ci={pathname:"/job/:id",method:"GET",schema:{response:c({id:v(),external_id:m(i()),city:m(i()),town:m(i()),category:m(i())})}};var Gt={pathname:"/search/save",method:"POST",schema:{response:Q(),body:c({contact:c({email:E(d(i()),i(),$e()),first_name:d(i()),last_name:d(i())}),alerts:E(d(i()),i(),I(Vn)),filters:Mt})}};var on=e=>{let t=new Date;return t.setTime(t.getTime()+7*24*60*60*1e3),`${H}=${e};expires=${t.toUTCString()};path=/`},Bt=(e,t)=>{let n=e.get("session_id");if(t||n)return n;let r=sessionStorage.getItem(`${H}-session_id`);return typeof r=="string"?r:null},Vt=()=>{if(typeof window=="undefined")return null;try{let e=window.localStorage.getItem(ke);return typeof e=="string"&&e!==""?e:null}catch(e){return null}},Ut=e=>{if(typeof window!="undefined")try{e?window.localStorage.setItem(ke,e):window.localStorage.removeItem(ke)}catch(t){}},Jn=new RegExp(`${H}=([^;]+)`),Oe=e=>{let t=e?e.url:location.href,{searchParams:n}=new URL(t),r=n.get("anonymous_id"),o=Bt(n,typeof window=="undefined");if(r)return{anonymous_id:r,session_id:o};let s=e?e.headers.get("cookie"):document.cookie;if(s){let a=Jn.exec(s),l=a==null?void 0:a[1];return{anonymous_id:l!=null?l:null,session_id:o}}return{anonymous_id:r,session_id:o}},Un=()=>{if(typeof window=="undefined")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let e=Oe().anonymous_id;if(e)return e;let t=tn(),n=Oe().anonymous_id;return n||(document.cookie=on(t),t)},Jt=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},zt=e=>e==="about:client"?"":e,Kt={pathname:"/log",method:"POST",schema:{response:Q(),body:Q()}},zn=({rpcClient:e,logger:t,onEvent:n,talentBank:r})=>({log:s=>N(void 0,null,function*(){var l;Le(s.request||typeof window!="undefined","Cannot log on the server without a request. Please pass a request to `log`.");let a="request"in s&&s.request?{href:s.request.url,referrer:zt(s.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};try{let u={library:{name:"inploi-sdk",version:dn},page:a},f=Oe(s.request);s.event==="IDENTIFY"&&!f.anonymous_id&&!s.request&&typeof window!="undefined"&&(f=U(C({},f),{anonymous_id:Un()}));let h=Vt();if(s.event==="IDENTIFY"&&r&&f.anonymous_id){let g=s.properties,w=yield r.identify({email:(l=g.email)!=null?l:g.identifier,firstName:g.first_name,lastName:g.last_name,phone:g.phone_number,anonymousId:f.anonymous_id,source:"sdk"});w!=null&&w.candidateId&&(h=w.candidateId,Ut(w.candidateId))}let p={anonymous_id:f.anonymous_id,session_id:f.session_id,candidate_id:h,event:s.event,sent_at:new Date().toISOString(),context:u,properties:s.properties,custom_properties:s.customProperties},x=()=>{var g,w;return(w=(g=Jn.exec(document.cookie))==null?void 0:g[1])!=null?w:null},k=typeof window!="undefined"?x():null,A=yield e.request(Kt,C({body:p},s.keepalive&&{keepalive:!0})),S=Jt(A);if(S!=null&&S.anonymous_id&&(p.anonymous_id=S.anonymous_id),S!=null&&S.session_id&&(p.session_id=S.session_id),typeof window!="undefined"&&p.anonymous_id){let g=x(),w=g!==null&&g!==k;p.session_id&&!w&&sessionStorage.setItem(`${H}-session_id`,p.session_id.toString()),document.cookie=on(w?g:p.anonymous_id)}return n==null||n(p),{success:!0,data:p}}catch(u){return t.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:u}}}),getHeaders:s=>{let a=new Headers;return s!=null&&s.anonymous_id&&a.append("Set-Cookie",on(s.anonymous_id)),a},getSessionInfo:Oe});function sn({publishableKey:e,env:t,logger:n=Fe,onEvent:r}){let o=yn({baseUrl:be[t],publishableKey:e}),s=n===!1?qe:n,a=new ae({environment:t,apiKey:{type:"publishable",key:e},logger:s}),l=nn({environment:t,publishableKey:e,logger:s}),u=zn({rpcClient:a,logger:s,onEvent:r,talentBank:l});return{register:h=>h({logger:s,apiClient:o,analytics:u,rpcClient:a,publishableKey:e,env:t}),analytics:u,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=sn;window.inploi.ready=rn;})();
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ResponseObj } from '@inploi/core/common';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
+ import * as v from 'valibot';
3
4
 
4
5
  type LogMessage = (...data: any[]) => void;
5
6
  type Logger = {
@@ -80,6 +81,60 @@ type JobProperties = {
80
81
  id: string;
81
82
  id_type: 'internal' | 'external';
82
83
  };
84
+ /**
85
+ * One question on a candidate's path through an application, in a `FLOW_NODE` summary. Keys, positions, input types,
86
+ * timings and counts only: never an answer, a file or any text the candidate typed.
87
+ */
88
+ type FlowPathStep = {
89
+ /** The question's key in the flow (its submission key). */
90
+ k?: string;
91
+ /** 1-based position on this session's path. */
92
+ i: number;
93
+ /** The question's input type, e.g. `text`, `enum`, `file`. */
94
+ t: string;
95
+ /** Milliseconds from the question being shown to it being answered or skipped. */
96
+ ms?: number;
97
+ /** `a` answered, `s` skipped; absent while it waits. */
98
+ o?: 'a' | 's';
99
+ /** How many times a refusal (validation) appeared on it; repeated refusals behind one visible message count once. */
100
+ e?: number;
101
+ /** How many times it was changed at review. */
102
+ r?: number;
103
+ };
104
+ /** Why a path summary was sent: the moments a session can end or pause. */
105
+ type FlowPathTrigger = 'submit' | 'redirect' | 'minimise' | 'hidden' | 'pagehide' | 'restart';
106
+ /**
107
+ * `FLOW_NODE`, the Candidate Agent's application path summary: sent when a session pauses or ends and its path has
108
+ * changed since the last summary, never per step, so a session costs a few rows. The latest by `sent_at` per `flow_session_id` is the whole path so far.
109
+ */
110
+ type FlowPathProperties = FunnelFlowProperties & {
111
+ job: JobProperties | undefined;
112
+ trigger: FlowPathTrigger;
113
+ steps: FlowPathStep[];
114
+ /** The earliest steps left out to keep the summary within the api's size limit; the latest are always kept. */
115
+ steps_omitted?: number;
116
+ /** The node the candidate was on when it was sent. */
117
+ to_node_id?: string;
118
+ /** Milliseconds since the candidate's own last action (answer, skip, refusal, edit, typing, a CV, the redirect click). */
119
+ idle_ms: number;
120
+ submit_attempts: number;
121
+ /** The last attempt's outcome: `success`, `redirect`, `pending`, `failed` or the failure's outcome. */
122
+ submit_result?: string;
123
+ /** The widget's CV invitation before the first question; a CV question is a step whose `t` is `file`. */
124
+ cv?: 'offered' | 'attached';
125
+ /** The device class, never a user agent: a coarse (touch) or fine pointer, and the screen width's bucket. */
126
+ device: {
127
+ pointer: 'coarse' | 'fine';
128
+ width: 'xs' | 's' | 'm' | 'l';
129
+ };
130
+ /** The candidate opened the employer's link after submitting (a redirect such as TribePad's). */
131
+ redirect_clicked?: true;
132
+ /** Milliseconds from the redirect's submit result to the click; absent on a revisit, whose submit was earlier. */
133
+ redirect_ms?: number;
134
+ /** The click came on a later visit, from the link restored with the conversation. */
135
+ redirect_revisit?: true;
136
+ agent_conversation_key?: string;
137
+ };
83
138
  type AnalyticsLogParams = {
84
139
  event: 'VIEW_JOB';
85
140
  properties: {
@@ -101,10 +156,15 @@ type AnalyticsLogParams = {
101
156
  properties: {
102
157
  job: JobProperties | undefined;
103
158
  } & FlowProperties;
159
+ } | {
160
+ event: 'FLOW_NODE';
161
+ properties: FlowPathProperties;
104
162
  } | {
105
163
  event: 'FLOW_SUBMIT';
106
164
  properties: {
107
165
  service: string;
166
+ /** Confirmed first-apply capture, even when downstream delivery failed. */
167
+ captured?: boolean;
108
168
  response: {
109
169
  status: number;
110
170
  payload: unknown;
@@ -227,6 +287,8 @@ type LogFnParams<T extends keyof EventPropertyMap> = {
227
287
  customProperties?: Record<string, unknown>;
228
288
  /** Passing a request will make logging possible on a server environment. */
229
289
  request?: Request;
290
+ /** Sent so it survives the page being left (`fetch` keepalive): for a summary sent on pagehide. */
291
+ keepalive?: boolean;
230
292
  } & EventPropertyMap[T];
231
293
  type LogFn = <TEvent extends keyof EventPropertyMap>(params: LogFnParams<TEvent>) => Promise<ResponseObj<TrackPayload<EventPropertyMap[TEvent]['properties']>>>;
232
294
  type AnalyticsService = {
@@ -337,6 +399,8 @@ declare class InploiRpcClient {
337
399
  params: TPathParams;
338
400
  }> & {
339
401
  signal?: AbortSignal;
402
+ /** Lets the request outlive the page (`fetch` keepalive), for a last analytics event on pagehide. */
403
+ keepalive?: boolean;
340
404
  /**
341
405
  * Whether to validate the inputs against the schema.
342
406
  * If you want to skip validation (e.g.: already validated yourself or with `validateEndpontInputs`), set this to false.
@@ -373,6 +437,8 @@ declare class InploiRpcClient {
373
437
  params: TPathParams;
374
438
  }> & {
375
439
  signal?: AbortSignal;
440
+ /** Lets the request outlive the page (`fetch` keepalive), for a last analytics event on pagehide. */
441
+ keepalive?: boolean;
376
442
  /**
377
443
  * Whether to validate the inputs against the schema.
378
444
  * If you want to skip validation (e.g.: already validated yourself or with `validateEndpontInputs`), set this to false.
@@ -541,4 +607,47 @@ declare const generateUUID: () => `${string}-${string}-${string}-${string}-${str
541
607
 
542
608
  declare function ready(callback: () => void): void;
543
609
 
544
- export { AnalyticsLogEvent, AnalyticsLogParams, AnalyticsOnEventCallback, AnalyticsService, ApiClient, ApiError, ConsentConfig, FlowType, InitialiseInploiSdkParams, InploiRpcClient, InploiSdk, InploiSdkEnvironment, InploiSdkPlugin, Logger, NotFoundError, JsonParsingError as ParsingError, PluginParams, RpcEndpoint, SchemaValidationError, SdkError, TalentBankCheckDuplicateResult, TalentBankClient, TalentBankIdentifyParams, TalentBankIdentifyResult, UnauthorisedError, consentStorageKey, createPlugin, createTalentBankClient, endpoint, generateUUID, getConsentAcceptance, getOrCreateAnonymousId, hashConsentConfig, initialiseSdk, inploiBrandedLogger, isApiErrorWithData, isSdkError, noLogging, ready, setConsentAcceptance, typed, validateEndpointInputs };
610
+ declare const JOB_ALERT_FREQUENCIES: readonly ["DAILY", "WEEKLY", "MONTHLY"];
611
+ /** A saved search: each filter's values and, for a search around a place, the place and radius in metres
612
+ * (the API's alert engine matches jobs within it), with the unit and place name the candidate saw. */
613
+ declare const alertFiltersSchema: v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ObjectSchema<{
614
+ readonly type: v.LiteralSchema<"provided", undefined>;
615
+ readonly lat: v.NumberSchema<undefined>;
616
+ readonly lng: v.NumberSchema<undefined>;
617
+ readonly radius: v.NumberSchema<undefined>;
618
+ readonly unit: v.OptionalSchema<v.PicklistSchema<["miles", "km"], undefined>, undefined>;
619
+ readonly label: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
620
+ }, undefined>], undefined>, undefined>;
621
+ type JobAlertsFilters = v.InferInput<typeof alertFiltersSchema>;
622
+ /** Save alerts only after the candidate opts in; a failed lookup must never widen the search. */
623
+ declare function saveClosedRoleJobAlerts(rpcClient: InploiRpcClient, { contact, job, }: {
624
+ contact: {
625
+ email: string;
626
+ first_name?: string;
627
+ last_name?: string;
628
+ };
629
+ job?: {
630
+ id: string;
631
+ id_type: 'internal' | 'external';
632
+ };
633
+ }): Promise<void>;
634
+ declare const saveSearchEndpoint: RpcEndpoint<"POST", "/search/save", Record<string, never>, never, {
635
+ contact: {
636
+ email?: string | undefined;
637
+ first_name?: string | undefined;
638
+ last_name?: string | undefined;
639
+ };
640
+ alerts?: string | undefined;
641
+ filters: {
642
+ [x: string]: string | string[] | {
643
+ type: "provided";
644
+ lat: number;
645
+ lng: number;
646
+ radius: number;
647
+ unit?: "miles" | "km" | undefined;
648
+ label?: string | undefined;
649
+ };
650
+ };
651
+ }, void>;
652
+
653
+ export { AnalyticsLogEvent, AnalyticsLogParams, AnalyticsOnEventCallback, AnalyticsService, ApiClient, ApiError, ConsentConfig, FlowPathProperties, FlowPathStep, FlowPathTrigger, FlowType, InitialiseInploiSdkParams, InploiRpcClient, InploiSdk, InploiSdkEnvironment, InploiSdkPlugin, JOB_ALERT_FREQUENCIES, JobAlertsFilters, Logger, NotFoundError, JsonParsingError as ParsingError, PluginParams, RpcEndpoint, SchemaValidationError, SdkError, TalentBankCheckDuplicateResult, TalentBankClient, TalentBankIdentifyParams, TalentBankIdentifyResult, UnauthorisedError, consentStorageKey, createPlugin, createTalentBankClient, endpoint, generateUUID, getConsentAcceptance, getOrCreateAnonymousId, hashConsentConfig, initialiseSdk, inploiBrandedLogger, isApiErrorWithData, isSdkError, noLogging, ready, saveClosedRoleJobAlerts, saveSearchEndpoint, setConsentAcceptance, typed, validateEndpointInputs };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ResponseObj } from '@inploi/core/common';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
+ import * as v from 'valibot';
3
4
 
4
5
  type LogMessage = (...data: any[]) => void;
5
6
  type Logger = {
@@ -80,6 +81,60 @@ type JobProperties = {
80
81
  id: string;
81
82
  id_type: 'internal' | 'external';
82
83
  };
84
+ /**
85
+ * One question on a candidate's path through an application, in a `FLOW_NODE` summary. Keys, positions, input types,
86
+ * timings and counts only: never an answer, a file or any text the candidate typed.
87
+ */
88
+ type FlowPathStep = {
89
+ /** The question's key in the flow (its submission key). */
90
+ k?: string;
91
+ /** 1-based position on this session's path. */
92
+ i: number;
93
+ /** The question's input type, e.g. `text`, `enum`, `file`. */
94
+ t: string;
95
+ /** Milliseconds from the question being shown to it being answered or skipped. */
96
+ ms?: number;
97
+ /** `a` answered, `s` skipped; absent while it waits. */
98
+ o?: 'a' | 's';
99
+ /** How many times a refusal (validation) appeared on it; repeated refusals behind one visible message count once. */
100
+ e?: number;
101
+ /** How many times it was changed at review. */
102
+ r?: number;
103
+ };
104
+ /** Why a path summary was sent: the moments a session can end or pause. */
105
+ type FlowPathTrigger = 'submit' | 'redirect' | 'minimise' | 'hidden' | 'pagehide' | 'restart';
106
+ /**
107
+ * `FLOW_NODE`, the Candidate Agent's application path summary: sent when a session pauses or ends and its path has
108
+ * changed since the last summary, never per step, so a session costs a few rows. The latest by `sent_at` per `flow_session_id` is the whole path so far.
109
+ */
110
+ type FlowPathProperties = FunnelFlowProperties & {
111
+ job: JobProperties | undefined;
112
+ trigger: FlowPathTrigger;
113
+ steps: FlowPathStep[];
114
+ /** The earliest steps left out to keep the summary within the api's size limit; the latest are always kept. */
115
+ steps_omitted?: number;
116
+ /** The node the candidate was on when it was sent. */
117
+ to_node_id?: string;
118
+ /** Milliseconds since the candidate's own last action (answer, skip, refusal, edit, typing, a CV, the redirect click). */
119
+ idle_ms: number;
120
+ submit_attempts: number;
121
+ /** The last attempt's outcome: `success`, `redirect`, `pending`, `failed` or the failure's outcome. */
122
+ submit_result?: string;
123
+ /** The widget's CV invitation before the first question; a CV question is a step whose `t` is `file`. */
124
+ cv?: 'offered' | 'attached';
125
+ /** The device class, never a user agent: a coarse (touch) or fine pointer, and the screen width's bucket. */
126
+ device: {
127
+ pointer: 'coarse' | 'fine';
128
+ width: 'xs' | 's' | 'm' | 'l';
129
+ };
130
+ /** The candidate opened the employer's link after submitting (a redirect such as TribePad's). */
131
+ redirect_clicked?: true;
132
+ /** Milliseconds from the redirect's submit result to the click; absent on a revisit, whose submit was earlier. */
133
+ redirect_ms?: number;
134
+ /** The click came on a later visit, from the link restored with the conversation. */
135
+ redirect_revisit?: true;
136
+ agent_conversation_key?: string;
137
+ };
83
138
  type AnalyticsLogParams = {
84
139
  event: 'VIEW_JOB';
85
140
  properties: {
@@ -101,10 +156,15 @@ type AnalyticsLogParams = {
101
156
  properties: {
102
157
  job: JobProperties | undefined;
103
158
  } & FlowProperties;
159
+ } | {
160
+ event: 'FLOW_NODE';
161
+ properties: FlowPathProperties;
104
162
  } | {
105
163
  event: 'FLOW_SUBMIT';
106
164
  properties: {
107
165
  service: string;
166
+ /** Confirmed first-apply capture, even when downstream delivery failed. */
167
+ captured?: boolean;
108
168
  response: {
109
169
  status: number;
110
170
  payload: unknown;
@@ -227,6 +287,8 @@ type LogFnParams<T extends keyof EventPropertyMap> = {
227
287
  customProperties?: Record<string, unknown>;
228
288
  /** Passing a request will make logging possible on a server environment. */
229
289
  request?: Request;
290
+ /** Sent so it survives the page being left (`fetch` keepalive): for a summary sent on pagehide. */
291
+ keepalive?: boolean;
230
292
  } & EventPropertyMap[T];
231
293
  type LogFn = <TEvent extends keyof EventPropertyMap>(params: LogFnParams<TEvent>) => Promise<ResponseObj<TrackPayload<EventPropertyMap[TEvent]['properties']>>>;
232
294
  type AnalyticsService = {
@@ -337,6 +399,8 @@ declare class InploiRpcClient {
337
399
  params: TPathParams;
338
400
  }> & {
339
401
  signal?: AbortSignal;
402
+ /** Lets the request outlive the page (`fetch` keepalive), for a last analytics event on pagehide. */
403
+ keepalive?: boolean;
340
404
  /**
341
405
  * Whether to validate the inputs against the schema.
342
406
  * If you want to skip validation (e.g.: already validated yourself or with `validateEndpontInputs`), set this to false.
@@ -373,6 +437,8 @@ declare class InploiRpcClient {
373
437
  params: TPathParams;
374
438
  }> & {
375
439
  signal?: AbortSignal;
440
+ /** Lets the request outlive the page (`fetch` keepalive), for a last analytics event on pagehide. */
441
+ keepalive?: boolean;
376
442
  /**
377
443
  * Whether to validate the inputs against the schema.
378
444
  * If you want to skip validation (e.g.: already validated yourself or with `validateEndpontInputs`), set this to false.
@@ -541,4 +607,47 @@ declare const generateUUID: () => `${string}-${string}-${string}-${string}-${str
541
607
 
542
608
  declare function ready(callback: () => void): void;
543
609
 
544
- export { AnalyticsLogEvent, AnalyticsLogParams, AnalyticsOnEventCallback, AnalyticsService, ApiClient, ApiError, ConsentConfig, FlowType, InitialiseInploiSdkParams, InploiRpcClient, InploiSdk, InploiSdkEnvironment, InploiSdkPlugin, Logger, NotFoundError, JsonParsingError as ParsingError, PluginParams, RpcEndpoint, SchemaValidationError, SdkError, TalentBankCheckDuplicateResult, TalentBankClient, TalentBankIdentifyParams, TalentBankIdentifyResult, UnauthorisedError, consentStorageKey, createPlugin, createTalentBankClient, endpoint, generateUUID, getConsentAcceptance, getOrCreateAnonymousId, hashConsentConfig, initialiseSdk, inploiBrandedLogger, isApiErrorWithData, isSdkError, noLogging, ready, setConsentAcceptance, typed, validateEndpointInputs };
610
+ declare const JOB_ALERT_FREQUENCIES: readonly ["DAILY", "WEEKLY", "MONTHLY"];
611
+ /** A saved search: each filter's values and, for a search around a place, the place and radius in metres
612
+ * (the API's alert engine matches jobs within it), with the unit and place name the candidate saw. */
613
+ declare const alertFiltersSchema: v.RecordSchema<v.StringSchema<undefined>, v.UnionSchema<[v.StringSchema<undefined>, v.ArraySchema<v.StringSchema<undefined>, undefined>, v.ObjectSchema<{
614
+ readonly type: v.LiteralSchema<"provided", undefined>;
615
+ readonly lat: v.NumberSchema<undefined>;
616
+ readonly lng: v.NumberSchema<undefined>;
617
+ readonly radius: v.NumberSchema<undefined>;
618
+ readonly unit: v.OptionalSchema<v.PicklistSchema<["miles", "km"], undefined>, undefined>;
619
+ readonly label: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
620
+ }, undefined>], undefined>, undefined>;
621
+ type JobAlertsFilters = v.InferInput<typeof alertFiltersSchema>;
622
+ /** Save alerts only after the candidate opts in; a failed lookup must never widen the search. */
623
+ declare function saveClosedRoleJobAlerts(rpcClient: InploiRpcClient, { contact, job, }: {
624
+ contact: {
625
+ email: string;
626
+ first_name?: string;
627
+ last_name?: string;
628
+ };
629
+ job?: {
630
+ id: string;
631
+ id_type: 'internal' | 'external';
632
+ };
633
+ }): Promise<void>;
634
+ declare const saveSearchEndpoint: RpcEndpoint<"POST", "/search/save", Record<string, never>, never, {
635
+ contact: {
636
+ email?: string | undefined;
637
+ first_name?: string | undefined;
638
+ last_name?: string | undefined;
639
+ };
640
+ alerts?: string | undefined;
641
+ filters: {
642
+ [x: string]: string | string[] | {
643
+ type: "provided";
644
+ lat: number;
645
+ lng: number;
646
+ radius: number;
647
+ unit?: "miles" | "km" | undefined;
648
+ label?: string | undefined;
649
+ };
650
+ };
651
+ }, void>;
652
+
653
+ export { AnalyticsLogEvent, AnalyticsLogParams, AnalyticsOnEventCallback, AnalyticsService, ApiClient, ApiError, ConsentConfig, FlowPathProperties, FlowPathStep, FlowPathTrigger, FlowType, InitialiseInploiSdkParams, InploiRpcClient, InploiSdk, InploiSdkEnvironment, InploiSdkPlugin, JOB_ALERT_FREQUENCIES, JobAlertsFilters, Logger, NotFoundError, JsonParsingError as ParsingError, PluginParams, RpcEndpoint, SchemaValidationError, SdkError, TalentBankCheckDuplicateResult, TalentBankClient, TalentBankIdentifyParams, TalentBankIdentifyResult, UnauthorisedError, consentStorageKey, createPlugin, createTalentBankClient, endpoint, generateUUID, getConsentAcceptance, getOrCreateAnonymousId, hashConsentConfig, initialiseSdk, inploiBrandedLogger, isApiErrorWithData, isSdkError, noLogging, ready, saveClosedRoleJobAlerts, saveSearchEndpoint, setConsentAcceptance, typed, validateEndpointInputs };