@dereekb/zoho 13.9.0 → 13.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/index.js +5 -1
- package/cli/package.json +6 -6
- package/nestjs/package.json +5 -5
- package/package.json +4 -4
package/cli/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __createRequire } from 'node:module';
|
|
3
3
|
const require = __createRequire(import.meta.url);
|
|
4
|
-
var Qc=Object.defineProperty;var eu=Object.getOwnPropertyDescriptor;var S=(e,t,o,r)=>{for(var n=r>1?void 0:r?eu(t,o):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(n=(r?i(t,o,n):i(n))||n);return r&&n&&Qc(t,o,n),n},M=(e,t)=>(o,r)=>t(o,r,e);import Ly from"yargs";import{hideBin as vy}from"yargs/helpers";import{readFile as tu,writeFile as ou,rm as ru,mkdirSync as nu}from"node:fs";import{join as So}from"node:path";import{homedir as au}from"node:os";var Lt=["recruit","crm","desk"];function Co(){return So(au(),".zoho-cli")}function st(){return So(Co(),"config.json")}function ct(){return So(Co(),".tokens.json")}function Y(e,t){if(t){let o=process.env[`ZOHO_${t}_${e}`];if(o)return o}return process.env[`ZOHO_${e}`]}async function w(){let e=st(),t=await cu(e),o=Y("ACCOUNTS_CLIENT_ID"),r=Y("ACCOUNTS_CLIENT_SECRET"),n=Y("ACCOUNTS_REFRESH_TOKEN");if(!t&&!(o&&r&&n))return;let i={clientId:o??t?.shared?.clientId??"",clientSecret:r??t?.shared?.clientSecret??"",refreshToken:n??t?.shared?.refreshToken??"",region:Y("ACCOUNTS_URL")??t?.shared?.region,apiMode:Y("API_URL")??t?.shared?.apiMode};function s(p){let u=p.toUpperCase(),d=Y("ACCOUNTS_CLIENT_ID",u),f=Y("ACCOUNTS_CLIENT_SECRET",u),h=Y("ACCOUNTS_REFRESH_TOKEN",u),g=Y("API_URL",u),R=p==="desk"?Y("DESK_ORG_ID"):void 0,x=t?.[p],C=process.env[`ZOHO_${u}_ACCOUNTS_CLIENT_ID`],O=process.env[`ZOHO_${u}_ACCOUNTS_CLIENT_SECRET`],V=process.env[`ZOHO_${u}_ACCOUNTS_REFRESH_TOKEN`];if(!(!x&&!(C||O||V)&&!R))return{clientId:C??x?.clientId,clientSecret:O??x?.clientSecret,refreshToken:V??x?.refreshToken,apiUrl:g??x?.apiUrl,orgId:R??x?.orgId}}return{shared:i,recruit:s("recruit")??t?.recruit,crm:s("crm")??t?.crm,desk:s("desk")??t?.desk,output:t?.output}}function ut(e,t){let o=e[t],r=e.shared,n=o?.clientId??r.clientId,a=o?.clientSecret??r.clientSecret,i=o?.refreshToken??r.refreshToken;if(!(!n||!a||!i))return{clientId:n,clientSecret:a,refreshToken:i,region:r.region??"us",apiMode:o?.apiUrl??r.apiMode??"production",orgId:o?.orgId}}async function iu(e){let t=st();return nu(Co(),{recursive:!0}),new Promise((o,r)=>{ou(t,JSON.stringify(e,null,2),{},n=>{n?r(n):o()})})}async function U(e){let t=await w(),o={shared:{...t?.shared,...e.shared},recruit:e.recruit!==void 0?{...t?.recruit,...e.recruit}:t?.recruit,crm:e.crm!==void 0?{...t?.crm,...e.crm}:t?.crm,desk:e.desk!==void 0?{...t?.desk,...e.desk}:t?.desk,output:e.output!==void 0?su(t?.output,e.output):t?.output};return await iu(o),o}function su(e,t){return{dumpDir:"dumpDir"in t?t.dumpDir:e?.dumpDir,pick:"pick"in t?t.pick:e?.pick,commands:"commands"in t?t.commands?{...e?.commands,...t.commands}:void 0:e?.commands}}function en(e,t,o){let r=t.join("."),n=r?e?.commands?.[r]:void 0;return{dumpDir:o.dumpDir??n?.dumpDir??e?.dumpDir,pick:o.pick??n?.pick??e?.pick}}async function tn(){await U({output:{dumpDir:void 0,pick:void 0,commands:void 0}})}async function on(){let e=st(),t=ct();await Qr(e),await Qr(t)}function $(e){return Lt.filter(t=>{let o=ut(e,t);return!(!o||t==="desk"&&!o.orgId)})}function cu(e){return new Promise(t=>{tu(e,{encoding:"utf-8"},(o,r)=>{if(o){t(void 0);return}try{t(JSON.parse(r))}catch{t(void 0)}})})}function Qr(e){return new Promise(t=>{ru(e,()=>t())})}function ye(e){return e.length<=4?"***":e.substring(0,4)+"***"}function F(){}import{Inject as pc,Injectable as yl}from"@nestjs/common";function vt(e,t){let o;return t&&typeof e=="string"?o=[e]:ce(e)?o=[...e]:o=[e],o}function Io(e,t){return new Map(vt(e).map(o=>[t(o),o]))}function ce(e,t=!1){return typeof e=="string"?t:e!=null&&typeof e=="object"&&Symbol.iterator in e}function pt(e){for(let t of e)return!1;return!0}function he(e,t){for(let o of e)t(o)}function W(e,t,o=!1){e!=null&&(ce(e,o)?he(e,t):t(e))}function rn(e){if(!Array.isArray(e))throw new Error("Input is not an array/tuple...");let t;if(e.length>0){let o=e[0],r=!1;if(Array.isArray(o)){let n=o.length;r=e.findIndex(i=>Array.isArray(i)?i.length!==n:!0)!==-1}else r=!0;t=r?[e]:e}else t=e;return t}function uu(e){return e!=null?Mo(e):[]}var y=uu;function Mo(e){return Array.isArray(e)?e:[e]}function Oo(e){return nn([],...e)}function nn(e,...t){return e??=[],t.forEach(o=>{o!=null&&an(e,o)}),e}function an(e,t){return Array.prototype.push.apply(e,t),e}import{symmetricDifference as rh}from"extra-set";function pu(e,t){let o=new Set(e??void 0);return t(o),o}function sn(e,t){return pu(e,o=>dt(o,t))}function dt(e,t){W(t,o=>e.add(o))}function lt(e,t=!0){return t?((...o)=>!e.call(void 0,...o)):e}function cn(e){return Object.keys(e).length===0}function ue(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function un(e){let t={};return e.forEach((o,r)=>{t[r]=o}),t}function Po(e){return{...e}}function mt(e){return e!=null}function Me(e){return ce(e,!1)?!pt(e):pn(e)}function Eo(e){let t;return ce(e,!0)?t=!pt(e):pn(e)?t=typeof e=="object"?!cn(e):!0:t=!1,t}function pn(e){return e!=null&&e!==""}function dn(e){return(t=>{let o;return t!=null?o=t.filter(e):o=[],o})}var k=dn(mt),du=dn(Me);function _t({base:e,build:t}){let o=e??{};return t(o),o}function wt(e){return t=>t.map(e)}var Ne=(e=>e);function fe(){return Ne}function lu(e,t){return k(e!=null?Array.isArray(e)?e:mn(e,t):[])}function mn(e,t){let o=new Set(e.keys);return e.values&&dt(o,e.values.map(t)),Array.from(o)}function ko(e,t){let o=lu(t,e);function r(n){let a=n?Array.isArray(n)?n.map(e):mn(n,e):[];return a.length?Oo([k(a),o]):o}return(n,a)=>{let i=r(a),s=new Set(i);return n.filter(p=>{let u=e(p);return s.has(u)?!1:(s.add(u),!0)})}}var mu=e=>e.id;function Zo(e,t,o){let r=o(t);return Do(e,r,o)}function Do(e,t,o=mu){return e.filter(r=>o(r)!==t)}function Lo(e){return t=>{let o=e(t);if(o==="")throw new Error('Cannot use "empty" string for BooleanKey.');return o}}function hn(e){return!e||e.length<=0}function yu(e){return!hn(e)}function hu(e,t,o){return e?[...Zo(e,t,Lo(o)),t]:[t]}function fu(e,t,o){return e&&Zo(e,t,Lo(o))}function gu(e,t,o){return e&&Do(e,t,Lo(o))}function Tu(e){let t=s=>hn(s),o=s=>yu(s),r=(s,c,p=!0)=>p?n(s,c):a(s,c),n=(s,c)=>hu(s,c,e),a=(s,c)=>fu(s,c,e);return{isFalse:t,isTrue:o,set:r,insert:n,remove:a,removeByKey:(s,c)=>gu(s,c,e)}}var vh=Tu(e=>e||void 0);function ge(e,t){let o=xu(e,r=>t(r)?"in":"out");return{included:o.in??[],excluded:o.out??[]}}function xu(e,t){let o=fn(e,t);return un(o)}function fn(e,t){let o=new Map;return e?.forEach(r=>{let n=t(r),a=o.get(n);a!=null?a.push(r):o.set(n,[r])}),o}function gn(e,t,o){return y(t).forEach(r=>e.set(r,o)),e}function vo(e){return Array.from(e.entries())}function Tn(e){return Ru(vo(e))}function Ru(e){let t=[];return e.forEach(([o,r])=>{W(r,n=>{t.push([o,n])})}),t}function No(){let e=new Map,t=(n,a)=>{let i=e.get(n);i==null&&(i=[],e.set(n,i)),W(a,s=>i.push(s))},o=(n,a)=>t(n,rn(a));return{map:()=>e,entries:()=>vo(e),tuples:()=>Tn(e),delete:n=>e.delete(n),add:t,addTuples:o,addToKeys:(n,a)=>W(n,i=>t(i,a)),addTuplesToKeys:(n,a)=>W(n,i=>o(i,a)),has:n=>e.has(n),get:n=>e.get(n)??[]}}function xn(e){let{readKey:t,defaultIfKeyNull:o=!1}=e;return r=>{let n=new Set(r);return a=>{let i=t(a);return i!=null?n.has(i):o}}}var bu=32;function Fu(e){return t=>{let o=new Set;for(let r=0;r<e;r+=1)t&1<<r&&o.add(r);return o}}var Yh=Fu(bu);function Su(e){return typeof e=="function"?e.prototype?Object.getOwnPropertyDescriptor(e,"prototype")?.writable?"function":"class":e.constructor.name==="AsyncFunction"?"function":"arrow":null}function Rn(e){let t=Su(e);return t!=null&&t!=="class"}function pe(e){return Rn(e)?e:()=>e}function yt(e={}){let{startAt:t,increaseBy:o}=e,r=pe(o??1),n=t??0;return()=>{let a=n;return n+=r(),a}}function Cu(e){let{min:t,max:o}=e;return t<=o}function Iu(e){let{min:t,max:o}=e;if(!Cu(e))throw new Error("Invalid bounds. Min was greater than the max.");return r=>r>=t&&r<=o}function Vt(e){let{min:t,max:o,fencePosts:r=!1}=e,n=o-t,a=Iu(e),i=(s=>{let c;if(a(s))c=s;else{let p=r?s<t?1:-1:0;c=((s-t)%n+n)%n+t+p}return c});return i._wrap=e,i}function Kt(e){let{min:t,max:o,wrap:r}=e;return r?Vt(e):n=>Mu(n,t,o)}function Mu(e,t,o){return Math.max(Math.min(e,o),t)}function bn(e){let t;switch(typeof e){case"number":t=e;break;case"string":t=Number(e);break;default:t=0;break}return t}function Fn(e,t){return Math.log(t)/Math.log(e)}function _o(e){let t;switch(e){case"floor":t=Math.floor;break;case"ceil":t=Math.ceil;break;case"none":t=o=>o;break;default:t=Math.round;break}return t}var pf=ht(0);function ht(e,t="cut"){let o=Au(e,t),r=(n=>o(bn(n)));return r._precision=e,r}function Au(e,t="round"){let o;if(t==="cut")o=r=>Sn(r,e);else{let r=_o(t);o=n=>+(r(+(n+"e+"+e))+"e-"+e)}return o}function Sn(e,t){return+((e>0?Math.floor:Math.ceil)(+(e+"e+"+t))+"e-"+t)}function _e(e,t){let o=typeof e=="number"?{min:0,max:e}:e,{min:r,max:n,round:a}=o,i=t??a,s;if(r!=null){let c=n-r;s=()=>Math.random()*c+r}else s=()=>Math.random()*n;if(i&&i!=="none"){let c=typeof i=="function"?i:_o(i),p=s;s=()=>c(p())}return s}function Cn(e){return(t,o)=>{let r=e(t),n=e(o);return r-n}}var ff=Cn(e=>e);function Mn(e){return e.i}var Xf=ko(Mn);var Qf=xn({readKey:Mn});var On=",",Eu=" ";function ku(e,t=On,o=!1){if(e==null)return e;let r=y(e);return o&&(r=r.map(n=>n?.trim())),r.filter(Boolean).join(t)}function Bt(e,t,o){let r=e.split(t),n=[];if(r.length>1){let a=r.length>o,i=a?o-1:r.length;for(let s=0;s<i;s+=1)n.push(r[s]);a&&n.push(r.slice(i).join(t))}else n.push(r[0]);return n}function Zu(e){let{joiner:t,trimByDefault:o=!1}=e,r=function(n,a=o){return ku(n,t,a)};return r.joiner=t,r.trimByDefault=o,r}function An(e){let{joiner:t}=e,o=Zu(e),r=(n,a=i=>i)=>n.split(t).map(s=>a(s.trim()));return{joiner:t,trimByDefault:o.trimByDefault,joinStrings:o,splitStrings:r,splitStringsToSet(n){return new Set(n!=null?r(n):[])},splitJoinRemainder(n,a){return Bt(n,t,a)}}}var Vo=An({joiner:On}),Du=An({joiner:Eu,trimByDefault:!0});var A=Vo.joinStrings,Ng=Vo.splitStrings,_g=Vo.splitStringsToSet,Lu=Du.joinStrings;function Pn(e){return e.trim()}function En(e){return e.toUpperCase()}function kn(e){return e.toLowerCase()}var rT=wt(Pn),nT=wt(En),aT=wt(kn);import{BaseError as Nu}from"make-error";var _u="DBX_ASSERTION_ERROR",Ko=class extends Nu{code=_u;_target;_property;constructor(t,o){super(o),this.name="AssertionError",this._target=t.target,this._property=t.propertyKey}get target(){return this._target}get propertyKey(){return this._property}},Uo=class{handle(t){throw this.buildException(t)}buildException(t){let o=this.buildExceptionString(t);return new Ko(t,o)}buildExceptionString(t){let o;return t.options?.message?o=t.options.message:o="Assertion failed for property '"+t.propertyKey+'".',o}},wu=new Uo;var Zn=lt;function we(e,{forEach:t,filter:o}){Dn(e,o).forEach(t)}function Dn(e,t){return Go(t)(e)}function Go(e){let t;if(e!=null){let o=Ku(e);t=r=>Wo(r).filter(o)}else t=Wo;return t}function Wo(e){return Object.entries(e)}function jo(e){return typeof e=="object"?e:{valueFilter:e}}function Ku(e){let t=jo(e),{valueFilter:o=1,invertFilter:r=!1,keysFilter:n}=t,a;switch(o){case 1:a=([,i])=>i!==void 0;break;case 2:a=([,i])=>i!=null;break;case 3:a=([,i])=>!!i;break;case 4:a=([,i])=>Me(i);break;case 5:a=([,i])=>Eo(i);break;case 6:a=([,i])=>!!i&&Me(i);break;case 7:a=([,i])=>!!i&&Eo(i);break;default:a=()=>!0;break}if(n){let i=a,s=new Set(n.map(c=>c.toString()));a=(c,p)=>i(c,p)&&s.has(c[0])}return Zn(a,r)}function Ve(e){let t,o=n=>{t={value:e(n)}},r=(n=>(t||o(n),t.value));return r.set=n=>t={value:n},r.reset=()=>t=void 0,r.init=o,r.used=()=>!!t,r}function Uu({filter:e,copy:t,dynamic:o=!1}){let r=e!=null?Ke({filter:e,copy:!1}):Wu;return n=>{let a=()=>{let s={};return n.forEach(c=>{let p=r({...c});Object.assign(s,p)}),s},i=o?a:Ve(a);return s=>{let c=i();return t&&(s=Po(s)),Object.assign(s,c),s}}}function Wt(e,t){return Bu(t)(e)}function Bu(e){let t=Uu({filter:e,copy:!1,dynamic:!0});return o=>t(k(o))({})}var cx=Ke({copy:!0,filter:{valueFilter:1}}),ux=Ke({copy:!0,filter:{valueFilter:2}}),Ln=Ke({copy:!0,filter:{valueFilter:4}}),px=Ke({copy:!0,filter:{valueFilter:6}}),dx=qo({valueFilter:1}),lx=qo({valueFilter:6}),mx=qo({valueFilter:2});function qo(e){let t=$o({filter:e,forEach:([o],r,n,a)=>{a.keys.push(o)}});return o=>{let r={keys:[]};return t(o,r),r.keys}}function Ke({copy:e=!1,filter:t={valueFilter:1}}={}){let o=jo(t);o.invertFilter=!o.invertFilter;let r=$o({filter:o,forEach:([n],a,i)=>{delete i[n]}});return(n,a)=>((typeof a=="boolean"?a:e)&&(n={...n}),r(n),n)}var Wu=Ke({copy:!1});function $o({forEach:e,filter:t}){let o=Go(t);return((r,n)=>{o(r).forEach((i,s)=>e(i,s,r,n))})}function Gu(e){let{readKey:t,isModifiedFunction:o=()=>{}}=e;return(r,n)=>{let a=[],i=Io(r,t),s=Io(n,t),c=new Set(i.keys()),p=new Set(s.keys()),u=sn(c,p);return he(u,d=>{if(d==null)return;let f=c.has(d),h=p.has(d),g;h&&f?g=0:f?g=-1:g=1;let R=f?i.get(d):void 0,x=h?s.get(d):void 0,C=R&&x?o(R,x):void 0;a.push({key:d,pastValue:R,nextValue:x,change:g,isModified:C,value:x??R})}),a}}var Cx=Gu({readKey:e=>e});function gt(e,t,o){let[r,n]=Gt(e,t,!1);return r+o+n}function Gt(e,t,o=!1){let r=e.substring(0,t),n=e.substring(t+(o?0:1));return[r,n]}function Nn(e){let t={};for(let[o,r]of[...e].entries())t[r]=o;return t}var ju=["\\","^","$",".","|","?","*","+","(",")","[","]","{","}"],qu=new Set(ju);function Ho(e){let{escapeTargets:t,escapeCharacter:o}=e,r=t instanceof Set?t:new Set(t);return n=>{let a=jt(r,n),i;switch(a.length){case 0:i=n;break;case 1:{let s=n[a[0]];i=gt(n,a[0],o(s));break}default:{let s=[],c=a.length,p=0,u=0;for(let d=0;d<c;d+=1){u=a[d];let f=n[u],g=n.substring(p,u)+o(f);s.push(g),p=u+1}s.push(n.substring(p)),i=s.join("");break}}return i}}var _n=Ho({escapeTargets:qu,escapeCharacter(e){return`\\${e}`}});function $u(e){return(t,o)=>{let r=o??Number.MAX_SAFE_INTEGER,n=[];for(let[a,i]of[...t].entries())if(e.has(i)&&(n.push(a),n.length>=r))break;return n}}function jt(e,t,o){return $u(e)(t,o)}function Hu(e,t){return jt(e,t,1)[0]}function qt(e){return t=>{let r=Hu(typeof e=="string"?new Set([e]):e,t),n;return r!=null?n=Gt(t,r,!1):n=[t,void 0],n}}function wn(e,t){return qt(t)(e)}function Vn(e){let t=qt(e);return o=>t(o)[0]}var Qx=Vn("#"),eR=qt("#");var Ue="/",zu=".";function Ju(e){let t=e.split(zu,3).length-1,o;switch(t){case 0:e.length===0?o="invalid":e[e.length-1]===Ue?o="folder":o="file";break;case 1:o="typedfile";break;default:o="invalid";break}return o}function Kn(e){return Ju(e)!=="invalid"}var Yu=/^\/+/,Xu=/\/+$/;var Qu=/\/{2,}/g;function Un(e){return e.startsWith(Ue)?e.replace(Yu,Ue):`${Ue}${e}`}function Bn(e){return e.replace(Qu,Ue)}function Wn(e){return e.replace(Xu,"")}var ep=/(.+)\.(.+)/;function tp(e){return ep.test(e)}var Gn=/:(\d+)/;function op(e){return Gn.test(e)}function rp(e){let t=Gn.exec(e);return t?Number(t[1]):void 0}function np(e){let t=Hn(e),o=qn(t),{domain:r,path:n}=o,a=tp(r),i=op(e),s=i?rp(e)??void 0:void 0,[c,p]=wn(o.path,"?"),u=a&&(c===""||Kn(c+"/")),d=ip(e);return{input:e,isWebsiteUrl:u,hasWebsiteDomain:a,hasHttpPrefix:d,hasPortNumber:i,portNumber:s,splitPair:o,domain:r,websitePath:n,path:c,query:p}}function zo(e){let t=np(e);return t.hasHttpPrefix&&t.isWebsiteUrl}function jn(e,t=!1){let o=jt(new Set("?"),e),r,n=e;return t&&o.length?r=o:o.length>1&&(r=o.reverse(),r.pop()),r?.length&&r.forEach(a=>n=gt(n,a,"&")),n}function qn(e){let t=Hn(e);return ap(t)}function ap(e){let t=Bt(e,"/",2),o=t[0],r=t[1];return{domain:o,path:Un(r??"/")}}var $n=/^https:\/\/|http:\/\//;function Hn(e){return e.replace($n,"")}function ip(e){return $n.test(e)}var jR={prefixes:"email.",domains:"test.dereekb.com",numberFactory:yt()};var qR={internationalAreaCodes:[1210,1979,1512,1303],numberFactory:_e({min:2e6,max:1e7,round:"floor"})};import{BaseError as tb}from"make-error";var sp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_",cp="!";function up(e){let{negativePrefix:t,digits:o}=e,r=t?"integer":"positive_integer",n=Math.min(6,Math.floor(Math.log2(o.length))),a=Math.pow(2,n),i=a-1,s=Nn(o);function c(u){let d="",f=u<0;f&&(u=-u);do{let h=u&i;d=o[h]+d,u>>>=n}while(u!==0);return f&&t&&(d=t+d),d}function p(u){let d=!1;u[0]===t&&(d=!0);let f=d?1:0,h=0;for(let g=f;g<u.length;g+=1)h=(h<<n)+s[u[g]];return d&&(h=-h),h}return{type:r,digits:o,bitDepth:a,negativePrefix:t,encodeNumber:c,decodeNumber:p}}var pp=up({negativePrefix:cp,digits:sp});var zn=-90,Jn=90,qb=Jn-zn,Yn=-180,Xn=180,dp=Xn-Yn;var $b=Kt({min:zn,max:Jn}),Hb=Vt({min:Yn,max:Xn});var mp=24,yp=60,Qn=1440,ea=60,uF=ea*yp,Z=1e3,de=Z*60,$t=de*60,ta=$t*mp,hp=7,fp=ta*hp;function Ht(e){return e.getTime()<Date.now()}var mF=ht(3);var yF=Qn-1;function oa(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}async function xt(e,t){return new Promise(o=>setTimeout(()=>o(t),e))}function bp(e){let n=$t,a={startLimitAt:1,cooldownRate:1,exponentRate:2,maxWaitTime:n},i=0,s=Number.MAX_SAFE_INTEGER,c=new Date,p=!0;h(e??a);function u(){return{...a}}function d(){return p}function f(O){p=O}function h(O,V=!1){let se=Math.max(0,O.startLimitAt??1),I=O.cooldownRate??1,K=O.maxWaitTime??n,_=O.exponentRate??2;a={startLimitAt:se,cooldownRate:I,maxWaitTime:K,exponentRate:_},s=Fn(_,K/Z+1),V&&g()}function g(){i=0,c=new Date}function R(O){if(!p)return 0;let{cooldownRate:V}=a,I=(Date.now()-c.getTime())*V/Z,K=Math.max(i-I,0),_=Math.max(0,K-a.startLimitAt);return O&&(i=K+O,c=new Date),_>=s?a.maxWaitTime:(Math.pow(a.exponentRate,Math.max(_,0))-1)*Z}function x(O){return R(O??0)}function C(){let O=R(1);return xt(O)}return{waitForRateLimit:C,getNextWaitTime:x,getConfig:u,setConfig:h,getEnabled:d,setEnabled:f,reset:g}}function aa(e){let o=bp({exponentRate:1.5,maxWaitTime:Z*8,...e}),r=de,n=new Date,a=0,i=0,s=!0;C(e,!0);function c(){Ht(n)&&d()}function p(){return s}function u(I){s=I}function d(){i=a,n=new Date(Date.now()+r)}function f(){return n}function h(){return Math.max(0,n.getTime()-Date.now())}function g(I){n=I}function R(){return c(),i}function x(I){i=I}function C(I,K=!1){a=I.limit??a,r=I.resetPeriod??r;let _={cooldownRate:I.cooldownRate??Math.max(.1,r/Z),exponentRate:I.exponentRate??1.5,maxWaitTime:I.maxWaitTime??Z*8};o.setConfig(_,K),K&&d(),n=I.resetAt??n}function O(I){if(!s)return 0;function K(){return i-=I,o.getNextWaitTime(I)}let _=0;return i>0?_=K():(c(),i>0?_=K():_=h()),_}function V(I){return O(I??0)}function se(){let I=O(1);return xt(I)}return{getRemainingLimit:R,setRemainingLimit:x,getTimeUntilNextReset:h,getResetAt:f,setNextResetAt:g,setConfig:C,reset:d,getNextWaitTime:V,waitForRateLimit:se,getEnabled:p,setEnabled:u}}function ia(e){let{promiseFactories:t,successOnMaybe:o,throwErrors:r}=e;return async(n,a)=>{let{successOnMaybe:i,throwErrors:s}=a??{},c=i??o,p=s??r,u;for(let d of t)try{if(u=await d(n),u!=null||c)break}catch(f){if(p)throw f}return u}}import{BaseError as xC}from"make-error";function Fp(e){return t=>{let o={};return Object.entries(t).forEach(([r,n])=>{let a=e(r,n);o[a]=n}),o}}var zC=Fp(e=>{let t=e;return typeof e=="string"&&(t=e.toLowerCase()),t});function Sp(e){return t=>Cp(t).then(o=>o.toString(e))}var DI=Sp("base64");function Cp(e){let t=[];return new Promise((o,r)=>{e.on("data",n=>t.push(Buffer.from(n))),e.on("end",()=>o(Buffer.concat(t))),e.on("error",r)})}var Ip="__CATCH_ALL_HANDLE_RESULT_KEY__";function ca(e,t){let o=t?.defaultResult??!0,r=t?.negativeResult??!1;return()=>{let n,a=new Map,i=p=>{n=p},s=(p,u)=>{p===Ip?i(u):gn(a,p,u)},c=(p,u,d)=>{let f=d.bind(p);s(u,f)};return _t({base:(p=>{let u=e(p),d=(u!=null?a.get(u):void 0)??n,f;return d?f=Promise.resolve(d(p)).then(h=>h??o):f=Promise.resolve(r),f}),build:p=>{p.readKey=e,p.set=s,p.bindSet=c,p.setCatchAll=i}})}}function Mp(e,t){return{accessor:t,boundTo:e,set:(o,r)=>{t.bindSet(e,o,r)},setCatchAll:o=>{t.setCatchAll(o)}}}function Op(e,t){let o=r=>{e.set(t,r)};return o.key=t,o}function Ap(e,t,o){let r=Op(e,t);return n=>{r(function(a){let i=o(a);return n.call(this,i)})}}function ua(e,t){return o=>Ap(e,o,t)}function pa(e){return t=>(o,r)=>{let n=Mp(o,t),a=e.configurerForAccessor(n);r(a)}}import{BaseError as sM}from"make-error";var Jo=class{_length=0;_storage={};get length(){return this._length}key(t){return Object.keys(this._storage)[t]??null}hasKey(t){return ue(this._storage,t)}getItem(t){return this._storage[t]??null}setItem(t,o){o==null?this.removeItem(t):(this.hasKey(t)||(this._length=this._length+1),this._storage[t]=String(o))}removeItem(t){this.hasKey(t)&&(delete this._storage[t],this._length=this._length-1)}clear(){this._storage={},this._length=0}},pM=new Jo;function zt(e){let t={};return Object.entries(e).forEach(([o,r])=>{t[r]=o}),t}var da="image/jpeg",Pp="image/png",Ep="image/webp",kp="image/gif",Zp="image/heif",Dp="image/tiff",Lp="image/svg+xml",vp="image/raw",Np={jpeg:da,jpg:da,png:Pp,webp:Ep,gif:kp,svg:Lp,raw:vp,heif:Zp,tiff:Dp},MM=zt(Np);var _p="application/pdf",wp="application/vnd.openxmlformats-officedocument.wordprocessingml.document",Vp="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",Kp="text/plain",Up="text/csv",Bp="text/html",Wp="application/xml",Gp="application/json",jp="application/yaml",qp="text/markdown",$p={pdf:_p,docx:wp,xlsx:Vp,txt:Kp,csv:Up,html:Bp,xml:Wp,json:Gp,yaml:jp,md:qp},OM=zt($p);var Hp="application/zip",zp={zip:Hp},AM=zt(zp);function Jp(e){let{prefix:t,suffix:o,prefixEmptyString:r,suffixEmptyString:n}=e,a=t??"",i=o??"";function s(p){let u=p;if(a)for(;u.startsWith(a);)u=u.slice(a.length);if(i)for(;u.endsWith(i);)u=u.slice(0,u.length-i.length);return u}function c(p){let u=s(p),d;return u===""?(d="",r&&(d=`${a}${u}`),n&&(d=`${d}${i}`)):d=`${a}${u}${i}`,d}return{prefix:a,suffix:i,prefixEmptyString:r,suffixEmptyString:n,prefixSuffixString:c,cleanString:s}}var EM=Jp({prefix:"-"});function Yp(e){return(t,o)=>{let r=e(t),n=e(o);return r.localeCompare(n)}}var ZM=Yp(e=>e.label);var Rt={VISIT_ALL:0,VISIT_NODE_ONLY:1,VISIT_CHILDREN_ONLY:2,SKIP_ALL:3};var iO={ADD_ALL:Rt.VISIT_ALL,ADD_NODE_ONLY:Rt.VISIT_NODE_ONLY,ADD_CHILDREN_ONLY:Rt.VISIT_CHILDREN_ONLY,SKIP_ALL:Rt.SKIP_ALL};var Xp=-1,Yo=0;function Qp(e){return e?.page??Xp}function Xo(e){return Qp(e)+1}import{BaseError as la}from"make-error";var H=class extends la{constructor(o){super(`Fetch request failed to build due to an unexpected error: ${typeof o=="object"?o.message:o}`);this.error=o}};function ma(e){return(t,o)=>ed(e(t,o))}var Be=class extends la{constructor(o){super(`Fetch response was a non-ok status code (${o.status}): ${o.statusText}`);this.response=o}};function ed(e){return e.then(t=>{if(!t.ok)throw new Be(t);return t})}import{BaseError as CA}from"make-error";function ya(e){return(t,o)=>{let r,n=o?.timeout??t.timeout;if(!o?.signal&&n){let i=new AbortController;r=i,o={...o,signal:i.signal}}let a=e(t,o);if(n){let i=setTimeout(()=>{r?.abort()},n);a=a.finally(()=>{clearTimeout(i)})}return a}}function fa(e){let{makeFetch:t,makeRequest:o,baseRequest:r}=e;return{fetchRequestFactory:n=>ga({makeRequest:o,baseRequest:r,...n}),makeFetch:(n={})=>od({makeRequest:o,makeFetch:t,baseRequest:r,...n}),makeRequest:e.makeRequest}}var td=(e,t)=>t(e);function od(e){let{makeFetch:t=fetch,fetchHandler:o=td,useTimeout:r,requireOkResponse:n,mapResponse:a}=e,i=t;r&&(i=ya(i)),n&&(i=ma(i));let s=ga(e);return async(c,p)=>{let u=await s(c,p),d=o(u,i);return a&&(d=a(d)),d}}var rd=(e,t)=>new Request(e,t);function ga(e){let{makeRequest:t=rd,baseUrl:o,baseRequest:r,timeout:n,requestInitFactory:a,useBaseUrlForConfiguredFetchRequests:i=!1,forceBaseUrlForWebsiteUrlWithPrefix:s=i}=e,c=o?new URL(Wn(o)):void 0,p=c?h=>{let g,R=h.toString();if(!s&&zo(R))g=new URL(R);else{let x=c.origin+Bn("/"+c.pathname+"/"+h);g=new URL(x,c)}return g}:void 0;async function u(h){let g=oa(h)?await h:h;return ha(g)?g:t(g)}let d=p?async h=>{let g,R,x;if(typeof h=="string"?g=h:ha(h)?i?(g=h.url,R=h):x=h:x=await t(h),!x){let C=p(g);x=await t(C.href,R)}return x}:u,f;if(r!=null||n!=null){let h=pe(r);async function g(){let x=await h();return n?{...x,timeout:n}:x}async function R(x,C){let O=await g(),V=nd(O,await C),se=V.timeout===void 0?x.timeout:V.timeout;return{...V,timeout:se}}a?f=(x,C)=>a(x,R(x,C)):f=(x,C)=>R(x,C)}else a?f=a:f=(h,g)=>g;return async(h,g)=>{try{let R=await d(h);g=await f(R,g);let x=await t(R,g);return x.timeout=n,x}catch(R){throw R instanceof H?R:new H(R)}}}function nd(e,t){let o;if(t){let r=ad([e.headers,t.headers]);o={...e,...t,headers:r}}else o=e;return o}function ad(e){let t=No();return k(e).forEach(o=>{let r=id(o),n=new Set;r.forEach(([a,i])=>{n.has(a)||(t.delete(a),n.add(a)),i&&t.add(a,i)})}),t.tuples()}function id(e){let t=[];return Array.isArray(e)?t=e:typeof e.forEach=="function"?e.forEach((o,r)=>{t.push([r,o])}):typeof e=="object"&&(t=Object.entries(e)),t}function ha(e){return!!e.url}import{safeParse as sd}from"fast-content-type-parse";function Jt(e){let t=e.headers.get("content-type"),o=sd(t??""),r=o.type!==""?o:void 0;return{response:e,rawContentType:t,contentType:r,mimeType:r?.type}}function Ta(e){let{updateWithResponse:t,maxRetries:o}=e,r=o??1,n=e.rateLimiter,a=async(i,s)=>{async function c(p){await n.waitForRateLimit();let u,d;try{u=await s(i.clone())}catch(h){d=h,u=d.response}if(await t(u,d)&&p<r)u=await c(p+1);else if(d!=null)throw d;return u}return c(0)};return a._rateLimiter=n,a}var Qo=class extends H{constructor(o){super("There was no next page for this.");this.page=o}},er=class extends H{constructor(o,r){super(`The limit of ${r} for the number of pages to read was reached.`);this.page=o;this.limit=r}},cd=100;function We(e){let{fetch:t,readFetchPageResultInfo:o,buildInputForNextPage:r,defaultMaxPage:n,defaultMaxItemsPerPage:a}=e;return(i,s)=>{let{maxPage:c=n,maxItemsPerPage:p}=s??{},u=p??a,d=c===null?Number.MAX_SAFE_INTEGER:c??cd;function f(g,R=void 0){return async()=>{let x=await t(g),{cursor:C,nextPageCursor:O,hasNext:V}=await o(x),se=C??R?.cursor,I=V!==!1,K=R?R.page+1:Yo,_=K>=d,it={input:g,result:x,page:K,previous:R,hasNext:I,isAtMaxPage:_,cursor:se,nextPageCursor:O,fetchNext:Ve(async()=>{if(_)throw new er(it,d);let Xr=I?await r(it,g,{maxPage:d,maxItemsPerPage:u}):void 0;if(!Xr)throw new Qo(it);return f({...g,...Xr},it)()})};return it}}return{input:i,fetchNext:Ve(()=>f(i)())}}}function T(e,t){let{omitKeys:o,filterEmptyValues:r}=t??{},n=Array.isArray(e)?Wt(e):e,a=r??!0?Ln(n??{}):n,i=new URLSearchParams(a);return o!=null&&W(o,s=>i.delete(s),!1),i}function tr(e){let t;if(typeof e=="string")t=e;else if(ud(e))t=e.href;else{let o=tr(e.url);if(e.queryParams){let r=ld(e.queryParams);pt(r)?t=o:t=jn(o+`?${r.toString()}`)}else t=o}return t}function ud(e){return typeof e=="object"&&e instanceof URL}function pd(e){return typeof e=="object"&&e instanceof URLSearchParams}function dd(e){let t=[];return he(e,o=>{let[r,n]=o;if(r!=null&&n!=null){let a=String(r);W(n,i=>{i!=null&&t.push([a,String(i)])})}}),t}function ld(e){let t;return pd(e)?t=e:typeof e=="string"?t=new URLSearchParams(e):ce(e)?t=new URLSearchParams(dd(e)):t=md(e),t}function md(e){let t=[];return we(e,{forEach:o=>{let[r,n]=o,a=String(r);n!=null&&W(n,i=>{t.push([a,String(i)])})}}),new URLSearchParams(t)}var or=class extends Error{constructor(o){super("Failed to parse the JSON body.");this.response=o}};function yd(e){return e!=null?typeof e=="string"?e:JSON.stringify(e):void 0}var hd=e=>{throw new or(e)},X=e=>null;function Q(e,t){let o;typeof t=="function"?o={handleFetchJsonParseErrorFunction:t}:o=t??{},o={...o,handleFetchJsonParseErrorFunction:o.handleFetchJsonParseErrorFunction??hd};let{handleFetchJsonParseErrorFunction:r,interceptJsonResponse:n}=o,a=xa(o);return(i,s,c)=>{let p=tr(i),u=a(s,c),d=typeof s=="object"?s.interceptResponse:void 0;return e(p,u).then(h=>{let g=h.json().catch(r),R=n?g.then(x=>n(x,h)):g;return d?R.then(x=>d(x,h)):R})}}function xa(e={}){let{defaultMethod:t="GET",mapFetchJsonInput:o=fe()}=e;return(r=t,n)=>{let a;return typeof r=="string"?a={method:r,body:n}:a=r,a=o(a),{...a,method:a.method,body:yd(a.body)}}}var HA=xa();var ee=fa({makeFetch:fetch,makeRequest:(e,t)=>new Request(e,t)});function Ge(){return{data:[],info:{page:1,per_page:100,count:0,more_records:!1}}}function v(e,t){return We({...t,fetch:e,readFetchPageResultInfo:function(o){return{hasNext:o.info?.more_records??!1}},buildInputForNextPage:function(o,r,n){return{...r,page:Xo(o),per_page:n.maxItemsPerPage??r.per_page}}})}function Yt(e){switch(e){case"sandbox":return"https://recruitsandbox.zoho.com/recruit";case"production":return"https://recruit.zoho.com/recruit";default:return e}}var je="Candidates",Ra="Job_Openings",Xt="Notes",ba="Emails",bt="Attachments";function Qt(e){let t;if(e!=null)switch(typeof e){case"string":t=e;break;case"object":{let o;Array.isArray(e)?o={and:[e]}:o=e,t=eo(o);break}default:break}return t}function eo(e){function t(i){let s;return typeof i=="object"?Array.isArray(i)?s=i.map(rr):i&&(s=eo(i)):s=i,s}function o(i,s){return i.length>1?`(${i.join(s)})`:i[0]}function r(i,s){let c=k(i.map(t)).flatMap(y);return o(c,s)}let n=e.or?r(e.or,"or"):void 0,a=n;return e.and&&(a=r([r(e.and,"and"),n],"and")),a}var Fa=Ho({escapeTargets:["(",")",","],escapeCharacter:e=>`\\\\${e}`});function rr(e){let t=Fa(e.value);return`(${e.field}:${e.filter}:${t})`}var Sa=Qt;import{BaseError as Pd}from"make-error";import{BaseError as Td}from"make-error";var xd="__internal_data_array_blank_error";function Rd(e){return Array.isArray(e?.data)}var $e="success";function z(e){let t=typeof e,o;return t==="object"?o=e:o={code:e,message:""},o}var Te=class extends Td{constructor(o){super(o.message);this.error=o}get code(){return this.error.code}},B=class extends Te{constructor(o,r,n){super(o);this.data=o;this.errorResponseData=r;this.responseError=n}},qe=class extends B{constructor(t,o){super({code:xd,message:"Check data for individual errors."},t,o)}get errorDataArray(){return this.errorResponseData.data}};function te(e,t){let{logDataArrayErrors:o=!1}=t??{};return r=>{r instanceof qe&&!o||(r instanceof B?console.log(`${e}Error(${r.responseError.response.status}): `,{error:r,errorData:r.data}):r instanceof Te?console.log(`${e}Error(code:${r.code}): `,{error:r}):console.log(`${e}Error(name:${r.name}): `,{error:r}))}}function oe(e,t){return(o,r=t,n)=>async(a,i)=>{try{return await o(a,i)}catch(s){if(s instanceof Be){let c=await e(s);if(c)throw r(c),n?.(c),c}throw s}}}function re(e){return(t,o)=>{if(t?.error!=null){let n=new Be(o),a=e(t,n);if(a)throw a}return t}}var bd="INTERNAL_ERROR",Fd="INVALID_TOKEN",G=class extends B{},Ca="FAILURE",nr=class extends B{},Sd="4834",Ft=class extends B{},Cd="INVALID_QUERY",ar=class extends B{get details(){return this.error.details}},to="MANDATORY_NOT_FOUND",xe="DUPLICATE_DATA",oo="INVALID_DATA",Id="TOO_MANY_REQUESTS",Ia=429,Md="X-RATELIMIT-LIMIT",Od="X-RATELIMIT-REMAINING",Ad="X-RATELIMIT-RESET",Ma=100,Oa=de;function ir(e){let t=e.get(Md),o=e.get(Od),r=e.get(Ad),n=null;if(t!=null&&o!=null&&r!=null){let a=Number(t),i=Number(o),s=Number(r),c=new Date(s);n={limit:a,remaining:i,reset:s,resetAt:c}}return n}var St=class extends B{get headerDetails(){return ir(this.responseError.response.headers)}};function ne(e,t){let o;if(Rd(e))o=new qe(e,t);else{let r=le(e,t);if(r){let n=z(r);switch(n.code){case bd:o=new nr(n,e,t);break;case Fd:o=new G(n,e,t);break;case Sd:o=new Ft(n,e,t);break;case Cd:o=new ar(n,e,t);break;case Id:o=new St(n,e,t);break;default:o=new B(n,e,t);break}}}return o}function le(e,t){return e.error??e.data?.[0]??(t.response.ok?void 0:e)}var Aa="ALREADY_ASSOCIATED",sr=class extends Pd{constructor(o,r){super("There was no content or matching records for the content. It may not exist.");this.moduleName=o;this.recordId=r}},He=class extends Te{},cr=class extends He{},ur=class extends He{},ro=class extends He{get invalidFieldDetails(){return this.error.details}},pr=class extends ro{};function Pa(e){let t;switch(e.code){case oo:{let o=new ro(e);o.invalidFieldDetails.id?t=new pr(e):t=o;break}case to:t=new cr(e);break;case xe:t=new ur(e);break;default:t=new He(e);break}return t}function Ea(e,t){return o=>{if(o?.data?.length)return o;throw new sr(e,t)}}var Ed=te("ZohoRecruit");async function kd(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=ka(t,e)),o}function ka(e,t){let o,r=le(e,t);if(r)switch(z(r).code){default:o=ne(e,t);break}return o}var Za=re(ka),Da=oe(kd,Ed);import{BaseError as Zd}from"make-error";function lr(e,t,o){return(({data:r,module:n})=>e.fetchJson(`/v2/${n}${t}`,D(o,{data:y(r)})).then(a=>{let i=Array.isArray(r),s=ae(y(r),a.data),c;if(i)c=s;else{let{successItems:p,errorItems:u}=s;if(u[0]!=null)throw Pa(u[0].result);c=p[0].result.details}return c}))}function La(e){return lr(e,"","POST")}function va(e){return lr(e,"/upsert","POST")}function Na(e){return lr(e,"","PUT")}function _a(e){return({ids:t,module:o,wf_trigger:r})=>e.fetchJson(`/v2/${o}?${T({ids:t,wf_trigger:r})}`,D("DELETE")).then(Dd)}function wa(e){return t=>e.fetchJson(`/v2/${t.module}/${t.id}`,D("GET")).then(Ea(t.module)).then(o=>o.data[0])}function Va(e){return(t=>e.fetchJson(`/v2/${t.module}?${$a(t).toString()}`,D("GET")))}function mr(e){function t(o){let r={...o};if(delete r.criteria,o.criteria!=null){let n=Sa(o.criteria);r.criteria=n}if(!r.word&&!o.criteria&&!o.email&&!o.phone)throw new Error("At least one of word, criteria, email, or phone must be provided");return $a(r)}return(o=>e.fetchJson(`/v2/${o.module}/search?${t(o).toString()}`,D("GET")).then(r=>r??{data:[],info:{more_records:!1}}))}function Ka(e){return v(mr(e))}function ze(e){return t=>{let{targetModule:o,returnEmptyRecordsInsteadOfNull:r=!0}=t;return n=>e.fetchJson(`/v2/${n.module}/${n.id}/${o}?${fr(n,n.filter).toString()}`,D("GET")).then(a=>a??(r!==!1?Ge():a))}}function yr(e){return ze(e)({targetModule:ba})}function Ua(e){return v(yr(e))}function hr(e){return ze(e)({targetModule:bt})}function Ba(e){return v(hr(e))}var VP=20*1024*1024;function Wa(e){return t=>{let{attachmentCategoryId:o,attachmentCategoryName:r,file:n,attachmentUrl:a}=t,i={attachments_category_id:A(o),attachments_category:A(r)};if(!i.attachments_category_id?.length&&!i.attachments_category?.length)throw new Error("attachmentCategoryId or attachmentCategoryName must be provided and not empty.");let s=`/v2/${t.module}/${t.id}/${bt}?${T(i).toString()}`,c;if(n!=null){let p=new FormData;p.append("file",n),c=e.fetch(s,{method:"POST",headers:{"Content-Type":""},body:p})}else if(a){let p=`${s}&${T({attachment_url:a}).toString()}`;c=e.fetch(p,{method:"POST"})}else throw new Error("file or attachmentUrl must be provided.");return c}}function Ga(e){return t=>e.fetch(`/v2/${t.module}/${t.id}/${bt}/${t.attachment_id}`,{method:"GET"}).then(Jt)}function ja(e){return t=>e.fetch(`/v2/${t.module}/${t.id}/${bt}/${t.attachment_id}`,{method:"DELETE"})}var dr=class extends Zd{constructor(o){super(`An error occured during the execution of the function. Code: ${o.code}, Message: ${o.message}`);this.error=o}};function qa(e){return t=>{let r=T(t.params).toString(),n=!!t.apiKey,a=(n?`auth_type=apikey&zapikey=${t.apiKey}`:"auth_type=oauth")+(r?`&${r}`:""),i=`/v2/functions/${t.functionName}/actions/execute?${a}`,c=`${n&&t.apiUrl!=null?Yt(t.apiUrl):""}${i}`;return e.fetchJson(c,D("POST")).then(p=>{if(p.code!=="success")throw new dr(p);return p.details})}}function $a(...e){return T(e,{omitKeys:"module"})}function fr(...e){return T(e,{omitKeys:["id","module"]})}function D(e,t){return{method:e,body:t??void 0}}function Dd(e){let{data:t}=e,o=[],r=[];return t.forEach(a=>{a.status===$e?o.push(a):r.push(a)}),{...e,successItems:o,errorItems:r}}function ae(e,t){let o=[],r=[];return e.forEach((a,i)=>{let s=t[i];s.status===$e?o.push({input:a,result:s}):r.push({input:a,result:s})}),{successItems:o,errorItems:r}}function Ha(e){return t=>e.fetchJson(`/v2/${je}/actions/associate`,D("PUT",{data:y(t)})).then(o=>{let r=o.data.map(()=>t),n=ae(r,o.data),{included:a,excluded:i}=ge(n.errorItems,s=>s.result.code===Ca&&s.result.details.error[0].code===Aa);return{...n,errorItems:i,alreadyAssociatedErrorItems:a,allErrorItems:n.errorItems}})}function za(e){return t=>e.fetchJson(`/v2/${t.module}/${t.id}/associate?${fr(t).toString()}`,D("GET")).then(o=>o??Ge())}function gr(e){let t=za(e);return o=>t({...o,module:je})}function Ja(e){return v(gr(e))}function Tr(e,t=Ra){let o=za(e);return r=>o({...r,module:t})}function Ya(e){return v(Tr(e))}function xr(e){return t=>e.fetchJson(`/v2/${Xt}`,D("POST",{data:t.data})).then(o=>ae(y(t.data),o.data))}function Xa(e){return t=>e.fetchJson(`/v2/${Xt}?${T({ids:t.ids})}`,D("DELETE")).then(o=>ae(y(t.ids),o.data))}function Rr(e){return ze(e)({targetModule:Xt})}function Qa(e){return v(Rr(e))}function ei(e){let t=xr(e);return o=>{let{module:r,id:n,notes:a}=o,i={data:y(a).map(s=>({...s,se_module:r,Parent_Id:n}))};return t(i)}}function ri(e){return t=>e.fetchJson(`/v2/settings/tags?${T({module:t.module})}`,D("POST",{tags:y(t.tags)})).then(o=>{let r=ae(y(t.tags),o.tags),{included:n,excluded:a}=ge(r.errorItems,i=>i.result.code===xe);return{...r,errorItems:a,duplicateErrorItems:n,allErrorItems:r.errorItems}})}function ni(e){return t=>e.fetchJson(`/v2/settings/tags?${T({module:t.module,my_tags:t.my_tags})}`,D("GET")).then(o=>({...o,data:o.tags}))}var ti=100;function ai(e){return t=>{if(Array.isArray(t.ids)&&t.ids.length>ti)throw new Error(`Cannot add tags to more than ${ti} records at once.`);return e.fetchJson(`/v2/${je}/actions/add_tags?${T({tag_names:t.tag_names,ids:t.ids})}`,D("POST")).then(o=>{let r=o.data.map(()=>t);return ae(r,o.data)})}}var oi=100;function ii(e){return t=>{if(Array.isArray(t.ids)&&t.ids.length>oi)throw new Error(`Cannot remove tags from more than ${oi} records at once.`);return e.fetchJson(`/v2/${je}/actions/remove_tags?${T({tag_names:t.tag_names,ids:t.ids})}`,D("POST")).then(o=>{let r=o.data.map(()=>t);return ae(r,o.data)})}}var Ld="invalid_code",vd="invalid_client",br=class extends H{constructor(o){super(`ZohoAccountsAccessTokenError: ${o}`);this.errorCode=o}},Je=class extends H{constructor(o){super(`Failed to retrieve proper authentication for the API call. Reason: ${o}`);this.reason=o}},Nd=te("ZohoAccounts");async function _d(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=si(t,e)),o}function si(e,t){let o,r=e.error;if(r){let n=z(r);switch(n.code){case Ld:case vd:o=new br(n.code);break;default:o=ne(e,t);break}}return o}var ci=re(si),ui=oe(_d,Nd);function Re(e){return async()=>{let t=await e();if(!t.accessToken)throw new Je;return t.accessToken}}var wd=e=>{let t="limit"in e?e.limit:void 0,o="resetAt"in e?e.resetAt:void 0,r=t!=null?" The limit is "+String(t)+" requests per reset period.":"",n=o!=null?" Will be reset at "+String(o)+".":"";console.warn("zohoRateLimitedFetchHandler(): Too many requests made."+r+n)};function Fr(e){let{readRateLimitDetails:t}=e,o=e.onTooManyRequests!==!1?e.onTooManyRequests??wd:void 0,r=e.maxRateLimit??Ma,n=e.resetPeriod??Oa;function a(c,p){return{limit:c,startLimitAt:Math.ceil(c/10),cooldownRate:1.2*(c/(n/Z)),exponentRate:1.08,maxWaitTime:Z*10,resetPeriod:n,resetAt:p}}let i=a(r),s=aa(i);return Ta({rateLimiter:s,maxRetries:e.maxRetries,updateWithResponse:function(c,p){let u=t(c.headers),d=!1,f=!1;if(u){let{remaining:h,limit:g,resetAt:R}=u;if(g!=null&&g!==r){let x=a(g,R??void 0);s.setConfig(x,!1)}if(s.setRemainingLimit(h),R&&s.setNextResetAt(R),f=!0,c.status===Ia){d=!0;try{o?.(u,c,p)}catch{}}}return s.setEnabled(f),d}})}function be(e){return Fr({...e,readRateLimitDetails:Vd})}function Vd(e){let t=ir(e),o;return t&&(o={remaining:t.remaining,limit:t.limit,resetAt:t.resetAt}),o}function pi(e){let{accountsContext:t}=e,o=Re(t.loadAccessToken),r=be(e.rateLimiterConfig),{logZohoServerErrorFunction:n,fetchFactory:a=i=>ee.makeFetch({baseUrl:i.apiUrl,baseRequest:async()=>({headers:{"Content-Type":"application/json",Authorization:`Bearer ${await o()}`}}),fetchHandler:r,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return i=>{if(!i.apiUrl)throw new Error("ZohoConfig missing api url.");let s=Yt(i.apiUrl),c=a({apiUrl:s}),p=Da(c,n,h=>{h instanceof G&&t.loadAccessToken.resetAccessToken()}),u=Q(p,{interceptJsonResponse:Za,handleFetchJsonParseErrorFunction:X});return{recruitContext:{fetch:p,fetchJson:u,accessTokenStringFactory:o,config:{...i,apiUrl:s},zohoRateLimiter:r._rateLimiter}}}}function no(e){switch(e){case"sandbox":return"https://crmsandbox.zoho.com/crm";case"production":return"https://www.zohoapis.com/crm";default:return e}}var ao="Notes",di="Emails",Ct="Attachments";var li=Qt;import{BaseError as Kd}from"make-error";var Sr=class extends Kd{constructor(o,r){super("There was no content or matching records for the content. It may not exist.");this.moduleName=o;this.recordId=r}},Ye=class extends Te{},Cr=class extends Ye{},Ir=class extends Ye{},io=class extends Ye{get invalidFieldDetails(){return this.error.details}},Mr=class extends io{};function mi(e){let t;switch(e.code){case oo:{let o=new io(e);o.invalidFieldDetails.api_name==="id"?t=new Mr(e):t=o;break}case to:t=new Cr(e);break;case xe:t=new Ir(e);break;default:t=new Ye(e);break}return t}function yi(e,t){return o=>{if(o?.data?.length)return o;throw new Sr(e,t)}}var Ud=te("ZohoCrm",{logDataArrayErrors:!1});async function Bd(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=hi(t,e)),o}function hi(e,t){let o,r=le(e,t);if(r)switch(z(r).code){default:o=ne(e,t);break}return o}var fi=re(hi),gi=oe(Bd,Ud);import{BaseError as Wd}from"make-error";function Ar(e,t,o){return(({data:r,module:n})=>e.fetchJson(`/v8/${n}${t}`,N(o,{data:y(r)})).catch(Zi).then(a=>{let i=Array.isArray(r),s=Fe(y(r),a.data),c;if(i)c=s;else{let{successItems:p,errorItems:u}=s;if(u[0]!=null)throw mi(u[0].result);c=p[0].result.details}return c}))}function Ti(e){return Ar(e,"","POST")}function xi(e){return Ar(e,"/upsert","POST")}function Ri(e){return Ar(e,"","PUT")}function bi(e){return({ids:t,module:o,wf_trigger:r})=>e.fetchJson(`/v8/${o}?${T({ids:t,wf_trigger:r})}`,N("DELETE")).catch(Zi).then(jd)}function Fi(e){return t=>e.fetchJson(`/v8/${t.module}/${t.id}`,N("GET")).then(yi(t.module)).then(o=>o.data[0])}function Si(e){return(t=>e.fetchJson(`/v8/${t.module}?${ki(t).toString()}`,N("GET")))}function Pr(e){function t(o){let r={...o};if(delete r.criteria,o.criteria!=null){let n=li(o.criteria);r.criteria=n}if(!r.word&&!o.cvid&&!o.criteria&&!o.email&&!o.phone)throw new Error("At least one of word, cvid, criteria, email, or phone must be provided");return ki(r)}return(o=>e.fetchJson(`/v8/${o.module}/search?${t(o).toString()}`,N("GET")).then(r=>r??{data:[],info:{more_records:!1}}))}function Ci(e){return v(Pr(e))}function Xe(e){return t=>{let{targetModule:o,returnEmptyRecordsInsteadOfNull:r=!0}=t;return n=>e.fetchJson(`/v8/${n.module}/${n.id}/${o}?${Gd(n,n.filter).toString()}`,N("GET")).then(a=>a??(r!==!1?Ge():a))}}function Er(e){let t=Xe(e)({targetModule:di});return o=>t(o).then(r=>{let n=r.data??r.Emails;return{...r,data:n}})}function Ii(e){return v(Er(e))}function kr(e){return Xe(e)({targetModule:Ct})}function Mi(e){return v(kr(e))}var QE=20*1024*1024;function Oi(e){return t=>{let{attachmentCategoryId:o,attachmentCategoryName:r,file:n}=t,a={attachments_category_id:A(o),attachments_category:A(r)};if(!a.attachments_category_id?.length&&!a.attachments_category?.length)throw new Error("attachmentCategoryId or attachmentCategoryName must be provided and not empty.");let i=`/v8/${t.module}/${t.id}/${Ct}?${T(a).toString()}`,s=new FormData;return s.append("file",n),e.fetch(i,{method:"POST",headers:{"Content-Type":""},body:s})}}function Ai(e){return t=>e.fetch(`/v8/${t.module}/${t.id}/${Ct}/${t.attachment_id}`,{method:"GET"}).then(Jt)}function Pi(e){return t=>e.fetch(`/v8/${t.module}/${t.id}/${Ct}/${t.attachment_id}`,{method:"DELETE"})}var Or=class extends Wd{constructor(o){super(`An error occured during the execution of the function. Code: ${o.code}, Message: ${o.message}`);this.error=o}};function Ei(e){return t=>{let r=T(t.params).toString(),n=!!t.apiKey,a=(n?`auth_type=apikey&zapikey=${t.apiKey}`:"auth_type=oauth")+(r?`&${r}`:""),i=`/v8/functions/${t.functionName}/actions/execute?${a}`,c=`${n&&t.apiUrl!=null?no(t.apiUrl):""}${i}`;return e.fetchJson(c,N("POST")).then(p=>{if(p.code!=="success")throw new Or(p);return p.details})}}function ki(...e){return T(e,{omitKeys:"module"})}function Gd(...e){return T(e,{omitKeys:["id","module"]})}function N(e,t){return{method:e,body:t??void 0}}function Zi(e){let t;if(e instanceof qe)t={data:e.errorDataArray};else throw e;return t}function jd(e){let{data:t}=e,o=[],r=[];return t.forEach(a=>{a.status===$e?o.push(a):r.push(a)}),{...e,successItems:o,errorItems:r}}function Fe(e,t){let o=[],r=[];return e.forEach((a,i)=>{let s=t[i];s.status===$e?o.push({input:a,result:s}):r.push({input:a,result:s})}),{successItems:o,errorItems:r}}function Zr(e){return t=>e.fetchJson(`/v2/${ao}`,N("POST",{data:t.data})).then(o=>Fe(y(t.data),o.data))}function Di(e){return t=>e.fetchJson(`/v2/${ao}?${T({ids:t.ids})}`,N("DELETE")).then(o=>Fe(y(t.ids),o.data))}function Dr(e){return Xe(e)({targetModule:ao})}function Li(e){return v(Dr(e))}function vi(e){let t=Zr(e);return o=>{let{module:r,id:n,notes:a}=o,i={data:y(a).map(s=>({...s,se_module:r,Parent_Id:n}))};return t(i)}}function _i(e){return t=>e.fetchJson(`/v8/settings/tags?${T({module:t.module})}`,N("POST",{tags:y(t.tags)})).catch(o=>{let r;if(o instanceof B){let n=o.data?.tags;Array.isArray(n)&&(r={tags:n})}if(!r)throw o;return r}).then(o=>{let r=Fe(y(t.tags),o.tags),{included:n,excluded:a}=ge(r.errorItems,i=>i.result.code===xe);return{...r,errorItems:a,duplicateErrorItems:n,allErrorItems:r.errorItems}})}function wi(e){return t=>e.fetchJson(`/v8/settings/tags/${t.id}`,N("DELETE")).then(o=>o.tags)}function Vi(e){return t=>e.fetchJson(`/v8/settings/tags?${T({module:t.module,my_tags:t.my_tags})}`,N("GET")).then(o=>({...o,data:o.tags}))}var Ni=100;function Ki(e){return t=>e.fetchJson(`/v8/${t.module}/actions/add_tags`,N("POST",Ui(t))).then(o=>{let r=o.data.map(()=>t);return Fe(r,o.data)})}function Ui(e){if(Array.isArray(e.ids)&&e.ids.length>Ni)throw new Error(`Cannot add/remove tags from more than ${Ni} records at once.`);let t=[...y(e.tags)],o=new Set(t.map(r=>r.name));return e.tag_names&&y(e.tag_names).forEach(r=>{o.has(r)||(t.push({name:r}),o.add(r))}),{tags:t,ids:y(e.ids)}}function Bi(e){return t=>e.fetchJson(`/v8/${t.module}/actions/remove_tags`,N("POST",Ui(t))).then(o=>{let r=o.data.map(()=>t);return Fe(r,o.data)})}function Wi(e){let{accountsContext:t}=e,o=Re(t.loadAccessToken),r=be(e.rateLimiterConfig),{logZohoServerErrorFunction:n,fetchFactory:a=i=>ee.makeFetch({baseUrl:i.apiUrl,baseRequest:async()=>({headers:{"Content-Type":"application/json",Authorization:`Bearer ${await o()}`}}),fetchHandler:r,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return i=>{if(!i.apiUrl)throw new Error("ZohoConfig missing api url.");let s=no(i.apiUrl),c=a({apiUrl:s}),p=gi(c,n,h=>{h instanceof G&&t.loadAccessToken.resetAccessToken()}),u=Q(p,{interceptJsonResponse:fi,handleFetchJsonParseErrorFunction:X});return{crmContext:{fetch:p,fetchJson:u,accessTokenStringFactory:o,config:{...i,apiUrl:s},zohoRateLimiter:r._rateLimiter}}}}function Gi(e,t){return We({...t,fetch:e,readFetchPageResultInfo:function(o){return{hasNext:o.page_context?.has_more_rows??!1}},buildInputForNextPage:function(o,r,n){let i=o.result?.page_context,s=n.maxItemsPerPage??r.row_count??i?.row_count??20,c=(i?.start_index??r.start_index??1)+s;return{...r,start_index:c,row_count:s}}})}function Oe(e,t){return{method:e,body:t??void 0}}function ji(e){return({requestId:t})=>e.fetchJson(`/requests/${t}`,Oe("GET"))}function Lr(e){return t=>{let{search_columns:o,...r}=t,n={page_context:{...r,...o?{search_columns:o}:{}}};return e.fetchJson({url:"/requests",queryParams:{data:JSON.stringify(n)}},Oe("GET"))}}function qi(e){let t=Lr(e);return Gi(t)}function $i(e){return({requestId:t})=>e.fetchJson(`/requests/${t}/fielddata`,Oe("GET"))}function Hi(e){return()=>e.fetchJson("/fieldtypes",Oe("GET"))}function zi(e){return({requestId:t,...o})=>{let n=T(o).toString(),a=n?`?${n}`:"",i=`/requests/${t}/pdf${a}`;return e.fetch(i,{method:"GET"})}}function Ji(e){return({requestId:t})=>e.fetch(`/requests/${t}/completioncertificate`,{method:"GET"})}function Yi(e){return({requestData:t,file:o})=>{let r=new FormData;return r.append("data",JSON.stringify({requests:t})),r.append("file",o),e.fetch("/requests",{method:"POST",headers:{"Content-Type":""},body:r}).then(n=>n.json())}}function Xi(e){return({requestId:t,data:o})=>e.fetchJson(`/requests/${t}`,Oe("PUT",{requests:o}))}function Qi(e){return({requestId:t,data:o})=>{let r=o?{requests:o}:void 0;return e.fetchJson(`/requests/${t}/submit`,Oe("POST",r))}}function es(e){return({requestId:t,expire_by:o})=>e.fetchJson(`/requests/${t}/extend`,Oe("PUT",{expire_by:o}))}function ts(e){return({requestId:t,recall_inprogress:o,reason:r})=>{let n={};o!=null&&(n.recall_inprogress=String(o)),r!=null&&(n.reason=r);let a=T(n),i=a.toString().length>0;return e.fetchJson(`/requests/${t}/delete`,{method:"PUT",...i?{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()}:{}})}}function os(e){switch(e){case"sandbox":return"https://signsandbox.zoho.com/api/v1";case"production":return"https://sign.zoho.com/api/v1";default:return e}}var qd=te("ZohoSign",{logDataArrayErrors:!1});async function $d(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=rs(t,e)),o}function rs(e,t){let o,r=le(e,t);if(r)switch(z(r).code){default:o=ne(e,t);break}return o}var ns=re(rs),as=oe($d,qd);function is(e){let{accountsContext:t}=e,o=Re(t.loadAccessToken),r=be(e.rateLimiterConfig),{logZohoServerErrorFunction:n,fetchFactory:a=i=>ee.makeFetch({baseUrl:i.apiUrl,baseRequest:async()=>({headers:{"Content-Type":"application/json",Authorization:`Bearer ${await o()}`}}),fetchHandler:r,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return i=>{if(!i.apiUrl)throw new Error("ZohoConfig missing api url.");let s=os(i.apiUrl),c=a({apiUrl:s}),p=as(c,n,h=>{h instanceof G&&t.loadAccessToken.resetAccessToken()}),u=Q(p,{interceptJsonResponse:ns,handleFetchJsonParseErrorFunction:X});return{signContext:{fetch:p,fetchJson:u,accessTokenStringFactory:o,config:{...i,apiUrl:s},zohoRateLimiter:r._rateLimiter}}}}function ss(e){let t;switch(e){case"sandbox":case"production":t="https://desk.zoho.com/api/v1";break;default:t=e;break}return t}var Hd=te("ZohoDesk",{logDataArrayErrors:!1});async function zd(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=cs(t,e)),o}function cs(e,t){let o,r=le(e,t);if(r)switch(z(r).code){default:o=ne(e,t);break}return o}var us=re(cs),ps=oe(zd,Hd);var Jd="X-Rate-Limit-Remaining-v3",Yd="Retry-After",Xd=200;function Qd(e){let t=e.get(Jd),o;if(t!=null){let r=Number(t),n,a=e.get(Yd);if(a!=null){let i=Number(a);isNaN(i)||(n=new Date(Date.now()+i*Z))}isNaN(r)||(o={remaining:r,resetAt:n})}return o}function ds(e){return Fr({maxRateLimit:Xd,...e,readRateLimitDetails:Qd})}function ls(e){let{accountsContext:t}=e,o=Re(t.loadAccessToken),r=ds(e.rateLimiterConfig),{logZohoServerErrorFunction:n,fetchFactory:a=i=>ee.makeFetch({baseUrl:i.apiUrl,baseRequest:async()=>({headers:{"Content-Type":"application/json",Authorization:`Bearer ${await o()}`,orgId:i.orgId}}),fetchHandler:r,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return i=>{if(!i.apiUrl)throw new Error("ZohoDeskConfig missing api url.");if(!i.orgId)throw new Error("ZohoDeskConfig missing orgId.");let s=ss(i.apiUrl),c=a({apiUrl:s,orgId:i.orgId}),p=ps(c,n,h=>{h instanceof G&&t.loadAccessToken.resetAccessToken()}),u=Q(p,{interceptJsonResponse:us,handleFetchJsonParseErrorFunction:X});return{deskContext:{fetch:p,fetchJson:u,accessTokenStringFactory:o,config:{...i,apiUrl:s},zohoRateLimiter:r._rateLimiter}}}}var ms=25;function J(e,t){return We({...t,fetch:e,readFetchPageResultInfo:function(o){let r=o.data?.length??0;return{hasNext:r>0&&r>=ms}},buildInputForNextPage:function(o,r,n){let a=n.maxItemsPerPage??r.limit??ms,s=(r.from??1)+a;return{...r,from:s,limit:a}}})}function Ae(e,t){return{method:e,body:t??void 0}}function Qe(e,t){return T(e,{omitKeys:t})}function so(e){let t;return e&&(t=A(y(e))),t}function vr(e){return t=>{let{include:o,...r}=t,n=Qe([{...r,include:so(o)}]);return e.fetchJson(`/tickets?${n}`,Ae("GET")).then(a=>a??{data:[]})}}function ys(e){return t=>{let{ticketId:o,include:r}=t,a=Qe([{include:so(r)}]).toString();return e.fetchJson(`/tickets/${o}${a?`?${a}`:""}`,Ae("GET"))}}function Nr(e){return t=>{let o=Qe([t]);return e.fetchJson(`/tickets/search?${o}`,Ae("GET")).then(r=>r??{data:[]})}}function hs(e){return t=>{let{contactId:o,include:r,...n}=t,a=Qe([{...n,include:so(r)}]);return e.fetchJson(`/contacts/${o}/tickets?${a}`,Ae("GET")).then(i=>i??{data:[]})}}function fs(e){return t=>{let{productId:o,include:r,...n}=t,a=Qe([{...n,include:so(r)}]);return e.fetchJson(`/products/${o}/tickets?${a}`,Ae("GET")).then(i=>i??{data:[]})}}function gs(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/metrics`,Ae("GET"))}function Ts(e){return t=>{let o=Qe([{agentIds:A(y(t.agentIds)),departmentId:t.departmentId}]);return e.fetchJson(`/agentsTicketsCount?${o}`,Ae("GET"))}}function xs(e){return J(vr(e))}function Rs(e){return J(Nr(e))}function bs(e){return{method:e}}function Fs(e){return t=>{let o=T([t]);return e.fetchJson(`/departments?${o}`,bs("GET")).then(r=>r??{data:[]})}}function Ss(e){return t=>e.fetchJson(`/departments/${t.departmentId}`,bs("GET"))}function _r(e){return{method:e}}function Cs(e){let t;return e&&(t=A(y(e))),t}function wr(e){return t=>{let{include:o,...r}=t,n=T([{...r,include:Cs(o)}]);return e.fetchJson(`/contacts?${n}`,_r("GET")).then(a=>a??{data:[]})}}function Is(e){return t=>{let{contactId:o,include:r}=t,a=T([{include:Cs(r)}]).toString();return e.fetchJson(`/contacts/${o}${a?`?${a}`:""}`,_r("GET"))}}function Ms(e){return t=>{let o=T([{contactIds:A(y(t.contactIds))}]);return e.fetchJson(`/contacts/contactsByIds?${o}`,_r("GET")).then(r=>r??[])}}function Os(e){return J(wr(e))}function It(e,t){return{method:e,body:t??void 0}}function As(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/tags`,It("GET")).then(o=>o??[])}function Ps(e){return t=>{let o={tags:y(t.tags).map(r=>({name:r}))};return e.fetchJson(`/tickets/${t.ticketId}/tags`,It("POST",o)).then(r=>r??[])}}function Es(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/tags/${t.tagId}`,It("DELETE"))}function ks(e){return t=>{let o=T([t]);return e.fetchJson(`/tags/search?${o}`,It("GET")).then(r=>r??{data:[]})}}function Zs(e){return t=>{let o=T([t]);return e.fetchJson(`/ticketTags?${o}`,It("GET")).then(r=>r??{data:[]})}}function Vr(e,t){return{method:e,body:t??void 0}}function Ds(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/followers`,Vr("GET")).then(o=>o??[])}function Ls(e){return t=>{let o={ids:y(t.agentIds)};return e.fetchJson(`/tickets/${t.ticketId}/followers`,Vr("POST",o))}}function vs(e){return t=>{let o={ids:y(t.agentIds)};return e.fetchJson(`/tickets/${t.ticketId}/followers`,Vr("DELETE",o))}}function Ns(e,t){return{method:e,body:t??void 0}}function el(e){let t;return e&&(t=A(y(e))),t}function _s(e){return t=>{let{ticketId:o,include:r,...n}=t,a=T([{...n,include:el(r)}]);return e.fetchJson(`/tickets/${o}/attachments?${a}`,Ns("GET")).then(i=>i??{data:[]})}}function ws(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/attachments/${t.attachmentId}`,Ns("DELETE"))}function co(e,t){return{method:e,body:t??void 0}}function Vs(e){let t;return e&&(t=A(y(e))),t}function Ks(e){return t=>{let{ticketId:o,include:r,...n}=t,a=T([{...n,include:Vs(r)}]);return e.fetchJson(`/tickets/${o}/comments?${a}`,co("GET")).then(i=>i??{data:[]})}}function Us(e){return t=>{let{ticketId:o,commentId:r,include:n}=t,i=T([{include:Vs(n)}]).toString();return e.fetchJson(`/tickets/${o}/comments/${r}${i?`?${i}`:""}`,co("GET"))}}function Bs(e){return t=>{let{ticketId:o,...r}=t;return e.fetchJson(`/tickets/${o}/comments`,co("POST",r))}}function Ws(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/comments/${t.commentId}`,co("DELETE"))}function Mt(e,t){return{method:e,body:t??void 0}}function Gs(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/timer`,Mt("GET"))}function js(e){return t=>{let{ticketId:o,...r}=t;return e.fetchJson(`/tickets/${o}/timer`,Mt("POST",r))}}function qs(e){return t=>{let{ticketId:o,...r}=t,n=T([r]);return e.fetchJson(`/tickets/${o}/timeEntries?${n}`,Mt("GET")).then(a=>a??{data:[]})}}function $s(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/timeEntries/${t.timeEntryId}`,Mt("GET"))}function Hs(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/timeEntries/summation`,Mt("GET"))}function zs(e){return{method:e}}function Js(e){let t;return e&&(t=A(y(e))),t}function Kr(e){return t=>{let{ticketId:o,include:r,...n}=t,a=T([{...n,include:Js(r)}]);return e.fetchJson(`/tickets/${o}/threads?${a}`,zs("GET")).then(i=>i??{data:[]})}}function Ys(e){return t=>{let{ticketId:o,threadId:r,include:n}=t,i=T([{include:Js(n)}]).toString();return e.fetchJson(`/tickets/${o}/threads/${r}${i?`?${i}`:""}`,zs("GET"))}}function Xs(e){return J(Kr(e))}function tl(e){return{method:e}}function ol(e){let t;return e&&(t=A(y(e))),t}function Ur(e){return t=>{let{ticketId:o,include:r,...n}=t,a=T([{...n,include:ol(r)}]);return e.fetchJson(`/tickets/${o}/activities?${a}`,tl("GET")).then(i=>i??{data:[]})}}function Qs(e){return J(Ur(e))}function uo(e){return{method:e}}function ec(e){let t;return e&&(t=A(y(e))),t}function Br(e){return t=>{let{include:o,...r}=t,n=T([{...r,include:ec(o)}]);return e.fetchJson(`/agents?${n}`,uo("GET")).then(a=>a??{data:[]})}}function tc(e){return t=>{let{agentId:o,include:r}=t,a=T([{include:ec(r)}]).toString();return e.fetchJson(`/agents/${o}${a?`?${a}`:""}`,uo("GET"))}}function oc(e){return t=>{let o=T([{agentIds:A(y(t.agentIds))}]);return e.fetchJson(`/agentsByIds?${o}`,uo("GET")).then(r=>r?.data??[])}}function rc(e){return()=>e.fetchJson("/myinfo",uo("GET"))}function nc(e){return J(Br(e))}function po(e){return t=>{let{clientId:o,clientSecret:r,refreshToken:n}=e.config,{client:a,refreshToken:i}=t??{},s=a?.clientId??o,c=a?.clientSecret??r,u=T({grant_type:"refresh_token",client_id:s,client_secret:c,refresh_token:i??n});return e.fetchJson(`/oauth/v2/token?${u}`,rl("POST"))}}function rl(e,t){return{method:e,body:t}}var nl="https://accounts.zoho.com";function ac(e){return e==="us"?nl:e}function ic(e){let t=be(),{logZohoServerErrorFunction:o,fetchFactory:r=n=>ee.makeFetch({baseUrl:n.apiUrl,baseRequest:{headers:{"Content-Type":"application/json"}},fetchHandler:t,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return n=>{if(n.refreshToken)if(n.clientId){if(!n.clientSecret)throw new Error("ZohoAccountsConfig missing clientSecret.")}else throw new Error("ZohoAccountsConfig missing clientId.");else throw new Error("ZohoAccountsConfig missing refreshToken.");let a=ac(n.apiUrl??"us"),i=r({apiUrl:a}),s=ui(i,o),c=Q(s,{interceptJsonResponse:ci,handleFetchJsonParseErrorFunction:X}),p=async()=>{let h=new Date().getTime(),{access_token:g,api_domain:R,scope:x,expires_in:C}=await po(d)();return{accessToken:g,apiDomain:R,expiresIn:C,expiresAt:new Date(h+C*Z),scope:x}};p.resetAccessToken=async()=>n.accessTokenCache?.clearCachedToken();let u=al({tokenRefresher:p,accessTokenCache:n.accessTokenCache}),d={fetch:s,fetchJson:c,loadAccessToken:u,config:{...n,apiUrl:a}};return{accountsContext:d}}}function al(e){let{tokenRefresher:t,accessTokenCache:o,tokenExpirationBuffer:r}=e,n=r??de,a=null,i=async()=>{a=null},s=async()=>{if(!a){let c=await o?.loadCachedToken();c&&(a=c)}if(a!=null&&new Date().getTime()+n>=a.expiresAt.getTime()&&(a=null),!a){try{a=await t()}catch(c){throw console.error("zohoAccountsZohoAccessTokenFactory(): Failed retrieving new token from tokenRefresher: ",c),new Je("Token Refresh Failed")}try{await o?.updateCachedToken(a)}catch{}}return a};return s.resetAccessToken=i,s}function Se(e){if(!e.apiUrl)throw new Error("No Zoho API url or type specified.")}var Ce=class{zohoAccounts;factoryConfig;static assertValidConfig(t){let{zohoAccounts:o}=t;if(o)if(o.serviceAccessTokenKey)if(o.refreshToken)if(o.apiUrl){if(!o.clientId)throw new Error("ZohoAccountsServiceConfig.zohoAccounts.clientId is required")}else throw new Error("ZohoAccountsServiceConfig.zohoAccounts.apiUrl is required");else throw new Error("ZohoAccountsServiceConfig.zohoAccounts.refreshToken is required");else throw new Error("ZohoAccountsServiceConfig.zohoAccounts.serviceAccessTokenKey is required");else throw new Error("ZohoAccountsServiceConfig.zohoAccounts is required")}};import{Injectable as il}from"@nestjs/common";import{dirname as sl}from"node:path";import{readFile as cl,writeFile as ul,rm as pl,mkdirSync as dl}from"node:fs";var et=class{};et=S([il()],et);function ll(e){console.warn(`mergeZohoAccountsAccessTokenCacheServices(): failed updating ${e.length} caches.`),e.forEach(([t,o],r)=>{console.warn(`Cache update failure ${r+1}: - ${o}`)})}function sc(e,t){let o=[...e],r=typeof t=="function"?t:t!==!1?ll:void 0;if(o.length===0)throw new Error("mergeZohoAccountsAccessTokenCacheServices() input cannot be empty.");return{loadZohoAccessTokenCache:function(a){let i=o.map(p=>p.loadZohoAccessTokenCache(a)),s=ia({promiseFactories:i.map(p=>()=>p.loadCachedToken().catch(()=>null).then(u=>{let d;return u&&!Ht(u.expiresAt)&&(d=u),d})),successOnMaybe:!1,throwErrors:!1});return{loadCachedToken:function(){return s()},updateCachedToken:async function(p){return Promise.allSettled(i.map(u=>u.updateCachedToken(p).then(()=>null).catch(d=>[u,d]))).then(u=>{if(r!=null){let d=k(u.map(f=>f.value));d.length&&r(d)}})},clearCachedToken:async function(){await Promise.allSettled(i.map(p=>p.clearCachedToken()))}}}}}function cc(e,t){let o=e??{};function r(n){return{loadCachedToken:async function(){let i=o[n];return t&&console.log("retrieving access token from memory: ",{token:i,service:n}),i},updateCachedToken:async function(i){o[n]=i,t&&console.log("updating access token in memory: ",{accessToken:i,service:n})},clearCachedToken:async function(){delete o[n],t&&console.log("clearing access token in memory: ",{service:n})}}}return{loadZohoAccessTokenCache:r}}var ml=".tmp/zoho-access-tokens.json";function uc(e=ml,t=!0){let o=null;async function r(){return o||(await n()??{})}function n(){return new Promise(c=>{dl(sl(e),{recursive:!0}),cl(e,{},(p,u)=>{let d;if(!p)try{d=JSON.parse(u.toString()),we(d,{forEach:f=>{f[1]&&(f[1].expiresAt=new Date(f[1].expiresAt))}})}catch(f){console.error("Failed reading token file: ",f)}c(d)})}).then(c=>(t&&(o={...o,...c}),c))}async function a(c){return new Promise((p,u)=>{ul(e,JSON.stringify(c),{},d=>{d?u(d):p()})})}async function i(){return new Promise((c,p)=>{pl(e,u=>{u?p(u):c()})})}function s(c){return{loadCachedToken:async function(){return(await r())[c]},updateCachedToken:async function(u){let d=await r();d&&(d[c]=u);try{await a(d)}catch(f){console.error("Failed updating access token in file: ",f)}},clearCachedToken:async function(){try{await a({})}catch(u){console.error("Failed clearing access token in file: ",u)}}}}return{loadZohoAccessTokenCache:s,readTokenFile:n,writeTokenFile:a,deleteTokenFile:i}}var L=class{constructor(t,o){this.config=t;this.cacheService=o;let r=t.zohoAccounts.accessTokenCache??o.loadZohoAccessTokenCache(t.zohoAccounts.serviceAccessTokenKey);this.zohoAccounts=ic(t.factoryConfig??{})({accessTokenCache:r,...t.zohoAccounts})}zohoAccounts;get accountsContext(){return this.zohoAccounts.accountsContext}get accessToken(){return po(this.accountsContext)}};L=S([yl(),M(0,pc(Ce)),M(1,pc(et))],L);import{Inject as dc,Injectable as hl}from"@nestjs/common";var Ot=class{zohoCrm;factoryConfig;static assertValidConfig(t){Se(t.zohoCrm)}};var Pe=class{constructor(t,o){this.config=t;this.zohoAccountsApi=o;this.zohoCrm=Wi({...t.factoryConfig,accountsContext:o.accountsContext})(t.zohoCrm)}zohoCrm;get crmContext(){return this.zohoCrm.crmContext}get zohoRateLimiter(){return this.zohoCrm.crmContext.zohoRateLimiter}get insertRecord(){return Ti(this.crmContext)}get upsertRecord(){return xi(this.crmContext)}get updateRecord(){return Ri(this.crmContext)}get deleteRecord(){return bi(this.crmContext)}get getRecordById(){return Fi(this.crmContext)}get getRecords(){return Si(this.crmContext)}get searchRecords(){return Pr(this.crmContext)}get searchRecordsPageFactory(){return Ci(this.crmContext)}get getRelatedRecordsFunctionFactory(){return Xe(this.crmContext)}get getEmailsForRecord(){return Er(this.crmContext)}get getEmailsForRecordPageFactory(){return Ii(this.crmContext)}get getAttachmentsForRecord(){return kr(this.crmContext)}get getAttachmentsForRecordPageFactory(){return Mi(this.crmContext)}get uploadAttachmentForRecord(){return Oi(this.crmContext)}get downloadAttachmentForRecord(){return Ai(this.crmContext)}get deleteAttachmentFromRecord(){return Pi(this.crmContext)}get createNotes(){return Zr(this.crmContext)}get deleteNotes(){return Di(this.crmContext)}get createNotesForRecord(){return vi(this.crmContext)}get getNotesForRecord(){return Dr(this.crmContext)}get getNotesForRecordPageFactory(){return Li(this.crmContext)}get executeRestApiFunction(){return Ei(this.crmContext)}get createTagsForModule(){return _i(this.crmContext)}get deleteTag(){return wi(this.crmContext)}get getTagsForModule(){return Vi(this.crmContext)}get addTagsToRecords(){return Ki(this.crmContext)}get removeTagsFromRecords(){return Bi(this.crmContext)}};Pe=S([hl(),M(0,dc(Ot)),M(1,dc(L))],Pe);import{ConfigModule as SL,ConfigService as CL}from"@nestjs/config";import{Inject as lc,Injectable as fl}from"@nestjs/common";var At=class{zohoRecruit;factoryConfig;static assertValidConfig(t){Se(t.zohoRecruit)}};var Ee=class{constructor(t,o){this.config=t;this.zohoAccountsApi=o;this.zohoRecruit=pi({...t.factoryConfig,accountsContext:o.accountsContext})(t.zohoRecruit)}zohoRecruit;get recruitContext(){return this.zohoRecruit.recruitContext}get zohoRateLimiter(){return this.zohoRecruit.recruitContext.zohoRateLimiter}get insertRecord(){return La(this.recruitContext)}get upsertRecord(){return va(this.recruitContext)}get updateRecord(){return Na(this.recruitContext)}get deleteRecord(){return _a(this.recruitContext)}get getRecordById(){return wa(this.recruitContext)}get getRecords(){return Va(this.recruitContext)}get searchRecords(){return mr(this.recruitContext)}get searchRecordsPageFactory(){return Ka(this.recruitContext)}get getRelatedRecordsFunctionFactory(){return ze(this.recruitContext)}get getEmailsForRecord(){return yr(this.recruitContext)}get getEmailsForRecordPageFactory(){return Ua(this.recruitContext)}get getAttachmentsForRecord(){return hr(this.recruitContext)}get getAttachmentsForRecordPageFactory(){return Ba(this.recruitContext)}get uploadAttachmentForRecord(){return Wa(this.recruitContext)}get downloadAttachmentForRecord(){return Ga(this.recruitContext)}get deleteAttachmentFromRecord(){return ja(this.recruitContext)}get createNotes(){return xr(this.recruitContext)}get deleteNotes(){return Xa(this.recruitContext)}get createNotesForRecord(){return ei(this.recruitContext)}get getNotesForRecord(){return Rr(this.recruitContext)}get getNotesForRecordPageFactory(){return Qa(this.recruitContext)}get executeRestApiFunction(){return qa(this.recruitContext)}get associateCandidateRecordsWithJobOpenings(){return Ha(this.recruitContext)}get searchCandidateAssociatedJobOpeningRecords(){return gr(this.recruitContext)}get searchCandidateAssociatedJobOpeningRecordsPageFactory(){return Ja(this.recruitContext)}get searchJobOpeningAssociatedCandidateRecords(){return Tr(this.recruitContext)}get searchJobOpeningAssociatedCandidateRecordsPageFactory(){return Ya(this.recruitContext)}get createTagsForModule(){return ri(this.recruitContext)}get getTagsForModule(){return ni(this.recruitContext)}get addTagsToRecords(){return ai(this.recruitContext)}get removeTagsFromRecords(){return ii(this.recruitContext)}};Ee=S([fl(),M(0,lc(At)),M(1,lc(L))],Ee);import{ConfigModule as qL,ConfigService as $L}from"@nestjs/config";import{Inject as mc,Injectable as gl}from"@nestjs/common";var Pt=class{zohoSign;factoryConfig;static assertValidConfig(t){Se(t.zohoSign)}};var Et=class{constructor(t,o){this.config=t;this.zohoAccountsApi=o;this.zohoSign=is({...t.factoryConfig,accountsContext:o.accountsContext})(t.zohoSign)}zohoSign;get signContext(){return this.zohoSign.signContext}get zohoRateLimiter(){return this.zohoSign.signContext.zohoRateLimiter}get getDocument(){return ji(this.signContext)}get getDocuments(){return Lr(this.signContext)}get getDocumentsPageFactory(){return qi(this.signContext)}get getDocumentFormData(){return $i(this.signContext)}get retrieveFieldTypes(){return Hi(this.signContext)}get downloadPdf(){return zi(this.signContext)}get downloadCompletionCertificate(){return Ji(this.signContext)}get createDocument(){return Yi(this.signContext)}get updateDocument(){return Xi(this.signContext)}get sendDocumentForSignature(){return Qi(this.signContext)}get extendDocument(){return es(this.signContext)}get deleteDocument(){return ts(this.signContext)}};Et=S([gl(),M(0,mc(Pt)),M(1,mc(L))],Et);import{ConfigModule as hv,ConfigService as fv}from"@nestjs/config";function yc(e){return{...e,operationType:e.notifications.operation_type}}var hc=ca(e=>e.operationType),fc=pa({configurerForAccessor:e=>{let t=ua(e,r=>r);return{...e,handleRequestSubmitted:t("RequestSubmitted"),handleRequestViewed:t("RequestViewed"),handleRequestSigningSuccess:t("RequestSigningSuccess"),handleRequestCompleted:t("RequestCompleted"),handleRequestRejected:t("RequestRejected"),handleRequestRecalled:t("RequestRecalled"),handleRequestForwarded:t("RequestForwarded"),handleRequestExpired:t("RequestExpired")}}});var gc="ZOHO_SIGN_WEBHOOK_SECRET_TOKEN",ke=class{zohoSignWebhook;static assertValidConfig(t){if(!t.zohoSignWebhook.webhookSecret)throw new Error("No Zoho Sign webhook secret specified.")}};import{defer as kv,from as Zv}from"rxjs";import{combineLatest as eN,filter as tN,skipWhile as oN,startWith as rN,switchMap as nN,of as aN,map as iN,delay as sN,EMPTY as cN}from"rxjs";import{switchMap as Hv,of as zv,isObservable as Jv}from"rxjs";import{switchMap as IN,distinctUntilChanged as MN,shareReplay as ON,map as AN,BehaviorSubject as PN,of as EN,combineLatest as kN,EMPTY as ZN,skip as DN,defaultIfEmpty as LN}from"rxjs";import{distinctUntilChanged as hN,filter as fN,mergeMap as gN,isObservable as TN}from"rxjs";import{BehaviorSubject as GN,switchMap as jN,map as qN,distinctUntilChanged as $N,shareReplay as HN,first as zN,merge as JN,finalize as YN}from"rxjs";import{map as e_}from"rxjs";import{first as u_,shareReplay as p_,firstValueFrom as d_,switchMap as l_,of as m_}from"rxjs";import{startWith as EB,map as kB,shareReplay as ZB,skipWhile as DB,distinctUntilChanged as LB,filter as vB,first as NB,firstValueFrom as _B,switchMap as wB,from as VB}from"rxjs";import{exhaustMap as g_,map as T_,scan as x_,shareReplay as R_,startWith as b_,distinctUntilChanged as F_,switchMap as S_,combineLatest as C_,of as I_,first as M_}from"rxjs";import{identity as N_,map as __}from"rxjs";import{filter as E_,map as k_,scan as Z_}from"rxjs";import{combineLatest as W_,map as G_,of as j_,switchMap as q_,throttleTime as $_}from"rxjs";import{filter as X_,map as Q_,skipWhile as ew,switchMap as tw,takeWhile as ow}from"rxjs";import{of as aw,timeout as iw,tap as sw,throwError as cw,map as uw,startWith as pw}from"rxjs";import{takeWhile as hw,map as fw,timer as gw}from"rxjs";import{distinctUntilChanged as Sw}from"rxjs";import{finalize as Ow,of as Aw,scan as Pw,switchMap as Ew}from"rxjs";import{startWith as Dw,distinctUntilChanged as Lw,shareReplay as vw,map as Nw,first as _w}from"rxjs";import{tap as Uw,delayWhen as Bw,timer as Ww,asyncScheduler as Gw}from"rxjs";import{map as Xw,switchMap as Qw,shareReplay as eV,distinctUntilChanged as tV}from"rxjs";import{scan as cV}from"rxjs";import{combineLatest as lV,skipWhile as mV,startWith as yV,BehaviorSubject as hV,shareReplay as fV,map as gV,finalize as TV,of as xV,mergeMap as RV,from as bV}from"rxjs";import{map as IV}from"rxjs";import{throttleTime as EV,distinctUntilChanged as kV,BehaviorSubject as ZV}from"rxjs";import{map as VV,combineLatest as KV,of as UV}from"rxjs";import{map as HV,of as zV,switchMap as JV}from"rxjs";import{distinctUntilChanged as nK}from"rxjs";import{map as pK,switchMap as dK}from"rxjs";import{first as yK}from"rxjs";import{switchMap as BK,of as WK}from"rxjs";import{map as AU,switchMap as PU,shareReplay as EU,distinctUntilChanged as kU,BehaviorSubject as ZU,isObservable as DU,of as LU}from"rxjs";function xc(e){let t=!ho(e),o;return t?o="loading":ue(e,"value")?o="success":ue(e,"error")?o="error":o="idle",o}function ho(e){let t=!1;if(e){let o=e.loading;o===!0?t=!1:t=o===!1||!!(e.value??e.error)||e.value===null}return t}function fo(e){let t=e==="idle";return o=>o?xc(o)===e:t}var zK=fo("idle"),kt=fo("loading");var JK=fo("success"),YK=fo("error");import{startWith as sU,filter as cU,map as uU,tap as pU,catchError as dU,combineLatest as lU,distinctUntilChanged as mU,first as yU,of as hU,shareReplay as fU,switchMap as gU,firstValueFrom as TU,scan as xU}from"rxjs";import{distinctUntilChanged as XU,map as QU,shareReplay as eB,skipWhile as tB}from"rxjs";import{map as BU}from"rxjs";import{BehaviorSubject as cB}from"rxjs";import{combineLatest as HB,map as zB,shareReplay as JB,skipWhile as YB}from"rxjs";import{map as oW,shareReplay as rW}from"rxjs";import{distinctUntilChanged as fW,map as gW,scan as TW,startWith as xW,catchError as RW,skip as bW,mergeMap as FW,delay as SW,BehaviorSubject as CW,combineLatest as IW,exhaustMap as MW,filter as OW,first as AW,of as PW,shareReplay as EW,defaultIfEmpty as kW}from"rxjs";import{defaultIfEmpty as $W,delay as HW,filter as zW,first as JW,map as YW,shareReplay as XW,switchMap as QW,tap as eG,startWith as tG,timeout as oG,of as rG,BehaviorSubject as nG,Subject as aG}from"rxjs";import{isObservable as AG}from"rxjs";import{filter as lG,map as mG,BehaviorSubject as yG,of as hG,first as fG,shareReplay as gG,switchMap as TG,delay as xG,from as RG,tap as bG}from"rxjs";import{createParamDecorator as Il}from"@nestjs/common";var aj=Il((e,t)=>Ml(t));function Ml(e){let o=e.switchToHttp().getRequest().headers.origin??"";return o.startsWith("http://localhost")||o.startsWith("https://localhost")}import{createParamDecorator as $r,BadRequestException as Ol,InternalServerErrorException as Al,Logger as Pl}from"@nestjs/common";import El from"raw-body";import{parse as kl}from"querystring";var Fc=new Pl("RawBody"),pj=$r(async(e,t)=>{let o=t.switchToHttp().getRequest();if(!o.readable)throw Fc.error("RawBody request was not readable. This is generally due to bad configuration."),new Ol("Invalid body");return await El(o)}),Sc=$r(async(e,t)=>{let r=t.switchToHttp().getRequest().body;if(!Buffer.isBuffer(r))throw Fc.error("RawBody expected a buffer set to req.body."),new Al("failed parsing body");return r}),dj=$r(async(e,t)=>{let o=t.switchToHttp().getRequest();return o.body=Zl(o.body),o.body});function Zl(e){let t=Dl(e);return kl(t)}function Dl(e){return e.toString("utf8").trim()}import{Injectable as Ll}from"@nestjs/common";import vl from"body-parser";var ot=class{use(t,o,r){vl.json()(t,o,r)}};ot=S([Ll()],ot);import{Injectable as Nl}from"@nestjs/common";import _l from"body-parser";var rt=class{use(t,o,r){_l.raw({type:"*/*"})(t,o,r)}};rt=S([Nl()],rt);import{Logger as wl,Module as Vl,RequestMethod as Kl}from"@nestjs/common";var Ul="/webhook",Bl={path:`${Ul}/{*path}`,method:Kl.POST},Hr=class{configure(t){Wl(t)}},go=class extends Hr{logger=new wl("ConfigureWebhookMiddlewareModule");configure(t){super.configure(t),this.logger.debug("Configured webhook routes with proper middleware.")}};go=S([Vl({})],go);function Wl(e){e.apply(rt).forRoutes(Bl).apply(ot).forRoutes("{*path}")}var Cc="CLIENT_WEB_APP_URL";var Ze=class{client;static assertValidConfig(t){if(!t.client.clientWebAppUrl)throw new Error("No client app url specified.")}};import{Inject as Gl,Injectable as jl}from"@nestjs/common";var De=class{_config;constructor(t){this._config=t}get config(){return this._config}get webAppUrl(){return this.config.client.clientWebAppUrl}get webAppHost(){return this.webAppUrl.split("://",2)[1]}};De=S([jl(),M(0,Gl(Ze))],De);import{Module as ql}from"@nestjs/common";import{ConfigModule as $l,ConfigService as Hl}from"@nestjs/config";function zl(e){let t={client:{clientWebAppUrl:e.get(Cc)}};return Ze.assertValidConfig(t),t}var To=class{};To=S([ql({imports:[$l],providers:[{provide:Ze,inject:[Hl],useFactory:zl},De],exports:[De]})],To);var Ic="SERVER_ENV_TOKEN";import{Inject as Jl,Injectable as Yl}from"@nestjs/common";function Mc(){return process.env.NODE_ENV==="test"}var xo=class{constructor(t){this.env=t}get isTestingEnv(){return Mc()}get isProduction(){return this.env.production}get isStaging(){return!!this.env.staging}get developerToolsEnabled(){return!!(!this.isProduction&&this.env.developerToolsEnabled)}get appUrl(){return this.env.appUrl}get appApiUrl(){return this.env.appApiUrl}};xo=S([Yl(),M(0,Jl(Ic))],xo);import{Controller as nm,Inject as am,Post as im,Req as sm}from"@nestjs/common";import{Inject as tm,Injectable as om,Logger as rm}from"@nestjs/common";import{createHmac as Xl,timingSafeEqual as Ql}from"node:crypto";var em="x-zs-webhook-signature";function Oc(e){let{secret:t}=e;return async(o,r)=>{let n=o.headers[em];if(!n)return{valid:!1};let a=r.toString("utf-8"),i=Xl("sha256",t).update(a,"utf-8").digest("base64"),s=!1;try{let p=Buffer.from(n,"base64"),u=Buffer.from(i,"base64");p.length===u.length&&(s=Ql(p,u))}catch{s=!1}let c;if(s)try{let p=JSON.parse(a);c=yc(p)}catch{s=!1}return s&&c?{valid:!0,event:c}:{valid:!1}}}var me=class{logger=new rm("ZohoSignWebhookService");_verifier;handler=hc();configure=fc(this.handler);constructor(t){let{webhookSecret:o}=t.zohoSignWebhook;this._verifier=Oc({secret:o})}async updateForWebhook(t,o){let r=await this._verifier(t,o);r.valid?await this.updateForZohoSignEvent(r.event):this.logger.warn("Received invalid Zoho Sign webhook event.",t)}async updateForZohoSignEvent(t){await this.handler(t)||this.logger.warn("Received unexpected/unhandled Zoho Sign webhook event.",t)}};me=S([om(),M(0,tm(ke))],me);var Le=class{_zohoSignWebhookService;constructor(t){this._zohoSignWebhookService=t}async handleZohoSignWebhook(t,o){await this._zohoSignWebhookService.updateForWebhook(t,o)}};S([im(),M(0,sm()),M(1,Sc())],Le.prototype,"handleZohoSignWebhook",1),Le=S([nm("/webhook/zoho/sign"),M(0,am(me))],Le);import{Module as cm}from"@nestjs/common";import{ConfigModule as um,ConfigService as pm}from"@nestjs/config";function dm(e){let t={zohoSignWebhook:{webhookSecret:e.get(gc)}};return ke.assertValidConfig(t),t}var Ro=class{};Ro=S([cm({imports:[um],controllers:[Le],providers:[{provide:ke,inject:[pm],useFactory:dm},me],exports:[me]})],Ro);import{Inject as Ac,Injectable as lm}from"@nestjs/common";var Zt=class{zohoDesk;factoryConfig;static assertValidConfig(t){if(Se(t.zohoDesk),!t.zohoDesk.orgId)throw new Error("No Zoho Desk orgId specified.")}};var ve=class{constructor(t,o){this.config=t;this.zohoAccountsApi=o;this.zohoDesk=ls({...t.factoryConfig,accountsContext:o.accountsContext})(t.zohoDesk)}zohoDesk;get deskContext(){return this.zohoDesk.deskContext}get zohoRateLimiter(){return this.zohoDesk.deskContext.zohoRateLimiter}get getTickets(){return vr(this.deskContext)}get getTicketById(){return ys(this.deskContext)}get searchTickets(){return Nr(this.deskContext)}get getTicketsForContact(){return hs(this.deskContext)}get getTicketsForProduct(){return fs(this.deskContext)}get getTicketMetrics(){return gs(this.deskContext)}get getAgentsTicketsCount(){return Ts(this.deskContext)}get getTicketsPageFactory(){return xs(this.deskContext)}get searchTicketsPageFactory(){return Rs(this.deskContext)}get getDepartments(){return Fs(this.deskContext)}get getDepartmentById(){return Ss(this.deskContext)}get getContacts(){return wr(this.deskContext)}get getContactById(){return Is(this.deskContext)}get getContactsByIds(){return Ms(this.deskContext)}get getContactsPageFactory(){return Os(this.deskContext)}get getTicketTags(){return As(this.deskContext)}get associateTicketTags(){return Ps(this.deskContext)}get dissociateTicketTag(){return Es(this.deskContext)}get searchTags(){return ks(this.deskContext)}get getAllTags(){return Zs(this.deskContext)}get getTicketFollowers(){return Ds(this.deskContext)}get addTicketFollowers(){return Ls(this.deskContext)}get removeTicketFollowers(){return vs(this.deskContext)}get getTicketAttachments(){return _s(this.deskContext)}get deleteTicketAttachment(){return ws(this.deskContext)}get getTicketComments(){return Ks(this.deskContext)}get getTicketCommentById(){return Us(this.deskContext)}get createTicketComment(){return Bs(this.deskContext)}get deleteTicketComment(){return Ws(this.deskContext)}get getTicketTimer(){return Gs(this.deskContext)}get performTicketTimerAction(){return js(this.deskContext)}get getTicketTimeEntries(){return qs(this.deskContext)}get getTicketTimeEntryById(){return $s(this.deskContext)}get getTicketTimeEntrySummation(){return Hs(this.deskContext)}get getTicketThreads(){return Kr(this.deskContext)}get getTicketThreadById(){return Ys(this.deskContext)}get getTicketThreadsPageFactory(){return Xs(this.deskContext)}get getTicketActivities(){return Ur(this.deskContext)}get getTicketActivitiesPageFactory(){return Qs(this.deskContext)}get getAgents(){return Br(this.deskContext)}get getAgentById(){return tc(this.deskContext)}get getAgentsByIds(){return oc(this.deskContext)}get getMyInfo(){return rc(this.deskContext)}get getAgentsPageFactory(){return nc(this.deskContext)}};ve=S([lm(),M(0,Ac(Zt)),M(1,Ac(L))],ve);import{ConfigModule as R$,ConfigService as b$}from"@nestjs/config";function mm(e){return`${e.clientId}:${e.refreshToken}`}function nt(e){let t=sc([cc(),uc(ct())]),o=new Map;function r(u,d){let f=mm(u),h=o.get(f);if(h)return h;let g={zohoAccounts:{serviceAccessTokenKey:d,refreshToken:u.refreshToken,clientId:u.clientId,clientSecret:u.clientSecret,apiUrl:u.region??"us"}},R=new L(g,t);return o.set(f,R),R}let n,a=ut(e,"recruit");if(a){let u=r(a,"recruit"),d={zohoRecruit:{apiUrl:a.apiMode}};n=new Ee(d,u)}let i,s=ut(e,"crm");if(s){let u=r(s,"crm"),d={zohoCrm:{apiUrl:s.apiMode}};i=new Pe(d,u)}let c,p=ut(e,"desk");if(p?.orgId){let u=r(p,"desk"),d={zohoDesk:{apiUrl:p.apiMode,orgId:p.orgId}};c=new ve(d,u)}return{recruitApi:n,crmApi:i,deskApi:c}}import{existsSync as ym,mkdirSync as hm,writeFileSync as fm}from"node:fs";import{join as gm}from"node:path";var bo={};function Ec(e){bo=e}var Tm=[/Bearer\s+\S+/gi,/access_token[=:]\s*\S+/gi,/refresh_token[=:]\s*\S+/gi,/client_secret[=:]\s*\S+/gi,/1000\.\w{20,}/g];function at(e){let t=e;for(let o of Tm)t=t.replace(o,"[REDACTED]");return t}function xm(){return new Date().toISOString().replace(/[:.]/g,"-")}function Rm(e,t){let{dumpDir:o,commandPath:r}=bo;if(!o)return;ym(o)||hm(o,{recursive:!0});let a=`${r?.length?r.join("_"):"response"}_${xm()}.json`,i=gm(o,a),s={ok:!0,data:e,...t?{meta:t}:{}};fm(i,JSON.stringify(s,null,2))}function bm(e,t){let o=t.split(",").map(r=>r.trim());return Array.isArray(e)?e.map(r=>Pc(r,o)):e!=null&&typeof e=="object"?Pc(e,o):e}function Pc(e,t){if(e==null||typeof e!="object")return e;let o={};for(let r of t)r in e&&(o[r]=e[r]);return o}function l(e,t){Rm(e,t);let r={ok:!0,data:bo.pick?bm(e,bo.pick):e,...t?{meta:t}:{}};console.log(JSON.stringify(r))}function m(e){let t=Fm(e);console.log(JSON.stringify(t))}function Fm(e){return e instanceof G?{ok:!1,error:at(e.message),code:"TOKEN_EXPIRED",suggestion:"Run: zoho-cli auth check"}:e instanceof Ft?{ok:!1,error:at(e.message),code:"AUTH_ERROR",suggestion:"Check your client ID, secret, and refresh token."}:e instanceof St?{ok:!1,error:at(e.message),code:"RATE_LIMITED",suggestion:"Wait and retry. Zoho rate limit exceeded."}:e instanceof B?{ok:!1,error:at(e.message),code:"API_ERROR"}:e instanceof Error?{ok:!1,error:at(e.message),code:"ERROR"}:{ok:!1,error:at(String(e)),code:"UNKNOWN_ERROR"}}var kc={us:"https://accounts.zoho.com",eu:"https://accounts.zoho.eu",in:"https://accounts.zoho.in",au:"https://accounts.zoho.com.au",jp:"https://accounts.zoho.jp"},Zc={recruit:["ZohoRecruit.modules.ALL","ZohoRecruit.settings.all","ZohoRecruit.functions.execute.READ","ZohoRecruit.functions.execute.CREATE"],crm:["ZohoCRM.modules.ALL","ZohoCRM.settings.ALL","ZohoCRM.functions.execute.READ","ZohoCRM.functions.execute.CREATE"],desk:["Desk.tickets.ALL","Desk.tasks.ALL","Desk.contacts.ALL","Desk.settings.ALL","Desk.events.ALL","Desk.search.READ","Desk.articles.READ","Desk.basic.READ"],sign:["ZohoSign.documents.ALL","ZohoSign.templates.ALL"]};function Sm(e){if(e){if(e.startsWith("http://")||e.startsWith("https://"))try{let o=new URL(e).searchParams.get("code");if(!o)throw new Error('No "code" parameter found in the provided URL.');return o}catch(t){throw t instanceof TypeError?new Error(`Invalid URL provided for --code: ${e}`):t}return e}}var Cm={command:"setup",describe:"Generate OAuth authorization URL, exchange code, or set refresh token directly",builder:e=>e.option("client-id",{type:"string",describe:"OAuth client ID (from https://api-console.zoho.com/)"}).option("client-secret",{type:"string",describe:"OAuth client secret"}).option("redirect-uri",{type:"string",default:"http://localhost/oauth",describe:"Redirect URI (must match API console config)"}).option("region",{type:"string",default:"us",choices:["us","eu","in","au","jp"],describe:"Zoho region"}).option("scopes",{type:"string",default:"recruit,crm,desk",describe:"Comma-separated products for OAuth scopes (recruit,crm,desk,sign)"}).option("code",{type:"string",describe:"Authorization code or the full redirect URL (code is extracted automatically)"}).option("token",{type:"string",describe:"Set a refresh token directly (skips OAuth code exchange)"}).option("product",{type:"string",choices:[...Lt],describe:"Store credentials for a specific product instead of shared"}).option("org-id",{type:"string",describe:"Zoho Desk organization ID"}).option("api-mode",{type:"string",default:"production",choices:["production","sandbox"],describe:"API mode"}).example([["$0 auth setup --client-id 1000.ABC --client-secret xyz","Step 1: Get OAuth URL (saves shared credentials)"],["$0 auth setup --code 1000.AUTH.CODE","Step 2: Exchange code for refresh token"],['$0 auth setup --code "http://localhost/oauth?code=1000.AUTH.CODE&location=us"',"Step 2: Paste the full redirect URL"],["$0 auth setup --client-id 1000.ABC --client-secret xyz --token 1000.REFRESH.TOKEN","Set shared refresh token directly"],["$0 auth setup --product crm --client-id 1000.CRM --client-secret xyz --token 1000.CRM.TOKEN","Set CRM-specific credentials"]]),handler:async e=>{try{let t=await w(),o=e.product,r=e.clientId??t?.shared?.clientId,n=e.clientSecret??t?.shared?.clientSecret,a=e.redirectUri,i=e.region??t?.shared?.region??"us",s=e.scopes.split(",").map(d=>d.trim()),c=Sm(e.code),p=e.token,u=kc[i]??kc.us;if(!r||!n)throw new Error("--client-id and --client-secret are required. Get them from https://api-console.zoho.com/");if(p){let d={clientId:r,clientSecret:n,refreshToken:p};if(o){let f={...d,apiUrl:e.apiMode,orgId:o==="desk"?e.orgId:void 0},h=await U({shared:t?.shared??{clientId:"",clientSecret:"",refreshToken:""},[o]:f});l({success:!0,product:o,refreshToken:ye(p),configSaved:!0,configuredProducts:$(h)})}else{let f=await U({shared:{...d,region:i,apiMode:e.apiMode},desk:e.orgId?{orgId:e.orgId}:void 0});l({success:!0,refreshToken:ye(p),configSaved:!0,configuredProducts:$(f)})}}else if(c){let d=`${u}/oauth/v2/token`,f=new URLSearchParams({grant_type:"authorization_code",client_id:r,client_secret:n,redirect_uri:a,code:c}),g=await(await fetch(d,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:f.toString()})).json();if(g.error)throw new Error(`Token exchange failed: ${g.error}`);let R=g.refresh_token;if(!R)throw new Error("No refresh_token in response. The authorization code may have expired (valid for 2 minutes). Generate a new one.");let x={clientId:r,clientSecret:n,refreshToken:R},C;o?C=await U({shared:t?.shared??{clientId:"",clientSecret:"",refreshToken:""},[o]:{...x,apiUrl:e.apiMode,orgId:o==="desk"?e.orgId:void 0}}):C=await U({shared:{...x,region:i,apiMode:e.apiMode},desk:e.orgId?{orgId:e.orgId}:void 0}),l({step:2,success:!0,product:o??"shared",refreshToken:ye(R),accessToken:g.access_token?ye(g.access_token):null,scope:g.scope,configSaved:!0,configuredProducts:$(C)})}else{let d=s.flatMap(h=>Zc[h]??[]);if(d.length===0)throw new Error(`No valid products specified. Choose from: ${Object.keys(Zc).join(", ")}`);let f=`${u}/oauth/v2/auth?scope=${d.join(",")}&client_id=${encodeURIComponent(r)}&response_type=code&access_type=offline&redirect_uri=${encodeURIComponent(a)}`;await U({shared:{clientId:r,clientSecret:n,refreshToken:t?.shared?.refreshToken??"",region:i,apiMode:e.apiMode??t?.shared?.apiMode},desk:e.orgId?{orgId:e.orgId}:void 0}),l({step:1,instructions:'Open the authorization URL in a browser. Authorize the application. Copy the "code" parameter from the redirect URL.',authorizationUrl:f,redirectUri:a,scopes:d,credentialsSaved:!0,nextStep:'zoho-cli auth setup --code "PASTE_REDIRECT_URL_OR_AUTH_CODE"'})}}catch(t){m(t),process.exit(1)}}},Im={command:"set",describe:"Save Zoho API credentials directly",builder:e=>e.option("client-id",{type:"string",demandOption:!0,describe:"OAuth client ID"}).option("client-secret",{type:"string",demandOption:!0,describe:"OAuth client secret"}).option("refresh-token",{type:"string",demandOption:!0,describe:"OAuth refresh token"}).option("product",{type:"string",choices:[...Lt],describe:"Store for a specific product instead of shared"}).option("region",{type:"string",default:"us",describe:"Zoho region (us, eu, in, au, jp)"}).option("org-id",{type:"string",describe:"Zoho Desk organization ID"}).option("api-mode",{type:"string",default:"production",choices:["production","sandbox"],describe:"API mode"}).example([["$0 auth set --client-id abc --client-secret xyz --refresh-token 1000.abc.xyz","Set shared credentials"],["$0 auth set --product crm --client-id abc --client-secret xyz --refresh-token 1000.crm.xyz","Set CRM-specific credentials"]]),handler:async e=>{try{let t=e.product,o={clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:e.refreshToken},r;t?r=await U({shared:(await w())?.shared??{clientId:"",clientSecret:"",refreshToken:""},[t]:{...o,apiUrl:e.apiMode,orgId:t==="desk"?e.orgId:void 0}}):r=await U({shared:{...o,region:e.region,apiMode:e.apiMode},desk:e.orgId?{orgId:e.orgId}:void 0}),l({saved:!0,product:t??"shared",configuredProducts:$(r)})}catch(t){m(t),process.exit(1)}}},Mm={command:"show",describe:"Show current configuration (secrets masked)",builder:e=>e,handler:async()=>{try{let o=function(r){if(r)return{clientId:r.clientId?ye(r.clientId):void 0,clientSecret:r.clientSecret?ye(r.clientSecret):void 0,refreshToken:r.refreshToken?ye(r.refreshToken):void 0}};var e=o;let t=await w();if(!t){l({configured:!1});return}l({configured:!0,shared:{...o(t.shared),region:t.shared?.region??"us",apiMode:t.shared?.apiMode??"production"},recruit:t.recruit?{...o(t.recruit),apiUrl:t.recruit.apiUrl}:null,crm:t.crm?{...o(t.crm),apiUrl:t.crm.apiUrl}:null,desk:t.desk?{...o(t.desk),apiUrl:t.desk.apiUrl,orgId:t.desk.orgId}:null,configuredProducts:$(t)})}catch(t){m(t),process.exit(1)}}},Om={command:"check",describe:"Verify credentials by exchanging tokens",builder:e=>e,handler:async()=>{try{let e=await w();if(!e){l({authenticated:!1,error:"No credentials configured. Run: zoho-cli auth setup"});return}let t=$(e);if(t.length===0){l({authenticated:!1,error:"No products have complete credentials. Run: zoho-cli auth setup"});return}let o=nt(e),r={};for(let n of t)try{let a=n==="recruit"?o.recruitApi:n==="crm"?o.crmApi:o.deskApi;if(!a){r[n]={authenticated:!1,error:"Not configured"};continue}let s=await a.zohoAccountsApi.accessToken();r[n]={authenticated:!0,scope:s.scope,expiresIn:s.expires_in}}catch(a){let i=a instanceof Error?a.message:String(a);r[n]={authenticated:!1,error:i}}l({products:r})}catch(e){m(e),process.exit(1)}}},Am={command:"clear",describe:"Remove stored credentials and token cache",builder:e=>e,handler:async()=>{try{await on(),l({cleared:!0})}catch(e){m(e),process.exit(1)}}},Dc={command:"auth",describe:"Manage Zoho API credentials",builder:e=>e.command(Cm).command(Im).command(Mm).command(Om).command(Am).demandCommand(1,"Please specify an auth subcommand."),handler:F};import{access as Pm,constants as Em}from"node:fs";import{dirname as km}from"node:path";var Lc={command:"doctor",describe:"Check CLI configuration and connectivity",builder:e=>e,handler:async()=>{let e=[],t=await w();t?e.push({name:"config",status:"pass",message:`Config loaded from ${st()}`}):e.push({name:"config",status:"fail",message:"No config found. Run: zoho-cli auth setup"}),t?.shared?.clientId&&t?.shared?.clientSecret&&t?.shared?.refreshToken?e.push({name:"shared-credentials",status:"pass",message:"Shared credentials present"}):t&&e.push({name:"shared-credentials",status:"warn",message:"Missing shared credentials. Per-product credentials may still work."});let o=km(ct());if(await Zm(o)?e.push({name:"token-cache",status:"pass",message:`Token cache directory writable: ${o}`}):e.push({name:"token-cache",status:"warn",message:`Token cache directory not writable: ${o}`}),t){let a=$(t);a.length>0?e.push({name:"products",status:"pass",message:`Configured products: ${a.join(", ")}`}):e.push({name:"products",status:"fail",message:"No products have complete credentials"});let i=nt(t);for(let s of a)try{let c=s==="recruit"?i.recruitApi:s==="crm"?i.crmApi:i.deskApi;if(c){let u=await c.zohoAccountsApi.accessToken();e.push({name:`${s}-token`,status:"pass",message:`${s}: Token exchange successful. Scope: ${u.scope}`})}}catch(c){let p=c instanceof Error?c.message:String(c);e.push({name:`${s}-token`,status:"fail",message:`${s}: Token exchange failed: ${p}`})}t.desk?.orgId?e.push({name:"desk-org-id",status:"pass",message:`Desk org ID configured: ${t.desk.orgId}`}):a.includes("desk")||e.push({name:"desk-org-id",status:"warn",message:"No Desk org ID. Desk commands unavailable."})}let n=e.every(a=>a.status==="pass");l({checks:e,healthy:n}),n||process.exit(e.some(a=>a.status==="fail")?1:0)}};function Zm(e){return new Promise(t=>{Pm(e,Em.W_OK,o=>{t(!o)})})}var zr;function vc(e){return async t=>{let o=t._?.[0];if(!(typeof o=="string"&&e.has(o)))try{let r=await w();r||(m(new Error("Not authenticated. Run: zoho-cli auth setup --client-id X --client-secret Y --token Z")),process.exit(4)),$(r).length===0&&(m(new Error("No products configured with complete credentials. Run: zoho-cli auth setup")),process.exit(4)),zr=nt(r)}catch(r){m(r),process.exit(4)}}}function Jr(e){if(!zr)throw new Error("CLI context not initialized. This is a bug.");return zr}function j(e){let{recruitApi:t}=Jr(e);if(!t)throw new Error("Recruit not configured. Run: zoho-cli auth setup --client-id X --client-secret Y --token Z");return t}function q(e){let{crmApi:t}=Jr(e);if(!t)throw new Error("CRM not configured. Run: zoho-cli auth setup --product crm --client-id X --client-secret Y --token Z");return t}function b(e){let{deskApi:t}=Jr(e);if(!t)throw new Error("Desk not configured. Run: zoho-cli auth setup --product desk --client-id X --client-secret Y --token Z --org-id YOUR_ORG_ID");return t}function ie(e){return e.option("page",{type:"number",default:1,describe:"Page number (1-based)"}).option("per-page",{type:"number",default:20,describe:"Records per page"})}function P(e){return e.option("from",{type:"number",default:1,describe:"Start index (1-based)"}).option("limit",{type:"number",default:25,describe:"Max records (max 50)"})}function E(e){return e.option("module",{alias:"m",type:"string",demandOption:!0,describe:"Zoho module name (e.g. Candidates, Contacts, Leads)"})}function Ie(e){return e.option("id",{type:"string",demandOption:!0,describe:"Record ID"})}function Dt(e,t=!1){return e.option("fields",{type:"string",demandOption:t,describe:"Comma-separated field names to return"})}function Fo(e){return e.option("sort-by",{type:"string",describe:"Field to sort by"}).option("sort-order",{type:"string",choices:["asc","desc"],describe:"Sort direction"})}var Dm={command:"list",describe:"List records from a module",builder:e=>Fo(Dt(ie(E(e)))),handler:async e=>{try{let o=await j(e).getRecords({module:e.module,page:e.page,per_page:e.perPage,fields:e.fields,sort_by:e.sortBy,sort_order:e.sortOrder});l(o.data,{page:o.info?.page,per_page:o.info?.per_page,more_records:o.info?.more_records})}catch(t){m(t),process.exit(1)}}},Lm={command:"get",describe:"Get a record by ID",builder:e=>Ie(E(e)),handler:async e=>{try{let o=await j(e).getRecordById({module:e.module,id:e.id});l(o)}catch(t){m(t),process.exit(1)}}},vm={command:"search",describe:"Search records in a module",builder:e=>ie(E(e)).option("criteria",{type:"string",describe:"Search criteria string, e.g. (First_Name:equals:John)"}).option("word",{type:"string",describe:"Keyword search"}).option("email",{type:"string",describe:"Search by email"}).option("phone",{type:"string",describe:"Search by phone"}),handler:async e=>{try{let o=await j(e).searchRecords({module:e.module,criteria:e.criteria,word:e.word,email:e.email,phone:e.phone,page:e.page,per_page:e.perPage});l(o.data,{page:o.info?.page,per_page:o.info?.per_page,more_records:o.info?.more_records})}catch(t){m(t),process.exit(1)}}},Nm={command:"insert",describe:"Insert a record into a module",builder:e=>E(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array)"}),handler:async e=>{try{let t=j(e),o=JSON.parse(e.data),r=await t.insertRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},_m={command:"upsert",describe:"Upsert a record in a module",builder:e=>E(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array, include id for update)"}),handler:async e=>{try{let t=j(e),o=JSON.parse(e.data),r=await t.upsertRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},wm={command:"update",describe:"Update a record in a module",builder:e=>E(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array, must include id)"}),handler:async e=>{try{let t=j(e),o=JSON.parse(e.data),r=await t.updateRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},Vm={command:"delete",describe:"Delete records from a module",builder:e=>E(e).option("ids",{type:"string",demandOption:!0,describe:"Comma-separated record IDs to delete"}),handler:async e=>{try{let t=j(e),o=e.ids.split(",").map(n=>n.trim()),r=await t.deleteRecord({module:e.module,ids:o});l(r)}catch(t){m(t),process.exit(1)}}},Km={command:"emails",describe:"Get emails for a record",builder:e=>ie(Ie(E(e))),handler:async e=>{try{let o=await j(e).getEmailsForRecord({module:e.module,id:e.id,page:e.page,per_page:e.perPage});l(o.data,{page:o.info?.page,per_page:o.info?.per_page,more_records:o.info?.more_records})}catch(t){m(t),process.exit(1)}}},Um={command:"attachments",describe:"Get attachments for a record",builder:e=>ie(Ie(E(e))),handler:async e=>{try{let o=await j(e).getAttachmentsForRecord({module:e.module,id:e.id,page:e.page,per_page:e.perPage});l(o.data,{page:o.info?.page,per_page:o.info?.per_page,more_records:o.info?.more_records})}catch(t){m(t),process.exit(1)}}},Nc={command:"recruit",describe:"Zoho Recruit operations",builder:e=>e.command(Dm).command(Lm).command(vm).command(Nm).command(_m).command(wm).command(Vm).command(Km).command(Um).demandCommand(1,"Please specify a recruit subcommand.").example([["$0 recruit list -m Candidates --per-page 10","List first 10 candidates"],["$0 recruit get -m Candidates --id 12345","Get a candidate by ID"],['$0 recruit search -m Candidates --word "John"',"Search candidates by keyword"],[`$0 recruit insert -m Candidates --data '{"First_Name":"John","Last_Name":"Doe"}'`,"Insert a candidate"]]),handler:F};var Bm={command:"list",describe:"List records from a module",builder:e=>Fo(Dt(ie(E(e)),!0)),handler:async e=>{try{let o=await q(e).getRecords({module:e.module,fields:e.fields,page:e.page,per_page:e.perPage,sort_by:e.sortBy,sort_order:e.sortOrder});l(o.data,{page:o.info?.page,per_page:o.info?.per_page,more_records:o.info?.more_records})}catch(t){m(t),process.exit(1)}}},Wm={command:"get",describe:"Get a record by ID",builder:e=>Ie(E(e)),handler:async e=>{try{let o=await q(e).getRecordById({module:e.module,id:e.id});l(o)}catch(t){m(t),process.exit(1)}}},Gm={command:"search",describe:"Search records in a module",builder:e=>ie(E(e)).option("criteria",{type:"string",describe:"Search criteria string, e.g. (First_Name:equals:John)"}).option("word",{type:"string",describe:"Keyword search"}).option("email",{type:"string",describe:"Search by email"}).option("phone",{type:"string",describe:"Search by phone"}),handler:async e=>{try{let o=await q(e).searchRecords({module:e.module,criteria:e.criteria,word:e.word,email:e.email,phone:e.phone,page:e.page,per_page:e.perPage});l(o.data,{page:o.info?.page,per_page:o.info?.per_page,more_records:o.info?.more_records})}catch(t){m(t),process.exit(1)}}},jm={command:"insert",describe:"Insert a record into a module",builder:e=>E(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array)"}),handler:async e=>{try{let t=q(e),o=JSON.parse(e.data),r=await t.insertRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},qm={command:"upsert",describe:"Upsert a record in a module",builder:e=>E(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array, include id for update)"}),handler:async e=>{try{let t=q(e),o=JSON.parse(e.data),r=await t.upsertRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},$m={command:"update",describe:"Update a record in a module",builder:e=>E(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array, must include id)"}),handler:async e=>{try{let t=q(e),o=JSON.parse(e.data),r=await t.updateRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},Hm={command:"delete",describe:"Delete records from a module",builder:e=>E(e).option("ids",{type:"string",demandOption:!0,describe:"Comma-separated record IDs to delete"}),handler:async e=>{try{let t=q(e),o=e.ids.split(",").map(n=>n.trim()),r=await t.deleteRecord({module:e.module,ids:o});l(r)}catch(t){m(t),process.exit(1)}}},zm={command:"emails",describe:"Get emails for a record",builder:e=>ie(Ie(E(e))),handler:async e=>{try{let o=await q(e).getEmailsForRecord({module:e.module,id:e.id,page:e.page,per_page:e.perPage});l(o.data,{page:o.info?.page,per_page:o.info?.per_page,more_records:o.info?.more_records})}catch(t){m(t),process.exit(1)}}},Jm={command:"attachments",describe:"Get attachments for a record",builder:e=>Dt(ie(Ie(E(e))),!0),handler:async e=>{try{let o=await q(e).getAttachmentsForRecord({module:e.module,id:e.id,fields:e.fields,page:e.page,per_page:e.perPage});l(o.data,{page:o.info?.page,per_page:o.info?.per_page,more_records:o.info?.more_records})}catch(t){m(t),process.exit(1)}}},_c={command:"crm",describe:"Zoho CRM operations",builder:e=>e.command(Bm).command(Wm).command(Gm).command(jm).command(qm).command($m).command(Hm).command(zm).command(Jm).demandCommand(1,"Please specify a CRM subcommand.").example([['$0 crm list -m Contacts --fields "First_Name,Last_Name,Email" --per-page 10',"List contacts"],["$0 crm get -m Contacts --id 12345","Get a contact by ID"],['$0 crm search -m Leads --word "Acme"',"Search leads by keyword"],[`$0 crm insert -m Contacts --data '{"First_Name":"Jane","Last_Name":"Doe"}'`,"Insert a contact"]]),handler:F};var Ym={command:"list",describe:"List tickets",builder:e=>P(e).option("department-id",{type:"string",describe:"Filter by department ID"}).option("status",{type:"string",describe:"Filter by status"}).option("sort-by",{type:"string",describe:"Field to sort by"}).option("include",{type:"string",describe:"Comma-separated includes (e.g. contacts,assignee,departments,team,isRead)"}),handler:async e=>{try{let o=await b(e).getTickets({from:e.from,limit:e.limit,departmentId:e.departmentId,status:e.status,sortBy:e.sortBy,include:e.include});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},Xm={command:"get <ticketId>",describe:"Get a ticket by ID",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("include",{type:"string",describe:"Comma-separated includes (e.g. contacts,assignee,departments,team,isRead)"}),handler:async e=>{try{let o=await b(e).getTicketById({ticketId:e.ticketId,include:e.include});l(o)}catch(t){m(t),process.exit(1)}}},Qm={command:"search",describe:"Search tickets",builder:e=>P(e).option("subject",{type:"string",describe:"Search by subject"}).option("status",{type:"string",describe:"Filter by status"}).option("email",{type:"string",describe:"Filter by email"}).option("department-id",{type:"string",describe:"Filter by department ID"}).option("channel",{type:"string",describe:"Filter by channel"}).option("priority",{type:"string",describe:"Filter by priority"}),handler:async e=>{try{let o=await b(e).searchTickets({from:e.from,limit:e.limit,subject:e.subject,status:e.status,email:e.email,departmentId:e.departmentId,channel:e.channel,priority:e.priority});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},ey={command:"by-contact <contactId>",describe:"List tickets for a contact",builder:e=>P(e).positional("contactId",{type:"string",demandOption:!0,describe:"Contact ID"}),handler:async e=>{try{let o=await b(e).getTicketsForContact({contactId:e.contactId,from:e.from,limit:e.limit});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},ty={command:"metrics <ticketId>",describe:"Get ticket metrics",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketMetrics({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},oy={command:"agent-counts",describe:"Get ticket counts per agent",builder:e=>e.option("agent-ids",{type:"string",demandOption:!0,describe:"Comma-separated agent IDs"}).option("department-id",{type:"string",describe:"Filter by department ID"}),handler:async e=>{try{let t=b(e),o=e.agentIds.split(",").map(n=>n.trim()),r=await t.getAgentsTicketsCount({agentIds:o,departmentId:e.departmentId});l(r)}catch(t){m(t),process.exit(1)}}},wc={command:"tickets",describe:"Desk ticket operations",builder:e=>e.command(Ym).command(Xm).command(Qm).command(ey).command(ty).command(oy).demandCommand(1),handler:F};var ry={command:"list",describe:"List departments",builder:e=>P(e).option("search",{type:"string",describe:"Search by name"}).option("is-enabled",{type:"boolean",describe:"Filter by enabled status"}),handler:async e=>{try{let o=await b(e).getDepartments({from:e.from,limit:e.limit,searchStr:e.search,isEnabled:e.isEnabled});l(o.data,{count:o.data?.length})}catch(t){m(t),process.exit(1)}}},ny={command:"get <departmentId>",describe:"Get a department by ID",builder:e=>e.positional("departmentId",{type:"string",demandOption:!0,describe:"Department ID"}),handler:async e=>{try{let o=await b(e).getDepartmentById({departmentId:e.departmentId});l(o)}catch(t){m(t),process.exit(1)}}},Vc={command:"departments",describe:"Desk department operations",builder:e=>e.command(ry).command(ny).demandCommand(1),handler:F};var ay={command:"list",describe:"List contacts",builder:e=>P(e).option("sort-by",{type:"string",describe:"Field to sort by"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let o=await b(e).getContacts({from:e.from,limit:e.limit,sortBy:e.sortBy,include:e.include});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},iy={command:"get <contactId>",describe:"Get a contact by ID",builder:e=>e.positional("contactId",{type:"string",demandOption:!0,describe:"Contact ID"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let o=await b(e).getContactById({contactId:e.contactId,include:e.include});l(o)}catch(t){m(t),process.exit(1)}}},Kc={command:"contacts",describe:"Desk contact operations",builder:e=>e.command(ay).command(iy).demandCommand(1),handler:F};var sy={command:"list",describe:"List agents",builder:e=>P(e).option("department-id",{type:"string",describe:"Filter by department ID"}).option("status",{type:"string",describe:"Filter by status (active, disabled)"}).option("include",{type:"string",describe:"Comma-separated includes (e.g. role,profile,departments)"}),handler:async e=>{try{let o=await b(e).getAgents({from:e.from,limit:e.limit,departmentId:e.departmentId,status:e.status,include:e.include});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},cy={command:"get <agentId>",describe:"Get an agent by ID",builder:e=>e.positional("agentId",{type:"string",demandOption:!0,describe:"Agent ID"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let o=await b(e).getAgentById({agentId:e.agentId,include:e.include});l(o)}catch(t){m(t),process.exit(1)}}},uy={command:"my-info",describe:"Get current authenticated agent info",builder:e=>e,handler:async e=>{try{let o=await b(e).getMyInfo();l(o)}catch(t){m(t),process.exit(1)}}},Uc={command:"agents",describe:"Desk agent operations",builder:e=>e.command(sy).command(cy).command(uy).demandCommand(1),handler:F};var py={command:"list",describe:"List all tags",builder:e=>P(e).option("department-id",{alias:"d",type:"string",demandOption:!0,describe:"Department ID"}),handler:async e=>{try{let o=await b(e).getAllTags({from:e.from,limit:e.limit,departmentId:e.departmentId});l(o.data,{count:o.data?.length})}catch(t){m(t),process.exit(1)}}},dy={command:"search",describe:"Search tags",builder:e=>P(e).option("department-id",{alias:"d",type:"string",describe:"Department ID"}).option("query",{alias:"q",type:"string",demandOption:!0,describe:"Search string"}),handler:async e=>{try{let o=await b(e).searchTags({from:e.from,limit:e.limit,departmentId:e.departmentId,searchVal:e.query});l(o.data,{count:o.data?.length})}catch(t){m(t),process.exit(1)}}},ly={command:"for-ticket <ticketId>",describe:"Get tags on a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketTags({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},my={command:"associate <ticketId>",describe:"Add tags to a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("tags",{type:"string",demandOption:!0,describe:"Comma-separated tag names"}),handler:async e=>{try{let t=b(e),o=e.tags.split(",").map(n=>n.trim()),r=await t.associateTicketTags({ticketId:e.ticketId,tags:o});l(r)}catch(t){m(t),process.exit(1)}}},yy={command:"dissociate <ticketId>",describe:"Remove a tag from a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("tag-id",{type:"string",demandOption:!0,describe:"Tag ID to remove"}),handler:async e=>{try{await b(e).dissociateTicketTag({ticketId:e.ticketId,tagId:e.tagId}),l({removed:!0})}catch(t){m(t),process.exit(1)}}},Bc={command:"tags",describe:"Desk tag operations",builder:e=>e.command(py).command(dy).command(ly).command(my).command(yy).demandCommand(1),handler:F};var hy={command:"list <ticketId>",describe:"List comments on a ticket",builder:e=>P(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("sort-by",{type:"string",describe:"Sort field"}),handler:async e=>{try{let o=await b(e).getTicketComments({ticketId:e.ticketId,from:e.from,limit:e.limit,sortBy:e.sortBy});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},fy={command:"get <ticketId> <commentId>",describe:"Get a comment by ID",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).positional("commentId",{type:"string",demandOption:!0,describe:"Comment ID"}),handler:async e=>{try{let o=await b(e).getTicketCommentById({ticketId:e.ticketId,commentId:e.commentId});l(o)}catch(t){m(t),process.exit(1)}}},gy={command:"create <ticketId>",describe:"Create a comment on a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("content",{type:"string",demandOption:!0,describe:"Comment content"}).option("public",{type:"boolean",default:!1,describe:"Make comment public"}).option("content-type",{type:"string",default:"plainText",choices:["plainText","html"],describe:"Content type"}),handler:async e=>{try{let o=await b(e).createTicketComment({ticketId:e.ticketId,content:e.content,isPublic:e.public,contentType:e.contentType});l(o)}catch(t){m(t),process.exit(1)}}},Ty={command:"delete <ticketId> <commentId>",describe:"Delete a comment",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).positional("commentId",{type:"string",demandOption:!0,describe:"Comment ID"}),handler:async e=>{try{await b(e).deleteTicketComment({ticketId:e.ticketId,commentId:e.commentId}),l({deleted:!0})}catch(t){m(t),process.exit(1)}}},Wc={command:"comments",describe:"Desk comment operations",builder:e=>e.command(hy).command(fy).command(gy).command(Ty).demandCommand(1),handler:F};var xy={command:"list <ticketId>",describe:"List attachments on a ticket",builder:e=>P(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketAttachments({ticketId:e.ticketId,from:e.from,limit:e.limit});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},Ry={command:"delete <ticketId> <attachmentId>",describe:"Delete an attachment",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).positional("attachmentId",{type:"string",demandOption:!0,describe:"Attachment ID"}),handler:async e=>{try{await b(e).deleteTicketAttachment({ticketId:e.ticketId,attachmentId:e.attachmentId}),l({deleted:!0})}catch(t){m(t),process.exit(1)}}},Gc={command:"attachments",describe:"Desk attachment operations",builder:e=>e.command(xy).command(Ry).demandCommand(1),handler:F};var by={command:"list <ticketId>",describe:"List followers of a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketFollowers({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},Fy={command:"add <ticketId>",describe:"Add followers to a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("agent-ids",{type:"string",demandOption:!0,describe:"Comma-separated agent IDs"}),handler:async e=>{try{let t=b(e),o=e.agentIds.split(",").map(r=>r.trim());await t.addTicketFollowers({ticketId:e.ticketId,agentIds:o}),l({added:!0})}catch(t){m(t),process.exit(1)}}},Sy={command:"remove <ticketId>",describe:"Remove followers from a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("agent-ids",{type:"string",demandOption:!0,describe:"Comma-separated agent IDs"}),handler:async e=>{try{let t=b(e),o=e.agentIds.split(",").map(r=>r.trim());await t.removeTicketFollowers({ticketId:e.ticketId,agentIds:o}),l({removed:!0})}catch(t){m(t),process.exit(1)}}},jc={command:"followers",describe:"Desk ticket follower operations",builder:e=>e.command(by).command(Fy).command(Sy).demandCommand(1),handler:F};var Cy={command:"timer <ticketId>",describe:"Get current timer state for a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketTimer({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},Iy={command:"timer-action <ticketId>",describe:"Start, pause, resume, or stop a timer",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("action",{type:"string",demandOption:!0,choices:["start","pause","resume","stop"],describe:"Timer action"}),handler:async e=>{try{let o=await b(e).performTicketTimerAction({ticketId:e.ticketId,timerAction:e.action});l(o)}catch(t){m(t),process.exit(1)}}},My={command:"entries <ticketId>",describe:"List time entries for a ticket",builder:e=>P(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketTimeEntries({ticketId:e.ticketId,from:e.from,limit:e.limit});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},Oy={command:"summation <ticketId>",describe:"Get time entry summation for a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketTimeEntrySummation({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},qc={command:"time",describe:"Desk time tracking operations",builder:e=>e.command(Cy).command(Iy).command(My).command(Oy).demandCommand(1),handler:F};var Ay={command:"list <ticketId>",describe:"List threads on a ticket",builder:e=>P(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let o=await b(e).getTicketThreads({ticketId:e.ticketId,from:e.from,limit:e.limit,include:e.include});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},Py={command:"get <ticketId> <threadId>",describe:"Get a thread by ID",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).positional("threadId",{type:"string",demandOption:!0,describe:"Thread ID"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let o=await b(e).getTicketThreadById({ticketId:e.ticketId,threadId:e.threadId,include:e.include});l(o)}catch(t){m(t),process.exit(1)}}},$c={command:"threads",describe:"Desk ticket thread operations",builder:e=>e.command(Ay).command(Py).demandCommand(1),handler:F};var Ey={command:"list <ticketId>",describe:"List activities on a ticket",builder:e=>P(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketActivities({ticketId:e.ticketId,from:e.from,limit:e.limit});l(o.data,{from:e.from,limit:e.limit,count:o.data?.length})}catch(t){m(t),process.exit(1)}}},Hc={command:"activities",describe:"Desk ticket activity operations",builder:e=>e.command(Ey).demandCommand(1),handler:F};var zc={command:"desk",describe:"Zoho Desk operations",builder:e=>e.command(wc).command(Vc).command(Kc).command(Uc).command(Bc).command(Wc).command(Gc).command(jc).command(qc).command($c).command(Hc).demandCommand(1,"Please specify a desk subcommand.").example([["$0 desk tickets list --limit 10","List first 10 tickets"],["$0 desk tickets get 12345","Get a ticket by ID"],["$0 desk agents my-info","Get current agent info"],['$0 desk comments create 12345 --content "Looking into this"',"Add a comment"]]),handler:F};var Jc={command:"request <product> <method> <path>",describe:"Make a raw API request through the authenticated context",builder:e=>e.positional("product",{type:"string",demandOption:!0,choices:["recruit","crm","desk"],describe:"Zoho product"}).positional("method",{type:"string",demandOption:!0,choices:["GET","POST","PUT","PATCH","DELETE"],describe:"HTTP method"}).positional("path",{type:"string",demandOption:!0,describe:"API path (relative to product base URL)"}).option("body",{type:"string",describe:"JSON request body"}).option("query",{type:"string",describe:"JSON query parameters"}).example([["$0 request recruit GET /v2/Candidates","List candidates via raw API"],[`$0 request desk GET /tickets --query '{"limit":5}'`,"List 5 desk tickets via raw API"],[`$0 request crm POST /v8/Contacts --body '{"data":[{"Last_Name":"Test"}]}'`,"Create a CRM contact via raw API"]]),handler:async e=>{try{let t=e.product,o=e.method,r=e.path,n;switch(t){case"recruit":n=j(e).recruitContext;break;case"crm":n=q(e).crmContext;break;case"desk":n=b(e).deskContext;break;default:throw new Error(`Unknown product: ${t}`)}let a=r;if(e.query){let c=JSON.parse(e.query),p=new URLSearchParams(c),u=a.includes("?")?"&":"?";a=`${a}${u}${p.toString()}`}let i={method:o};e.body&&(i.body=e.body,i.headers={"Content-Type":"application/json"});let s=await n.fetchJson(a,i);l(s)}catch(t){m(t),process.exit(1)}}};var ky={command:"set",describe:"Configure output settings (global or per-command)",builder:e=>e.option("command",{alias:"c",type:"string",describe:"Command path to configure (e.g. desk.tickets.list)"}).check(t=>{if(!t.setDumpDir&&!t.setPick)throw new Error("At least one of --set-dump-dir or --set-pick is required");return!0}),handler:async e=>{try{let t=e.command,o=e.setDumpDir,r=e.setPick,n;if(t){let i={...o!==void 0?{dumpDir:o}:{},...r!==void 0?{pick:r}:{}};n={commands:{[t]:i}}}else n={...o!==void 0?{dumpDir:o}:{},...r!==void 0?{pick:r}:{}};let a=await U({output:n});l({saved:!0,output:a.output})}catch(t){m(t),process.exit(1)}}},Zy={command:"show",describe:"Show current output configuration",builder:e=>e,handler:async()=>{try{let e=await w();l({output:e?.output??{}})}catch(e){m(e),process.exit(1)}}},Dy={command:"clear",describe:"Clear output configuration (global or per-command)",builder:e=>e.option("command",{alias:"c",type:"string",describe:"Command path to clear (omit to clear all output config)"}),handler:async e=>{try{let t=e.command;if(t){let o=await w(),r={...o?.output?.commands};delete r[t];let n={...o?.output,commands:r};await U({output:n}),l({cleared:!0,command:t})}else await tn(),l({cleared:!0})}catch(t){m(t),process.exit(1)}}},Yc={command:"output",describe:"Configure output settings (dump, field filtering)",builder:e=>e.command(ky).command(Zy).command(Dy).demandCommand(1),handler:F};var Ny=[Nc,_c,zc,Jc],Xc=[Dc,Yc,Lc];function _y(e){return e.command.split(" ")[0]}var Yr=new Set(Xc.map(_y));function wy(){return async e=>{let t=e._?e._.map(String):[],o=t[0],r=e.setDumpDir,n=e.setPick;if((r!==void 0||n!==void 0)&&o&&!Yr.has(o)){let p=t.join("."),u={...r!==void 0?{dumpDir:r}:{},...n!==void 0?{pick:n}:{}};await U({output:{commands:{[p]:u}}})}let i=o&&!Yr.has(o),s=await w(),c=i?en(s?.output,t,{dumpDir:e.dumpDir??r,pick:e.pick??n}):{dumpDir:void 0,pick:void 0};Ec({dumpDir:c.dumpDir,pick:e.pickAll?void 0:c.pick,commandPath:t})}}async function Vy(){try{await Ly(vy(process.argv)).scriptName("zoho-cli").usage("$0 <command> [options]").option("verbose",{alias:"v",type:"boolean",default:!1,global:!0,describe:"Verbose output"}).option("dump-dir",{type:"string",global:!0,describe:"Directory to save full API responses as JSON files (overrides config)"}).option("pick",{type:"string",global:!0,describe:"Comma-separated top-level fields to include in output (overrides config)"}).option("set-dump-dir",{type:"string",global:!0,describe:"Save dump directory to config for this command and apply now"}).option("set-pick",{type:"string",global:!0,describe:"Save pick fields to config for this command and apply now"}).option("pick-all",{type:"boolean",global:!0,describe:"Ignore any configured pick filters and return full response data"}).middleware([vc(Yr),wy()],!0).command(Xc).command(Ny).demandCommand(1,"Please specify a command. Use --help for available commands.").strict().fail(!1).help().alias("help","h").version(!1).wrap(Math.min(120,process.stdout.columns||80)).parse()}catch(e){m(e),process.exit(1)}}Vy();
|
|
4
|
+
var pu=Object.defineProperty;var du=Object.getOwnPropertyDescriptor;var O=(e,t,o,r)=>{for(var n=r>1?void 0:r?du(t,o):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(n=(r?i(t,o,n):i(n))||n);return r&&n&&pu(t,o,n),n},A=(e,t)=>(o,r)=>t(o,r,e);import qy from"yargs";import{hideBin as $y}from"yargs/helpers";import{readFile as lu,writeFile as mu,rm as yu,mkdirSync as hu}from"node:fs";import{join as Po}from"node:path";import{homedir as fu}from"node:os";var Kt=["recruit","crm","desk"];function Ao(){return Po(fu(),".zoho-cli")}function lt(){return Po(Ao(),"config.json")}function mt(){return Po(Ao(),".tokens.json")}function ee(e,t){if(t){let o=process.env[`ZOHO_${t}_${e}`];if(o)return o}return process.env[`ZOHO_${e}`]}async function B(){let e=lt(),t=await xu(e),o=ee("ACCOUNTS_CLIENT_ID"),r=ee("ACCOUNTS_CLIENT_SECRET"),n=ee("ACCOUNTS_REFRESH_TOKEN");if(!t&&!(o&&r&&n))return;let i={clientId:o??t?.shared?.clientId??"",clientSecret:r??t?.shared?.clientSecret??"",refreshToken:n??t?.shared?.refreshToken??"",region:ee("ACCOUNTS_URL")??t?.shared?.region,apiMode:ee("API_URL")??t?.shared?.apiMode};function s(u){let p=u.toUpperCase(),d=ee("ACCOUNTS_CLIENT_ID",p),g=ee("ACCOUNTS_CLIENT_SECRET",p),y=ee("ACCOUNTS_REFRESH_TOKEN",p),h=ee("API_URL",p),T=u==="desk"?ee("DESK_ORG_ID"):void 0,R=t?.[u],S=process.env[`ZOHO_${p}_ACCOUNTS_CLIENT_ID`],M=process.env[`ZOHO_${p}_ACCOUNTS_CLIENT_SECRET`],v=process.env[`ZOHO_${p}_ACCOUNTS_REFRESH_TOKEN`];if(!(!R&&!(S||M||v)&&!T))return{clientId:S??R?.clientId,clientSecret:M??R?.clientSecret,refreshToken:v??R?.refreshToken,apiUrl:h??R?.apiUrl,orgId:T??R?.orgId}}return{shared:i,recruit:s("recruit")??t?.recruit,crm:s("crm")??t?.crm,desk:s("desk")??t?.desk,output:t?.output}}function yt(e,t){let o=e[t],r=e.shared,n=o?.clientId??r.clientId,a=o?.clientSecret??r.clientSecret,i=o?.refreshToken??r.refreshToken;if(!(!n||!a||!i))return{clientId:n,clientSecret:a,refreshToken:i,region:r.region??"us",apiMode:o?.apiUrl??r.apiMode??"production",orgId:o?.orgId}}async function gu(e){let t=lt();return hu(Ao(),{recursive:!0}),new Promise((o,r)=>{mu(t,JSON.stringify(e,null,2),{},n=>{n?r(n):o()})})}async function G(e){let t=await B(),o={shared:{...t?.shared,...e.shared},recruit:e.recruit!==void 0?{...t?.recruit,...e.recruit}:t?.recruit,crm:e.crm!==void 0?{...t?.crm,...e.crm}:t?.crm,desk:e.desk!==void 0?{...t?.desk,...e.desk}:t?.desk,output:e.output!==void 0?Tu(t?.output,e.output):t?.output};return await gu(o),o}function Tu(e,t){return{dumpDir:"dumpDir"in t?t.dumpDir:e?.dumpDir,pick:"pick"in t?t.pick:e?.pick,commands:"commands"in t?t.commands?{...e?.commands,...t.commands}:void 0:e?.commands}}function sn(e,t,o){let r=t.join("."),n=r?e?.commands?.[r]:void 0;return{dumpDir:o.dumpDir??n?.dumpDir??e?.dumpDir,pick:o.pick??n?.pick??e?.pick}}async function cn(){await G({output:{dumpDir:void 0,pick:void 0,commands:void 0}})}async function un(){let e=lt(),t=mt();await an(e),await an(t)}function J(e){return Kt.filter(t=>{let o=yt(e,t);return!(!o||t==="desk"&&!o.orgId)})}function xu(e){return new Promise(t=>{lu(e,{encoding:"utf-8"},(o,r)=>{if(o){t(void 0);return}try{t(JSON.parse(r))}catch{t(void 0)}})})}function an(e){return new Promise(t=>{yu(e,()=>t())})}function Te(e){return e.length<=4?"***":e.substring(0,4)+"***"}function C(){}import{Inject as fc,Injectable as Il}from"@nestjs/common";function Ut(e,t){let o;return t&&typeof e=="string"?o=[e]:de(e)?o=[...e]:o=[e],o}function Eo(e,t){return new Map(Ut(e).map(o=>[t(o),o]))}function de(e,t=!1){return typeof e=="string"?t:e!=null&&typeof e=="object"&&Symbol.iterator in e}function ht(e){for(let t of e)return!1;return!0}function xe(e,t){for(let o of e)t(o)}function q(e,t,o=!1){e!=null&&(de(e,o)?xe(e,t):t(e))}function pn(e){if(!Array.isArray(e))throw new Error("Input is not an array/tuple...");let t;if(e.length>0){let o=e[0],r=!1;if(Array.isArray(o)){let n=o.length;r=e.findIndex(i=>Array.isArray(i)?i.length!==n:!0)!==-1}else r=!0;t=r?[e]:e}else t=e;return t}function Ru(e){return e!=null?ko(e):[]}var f=Ru;function ko(e){return Array.isArray(e)?e:[e]}function Zo(e){return dn([],...e)}function dn(e,...t){return e??=[],t.forEach(o=>{o!=null&&ln(e,o)}),e}function ln(e,t){return Array.prototype.push.apply(e,t),e}import{symmetricDifference as hh}from"extra-set";function bu(e,t){let o=new Set(e??void 0);return t(o),o}function mn(e,t){return bu(e,o=>ft(o,t))}function ft(e,t){q(t,o=>e.add(o))}function gt(e,t=!0){return t?((...o)=>!e.call(void 0,...o)):e}function yn(e){return Object.keys(e).length===0}function le(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function hn(e){let t={};return e.forEach((o,r)=>{t[r]=o}),t}function Lo(e){return{...e}}function Tt(e){return e!=null}function Ee(e){return de(e,!1)?!ht(e):fn(e)}function vo(e){let t;return de(e,!0)?t=!ht(e):fn(e)?t=typeof e=="object"?!yn(e):!0:t=!1,t}function fn(e){return e!=null&&e!==""}function gn(e){return(t=>{let o;return t!=null?o=t.filter(e):o=[],o})}var N=gn(Tt),Fu=gn(Ee);function Bt({base:e,build:t}){let o=e??{};return t(o),o}function Gt(e){return t=>t.map(e)}var Ke=(e=>e);function Re(){return Ke}function Su(e,t){return N(e!=null?Array.isArray(e)?e:xn(e,t):[])}function xn(e,t){let o=new Set(e.keys);return e.values&&ft(o,e.values.map(t)),Array.from(o)}function No(e,t){let o=Su(t,e);function r(n){let a=n?Array.isArray(n)?n.map(e):xn(n,e):[];return a.length?Zo([N(a),o]):o}return(n,a)=>{let i=r(a),s=new Set(i);return n.filter(u=>{let p=e(u);return s.has(p)?!1:(s.add(p),!0)})}}var Cu=e=>e.id;function _o(e,t,o){let r=o(t);return wo(e,r,o)}function wo(e,t,o=Cu){return e.filter(r=>o(r)!==t)}function Vo(e){return t=>{let o=e(t);if(o==="")throw new Error('Cannot use "empty" string for BooleanKey.');return o}}function bn(e){return!e||e.length<=0}function Iu(e){return!bn(e)}function Ou(e,t,o){return e?[..._o(e,t,Vo(o)),t]:[t]}function Mu(e,t,o){return e&&_o(e,t,Vo(o))}function Pu(e,t,o){return e&&wo(e,t,Vo(o))}function Au(e){let t=s=>bn(s),o=s=>Iu(s),r=(s,c,u=!0)=>u?n(s,c):a(s,c),n=(s,c)=>Ou(s,c,e),a=(s,c)=>Mu(s,c,e);return{isFalse:t,isTrue:o,set:r,insert:n,remove:a,removeByKey:(s,c)=>Pu(s,c,e)}}var $h=Au(e=>e||void 0);function be(e,t){let o=Eu(e,r=>t(r)?"in":"out");return{included:o.in??[],excluded:o.out??[]}}function Eu(e,t){let o=Fn(e,t);return hn(o)}function Fn(e,t){let o=new Map;return e?.forEach(r=>{let n=t(r),a=o.get(n);a!=null?a.push(r):o.set(n,[r])}),o}function Sn(e,t,o){return f(t).forEach(r=>e.set(r,o)),e}function Ko(e){return Array.from(e.entries())}function Cn(e){return ku(Ko(e))}function ku(e){let t=[];return e.forEach(([o,r])=>{q(r,n=>{t.push([o,n])})}),t}function Uo(){let e=new Map,t=(n,a)=>{let i=e.get(n);i==null&&(i=[],e.set(n,i)),q(a,s=>i.push(s))},o=(n,a)=>t(n,pn(a));return{map:()=>e,entries:()=>Ko(e),tuples:()=>Cn(e),delete:n=>e.delete(n),add:t,addTuples:o,addToKeys:(n,a)=>q(n,i=>t(i,a)),addTuplesToKeys:(n,a)=>q(n,i=>o(i,a)),has:n=>e.has(n),get:n=>e.get(n)??[]}}function In(e){let{readKey:t,defaultIfKeyNull:o=!1}=e;return r=>{let n=new Set(r);return a=>{let i=t(a);return i!=null?n.has(i):o}}}var Zu=32;function Du(e){return t=>{let o=new Set;for(let r=0;r<e;r+=1)t&1<<r&&o.add(r);return o}}var pf=Du(Zu);function Lu(e){return typeof e=="function"?e.prototype?Object.getOwnPropertyDescriptor(e,"prototype")?.writable?"function":"class":e.constructor.name==="AsyncFunction"?"function":"arrow":null}function On(e){let t=Lu(e);return t!=null&&t!=="class"}function me(e){return On(e)?e:()=>e}function xt(e={}){let{startAt:t,increaseBy:o}=e,r=me(o??1),n=t??0;return()=>{let a=n;return n+=r(),a}}function vu(e){let{min:t,max:o}=e;return t<=o}function Nu(e){let{min:t,max:o}=e;if(!vu(e))throw new Error("Invalid bounds. Min was greater than the max.");return r=>r>=t&&r<=o}function jt(e){let{min:t,max:o,fencePosts:r=!1}=e,n=o-t,a=Nu(e),i=(s=>{let c;if(a(s))c=s;else{let u=r?s<t?1:-1:0;c=((s-t)%n+n)%n+t+u}return c});return i._wrap=e,i}function qt(e){let{min:t,max:o,wrap:r}=e;return r?jt(e):n=>_u(n,t,o)}function _u(e,t,o){return Math.max(Math.min(e,o),t)}function Mn(e){let t;switch(typeof e){case"number":t=e;break;case"string":t=Number(e);break;default:t=0;break}return t}function Pn(e,t){return Math.log(t)/Math.log(e)}function Wo(e){let t;switch(e){case"floor":t=Math.floor;break;case"ceil":t=Math.ceil;break;case"none":t=o=>o;break;default:t=Math.round;break}return t}var Ff=Rt(0);function Rt(e,t="cut"){let o=Vu(e,t),r=(n=>o(Mn(n)));return r._precision=e,r}function Vu(e,t="round"){let o;if(t==="cut")o=r=>An(r,e);else{let r=Wo(t);o=n=>+(r(+(n+"e+"+e))+"e-"+e)}return o}function An(e,t){return+((e>0?Math.floor:Math.ceil)(+(e+"e+"+t))+"e-"+t)}function Ue(e,t){let o=typeof e=="number"?{min:0,max:e}:e,{min:r,max:n,round:a}=o,i=t??a,s;if(r!=null){let c=n-r;s=()=>Math.random()*c+r}else s=()=>Math.random()*n;if(i&&i!=="none"){let c=typeof i=="function"?i:Wo(i),u=s;s=()=>c(u())}return s}function En(e){return(t,o)=>{let r=e(t),n=e(o);return r-n}}var Pf=En(e=>e);function Zn(e){return e.i}var pg=No(Zn);var dg=In({readKey:Zn});var Dn=",",Uu=" ";function Wu(e,t=Dn,o=!1){if(e==null)return e;let r=f(e);return o&&(r=r.map(n=>n?.trim())),r.filter(Boolean).join(t)}function Ht(e,t,o){let r=e.split(t),n=[];if(r.length>1){let a=r.length>o,i=a?o-1:r.length;for(let s=0;s<i;s+=1)n.push(r[s]);a&&n.push(r.slice(i).join(t))}else n.push(r[0]);return n}function Bu(e){let{joiner:t,trimByDefault:o=!1}=e,r=function(n,a=o){return Wu(n,t,a)};return r.joiner=t,r.trimByDefault=o,r}function Ln(e){let{joiner:t}=e,o=Bu(e),r=(n,a=i=>i)=>n.split(t).map(s=>a(s.trim()));return{joiner:t,trimByDefault:o.trimByDefault,joinStrings:o,splitStrings:r,splitStringsToSet(n){return new Set(n==null?[]:r(n))},splitJoinRemainder(n,a){return Ht(n,t,a)}}}var Go=Ln({joiner:Dn}),Gu=Ln({joiner:Uu,trimByDefault:!0});var E=Go.joinStrings,Hg=Go.splitStrings,zg=Go.splitStringsToSet,ju=Gu.joinStrings;function vn(e){return e.trim()}function Nn(e){return e.toUpperCase()}function _n(e){return e.toLowerCase()}var hT=Gt(vn),fT=Gt(Nn),gT=Gt(_n);import{BaseError as $u}from"make-error";var Hu="DBX_ASSERTION_ERROR",jo=class extends $u{code=Hu;_target;_property;constructor(t,o){super(o),this.name="AssertionError",this._target=t.target,this._property=t.propertyKey}get target(){return this._target}get propertyKey(){return this._property}},qo=class{handle(t){throw this.buildException(t)}buildException(t){let o=this.buildExceptionString(t);return new jo(t,o)}buildExceptionString(t){let o;return t.options?.message?o=t.options.message:o="Assertion failed for property '"+t.propertyKey+'".',o}},zu=new qo;var wn=gt;function We(e,{forEach:t,filter:o}){Vn(e,o).forEach(t)}function Vn(e,t){return zo(t)(e)}function zo(e){let t;if(e!=null){let o=Yu(e);t=r=>Ho(r).filter(o)}else t=Ho;return t}function Ho(e){return Object.entries(e)}function Jo(e){return typeof e=="object"?e:{valueFilter:e}}function Yu(e){let t=Jo(e),{valueFilter:o=1,invertFilter:r=!1,keysFilter:n}=t,a;switch(o){case 1:a=([,i])=>i!==void 0;break;case 2:a=([,i])=>i!=null;break;case 3:a=([,i])=>!!i;break;case 4:a=([,i])=>Ee(i);break;case 5:a=([,i])=>vo(i);break;case 6:a=([,i])=>!!i&&Ee(i);break;case 7:a=([,i])=>!!i&&vo(i);break;default:a=()=>!0;break}if(n){let i=a,s=new Set(n.map(c=>c.toString()));a=(c,u)=>i(c,u)&&s.has(c[0])}return wn(a,r)}function Be(e){let t,o=n=>{t={value:e(n)}},r=(n=>(t||o(n),t.value));return r.set=n=>t={value:n},r.reset=()=>t=void 0,r.init=o,r.used=()=>!!t,r}function Xu({filter:e,copy:t,dynamic:o=!1}){let r=e!=null?Ge({filter:e,copy:!1}):ep;return n=>{let a=()=>{let s={};return n.forEach(c=>{let u=r({...c});Object.assign(s,u)}),s},i=o?a:Be(a);return s=>{let c=i();return t&&(s=Lo(s)),Object.assign(s,c),s}}}function zt(e,t){return Qu(t)(e)}function Qu(e){let t=Xu({filter:e,copy:!1,dynamic:!0});return o=>t(N(o))({})}var Rx=Ge({copy:!0,filter:{valueFilter:1}}),bx=Ge({copy:!0,filter:{valueFilter:2}}),Kn=Ge({copy:!0,filter:{valueFilter:4}}),Fx=Ge({copy:!0,filter:{valueFilter:6}}),Sx=Yo({valueFilter:1}),Cx=Yo({valueFilter:6}),Ix=Yo({valueFilter:2});function Yo(e){let t=Xo({filter:e,forEach:([o],r,n,a)=>{a.keys.push(o)}});return o=>{let r={keys:[]};return t(o,r),r.keys}}function Ge({copy:e=!1,filter:t={valueFilter:1}}={}){let o=Jo(t);o.invertFilter=!o.invertFilter;let r=Xo({filter:o,forEach:([n],a,i)=>{delete i[n]}});return(n,a)=>((typeof a=="boolean"?a:e)&&(n={...n}),r(n),n)}var ep=Ge({copy:!1});function Xo({forEach:e,filter:t}){let o=zo(t);return((r,n)=>{o(r).forEach((i,s)=>e(i,s,r,n))})}function tp(e){let{readKey:t,isModifiedFunction:o=()=>{}}=e;return(r,n)=>{let a=[],i=Eo(r,t),s=Eo(n,t),c=new Set(i.keys()),u=new Set(s.keys()),p=mn(c,u);return xe(p,d=>{if(d==null)return;let g=c.has(d),y=u.has(d),h;y&&g?h=0:g?h=-1:h=1;let T=g?i.get(d):void 0,R=y?s.get(d):void 0,S=T&&R?o(T,R):void 0;a.push({key:d,pastValue:T,nextValue:R,change:h,isModified:S,value:R??T})}),a}}var Nx=tp({readKey:e=>e});function Ft(e,t,o){let[r,n]=Jt(e,t,!1);return r+o+n}function Jt(e,t,o=!1){let r=e.substring(0,t),n=e.substring(t+(o?0:1));return[r,n]}function Wn(e){let t={};for(let[o,r]of[...e].entries())t[r]=o;return t}var op=["\\","^","$",".","|","?","*","+","(",")","[","]","{","}"],rp=new Set(op);function Qo(e){let{escapeTargets:t,escapeCharacter:o}=e,r=t instanceof Set?t:new Set(t);return n=>{let a=Yt(r,n),i;switch(a.length){case 0:i=n;break;case 1:{let s=n[a[0]];i=Ft(n,a[0],o(s));break}default:{let s=[],c=a.length,u=0,p=0;for(let d=0;d<c;d+=1){p=a[d];let g=n[p],h=n.substring(u,p)+o(g);s.push(h),u=p+1}s.push(n.substring(u)),i=s.join("");break}}return i}}var Bn=Qo({escapeTargets:rp,escapeCharacter(e){return`\\${e}`}});function np(e){return(t,o)=>{let r=o??Number.MAX_SAFE_INTEGER,n=[];for(let[a,i]of[...t].entries())if(e.has(i)&&(n.push(a),n.length>=r))break;return n}}function Yt(e,t,o){return np(e)(t,o)}function ap(e,t){return Yt(e,t,1)[0]}function Xt(e){return t=>{let r=ap(typeof e=="string"?new Set([e]):e,t),n;return r!=null?n=Jt(t,r,!1):n=[t,void 0],n}}function Gn(e,t){return Xt(t)(e)}function jn(e){let t=Xt(e);return o=>t(o)[0]}var dR=jn("#"),lR=Xt("#");var je="/",ip=".";function sp(e){let t=e.split(ip,3).length-1,o;switch(t){case 0:e.length===0?o="invalid":e[e.length-1]===je?o="folder":o="file";break;case 1:o="typedfile";break;default:o="invalid";break}return o}function qn(e){return sp(e)!=="invalid"}var cp=/^\/+/,up=/\/+$/;var pp=/\/{2,}/g;function $n(e){return e.startsWith(je)?e.replace(cp,je):`${je}${e}`}function Hn(e){return e.replace(pp,je)}function zn(e){return e.replace(up,"")}var dp=/(.+)\.(.+)/;function lp(e){return dp.test(e)}var Jn=/:(\d+)/;function mp(e){return Jn.test(e)}function yp(e){let t=Jn.exec(e);return t?Number(t[1]):void 0}function hp(e){let t=ea(e),o=Xn(t),{domain:r,path:n}=o,a=lp(r),i=mp(e),s=i?yp(e)??void 0:void 0,[c,u]=Gn(o.path,"?"),p=a&&(c===""||qn(c+"/")),d=gp(e);return{input:e,isWebsiteUrl:p,hasWebsiteDomain:a,hasHttpPrefix:d,hasPortNumber:i,portNumber:s,splitPair:o,domain:r,websitePath:n,path:c,query:u}}function er(e){let t=hp(e);return t.hasHttpPrefix&&t.isWebsiteUrl}function Yn(e,t=!1){let o=Yt(new Set("?"),e),r,n=e;return t&&o.length?r=o:o.length>1&&(r=o.reverse(),r.pop()),r?.length&&r.forEach(a=>n=Ft(n,a,"&")),n}function Xn(e){let t=ea(e);return fp(t)}function fp(e){let t=Ht(e,"/",2),o=t[0],r=t[1];return{domain:o,path:$n(r??"/")}}var Qn=/^https:\/\/|http:\/\//;function ea(e){return e.replace(Qn,"")}function gp(e){return Qn.test(e)}var rb={prefixes:"email.",domains:"test.dereekb.com",numberFactory:xt()};var nb={internationalAreaCodes:[1210,1979,1512,1303],numberFactory:Ue({min:2e6,max:1e7,round:"floor"})};import{BaseError as mb}from"make-error";var Tp="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_",xp="!";function Rp(e){let{negativePrefix:t,digits:o}=e,r=t?"integer":"positive_integer",n=Math.min(6,Math.floor(Math.log2(o.length))),a=Math.pow(2,n),i=a-1,s=Wn(o);function c(p){let d="",g=p<0;g&&(p=-p);do{let y=p&i;d=o[y]+d,p>>>=n}while(p!==0);return g&&t&&(d=t+d),d}function u(p){let d=!1;p[0]===t&&(d=!0);let g=d?1:0,y=0;for(let h=g;h<p.length;h+=1)y=(y<<n)+s[p[h]];return d&&(y=-y),y}return{type:r,digits:o,bitDepth:a,negativePrefix:t,encodeNumber:c,decodeNumber:u}}var bp=Rp({negativePrefix:xp,digits:Tp});var ta=-90,oa=90,nF=oa-ta,ra=-180,na=180,Fp=na-ra;var aF=qt({min:ta,max:oa}),iF=jt({min:ra,max:na});var Cp=24,Ip=60,aa=1440,ia=60,bF=ia*Ip,_=1e3,ye=_*60,Qt=ye*60,sa=Qt*Cp,Op=7,Mp=sa*Op;function eo(e){return e.getTime()<Date.now()}var IF=Rt(3);var OF=aa-1;function ca(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}async function Ct(e,t){return new Promise(o=>setTimeout(()=>o(t),e))}function Zp(e){let n=Qt,a={startLimitAt:1,cooldownRate:1,exponentRate:2,maxWaitTime:n},i=0,s=Number.MAX_SAFE_INTEGER,c=new Date,u=!0;y(e??a);function p(){return{...a}}function d(){return u}function g(M){u=M}function y(M,v=!1){let U=Math.max(0,M.startLimitAt??1),I=M.cooldownRate??1,D=M.maxWaitTime??n,P=M.exponentRate??2;a={startLimitAt:U,cooldownRate:I,maxWaitTime:D,exponentRate:P},s=Pn(P,D/_+1),v&&h()}function h(){i=0,c=new Date}function T(M){if(!u)return 0;let{cooldownRate:v}=a,I=(Date.now()-c.getTime())*v/_,D=Math.max(i-I,0),P=Math.max(0,D-a.startLimitAt);return M&&(i=D+M,c=new Date),P>=s?a.maxWaitTime:(Math.pow(a.exponentRate,Math.max(P,0))-1)*_}function R(M){return T(M??0)}function S(){let M=T(1);return Ct(M)}return{waitForRateLimit:S,getNextWaitTime:R,getConfig:p,setConfig:y,getEnabled:d,setEnabled:g,reset:h}}function da(e){let o=Zp({exponentRate:1.5,maxWaitTime:_*8,...e}),r=ye,n=new Date,a=0,i=0,s=!0;S(e,!0);function c(){eo(n)&&d()}function u(){return s}function p(I){s=I}function d(){i=a,n=new Date(Date.now()+r)}function g(){return n}function y(){return Math.max(0,n.getTime()-Date.now())}function h(I){n=I}function T(){return c(),i}function R(I){i=I}function S(I,D=!1){a=I.limit??a,r=I.resetPeriod??r;let P={cooldownRate:I.cooldownRate??Math.max(.1,r/_),exponentRate:I.exponentRate??1.5,maxWaitTime:I.maxWaitTime??_*8};o.setConfig(P,D),D&&d(),n=I.resetAt??n}function M(I){if(!s)return 0;function D(){return i-=I,o.getNextWaitTime(I)}let P=0;return i>0?P=D():(c(),i>0?P=D():P=y()),P}function v(I){return M(I??0)}function U(){let I=M(1);return Ct(I)}return{getRemainingLimit:T,setRemainingLimit:R,getTimeUntilNextReset:y,getResetAt:g,setNextResetAt:h,setConfig:S,reset:d,getNextWaitTime:v,waitForRateLimit:U,getEnabled:u,setEnabled:p}}function la(e){let{promiseFactories:t,successOnMaybe:o,throwErrors:r}=e;return async(n,a)=>{let{successOnMaybe:i,throwErrors:s}=a??{},c=i??o,u=s??r,p;for(let d of t)try{if(p=await d(n),p!=null||c)break}catch(g){if(u)throw g}return p}}import{BaseError as kC}from"make-error";function Dp(e){return t=>{let o={};return Object.entries(t).forEach(([r,n])=>{let a=e(r,n);o[a]=n}),o}}var sI=Dp(e=>{let t=e;return typeof e=="string"&&(t=e.toLowerCase()),t});function Lp(e){return t=>vp(t).then(o=>o.toString(e))}var jI=Lp("base64");function vp(e){let t=[];return new Promise((o,r)=>{e.on("data",n=>t.push(Buffer.from(n))),e.on("end",()=>o(Buffer.concat(t))),e.on("error",r)})}var Np="__CATCH_ALL_HANDLE_RESULT_KEY__";function ya(e,t){let o=t?.defaultResult??!0,r=t?.negativeResult??!1;return()=>{let n,a=new Map,i=u=>{n=u},s=(u,p)=>{u===Np?i(p):Sn(a,u,p)},c=(u,p,d)=>{let g=d.bind(u);s(p,g)};return Bt({base:(u=>{let p=e(u),d=(p!=null?a.get(p):void 0)??n,g;return d?g=Promise.resolve(d(u)).then(y=>y??o):g=Promise.resolve(r),g}),build:u=>{u.readKey=e,u.set=s,u.bindSet=c,u.setCatchAll=i}})}}function _p(e,t){return{accessor:t,boundTo:e,set:(o,r)=>{t.bindSet(e,o,r)},setCatchAll:o=>{t.setCatchAll(o)}}}function wp(e,t){let o=r=>{e.set(t,r)};return o.key=t,o}function Vp(e,t,o){let r=wp(e,t);return n=>{r(function(a){let i=o(a);return n.call(this,i)})}}function ha(e,t){return o=>Vp(e,o,t)}function fa(e){return t=>(o,r)=>{let n=_p(o,t),a=e.configurerForAccessor(n);r(a)}}import{BaseError as xO}from"make-error";var tr=class{_length=0;_storage={};get length(){return this._length}key(t){return Object.keys(this._storage)[t]??null}hasKey(t){return le(this._storage,t)}getItem(t){return this._storage[t]??null}setItem(t,o){o==null?this.removeItem(t):(this.hasKey(t)||(this._length=this._length+1),this._storage[t]=String(o))}removeItem(t){this.hasKey(t)&&(delete this._storage[t],this._length=this._length-1)}clear(){this._storage={},this._length=0}},FO=new tr;function to(e){let t={};return Object.entries(e).forEach(([o,r])=>{t[r]=o}),t}var ga="image/jpeg",Kp="image/png",Up="image/webp",Wp="image/gif",Bp="image/heif",Gp="image/tiff",jp="image/svg+xml",qp="image/raw",$p={jpeg:ga,jpg:ga,png:Kp,webp:Up,gif:Wp,svg:jp,raw:qp,heif:Bp,tiff:Gp},VO=to($p);var Hp="application/pdf",zp="application/vnd.openxmlformats-officedocument.wordprocessingml.document",Jp="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",Yp="text/plain",Xp="text/csv",Qp="text/html",ed="application/xml",td="application/json",od="application/yaml",rd="text/markdown",nd={pdf:Hp,docx:zp,xlsx:Jp,txt:Yp,csv:Xp,html:Qp,xml:ed,json:td,yaml:od,md:rd},KO=to(nd);var ad="application/zip",id={zip:ad},UO=to(id);function sd(e){let{prefix:t,suffix:o,prefixEmptyString:r,suffixEmptyString:n}=e,a=t??"",i=o??"";function s(u){let p=u;if(a)for(;p.startsWith(a);)p=p.slice(a.length);if(i)for(;p.endsWith(i);)p=p.slice(0,p.length-i.length);return p}function c(u){let p=s(u),d;return p===""?(d="",r&&(d=`${a}${p}`),n&&(d=`${d}${i}`)):d=`${a}${p}${i}`,d}return{prefix:a,suffix:i,prefixEmptyString:r,suffixEmptyString:n,prefixSuffixString:c,cleanString:s}}var BO=sd({prefix:"-"});function cd(e){return(t,o)=>{let r=e(t),n=e(o);return r.localeCompare(n)}}var jO=cd(e=>e.label);var It={VISIT_ALL:0,VISIT_NODE_ONLY:1,VISIT_CHILDREN_ONLY:2,SKIP_ALL:3};var RM={ADD_ALL:It.VISIT_ALL,ADD_NODE_ONLY:It.VISIT_NODE_ONLY,ADD_CHILDREN_ONLY:It.VISIT_CHILDREN_ONLY,SKIP_ALL:It.SKIP_ALL};var ud=-1,or=0;function pd(e){return e?.page??ud}function rr(e){return pd(e)+1}import{BaseError as Ta}from"make-error";var Y=class extends Ta{constructor(o){super(`Fetch request failed to build due to an unexpected error: ${typeof o=="object"?o.message:o}`);this.error=o}};function xa(e){return(t,o)=>dd(e(t,o))}var qe=class extends Ta{constructor(o){super(`Fetch response was a non-ok status code (${o.status}): ${o.statusText}`);this.response=o}};function dd(e){return e.then(t=>{if(!t.ok)throw new qe(t);return t})}import{BaseError as wP}from"make-error";function Ra(e){return(t,o)=>{let r,n=o?.timeout??t.timeout;if(!o?.signal&&n){let i=new AbortController;r=i,o={...o,signal:i.signal}}let a=e(t,o);if(n){let i=setTimeout(()=>{r?.abort()},n);a=a.finally(()=>{clearTimeout(i)})}return a}}function Fa(e){let{makeFetch:t,makeRequest:o,baseRequest:r}=e;return{fetchRequestFactory:n=>Sa({makeRequest:o,baseRequest:r,...n}),makeFetch:(n={})=>md({makeRequest:o,makeFetch:t,baseRequest:r,...n}),makeRequest:e.makeRequest}}var ld=(e,t)=>t(e);function md(e){let{makeFetch:t=fetch,fetchHandler:o=ld,useTimeout:r,requireOkResponse:n,mapResponse:a}=e,i=t;r&&(i=Ra(i)),n&&(i=xa(i));let s=Sa(e);return async(c,u)=>{let p=await s(c,u),d=o(p,i);return a&&(d=a(d)),d}}var yd=(e,t)=>new Request(e,t);function Sa(e){let{makeRequest:t=yd,baseUrl:o,baseRequest:r,timeout:n,requestInitFactory:a,useBaseUrlForConfiguredFetchRequests:i=!1,forceBaseUrlForWebsiteUrlWithPrefix:s=i}=e,c=o?new URL(zn(o)):void 0,u=c?y=>{let h,T=y.toString();if(!s&&er(T))h=new URL(T);else{let R=c.origin+Hn("/"+c.pathname+"/"+y);h=new URL(R,c)}return h}:void 0;async function p(y){let h=ca(y)?await y:y;return ba(h)?h:t(h)}let d=u?async y=>{let h,T,R;if(typeof y=="string"?h=y:ba(y)?i?(h=y.url,T=y):R=y:R=await t(y),!R){let S=u(h);R=await t(S.href,T)}return R}:p,g;if(r!=null||n!=null){let y=me(r);async function h(){let R=await y();return n?{...R,timeout:n}:R}async function T(R,S){let M=await h(),v=hd(M,await S),U=v.timeout===void 0?R.timeout:v.timeout;return{...v,timeout:U}}a?g=(R,S)=>a(R,T(R,S)):g=(R,S)=>T(R,S)}else a?g=a:g=(y,h)=>h;return async(y,h)=>{try{let T=await d(y);h=await g(T,h);let R=await t(T,h);return R.timeout=n,R}catch(T){throw T instanceof Y?T:new Y(T)}}}function hd(e,t){let o;if(t){let r=fd([e.headers,t.headers]);o={...e,...t,headers:r}}else o=e;return o}function fd(e){let t=Uo();return N(e).forEach(o=>{let r=gd(o),n=new Set;r.forEach(([a,i])=>{n.has(a)||(t.delete(a),n.add(a)),i&&t.add(a,i)})}),t.tuples()}function gd(e){let t=[];return Array.isArray(e)?t=e:typeof e.forEach=="function"?e.forEach((o,r)=>{t.push([r,o])}):typeof e=="object"&&(t=Object.entries(e)),t}function ba(e){return!!e.url}import{safeParse as Td}from"fast-content-type-parse";function oo(e){let t=e.headers.get("content-type"),o=Td(t??""),r=o.type===""?void 0:o;return{response:e,rawContentType:t,contentType:r,mimeType:r?.type}}function Ca(e){let{updateWithResponse:t,maxRetries:o}=e,r=o??1,n=e.rateLimiter,a=async(i,s)=>{async function c(u){await n.waitForRateLimit();let p,d;try{p=await s(i.clone())}catch(y){d=y,p=d.response}if(await t(p,d)&&u<r)p=await c(u+1);else if(d!=null)throw d;return p}return c(0)};return a._rateLimiter=n,a}var nr=class extends Y{constructor(o){super("There was no next page for this.");this.page=o}},ar=class extends Y{constructor(o,r){super(`The limit of ${r} for the number of pages to read was reached.`);this.page=o;this.limit=r}},xd=100;function $e(e){let{fetch:t,readFetchPageResultInfo:o,buildInputForNextPage:r,defaultMaxPage:n,defaultMaxItemsPerPage:a}=e;return(i,s)=>{let{maxPage:c=n,maxItemsPerPage:u}=s??{},p=u??a,d=c===null?Number.MAX_SAFE_INTEGER:c??xd;function g(h,T=void 0){return async()=>{let R=await t(h),{cursor:S,nextPageCursor:M,hasNext:v}=await o(R),U=S??T?.cursor,I=v!==!1,D=T?T.page+1:or,P=D>=d,ge={input:h,result:R,page:D,previous:T,hasNext:I,isAtMaxPage:P,cursor:U,nextPageCursor:M,fetchNext:Be(async()=>{if(P)throw new ar(ge,d);let Vt=I?await r(ge,h,{maxPage:d,maxItemsPerPage:p}):void 0;if(!Vt)throw new nr(ge);return g({...h,...Vt},ge)()})};return ge}}return{input:i,fetchNext:Be(()=>g(i)())}}}function x(e,t){let{omitKeys:o,filterEmptyValues:r}=t??{},n=Array.isArray(e)?zt(e):e,a=r??!0?Kn(n??{}):n,i=new URLSearchParams(a);return o!=null&&q(o,s=>i.delete(s),!1),i}function ir(e){let t;if(typeof e=="string")t=e;else if(Rd(e))t=e.href;else{let o=ir(e.url);if(e.queryParams){let r=Sd(e.queryParams);ht(r)?t=o:t=Yn(o+`?${r.toString()}`)}else t=o}return t}function Rd(e){return typeof e=="object"&&e instanceof URL}function bd(e){return typeof e=="object"&&e instanceof URLSearchParams}function Fd(e){let t=[];return xe(e,o=>{let[r,n]=o;if(r!=null&&n!=null){let a=String(r);q(n,i=>{i!=null&&t.push([a,String(i)])})}}),t}function Sd(e){let t;return bd(e)?t=e:typeof e=="string"?t=new URLSearchParams(e):de(e)?t=new URLSearchParams(Fd(e)):t=Cd(e),t}function Cd(e){let t=[];return We(e,{forEach:o=>{let[r,n]=o,a=String(r);n!=null&&q(n,i=>{t.push([a,String(i)])})}}),new URLSearchParams(t)}var sr=class extends Error{constructor(o){super("Failed to parse the JSON body.");this.response=o}};function Id(e){return e!=null?typeof e=="string"?e:JSON.stringify(e):void 0}var Od=e=>{throw new sr(e)},te=e=>null;function oe(e,t){let o;typeof t=="function"?o={handleFetchJsonParseErrorFunction:t}:o=t??{},o={...o,handleFetchJsonParseErrorFunction:o.handleFetchJsonParseErrorFunction??Od};let{handleFetchJsonParseErrorFunction:r,interceptJsonResponse:n}=o,a=Ia(o);return(i,s,c)=>{let u=ir(i),p=a(s,c),d=typeof s=="object"?s.interceptResponse:void 0;return e(u,p).then(y=>{let h=y.json().catch(r),T=n?h.then(R=>n(R,y)):h;return d?T.then(R=>d(R,y)):T})}}function Ia(e={}){let{defaultMethod:t="GET",mapFetchJsonInput:o=Re()}=e;return(r=t,n)=>{let a;return typeof r=="string"?a={method:r,body:n}:a=r,a=o(a),{...a,method:a.method,body:Id(a.body)}}}var cA=Ia();var re=Fa({makeFetch:fetch,makeRequest:(e,t)=>new Request(e,t)});function He(){return{data:[],info:{page:1,per_page:100,count:0,more_records:!1}}}function K(e,t){return $e({...t,fetch:e,readFetchPageResultInfo:function(o){return{hasNext:o.info?.more_records??!1}},buildInputForNextPage:function(o,r,n){return{...r,page:rr(o),per_page:n.maxItemsPerPage??r.per_page}}})}function ro(e){switch(e){case"sandbox":return"https://recruitsandbox.zoho.com/recruit";case"production":return"https://recruit.zoho.com/recruit";default:return e}}var ze="Candidates",Oa="Job_Openings",no="Notes",Ma="Emails",Ot="Attachments";function ao(e){let t;if(e!=null)switch(typeof e){case"string":t=e;break;case"object":{let o;Array.isArray(e)?o={and:[e]}:o=e,t=io(o);break}default:break}return t}function io(e){function t(i){let s;return typeof i=="object"?Array.isArray(i)?s=i.map(cr):i&&(s=io(i)):s=i,s}function o(i,s){return i.length>1?`(${i.join(s)})`:i[0]}function r(i,s){let c=N(i.map(t)).flatMap(f);return o(c,s)}let n=e.or?r(e.or,"or"):void 0,a=n;return e.and&&(a=r([r(e.and,"and"),n],"and")),a}var Pa=Qo({escapeTargets:["(",")",","],escapeCharacter:e=>`\\\\${e}`});function cr(e){let t=Pa(e.value);return`(${e.field}:${e.filter}:${t})`}var Aa=ao;import{BaseError as Kd}from"make-error";import{BaseError as Ad}from"make-error";var Ed="__internal_data_array_blank_error";function kd(e){return Array.isArray(e?.data)}var Ye="success";function X(e){let t=typeof e,o;return t==="object"?o=e:o={code:e,message:""},o}var Fe=class extends Ad{constructor(o){super(o.message);this.error=o}get code(){return this.error.code}},j=class extends Fe{constructor(o,r,n){super(o);this.data=o;this.errorResponseData=r;this.responseError=n}},Je=class extends j{constructor(t,o){super({code:Ed,message:"Check data for individual errors."},t,o)}get errorDataArray(){return this.errorResponseData.data}};function ne(e,t){let{logDataArrayErrors:o=!1}=t??{};return r=>{r instanceof Je&&!o||(r instanceof j?console.log(`${e}Error(${r.responseError.response.status}): `,{error:r,errorData:r.data}):r instanceof Fe?console.log(`${e}Error(code:${r.code}): `,{error:r}):console.log(`${e}Error(name:${r.name}): `,{error:r}))}}function ae(e,t){return(o,r=t,n)=>async(a,i)=>{try{return await o(a,i)}catch(s){if(s instanceof qe){let c=await e(s);if(c)throw r(c),n?.(c),c}throw s}}}function ie(e){return(t,o)=>{if(t?.error!=null){let n=new qe(o),a=e(t,n);if(a)throw a}return t}}var Zd="INTERNAL_ERROR",Dd="INVALID_TOKEN",$=class extends j{},Ea="FAILURE",ur=class extends j{},Ld="4834",Mt=class extends j{},vd="INVALID_QUERY",pr=class extends j{get details(){return this.error.details}},so="MANDATORY_NOT_FOUND",Se="DUPLICATE_DATA",co="INVALID_DATA",Nd="TOO_MANY_REQUESTS",ka=429,_d="X-RATELIMIT-LIMIT",wd="X-RATELIMIT-REMAINING",Vd="X-RATELIMIT-RESET",Za=100,Da=ye;function dr(e){let t=e.get(_d),o=e.get(wd),r=e.get(Vd),n=null;if(t!=null&&o!=null&&r!=null){let a=Number(t),i=Number(o),s=Number(r),c=new Date(s);n={limit:a,remaining:i,reset:s,resetAt:c}}return n}var Pt=class extends j{get headerDetails(){return dr(this.responseError.response.headers)}};function se(e,t){let o;if(kd(e))o=new Je(e,t);else{let r=he(e,t);if(r){let n=X(r);switch(n.code){case Zd:o=new ur(n,e,t);break;case Dd:o=new $(n,e,t);break;case Ld:o=new Mt(n,e,t);break;case vd:o=new pr(n,e,t);break;case Nd:o=new Pt(n,e,t);break;default:o=new j(n,e,t);break}}}return o}function he(e,t){return e.error??e.data?.[0]??(t.response.ok?void 0:e)}var La="ALREADY_ASSOCIATED",lr=class extends Kd{constructor(o,r){super("There was no content or matching records for the content. It may not exist.");this.moduleName=o;this.recordId=r}},Xe=class extends Fe{},mr=class extends Xe{},yr=class extends Xe{},uo=class extends Xe{get invalidFieldDetails(){return this.error.details}},hr=class extends uo{};function va(e){let t;switch(e.code){case co:{let o=new uo(e);o.invalidFieldDetails.id?t=new hr(e):t=o;break}case so:t=new mr(e);break;case Se:t=new yr(e);break;default:t=new Xe(e);break}return t}function Na(e,t){return o=>{if(o?.data?.length)return o;throw new lr(e,t)}}var Ud=ne("ZohoRecruit");async function Wd(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=_a(t,e)),o}function _a(e,t){let o,r=he(e,t);if(r)switch(X(r).code){default:o=se(e,t);break}return o}var wa=ie(_a),Va=ae(Wd,Ud);import{BaseError as Bd}from"make-error";function gr(e,t,o){return(({data:r,module:n})=>e.fetchJson(`/v2/${n}${t}`,w(o,{data:f(r)})).then(a=>{let i=Array.isArray(r),s=ce(f(r),a.data),c;if(i)c=s;else{let{successItems:u,errorItems:p}=s;if(p[0]!=null)throw va(p[0].result);c=u[0].result.details}return c}))}function Ka(e){return gr(e,"","POST")}function Ua(e){return gr(e,"/upsert","POST")}function Wa(e){return gr(e,"","PUT")}function Ba(e){return({ids:t,module:o,wf_trigger:r})=>e.fetchJson(`/v2/${o}?${x({ids:t,wf_trigger:r})}`,w("DELETE")).then(Gd)}function Ga(e){return t=>e.fetchJson(`/v2/${t.module}/${t.id}`,w("GET")).then(Na(t.module)).then(o=>o.data[0])}function ja(e){return(t=>e.fetchJson(`/v2/${t.module}?${Qa(t).toString()}`,w("GET")))}function Tr(e){function t(o){let r={...o};if(delete r.criteria,o.criteria!=null){let n=Aa(o.criteria);r.criteria=n}if(!r.word&&!o.criteria&&!o.email&&!o.phone)throw new Error("At least one of word, criteria, email, or phone must be provided");return Qa(r)}return(o=>e.fetchJson(`/v2/${o.module}/search?${t(o).toString()}`,w("GET")).then(r=>r??{data:[],info:{more_records:!1}}))}function qa(e){return K(Tr(e))}function Qe(e){return t=>{let{targetModule:o,returnEmptyRecordsInsteadOfNull:r=!0}=t;return n=>e.fetchJson(`/v2/${n.module}/${n.id}/${o}?${br(n,n.filter).toString()}`,w("GET")).then(a=>a??(r!==!1?He():a))}}function xr(e){return Qe(e)({targetModule:Ma})}function $a(e){return K(xr(e))}function Rr(e){return Qe(e)({targetModule:Ot})}function Ha(e){return K(Rr(e))}var QA=20*1024*1024;function za(e){return t=>{let{attachmentCategoryId:o,attachmentCategoryName:r,file:n,attachmentUrl:a}=t,i={attachments_category_id:E(o),attachments_category:E(r)};if(!i.attachments_category_id?.length&&!i.attachments_category?.length)throw new Error("attachmentCategoryId or attachmentCategoryName must be provided and not empty.");let s=`/v2/${t.module}/${t.id}/${Ot}?${x(i).toString()}`,c;if(n!=null){let u=new FormData;u.append("file",n),c=e.fetch(s,{method:"POST",headers:{"Content-Type":""},body:u})}else if(a){let u=`${s}&${x({attachment_url:a}).toString()}`;c=e.fetch(u,{method:"POST"})}else throw new Error("file or attachmentUrl must be provided.");return c}}function Ja(e){return t=>e.fetch(`/v2/${t.module}/${t.id}/${Ot}/${t.attachment_id}`,{method:"GET"}).then(oo)}function Ya(e){return t=>e.fetch(`/v2/${t.module}/${t.id}/${Ot}/${t.attachment_id}`,{method:"DELETE"})}var fr=class extends Bd{constructor(o){super(`An error occured during the execution of the function. Code: ${o.code}, Message: ${o.message}`);this.error=o}};function Xa(e){return t=>{let r=x(t.params).toString(),n=!!t.apiKey,a=(n?`auth_type=apikey&zapikey=${t.apiKey}`:"auth_type=oauth")+(r?`&${r}`:""),i=`/v2/functions/${t.functionName}/actions/execute?${a}`,c=`${n&&t.apiUrl!=null?ro(t.apiUrl):""}${i}`;return e.fetchJson(c,w("POST")).then(u=>{if(u.code!=="success")throw new fr(u);return u.details})}}function Qa(...e){return x(e,{omitKeys:"module"})}function br(...e){return x(e,{omitKeys:["id","module"]})}function w(e,t){return{method:e,body:t??void 0}}function Gd(e){let{data:t}=e,o=[],r=[];return t.forEach(a=>{a.status===Ye?o.push(a):r.push(a)}),{...e,successItems:o,errorItems:r}}function ce(e,t){let o=[],r=[];return e.forEach((a,i)=>{let s=t[i];s.status===Ye?o.push({input:a,result:s}):r.push({input:a,result:s})}),{successItems:o,errorItems:r}}function ei(e){return t=>e.fetchJson(`/v2/${ze}/actions/associate`,w("PUT",{data:f(t)})).then(o=>{let r=o.data.map(()=>t),n=ce(r,o.data),{included:a,excluded:i}=be(n.errorItems,s=>s.result.code===Ea&&s.result.details.error[0].code===La);return{...n,errorItems:i,alreadyAssociatedErrorItems:a,allErrorItems:n.errorItems}})}function ti(e){return t=>e.fetchJson(`/v2/${t.module}/${t.id}/associate?${br(t).toString()}`,w("GET")).then(o=>o??He())}function Fr(e){let t=ti(e);return o=>t({...o,module:ze})}function oi(e){return K(Fr(e))}function Sr(e,t=Oa){let o=ti(e);return r=>o({...r,module:t})}function ri(e){return K(Sr(e))}function Cr(e){return t=>e.fetchJson(`/v2/${no}`,w("POST",{data:t.data})).then(o=>ce(f(t.data),o.data))}function ni(e){return t=>e.fetchJson(`/v2/${no}?${x({ids:t.ids})}`,w("DELETE")).then(o=>ce(f(t.ids),o.data))}function Ir(e){return Qe(e)({targetModule:no})}function ai(e){return K(Ir(e))}function ii(e){let t=Cr(e);return o=>{let{module:r,id:n,notes:a}=o,i={data:f(a).map(s=>({...s,se_module:r,Parent_Id:n}))};return t(i)}}function ui(e){return t=>e.fetchJson(`/v2/settings/tags?${x({module:t.module})}`,w("POST",{tags:f(t.tags)})).then(o=>{let r=ce(f(t.tags),o.tags),{included:n,excluded:a}=be(r.errorItems,i=>i.result.code===Se);return{...r,errorItems:a,duplicateErrorItems:n,allErrorItems:r.errorItems}})}function pi(e){return t=>e.fetchJson(`/v2/settings/tags?${x({module:t.module,my_tags:t.my_tags})}`,w("GET")).then(o=>({...o,data:o.tags}))}var si=100;function di(e){return t=>{if(Array.isArray(t.ids)&&t.ids.length>si)throw new Error(`Cannot add tags to more than ${si} records at once.`);return e.fetchJson(`/v2/${ze}/actions/add_tags?${x({tag_names:t.tag_names,ids:t.ids})}`,w("POST")).then(o=>{let r=o.data.map(()=>t);return ce(r,o.data)})}}var ci=100;function li(e){return t=>{if(Array.isArray(t.ids)&&t.ids.length>ci)throw new Error(`Cannot remove tags from more than ${ci} records at once.`);return e.fetchJson(`/v2/${ze}/actions/remove_tags?${x({tag_names:t.tag_names,ids:t.ids})}`,w("POST")).then(o=>{let r=o.data.map(()=>t);return ce(r,o.data)})}}var jd="invalid_code",qd="invalid_client",Or=class extends Y{constructor(o){super(`ZohoAccountsAccessTokenError: ${o}`);this.errorCode=o}},et=class extends Y{constructor(o){super(`Failed to retrieve proper authentication for the API call. Reason: ${o}`);this.reason=o}},$d=ne("ZohoAccounts");async function Hd(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=mi(t,e)),o}function mi(e,t){let o,r=e.error;if(r){let n=X(r);switch(n.code){case jd:case qd:o=new Or(n.code);break;default:o=se(e,t);break}}return o}var yi=ie(mi),hi=ae(Hd,$d);function Ce(e){return async()=>{let t=await e();if(!t.accessToken)throw new et;return t.accessToken}}var zd=e=>{let t="limit"in e?e.limit:void 0,o="resetAt"in e?e.resetAt:void 0,r=t!=null?" The limit is "+String(t)+" requests per reset period.":"",n=o!=null?" Will be reset at "+String(o)+".":"";console.warn("zohoRateLimitedFetchHandler(): Too many requests made."+r+n)};function Mr(e){let{readRateLimitDetails:t}=e,o=e.onTooManyRequests!==!1?e.onTooManyRequests??zd:void 0,r=e.maxRateLimit??Za,n=e.resetPeriod??Da;function a(c,u){return{limit:c,startLimitAt:Math.ceil(c/10),cooldownRate:1.2*(c/(n/_)),exponentRate:1.08,maxWaitTime:_*10,resetPeriod:n,resetAt:u}}let i=a(r),s=da(i);return Ca({rateLimiter:s,maxRetries:e.maxRetries,updateWithResponse:function(c,u){let p=t(c.headers),d=!1,g=!1;if(p){let{remaining:y,limit:h,resetAt:T}=p;if(h!=null&&h!==r){let R=a(h,T??void 0);s.setConfig(R,!1)}if(s.setRemainingLimit(y),T&&s.setNextResetAt(T),g=!0,c.status===ka){d=!0;try{o?.(p,c,u)}catch{}}}return s.setEnabled(g),d}})}function Ie(e){return Mr({...e,readRateLimitDetails:Jd})}function Jd(e){let t=dr(e),o;return t&&(o={remaining:t.remaining,limit:t.limit,resetAt:t.resetAt}),o}function fi(e){let{accountsContext:t}=e,o=Ce(t.loadAccessToken),r=Ie(e.rateLimiterConfig),{logZohoServerErrorFunction:n,fetchFactory:a=i=>re.makeFetch({baseUrl:i.apiUrl,baseRequest:async()=>({headers:{"Content-Type":"application/json",Authorization:`Bearer ${await o()}`}}),fetchHandler:r,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return i=>{if(!i.apiUrl)throw new Error("ZohoConfig missing api url.");let s=ro(i.apiUrl),c=a({apiUrl:s}),u=Va(c,n,y=>{y instanceof $&&t.loadAccessToken.resetAccessToken()}),p=oe(u,{interceptJsonResponse:wa,handleFetchJsonParseErrorFunction:te});return{recruitContext:{fetch:u,fetchJson:p,accessTokenStringFactory:o,config:{...i,apiUrl:s},zohoRateLimiter:r._rateLimiter}}}}function po(e){switch(e){case"sandbox":return"https://crmsandbox.zoho.com/crm";case"production":return"https://www.zohoapis.com/crm";default:return e}}var lo="Notes",gi="Emails",At="Attachments";var Ti=ao;import{BaseError as Yd}from"make-error";var Pr=class extends Yd{constructor(o,r){super("There was no content or matching records for the content. It may not exist.");this.moduleName=o;this.recordId=r}},tt=class extends Fe{},Ar=class extends tt{},Er=class extends tt{},mo=class extends tt{get invalidFieldDetails(){return this.error.details}},kr=class extends mo{};function xi(e){let t;switch(e.code){case co:{let o=new mo(e);o.invalidFieldDetails.api_name==="id"?t=new kr(e):t=o;break}case so:t=new Ar(e);break;case Se:t=new Er(e);break;default:t=new tt(e);break}return t}function Ri(e,t){return o=>{if(o?.data?.length)return o;throw new Pr(e,t)}}var Xd=ne("ZohoCrm",{logDataArrayErrors:!1});async function Qd(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=bi(t,e)),o}function bi(e,t){let o,r=he(e,t);if(r)switch(X(r).code){default:o=se(e,t);break}return o}var Fi=ie(bi),Si=ae(Qd,Xd);import{BaseError as el}from"make-error";function Dr(e,t,o){return(({data:r,module:n})=>e.fetchJson(`/v8/${n}${t}`,W(o,{data:f(r)})).catch(wi).then(a=>{let i=Array.isArray(r),s=Oe(f(r),a.data),c;if(i)c=s;else{let{successItems:u,errorItems:p}=s;if(p[0]!=null)throw xi(p[0].result);c=u[0].result.details}return c}))}function Ci(e){return Dr(e,"","POST")}function Ii(e){return Dr(e,"/upsert","POST")}function Oi(e){return Dr(e,"","PUT")}function Mi(e){return({ids:t,module:o,wf_trigger:r})=>e.fetchJson(`/v8/${o}?${x({ids:t,wf_trigger:r})}`,W("DELETE")).catch(wi).then(ol)}function Pi(e){return t=>e.fetchJson(`/v8/${t.module}/${t.id}`,W("GET")).then(Ri(t.module)).then(o=>o.data[0])}function Ai(e){return(t=>e.fetchJson(`/v8/${t.module}?${_i(t).toString()}`,W("GET")))}function Lr(e){function t(o){let r={...o};if(delete r.criteria,o.criteria!=null){let n=Ti(o.criteria);r.criteria=n}if(!r.word&&!o.cvid&&!o.criteria&&!o.email&&!o.phone)throw new Error("At least one of word, cvid, criteria, email, or phone must be provided");return _i(r)}return(o=>e.fetchJson(`/v8/${o.module}/search?${t(o).toString()}`,W("GET")).then(r=>r??{data:[],info:{more_records:!1}}))}function Ei(e){return K(Lr(e))}function ot(e){return t=>{let{targetModule:o,returnEmptyRecordsInsteadOfNull:r=!0}=t;return n=>e.fetchJson(`/v8/${n.module}/${n.id}/${o}?${tl(n,n.filter).toString()}`,W("GET")).then(a=>a??(r!==!1?He():a))}}function vr(e){let t=ot(e)({targetModule:gi});return o=>t(o).then(r=>{let n=r.data??r.Emails;return{...r,data:n}})}function ki(e){return K(vr(e))}function Nr(e){return ot(e)({targetModule:At})}function Zi(e){return K(Nr(e))}var mk=20*1024*1024;function Di(e){return t=>{let{attachmentCategoryId:o,attachmentCategoryName:r,file:n}=t,a={attachments_category_id:E(o),attachments_category:E(r)};if(!a.attachments_category_id?.length&&!a.attachments_category?.length)throw new Error("attachmentCategoryId or attachmentCategoryName must be provided and not empty.");let i=`/v8/${t.module}/${t.id}/${At}?${x(a).toString()}`,s=new FormData;return s.append("file",n),e.fetch(i,{method:"POST",headers:{"Content-Type":""},body:s})}}function Li(e){return t=>e.fetch(`/v8/${t.module}/${t.id}/${At}/${t.attachment_id}`,{method:"GET"}).then(oo)}function vi(e){return t=>e.fetch(`/v8/${t.module}/${t.id}/${At}/${t.attachment_id}`,{method:"DELETE"})}var Zr=class extends el{constructor(o){super(`An error occured during the execution of the function. Code: ${o.code}, Message: ${o.message}`);this.error=o}};function Ni(e){return t=>{let r=x(t.params).toString(),n=!!t.apiKey,a=(n?`auth_type=apikey&zapikey=${t.apiKey}`:"auth_type=oauth")+(r?`&${r}`:""),i=`/v8/functions/${t.functionName}/actions/execute?${a}`,c=`${n&&t.apiUrl!=null?po(t.apiUrl):""}${i}`;return e.fetchJson(c,W("POST")).then(u=>{if(u.code!=="success")throw new Zr(u);return u.details})}}function _i(...e){return x(e,{omitKeys:"module"})}function tl(...e){return x(e,{omitKeys:["id","module"]})}function W(e,t){return{method:e,body:t??void 0}}function wi(e){let t;if(e instanceof Je)t={data:e.errorDataArray};else throw e;return t}function ol(e){let{data:t}=e,o=[],r=[];return t.forEach(a=>{a.status===Ye?o.push(a):r.push(a)}),{...e,successItems:o,errorItems:r}}function Oe(e,t){let o=[],r=[];return e.forEach((a,i)=>{let s=t[i];s.status===Ye?o.push({input:a,result:s}):r.push({input:a,result:s})}),{successItems:o,errorItems:r}}function _r(e){return t=>e.fetchJson(`/v2/${lo}`,W("POST",{data:t.data})).then(o=>Oe(f(t.data),o.data))}function Vi(e){return t=>e.fetchJson(`/v2/${lo}?${x({ids:t.ids})}`,W("DELETE")).then(o=>Oe(f(t.ids),o.data))}function wr(e){return ot(e)({targetModule:lo})}function Ki(e){return K(wr(e))}function Ui(e){let t=_r(e);return o=>{let{module:r,id:n,notes:a}=o,i={data:f(a).map(s=>({...s,se_module:r,Parent_Id:n}))};return t(i)}}function Bi(e){return t=>e.fetchJson(`/v8/settings/tags?${x({module:t.module})}`,W("POST",{tags:f(t.tags)})).catch(o=>{let r;if(o instanceof j){let n=o.data?.tags;Array.isArray(n)&&(r={tags:n})}if(!r)throw o;return r}).then(o=>{let r=Oe(f(t.tags),o.tags),{included:n,excluded:a}=be(r.errorItems,i=>i.result.code===Se);return{...r,errorItems:a,duplicateErrorItems:n,allErrorItems:r.errorItems}})}function Gi(e){return t=>e.fetchJson(`/v8/settings/tags/${t.id}`,W("DELETE")).then(o=>o.tags)}function ji(e){return t=>e.fetchJson(`/v8/settings/tags?${x({module:t.module,my_tags:t.my_tags})}`,W("GET")).then(o=>({...o,data:o.tags}))}var Wi=100;function qi(e){return t=>e.fetchJson(`/v8/${t.module}/actions/add_tags`,W("POST",$i(t))).then(o=>{let r=o.data.map(()=>t);return Oe(r,o.data)})}function $i(e){if(Array.isArray(e.ids)&&e.ids.length>Wi)throw new Error(`Cannot add/remove tags from more than ${Wi} records at once.`);let t=[...f(e.tags)],o=new Set(t.map(r=>r.name));return e.tag_names&&f(e.tag_names).forEach(r=>{o.has(r)||(t.push({name:r}),o.add(r))}),{tags:t,ids:f(e.ids)}}function Hi(e){return t=>e.fetchJson(`/v8/${t.module}/actions/remove_tags`,W("POST",$i(t))).then(o=>{let r=o.data.map(()=>t);return Oe(r,o.data)})}function zi(e){let{accountsContext:t}=e,o=Ce(t.loadAccessToken),r=Ie(e.rateLimiterConfig),{logZohoServerErrorFunction:n,fetchFactory:a=i=>re.makeFetch({baseUrl:i.apiUrl,baseRequest:async()=>({headers:{"Content-Type":"application/json",Authorization:`Bearer ${await o()}`}}),fetchHandler:r,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return i=>{if(!i.apiUrl)throw new Error("ZohoConfig missing api url.");let s=po(i.apiUrl),c=a({apiUrl:s}),u=Si(c,n,y=>{y instanceof $&&t.loadAccessToken.resetAccessToken()}),p=oe(u,{interceptJsonResponse:Fi,handleFetchJsonParseErrorFunction:te});return{crmContext:{fetch:u,fetchJson:p,accessTokenStringFactory:o,config:{...i,apiUrl:s},zohoRateLimiter:r._rateLimiter}}}}function Ji(e,t){return $e({...t,fetch:e,readFetchPageResultInfo:function(o){return{hasNext:o.page_context?.has_more_rows??!1}},buildInputForNextPage:function(o,r,n){let i=o.result?.page_context,s=n.maxItemsPerPage??r.row_count??i?.row_count??20,c=(i?.start_index??r.start_index??1)+s;return{...r,start_index:c,row_count:s}}})}function ke(e,t){return{method:e,body:t??void 0}}function Yi(e){return({requestId:t})=>e.fetchJson(`/requests/${t}`,ke("GET"))}function Vr(e){return t=>{let{search_columns:o,...r}=t,n={page_context:{...r,...o?{search_columns:o}:{}}};return e.fetchJson({url:"/requests",queryParams:{data:JSON.stringify(n)}},ke("GET"))}}function Xi(e){let t=Vr(e);return Ji(t)}function Qi(e){return({requestId:t})=>e.fetchJson(`/requests/${t}/fielddata`,ke("GET"))}function es(e){return()=>e.fetchJson("/fieldtypes",ke("GET"))}function ts(e){return({requestId:t,...o})=>{let n=x(o).toString(),a=n?`?${n}`:"",i=`/requests/${t}/pdf${a}`;return e.fetch(i,{method:"GET"})}}function os(e){return({requestId:t})=>e.fetch(`/requests/${t}/completioncertificate`,{method:"GET"})}function rs(e){return({requestData:t,file:o})=>{let r=new FormData;return r.append("data",JSON.stringify({requests:t})),r.append("file",o),e.fetch("/requests",{method:"POST",headers:{"Content-Type":""},body:r}).then(n=>n.json())}}function ns(e){return({requestId:t,data:o})=>e.fetchJson(`/requests/${t}`,ke("PUT",{requests:o}))}function as(e){return({requestId:t,data:o})=>{let r=o?{requests:o}:void 0;return e.fetchJson(`/requests/${t}/submit`,ke("POST",r))}}function is(e){return({requestId:t,expire_by:o})=>e.fetchJson(`/requests/${t}/extend`,ke("PUT",{expire_by:o}))}function ss(e){return({requestId:t,recall_inprogress:o,reason:r})=>{let n={};o!=null&&(n.recall_inprogress=String(o)),r!=null&&(n.reason=r);let a=x(n),i=a.toString().length>0;return e.fetchJson(`/requests/${t}/delete`,{method:"PUT",...i?{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:a.toString()}:{}})}}function cs(e){switch(e){case"sandbox":return"https://signsandbox.zoho.com/api/v1";case"production":return"https://sign.zoho.com/api/v1";default:return e}}var rl=ne("ZohoSign",{logDataArrayErrors:!1});async function nl(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=us(t,e)),o}function us(e,t){let o,r=he(e,t);if(r)switch(X(r).code){default:o=se(e,t);break}return o}var ps=ie(us),ds=ae(nl,rl);function ls(e){let{accountsContext:t}=e,o=Ce(t.loadAccessToken),r=Ie(e.rateLimiterConfig),{logZohoServerErrorFunction:n,fetchFactory:a=i=>re.makeFetch({baseUrl:i.apiUrl,baseRequest:async()=>({headers:{"Content-Type":"application/json",Authorization:`Bearer ${await o()}`}}),fetchHandler:r,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return i=>{if(!i.apiUrl)throw new Error("ZohoConfig missing api url.");let s=cs(i.apiUrl),c=a({apiUrl:s}),u=ds(c,n,y=>{y instanceof $&&t.loadAccessToken.resetAccessToken()}),p=oe(u,{interceptJsonResponse:ps,handleFetchJsonParseErrorFunction:te});return{signContext:{fetch:u,fetchJson:p,accessTokenStringFactory:o,config:{...i,apiUrl:s},zohoRateLimiter:r._rateLimiter}}}}function ms(e){let t;switch(e){case"sandbox":case"production":t="https://desk.zoho.com/api/v1";break;default:t=e;break}return t}var al=ne("ZohoDesk",{logDataArrayErrors:!1});async function il(e){let t=await e.response.json().catch(()=>{}),o;return t&&(o=ys(t,e)),o}function ys(e,t){let o,r=he(e,t);if(r)switch(X(r).code){default:o=se(e,t);break}return o}var hs=ie(ys),fs=ae(il,al);var sl="X-Rate-Limit-Remaining-v3",cl="Retry-After",ul=200;function pl(e){let t=e.get(sl),o;if(t!=null){let r=Number(t),n,a=e.get(cl);if(a!=null){let i=Number(a);isNaN(i)||(n=new Date(Date.now()+i*_))}isNaN(r)||(o={remaining:r,resetAt:n})}return o}function gs(e){return Mr({maxRateLimit:ul,...e,readRateLimitDetails:pl})}function Ts(e){let{accountsContext:t}=e,o=Ce(t.loadAccessToken),r=gs(e.rateLimiterConfig),{logZohoServerErrorFunction:n,fetchFactory:a=i=>re.makeFetch({baseUrl:i.apiUrl,baseRequest:async()=>({headers:{"Content-Type":"application/json",Authorization:`Bearer ${await o()}`,orgId:i.orgId}}),fetchHandler:r,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return i=>{if(!i.apiUrl)throw new Error("ZohoDeskConfig missing api url.");if(!i.orgId)throw new Error("ZohoDeskConfig missing orgId.");let s=ms(i.apiUrl),c=a({apiUrl:s,orgId:i.orgId}),u=fs(c,n,y=>{y instanceof $&&t.loadAccessToken.resetAccessToken()}),p=oe(u,{interceptJsonResponse:hs,handleFetchJsonParseErrorFunction:te});return{deskContext:{fetch:u,fetchJson:p,accessTokenStringFactory:o,config:{...i,apiUrl:s},zohoRateLimiter:r._rateLimiter}}}}var xs=25;function Q(e,t){return $e({...t,fetch:e,readFetchPageResultInfo:function(o){let r=o.data?.length??0;return{hasNext:r>0&&r>=xs}},buildInputForNextPage:function(o,r,n){let a=n.maxItemsPerPage??r.limit??xs,s=(r.from??1)+a;return{...r,from:s,limit:a}}})}function Ze(e,t){return{method:e,body:t??void 0}}function rt(e,t){return x(e,{omitKeys:t})}function yo(e){let t;return e&&(t=E(f(e))),t}function Kr(e){return t=>{let{include:o,...r}=t,n=rt([{...r,include:yo(o)}]);return e.fetchJson(`/tickets?${n}`,Ze("GET")).then(a=>a??{data:[]})}}function Rs(e){return t=>{let{ticketId:o,include:r}=t,a=rt([{include:yo(r)}]).toString();return e.fetchJson(`/tickets/${o}${a?`?${a}`:""}`,Ze("GET"))}}function Ur(e){return t=>{let o=rt([t]);return e.fetchJson(`/tickets/search?${o}`,Ze("GET")).then(r=>r??{data:[]})}}function bs(e){return t=>{let{contactId:o,include:r,...n}=t,a=rt([{...n,include:yo(r)}]);return e.fetchJson(`/contacts/${o}/tickets?${a}`,Ze("GET")).then(i=>i??{data:[]})}}function Fs(e){return t=>{let{productId:o,include:r,...n}=t,a=rt([{...n,include:yo(r)}]);return e.fetchJson(`/products/${o}/tickets?${a}`,Ze("GET")).then(i=>i??{data:[]})}}function Ss(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/metrics`,Ze("GET"))}function Cs(e){return t=>{let o=rt([{agentIds:E(f(t.agentIds)),departmentId:t.departmentId}]);return e.fetchJson(`/agentsTicketsCount?${o}`,Ze("GET"))}}function Is(e){return Q(Kr(e))}function Os(e){return Q(Ur(e))}function Ms(e){return{method:e}}function Ps(e){return t=>{let o=x([t]);return e.fetchJson(`/departments?${o}`,Ms("GET")).then(r=>r??{data:[]})}}function As(e){return t=>e.fetchJson(`/departments/${t.departmentId}`,Ms("GET"))}function Wr(e){return{method:e}}function Es(e){let t;return e&&(t=E(f(e))),t}function Br(e){return t=>{let{include:o,...r}=t,n=x([{...r,include:Es(o)}]);return e.fetchJson(`/contacts?${n}`,Wr("GET")).then(a=>a??{data:[]})}}function ks(e){return t=>{let{contactId:o,include:r}=t,a=x([{include:Es(r)}]).toString();return e.fetchJson(`/contacts/${o}${a?`?${a}`:""}`,Wr("GET"))}}function Zs(e){return t=>{let o=x([{contactIds:E(f(t.contactIds))}]);return e.fetchJson(`/contacts/contactsByIds?${o}`,Wr("GET")).then(r=>r??[])}}function Ds(e){return Q(Br(e))}function Et(e,t){return{method:e,body:t??void 0}}function Ls(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/tags`,Et("GET")).then(o=>o??[])}function vs(e){return t=>{let o={tags:f(t.tags).map(r=>({name:r}))};return e.fetchJson(`/tickets/${t.ticketId}/tags`,Et("POST",o)).then(r=>r??[])}}function Ns(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/tags/${t.tagId}`,Et("DELETE"))}function _s(e){return t=>{let o=x([t]);return e.fetchJson(`/tags/search?${o}`,Et("GET")).then(r=>r??{data:[]})}}function ws(e){return t=>{let o=x([t]);return e.fetchJson(`/ticketTags?${o}`,Et("GET")).then(r=>r??{data:[]})}}function Gr(e,t){return{method:e,body:t??void 0}}function Vs(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/followers`,Gr("GET")).then(o=>o??[])}function Ks(e){return t=>{let o={ids:f(t.agentIds)};return e.fetchJson(`/tickets/${t.ticketId}/followers`,Gr("POST",o))}}function Us(e){return t=>{let o={ids:f(t.agentIds)};return e.fetchJson(`/tickets/${t.ticketId}/followers`,Gr("DELETE",o))}}function Ws(e,t){return{method:e,body:t??void 0}}function dl(e){let t;return e&&(t=E(f(e))),t}function Bs(e){return t=>{let{ticketId:o,include:r,...n}=t,a=x([{...n,include:dl(r)}]);return e.fetchJson(`/tickets/${o}/attachments?${a}`,Ws("GET")).then(i=>i??{data:[]})}}function Gs(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/attachments/${t.attachmentId}`,Ws("DELETE"))}function ho(e,t){return{method:e,body:t??void 0}}function js(e){let t;return e&&(t=E(f(e))),t}function qs(e){return t=>{let{ticketId:o,include:r,...n}=t,a=x([{...n,include:js(r)}]);return e.fetchJson(`/tickets/${o}/comments?${a}`,ho("GET")).then(i=>i??{data:[]})}}function $s(e){return t=>{let{ticketId:o,commentId:r,include:n}=t,i=x([{include:js(n)}]).toString();return e.fetchJson(`/tickets/${o}/comments/${r}${i?`?${i}`:""}`,ho("GET"))}}function Hs(e){return t=>{let{ticketId:o,...r}=t;return e.fetchJson(`/tickets/${o}/comments`,ho("POST",r))}}function zs(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/comments/${t.commentId}`,ho("DELETE"))}function kt(e,t){return{method:e,body:t??void 0}}function Js(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/timer`,kt("GET"))}function Ys(e){return t=>{let{ticketId:o,...r}=t;return e.fetchJson(`/tickets/${o}/timer`,kt("POST",r))}}function Xs(e){return t=>{let{ticketId:o,...r}=t,n=x([r]);return e.fetchJson(`/tickets/${o}/timeEntries?${n}`,kt("GET")).then(a=>a??{data:[]})}}function Qs(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/timeEntries/${t.timeEntryId}`,kt("GET"))}function ec(e){return t=>e.fetchJson(`/tickets/${t.ticketId}/timeEntries/summation`,kt("GET"))}function tc(e){return{method:e}}function oc(e){let t;return e&&(t=E(f(e))),t}function jr(e){return t=>{let{ticketId:o,include:r,...n}=t,a=x([{...n,include:oc(r)}]);return e.fetchJson(`/tickets/${o}/threads?${a}`,tc("GET")).then(i=>i??{data:[]})}}function rc(e){return t=>{let{ticketId:o,threadId:r,include:n}=t,i=x([{include:oc(n)}]).toString();return e.fetchJson(`/tickets/${o}/threads/${r}${i?`?${i}`:""}`,tc("GET"))}}function nc(e){return Q(jr(e))}function ll(e){return{method:e}}function ml(e){let t;return e&&(t=E(f(e))),t}function qr(e){return t=>{let{ticketId:o,include:r,...n}=t,a=x([{...n,include:ml(r)}]);return e.fetchJson(`/tickets/${o}/activities?${a}`,ll("GET")).then(i=>i??{data:[]})}}function ac(e){return Q(qr(e))}function fo(e){return{method:e}}function ic(e){let t;return e&&(t=E(f(e))),t}function $r(e){return t=>{let{include:o,...r}=t,n=x([{...r,include:ic(o)}]);return e.fetchJson(`/agents?${n}`,fo("GET")).then(a=>a??{data:[]})}}function sc(e){return t=>{let{agentId:o,include:r}=t,a=x([{include:ic(r)}]).toString();return e.fetchJson(`/agents/${o}${a?`?${a}`:""}`,fo("GET"))}}function cc(e){return t=>{let o=x([{agentIds:E(f(t.agentIds))}]);return e.fetchJson(`/agentsByIds?${o}`,fo("GET")).then(r=>r?.data??[])}}function uc(e){return()=>e.fetchJson("/myinfo",fo("GET"))}function pc(e){return Q($r(e))}function go(e){return t=>{let{clientId:o,clientSecret:r,refreshToken:n}=e.config,{client:a,refreshToken:i}=t??{},s=a?.clientId??o,c=a?.clientSecret??r,p=x({grant_type:"refresh_token",client_id:s,client_secret:c,refresh_token:i??n});return e.fetchJson(`/oauth/v2/token?${p}`,yl("POST"))}}function yl(e,t){return{method:e,body:t}}var hl="https://accounts.zoho.com";function dc(e){return e==="us"?hl:e}function lc(e){let t=Ie(),{logZohoServerErrorFunction:o,fetchFactory:r=n=>re.makeFetch({baseUrl:n.apiUrl,baseRequest:{headers:{"Content-Type":"application/json"}},fetchHandler:t,timeout:20*1e3,requireOkResponse:!0,useTimeout:!0})}=e;return n=>{if(n.refreshToken)if(n.clientId){if(!n.clientSecret)throw new Error("ZohoAccountsConfig missing clientSecret.")}else throw new Error("ZohoAccountsConfig missing clientId.");else throw new Error("ZohoAccountsConfig missing refreshToken.");let a=dc(n.apiUrl??"us"),i=r({apiUrl:a}),s=hi(i,o),c=oe(s,{interceptJsonResponse:yi,handleFetchJsonParseErrorFunction:te}),u=async()=>{let y=new Date().getTime(),{access_token:h,api_domain:T,scope:R,expires_in:S}=await go(d)();return{accessToken:h,apiDomain:T,expiresIn:S,expiresAt:new Date(y+S*_),scope:R}};u.resetAccessToken=async()=>n.accessTokenCache?.clearCachedToken();let p=fl({tokenRefresher:u,accessTokenCache:n.accessTokenCache}),d={fetch:s,fetchJson:c,loadAccessToken:p,config:{...n,apiUrl:a}};return{accountsContext:d}}}function fl(e){let{tokenRefresher:t,accessTokenCache:o,tokenExpirationBuffer:r}=e,n=r??ye,a=null,i=async()=>{a=null},s=async()=>{if(!a){let c=await o?.loadCachedToken();c&&(a=c)}if(a!=null&&new Date().getTime()+n>=a.expiresAt.getTime()&&(a=null),!a){try{a=await t()}catch(c){throw console.error("zohoAccountsZohoAccessTokenFactory(): Failed retrieving new token from tokenRefresher: ",c),new et("Token Refresh Failed")}try{await o?.updateCachedToken(a)}catch{}}return a};return s.resetAccessToken=i,s}function Me(e){if(!e.apiUrl)throw new Error("No Zoho API url or type specified.")}var Pe=class{zohoAccounts;factoryConfig;static assertValidConfig(t){let{zohoAccounts:o}=t;if(o)if(o.serviceAccessTokenKey)if(o.refreshToken)if(o.apiUrl){if(!o.clientId)throw new Error("ZohoAccountsServiceConfig.zohoAccounts.clientId is required")}else throw new Error("ZohoAccountsServiceConfig.zohoAccounts.apiUrl is required");else throw new Error("ZohoAccountsServiceConfig.zohoAccounts.refreshToken is required");else throw new Error("ZohoAccountsServiceConfig.zohoAccounts.serviceAccessTokenKey is required");else throw new Error("ZohoAccountsServiceConfig.zohoAccounts is required")}};import{Injectable as gl}from"@nestjs/common";import{dirname as Tl}from"node:path";import{readFile as xl,writeFile as Rl,rm as bl,mkdirSync as Fl}from"node:fs";var nt=class{};nt=O([gl()],nt);function Sl(e){console.warn(`mergeZohoAccountsAccessTokenCacheServices(): failed updating ${e.length} caches.`),e.forEach(([t,o],r)=>{console.warn(`Cache update failure ${r+1}: - ${o}`)})}function mc(e,t){let o=[...e],r=typeof t=="function"?t:t!==!1?Sl:void 0;if(o.length===0)throw new Error("mergeZohoAccountsAccessTokenCacheServices() input cannot be empty.");return{loadZohoAccessTokenCache:function(a){let i=o.map(u=>u.loadZohoAccessTokenCache(a)),s=la({promiseFactories:i.map(u=>()=>u.loadCachedToken().catch(()=>null).then(p=>{let d;return p&&!eo(p.expiresAt)&&(d=p),d})),successOnMaybe:!1,throwErrors:!1});return{loadCachedToken:function(){return s()},updateCachedToken:async function(u){return Promise.allSettled(i.map(p=>p.updateCachedToken(u).then(()=>null).catch(d=>[p,d]))).then(p=>{if(r!=null){let d=N(p.map(g=>g.value));d.length&&r(d)}})},clearCachedToken:async function(){await Promise.allSettled(i.map(u=>u.clearCachedToken()))}}}}}function yc(e,t){let o=e??{};function r(n){return{loadCachedToken:async function(){let i=o[n];return t&&console.log("retrieving access token from memory: ",{token:i,service:n}),i},updateCachedToken:async function(i){o[n]=i,t&&console.log("updating access token in memory: ",{accessToken:i,service:n})},clearCachedToken:async function(){delete o[n],t&&console.log("clearing access token in memory: ",{service:n})}}}return{loadZohoAccessTokenCache:r}}var Cl=".tmp/zoho-access-tokens.json";function hc(e=Cl,t=!0){let o=null;async function r(){return o||(await n()??{})}function n(){return new Promise(c=>{Fl(Tl(e),{recursive:!0}),xl(e,{},(u,p)=>{let d;if(!u)try{d=JSON.parse(p.toString()),We(d,{forEach:g=>{g[1]&&(g[1].expiresAt=new Date(g[1].expiresAt))}})}catch(g){console.error("Failed reading token file: ",g)}c(d)})}).then(c=>(t&&(o={...o,...c}),c))}async function a(c){return new Promise((u,p)=>{Rl(e,JSON.stringify(c),{},d=>{d?p(d):u()})})}async function i(){return new Promise((c,u)=>{bl(e,p=>{p?u(p):c()})})}function s(c){return{loadCachedToken:async function(){return(await r())[c]},updateCachedToken:async function(p){let d=await r();d&&(d[c]=p);try{await a(d)}catch(g){console.error("Failed updating access token in file: ",g)}},clearCachedToken:async function(){try{await a({})}catch(p){console.error("Failed clearing access token in file: ",p)}}}}return{loadZohoAccessTokenCache:s,readTokenFile:n,writeTokenFile:a,deleteTokenFile:i}}var V=class{constructor(t,o){this.config=t;this.cacheService=o;let r=t.zohoAccounts.accessTokenCache??o.loadZohoAccessTokenCache(t.zohoAccounts.serviceAccessTokenKey);this.zohoAccounts=lc(t.factoryConfig??{})({accessTokenCache:r,...t.zohoAccounts})}zohoAccounts;get accountsContext(){return this.zohoAccounts.accountsContext}get accessToken(){return go(this.accountsContext)}};V=O([Il(),A(0,fc(Pe)),A(1,fc(nt))],V);import{Inject as gc,Injectable as Ol}from"@nestjs/common";var Zt=class{zohoCrm;factoryConfig;static assertValidConfig(t){Me(t.zohoCrm)}};var De=class{constructor(t,o){this.config=t;this.zohoAccountsApi=o;this.zohoCrm=zi({...t.factoryConfig,accountsContext:o.accountsContext})(t.zohoCrm)}zohoCrm;get crmContext(){return this.zohoCrm.crmContext}get zohoRateLimiter(){return this.zohoCrm.crmContext.zohoRateLimiter}get insertRecord(){return Ci(this.crmContext)}get upsertRecord(){return Ii(this.crmContext)}get updateRecord(){return Oi(this.crmContext)}get deleteRecord(){return Mi(this.crmContext)}get getRecordById(){return Pi(this.crmContext)}get getRecords(){return Ai(this.crmContext)}get searchRecords(){return Lr(this.crmContext)}get searchRecordsPageFactory(){return Ei(this.crmContext)}get getRelatedRecordsFunctionFactory(){return ot(this.crmContext)}get getEmailsForRecord(){return vr(this.crmContext)}get getEmailsForRecordPageFactory(){return ki(this.crmContext)}get getAttachmentsForRecord(){return Nr(this.crmContext)}get getAttachmentsForRecordPageFactory(){return Zi(this.crmContext)}get uploadAttachmentForRecord(){return Di(this.crmContext)}get downloadAttachmentForRecord(){return Li(this.crmContext)}get deleteAttachmentFromRecord(){return vi(this.crmContext)}get createNotes(){return _r(this.crmContext)}get deleteNotes(){return Vi(this.crmContext)}get createNotesForRecord(){return Ui(this.crmContext)}get getNotesForRecord(){return wr(this.crmContext)}get getNotesForRecordPageFactory(){return Ki(this.crmContext)}get executeRestApiFunction(){return Ni(this.crmContext)}get createTagsForModule(){return Bi(this.crmContext)}get deleteTag(){return Gi(this.crmContext)}get getTagsForModule(){return ji(this.crmContext)}get addTagsToRecords(){return qi(this.crmContext)}get removeTagsFromRecords(){return Hi(this.crmContext)}};De=O([Ol(),A(0,gc(Zt)),A(1,gc(V))],De);import{ConfigModule as _L,ConfigService as wL}from"@nestjs/config";import{Inject as Tc,Injectable as Ml}from"@nestjs/common";var Dt=class{zohoRecruit;factoryConfig;static assertValidConfig(t){Me(t.zohoRecruit)}};var Le=class{constructor(t,o){this.config=t;this.zohoAccountsApi=o;this.zohoRecruit=fi({...t.factoryConfig,accountsContext:o.accountsContext})(t.zohoRecruit)}zohoRecruit;get recruitContext(){return this.zohoRecruit.recruitContext}get zohoRateLimiter(){return this.zohoRecruit.recruitContext.zohoRateLimiter}get insertRecord(){return Ka(this.recruitContext)}get upsertRecord(){return Ua(this.recruitContext)}get updateRecord(){return Wa(this.recruitContext)}get deleteRecord(){return Ba(this.recruitContext)}get getRecordById(){return Ga(this.recruitContext)}get getRecords(){return ja(this.recruitContext)}get searchRecords(){return Tr(this.recruitContext)}get searchRecordsPageFactory(){return qa(this.recruitContext)}get getRelatedRecordsFunctionFactory(){return Qe(this.recruitContext)}get getEmailsForRecord(){return xr(this.recruitContext)}get getEmailsForRecordPageFactory(){return $a(this.recruitContext)}get getAttachmentsForRecord(){return Rr(this.recruitContext)}get getAttachmentsForRecordPageFactory(){return Ha(this.recruitContext)}get uploadAttachmentForRecord(){return za(this.recruitContext)}get downloadAttachmentForRecord(){return Ja(this.recruitContext)}get deleteAttachmentFromRecord(){return Ya(this.recruitContext)}get createNotes(){return Cr(this.recruitContext)}get deleteNotes(){return ni(this.recruitContext)}get createNotesForRecord(){return ii(this.recruitContext)}get getNotesForRecord(){return Ir(this.recruitContext)}get getNotesForRecordPageFactory(){return ai(this.recruitContext)}get executeRestApiFunction(){return Xa(this.recruitContext)}get associateCandidateRecordsWithJobOpenings(){return ei(this.recruitContext)}get searchCandidateAssociatedJobOpeningRecords(){return Fr(this.recruitContext)}get searchCandidateAssociatedJobOpeningRecordsPageFactory(){return oi(this.recruitContext)}get searchJobOpeningAssociatedCandidateRecords(){return Sr(this.recruitContext)}get searchJobOpeningAssociatedCandidateRecordsPageFactory(){return ri(this.recruitContext)}get createTagsForModule(){return ui(this.recruitContext)}get getTagsForModule(){return pi(this.recruitContext)}get addTagsToRecords(){return di(this.recruitContext)}get removeTagsFromRecords(){return li(this.recruitContext)}};Le=O([Ml(),A(0,Tc(Dt)),A(1,Tc(V))],Le);import{ConfigModule as iv,ConfigService as sv}from"@nestjs/config";import{Inject as xc,Injectable as Pl}from"@nestjs/common";var Lt=class{zohoSign;factoryConfig;static assertValidConfig(t){Me(t.zohoSign)}};var vt=class{constructor(t,o){this.config=t;this.zohoAccountsApi=o;this.zohoSign=ls({...t.factoryConfig,accountsContext:o.accountsContext})(t.zohoSign)}zohoSign;get signContext(){return this.zohoSign.signContext}get zohoRateLimiter(){return this.zohoSign.signContext.zohoRateLimiter}get getDocument(){return Yi(this.signContext)}get getDocuments(){return Vr(this.signContext)}get getDocumentsPageFactory(){return Xi(this.signContext)}get getDocumentFormData(){return Qi(this.signContext)}get retrieveFieldTypes(){return es(this.signContext)}get downloadPdf(){return ts(this.signContext)}get downloadCompletionCertificate(){return os(this.signContext)}get createDocument(){return rs(this.signContext)}get updateDocument(){return ns(this.signContext)}get sendDocumentForSignature(){return as(this.signContext)}get extendDocument(){return is(this.signContext)}get deleteDocument(){return ss(this.signContext)}};vt=O([Pl(),A(0,xc(Lt)),A(1,xc(V))],vt);import{ConfigModule as Av,ConfigService as Ev}from"@nestjs/config";function Rc(e){return{...e,operationType:e.notifications.operation_type}}var bc=ya(e=>e.operationType),Fc=fa({configurerForAccessor:e=>{let t=ha(e,r=>r);return{...e,handleRequestSubmitted:t("RequestSubmitted"),handleRequestViewed:t("RequestViewed"),handleRequestSigningSuccess:t("RequestSigningSuccess"),handleRequestCompleted:t("RequestCompleted"),handleRequestRejected:t("RequestRejected"),handleRequestRecalled:t("RequestRecalled"),handleRequestForwarded:t("RequestForwarded"),handleRequestExpired:t("RequestExpired")}}});var Sc="ZOHO_SIGN_WEBHOOK_SECRET_TOKEN",ve=class{zohoSignWebhook;static assertValidConfig(t){if(!t.zohoSignWebhook.webhookSecret)throw new Error("No Zoho Sign webhook secret specified.")}};import{defer as jv,from as qv}from"rxjs";import{combineLatest as yN,filter as hN,skipWhile as fN,startWith as gN,switchMap as TN,of as xN,map as RN,delay as bN,EMPTY as FN}from"rxjs";import{switchMap as cN,of as uN,isObservable as pN}from"rxjs";import{switchMap as VN,distinctUntilChanged as KN,shareReplay as UN,map as WN,BehaviorSubject as BN,of as GN,combineLatest as jN,EMPTY as qN,skip as $N,defaultIfEmpty as HN}from"rxjs";import{distinctUntilChanged as AN,filter as EN,mergeMap as kN,isObservable as ZN}from"rxjs";import{BehaviorSubject as n_,switchMap as a_,map as i_,distinctUntilChanged as s_,shareReplay as c_,first as u_,merge as p_,finalize as d_}from"rxjs";import{map as y_}from"rxjs";import{first as S_,shareReplay as C_,firstValueFrom as I_,switchMap as O_,of as M_}from"rxjs";import{startWith as GW,map as jW,shareReplay as qW,skipWhile as $W,distinctUntilChanged as HW,filter as zW,first as JW,firstValueFrom as YW,switchMap as XW,from as QW}from"rxjs";import{exhaustMap as k_,map as Z_,scan as D_,shareReplay as L_,startWith as v_,distinctUntilChanged as N_,switchMap as __,combineLatest as w_,of as V_,first as K_}from"rxjs";import{identity as J_,map as Y_}from"rxjs";import{filter as G_,map as j_,scan as q_}from"rxjs";import{combineLatest as rw,map as nw,of as aw,switchMap as iw,throttleTime as sw}from"rxjs";import{filter as lw,map as mw,skipWhile as yw,switchMap as hw,takeWhile as fw}from"rxjs";import{of as xw,timeout as Rw,tap as bw,throwError as Fw,map as Sw,startWith as Cw}from"rxjs";import{takeWhile as Aw,map as Ew,timer as kw}from"rxjs";import{distinctUntilChanged as _w}from"rxjs";import{finalize as Uw,of as Ww,scan as Bw,switchMap as Gw}from"rxjs";import{startWith as $w,distinctUntilChanged as Hw,shareReplay as zw,map as Jw,first as Yw}from"rxjs";import{tap as tV,delayWhen as oV,timer as rV,asyncScheduler as nV}from"rxjs";import{map as lV,switchMap as mV,shareReplay as yV,distinctUntilChanged as hV}from"rxjs";import{scan as FV}from"rxjs";import{combineLatest as OV,skipWhile as MV,startWith as PV,BehaviorSubject as AV,shareReplay as EV,map as kV,finalize as ZV,of as DV,mergeMap as LV,from as vV}from"rxjs";import{map as VV}from"rxjs";import{throttleTime as GV,distinctUntilChanged as jV,BehaviorSubject as qV}from"rxjs";import{map as QV,combineLatest as eK,of as tK}from"rxjs";import{map as cK,of as uK,switchMap as pK}from"rxjs";import{distinctUntilChanged as TK}from"rxjs";import{map as CK,switchMap as IK}from"rxjs";import{first as PK}from"rxjs";import{switchMap as oU,of as rU}from"rxjs";import{map as WU,switchMap as BU,shareReplay as GU,distinctUntilChanged as jU,BehaviorSubject as qU,isObservable as $U,of as HU}from"rxjs";function Ic(e){let t=!bo(e),o;return t?o="loading":le(e,"value")?o="success":le(e,"error")?o="error":o="idle",o}function bo(e){let t=!1;if(e){let o=e.loading;o===!0?t=!1:t=o===!1||!!(e.value??e.error)||e.value===null}return t}function Fo(e){let t=e==="idle";return o=>o?Ic(o)===e:t}var uU=Fo("idle"),Nt=Fo("loading");var pU=Fo("success"),dU=Fo("error");import{startWith as bU,filter as FU,map as SU,tap as CU,catchError as IU,combineLatest as OU,distinctUntilChanged as MU,first as PU,of as AU,shareReplay as EU,switchMap as kU,firstValueFrom as ZU,scan as DU}from"rxjs";import{distinctUntilChanged as lW,map as mW,shareReplay as yW,skipWhile as hW}from"rxjs";import{map as oW}from"rxjs";import{BehaviorSubject as FW}from"rxjs";import{combineLatest as cB,map as uB,shareReplay as pB,skipWhile as dB}from"rxjs";import{map as fB,shareReplay as gB}from"rxjs";import{distinctUntilChanged as EB,map as kB,scan as ZB,startWith as DB,catchError as LB,skip as vB,mergeMap as NB,delay as _B,BehaviorSubject as wB,combineLatest as VB,exhaustMap as KB,filter as UB,first as WB,of as BB,shareReplay as GB,defaultIfEmpty as jB}from"rxjs";import{defaultIfEmpty as sG,delay as cG,filter as uG,first as pG,map as dG,shareReplay as lG,switchMap as mG,tap as yG,startWith as hG,timeout as fG,of as gG,BehaviorSubject as TG,Subject as xG}from"rxjs";import{isObservable as WG}from"rxjs";import{filter as OG,map as MG,BehaviorSubject as PG,of as AG,first as EG,shareReplay as kG,switchMap as ZG,delay as DG,from as LG,tap as vG}from"rxjs";import{createParamDecorator as Nl}from"@nestjs/common";var xj=Nl((e,t)=>_l(t));function _l(e){let o=e.switchToHttp().getRequest().headers.origin??"";return o.startsWith("http://localhost")||o.startsWith("https://localhost")}import{createParamDecorator as Xr,BadRequestException as wl,InternalServerErrorException as Vl,Logger as Kl}from"@nestjs/common";import Ul from"raw-body";import{parse as Wl}from"querystring";var Pc=new Kl("RawBody"),Cj=Xr(async(e,t)=>{let o=t.switchToHttp().getRequest();if(!o.readable)throw Pc.error("RawBody request was not readable. This is generally due to bad configuration."),new wl("Invalid body");return await Ul(o)}),Ac=Xr(async(e,t)=>{let r=t.switchToHttp().getRequest().body;if(!Buffer.isBuffer(r))throw Pc.error("RawBody expected a buffer set to req.body."),new Vl("failed parsing body");return r}),Ij=Xr(async(e,t)=>{let o=t.switchToHttp().getRequest();return o.body=Bl(o.body),o.body});function Bl(e){let t=Gl(e);return Wl(t)}function Gl(e){return e.toString("utf8").trim()}import{Injectable as jl}from"@nestjs/common";import ql from"body-parser";var it=class{use(t,o,r){ql.json()(t,o,r)}};it=O([jl()],it);import{Injectable as $l}from"@nestjs/common";import Hl from"body-parser";var st=class{use(t,o,r){Hl.raw({type:"*/*"})(t,o,r)}};st=O([$l()],st);import{Logger as zl,Module as Jl,RequestMethod as Yl}from"@nestjs/common";var Xl="/webhook",Ql={path:`${Xl}/{*path}`,method:Yl.POST},Qr=class{configure(t){em(t)}},So=class extends Qr{logger=new zl("ConfigureWebhookMiddlewareModule");configure(t){super.configure(t),this.logger.debug("Configured webhook routes with proper middleware.")}};So=O([Jl({})],So);function em(e){e.apply(st).forRoutes(Ql).apply(it).forRoutes("{*path}")}var Ec="CLIENT_WEB_APP_URL";var Ne=class{client;static assertValidConfig(t){if(!t.client.clientWebAppUrl)throw new Error("No client app url specified.")}};import{Inject as tm,Injectable as om}from"@nestjs/common";var _e=class{_config;constructor(t){this._config=t}get config(){return this._config}get webAppUrl(){return this.config.client.clientWebAppUrl}get webAppHost(){return this.webAppUrl.split("://",2)[1]}};_e=O([om(),A(0,tm(Ne))],_e);import{Module as rm}from"@nestjs/common";import{ConfigModule as nm,ConfigService as am}from"@nestjs/config";function im(e){let t={client:{clientWebAppUrl:e.get(Ec)}};return Ne.assertValidConfig(t),t}var Co=class{};Co=O([rm({imports:[nm],providers:[{provide:Ne,inject:[am],useFactory:im},_e],exports:[_e]})],Co);var kc="SERVER_ENV_TOKEN";import{Inject as sm,Injectable as cm}from"@nestjs/common";function Zc(){return process.env.NODE_ENV==="test"}var Io=class{constructor(t){this.env=t}get isTestingEnv(){return Zc()}get isProduction(){return this.env.production}get isStaging(){return!!this.env.staging}get developerToolsEnabled(){return!!(!this.isProduction&&this.env.developerToolsEnabled)}get appUrl(){return this.env.appUrl}get appApiUrl(){return this.env.appApiUrl}};Io=O([cm(),A(0,sm(kc))],Io);import{Controller as hm,Inject as fm,Post as gm,Req as Tm}from"@nestjs/common";import{Inject as lm,Injectable as mm,Logger as ym}from"@nestjs/common";import{createHmac as um,timingSafeEqual as pm}from"node:crypto";var dm="x-zs-webhook-signature";function Dc(e){let{secret:t}=e;return async(o,r)=>{let n=o.headers[dm];if(!n)return{valid:!1};let a=r.toString("utf-8"),i=um("sha256",t).update(a,"utf-8").digest("base64"),s=!1;try{let u=Buffer.from(n,"base64"),p=Buffer.from(i,"base64");u.length===p.length&&(s=pm(u,p))}catch{s=!1}let c;if(s)try{let u=JSON.parse(a);c=Rc(u)}catch{s=!1}return s&&c?{valid:!0,event:c}:{valid:!1}}}var fe=class{logger=new ym("ZohoSignWebhookService");_verifier;handler=bc();configure=Fc(this.handler);constructor(t){let{webhookSecret:o}=t.zohoSignWebhook;this._verifier=Dc({secret:o})}async updateForWebhook(t,o){let r=await this._verifier(t,o);r.valid?await this.updateForZohoSignEvent(r.event):this.logger.warn("Received invalid Zoho Sign webhook event.",t)}async updateForZohoSignEvent(t){await this.handler(t)||this.logger.warn("Received unexpected/unhandled Zoho Sign webhook event.",t)}};fe=O([mm(),A(0,lm(ve))],fe);var we=class{_zohoSignWebhookService;constructor(t){this._zohoSignWebhookService=t}async handleZohoSignWebhook(t,o){await this._zohoSignWebhookService.updateForWebhook(t,o)}};O([gm(),A(0,Tm()),A(1,Ac())],we.prototype,"handleZohoSignWebhook",1),we=O([hm("/webhook/zoho/sign"),A(0,fm(fe))],we);import{Module as xm}from"@nestjs/common";import{ConfigModule as Rm,ConfigService as bm}from"@nestjs/config";function Fm(e){let t={zohoSignWebhook:{webhookSecret:e.get(Sc)}};return ve.assertValidConfig(t),t}var Oo=class{};Oo=O([xm({imports:[Rm],controllers:[we],providers:[{provide:ve,inject:[bm],useFactory:Fm},fe],exports:[fe]})],Oo);import{Inject as Lc,Injectable as Sm}from"@nestjs/common";var _t=class{zohoDesk;factoryConfig;static assertValidConfig(t){if(Me(t.zohoDesk),!t.zohoDesk.orgId)throw new Error("No Zoho Desk orgId specified.")}};var Ve=class{constructor(t,o){this.config=t;this.zohoAccountsApi=o;this.zohoDesk=Ts({...t.factoryConfig,accountsContext:o.accountsContext})(t.zohoDesk)}zohoDesk;get deskContext(){return this.zohoDesk.deskContext}get zohoRateLimiter(){return this.zohoDesk.deskContext.zohoRateLimiter}get getTickets(){return Kr(this.deskContext)}get getTicketById(){return Rs(this.deskContext)}get searchTickets(){return Ur(this.deskContext)}get getTicketsForContact(){return bs(this.deskContext)}get getTicketsForProduct(){return Fs(this.deskContext)}get getTicketMetrics(){return Ss(this.deskContext)}get getAgentsTicketsCount(){return Cs(this.deskContext)}get getTicketsPageFactory(){return Is(this.deskContext)}get searchTicketsPageFactory(){return Os(this.deskContext)}get getDepartments(){return Ps(this.deskContext)}get getDepartmentById(){return As(this.deskContext)}get getContacts(){return Br(this.deskContext)}get getContactById(){return ks(this.deskContext)}get getContactsByIds(){return Zs(this.deskContext)}get getContactsPageFactory(){return Ds(this.deskContext)}get getTicketTags(){return Ls(this.deskContext)}get associateTicketTags(){return vs(this.deskContext)}get dissociateTicketTag(){return Ns(this.deskContext)}get searchTags(){return _s(this.deskContext)}get getAllTags(){return ws(this.deskContext)}get getTicketFollowers(){return Vs(this.deskContext)}get addTicketFollowers(){return Ks(this.deskContext)}get removeTicketFollowers(){return Us(this.deskContext)}get getTicketAttachments(){return Bs(this.deskContext)}get deleteTicketAttachment(){return Gs(this.deskContext)}get getTicketComments(){return qs(this.deskContext)}get getTicketCommentById(){return $s(this.deskContext)}get createTicketComment(){return Hs(this.deskContext)}get deleteTicketComment(){return zs(this.deskContext)}get getTicketTimer(){return Js(this.deskContext)}get performTicketTimerAction(){return Ys(this.deskContext)}get getTicketTimeEntries(){return Xs(this.deskContext)}get getTicketTimeEntryById(){return Qs(this.deskContext)}get getTicketTimeEntrySummation(){return ec(this.deskContext)}get getTicketThreads(){return jr(this.deskContext)}get getTicketThreadById(){return rc(this.deskContext)}get getTicketThreadsPageFactory(){return nc(this.deskContext)}get getTicketActivities(){return qr(this.deskContext)}get getTicketActivitiesPageFactory(){return ac(this.deskContext)}get getAgents(){return $r(this.deskContext)}get getAgentById(){return sc(this.deskContext)}get getAgentsByIds(){return cc(this.deskContext)}get getMyInfo(){return uc(this.deskContext)}get getAgentsPageFactory(){return pc(this.deskContext)}};Ve=O([Sm(),A(0,Lc(_t)),A(1,Lc(V))],Ve);import{ConfigModule as L$,ConfigService as v$}from"@nestjs/config";function Cm(e){return`${e.clientId}:${e.refreshToken}`}function ct(e){let t=mc([yc(),hc(mt())]),o=new Map;function r(p,d){let g=Cm(p),y=o.get(g);if(y)return y;let h={zohoAccounts:{serviceAccessTokenKey:d,refreshToken:p.refreshToken,clientId:p.clientId,clientSecret:p.clientSecret,apiUrl:p.region??"us"}},T=new V(h,t);return o.set(g,T),T}let n,a=yt(e,"recruit");if(a){let p=r(a,"recruit"),d={zohoRecruit:{apiUrl:a.apiMode}};n=new Le(d,p)}let i,s=yt(e,"crm");if(s){let p=r(s,"crm"),d={zohoCrm:{apiUrl:s.apiMode}};i=new De(d,p)}let c,u=yt(e,"desk");if(u?.orgId){let p=r(u,"desk"),d={zohoDesk:{apiUrl:u.apiMode,orgId:u.orgId}};c=new Ve(d,p)}return{recruitApi:n,crmApi:i,deskApi:c}}import{existsSync as Nc,mkdirSync as _c,writeFileSync as Im}from"node:fs";import{join as wc}from"node:path";var pt={};function Vc(e){pt=e}var Om=[/Bearer\s+\S+/gi,/access_token[=:]\s*\S+/gi,/refresh_token[=:]\s*\S+/gi,/client_secret[=:]\s*\S+/gi,/1000\.\w{20,}/g];function ut(e){let t=e;for(let o of Om)t=t.replace(o,"[REDACTED]");return t}function Kc(){return new Date().toISOString().replace(/[:.]/g,"-")}function en(){return pt}function tn(e,t){let{dumpDir:o,commandPath:r}=pt;if(!o)return;Nc(o)||_c(o,{recursive:!0});let n=r?.length?r.join("_"):"response",a=Kc(),i=t?`${n}_${a}_${t}`:`${n}_${a}`;return wc(o,`${i}.${e}`)}function Mm(e,t){let{dumpDir:o,commandPath:r}=pt;if(!o)return;Nc(o)||_c(o,{recursive:!0});let a=`${r?.length?r.join("_"):"response"}_${Kc()}.json`,i=wc(o,a),s={ok:!0,data:e,...t?{meta:t}:{}};Im(i,JSON.stringify(s,null,2))}function dt(e,t){let o=t.split(",").map(r=>r.trim());return Array.isArray(e)?e.map(r=>vc(r,o)):e!=null&&typeof e=="object"?vc(e,o):e}function vc(e,t){if(e==null||typeof e!="object")return e;let o={};for(let r of t)r in e&&(o[r]=e[r]);return o}function l(e,t){Mm(e,t);let r={ok:!0,data:pt.pick?dt(e,pt.pick):e,...t?{meta:t}:{}};console.log(JSON.stringify(r))}function m(e){let t=Pm(e);console.log(JSON.stringify(t))}function Pm(e){return e instanceof $?{ok:!1,error:ut(e.message),code:"TOKEN_EXPIRED",suggestion:"Run: zoho-cli auth check"}:e instanceof Mt?{ok:!1,error:ut(e.message),code:"AUTH_ERROR",suggestion:"Check your client ID, secret, and refresh token."}:e instanceof Pt?{ok:!1,error:ut(e.message),code:"RATE_LIMITED",suggestion:"Wait and retry. Zoho rate limit exceeded."}:e instanceof j?{ok:!1,error:ut(e.message),code:"API_ERROR"}:e instanceof Error?{ok:!1,error:ut(e.message),code:"ERROR"}:{ok:!1,error:ut(String(e)),code:"UNKNOWN_ERROR"}}var Uc={us:"https://accounts.zoho.com",eu:"https://accounts.zoho.eu",in:"https://accounts.zoho.in",au:"https://accounts.zoho.com.au",jp:"https://accounts.zoho.jp"},Wc={recruit:["ZohoRecruit.modules.ALL","ZohoRecruit.settings.all","ZohoRecruit.functions.execute.READ","ZohoRecruit.functions.execute.CREATE"],crm:["ZohoCRM.modules.ALL","ZohoCRM.settings.ALL","ZohoCRM.functions.execute.READ","ZohoCRM.functions.execute.CREATE"],desk:["Desk.tickets.ALL","Desk.tasks.ALL","Desk.contacts.ALL","Desk.settings.ALL","Desk.events.ALL","Desk.search.READ","Desk.articles.READ","Desk.basic.READ"],sign:["ZohoSign.documents.ALL","ZohoSign.templates.ALL"]};function Am(e){if(e){if(e.startsWith("http://")||e.startsWith("https://"))try{let o=new URL(e).searchParams.get("code");if(!o)throw new Error('No "code" parameter found in the provided URL.');return o}catch(t){throw t instanceof TypeError?new Error(`Invalid URL provided for --code: ${e}`):t}return e}}var Em={command:"setup",describe:"Generate OAuth authorization URL, exchange code, or set refresh token directly",builder:e=>e.option("client-id",{type:"string",describe:"OAuth client ID (from https://api-console.zoho.com/)"}).option("client-secret",{type:"string",describe:"OAuth client secret"}).option("redirect-uri",{type:"string",default:"http://localhost/oauth",describe:"Redirect URI (must match API console config)"}).option("region",{type:"string",default:"us",choices:["us","eu","in","au","jp"],describe:"Zoho region"}).option("scopes",{type:"string",default:"recruit,crm,desk",describe:"Comma-separated products for OAuth scopes (recruit,crm,desk,sign)"}).option("code",{type:"string",describe:"Authorization code or the full redirect URL (code is extracted automatically)"}).option("token",{type:"string",describe:"Set a refresh token directly (skips OAuth code exchange)"}).option("product",{type:"string",choices:[...Kt],describe:"Store credentials for a specific product instead of shared"}).option("org-id",{type:"string",describe:"Zoho Desk organization ID"}).option("api-mode",{type:"string",default:"production",choices:["production","sandbox"],describe:"API mode"}).example([["$0 auth setup --client-id 1000.ABC --client-secret xyz","Step 1: Get OAuth URL (saves shared credentials)"],["$0 auth setup --code 1000.AUTH.CODE","Step 2: Exchange code for refresh token"],['$0 auth setup --code "http://localhost/oauth?code=1000.AUTH.CODE&location=us"',"Step 2: Paste the full redirect URL"],["$0 auth setup --client-id 1000.ABC --client-secret xyz --token 1000.REFRESH.TOKEN","Set shared refresh token directly"],["$0 auth setup --product crm --client-id 1000.CRM --client-secret xyz --token 1000.CRM.TOKEN","Set CRM-specific credentials"]]),handler:async e=>{try{let t=await B(),o=e.product,r=e.clientId??t?.shared?.clientId,n=e.clientSecret??t?.shared?.clientSecret,a=e.redirectUri,i=e.region??t?.shared?.region??"us",s=e.scopes.split(",").map(d=>d.trim()),c=Am(e.code),u=e.token,p=Uc[i]??Uc.us;if(!r||!n)throw new Error("--client-id and --client-secret are required. Get them from https://api-console.zoho.com/");if(u){let d={clientId:r,clientSecret:n,refreshToken:u};if(o){let g={...d,apiUrl:e.apiMode,orgId:o==="desk"?e.orgId:void 0},y=await G({shared:t?.shared??{clientId:"",clientSecret:"",refreshToken:""},[o]:g});l({success:!0,product:o,refreshToken:Te(u),configSaved:!0,configuredProducts:J(y)})}else{let g=await G({shared:{...d,region:i,apiMode:e.apiMode},desk:e.orgId?{orgId:e.orgId}:void 0});l({success:!0,refreshToken:Te(u),configSaved:!0,configuredProducts:J(g)})}}else if(c){let d=`${p}/oauth/v2/token`,g=new URLSearchParams({grant_type:"authorization_code",client_id:r,client_secret:n,redirect_uri:a,code:c}),h=await(await fetch(d,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:g.toString()})).json();if(h.error)throw new Error(`Token exchange failed: ${h.error}`);let T=h.refresh_token;if(!T)throw new Error("No refresh_token in response. The authorization code may have expired (valid for 2 minutes). Generate a new one.");let R={clientId:r,clientSecret:n,refreshToken:T},S;o?S=await G({shared:t?.shared??{clientId:"",clientSecret:"",refreshToken:""},[o]:{...R,apiUrl:e.apiMode,orgId:o==="desk"?e.orgId:void 0}}):S=await G({shared:{...R,region:i,apiMode:e.apiMode},desk:e.orgId?{orgId:e.orgId}:void 0}),l({step:2,success:!0,product:o??"shared",refreshToken:Te(T),accessToken:h.access_token?Te(h.access_token):null,scope:h.scope,configSaved:!0,configuredProducts:J(S)})}else{let d=s.flatMap(y=>Wc[y]??[]);if(d.length===0)throw new Error(`No valid products specified. Choose from: ${Object.keys(Wc).join(", ")}`);let g=`${p}/oauth/v2/auth?scope=${d.join(",")}&client_id=${encodeURIComponent(r)}&response_type=code&access_type=offline&redirect_uri=${encodeURIComponent(a)}`;await G({shared:{clientId:r,clientSecret:n,refreshToken:t?.shared?.refreshToken??"",region:i,apiMode:e.apiMode??t?.shared?.apiMode},desk:e.orgId?{orgId:e.orgId}:void 0}),l({step:1,instructions:'Open the authorization URL in a browser. Authorize the application. Copy the "code" parameter from the redirect URL.',authorizationUrl:g,redirectUri:a,scopes:d,credentialsSaved:!0,nextStep:'zoho-cli auth setup --code "PASTE_REDIRECT_URL_OR_AUTH_CODE"'})}}catch(t){m(t),process.exit(1)}}},km={command:"set",describe:"Save Zoho API credentials directly",builder:e=>e.option("client-id",{type:"string",demandOption:!0,describe:"OAuth client ID"}).option("client-secret",{type:"string",demandOption:!0,describe:"OAuth client secret"}).option("refresh-token",{type:"string",demandOption:!0,describe:"OAuth refresh token"}).option("product",{type:"string",choices:[...Kt],describe:"Store for a specific product instead of shared"}).option("region",{type:"string",default:"us",describe:"Zoho region (us, eu, in, au, jp)"}).option("org-id",{type:"string",describe:"Zoho Desk organization ID"}).option("api-mode",{type:"string",default:"production",choices:["production","sandbox"],describe:"API mode"}).example([["$0 auth set --client-id abc --client-secret xyz --refresh-token 1000.abc.xyz","Set shared credentials"],["$0 auth set --product crm --client-id abc --client-secret xyz --refresh-token 1000.crm.xyz","Set CRM-specific credentials"]]),handler:async e=>{try{let t=e.product,o={clientId:e.clientId,clientSecret:e.clientSecret,refreshToken:e.refreshToken},r;t?r=await G({shared:(await B())?.shared??{clientId:"",clientSecret:"",refreshToken:""},[t]:{...o,apiUrl:e.apiMode,orgId:t==="desk"?e.orgId:void 0}}):r=await G({shared:{...o,region:e.region,apiMode:e.apiMode},desk:e.orgId?{orgId:e.orgId}:void 0}),l({saved:!0,product:t??"shared",configuredProducts:J(r)})}catch(t){m(t),process.exit(1)}}},Zm={command:"show",describe:"Show current configuration (secrets masked)",builder:e=>e,handler:async()=>{try{let o=function(r){if(r)return{clientId:r.clientId?Te(r.clientId):void 0,clientSecret:r.clientSecret?Te(r.clientSecret):void 0,refreshToken:r.refreshToken?Te(r.refreshToken):void 0}};var e=o;let t=await B();if(!t){l({configured:!1});return}l({configured:!0,shared:{...o(t.shared),region:t.shared?.region??"us",apiMode:t.shared?.apiMode??"production"},recruit:t.recruit?{...o(t.recruit),apiUrl:t.recruit.apiUrl}:null,crm:t.crm?{...o(t.crm),apiUrl:t.crm.apiUrl}:null,desk:t.desk?{...o(t.desk),apiUrl:t.desk.apiUrl,orgId:t.desk.orgId}:null,configuredProducts:J(t)})}catch(t){m(t),process.exit(1)}}},Dm={command:"check",describe:"Verify credentials by exchanging tokens",builder:e=>e,handler:async()=>{try{let e=await B();if(!e){l({authenticated:!1,error:"No credentials configured. Run: zoho-cli auth setup"});return}let t=J(e);if(t.length===0){l({authenticated:!1,error:"No products have complete credentials. Run: zoho-cli auth setup"});return}let o=ct(e),r={};for(let n of t)try{let a=n==="recruit"?o.recruitApi:n==="crm"?o.crmApi:o.deskApi;if(!a){r[n]={authenticated:!1,error:"Not configured"};continue}let s=await a.zohoAccountsApi.accessToken();r[n]={authenticated:!0,scope:s.scope,expiresIn:s.expires_in}}catch(a){let i=a instanceof Error?a.message:String(a);r[n]={authenticated:!1,error:i}}l({products:r})}catch(e){m(e),process.exit(1)}}},Lm={command:"clear",describe:"Remove stored credentials and token cache",builder:e=>e,handler:async()=>{try{await un(),l({cleared:!0})}catch(e){m(e),process.exit(1)}}},Bc={command:"auth",describe:"Manage Zoho API credentials",builder:e=>e.command(Em).command(km).command(Zm).command(Dm).command(Lm).demandCommand(1,"Please specify an auth subcommand."),handler:C};import{access as vm,constants as Nm}from"node:fs";import{dirname as _m}from"node:path";var Gc={command:"doctor",describe:"Check CLI configuration and connectivity",builder:e=>e,handler:async()=>{let e=[],t=await B();t?e.push({name:"config",status:"pass",message:`Config loaded from ${lt()}`}):e.push({name:"config",status:"fail",message:"No config found. Run: zoho-cli auth setup"}),t?.shared?.clientId&&t?.shared?.clientSecret&&t?.shared?.refreshToken?e.push({name:"shared-credentials",status:"pass",message:"Shared credentials present"}):t&&e.push({name:"shared-credentials",status:"warn",message:"Missing shared credentials. Per-product credentials may still work."});let o=_m(mt());if(await wm(o)?e.push({name:"token-cache",status:"pass",message:`Token cache directory writable: ${o}`}):e.push({name:"token-cache",status:"warn",message:`Token cache directory not writable: ${o}`}),t){let a=J(t);a.length>0?e.push({name:"products",status:"pass",message:`Configured products: ${a.join(", ")}`}):e.push({name:"products",status:"fail",message:"No products have complete credentials"});let i=ct(t);for(let s of a)try{let c=s==="recruit"?i.recruitApi:s==="crm"?i.crmApi:i.deskApi;if(c){let p=await c.zohoAccountsApi.accessToken();e.push({name:`${s}-token`,status:"pass",message:`${s}: Token exchange successful. Scope: ${p.scope}`})}}catch(c){let u=c instanceof Error?c.message:String(c);e.push({name:`${s}-token`,status:"fail",message:`${s}: Token exchange failed: ${u}`})}t.desk?.orgId?e.push({name:"desk-org-id",status:"pass",message:`Desk org ID configured: ${t.desk.orgId}`}):a.includes("desk")||e.push({name:"desk-org-id",status:"warn",message:"No Desk org ID. Desk commands unavailable."})}let n=e.every(a=>a.status==="pass");l({checks:e,healthy:n}),n||process.exit(e.some(a=>a.status==="fail")?1:0)}};function wm(e){return new Promise(t=>{vm(e,Nm.W_OK,o=>{t(!o)})})}var on;function jc(e){return async t=>{let o=t._?.[0];if(!(typeof o=="string"&&e.has(o)))try{let r=await B();r||(m(new Error("Not authenticated. Run: zoho-cli auth setup --client-id X --client-secret Y --token Z")),process.exit(4)),J(r).length===0&&(m(new Error("No products configured with complete credentials. Run: zoho-cli auth setup")),process.exit(4)),on=ct(r)}catch(r){m(r),process.exit(4)}}}function rn(e){if(!on)throw new Error("CLI context not initialized. This is a bug.");return on}function H(e){let{recruitApi:t}=rn(e);if(!t)throw new Error("Recruit not configured. Run: zoho-cli auth setup --client-id X --client-secret Y --token Z");return t}function z(e){let{crmApi:t}=rn(e);if(!t)throw new Error("CRM not configured. Run: zoho-cli auth setup --product crm --client-id X --client-secret Y --token Z");return t}function b(e){let{deskApi:t}=rn(e);if(!t)throw new Error("Desk not configured. Run: zoho-cli auth setup --product desk --client-id X --client-secret Y --token Z --org-id YOUR_ORG_ID");return t}var Vm=["raw","page_by_line","data_by_line"],Km=["replace","concat"],Um=["meta","pages","merged_page"];function qc(e){return e.option("multiple-pages",{type:"number",default:1,describe:"Pages to fetch in this invocation (>=1). Continues from --page (CRM/Recruit) or --from (Desk)."}).option("multiple-pages-output",{type:"string",choices:Um,default:"meta",describe:"Stdout shape when multiple-pages > 1: meta (summary, low memory), pages (array of page responses, WARNING: holds all pages in memory), merged_page (concat all records into one array, WARNING: holds all records in memory)."}).option("dump-output",{type:"string",choices:Vm,default:"raw",describe:"Dump file format when --dump-dir is set. raw: one full JSON page response (concatenated JSON when --dump-merge=concat, not standard JSON). page_by_line: NDJSON of page responses. data_by_line: NDJSON of records."}).option("dump-merge",{type:"string",choices:Km,default:"replace",describe:"Across pages with multiple-pages > 1: replace (truncate file each iteration; only last page survives) or concat (append)."})}function ue(e){return qc(e.option("page",{type:"number",default:1,describe:"Page number (1-based)"}).option("per-page",{type:"number",default:20,describe:"Records per page"}))}function k(e){return qc(e.option("from",{type:"number",default:1,describe:"Start index (1-based)"}).option("limit",{type:"number",default:25,describe:"Max records (max 50)"}))}function L(e){return e.option("module",{alias:"m",type:"string",demandOption:!0,describe:"Zoho module name (e.g. Candidates, Contacts, Leads)"})}function Ae(e){return e.option("id",{type:"string",demandOption:!0,describe:"Record ID"})}function wt(e,t=!1){return e.option("fields",{type:"string",demandOption:t,describe:"Comma-separated field names to return"})}function Mo(e){return e.option("sort-by",{type:"string",describe:"Field to sort by"}).option("sort-order",{type:"string",choices:["asc","desc"],describe:"Sort direction"})}import{writeFileSync as Wm,appendFileSync as Bm}from"node:fs";var pe={nextInput:(e,t)=>{if(!t.info?.more_records)return;let o=e.page??1;return{...e,page:o+1}},countOf:e=>e.data?.length??0,metaOf:(e,t)=>({page:t.info?.page??e.page,per_page:t.info?.per_page??e.per_page,more_records:t.info?.more_records??!1}),hasMorePagesAvailable:(e,t)=>t.info?.more_records??!1},Z={nextInput:(e,t)=>{let o=e.limit??25;if(o<=0||(t.data?.length??0)<o)return;let n=e.from??1;return{...e,from:n+o}},countOf:e=>e.data?.length??0,metaOf:(e,t)=>({from:e.from,limit:e.limit,count:t.data?.length??0}),hasMorePagesAvailable:(e,t)=>{let o=e.limit??25;return o<=0?!1:(t.data?.length??0)>=o}};function Gm(e){let{dumpOutput:t,dumpMerge:o}=e,{pick:r}=en(),n=t==="raw"?"json":"ndjson",a=tn(n),i=r?tn(n,"pick"):void 0;if(!a)return{mainPath:void 0,pickPath:void 0,writePage:()=>{},close:()=>{}};let s=0;function c(d){if(!r)return d;let g=dt(d.data,r);return{...d,data:g}}function u(d){let g=d.append?Bm:Wm;a&&g(a,d.mainContent),i&&d.pickContent!==void 0&&g(i,d.pickContent)}function p(d){let y=o==="concat"&&!(s===0);if(t==="raw"){let h=JSON.stringify(d,null,2),T=i?JSON.stringify(c(d),null,2):void 0;u({mainContent:h,pickContent:T,append:y})}else if(t==="page_by_line"){let h=JSON.stringify(d)+`
|
|
5
|
+
`,T=i?JSON.stringify(c(d))+`
|
|
6
|
+
`:void 0;u({mainContent:h,pickContent:T,append:y})}else{let h=d.data??[],T=i?dt(h,r):void 0;h.length===0?y||u({mainContent:"",pickContent:i?"":void 0,append:!1}):h.forEach((R,S)=>{let M=y||S>0,v=JSON.stringify(R)+`
|
|
7
|
+
`,U=i&&T?JSON.stringify(T[S])+`
|
|
8
|
+
`:void 0;u({mainContent:v,pickContent:U,append:M})})}s+=1}return{mainPath:a,pickPath:i,writePage:p,close:()=>{}}}async function F(e){let{initialInput:t,fetchPage:o,adapter:r,multiplePagesOutput:n,dumpOutput:a,dumpMerge:i}=e,s=Math.max(1,Math.floor(e.multiplePages||1));if(s<=1)return{handled:!1,result:await o(t)};let c=en();c.dumpDir||console.error("[zoho-cli] warning: --multiple-pages used without --dump-dir; results not persisted.");let u=Gm({dumpOutput:a,dumpMerge:i}),p=[],d=[],g=n==="pages",y=n==="merged_page",h=t,T=0,R=0,S=!1,M,v=t;try{for(let D=0;D<s;D++){let P=await o(h);if(T+=1,R+=r.countOf(P),M=P,v=h,u.writePage(P),g)p.push(P);else if(y)for(let Vt of P.data??[])d.push(Vt);let ge=r.nextInput(h,P);if(S=r.hasMorePagesAvailable(h,P),!ge)break;h=ge}}finally{u.close()}let U=c.pick,I={pagesFetched:T,totalRecords:R,hasMorePagesAvailable:S,dumpFile:u.mainPath??null};if(u.pickPath&&(I.dumpFilePick=u.pickPath),n==="meta")console.log(JSON.stringify({ok:!0,meta:I}));else if(n==="pages"){let D=U?p.map(P=>({...P,data:dt(P.data,U)})):p;console.log(JSON.stringify({ok:!0,data:D,meta:I}))}else{let D=M?r.metaOf(v,M):{},P=U?dt(d,U):d;console.log(JSON.stringify({ok:!0,data:P,meta:{...D,...I}}))}return{handled:!0}}var jm={command:"list",describe:"List records from a module",builder:e=>Mo(wt(ue(L(e)))),handler:async e=>{try{let t=H(e),o={module:e.module,page:e.page,per_page:e.perPage,fields:e.fields,sort_by:e.sortBy,sort_order:e.sortOrder},r=await F({initialInput:o,fetchPage:n=>t.getRecords(n),adapter:pe,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{page:n.info?.page,per_page:n.info?.per_page,more_records:n.info?.more_records})}}catch(t){m(t),process.exit(1)}}},qm={command:"get",describe:"Get a record by ID",builder:e=>Ae(L(e)),handler:async e=>{try{let o=await H(e).getRecordById({module:e.module,id:e.id});l(o)}catch(t){m(t),process.exit(1)}}},$m={command:"search",describe:"Search records in a module",builder:e=>ue(L(e)).option("criteria",{type:"string",describe:"Search criteria string, e.g. (First_Name:equals:John)"}).option("word",{type:"string",describe:"Keyword search"}).option("email",{type:"string",describe:"Search by email"}).option("phone",{type:"string",describe:"Search by phone"}),handler:async e=>{try{let t=H(e),o={module:e.module,criteria:e.criteria,word:e.word,email:e.email,phone:e.phone,page:e.page,per_page:e.perPage},r=await F({initialInput:o,fetchPage:n=>t.searchRecords(n),adapter:pe,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{page:n.info?.page,per_page:n.info?.per_page,more_records:n.info?.more_records})}}catch(t){m(t),process.exit(1)}}},Hm={command:"insert",describe:"Insert a record into a module",builder:e=>L(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array)"}),handler:async e=>{try{let t=H(e),o=JSON.parse(e.data),r=await t.insertRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},zm={command:"upsert",describe:"Upsert a record in a module",builder:e=>L(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array, include id for update)"}),handler:async e=>{try{let t=H(e),o=JSON.parse(e.data),r=await t.upsertRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},Jm={command:"update",describe:"Update a record in a module",builder:e=>L(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array, must include id)"}),handler:async e=>{try{let t=H(e),o=JSON.parse(e.data),r=await t.updateRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},Ym={command:"delete",describe:"Delete records from a module",builder:e=>L(e).option("ids",{type:"string",demandOption:!0,describe:"Comma-separated record IDs to delete"}),handler:async e=>{try{let t=H(e),o=e.ids.split(",").map(n=>n.trim()),r=await t.deleteRecord({module:e.module,ids:o});l(r)}catch(t){m(t),process.exit(1)}}},Xm={command:"emails",describe:"Get emails for a record",builder:e=>ue(Ae(L(e))),handler:async e=>{try{let t=H(e),o={module:e.module,id:e.id,page:e.page,per_page:e.perPage},r=await F({initialInput:o,fetchPage:n=>t.getEmailsForRecord(n),adapter:pe,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{page:n.info?.page,per_page:n.info?.per_page,more_records:n.info?.more_records})}}catch(t){m(t),process.exit(1)}}},Qm={command:"attachments",describe:"Get attachments for a record",builder:e=>ue(Ae(L(e))),handler:async e=>{try{let t=H(e),o={module:e.module,id:e.id,page:e.page,per_page:e.perPage},r=await F({initialInput:o,fetchPage:n=>t.getAttachmentsForRecord(n),adapter:pe,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{page:n.info?.page,per_page:n.info?.per_page,more_records:n.info?.more_records})}}catch(t){m(t),process.exit(1)}}},$c={command:"recruit",describe:"Zoho Recruit operations",builder:e=>e.command(jm).command(qm).command($m).command(Hm).command(zm).command(Jm).command(Ym).command(Xm).command(Qm).demandCommand(1,"Please specify a recruit subcommand.").example([["$0 recruit list -m Candidates --per-page 10","List first 10 candidates"],["$0 recruit get -m Candidates --id 12345","Get a candidate by ID"],['$0 recruit search -m Candidates --word "John"',"Search candidates by keyword"],[`$0 recruit insert -m Candidates --data '{"First_Name":"John","Last_Name":"Doe"}'`,"Insert a candidate"]]),handler:C};var ey={command:"list",describe:"List records from a module",builder:e=>Mo(wt(ue(L(e)),!0)),handler:async e=>{try{let t=z(e),o={module:e.module,fields:e.fields,page:e.page,per_page:e.perPage,sort_by:e.sortBy,sort_order:e.sortOrder},r=await F({initialInput:o,fetchPage:n=>t.getRecords(n),adapter:pe,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{page:n.info?.page,per_page:n.info?.per_page,more_records:n.info?.more_records})}}catch(t){m(t),process.exit(1)}}},ty={command:"get",describe:"Get a record by ID",builder:e=>Ae(L(e)),handler:async e=>{try{let o=await z(e).getRecordById({module:e.module,id:e.id});l(o)}catch(t){m(t),process.exit(1)}}},oy={command:"search",describe:"Search records in a module",builder:e=>ue(L(e)).option("criteria",{type:"string",describe:"Search criteria string, e.g. (First_Name:equals:John)"}).option("word",{type:"string",describe:"Keyword search"}).option("email",{type:"string",describe:"Search by email"}).option("phone",{type:"string",describe:"Search by phone"}),handler:async e=>{try{let t=z(e),o={module:e.module,criteria:e.criteria,word:e.word,email:e.email,phone:e.phone,page:e.page,per_page:e.perPage},r=await F({initialInput:o,fetchPage:n=>t.searchRecords(n),adapter:pe,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{page:n.info?.page,per_page:n.info?.per_page,more_records:n.info?.more_records})}}catch(t){m(t),process.exit(1)}}},ry={command:"insert",describe:"Insert a record into a module",builder:e=>L(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array)"}),handler:async e=>{try{let t=z(e),o=JSON.parse(e.data),r=await t.insertRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},ny={command:"upsert",describe:"Upsert a record in a module",builder:e=>L(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array, include id for update)"}),handler:async e=>{try{let t=z(e),o=JSON.parse(e.data),r=await t.upsertRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},ay={command:"update",describe:"Update a record in a module",builder:e=>L(e).option("data",{type:"string",demandOption:!0,describe:"JSON record data (object or array, must include id)"}),handler:async e=>{try{let t=z(e),o=JSON.parse(e.data),r=await t.updateRecord({module:e.module,data:o});l(r)}catch(t){m(t),process.exit(1)}}},iy={command:"delete",describe:"Delete records from a module",builder:e=>L(e).option("ids",{type:"string",demandOption:!0,describe:"Comma-separated record IDs to delete"}),handler:async e=>{try{let t=z(e),o=e.ids.split(",").map(n=>n.trim()),r=await t.deleteRecord({module:e.module,ids:o});l(r)}catch(t){m(t),process.exit(1)}}},sy={command:"emails",describe:"Get emails for a record",builder:e=>ue(Ae(L(e))),handler:async e=>{try{let t=z(e),o={module:e.module,id:e.id,page:e.page,per_page:e.perPage},r=await F({initialInput:o,fetchPage:n=>t.getEmailsForRecord(n),adapter:pe,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{page:n.info?.page,per_page:n.info?.per_page,more_records:n.info?.more_records})}}catch(t){m(t),process.exit(1)}}},cy={command:"attachments",describe:"Get attachments for a record",builder:e=>wt(ue(Ae(L(e))),!0),handler:async e=>{try{let t=z(e),o={module:e.module,id:e.id,fields:e.fields,page:e.page,per_page:e.perPage},r=await F({initialInput:o,fetchPage:n=>t.getAttachmentsForRecord(n),adapter:pe,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{page:n.info?.page,per_page:n.info?.per_page,more_records:n.info?.more_records})}}catch(t){m(t),process.exit(1)}}},Hc={command:"crm",describe:"Zoho CRM operations",builder:e=>e.command(ey).command(ty).command(oy).command(ry).command(ny).command(ay).command(iy).command(sy).command(cy).demandCommand(1,"Please specify a CRM subcommand.").example([['$0 crm list -m Contacts --fields "First_Name,Last_Name,Email" --per-page 10',"List contacts"],["$0 crm get -m Contacts --id 12345","Get a contact by ID"],['$0 crm search -m Leads --word "Acme"',"Search leads by keyword"],[`$0 crm insert -m Contacts --data '{"First_Name":"Jane","Last_Name":"Doe"}'`,"Insert a contact"]]),handler:C};var uy={command:"list",describe:"List tickets",builder:e=>k(e).option("department-id",{type:"string",describe:"Filter by department ID"}).option("status",{type:"string",describe:"Filter by status"}).option("sort-by",{type:"string",describe:"Field to sort by"}).option("include",{type:"string",describe:"Comma-separated includes (e.g. contacts,assignee,departments,team,isRead)"}),handler:async e=>{try{let t=b(e),o={from:e.from,limit:e.limit,departmentId:e.departmentId,status:e.status,sortBy:e.sortBy,include:e.include},r=await F({initialInput:o,fetchPage:n=>t.getTickets(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},py={command:"get <ticketId>",describe:"Get a ticket by ID",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("include",{type:"string",describe:"Comma-separated includes (e.g. contacts,assignee,departments,team,isRead)"}),handler:async e=>{try{let o=await b(e).getTicketById({ticketId:e.ticketId,include:e.include});l(o)}catch(t){m(t),process.exit(1)}}},dy={command:"search",describe:"Search tickets",builder:e=>k(e).option("subject",{type:"string",describe:"Search by subject"}).option("status",{type:"string",describe:"Filter by status"}).option("email",{type:"string",describe:"Filter by email"}).option("department-id",{type:"string",describe:"Filter by department ID"}).option("channel",{type:"string",describe:"Filter by channel"}).option("priority",{type:"string",describe:"Filter by priority"}),handler:async e=>{try{let t=b(e),o={from:e.from,limit:e.limit,subject:e.subject,status:e.status,email:e.email,departmentId:e.departmentId,channel:e.channel,priority:e.priority},r=await F({initialInput:o,fetchPage:n=>t.searchTickets(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},ly={command:"by-contact <contactId>",describe:"List tickets for a contact",builder:e=>k(e).positional("contactId",{type:"string",demandOption:!0,describe:"Contact ID"}),handler:async e=>{try{let t=b(e),o={contactId:e.contactId,from:e.from,limit:e.limit},r=await F({initialInput:o,fetchPage:n=>t.getTicketsForContact(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},my={command:"metrics <ticketId>",describe:"Get ticket metrics",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketMetrics({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},yy={command:"agent-counts",describe:"Get ticket counts per agent",builder:e=>e.option("agent-ids",{type:"string",demandOption:!0,describe:"Comma-separated agent IDs"}).option("department-id",{type:"string",describe:"Filter by department ID"}),handler:async e=>{try{let t=b(e),o=e.agentIds.split(",").map(n=>n.trim()),r=await t.getAgentsTicketsCount({agentIds:o,departmentId:e.departmentId});l(r)}catch(t){m(t),process.exit(1)}}},zc={command:"tickets",describe:"Desk ticket operations",builder:e=>e.command(uy).command(py).command(dy).command(ly).command(my).command(yy).demandCommand(1),handler:C};var hy={command:"list",describe:"List departments",builder:e=>k(e).option("search",{type:"string",describe:"Search by name"}).option("is-enabled",{type:"boolean",describe:"Filter by enabled status"}),handler:async e=>{try{let t=b(e),o={from:e.from,limit:e.limit,searchStr:e.search,isEnabled:e.isEnabled},r=await F({initialInput:o,fetchPage:n=>t.getDepartments(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},fy={command:"get <departmentId>",describe:"Get a department by ID",builder:e=>e.positional("departmentId",{type:"string",demandOption:!0,describe:"Department ID"}),handler:async e=>{try{let o=await b(e).getDepartmentById({departmentId:e.departmentId});l(o)}catch(t){m(t),process.exit(1)}}},Jc={command:"departments",describe:"Desk department operations",builder:e=>e.command(hy).command(fy).demandCommand(1),handler:C};var gy={command:"list",describe:"List contacts",builder:e=>k(e).option("sort-by",{type:"string",describe:"Field to sort by"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let t=b(e),o={from:e.from,limit:e.limit,sortBy:e.sortBy,include:e.include},r=await F({initialInput:o,fetchPage:n=>t.getContacts(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},Ty={command:"get <contactId>",describe:"Get a contact by ID",builder:e=>e.positional("contactId",{type:"string",demandOption:!0,describe:"Contact ID"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let o=await b(e).getContactById({contactId:e.contactId,include:e.include});l(o)}catch(t){m(t),process.exit(1)}}},Yc={command:"contacts",describe:"Desk contact operations",builder:e=>e.command(gy).command(Ty).demandCommand(1),handler:C};var xy={command:"list",describe:"List agents",builder:e=>k(e).option("department-id",{type:"string",describe:"Filter by department ID"}).option("status",{type:"string",describe:"Filter by status (active, disabled)"}).option("include",{type:"string",describe:"Comma-separated includes (e.g. role,profile,departments)"}),handler:async e=>{try{let t=b(e),o={from:e.from,limit:e.limit,departmentId:e.departmentId,status:e.status,include:e.include},r=await F({initialInput:o,fetchPage:n=>t.getAgents(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},Ry={command:"get <agentId>",describe:"Get an agent by ID",builder:e=>e.positional("agentId",{type:"string",demandOption:!0,describe:"Agent ID"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let o=await b(e).getAgentById({agentId:e.agentId,include:e.include});l(o)}catch(t){m(t),process.exit(1)}}},by={command:"my-info",describe:"Get current authenticated agent info",builder:e=>e,handler:async e=>{try{let o=await b(e).getMyInfo();l(o)}catch(t){m(t),process.exit(1)}}},Xc={command:"agents",describe:"Desk agent operations",builder:e=>e.command(xy).command(Ry).command(by).demandCommand(1),handler:C};var Fy={command:"list",describe:"List all tags",builder:e=>k(e).option("department-id",{alias:"d",type:"string",demandOption:!0,describe:"Department ID"}),handler:async e=>{try{let t=b(e),o={from:e.from,limit:e.limit,departmentId:e.departmentId},r=await F({initialInput:o,fetchPage:n=>t.getAllTags(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},Sy={command:"search",describe:"Search tags",builder:e=>k(e).option("department-id",{alias:"d",type:"string",describe:"Department ID"}).option("query",{alias:"q",type:"string",demandOption:!0,describe:"Search string"}),handler:async e=>{try{let t=b(e),o={from:e.from,limit:e.limit,departmentId:e.departmentId,searchVal:e.query},r=await F({initialInput:o,fetchPage:n=>t.searchTags(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},Cy={command:"for-ticket <ticketId>",describe:"Get tags on a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketTags({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},Iy={command:"associate <ticketId>",describe:"Add tags to a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("tags",{type:"string",demandOption:!0,describe:"Comma-separated tag names"}),handler:async e=>{try{let t=b(e),o=e.tags.split(",").map(n=>n.trim()),r=await t.associateTicketTags({ticketId:e.ticketId,tags:o});l(r)}catch(t){m(t),process.exit(1)}}},Oy={command:"dissociate <ticketId>",describe:"Remove a tag from a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("tag-id",{type:"string",demandOption:!0,describe:"Tag ID to remove"}),handler:async e=>{try{await b(e).dissociateTicketTag({ticketId:e.ticketId,tagId:e.tagId}),l({removed:!0})}catch(t){m(t),process.exit(1)}}},Qc={command:"tags",describe:"Desk tag operations",builder:e=>e.command(Fy).command(Sy).command(Cy).command(Iy).command(Oy).demandCommand(1),handler:C};var My={command:"list <ticketId>",describe:"List comments on a ticket",builder:e=>k(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("sort-by",{type:"string",describe:"Sort field"}),handler:async e=>{try{let t=b(e),o={ticketId:e.ticketId,from:e.from,limit:e.limit,sortBy:e.sortBy},r=await F({initialInput:o,fetchPage:n=>t.getTicketComments(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},Py={command:"get <ticketId> <commentId>",describe:"Get a comment by ID",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).positional("commentId",{type:"string",demandOption:!0,describe:"Comment ID"}),handler:async e=>{try{let o=await b(e).getTicketCommentById({ticketId:e.ticketId,commentId:e.commentId});l(o)}catch(t){m(t),process.exit(1)}}},Ay={command:"create <ticketId>",describe:"Create a comment on a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("content",{type:"string",demandOption:!0,describe:"Comment content"}).option("public",{type:"boolean",default:!1,describe:"Make comment public"}).option("content-type",{type:"string",default:"plainText",choices:["plainText","html"],describe:"Content type"}),handler:async e=>{try{let o=await b(e).createTicketComment({ticketId:e.ticketId,content:e.content,isPublic:e.public,contentType:e.contentType});l(o)}catch(t){m(t),process.exit(1)}}},Ey={command:"delete <ticketId> <commentId>",describe:"Delete a comment",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).positional("commentId",{type:"string",demandOption:!0,describe:"Comment ID"}),handler:async e=>{try{await b(e).deleteTicketComment({ticketId:e.ticketId,commentId:e.commentId}),l({deleted:!0})}catch(t){m(t),process.exit(1)}}},eu={command:"comments",describe:"Desk comment operations",builder:e=>e.command(My).command(Py).command(Ay).command(Ey).demandCommand(1),handler:C};var ky={command:"list <ticketId>",describe:"List attachments on a ticket",builder:e=>k(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let t=b(e),o={ticketId:e.ticketId,from:e.from,limit:e.limit},r=await F({initialInput:o,fetchPage:n=>t.getTicketAttachments(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},Zy={command:"delete <ticketId> <attachmentId>",describe:"Delete an attachment",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).positional("attachmentId",{type:"string",demandOption:!0,describe:"Attachment ID"}),handler:async e=>{try{await b(e).deleteTicketAttachment({ticketId:e.ticketId,attachmentId:e.attachmentId}),l({deleted:!0})}catch(t){m(t),process.exit(1)}}},tu={command:"attachments",describe:"Desk attachment operations",builder:e=>e.command(ky).command(Zy).demandCommand(1),handler:C};var Dy={command:"list <ticketId>",describe:"List followers of a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketFollowers({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},Ly={command:"add <ticketId>",describe:"Add followers to a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("agent-ids",{type:"string",demandOption:!0,describe:"Comma-separated agent IDs"}),handler:async e=>{try{let t=b(e),o=e.agentIds.split(",").map(r=>r.trim());await t.addTicketFollowers({ticketId:e.ticketId,agentIds:o}),l({added:!0})}catch(t){m(t),process.exit(1)}}},vy={command:"remove <ticketId>",describe:"Remove followers from a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("agent-ids",{type:"string",demandOption:!0,describe:"Comma-separated agent IDs"}),handler:async e=>{try{let t=b(e),o=e.agentIds.split(",").map(r=>r.trim());await t.removeTicketFollowers({ticketId:e.ticketId,agentIds:o}),l({removed:!0})}catch(t){m(t),process.exit(1)}}},ou={command:"followers",describe:"Desk ticket follower operations",builder:e=>e.command(Dy).command(Ly).command(vy).demandCommand(1),handler:C};var Ny={command:"timer <ticketId>",describe:"Get current timer state for a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketTimer({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},_y={command:"timer-action <ticketId>",describe:"Start, pause, resume, or stop a timer",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("action",{type:"string",demandOption:!0,choices:["start","pause","resume","stop"],describe:"Timer action"}),handler:async e=>{try{let o=await b(e).performTicketTimerAction({ticketId:e.ticketId,timerAction:e.action});l(o)}catch(t){m(t),process.exit(1)}}},wy={command:"entries <ticketId>",describe:"List time entries for a ticket",builder:e=>k(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let t=b(e),o={ticketId:e.ticketId,from:e.from,limit:e.limit},r=await F({initialInput:o,fetchPage:n=>t.getTicketTimeEntries(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},Vy={command:"summation <ticketId>",describe:"Get time entry summation for a ticket",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let o=await b(e).getTicketTimeEntrySummation({ticketId:e.ticketId});l(o)}catch(t){m(t),process.exit(1)}}},ru={command:"time",describe:"Desk time tracking operations",builder:e=>e.command(Ny).command(_y).command(wy).command(Vy).demandCommand(1),handler:C};var Ky={command:"list <ticketId>",describe:"List threads on a ticket",builder:e=>k(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let t=b(e),o={ticketId:e.ticketId,from:e.from,limit:e.limit,include:e.include},r=await F({initialInput:o,fetchPage:n=>t.getTicketThreads(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},Uy={command:"get <ticketId> <threadId>",describe:"Get a thread by ID",builder:e=>e.positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}).positional("threadId",{type:"string",demandOption:!0,describe:"Thread ID"}).option("include",{type:"string",describe:"Comma-separated includes"}),handler:async e=>{try{let o=await b(e).getTicketThreadById({ticketId:e.ticketId,threadId:e.threadId,include:e.include});l(o)}catch(t){m(t),process.exit(1)}}},nu={command:"threads",describe:"Desk ticket thread operations",builder:e=>e.command(Ky).command(Uy).demandCommand(1),handler:C};var Wy={command:"list <ticketId>",describe:"List activities on a ticket",builder:e=>k(e).positional("ticketId",{type:"string",demandOption:!0,describe:"Ticket ID"}),handler:async e=>{try{let t=b(e),o={ticketId:e.ticketId,from:e.from,limit:e.limit},r=await F({initialInput:o,fetchPage:n=>t.getTicketActivities(n),adapter:Z,multiplePages:e.multiplePages,multiplePagesOutput:e.multiplePagesOutput,dumpOutput:e.dumpOutput,dumpMerge:e.dumpMerge});if(r.handled===!1){let n=r.result;l(n.data,{from:e.from,limit:e.limit,count:n.data?.length})}}catch(t){m(t),process.exit(1)}}},au={command:"activities",describe:"Desk ticket activity operations",builder:e=>e.command(Wy).demandCommand(1),handler:C};var iu={command:"desk",describe:"Zoho Desk operations",builder:e=>e.command(zc).command(Jc).command(Yc).command(Xc).command(Qc).command(eu).command(tu).command(ou).command(ru).command(nu).command(au).demandCommand(1,"Please specify a desk subcommand.").example([["$0 desk tickets list --limit 10","List first 10 tickets"],["$0 desk tickets get 12345","Get a ticket by ID"],["$0 desk agents my-info","Get current agent info"],['$0 desk comments create 12345 --content "Looking into this"',"Add a comment"]]),handler:C};var su={command:"request <product> <method> <path>",describe:"Make a raw API request through the authenticated context",builder:e=>e.positional("product",{type:"string",demandOption:!0,choices:["recruit","crm","desk"],describe:"Zoho product"}).positional("method",{type:"string",demandOption:!0,choices:["GET","POST","PUT","PATCH","DELETE"],describe:"HTTP method"}).positional("path",{type:"string",demandOption:!0,describe:"API path (relative to product base URL)"}).option("body",{type:"string",describe:"JSON request body"}).option("query",{type:"string",describe:"JSON query parameters"}).example([["$0 request recruit GET /v2/Candidates","List candidates via raw API"],[`$0 request desk GET /tickets --query '{"limit":5}'`,"List 5 desk tickets via raw API"],[`$0 request crm POST /v8/Contacts --body '{"data":[{"Last_Name":"Test"}]}'`,"Create a CRM contact via raw API"]]),handler:async e=>{try{let t=e.product,o=e.method,r=e.path,n;switch(t){case"recruit":n=H(e).recruitContext;break;case"crm":n=z(e).crmContext;break;case"desk":n=b(e).deskContext;break;default:throw new Error(`Unknown product: ${t}`)}let a=r;if(e.query){let c=JSON.parse(e.query),u=new URLSearchParams(c),p=a.includes("?")?"&":"?";a=`${a}${p}${u.toString()}`}let i={method:o};e.body&&(i.body=e.body,i.headers={"Content-Type":"application/json"});let s=await n.fetchJson(a,i);l(s)}catch(t){m(t),process.exit(1)}}};var By={command:"set",describe:"Configure output settings (global or per-command)",builder:e=>e.option("command",{alias:"c",type:"string",describe:"Command path to configure (e.g. desk.tickets.list)"}).check(t=>{if(!t.setDumpDir&&!t.setPick)throw new Error("At least one of --set-dump-dir or --set-pick is required");return!0}),handler:async e=>{try{let t=e.command,o=e.setDumpDir,r=e.setPick,n;if(t){let i={...o!==void 0?{dumpDir:o}:{},...r!==void 0?{pick:r}:{}};n={commands:{[t]:i}}}else n={...o!==void 0?{dumpDir:o}:{},...r!==void 0?{pick:r}:{}};let a=await G({output:n});l({saved:!0,output:a.output})}catch(t){m(t),process.exit(1)}}},Gy={command:"show",describe:"Show current output configuration",builder:e=>e,handler:async()=>{try{let e=await B();l({output:e?.output??{}})}catch(e){m(e),process.exit(1)}}},jy={command:"clear",describe:"Clear output configuration (global or per-command)",builder:e=>e.option("command",{alias:"c",type:"string",describe:"Command path to clear (omit to clear all output config)"}),handler:async e=>{try{let t=e.command;if(t){let o=await B(),r={...o?.output?.commands};delete r[t];let n={...o?.output,commands:r};await G({output:n}),l({cleared:!0,command:t})}else await cn(),l({cleared:!0})}catch(t){m(t),process.exit(1)}}},cu={command:"output",describe:"Configure output settings (dump, field filtering)",builder:e=>e.command(By).command(Gy).command(jy).demandCommand(1),handler:C};var Hy=[$c,Hc,iu,su],uu=[Bc,cu,Gc];function zy(e){return e.command.split(" ")[0]}var nn=new Set(uu.map(zy));function Jy(){return async e=>{let t=e._?e._.map(String):[],o=t[0],r=e.setDumpDir,n=e.setPick;if((r!==void 0||n!==void 0)&&o&&!nn.has(o)){let u=t.join("."),p={...r!==void 0?{dumpDir:r}:{},...n!==void 0?{pick:n}:{}};await G({output:{commands:{[u]:p}}})}let i=o&&!nn.has(o),s=await B(),c=i?sn(s?.output,t,{dumpDir:e.dumpDir??r,pick:e.pick??n}):{dumpDir:void 0,pick:void 0};Vc({dumpDir:c.dumpDir,pick:e.pickAll?void 0:c.pick,commandPath:t})}}async function Yy(){try{await qy($y(process.argv)).scriptName("zoho-cli").usage("$0 <command> [options]").option("verbose",{alias:"v",type:"boolean",default:!1,global:!0,describe:"Verbose output"}).option("dump-dir",{type:"string",global:!0,describe:"Directory to save full API responses as JSON files (overrides config)"}).option("pick",{type:"string",global:!0,describe:"Comma-separated top-level fields to include in output (overrides config)"}).option("set-dump-dir",{type:"string",global:!0,describe:"Save dump directory to config for this command and apply now"}).option("set-pick",{type:"string",global:!0,describe:"Save pick fields to config for this command and apply now"}).option("pick-all",{type:"boolean",global:!0,describe:"Ignore any configured pick filters and return full response data"}).middleware([jc(nn),Jy()],!0).command(uu).command(Hy).demandCommand(1,"Please specify a command. Use --help for available commands.").strict().fail(!1).help().alias("help","h").version(!1).wrap(Math.min(120,process.stdout.columns||80)).parse()}catch(e){m(e),process.exit(1)}}Yy();
|
package/cli/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/zoho/cli",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"zoho-cli": "./index.js"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/nestjs": "13.
|
|
10
|
-
"@dereekb/rxjs": "13.
|
|
11
|
-
"@dereekb/util": "13.
|
|
12
|
-
"@dereekb/zoho": "13.
|
|
13
|
-
"@dereekb/zoho/nestjs": "13.
|
|
9
|
+
"@dereekb/nestjs": "13.10.0",
|
|
10
|
+
"@dereekb/rxjs": "13.10.0",
|
|
11
|
+
"@dereekb/util": "13.10.0",
|
|
12
|
+
"@dereekb/zoho": "13.10.0",
|
|
13
|
+
"@dereekb/zoho/nestjs": "13.10.0",
|
|
14
14
|
"yargs": "^18.0.0"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
package/nestjs/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/zoho/nestjs",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.10.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/nestjs": "13.
|
|
6
|
-
"@dereekb/rxjs": "13.
|
|
7
|
-
"@dereekb/util": "13.
|
|
8
|
-
"@dereekb/zoho": "13.
|
|
5
|
+
"@dereekb/nestjs": "13.10.0",
|
|
6
|
+
"@dereekb/rxjs": "13.10.0",
|
|
7
|
+
"@dereekb/util": "13.10.0",
|
|
8
|
+
"@dereekb/zoho": "13.10.0",
|
|
9
9
|
"@nestjs/common": "^11.1.17",
|
|
10
10
|
"@nestjs/config": "^4.0.4",
|
|
11
11
|
"express": "^5.0.0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/zoho",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.10.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"zoho-cli": "./cli/index.js"
|
|
6
6
|
},
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@dereekb/nestjs": "13.
|
|
27
|
-
"@dereekb/rxjs": "13.
|
|
28
|
-
"@dereekb/util": "13.
|
|
26
|
+
"@dereekb/nestjs": "13.10.0",
|
|
27
|
+
"@dereekb/rxjs": "13.10.0",
|
|
28
|
+
"@dereekb/util": "13.10.0",
|
|
29
29
|
"@nestjs/common": "^11.1.17",
|
|
30
30
|
"@nestjs/config": "^4.0.4",
|
|
31
31
|
"express": "^5.0.0",
|