@inploi/sdk 2.4.1 → 2.5.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 +35 -7
- package/cdn/index.js +1 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,6 +24,34 @@ const sdk = initialiseSdk({
|
|
|
24
24
|
});
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
### Analytics persistence
|
|
28
|
+
|
|
29
|
+
For analytics without device identity storage, initialise with `persistence: 'none'`.
|
|
30
|
+
Every event is still sent, with null `anonymous_id` and `candidate_id`. Analytics
|
|
31
|
+
does not read or write cookies, localStorage or sessionStorage, and ignores URL
|
|
32
|
+
identity handoffs. Non-empty API `/log` session ids stay in this SDK instance's
|
|
33
|
+
memory; subsequent events and `analytics.getSessionInfo()` use the current id for
|
|
34
|
+
same-document flow submissions. A replacement minted by the API updates that id;
|
|
35
|
+
late responses to earlier requests and echoed old ids cannot overwrite it.
|
|
36
|
+
First events wait for the initial response so concurrent calls share the session.
|
|
37
|
+
Keepalive events and `FLOW_NODE` summaries with a `pagehide` or `hidden` trigger
|
|
38
|
+
send immediately with fetch keepalive, using a null session if none is known yet.
|
|
39
|
+
The API may mint a separate session for those exit events. Page URL, title and
|
|
40
|
+
referrer are captured when `log()` is called, including for queued events.
|
|
41
|
+
A new instance or hard navigation starts over.
|
|
42
|
+
Explicit server `request` logs stay isolated and never adopt the browser session
|
|
43
|
+
or return a `Set-Cookie` header.
|
|
44
|
+
|
|
45
|
+
`IDENTIFY` still writes to Talent Bank using a fresh, unpersisted id for that
|
|
46
|
+
single identify call. Its candidate id is not retained or attached to analytics.
|
|
47
|
+
Job-alert subscriptions remain independent server writes. The default,
|
|
48
|
+
`persistence: 'device'`, preserves existing analytics behaviour.
|
|
49
|
+
|
|
50
|
+
This option covers analytics only. Hosts own consent changes, clearing previously
|
|
51
|
+
stored identifiers, experiment cookies and rollout seeds, and replacing their SDK
|
|
52
|
+
instance when the persistence choice changes. Direct plugin storage and calls to
|
|
53
|
+
`getOrCreateAnonymousId` (including Kin/Ask identity) are outside this option.
|
|
54
|
+
|
|
27
55
|
## Plugins
|
|
28
56
|
|
|
29
57
|
The root exports `saveSearchEndpoint`, `JobAlertsFilters` and
|
|
@@ -39,7 +67,9 @@ You can write custom plugins via the `createPlugin` function. The plugin receive
|
|
|
39
67
|
Example:
|
|
40
68
|
|
|
41
69
|
```javascript
|
|
42
|
-
|
|
70
|
+
import { createPlugin } from '@inploi/sdk';
|
|
71
|
+
|
|
72
|
+
export const myCounterPlugin = createPlugin(({ logger }) => {
|
|
43
73
|
let count = 0;
|
|
44
74
|
logger.info('myCounterPlugin initialised');
|
|
45
75
|
|
|
@@ -57,7 +87,7 @@ export const myCounterPlugin = createPlugin(({ logger, apiClient }) => {
|
|
|
57
87
|
|
|
58
88
|
If your plugin requires external dependencies, you may want to wrap the `createPlugin` function with whatever it takes, to then generate a function that returns a plugin:
|
|
59
89
|
|
|
60
|
-
```
|
|
90
|
+
```ts
|
|
61
91
|
import { createPlugin } from '@inploi/sdk';
|
|
62
92
|
|
|
63
93
|
type CounterExternalDeps = {onUpdate: (newCounter: number) => void};
|
|
@@ -80,7 +110,7 @@ export const myCounterPlugin = ({onUpdate}: CounterExternalDeps) =>
|
|
|
80
110
|
|
|
81
111
|
## Using plugins
|
|
82
112
|
|
|
83
|
-
Register
|
|
113
|
+
Register the factory from the previous example with `sdk.register`. The plugin receives its declared services
|
|
84
114
|
and the returned object is exposed to the caller.
|
|
85
115
|
|
|
86
116
|
```javascript
|
|
@@ -89,9 +119,7 @@ const sdk = initialiseSdk({
|
|
|
89
119
|
env: 'sandbox',
|
|
90
120
|
});
|
|
91
121
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
const myCounterPlugin = sdk.register(myPluginWithDeps({ onUpdate: newCounter => console.log(newCounter) }));
|
|
122
|
+
const counter = sdk.register(myCounterPlugin({ onUpdate: newCounter => console.log(newCounter) }));
|
|
95
123
|
|
|
96
|
-
|
|
124
|
+
counter.add();
|
|
97
125
|
```
|
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 Wn=Object.defineProperty,Hn=Object.defineProperties;var Xn=Object.getOwnPropertyDescriptors;var fn=Object.getOwnPropertySymbols;var Yn=Object.prototype.hasOwnProperty,$n=Object.prototype.propertyIsEnumerable;var yn=(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)&&yn(e,n,t[n]);if(fn)for(var n of fn(t))$n.call(t,n)&&yn(e,n,t[n]);return e},K=(e,t)=>Hn(e,Xn(t));var N=(e,t,n)=>new Promise((r,u)=>{var s=o=>{try{c(n.next(o))}catch(f){u(f)}},a=o=>{try{c(n.throw(o))}catch(f){u(f)}},c=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,a);c((n=n.apply(e,t)).next())});function Le(e,t){if(!e)throw new Error(t)}function ee(e,t){return t in e}var nr=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.",X=class extends Error{constructor(n,r){super(n);this.status=r,this.name="ErrorWithStatus"}},ue=class extends X{constructor(t){super(t!=null?t:"Not found"),this.name="NotFoundError",this.status=404}},ae=class extends X{constructor(t,n){super(t!=null?t:"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=n!=null?n:401}},H=class extends X{constructor(n,r){let u=r?` in ${r}`:"";super(`Schema validation failed${u}`);this.issues=n;this.source=r;this.name="SchemaValidationError",this.status=400}},ge=class extends X{constructor(n,r,u){super(n);this.data=u;this.name="ApiError",this.status=r!=null?r:500}};var le=class extends X{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 le(e);return e.json().catch(()=>{throw new le(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(ee(e,n)){let r=e[n];typeof r=="string"&&t.push(r),Array.isArray(r)&&r.every(u=>typeof u=="string")&&t.push(...r)}ee(e,"integration_response")&&typeof e.integration_response=="object"&&e.integration_response!==null&&ee(e.integration_response,"error")&&typeof e.integration_response.error=="object"&&e.integration_response.error!==null&&ee(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 ue(n):n===Zn?new ae("You are not authenticated.",t):n===Qn?new ae(n,t):new ge(n,t,e)}}var hn=e=>{let t={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(u,...s)=>N(void 0,[u,...s],function*(n,r={}){let a=K(C({},r),{headers:C(C({},r.headers),t)}),c=yield fetch(`${e.baseUrl}${n}`,a);if(c.status===404)throw new ue;let o=yield Me(c);return Ge(o,c.status),o})}};var mn="2.4.1";var be={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},dn={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},vn=mn;var Y="isdk_session",ke=`${Y}-candidate_id`,rt=`${Y}-consent`;var Ue="RFC3986",Je={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:e=>String(e)},it="RFC1738";var st=Array.isArray,B=(()=>{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,u)=>{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(c){return"%26%23"+parseInt(c.slice(2),16)+"%3B"});let a="";for(let c=0;c<s.length;c+=Be){let o=s.length>=Be?s.slice(c,c+Be):s,f=[];for(let h=0;h<o.length;++h){let p=o.charCodeAt(h);if(p===45||p===46||p===95||p===126||p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||u===it&&(p===40||p===41)){f[f.length]=o.charAt(h);continue}if(p<128){f[f.length]=B[p];continue}if(p<2048){f[f.length]=B[192|p>>6]+B[128|p&63];continue}if(p<55296||p>=57344){f[f.length]=B[224|p>>12]+B[128|p>>6&63]+B[128|p&63];continue}h+=1,p=65536+((p&1023)<<10|o.charCodeAt(h)&1023),f[f.length]=B[240|p>>18]+B[128|p>>12&63]+B[128|p>>6&63]+B[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 gn(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 yr=Array.isArray;var at=Object.prototype.hasOwnProperty,bn={brackets(e){return String(e)+"[]"},comma:"comma",indices(e,t){return String(e)+"["+t+"]"},repeat(e){return String(e)}},V=Array.isArray,lt=Array.prototype.push,kn=function(e,t){lt.apply(e,V(t)?t:[t])},ct=Date.prototype.toISOString,T={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 _n(e,t,n,r,u,s,a,c,o,f,h,p,x,k,b,I,w,P){let v=e,M=P,G=0,an=!1;for(;(M=M.get(Ve))!==void 0&&!an;){let D=M.get(e);if(G+=1,typeof D!="undefined"){if(D===G)throw new RangeError("Cyclic object value");an=!0}typeof M.get(Ve)=="undefined"&&(G=0)}if(typeof f=="function"?v=f(t,v):v instanceof Date?v=x==null?void 0:x(v):n==="comma"&&V(v)&&(v=gn(v,function(D){return D instanceof Date?x==null?void 0:x(D):D})),v===null){if(s)return o&&!I?o(t,T.encoder,w,"key",k):t;v=""}if(pt(v)||ut(v)){if(o){let D=I?t:o(t,T.encoder,w,"key",k);return[(b==null?void 0:b(D))+"="+(b==null?void 0:b(o(v,T.encoder,w,"value",k)))]}return[(b==null?void 0:b(t))+"="+(b==null?void 0:b(String(v)))]}let Ce=[];if(typeof v=="undefined")return Ce;let oe;if(n==="comma"&&V(v))I&&o&&(v=gn(v,o)),oe=[{value:v.length>0?v.join(",")||null:void 0}];else if(V(f))oe=f;else{let D=Object.keys(v);oe=h?D.sort(h):D}let ln=c?String(t).replace(/\./g,"%2E"):String(t),me=r&&V(v)&&v.length===1?ln+"[]":ln;if(u&&V(v)&&v.length===0)return me+"[]";for(let D=0;D<oe.length;++D){let Q=oe[D],cn=typeof Q=="object"&&typeof Q.value!="undefined"?Q.value:v[Q];if(a&&cn===null)continue;let Ne=p&&c?Q.replace(/\./g,"%2E"):Q,zn=V(v)?typeof n=="function"?n(me,Ne):me:me+(p?"."+Ne:"["+Ne+"]");P.set(e,G);let pn=new WeakMap;pn.set(Ve,P),kn(Ce,_n(cn,zn,n,r,u,s,a,c,n==="comma"&&I&&V(v)?null:o,f,h,p,x,k,b,I,w,pn))}return Ce}function ft(e=T){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||T.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],u=T.filter;(typeof e.filter=="function"||V(e.filter))&&(u=e.filter);let s;if(e.arrayFormat&&e.arrayFormat in bn?s=e.arrayFormat:"indices"in e?s=e.indices?"indices":"repeat":s=T.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:T.allowDots:!!e.allowDots;return{addQueryPrefix:typeof e.addQueryPrefix=="boolean"?e.addQueryPrefix:T.addQueryPrefix,allowDots:a,allowEmptyArrays:typeof e.allowEmptyArrays=="boolean"?!!e.allowEmptyArrays:T.allowEmptyArrays,arrayFormat:s,charset:t,charsetSentinel:typeof e.charsetSentinel=="boolean"?e.charsetSentinel:T.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:typeof e.delimiter=="undefined"?T.delimiter:e.delimiter,encode:typeof e.encode=="boolean"?e.encode:T.encode,encodeDotInKeys:typeof e.encodeDotInKeys=="boolean"?e.encodeDotInKeys:T.encodeDotInKeys,encoder:typeof e.encoder=="function"?e.encoder:T.encoder,encodeValuesOnly:typeof e.encodeValuesOnly=="boolean"?e.encodeValuesOnly:T.encodeValuesOnly,filter:u,format:n,formatter:r,serializeDate:typeof e.serializeDate=="function"?e.serializeDate:T.serializeDate,skipNulls:typeof e.skipNulls=="boolean"?e.skipNulls:T.skipNulls,sort:typeof e.sort=="function"?e.sort:null,strictNullHandling:typeof e.strictNullHandling=="boolean"?e.strictNullHandling:T.strictNullHandling}}function xn(e,t={}){let n=e,r=ft(t),u,s;typeof r.filter=="function"?(s=r.filter,n=s("",n)):V(r.filter)&&(s=r.filter,u=s);let a=[];if(typeof n!="object"||n===null)return"";let c=bn[r.arrayFormat],o=c==="comma"&&r.commaRoundTrip;u||(u=Object.keys(n)),r.sort&&u.sort(r.sort);let f=new WeakMap;for(let x=0;x<u.length;++x){let k=u[x];r.skipNulls&&n[k]===null||kn(a,_n(n[k],k,c,o,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 Ke(e,t,n){let r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Async schema");if(r.issues)throw new H(r.issues,n);return r.value}function yt(e,t,n){try{return{success:!0,output:Ke(e,t,n)}}catch(r){if(r instanceof H)return{success:!1,issues:r.issues,source:r.source};throw r}}var ce=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 o;let r=(o=n.validateIn)!=null?o:!0,{searchParams:u,body:s}=r?En(t,n):n,a=new URL(this.baseUrl),c=t.pathname;if("params"in n&&n.params)for(let[f,h]of Object.entries(n.params))c=c.replace(`:${f}`,String(h));return a.pathname=c,t.schema.searchParams&&(a.search=xn(u)),[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 H(s.issues,s.source);return s.output})}request(t,n){return N(this,null,function*(){try{let r=this.getFetchParams(t,n),u=yield fetch(...r);return yield this.parseResponse(t,{response:u,validateOut:n.validateOut})}catch(r){throw r instanceof H?this.logger.error(r.message,r.issues):this.logger.error(r),r}})}};function ne(){return{"~standard":{vendor:"inploi",version:1,validate:e=>({value:e})}}}function En(e,t){let n={searchParams:void 0,body:void 0,validateIn:!1};return e.schema.searchParams&&(n.searchParams=Ke(e.schema.searchParams,"searchParams"in t?t.searchParams:{})),e.schema.body&&(n.body=Ke(e.schema.body,"body"in t?t.body:{})),n}var z;function Sn(e){var t,n,r;return{lang:(t=e==null?void 0:e.lang)!=null?t:z==null?void 0:z.lang,message:e==null?void 0:e.message,abortEarly:(n=e==null?void 0:e.abortEarly)!=null?n:z==null?void 0:z.abortEarly,abortPipeEarly:(r=e==null?void 0:e.abortPipeEarly)!=null?r:z==null?void 0:z.abortPipeEarly}}var ze;function ht(e){return ze==null?void 0:ze.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 $(e){var n,r,u;let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(u=e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))!=null?u:"null":t}function A(e,t,n,r,u){var p,x,k,b,I,w,P,v;let s=u&&"input"in u?u.input:n.value,a=(x=(p=u==null?void 0:u.expected)!=null?p:e.expects)!=null?x:null,c=(k=u==null?void 0:u.received)!=null?k:$(s),o={kind:e.kind,type:e.type,input:s,expected:a,received:c,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${c}`,requirement:e.requirement,path:u==null?void 0:u.path,issues:u==null?void 0:u.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},f=e.kind==="schema",h=(v=(P=(w=(I=(b=u==null?void 0:u.message)!=null?b:e.message)!=null?I:dt(e.reference,o.lang))!=null?w:f?mt(o.lang):null)!=null?P:r.message)!=null?v:ht(o.lang);h!==void 0&&(o.message=typeof h=="function"?h(o):h),f&&(n.typed=!1),n.issues?n.issues.push(o):n.issues=[o]}function R(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},Sn())}}}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,Er=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)&&A(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)&&A(this,"email",t,n),t}}}function te(e){return{kind:"validation",type:"integer",reference:te,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&A(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&&A(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():$(e)}`,requirement:e,message:t,"~run"(n,r){return n.typed&&!(n.value<=this.requirement)&&A(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():$(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&&A(this,"length",n,r,{received:`${n.value.length}`}),n}}}function re(e,t){return{kind:"validation",type:"min_value",reference:re,async:!1,expects:`>=${e instanceof Date?e.toJSON():$(e)}`,requirement:e,message:t,"~run"(n,r){return n.typed&&!(n.value>=this.requirement)&&A(this,"value",n,r,{received:n.value instanceof Date?n.value.toJSON():$(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 u=n.value;if(Array.isArray(u)){n.typed=!0,n.value=[];for(let a=0;a<u.length;a++){let c=u[a],o=this.item["~run"]({value:c},r);if(o.issues){let f={type:"array",origin:"value",input:u,key:a,value:c};for(let h of o.issues)h.path?h.path.unshift(f):h.path=[f],(s=n.issues)==null||s.push(h);if(n.issues||(n.issues=o.issues),r.abortEarly){n.typed=!1;break}}o.typed||(n.typed=!1),n.value.push(o.value)}}else A(this,"type",n,r);return n}}}function pe(e){return{kind:"schema",type:"boolean",reference:pe,expects:"boolean",async:!1,message:e,get"~standard"(){return R(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:A(this,"type",t,n),t}}}function _(e,t){return{kind:"schema",type:"literal",reference:_,expects:$(e),async:!1,literal:e,message:t,get"~standard"(){return R(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:A(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 g(e){return{kind:"schema",type:"number",reference:g,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:A(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 R(this)},"~run"(n,r){var s;let u=n.value;if(u&&typeof u=="object"){n.typed=!0,n.value={};for(let a in this.entries){let c=this.entries[a];if(a in u||(c.type==="exact_optional"||c.type==="optional"||c.type==="nullish")&&c.default!==void 0){let o=a in u?u[a]:we(c),f=c["~run"]({value:o},r);if(f.issues){let h={type:"object",origin:"value",input:u,key:a,value:o};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(c.fallback!==void 0)n.value[a]=bt(c);else if(c.type!=="exact_optional"&&c.type!=="optional"&&c.type!=="nullish"&&(A(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:u,key:a,value:u[a]}]}),r.abortEarly))break}}else A(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 S(e,t){return{kind:"schema",type:"picklist",reference:S,expects:Xe(e.map($),"|"),async:!1,options:e,message:t,get"~standard"(){return R(this)},"~run"(n,r){return this.options.includes(n.value)?n.typed=!0:A(this,"type",n,r),n}}}function U(e,t,n){return{kind:"schema",type:"record",reference:U,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return R(this)},"~run"(r,u){var a,c;let s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(let o in s)if(vt(s,o)){let f=s[o],h=this.key["~run"]({value:o},u);if(h.issues){let x={type:"object",origin:"key",input:s,key:o,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),u.abortEarly){r.typed=!1;break}}let p=this.value["~run"]({value:f},u);if(p.issues){let x={type:"object",origin:"value",input:s,key:o,value:f};for(let k of p.issues)k.path?k.path.unshift(x):k.path=[x],(c=r.issues)==null||c.push(k);if(r.issues||(r.issues=p.issues),u.abortEarly){r.typed=!1;break}}(!h.typed||!p.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=p.value)}}else A(this,"type",r,u);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:A(this,"type",t,n),t}}}function wn(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function fe(e,t){return{kind:"schema",type:"union",reference:fe,expects:Xe(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return R(this)},"~run"(n,r){let u,s,a;for(let c of this.options){let o=c["~run"]({value:n.value},r);if(o.typed)if(o.issues)s?s.push(o):s=[o];else{u=o;break}else a?a.push(o):a=[o]}if(u)return u;if(s){if(s.length===1)return s[0];A(this,"type",n,r,{issues:wn(s)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];A(this,"type",n,r,{issues:wn(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 ie(e,t,n){return{kind:"schema",type:"variant",reference:ie,expects:"Object",async:!1,key:e,options:t,message:n,get"~standard"(){return R(this)},"~run"(r,u){let s=r.value;if(s&&typeof s=="object"){let a,c=0,o=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 b=!0,I=0;for(let w of x){let P=k.entries[w];if(w in s?P["~run"]({typed:!1,value:s[w]},{abortEarly:!0}).issues:P.type!=="exact_optional"&&P.type!=="optional"&&P.type!=="nullish"){b=!1,o!==w&&(c<I||c===I&&w in s&&!(o in s))&&(c=I,o=w,f=[]),o===w&&f.push(k.entries[w].expects);break}I++}if(b){let w=k["~run"]({value:s},u);(!a||!a.typed&&w.typed)&&(a=w)}}if(a&&!a.issues)break}};if(h(this,new Set([this.key])),a)return a;A(this,"type",r,u,{input:s[o],expected:Xe(f,"|"),path:[{type:"object",origin:"value",input:s,key:o,value:s[o]}]})}else A(this,"type",r,u);return r}}}function E(...e){return K(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},Sn(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=S(kt),J=S(_t),F=E(i(),Ee(),j(1),_e(100)),Ie=S(xt),An=S(Et),Sr=S(wt),In=S(St),Tn=S(At),ye=E(i(),Ee(),j(1),_e(100)),Te=S(It),Pn=S(Tt),Dn=S(Pt);var L=ie("type",[l({type:_("user"),id:E(i(),j(1)),email:E(i(),j(1)),name:E(i(),j(1))}),l({type:_("system"),id:E(i(),j(1)),name:d(i())}),l({type:_("automation"),id:E(i(),j(1)),name:d(i())}),l({type:_("integration"),id:E(i(),j(1)),name:d(i())}),l({type:_("candidate"),id:E(i(),j(1)),email:d(i())})]);var Dt=l({total:g(),page:g(),perPage:g(),lastPage:g()});function Pe(e){return l({data:O(e),pagination:Dt})}var he=l({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 se=E(i(),j(1)),Rn=E(g(),te(),re(1)),W=U(i(),Qe());var jn=l({id:i(),applicationId:i(),status:An,scheduledAt:y(i()),completedAt:y(i()),meta:y(W),createdAt:i(),updatedAt:i()});var en=l({score:g(),reason:i(),confidence:g()}),On=l({id:i(),candidateId:i(),jobId:g(),stage:F,stageGroup:J,stageEnteredAt:i(),rating:y(g()),disqualifiedAt:y(i()),disqualificationReason:y(ye),disqualificationNote:y(i()),source:Te,sourceDetail:y(i()),sessionId:y(g()),externalApplicationId:y(i()),meta:y(W),context:y(W),scoredAt:y(i()),createdAt:i(),updatedAt:i()}),Rt=l({id:i(),applicationId:i(),scoreType:Ie,score:y(g()),reason:y(i()),categories:y(U(i(),en)),scoredBy:y(i()),createdAt:i()}),De=l(K(C({},On.entries),{candidate:y(he),score:y(Rt),interview:y(jn)})),jt=l(K(C({},he.entries),{applications:O(On)})),Cn=l({id:i(),applicationId:i(),action:Pn,fromStage:y(F),fromStageGroup:y(J),toStage:y(F),toStageGroup:y(J),disqualificationReason:y(ye),disqualificationNote:y(i()),actorId:y(i()),actorType:Dn,actorEmail:y(i()),actorName:y(i()),meta:y(W),schemaVersion:g(),createdAt:i()});var Nn=l({anonymousId:se,email:se,firstName:m(i()),lastName:m(i()),phone:m(i()),source:m(Ae)}),Ln=l({candidateId:i(),isNew:pe()});var Ot=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],je=S(Ot),Fn=E(i(),xe(e=>e.split(",").map(t=>t.trim()).filter(t=>t.length>0))),Ct=E(Fn,O(F)),Nt=E(Fn,O(J)),qn=E(i(),xe(e=>e.split(",").map(t=>Number(t.trim())).filter(t=>Number.isInteger(t)&&t>0))),Wr=l({stages:d(Ct),stage_groups:d(Nt),job_id:d(i()),job_ids:d(qn),candidate_id:d(i()),is_disqualified:d(S(["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(S(["true","false"])),sort:d(In),order:d(Tn),page:d(i()),per_page:d(i())}),Hr=E(l({candidateId:se,jobId:Rn,meta:m(W),sessionId:m(g()),externalApplicationId:m(i()),context:m(W),source:m(Te),sourceDetail:m(i()),stage:m(F),stageGroup:m(J),actor:m(L)}),Ye(e=>e.stage==null==(e.stageGroup==null),"stage and stageGroup must be supplied together")),Mn=l({id:i(),stageGroup:i(),createdAt:i()}),Xr=fe([l({ok:_(!0),duplicate:_(!1),applicationId:i(),candidateId:i()}),l({ok:_(!0),duplicate:_(!0),existingApplication:Mn})]),Gn=l({isDuplicate:pe(),existingApplication:d(Mn)}),Yr=l({applicationId:se,scoreType:Ie,score:g(),reason:m(i()),categories:m(U(i(),en)),scoredBy:m(i()),actor:m(L)}),$r=l({scoreId:i()}),Zr=Pe(De);var Qr=S(["already_in_target_stage","not_in_source_stage","disqualified"]),ei=O(Cn),Re=l({stage:m(F),note:m(i())}),Lt=l({stage:m(F),startDate:m(i()),note:m(i())}),Ft=ie("action",[l({action:_("shortlist"),actor:L,meta:m(Re)}),l({action:_("move_to_interview"),actor:L,meta:m(Re)}),l({action:_("make_offer"),actor:L,meta:m(Re)}),l({action:_("hire"),actor:L,meta:m(Lt)}),l({action:_("withdraw"),actor:L,meta:m(Re)}),l({action:_("move_to_stage"),actor:L,meta:l({stage:F,stageGroup:J,note:m(i())})}),l({action:_("stage_transition"),actor:L,meta:l({toStage:F,toStageGroup:J,note:m(i())})}),l({action:_("disqualify"),actor:L,meta:l({reason:ye,note:m(i())})}),l({action:_("reinstate"),actor:L,meta:l({toStage:F,toStageGroup:J,note:m(i())})}),l({action:_("rate"),actor:L,meta:l({rating:y(E(g(),te(),re(1),Ze(5)))})})]),ni=l({applicationIds:E(O(i()),j(1)),body:Ft}),Bn=S(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),ti=ie("kind",[l({kind:_("updated"),action:je,application:De}),l({kind:_("skipped"),action:je,applicationId:i(),reason:Bn})]),ri=l({updated:O(l({kind:_("updated"),action:je,application:De})),skipped:O(l({kind:_("skipped"),action:je,applicationId:i(),reason:Bn})),failed:O(l({applicationId:i(),error:i()}))}),Z=E(g(),te(),re(0)),qt=l({APPLIED:Z,SHORTLISTED:Z,INTERVIEWED:Z,OFFERED:Z,HIRED:Z,REJECTED:Z,WITHDRAWN:Z}),ii=l({job_ids:qn}),si=l({counts:U(i(),qt)});var ci=Pe(he);var fi=l({avg_score:y(g()),p90_score:y(g()),p85_score:y(g()),p80_score:y(g()),total_scores:g(),total_shortlists:g()});var nn=({environment:e,publishableKey:t,logger:n})=>{let r=dn[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 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 o=yield c.json(),f=Se(Gn,o);return f.success?f.output:(n.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof o=="object"&&o!=null&&typeof o.isDuplicate=="boolean"?{isDuplicate:o.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 c={email:s.email,firstName:s.firstName,lastName:s.lastName,phone:s.phone,anonymousId:s.anonymousId,source:(a=s.source)!=null?a:"sdk"},o=Se(Nn,c);if(!o.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(o.output)});if(!f.ok)return n.error(`[TalentBankClient] identify failed with status ${f.status}`),null;let h=Se(Ln,yield f.json());return h.success?h.output:(n.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return n.error("[TalentBankClient] identify failed:",c),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 Un=["DAILY","WEEKLY","MONTHLY"],Mt=U(i(),fe([i(),O(i()),l({type:_("provided"),lat:g(),lng:g(),radius:g(),unit:d(S(["miles","km"])),label:d(i())})])),Ni={pathname:"/job/:id",method:"GET",schema:{response:l({id:g(),external_id:m(i()),city:m(i()),town:m(i()),category:m(i())})}};var Gt={pathname:"/search/save",method:"POST",schema:{response:ne(),body:l({contact:l({email:E(d(i()),i(),$e()),first_name:d(i()),last_name:d(i())}),alerts:E(d(i()),i(),S(Un)),filters:Mt})}};var on=e=>{let t=new Date;return t.setTime(t.getTime()+7*24*60*60*1e3),`${Y}=${e};expires=${t.toUTCString()};path=/`},Bt=(e,t)=>{let n=e.get("session_id");if(t||n)return n;let r=sessionStorage.getItem(`${Y}-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){}},Jt=new RegExp(`(?:^|;\\s*)${Y}=([^;]+)`),un=e=>{var n,r;let t=e?e.headers.get("cookie"):document.cookie;return t&&(r=(n=Jt.exec(t))==null?void 0:n[1])!=null?r:null},Oe=e=>{var r;let t=e?e.url:location.href,{searchParams:n}=new URL(t);return{anonymous_id:(r=un(e))!=null?r:n.get("anonymous_id"),session_id:Bt(n,typeof window=="undefined")}},Jn=()=>{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)},Kt=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,Wt={pathname:"/log",method:"POST",schema:{response:ne(),body:ne()}},Kn=({rpcClient:e,logger:t,onEvent:n,talentBank:r})=>({log:s=>N(void 0,null,function*(){var c;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 o={library:{name:"inploi-sdk",version:vn},page:a},f=Oe(s.request);s.event==="IDENTIFY"&&!f.anonymous_id&&!s.request&&typeof window!="undefined"&&(f=K(C({},f),{anonymous_id:Jn()}));let h=Vt();if(s.event==="IDENTIFY"&&r&&f.anonymous_id){let M=s.properties,G=yield r.identify({email:(c=M.email)!=null?c:M.identifier,firstName:M.first_name,lastName:M.last_name,phone:M.phone_number,anonymousId:f.anonymous_id,source:"sdk"});G!=null&&G.candidateId&&(h=G.candidateId,Ut(G.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:o,properties:s.properties,custom_properties:s.customProperties},x=un(s.request),k=yield e.request(Wt,C({body:p},s.keepalive&&{keepalive:!0})),b=Kt(k),I=s.request?x:un(),w=I!==null&&I!==x,P=I!=null?I:x,v=!w&&(!P||!(b!=null&&b.anonymous_id)||P===b.anonymous_id);return v?(b!=null&&b.anonymous_id&&(p.anonymous_id=b.anonymous_id),b!=null&&b.session_id&&(p.session_id=b.session_id)):p.anonymous_id=P,!s.request&&typeof window!="undefined"&&p.anonymous_id&&(v&&p.session_id&&sessionStorage.setItem(`${Y}-session_id`,p.session_id.toString()),document.cookie=on(p.anonymous_id)),n==null||n(p),{success:!0,data:p}}catch(o){return t.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:o}}}),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 u=hn({baseUrl:be[t],publishableKey:e}),s=n===!1?qe:n,a=new ce({environment:t,apiKey:{type:"publishable",key:e},logger:s}),c=nn({environment:t,publishableKey:e,logger:s}),o=Kn({rpcClient:a,logger:s,onEvent:r,talentBank:c});return{register:h=>h({logger:s,apiClient:u,analytics:o,rpcClient:a,publishableKey:e,env:t}),analytics:o,apiClient:u}}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;})();
|
|
3
|
+
"use strict";(()=>{var Wn=Object.defineProperty,Hn=Object.defineProperties;var Xn=Object.getOwnPropertyDescriptors;var fn=Object.getOwnPropertySymbols;var Yn=Object.prototype.hasOwnProperty,$n=Object.prototype.propertyIsEnumerable;var yn=(e,t,n)=>t in e?Wn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Yn.call(t,n)&&yn(e,n,t[n]);if(fn)for(var n of fn(t))$n.call(t,n)&&yn(e,n,t[n]);return e},B=(e,t)=>Hn(e,Xn(t));var F=(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())});function Me(e,t){if(!e)throw new Error(t)}function se(e,t){return t in e}var nr=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var _e="%c[inploi SDK]",xe="color: #65BC67; font-weight: bold;",Ge={warn:(...e)=>console.warn(_e,xe,...e),error:(...e)=>console.error(_e,xe,...e),info:(...e)=>console.info(_e,xe,...e),log:(...e)=>console.log(_e,xe,...e)},Be={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Zn="Unauthenticated",Qn="This action is unauthorized.",ee=class extends Error{constructor(n,r){super(n);this.status=r,this.name="ErrorWithStatus"}},ye=class extends ee{constructor(t){super(t!=null?t:"Not found"),this.name="NotFoundError",this.status=404}},he=class extends ee{constructor(t,n){super(t!=null?t:"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=n!=null?n:401}},Q=class extends ee{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 ee{constructor(n,r,s){super(n);this.data=s;this.name="ApiError",this.status=r!=null?r:500}};var me=class extends ee{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 F(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 me(e);return e.json().catch(()=>{throw new me(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(se(e,n)){let r=e[n];typeof r=="string"&&t.push(r),Array.isArray(r)&&r.every(s=>typeof s=="string")&&t.push(...r)}se(e,"integration_response")&&typeof e.integration_response=="object"&&e.integration_response!==null&&se(e.integration_response,"error")&&typeof e.integration_response.error=="object"&&e.integration_response.error!==null&&se(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 Ue(e,t){if(t>=300){let n=nt(e);throw t===404?new ye(n):n===Zn?new he("You are not authenticated.",t):n===Qn?new he(n,t):new Ee(n,t,e)}}var hn=e=>{let t={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(s,...o)=>F(void 0,[s,...o],function*(n,r={}){let a=B(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 Ve(c);return Ue(u,c.status),u})}};var mn="2.5.0";var Se={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},dn={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},vn=mn;var ne="isdk_session",we=`${ne}-candidate_id`,rt=`${ne}-consent`;var ze="RFC3986",We={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:e=>String(e)},it="RFC1738";var st=Array.isArray,V=(()=>{let e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})();var Je=1024,ot=(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 m=0;m<u.length;++m){let y=u.charCodeAt(m);if(y===45||y===46||y===95||y===126||y>=48&&y<=57||y>=65&&y<=90||y>=97&&y<=122||s===it&&(y===40||y===41)){f[f.length]=u.charAt(m);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}m+=1,y=65536+((y&1023)<<10|u.charCodeAt(m)&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 ut(e){return!e||typeof e!="object"?!1:!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))}function gn(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 yr=Array.isArray;var at=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,lt=Array.prototype.push,kn=function(e,t){lt.apply(e,U(t)?t:[t])},ct=Date.prototype.toISOString,j={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:ot,encodeValuesOnly:!1,format:ze,formatter:We[ze],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 Ke={};function _n(e,t,n,r,s,o,a,c,u,f,m,y,p,v,E,T,w,P){let b=e,D=P,Y=0,pe=!1;for(;(D=D.get(Ke))!==void 0&&!pe;){let R=D.get(e);if(Y+=1,typeof R!="undefined"){if(R===Y)throw new RangeError("Cyclic object value");pe=!0}typeof D.get(Ke)=="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(R){return R instanceof Date?p==null?void 0:p(R):R})),b===null){if(o)return u&&!T?u(t,j.encoder,w,"key",v):t;b=""}if(pt(b)||ut(b)){if(u){let R=T?t:u(t,j.encoder,w,"key",v);return[(E==null?void 0:E(R))+"="+(E==null?void 0:E(u(b,j.encoder,w,"value",v)))]}return[(E==null?void 0:E(t))+"="+(E==null?void 0:E(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 R=Object.keys(b);x=m?R.sort(m):R}let $=c?String(t).replace(/\./g,"%2E"):String(t),ie=r&&U(b)&&b.length===1?$+"[]":$;if(s&&U(b)&&b.length===0)return ie+"[]";for(let R=0;R<x.length;++R){let z=x[R],Z=typeof z=="object"&&typeof z.value!="undefined"?z.value:b[z];if(a&&Z===null)continue;let W=y&&c?z.replace(/\./g,"%2E"):z,zn=U(b)?typeof n=="function"?n(ie,W):ie:ie+(y?"."+W:"["+W+"]");P.set(e,Y);let pn=new WeakMap;pn.set(Ke,P),kn(fe,_n(Z,zn,n,r,s,o,a,c,n==="comma"&&T&&U(b)?null:u,f,m,y,p,v,E,T,w,pn))}return fe}function ft(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=ze;if(typeof e.format!="undefined"){if(!at.call(We,e.format))throw new TypeError("Unknown format option provided.");n=e.format}let r=We[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=ft(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 m=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&"),m.length>0?y+m:""}function He(e,t,n){let r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Async schema");if(r.issues)throw new Q(r.issues,n);return r.value}function yt(e,t,n){try{return{success:!0,output:He(e,t,n)}}catch(r){if(r instanceof Q)return{success:!1,issues:r.issues,source:r.source};throw r}}var de=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?En(t,n):n,a=new URL(this.baseUrl),c=t.pathname;if("params"in n&&n.params)for(let[f,m]of Object.entries(n.params))c=c.replace(`:${f}`,String(m));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 F(this,null,function*(){var a;let r=yield Ve(n.response);if(Ue(r,n.response.status),!((a=n.validateOut)!=null?a:!0))return r;let o=yt(t.schema.response,r,"response");if(!o.success)throw new Q(o.issues,o.source);return o.output})}request(t,n){return F(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 Q?this.logger.error(r.message,r.issues):this.logger.error(r),r}})}};function oe(){return{"~standard":{vendor:"inploi",version:1,validate:e=>({value:e})}}}function En(e,t){let n={searchParams:void 0,body:void 0,validateIn:!1};return e.schema.searchParams&&(n.searchParams=He(e.schema.searchParams,"searchParams"in t?t.searchParams:{})),e.schema.body&&(n.body=He(e.schema.body,"body"in t?t.body:{})),n}var H;function wn(e){var t,n,r;return{lang:(t=e==null?void 0:e.lang)!=null?t:H==null?void 0:H.lang,message:e==null?void 0:e.message,abortEarly:(n=e==null?void 0:e.abortEarly)!=null?n:H==null?void 0:H.abortEarly,abortPipeEarly:(r=e==null?void 0:e.abortPipeEarly)!=null?r:H==null?void 0:H.abortPipeEarly}}var Xe;function ht(e){return Xe==null?void 0:Xe.get(e)}var Ye;function mt(e){return Ye==null?void 0:Ye.get(e)}var $e;function dt(e,t){var n;return(n=$e==null?void 0:$e.get(e))==null?void 0:n.get(t)}function te(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,E,T,w,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:te(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",m=(b=(P=(w=(T=(E=s==null?void 0:s.message)!=null?E:e.message)!=null?T:dt(e.reference,u.lang))!=null?w:f?mt(u.lang):null)!=null?P:r.message)!=null?b:ht(u.lang);m!==void 0&&(u.message=typeof m=="function"?m(u):m),f&&(n.typed=!1),n.issues?n.issues.push(u):n.issues=[u]}function C(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 Ze(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,Er=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 Qe(e,t){return{kind:"validation",type:"check",reference:Qe,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 en(e){return{kind:"validation",type:"email",reference:en,expects:null,async:!1,requirement:gt,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 Ae(e,t){return{kind:"validation",type:"max_length",reference:Ae,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 nn(e,t){return{kind:"validation",type:"max_value",reference:nn,async:!1,expects:`<=${e instanceof Date?e.toJSON():te(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():te(n.value)}),n}}}function N(e,t){return{kind:"validation",type:"min_length",reference:N,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():te(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():te(n.value)}),n}}}function Ie(e){return{kind:"transformation",type:"transform",reference:Ie,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function Te(){return{kind:"transformation",type:"trim",reference:Te,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 Pe(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function L(e,t){return{kind:"schema",type:"array",reference:L,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return C(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 m of u.issues)m.path?m.path.unshift(f):m.path=[f],(o=n.issues)==null||o.push(m);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 C(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:te(e),async:!1,literal:e,message:t,get"~standard"(){return C(this)},"~run"(n,r){return n.value===this.literal?n.typed=!0:I(this,"type",n,r),n}}}function h(e,t){return{kind:"schema",type:"nullable",reference:h,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,get"~standard"(){return C(this)},"~run"(n,r){return n.value===null&&(this.default!==void 0&&(n.value=Pe(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 C(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=Pe(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 C(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 C(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]:Pe(c),f=c["~run"]({value:u},r);if(f.issues){let m={type:"object",origin:"value",input:s,key:a,value:u};for(let y of f.issues)y.path?y.path.unshift(m):y.path=[m],(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]=bt(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 C(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=Pe(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:Ze(e.map(te),"|"),async:!1,options:e,message:t,get"~standard"(){return C(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 C(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(vt(o,u)){let f=o[u],m=this.key["~run"]({value:u},s);if(m.issues){let p={type:"object",origin:"key",input:o,key:u,value:f};for(let v of m.issues)v.path=[p],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=m.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}}(!m.typed||!y.typed)&&(r.typed=!1),m.typed&&(r.value[m.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 C(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)t?t.push(...n.issues):t=n.issues;return t}function ge(e,t){return{kind:"schema",type:"union",reference:ge,expects:Ze(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return C(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 tn(){return{kind:"schema",type:"unknown",reference:tn,expects:"unknown",async:!1,get"~standard"(){return C(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 C(this)},"~run"(r,s){let o=r.value;if(o&&typeof o=="object"){let a,c=0,u=this.key,f=[],m=(y,p)=>{for(let v of y.options){if(v.type==="variant")m(v,new Set(p).add(v.key));else{let E=!0,T=0;for(let w of p){let P=v.entries[w];if(w in o?P["~run"]({typed:!1,value:o[w]},{abortEarly:!0}).issues:P.type!=="exact_optional"&&P.type!=="optional"&&P.type!=="nullish"){E=!1,u!==w&&(c<T||c===T&&w in o&&!(u in o))&&(c=T,u=w,f=[]),u===w&&f.push(v.entries[w].expects);break}T++}if(E){let w=v["~run"]({value:o},s);(!a||!a.typed&&w.typed)&&(a=w)}}if(a&&!a.issues)break}};if(m(this,new Set([this.key])),a)return a;I(this,"type",r,s,{input:o[u],expected:Ze(f,"|"),path:[{type:"object",origin:"value",input:o,key:u,value:o[u]}]})}else I(this,"type",r,s);return r}}}function S(...e){return B(O({},e[0]),{pipe:e,get"~standard"(){return C(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},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"],St=["job","company"],wt=["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"],Re=A(kt),K=A(_t),M=S(i(),Te(),N(1),Ae(100)),je=A(xt),An=A(Et),wr=A(St),In=A(wt),Tn=A(At),be=S(i(),Te(),N(1),Ae(100)),Oe=A(It),Pn=A(Tt),Dn=A(Pt);var q=le("type",[l({type:_("user"),id:S(i(),N(1)),email:S(i(),N(1)),name:S(i(),N(1))}),l({type:_("system"),id:S(i(),N(1)),name:g(i())}),l({type:_("automation"),id:S(i(),N(1)),name:g(i())}),l({type:_("integration"),id:S(i(),N(1)),name:g(i())}),l({type:_("candidate"),id:S(i(),N(1)),email:g(i())})]);var Dt=l({total:k(),page:k(),perPage:k(),lastPage:k()});function Ce(e){return l({data:L(e),pagination:Dt})}var ke=l({id:i(),email:h(i()),firstName:h(i()),lastName:h(i()),phone:h(i()),source:h(Re),identifiedAt:h(i()),createdAt:i(),updatedAt:i()});var ce=S(i(),N(1)),Rn=S(k(),ue(),ae(1)),X=J(i(),tn());var jn=l({id:i(),applicationId:i(),status:An,scheduledAt:h(i()),completedAt:h(i()),meta:h(X),createdAt:i(),updatedAt:i()});var rn=l({score:k(),reason:i(),confidence:k()}),On=l({id:i(),candidateId:i(),jobId:k(),stage:M,stageGroup:K,stageEnteredAt:i(),rating:h(k()),disqualifiedAt:h(i()),disqualificationReason:h(be),disqualificationNote:h(i()),source:Oe,sourceDetail:h(i()),sessionId:h(k()),externalApplicationId:h(i()),meta:h(X),context:h(X),scoredAt:h(i()),createdAt:i(),updatedAt:i()}),Rt=l({id:i(),applicationId:i(),scoreType:je,score:h(k()),reason:h(i()),categories:h(J(i(),rn)),scoredBy:h(i()),createdAt:i()}),Ne=l(B(O({},On.entries),{candidate:h(ke),score:h(Rt),interview:h(jn)})),jt=l(B(O({},ke.entries),{applications:L(On)})),Cn=l({id:i(),applicationId:i(),action:Pn,fromStage:h(M),fromStageGroup:h(K),toStage:h(M),toStageGroup:h(K),disqualificationReason:h(be),disqualificationNote:h(i()),actorId:h(i()),actorType:Dn,actorEmail:h(i()),actorName:h(i()),meta:h(X),schemaVersion:k(),createdAt:i()});var Nn=l({anonymousId:ce,email:ce,firstName:d(i()),lastName:d(i()),phone:d(i()),source:d(Re)}),Ln=l({candidateId:i(),isNew:ve()});var Ot=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],Fe=A(Ot),Fn=S(i(),Ie(e=>e.split(",").map(t=>t.trim()).filter(t=>t.length>0))),Ct=S(Fn,L(M)),Nt=S(Fn,L(K)),qn=S(i(),Ie(e=>e.split(",").map(t=>Number(t.trim())).filter(t=>Number.isInteger(t)&&t>0))),Wr=l({stages:g(Ct),stage_groups:g(Nt),job_id:g(i()),job_ids:g(qn),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(In),order:g(Tn),page:g(i()),per_page:g(i())}),Hr=S(l({candidateId:ce,jobId:Rn,meta:d(X),sessionId:d(k()),externalApplicationId:d(i()),context:d(X),source:d(Oe),sourceDetail:d(i()),stage:d(M),stageGroup:d(K),actor:d(q)}),Qe(e=>e.stage==null==(e.stageGroup==null),"stage and stageGroup must be supplied together")),Mn=l({id:i(),stageGroup:i(),createdAt:i()}),Xr=ge([l({ok:_(!0),duplicate:_(!1),applicationId:i(),candidateId:i()}),l({ok:_(!0),duplicate:_(!0),existingApplication:Mn})]),Gn=l({isDuplicate:ve(),existingApplication:g(Mn)}),Yr=l({applicationId:ce,scoreType:je,score:k(),reason:d(i()),categories:d(J(i(),rn)),scoredBy:d(i()),actor:d(q)}),$r=l({scoreId:i()}),Zr=Ce(Ne);var Qr=A(["already_in_target_stage","not_in_source_stage","disqualified"]),ei=L(Cn),Le=l({stage:d(M),note:d(i())}),Lt=l({stage:d(M),startDate:d(i()),note:d(i())}),Ft=le("action",[l({action:_("shortlist"),actor:q,meta:d(Le)}),l({action:_("move_to_interview"),actor:q,meta:d(Le)}),l({action:_("make_offer"),actor:q,meta:d(Le)}),l({action:_("hire"),actor:q,meta:d(Lt)}),l({action:_("withdraw"),actor:q,meta:d(Le)}),l({action:_("move_to_stage"),actor:q,meta:l({stage:M,stageGroup:K,note:d(i())})}),l({action:_("stage_transition"),actor:q,meta:l({toStage:M,toStageGroup:K,note:d(i())})}),l({action:_("disqualify"),actor:q,meta:l({reason:be,note:d(i())})}),l({action:_("reinstate"),actor:q,meta:l({toStage:M,toStageGroup:K,note:d(i())})}),l({action:_("rate"),actor:q,meta:l({rating:h(S(k(),ue(),ae(1),nn(5)))})})]),ni=l({applicationIds:S(L(i()),N(1)),body:Ft}),Bn=A(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),ti=le("kind",[l({kind:_("updated"),action:Fe,application:Ne}),l({kind:_("skipped"),action:Fe,applicationId:i(),reason:Bn})]),ri=l({updated:L(l({kind:_("updated"),action:Fe,application:Ne})),skipped:L(l({kind:_("skipped"),action:Fe,applicationId:i(),reason:Bn})),failed:L(l({applicationId:i(),error:i()}))}),re=S(k(),ue(),ae(0)),qt=l({APPLIED:re,SHORTLISTED:re,INTERVIEWED:re,OFFERED:re,HIRED:re,REJECTED:re,WITHDRAWN:re}),ii=l({job_ids:qn}),si=l({counts:J(i(),qt)});var ci=Ce(ke);var fi=l({avg_score:h(k()),p90_score:h(k()),p85_score:h(k()),p80_score:h(k()),total_scores:k(),total_shortlists:k()});var sn=({environment:e,publishableKey:t,logger:n})=>{let r=dn[e];return{checkDuplicate(o){return F(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(Gn,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 F(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(Nn,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 m=De(Ln,yield f.json());return m.success?m.output:(n.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return n.error("[TalentBankClient] identify failed:",c),null}})}}};var qe=()=>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 on(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"],Mt=J(i(),ge([i(),L(i()),l({type:_("provided"),lat:k(),lng:k(),radius:k(),unit:g(A(["miles","km"])),label:g(i())})])),Ni={pathname:"/job/:id",method:"GET",schema:{response:l({id:k(),external_id:d(i()),city:d(i()),town:d(i()),category:d(i())})}};var Gt={pathname:"/search/save",method:"POST",schema:{response:oe(),body:l({contact:l({email:S(g(i()),i(),en()),first_name:g(i()),last_name:g(i())}),alerts:S(g(i()),i(),A(Un)),filters:Mt})}};var an=e=>{let t=new Date;return t.setTime(t.getTime()+7*24*60*60*1e3),`${ne}=${e};expires=${t.toUTCString()};path=/`},Bt=(e,t)=>{let n=e.get("session_id");if(t||n)return n;let r=sessionStorage.getItem(`${ne}-session_id`);return typeof r=="string"?r:null},Vt=()=>{if(typeof window=="undefined")return null;try{let e=window.localStorage.getItem(we);return typeof e=="string"&&e!==""?e:null}catch(e){return null}},Ut=e=>{if(typeof window!="undefined")try{e?window.localStorage.setItem(we,e):window.localStorage.removeItem(we)}catch(t){}},Jt=new RegExp(`(?:^|;\\s*)${ne}=([^;]+)`),ln=e=>{var n,r;let t=e?e.headers.get("cookie"):document.cookie;return t&&(r=(n=Jt.exec(t))==null?void 0:n[1])!=null?r:null},cn=e=>{var r;let t=e?e.url:location.href,{searchParams:n}=new URL(t);return{anonymous_id:(r=ln(e))!=null?r:n.get("anonymous_id"),session_id:Bt(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=qe(),n=cn().anonymous_id;return n||(document.cookie=an(t),t)},Kt=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,Wt={pathname:"/log",method:"POST",schema:{response:oe(),body:oe()}},Kn=({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)=>F(void 0,null,function*(){var E,T;try{let w={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=B(O({},P),{anonymous_id:Jn()}));let b=s==="none"?null:Vt();if(p.event==="IDENTIFY"&&r&&(P.anonymous_id||s==="none")){let Z=p.properties,W=yield r.identify({email:(E=Z.email)!=null?E:Z.identifier,firstName:Z.first_name,lastName:Z.last_name,phone:Z.phone_number,anonymousId:(T=P.anonymous_id)!=null?T:qe(),source:"sdk"});W!=null&&W.candidateId&&s==="device"&&(b=W.candidateId,Ut(W.candidateId))}let D={anonymous_id:P.anonymous_id,session_id:P.session_id,candidate_id:b,event:p.event,sent_at:new Date().toISOString(),context:w,properties:p.properties,custom_properties:p.customProperties},Y=s==="none"?null:ln(p.request),pe=++a,fe=yield e.request(Wt,O({body:D},p.keepalive&&{keepalive:!0})),x=Kt(fe);if(s==="none")return!p.request&&(x!=null&&x.session_id)&&pe>c&&(c=pe,x.session_id!==D.session_id&&(o=x.session_id)),D.session_id=p.request?(x==null?void 0:x.session_id)||null:o,n==null||n(D),{success:!0,data:D};let $=p.request?Y:ln(),ie=$!==null&&$!==Y,R=$!=null?$:Y,z=!ie&&(!R||!(x!=null&&x.anonymous_id)||R===x.anonymous_id);return z?(x!=null&&x.anonymous_id&&(D.anonymous_id=x.anonymous_id),x!=null&&x.session_id&&(D.session_id=x.session_id)):D.anonymous_id=R,!p.request&&typeof window!="undefined"&&D.anonymous_id&&(z&&D.session_id&&sessionStorage.setItem(`${ne}-session_id`,D.session_id.toString()),document.cookie=an(D.anonymous_id)),n==null||n(D),{success:!0,data:D}}catch(w){return t.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:w}}}),m=Promise.resolve();return{log:p=>F(void 0,null,function*(){Me(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:zt(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=B(O({},p),{keepalive:!0})),s==="device"||p.request||o||p.keepalive)return f(p,v);let E=()=>f(p,v),T=m.then(E,E);return m=T,T}),getHeaders:p=>{let v=new Headers;return s==="none"||!(p!=null&&p.anonymous_id)||v.append("Set-Cookie",an(p.anonymous_id)),v},getSessionInfo:u}};function un({publishableKey:e,env:t,logger:n=Ge,onEvent:r,persistence:s}){let o=hn({baseUrl:Se[t],publishableKey:e}),a=n===!1?Be:n,c=new de({environment:t,apiKey:{type:"publishable",key:e},logger:a}),u=sn({environment:t,publishableKey:e,logger:a}),f=Kn({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=un;window.inploi.ready=on;})();
|
package/dist/index.d.mts
CHANGED
|
@@ -249,6 +249,8 @@ type AnalyticsLogParams = {
|
|
|
249
249
|
event: 'INTERACTION';
|
|
250
250
|
properties: {
|
|
251
251
|
tag: string;
|
|
252
|
+
/** `feedback_shown` only: the frame was under 400px wide (a phone) when the faces were first on screen. */
|
|
253
|
+
narrow?: boolean;
|
|
252
254
|
};
|
|
253
255
|
};
|
|
254
256
|
type AnalyticsLogEvent = AnalyticsLogParams['event'];
|
|
@@ -529,8 +531,10 @@ type InitialiseInploiSdkParams = {
|
|
|
529
531
|
logger?: Logger | false;
|
|
530
532
|
/** When provided, this callback will be called with every event that is logged to the analytics service. */
|
|
531
533
|
onEvent?: AnalyticsOnEventCallback;
|
|
534
|
+
/** Analytics identity storage. `none` keeps only an API session in memory; defaults to `device`. */
|
|
535
|
+
persistence?: 'device' | 'none';
|
|
532
536
|
};
|
|
533
|
-
declare function initialiseSdk({ publishableKey, env, logger, onEvent, }: InitialiseInploiSdkParams): {
|
|
537
|
+
declare function initialiseSdk({ publishableKey, env, logger, onEvent, persistence, }: InitialiseInploiSdkParams): {
|
|
534
538
|
register: <P extends InploiSdkPlugin>(plugin: P) => ReturnType<P>;
|
|
535
539
|
analytics: AnalyticsService;
|
|
536
540
|
apiClient: ApiClient;
|
package/dist/index.d.ts
CHANGED
|
@@ -249,6 +249,8 @@ type AnalyticsLogParams = {
|
|
|
249
249
|
event: 'INTERACTION';
|
|
250
250
|
properties: {
|
|
251
251
|
tag: string;
|
|
252
|
+
/** `feedback_shown` only: the frame was under 400px wide (a phone) when the faces were first on screen. */
|
|
253
|
+
narrow?: boolean;
|
|
252
254
|
};
|
|
253
255
|
};
|
|
254
256
|
type AnalyticsLogEvent = AnalyticsLogParams['event'];
|
|
@@ -529,8 +531,10 @@ type InitialiseInploiSdkParams = {
|
|
|
529
531
|
logger?: Logger | false;
|
|
530
532
|
/** When provided, this callback will be called with every event that is logged to the analytics service. */
|
|
531
533
|
onEvent?: AnalyticsOnEventCallback;
|
|
534
|
+
/** Analytics identity storage. `none` keeps only an API session in memory; defaults to `device`. */
|
|
535
|
+
persistence?: 'device' | 'none';
|
|
532
536
|
};
|
|
533
|
-
declare function initialiseSdk({ publishableKey, env, logger, onEvent, }: InitialiseInploiSdkParams): {
|
|
537
|
+
declare function initialiseSdk({ publishableKey, env, logger, onEvent, persistence, }: InitialiseInploiSdkParams): {
|
|
534
538
|
register: <P extends InploiSdkPlugin>(plugin: P) => ReturnType<P>;
|
|
535
539
|
analytics: AnalyticsService;
|
|
536
540
|
apiClient: ApiClient;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var at=Object.create;var M=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var dt=(t,n)=>{for(var r in n)M(t,r,{get:n[r],enumerable:!0})},Ae=(t,n,r,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let p of ct(n))!lt.call(t,p)&&p!==r&&M(t,p,{get:()=>n[p],enumerable:!(a=st(n,p))||a.enumerable});return t};var _=(t,n,r)=>(r=t!=null?at(pt(t)):{},Ae(n||!t||!t.__esModule?M(r,"default",{value:t,enumerable:!0}):r,t)),ut=t=>Ae(M({},"__esModule",{value:!0}),t);var Kt={};dt(Kt,{ApiError:()=>R,InploiRpcClient:()=>j,JOB_ALERT_FREQUENCIES:()=>xe,NotFoundError:()=>P,ParsingError:()=>w,SchemaValidationError:()=>T,SdkError:()=>fe,UnauthorisedError:()=>k,consentStorageKey:()=>ce,createPlugin:()=>Pe,createTalentBankClient:()=>ae,endpoint:()=>Q,generateUUID:()=>Y,getConsentAcceptance:()=>et,getOrCreateAnonymousId:()=>Se,hashConsentConfig:()=>se,initialiseSdk:()=>Ze,inploiBrandedLogger:()=>H,isApiErrorWithData:()=>ke,isSdkError:()=>we,noLogging:()=>J,ready:()=>nt,saveClosedRoleJobAlerts:()=>rt,saveSearchEndpoint:()=>Ee,setConsentAcceptance:()=>tt,typed:()=>L,validateEndpointInputs:()=>_e});module.exports=ut(Kt);var G="%c[inploi SDK]",$="color: #65BC67; font-weight: bold;",H={warn:(...t)=>console.warn(G,$,...t),error:(...t)=>console.error(G,$,...t),info:(...t)=>console.info(G,$,...t),log:(...t)=>console.log(G,$,...t)},J={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Pe=t=>t;function me(t,n){if(!t)throw new Error(n)}function N(t,n){return n in t}var rn=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var mt="Unauthenticated",vt="This action is unauthorized.",A=class extends Error{constructor(r,a){super(r);this.status=a,this.name="ErrorWithStatus"}},P=class extends A{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},k=class extends A{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},T=class extends A{constructor(r,a){let p=a?` in ${a}`:"";super(`Schema validation failed${p}`);this.issues=r;this.source=a;this.name="SchemaValidationError",this.status=400}},R=class extends A{constructor(r,a,p){super(r);this.data=p;this.name="ApiError",this.status=a??500}},ke=t=>t instanceof R&&t.data!==void 0,w=class extends A{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 ve(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new w(t);return t.json().catch(()=>{throw new w(t)})}var gt=["message","error","errors","exception","exceptions"];function ft(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of gt)if(N(t,r)){let a=t[r];typeof a=="string"&&n.push(a),Array.isArray(a)&&a.every(p=>typeof p=="string")&&n.push(...a)}N(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&N(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&N(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 ge(t,n){if(n>=300){let r=ft(t);throw n===404?new P(r):r===mt?new k("You are not authenticated.",n):r===vt?new k(r,n):new R(r,n,t)}}var Re=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,a={})=>{let p={...a,headers:{...a.headers,...n}},c=await fetch(`${t.baseUrl}${r}`,p);if(c.status===404)throw new P;let l=await ve(c);return ge(l,c.status),l}}},fe={NotFound:P,Unauthorised:k,SchemaValidation:T,Api:R,JsonParsing:w};function we(t){return Object.values(fe).some(n=>t instanceof n)}var Ce="2.4.1";var K={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Le={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},De=Ce;var C="isdk_session",W=`${C}-candidate_id`,Oe=`${C}-consent`;var Y=()=>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 he=t=>{let n=new Date;return n.setTime(n.getTime()+7*24*60*60*1e3),`${C}=${t};expires=${n.toUTCString()};path=/`},yt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let a=sessionStorage.getItem(`${C}-session_id`);return typeof a=="string"?a:null},St=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(W);return typeof t=="string"&&t!==""?t:null}catch{return null}},bt=t=>{if(!(typeof window>"u"))try{t?window.localStorage.setItem(W,t):window.localStorage.removeItem(W)}catch{}},_t=new RegExp(`(?:^|;\\s*)${C}=([^;]+)`),ye=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?_t.exec(n)?.[1]??null:null},z=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:ye(t)??r.get("anonymous_id"),session_id:yt(r,typeof window>"u")}},Se=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=z().anonymous_id;if(t)return t;let n=Y(),r=z().anonymous_id;return r||(document.cookie=he(n),n)},Tt=t=>typeof t!="object"||t===null?null:{anonymous_id:"anonymous_id"in t&&typeof t.anonymous_id=="string"?t.anonymous_id:null,session_id:"session_id"in t&&typeof t.session_id=="string"?t.session_id:null},xt=t=>t==="about:client"?"":t,Et={pathname:"/log",method:"POST",schema:{response:L(),body:L()}},Ne=({rpcClient:t,logger:n,onEvent:r,talentBank:a})=>({log:async c=>{me(c.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let l="request"in c&&c.request?{href:c.request.url,referrer:xt(c.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};try{let d={library:{name:"inploi-sdk",version:De},page:l},u=z(c.request);c.event==="IDENTIFY"&&!u.anonymous_id&&!c.request&&typeof window<"u"&&(u={...u,anonymous_id:Se()});let B=St();if(c.event==="IDENTIFY"&&a&&u.anonymous_id){let U=c.properties,ue=await a.identify({email:U.email??U.identifier,firstName:U.first_name,lastName:U.last_name,phone:U.phone_number,anonymousId:u.anonymous_id,source:"sdk"});ue?.candidateId&&(B=ue.candidateId,bt(ue.candidateId))}let S={anonymous_id:u.anonymous_id,session_id:u.session_id,candidate_id:B,event:c.event,sent_at:new Date().toISOString(),context:d,properties:c.properties,custom_properties:c.customProperties},pe=ye(c.request),ot=await t.request(Et,{body:S,...c.keepalive&&{keepalive:!0}}),O=Tt(ot),le=c.request?pe:ye(),it=le!==null&&le!==pe,de=le??pe,Ie=!it&&(!de||!O?.anonymous_id||de===O.anonymous_id);return Ie?(O?.anonymous_id&&(S.anonymous_id=O.anonymous_id),O?.session_id&&(S.session_id=O.session_id)):S.anonymous_id=de,!c.request&&typeof window<"u"&&S.anonymous_id&&(Ie&&S.session_id&&sessionStorage.setItem(`${C}-session_id`,S.session_id.toString()),document.cookie=he(S.anonymous_id)),r?.(S),{success:!0,data:S}}catch(d){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:d}}},getHeaders:c=>{let l=new Headers;return c?.anonymous_id&&l.append("Set-Cookie",he(c.anonymous_id)),l},getSessionInfo:z});var je=require("neoqs");function be(t,n,r){let a=t["~standard"].validate(n);if(a instanceof Promise)throw new TypeError("Async schema");if(a.issues)throw new T(a.issues,r);return a.value}function It(t,n,r){try{return{success:!0,output:be(t,n,r)}}catch(a){if(a instanceof T)return{success:!1,issues:a.issues,source:a.source};throw a}}var j=class{constructor(n){if(this.baseUrl=K[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 a=r.validateIn??!0,{searchParams:p,body:c}=a?_e(n,r):r,l=new URL(this.baseUrl),d=n.pathname;if("params"in r&&r.params)for(let[u,B]of Object.entries(r.params))d=d.replace(`:${u}`,String(B));return l.pathname=d,n.schema.searchParams&&(l.search=(0,je.stringify)(p)),[l.toString(),{method:n.method,body:c?JSON.stringify(c):void 0,headers:this.headers,signal:r.signal,...r.keepalive&&{keepalive:!0}}]}async parseResponse(n,r){let a=await ve(r.response);if(ge(a,r.response.status),!(r.validateOut??!0))return a;let c=It(n.schema.response,a,"response");if(!c.success)throw new T(c.issues,c.source);return c.output}async request(n,r){try{let a=this.getFetchParams(n,r),p=await fetch(...a);return await this.parseResponse(n,{response:p,validateOut:r.validateOut})}catch(a){throw a instanceof T?this.logger.error(a.message,a.issues):this.logger.error(a),a}}};function L(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function Q(t){return t}function _e(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=be(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=be(t.schema.body,"body"in n?n.body:{})),r}var i=_(require("valibot"),1),At=["agent","sdk","form","integration","migration"],Pt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var kt=["screening","cv_match","interview","overall"],Rt=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],wt=["job","company"],Ct=["created_at","updated_at"],Lt=["asc","desc"],Dt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Ot=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],Nt=["user","system","automation","integration","candidate"],X=i.picklist(At),x=i.picklist(Pt),b=i.pipe(i.string(),i.trim(),i.minLength(1),i.maxLength(100)),Z=i.picklist(kt),Fe=i.picklist(Rt),xn=i.picklist(wt),Be=i.picklist(Ct),Ue=i.picklist(Lt),q=i.pipe(i.string(),i.trim(),i.minLength(1),i.maxLength(100)),ee=i.picklist(Dt),qe=i.picklist(Ot),Ve=i.picklist(Nt);var h=i.variant("type",[i.object({type:i.literal("user"),id:i.pipe(i.string(),i.minLength(1)),email:i.pipe(i.string(),i.minLength(1)),name:i.pipe(i.string(),i.minLength(1))}),i.object({type:i.literal("system"),id:i.pipe(i.string(),i.minLength(1)),name:i.optional(i.string())}),i.object({type:i.literal("automation"),id:i.pipe(i.string(),i.minLength(1)),name:i.optional(i.string())}),i.object({type:i.literal("integration"),id:i.pipe(i.string(),i.minLength(1)),name:i.optional(i.string())}),i.object({type:i.literal("candidate"),id:i.pipe(i.string(),i.minLength(1)),email:i.optional(i.string())})]);var E=_(require("valibot"),1),jt=E.object({total:E.number(),page:E.number(),perPage:E.number(),lastPage:E.number()});function te(t){return E.object({data:E.array(t),pagination:jt})}var m=_(require("valibot"),1);var V=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(X),identifiedAt:m.nullable(m.string()),createdAt:m.string(),updatedAt:m.string()});var o=_(require("valibot"),1);var v=_(require("valibot"),1),F=v.pipe(v.string(),v.minLength(1)),Me=v.pipe(v.number(),v.integer(),v.minValue(1)),I=v.record(v.string(),v.unknown());var y=_(require("valibot"),1);var Ge=y.object({id:y.string(),applicationId:y.string(),status:Fe,scheduledAt:y.nullable(y.string()),completedAt:y.nullable(y.string()),meta:y.nullable(I),createdAt:y.string(),updatedAt:y.string()});var Te=o.object({score:o.number(),reason:o.string(),confidence:o.number()}),$e=o.object({id:o.string(),candidateId:o.string(),jobId:o.number(),stage:b,stageGroup:x,stageEnteredAt:o.string(),rating:o.nullable(o.number()),disqualifiedAt:o.nullable(o.string()),disqualificationReason:o.nullable(q),disqualificationNote:o.nullable(o.string()),source:ee,sourceDetail:o.nullable(o.string()),sessionId:o.nullable(o.number()),externalApplicationId:o.nullable(o.string()),meta:o.nullable(I),context:o.nullable(I),scoredAt:o.nullable(o.string()),createdAt:o.string(),updatedAt:o.string()}),Ft=o.object({id:o.string(),applicationId:o.string(),scoreType:Z,score:o.nullable(o.number()),reason:o.nullable(o.string()),categories:o.nullable(o.record(o.string(),Te)),scoredBy:o.nullable(o.string()),createdAt:o.string()}),ne=o.object({...$e.entries,candidate:o.nullable(V),score:o.nullable(Ft),interview:o.nullable(Ge)}),Bt=o.object({...V.entries,applications:o.array($e)}),He=o.object({id:o.string(),applicationId:o.string(),action:qe,fromStage:o.nullable(b),fromStageGroup:o.nullable(x),toStage:o.nullable(b),toStageGroup:o.nullable(x),disqualificationReason:o.nullable(q),disqualificationNote:o.nullable(o.string()),actorId:o.nullable(o.string()),actorType:Ve,actorEmail:o.nullable(o.string()),actorName:o.nullable(o.string()),meta:o.nullable(I),schemaVersion:o.number(),createdAt:o.string()});var g=_(require("valibot"),1);var Je=g.object({anonymousId:F,email:F,firstName:g.nullish(g.string()),lastName:g.nullish(g.string()),phone:g.nullish(g.string()),source:g.nullish(X)}),Ke=g.object({candidateId:g.string(),isNew:g.boolean()});var e=_(require("valibot"),1);var Ut=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],oe=e.picklist(Ut),We=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),qt=e.pipe(We,e.array(b)),Vt=e.pipe(We,e.array(x)),Ye=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),$n=e.object({stages:e.optional(qt),stage_groups:e.optional(Vt),job_id:e.optional(e.string()),job_ids:e.optional(Ye),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(Be),order:e.optional(Ue),page:e.optional(e.string()),per_page:e.optional(e.string())}),Hn=e.pipe(e.object({candidateId:F,jobId:Me,meta:e.nullish(I),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(I),source:e.nullish(ee),sourceDetail:e.nullish(e.string()),stage:e.nullish(b),stageGroup:e.nullish(x),actor:e.nullish(h)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together")),ze=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),Jn=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:ze})]),Qe=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(ze)}),Kn=e.object({applicationId:F,scoreType:Z,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),Te)),scoredBy:e.nullish(e.string()),actor:e.nullish(h)}),Wn=e.object({scoreId:e.string()}),Yn=te(ne);var zn=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),Qn=e.array(He),re=e.object({stage:e.nullish(b),note:e.nullish(e.string())}),Mt=e.object({stage:e.nullish(b),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Gt=e.variant("action",[e.object({action:e.literal("shortlist"),actor:h,meta:e.nullish(re)}),e.object({action:e.literal("move_to_interview"),actor:h,meta:e.nullish(re)}),e.object({action:e.literal("make_offer"),actor:h,meta:e.nullish(re)}),e.object({action:e.literal("hire"),actor:h,meta:e.nullish(Mt)}),e.object({action:e.literal("withdraw"),actor:h,meta:e.nullish(re)}),e.object({action:e.literal("move_to_stage"),actor:h,meta:e.object({stage:b,stageGroup:x,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:h,meta:e.object({toStage:b,toStageGroup:x,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:h,meta:e.object({reason:q,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:h,meta:e.object({toStage:b,toStageGroup:x,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:h,meta:e.object({rating:e.nullable(e.pipe(e.number(),e.integer(),e.minValue(1),e.maxValue(5)))})})]),Xn=e.object({applicationIds:e.pipe(e.array(e.string()),e.minLength(1)),body:Gt}),Xe=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),Zn=e.variant("kind",[e.object({kind:e.literal("updated"),action:oe,application:ne}),e.object({kind:e.literal("skipped"),action:oe,applicationId:e.string(),reason:Xe})]),er=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:oe,application:ne})),skipped:e.array(e.object({kind:e.literal("skipped"),action:oe,applicationId:e.string(),reason:Xe})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),D=e.pipe(e.number(),e.integer(),e.minValue(0)),$t=e.object({APPLIED:D,SHORTLISTED:D,INTERVIEWED:D,OFFERED:D,HIRED:D,REJECTED:D,WITHDRAWN:D}),tr=e.object({job_ids:Ye}),nr=e.object({counts:e.record(e.string(),$t)});var sr=te(V);var f=_(require("valibot"),1),pr=f.object({avg_score:f.nullable(f.number()),p90_score:f.nullable(f.number()),p85_score:f.nullable(f.number()),p80_score:f.nullable(f.number()),total_scores:f.number(),total_shortlists:f.number()});var ie=_(require("valibot"));var ae=({environment:t,publishableKey:n,logger:r})=>{let a=Le[t];return{async checkDuplicate(p){try{let c=new URLSearchParams({email:p.email,scope:p.scope});p.scope==="job"&&p.jobId!=null&&c.set("job_id",String(p.jobId));let l=await fetch(`${a}/applications/check-duplicate?${c}`,{method:"GET",headers:{Accept:"application/json","x-publishable-key":n}});if(!l.ok)return r.error(`[TalentBankClient] checkDuplicate failed with status ${l.status}`),{isDuplicate:!1};let d=await l.json(),u=ie.safeParse(Qe,d);return u.success?u.output:(r.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof d=="object"&&d!=null&&typeof d.isDuplicate=="boolean"?{isDuplicate:d.isDuplicate}:{isDuplicate:!1})}catch(c){return r.error("[TalentBankClient] checkDuplicate failed:",c),{isDuplicate:!1}}},async identify(p){try{if(!p.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let c={email:p.email,firstName:p.firstName,lastName:p.lastName,phone:p.phone,anonymousId:p.anonymousId,source:p.source??"sdk"},l=ie.safeParse(Je,c);if(!l.success)return r.error("[TalentBankClient] identify received invalid input"),null;let d=await fetch(`${a}/identify`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-publishable-key":n},body:JSON.stringify(l.output)});if(!d.ok)return r.error(`[TalentBankClient] identify failed with status ${d.status}`),null;let u=ie.safeParse(Ke,await d.json());return u.success?u.output:(r.error("[TalentBankClient] identify returned an invalid response"),null)}catch(c){return r.error("[TalentBankClient] identify failed:",c),null}}}};function Ze({publishableKey:t,env:n,logger:r=H,onEvent:a}){let p=Re({baseUrl:K[n],publishableKey:t}),c=r===!1?J:r,l=new j({environment:n,apiKey:{type:"publishable",key:t},logger:c}),d=ae({environment:n,publishableKey:t,logger:c}),u=Ne({rpcClient:l,logger:c,onEvent:a,talentBank:d});return{register:S=>S({logger:c,apiClient:p,analytics:u,rpcClient:l,publishableKey:t,env:n}),analytics:u,apiClient:p}}function se(t){let n=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),r=5381;for(let a=0;a<n.length;a++)r=r*33^n.charCodeAt(a);return(r>>>0).toString(36)}function ce(t,n){return`${Oe}:${t}:${n}`}function et(t,n){if(typeof window>"u")return!1;try{let r=ce(t,se(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function tt(t,n){if(!(typeof window>"u"))try{let r=ce(t,se(n));window.localStorage.setItem(r,"accepted")}catch{}}function nt(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}var s=_(require("valibot"));var xe=["DAILY","WEEKLY","MONTHLY"],Ht=s.record(s.string(),s.union([s.string(),s.array(s.string()),s.object({type:s.literal("provided"),lat:s.number(),lng:s.number(),radius:s.number(),unit:s.optional(s.picklist(["miles","km"])),label:s.optional(s.string())})])),Jt={pathname:"/job/:id",method:"GET",schema:{response:s.object({id:s.number(),external_id:s.nullish(s.string()),city:s.nullish(s.string()),town:s.nullish(s.string()),category:s.nullish(s.string())})}};async function rt(t,{contact:n,job:r}){let a={};if(r){let p=await t.request(Jt,{params:{id:r.id}});if((r.id_type==="internal"?String(p.id):p.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let l of["city","town","category"]){let d=p[l]?.trim();d&&(a[l]=[d])}}await t.request(Ee,{body:{contact:n,alerts:"WEEKLY",filters:a}})}var Ee={pathname:"/search/save",method:"POST",schema:{response:L(),body:s.object({contact:s.object({email:s.pipe(s.optional(s.string()),s.string(),s.email()),first_name:s.optional(s.string()),last_name:s.optional(s.string())}),alerts:s.pipe(s.optional(s.string()),s.string(),s.picklist(xe)),filters:Ht})}};0&&(module.exports={ApiError,InploiRpcClient,JOB_ALERT_FREQUENCIES,NotFoundError,ParsingError,SchemaValidationError,SdkError,UnauthorisedError,consentStorageKey,createPlugin,createTalentBankClient,endpoint,generateUUID,getConsentAcceptance,getOrCreateAnonymousId,hashConsentConfig,initialiseSdk,inploiBrandedLogger,isApiErrorWithData,isSdkError,noLogging,ready,saveClosedRoleJobAlerts,saveSearchEndpoint,setConsentAcceptance,typed,validateEndpointInputs});
|
|
1
|
+
"use strict";var vt=Object.create;var W=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var ht=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty;var St=(t,n)=>{for(var r in n)W(t,r,{get:n[r],enumerable:!0})},Oe=(t,n,r,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let c of ft(n))!yt.call(t,c)&&c!==r&&W(t,c,{get:()=>n[c],enumerable:!(a=gt(n,c))||a.enumerable});return t};var T=(t,n,r)=>(r=t!=null?vt(ht(t)):{},Oe(n||!t||!t.__esModule?W(r,"default",{value:t,enumerable:!0}):r,t)),bt=t=>Oe(W({},"__esModule",{value:!0}),t);var tn={};St(tn,{ApiError:()=>O,InploiRpcClient:()=>V,JOB_ALERT_FREQUENCIES:()=>ke,NotFoundError:()=>L,ParsingError:()=>N,SchemaValidationError:()=>I,SdkError:()=>be,UnauthorisedError:()=>D,consentStorageKey:()=>de,createPlugin:()=>Ne,createTalentBankClient:()=>pe,endpoint:()=>ee,generateUUID:()=>$,getConsentAcceptance:()=>ct,getOrCreateAnonymousId:()=>Ee,hashConsentConfig:()=>le,initialiseSdk:()=>st,inploiBrandedLogger:()=>z,isApiErrorWithData:()=>je,isSdkError:()=>Be,noLogging:()=>Q,ready:()=>lt,saveClosedRoleJobAlerts:()=>dt,saveSearchEndpoint:()=>Re,setConsentAcceptance:()=>pt,typed:()=>F,validateEndpointInputs:()=>Pe});module.exports=bt(tn);var K="%c[inploi SDK]",Y="color: #65BC67; font-weight: bold;",z={warn:(...t)=>console.warn(K,Y,...t),error:(...t)=>console.error(K,Y,...t),info:(...t)=>console.info(K,Y,...t),log:(...t)=>console.log(K,Y,...t)},Q={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};var Ne=t=>t;function he(t,n){if(!t)throw new Error(n)}function U(t,n){return n in t}var un=new Intl.RelativeTimeFormat(void 0,{numeric:"auto"});var _t="Unauthenticated",Tt="This action is unauthorized.",C=class extends Error{constructor(r,a){super(r);this.status=a,this.name="ErrorWithStatus"}},L=class extends C{constructor(n){super(n??"Not found"),this.name="NotFoundError",this.status=404}},D=class extends C{constructor(n,r){super(n??"You are not authorised to perform this action."),this.name="UnauthorisedError",this.status=r??401}},I=class extends C{constructor(r,a){let c=a?` in ${a}`:"";super(`Schema validation failed${c}`);this.issues=r;this.source=a;this.name="SchemaValidationError",this.status=400}},O=class extends C{constructor(r,a,c){super(r);this.data=c;this.name="ApiError",this.status=a??500}},je=t=>t instanceof O&&t.data!==void 0,N=class extends C{constructor(r){super("Error parsing response into JSON.");this.response=r;this.name="ParsingError",this.status=r&&r.status>=300?r.status:500,this.contentType=new Headers(r?.headers).get("content-type")??void 0}};async function ye(t){let r=new Headers(t.headers).get("content-type")?.replace(/;.*/,"").trim().toLowerCase();if(r&&r!=="application/json"&&!r.endsWith("+json"))throw new N(t);return t.json().catch(()=>{throw new N(t)})}var xt=["message","error","errors","exception","exceptions"];function Et(t){let n=[];if(typeof t=="object"&&t!==null){for(let r of xt)if(U(t,r)){let a=t[r];typeof a=="string"&&n.push(a),Array.isArray(a)&&a.every(c=>typeof c=="string")&&n.push(...a)}U(t,"integration_response")&&typeof t.integration_response=="object"&&t.integration_response!==null&&U(t.integration_response,"error")&&typeof t.integration_response.error=="object"&&t.integration_response.error!==null&&U(t.integration_response.error,"message")&&typeof t.integration_response.error.message=="string"&&n.push(t.integration_response.error.message)}return n.length===0&&n.push("Unknown error"),[...new Set(n)].join(", ")}function Se(t,n){if(n>=300){let r=Et(t);throw n===404?new L(r):r===_t?new D("You are not authenticated.",n):r===Tt?new D(r,n):new O(r,n,t)}}var Fe=t=>{let n={Accept:"application/json","Content-Type":"application/json","x-publishable-key":t.publishableKey};return{fetch:async(r,a={})=>{let c={...a,headers:{...a.headers,...n}},l=await fetch(`${t.baseUrl}${r}`,c);if(l.status===404)throw new L;let d=await ye(l);return Se(d,l.status),d}}},be={NotFound:L,Unauthorised:D,SchemaValidation:I,Api:O,JsonParsing:N};function Be(t){return Object.values(be).some(n=>t instanceof n)}var qe="2.5.0";var X={sandbox:"https://api.staging.inploi.com",production:"https://api.inploi.com",_internal_local:"http://api.test"},Ue={sandbox:"https://talent-bank.staging.inploi.com",production:"https://talent-bank.inploi.com",_internal_local:"http://localhost:8787"},Ve=qe;var j="isdk_session",Z=`${j}-candidate_id`,Me=`${j}-consent`;var $=()=>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 _e=t=>{let n=new Date;return n.setTime(n.getTime()+7*24*60*60*1e3),`${j}=${t};expires=${n.toUTCString()};path=/`},Pt=(t,n)=>{let r=t.get("session_id");if(n||r)return r;let a=sessionStorage.getItem(`${j}-session_id`);return typeof a=="string"?a:null},At=()=>{if(typeof window>"u")return null;try{let t=window.localStorage.getItem(Z);return typeof t=="string"&&t!==""?t:null}catch{return null}},kt=t=>{if(!(typeof window>"u"))try{t?window.localStorage.setItem(Z,t):window.localStorage.removeItem(Z)}catch{}},Rt=new RegExp(`(?:^|;\\s*)${j}=([^;]+)`),Te=t=>{let n=t?t.headers.get("cookie"):document.cookie;return n?Rt.exec(n)?.[1]??null:null},xe=t=>{let n=t?t.url:location.href,{searchParams:r}=new URL(n);return{anonymous_id:Te(t)??r.get("anonymous_id"),session_id:Pt(r,typeof window>"u")}},Ee=()=>{if(typeof window>"u")throw new Error("getOrCreateAnonymousId() can only be called in browser environment");let t=xe().anonymous_id;if(t)return t;let n=$(),r=xe().anonymous_id;return r||(document.cookie=_e(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},Ct=t=>t==="about:client"?"":t,Lt={pathname:"/log",method:"POST",schema:{response:F(),body:F()}},Ge=({rpcClient:t,logger:n,onEvent:r,talentBank:a,persistence:c="device"})=>{let l=null,d=0,u=0,b=p=>c==="none"?{anonymous_id:null,session_id:p?null:l}:xe(p),w=async(p,R)=>{try{let q={library:{name:"inploi-sdk",version:Ve},page:R},x=b(p.request);c==="device"&&p.event==="IDENTIFY"&&!x.anonymous_id&&!p.request&&typeof window<"u"&&(x={...x,anonymous_id:Ee()});let Ce=c==="none"?null:At();if(p.event==="IDENTIFY"&&a&&(x.anonymous_id||c==="none")){let G=p.properties,fe=await a.identify({email:G.email??G.identifier,firstName:G.first_name,lastName:G.last_name,phone:G.phone_number,anonymousId:x.anonymous_id??$(),source:"sdk"});fe?.candidateId&&c==="device"&&(Ce=fe.candidateId,kt(fe.candidateId))}let f={anonymous_id:x.anonymous_id,session_id:x.session_id,candidate_id:Ce,event:p.event,sent_at:new Date().toISOString(),context:q,properties:p.properties,custom_properties:p.customProperties},me=c==="none"?null:Te(p.request),Le=++d,ut=await t.request(Lt,{body:f,...p.keepalive&&{keepalive:!0}}),E=wt(ut);if(c==="none")return!p.request&&E?.session_id&&Le>u&&(u=Le,E.session_id!==f.session_id&&(l=E.session_id)),f.session_id=p.request?E?.session_id||null:l,r?.(f),{success:!0,data:f};let ve=p.request?me:Te(),mt=ve!==null&&ve!==me,ge=ve??me,De=!mt&&(!ge||!E?.anonymous_id||ge===E.anonymous_id);return De?(E?.anonymous_id&&(f.anonymous_id=E.anonymous_id),E?.session_id&&(f.session_id=E.session_id)):f.anonymous_id=ge,!p.request&&typeof window<"u"&&f.anonymous_id&&(De&&f.session_id&&sessionStorage.setItem(`${j}-session_id`,f.session_id.toString()),document.cookie=_e(f.anonymous_id)),r?.(f),{success:!0,data:f}}catch(q){return n.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:q}}},ue=Promise.resolve();return{log:async p=>{he(p.request||typeof window<"u","Cannot log on the server without a request. Please pass a request to `log`.");let R="request"in p&&p.request?{href:p.request.url,referrer:Ct(p.request.referrer),title:""}:{href:location.href,referrer:document.referrer,title:document.title};if(c==="none"&&p.event==="FLOW_NODE"&&p.properties&&"trigger"in p.properties&&(p.properties.trigger==="pagehide"||p.properties.trigger==="hidden")&&(p={...p,keepalive:!0}),c==="device"||p.request||l||p.keepalive)return w(p,R);let q=()=>w(p,R),x=ue.then(q,q);return ue=x,x},getHeaders:p=>{let R=new Headers;return c==="none"||!p?.anonymous_id||R.append("Set-Cookie",_e(p.anonymous_id)),R},getSessionInfo:b}};var $e=require("neoqs");function Ie(t,n,r){let a=t["~standard"].validate(n);if(a instanceof Promise)throw new TypeError("Async schema");if(a.issues)throw new I(a.issues,r);return a.value}function Dt(t,n,r){try{return{success:!0,output:Ie(t,n,r)}}catch(a){if(a instanceof I)return{success:!1,issues:a.issues,source:a.source};throw a}}var V=class{constructor(n){if(this.baseUrl=X[n.environment],this.headers=new Headers({"Content-Type":"application/json",Accept:"application/json"}),n.apiKey.type==="secret"){if(typeof window<"u")throw new Error("Secret key cannot be used in a browser environment");this.headers.set("x-secret-key",n.apiKey.key)}else this.headers.set("x-publishable-key",n.apiKey.key);this.logger=n.logger,this._environment=n.environment}get environment(){return this._environment}getFetchParams(n,r){let a=r.validateIn??!0,{searchParams:c,body:l}=a?Pe(n,r):r,d=new URL(this.baseUrl),u=n.pathname;if("params"in r&&r.params)for(let[b,w]of Object.entries(r.params))u=u.replace(`:${b}`,String(w));return d.pathname=u,n.schema.searchParams&&(d.search=(0,$e.stringify)(c)),[d.toString(),{method:n.method,body:l?JSON.stringify(l):void 0,headers:this.headers,signal:r.signal,...r.keepalive&&{keepalive:!0}}]}async parseResponse(n,r){let a=await ye(r.response);if(Se(a,r.response.status),!(r.validateOut??!0))return a;let l=Dt(n.schema.response,a,"response");if(!l.success)throw new I(l.issues,l.source);return l.output}async request(n,r){try{let a=this.getFetchParams(n,r),c=await fetch(...a);return await this.parseResponse(n,{response:c,validateOut:r.validateOut})}catch(a){throw a instanceof I?this.logger.error(a.message,a.issues):this.logger.error(a),a}}};function F(){return{"~standard":{vendor:"inploi",version:1,validate:t=>({value:t})}}}function ee(t){return t}function Pe(t,n){let r={searchParams:void 0,body:void 0,validateIn:!1};return t.schema.searchParams&&(r.searchParams=Ie(t.schema.searchParams,"searchParams"in n?n.searchParams:{})),t.schema.body&&(r.body=Ie(t.schema.body,"body"in n?n.body:{})),r}var i=T(require("valibot"),1),Ot=["agent","sdk","form","integration","migration"],Nt=["APPLIED","SHORTLISTED","INTERVIEWED","OFFERED","HIRED","REJECTED","WITHDRAWN"];var jt=["screening","cv_match","interview","overall"],Ft=["PENDING","SCHEDULED","IN_PROGRESS","COMPLETED","CANCELLED"],Bt=["job","company"],qt=["created_at","updated_at"],Ut=["asc","desc"],Vt=["careers_site","chatbot","plugin_job_search","ats_import","referral","agency","other","unknown"],Mt=["submit","stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate","score_written"],Gt=["user","system","automation","integration","candidate"],te=i.picklist(Ot),P=i.picklist(Nt),_=i.pipe(i.string(),i.trim(),i.minLength(1),i.maxLength(100)),ne=i.picklist(jt),He=i.picklist(Ft),Cn=i.picklist(Bt),Je=i.picklist(qt),We=i.picklist(Ut),H=i.pipe(i.string(),i.trim(),i.minLength(1),i.maxLength(100)),re=i.picklist(Vt),Ke=i.picklist(Mt),Ye=i.picklist(Gt);var y=i.variant("type",[i.object({type:i.literal("user"),id:i.pipe(i.string(),i.minLength(1)),email:i.pipe(i.string(),i.minLength(1)),name:i.pipe(i.string(),i.minLength(1))}),i.object({type:i.literal("system"),id:i.pipe(i.string(),i.minLength(1)),name:i.optional(i.string())}),i.object({type:i.literal("automation"),id:i.pipe(i.string(),i.minLength(1)),name:i.optional(i.string())}),i.object({type:i.literal("integration"),id:i.pipe(i.string(),i.minLength(1)),name:i.optional(i.string())}),i.object({type:i.literal("candidate"),id:i.pipe(i.string(),i.minLength(1)),email:i.optional(i.string())})]);var A=T(require("valibot"),1),$t=A.object({total:A.number(),page:A.number(),perPage:A.number(),lastPage:A.number()});function oe(t){return A.object({data:A.array(t),pagination:$t})}var m=T(require("valibot"),1);var J=m.object({id:m.string(),email:m.nullable(m.string()),firstName:m.nullable(m.string()),lastName:m.nullable(m.string()),phone:m.nullable(m.string()),source:m.nullable(te),identifiedAt:m.nullable(m.string()),createdAt:m.string(),updatedAt:m.string()});var o=T(require("valibot"),1);var v=T(require("valibot"),1),M=v.pipe(v.string(),v.minLength(1)),ze=v.pipe(v.number(),v.integer(),v.minValue(1)),k=v.record(v.string(),v.unknown());var S=T(require("valibot"),1);var Qe=S.object({id:S.string(),applicationId:S.string(),status:He,scheduledAt:S.nullable(S.string()),completedAt:S.nullable(S.string()),meta:S.nullable(k),createdAt:S.string(),updatedAt:S.string()});var Ae=o.object({score:o.number(),reason:o.string(),confidence:o.number()}),Xe=o.object({id:o.string(),candidateId:o.string(),jobId:o.number(),stage:_,stageGroup:P,stageEnteredAt:o.string(),rating:o.nullable(o.number()),disqualifiedAt:o.nullable(o.string()),disqualificationReason:o.nullable(H),disqualificationNote:o.nullable(o.string()),source:re,sourceDetail:o.nullable(o.string()),sessionId:o.nullable(o.number()),externalApplicationId:o.nullable(o.string()),meta:o.nullable(k),context:o.nullable(k),scoredAt:o.nullable(o.string()),createdAt:o.string(),updatedAt:o.string()}),Ht=o.object({id:o.string(),applicationId:o.string(),scoreType:ne,score:o.nullable(o.number()),reason:o.nullable(o.string()),categories:o.nullable(o.record(o.string(),Ae)),scoredBy:o.nullable(o.string()),createdAt:o.string()}),ie=o.object({...Xe.entries,candidate:o.nullable(J),score:o.nullable(Ht),interview:o.nullable(Qe)}),Jt=o.object({...J.entries,applications:o.array(Xe)}),Ze=o.object({id:o.string(),applicationId:o.string(),action:Ke,fromStage:o.nullable(_),fromStageGroup:o.nullable(P),toStage:o.nullable(_),toStageGroup:o.nullable(P),disqualificationReason:o.nullable(H),disqualificationNote:o.nullable(o.string()),actorId:o.nullable(o.string()),actorType:Ye,actorEmail:o.nullable(o.string()),actorName:o.nullable(o.string()),meta:o.nullable(k),schemaVersion:o.number(),createdAt:o.string()});var g=T(require("valibot"),1);var et=g.object({anonymousId:M,email:M,firstName:g.nullish(g.string()),lastName:g.nullish(g.string()),phone:g.nullish(g.string()),source:g.nullish(te)}),tt=g.object({candidateId:g.string(),isNew:g.boolean()});var e=T(require("valibot"),1);var Wt=["stage_transition","move_to_stage","shortlist","move_to_interview","make_offer","hire","withdraw","disqualify","reinstate","rate"],se=e.picklist(Wt),nt=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>n.trim()).filter(n=>n.length>0))),Kt=e.pipe(nt,e.array(_)),Yt=e.pipe(nt,e.array(P)),rt=e.pipe(e.string(),e.transform(t=>t.split(",").map(n=>Number(n.trim())).filter(n=>Number.isInteger(n)&&n>0))),Xn=e.object({stages:e.optional(Kt),stage_groups:e.optional(Yt),job_id:e.optional(e.string()),job_ids:e.optional(rt),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(Je),order:e.optional(We),page:e.optional(e.string()),per_page:e.optional(e.string())}),Zn=e.pipe(e.object({candidateId:M,jobId:ze,meta:e.nullish(k),sessionId:e.nullish(e.number()),externalApplicationId:e.nullish(e.string()),context:e.nullish(k),source:e.nullish(re),sourceDetail:e.nullish(e.string()),stage:e.nullish(_),stageGroup:e.nullish(P),actor:e.nullish(y)}),e.check(t=>t.stage==null==(t.stageGroup==null),"stage and stageGroup must be supplied together")),ot=e.object({id:e.string(),stageGroup:e.string(),createdAt:e.string()}),er=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:ot})]),it=e.object({isDuplicate:e.boolean(),existingApplication:e.optional(ot)}),tr=e.object({applicationId:M,scoreType:ne,score:e.number(),reason:e.nullish(e.string()),categories:e.nullish(e.record(e.string(),Ae)),scoredBy:e.nullish(e.string()),actor:e.nullish(y)}),nr=e.object({scoreId:e.string()}),rr=oe(ie);var or=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified"]),ir=e.array(Ze),ae=e.object({stage:e.nullish(_),note:e.nullish(e.string())}),zt=e.object({stage:e.nullish(_),startDate:e.nullish(e.string()),note:e.nullish(e.string())}),Qt=e.variant("action",[e.object({action:e.literal("shortlist"),actor:y,meta:e.nullish(ae)}),e.object({action:e.literal("move_to_interview"),actor:y,meta:e.nullish(ae)}),e.object({action:e.literal("make_offer"),actor:y,meta:e.nullish(ae)}),e.object({action:e.literal("hire"),actor:y,meta:e.nullish(zt)}),e.object({action:e.literal("withdraw"),actor:y,meta:e.nullish(ae)}),e.object({action:e.literal("move_to_stage"),actor:y,meta:e.object({stage:_,stageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("stage_transition"),actor:y,meta:e.object({toStage:_,toStageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("disqualify"),actor:y,meta:e.object({reason:H,note:e.nullish(e.string())})}),e.object({action:e.literal("reinstate"),actor:y,meta:e.object({toStage:_,toStageGroup:P,note:e.nullish(e.string())})}),e.object({action:e.literal("rate"),actor:y,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:Qt}),at=e.picklist(["already_in_target_stage","not_in_source_stage","disqualified","already_disqualified"]),sr=e.variant("kind",[e.object({kind:e.literal("updated"),action:se,application:ie}),e.object({kind:e.literal("skipped"),action:se,applicationId:e.string(),reason:at})]),cr=e.object({updated:e.array(e.object({kind:e.literal("updated"),action:se,application:ie})),skipped:e.array(e.object({kind:e.literal("skipped"),action:se,applicationId:e.string(),reason:at})),failed:e.array(e.object({applicationId:e.string(),error:e.string()}))}),B=e.pipe(e.number(),e.integer(),e.minValue(0)),Xt=e.object({APPLIED:B,SHORTLISTED:B,INTERVIEWED:B,OFFERED:B,HIRED:B,REJECTED:B,WITHDRAWN:B}),pr=e.object({job_ids:rt}),lr=e.object({counts:e.record(e.string(),Xt)});var gr=oe(J);var h=T(require("valibot"),1),hr=h.object({avg_score:h.nullable(h.number()),p90_score:h.nullable(h.number()),p85_score:h.nullable(h.number()),p80_score:h.nullable(h.number()),total_scores:h.number(),total_shortlists:h.number()});var ce=T(require("valibot"));var pe=({environment:t,publishableKey:n,logger:r})=>{let a=Ue[t];return{async checkDuplicate(c){try{let l=new URLSearchParams({email:c.email,scope:c.scope});c.scope==="job"&&c.jobId!=null&&l.set("job_id",String(c.jobId));let d=await fetch(`${a}/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(),b=ce.safeParse(it,u);return b.success?b.output:(r.error("[TalentBankClient] checkDuplicate response failed strict validation; falling back to isDuplicate flag"),typeof u=="object"&&u!=null&&typeof u.isDuplicate=="boolean"?{isDuplicate:u.isDuplicate}:{isDuplicate:!1})}catch(l){return r.error("[TalentBankClient] checkDuplicate failed:",l),{isDuplicate:!1}}},async identify(c){try{if(!c.anonymousId)return r.error("[TalentBankClient] identify skipped because anonymousId is missing"),null;let l={email:c.email,firstName:c.firstName,lastName:c.lastName,phone:c.phone,anonymousId:c.anonymousId,source:c.source??"sdk"},d=ce.safeParse(et,l);if(!d.success)return r.error("[TalentBankClient] identify received invalid input"),null;let u=await fetch(`${a}/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 b=ce.safeParse(tt,await u.json());return b.success?b.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=z,onEvent:a,persistence:c}){let l=Fe({baseUrl:X[n],publishableKey:t}),d=r===!1?Q:r,u=new V({environment:n,apiKey:{type:"publishable",key:t},logger:d}),b=pe({environment:n,publishableKey:t,logger:d}),w=Ge({rpcClient:u,logger:d,onEvent:a,talentBank:b,persistence:c});return{register:we=>we({logger:d,apiClient:l,analytics:w,rpcClient:u,publishableKey:t,env:n}),analytics:w,apiClient:l}}function le(t){let n=JSON.stringify({message:t.message,acceptLabel:t.acceptLabel??"",declineLabel:t.declineLabel??""}),r=5381;for(let a=0;a<n.length;a++)r=r*33^n.charCodeAt(a);return(r>>>0).toString(36)}function de(t,n){return`${Me}:${t}:${n}`}function ct(t,n){if(typeof window>"u")return!1;try{let r=de(t,le(n));return window.localStorage.getItem(r)==="accepted"}catch{return!1}}function pt(t,n){if(!(typeof window>"u"))try{let r=de(t,le(n));window.localStorage.setItem(r,"accepted")}catch{}}function lt(t){if(!(typeof document>"u")){if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",t,{once:!0});return}Promise.resolve().then(t)}}var s=T(require("valibot"));var ke=["DAILY","WEEKLY","MONTHLY"],Zt=s.record(s.string(),s.union([s.string(),s.array(s.string()),s.object({type:s.literal("provided"),lat:s.number(),lng:s.number(),radius:s.number(),unit:s.optional(s.picklist(["miles","km"])),label:s.optional(s.string())})])),en={pathname:"/job/:id",method:"GET",schema:{response:s.object({id:s.number(),external_id:s.nullish(s.string()),city:s.nullish(s.string()),town:s.nullish(s.string()),category:s.nullish(s.string())})}};async function dt(t,{contact:n,job:r}){let a={};if(r){let c=await t.request(en,{params:{id:r.id}});if((r.id_type==="internal"?String(c.id):c.external_id)!==r.id)throw new Error("Job lookup returned a different role");for(let d of["city","town","category"]){let u=c[d]?.trim();u&&(a[d]=[u])}}await t.request(Re,{body:{contact:n,alerts:"WEEKLY",filters:a}})}var Re={pathname:"/search/save",method:"POST",schema:{response:F(),body:s.object({contact:s.object({email:s.pipe(s.optional(s.string()),s.string(),s.email()),first_name:s.optional(s.string()),last_name:s.optional(s.string())}),alerts:s.pipe(s.optional(s.string()),s.string(),s.picklist(ke)),filters:Zt})}};0&&(module.exports={ApiError,InploiRpcClient,JOB_ALERT_FREQUENCIES,NotFoundError,ParsingError,SchemaValidationError,SdkError,UnauthorisedError,consentStorageKey,createPlugin,createTalentBankClient,endpoint,generateUUID,getConsentAcceptance,getOrCreateAnonymousId,hashConsentConfig,initialiseSdk,inploiBrandedLogger,isApiErrorWithData,isSdkError,noLogging,ready,saveClosedRoleJobAlerts,saveSearchEndpoint,setConsentAcceptance,typed,validateEndpointInputs});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|