@ezpaarse-project/ezreeport-sdk-js 1.2.0-beta.1 → 1.2.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("axios"),oe="1.2.0-beta.1",N=6e4,P=36e5;function u(e,t){const n=(t==null?void 0:t.additionalDigits)??2,s=ue(e);let r;if(s.date){const p=le(s.date,n);r=pe(p.restDateString,p.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);const o=r.getTime();let a=0,l;if(s.time&&(a=de(s.time),isNaN(a)))return new Date(NaN);if(s.timezone){if(l=fe(s.timezone),isNaN(l))return new Date(NaN)}else{const p=new Date(o+a),d=new Date(0);return d.setFullYear(p.getUTCFullYear(),p.getUTCMonth(),p.getUTCDate()),d.setHours(p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds(),p.getUTCMilliseconds()),d}return new Date(o+a+l)}const _={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ae=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ie=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ce=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ue(e){const t={},n=e.split(_.dateTimeDelimiter);let s;if(n.length>2)return t;if(/:/.test(n[0])?s=n[0]:(t.date=n[0],s=n[1],_.timeZoneDelimiter.test(t.date)&&(t.date=e.split(_.timeZoneDelimiter)[0],s=e.substr(t.date.length,e.length))),s){const r=_.timezone.exec(s);r?(t.time=s.replace(r[1],""),t.timezone=r[1]):t.time=s}return t}function le(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),s=e.match(n);if(!s)return{year:NaN,restDateString:""};const r=s[1]?parseInt(s[1]):null,o=s[2]?parseInt(s[2]):null;return{year:o===null?r:o*100,restDateString:e.slice((s[1]||s[2]).length)}}function pe(e,t){if(t===null)return new Date(NaN);const n=e.match(ae);if(!n)return new Date(NaN);const s=!!n[4],r=h(n[1]),o=h(n[2])-1,a=h(n[3]),l=h(n[4]),p=h(n[5])-1;if(s)return he(t,l,p)?ge(t,l,p):new Date(NaN);{const d=new Date(0);return!me(t,o,a)||!ve(t,r)?new Date(NaN):(d.setUTCFullYear(t,o,Math.max(r,a)),d)}}function h(e){return e?parseInt(e):1}function de(e){const t=e.match(ie);if(!t)return NaN;const n=L(t[1]),s=L(t[2]),r=L(t[3]);return we(n,s,r)?n*P+s*N+r*1e3:NaN}function L(e){return e&&parseFloat(e.replace(",","."))||0}function fe(e){if(e==="Z")return 0;const t=e.match(ce);if(!t)return 0;const n=t[1]==="+"?-1:1,s=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return _e(s,r)?n*(s*P+r*N):NaN}function ge(e,t,n){const s=new Date(0);s.setUTCFullYear(e,0,4);const r=s.getUTCDay()||7,o=(t-1)*7+n+1-r;return s.setUTCDate(s.getUTCDate()+o),s}const ye=[31,null,31,30,31,30,31,31,30,31,30,31];function M(e){return e%400===0||e%4===0&&e%100!==0}function me(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(ye[t]||(M(e)?29:28))}function ve(e,t){return t>=1&&t<=(M(e)?366:365)}function he(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function we(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function _e(e,t){return t>=0&&t<=59}const U=x.create({headers:{"Content-Type":"application/json"}}),f=async(e,...t)=>{try{return await U[e](...t)}catch(n){if(!(n instanceof x.AxiosError)||!n.response)throw n;const s=n.response;let r="";switch(s.status){case 400:r="Check parameters or API token";break;case 401:r="You must be logged before using this function, use `auth.login(token)`";break;case 403:r="You dont have enough permissions";break;case 404:r="Check parameters";break;case 409:r="Request conflit with current state";break;case 500:r="Something went wrong with server";break}throw r=`${n.code} (${s.status}) - ${r}: ${s.data.content.message}`,new Error(r)}},i=Object.assign(U,{$get:async(...e)=>(await f("get",...e)).data,$post:async(...e)=>(await f("post",...e)).data,$put:async(...e)=>(await f("put",...e)).data,$patch:async(...e)=>(await f("patch",...e)).data,$delete:async(...e)=>(await f("delete",...e)).data}),Y=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),be=e=>({...e,namespace:Y(e.namespace),createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),$e=e=>({...e,memberships:(e==null?void 0:e.memberships.map(be))??[],createdAt:u(e.createdAt),updatedAt:e!=null&&e.updatedAt?u(e.updatedAt):void 0}),z=e=>{i.defaults.headers.common.authorization=`Bearer ${e}`},F=()=>{i.defaults.headers.common.authorization=void 0},W=()=>{const e=i.defaults.headers.common.authorization;if(!e||typeof e!="string")return!1;const[,t]=e.split("Bearer ");return!!t},Te=async()=>{const{content:e,...t}=await i.$get("/me");return{...t,content:$e(e)}},Le=()=>i.$get("/me/permissions"),Ae=()=>i.$get("/me/namespaces"),ke=Object.freeze(Object.defineProperty({__proto__:null,getCurrentNamespaces:Ae,getCurrentPermissions:Le,getCurrentUser:Te,isLogged:W,login:z,logout:F},Symbol.toStringTag,{value:"Module"})),m=e=>({...e,nextRun:e.nextRun?u(e.nextRun):void 0,lastRun:e.lastRun?u(e.lastRun):void 0}),Ee=async()=>{const{content:e,...t}=await i.$get("/crons");return{...t,content:e.map(m)}},Re=async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$get(`/crons/${t}`);return{...s,content:m(n)}},Ce=async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$put(`/crons/${t}/start`,{});return{...s,content:m(n)}},De=async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$put(`/crons/${t}/stop`,{});return{...s,content:m(n)}},Se=async e=>{const{name:t,...n}=e,{content:s,...r}=await i.$patch(`/crons/${t}`,n);return{...r,content:m(s)}},je=async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$post(`/crons/${t}/_force`,{});return{...s,content:m(n)}},xe=Object.freeze(Object.defineProperty({__proto__:null,forceCron:je,getAllCrons:Ee,getCron:Re,startCron:Ce,stopCron:De,updateCron:Se},Symbol.toStringTag,{value:"Module"})),J=()=>i.$get("/health"),Ne=()=>i.$get("/health/_all"),B=e=>i.$get(`/health/${e}`),Pe=async()=>{const{content:{current:e}}=await J();return B(e)},Me=Object.freeze(Object.defineProperty({__proto__:null,checkAllConnectedService:Ne,checkConnectedService:B,checkCurrentService:Pe,getAllConnectedServices:J},Symbol.toStringTag,{value:"Module"}));var O=(e=>(e.DAILY="DAILY",e.WEEKLY="WEEKLY",e.MONTHLY="MONTHLY",e.QUARTERLY="QUARTERLY",e.BIENNIAL="BIENNIAL",e.YEARLY="YEARLY",e))(O||{});const $=e=>({...e,nextRun:u(e.nextRun),lastRun:e.lastRun?u(e.lastRun):void 0,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),Q=e=>{const{namespace:t,...n}=e,{namespaceId:s,...r}=$({namespaceId:t.id,...n});return{...r,namespace:Y(t)}},Ue=e=>({...e,createdAt:u(e.createdAt)}),Ye=e=>({...e,task:Q(e.task),createdAt:u(e.createdAt)}),ze=async(e,t)=>{const{data:{content:n,...s}}=await f("get","/tasks-activity",{params:{namespaces:t,...e??{}}});return{...s,content:n.map(Ye)}},q=Object.freeze(Object.defineProperty({__proto__:null,getAllEntries:ze},Symbol.toStringTag,{value:"Module"})),Fe=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),A=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),We=async()=>{const{content:e,...t}=await i.$get("/tasks-presets");return{...t,content:e.map(Fe)}},Je=async e=>{const t=typeof e=="string"?e:e.id,{content:n,...s}=await i.$get(`/tasks-presets/${t}`);return{...s,content:A(n)}},Be=async e=>{const{content:t,...n}=await i.$post("/tasks-presets/",e);return{...n,content:A(t)}},Oe=async e=>{const{id:t,...n}=e,{content:s,...r}=await i.$put(`/tasks-presets/${t}`,n);return{...r,content:A(s)}},Qe=async e=>{const t=typeof e=="string"?e:e.id;await i.$delete(`/tasks-presets/${t}`)},qe=Object.freeze(Object.defineProperty({__proto__:null,createTasksPreset:Be,deleteTasksPreset:Qe,getAllTasksPresets:We,getTasksPreset:Je,upsertTasksPreset:Oe},Symbol.toStringTag,{value:"Module"})),Ke=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),k=e=>({...e,added:u(e.added),started:e.started?u(e.started):void 0,ended:e.ended?u(e.ended):void 0}),He=()=>i.$get("/queues"),Ze=async e=>{const t=typeof e=="string"?e:e.name;return i.$get(`/queues/${t}`)},Ge=async e=>{const{name:t,...n}=e;return i.$patch(`/queues/${t}`,n)},Ie=async e=>{const t=typeof e=="string"?e:e.name;return i.$put(`/queues/${t}/pause`)},Ve=async e=>{const t=typeof e=="string"?e:e.name;return i.$put(`/queues/${t}/resume`)},Xe=async(e,t)=>{const n=typeof e=="string"?e:e.name,{data:{content:s,...r}}=await f("get",`/queues/${n}/jobs`,{params:t});return{...r,content:s.map(k)}},w=async(e,t,n)=>{const s=typeof e=="string"?e:e.name,r=typeof t=="string"||typeof t=="number"?t:t.id,{content:o,...a}=await i.$get(`/queues/${s}/jobs/${r}`,{params:{namespaces:n}});return{...a,content:k(o)}},et=async(e,t,n)=>{const s=typeof e=="string"?e:e.name,r=typeof t=="string"||typeof t=="number"?t:t.id,{content:o,...a}=await i.$post(`/queues/${s}/jobs/${r}/_retry`,{params:{namespaces:n}});return{...a,content:k(o)}},tt=Object.freeze(Object.defineProperty({__proto__:null,getAllQueues:He,getJob:w,getQueue:Ze,getQueueJobs:Xe,pauseQueue:Ie,resumeQueue:Ve,retryJob:et,updateQueue:Ge},Symbol.toStringTag,{value:"Module"}));function nt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E={exports:{}},y=typeof Reflect=="object"?Reflect:null,S=y&&typeof y.apply=="function"?y.apply:function(t,n,s){return Function.prototype.apply.call(t,n,s)},b;y&&typeof y.ownKeys=="function"?b=y.ownKeys:Object.getOwnPropertySymbols?b=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:b=function(t){return Object.getOwnPropertyNames(t)};function st(e){console&&console.warn&&console.warn(e)}var K=Number.isNaN||function(t){return t!==t};function c(){c.init.call(this)}E.exports=c;E.exports.once=it;c.EventEmitter=c;c.prototype._events=void 0;c.prototype._eventsCount=0;c.prototype._maxListeners=void 0;var j=10;function T(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return j},set:function(e){if(typeof e!="number"||e<0||K(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");j=e}});c.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};c.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||K(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function H(e){return e._maxListeners===void 0?c.defaultMaxListeners:e._maxListeners}c.prototype.getMaxListeners=function(){return H(this)};c.prototype.emit=function(t){for(var n=[],s=1;s<arguments.length;s++)n.push(arguments[s]);var r=t==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var l=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw l.context=a,l}var p=o[t];if(p===void 0)return!1;if(typeof p=="function")S(p,this,n);else for(var d=p.length,re=X(p,d),s=0;s<d;++s)S(re[s],this,n);return!0};function Z(e,t,n,s){var r,o,a;if(T(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),a===void 0)a=o[t]=n,++e._eventsCount;else if(typeof a=="function"?a=o[t]=s?[n,a]:[a,n]:s?a.unshift(n):a.push(n),r=H(e),r>0&&a.length>r&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,st(l)}return e}c.prototype.addListener=function(t,n){return Z(this,t,n,!1)};c.prototype.on=c.prototype.addListener;c.prototype.prependListener=function(t,n){return Z(this,t,n,!0)};function rt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function G(e,t,n){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=rt.bind(s);return r.listener=n,s.wrapFn=r,r}c.prototype.once=function(t,n){return T(n),this.on(t,G(this,t,n)),this};c.prototype.prependOnceListener=function(t,n){return T(n),this.prependListener(t,G(this,t,n)),this};c.prototype.removeListener=function(t,n){var s,r,o,a,l;if(T(n),r=this._events,r===void 0)return this;if(s=r[t],s===void 0)return this;if(s===n||s.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,s.listener||n));else if(typeof s!="function"){for(o=-1,a=s.length-1;a>=0;a--)if(s[a]===n||s[a].listener===n){l=s[a].listener,o=a;break}if(o<0)return this;o===0?s.shift():ot(s,o),s.length===1&&(r[t]=s[0]),r.removeListener!==void 0&&this.emit("removeListener",t,l||n)}return this};c.prototype.off=c.prototype.removeListener;c.prototype.removeAllListeners=function(t){var n,s,r;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[t]),this;if(arguments.length===0){var o=Object.keys(s),a;for(r=0;r<o.length;++r)a=o[r],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=s[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(r=n.length-1;r>=0;r--)this.removeListener(t,n[r]);return this};function I(e,t,n){var s=e._events;if(s===void 0)return[];var r=s[t];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?at(r):X(r,r.length)}c.prototype.listeners=function(t){return I(this,t,!0)};c.prototype.rawListeners=function(t){return I(this,t,!1)};c.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):V.call(e,t)};c.prototype.listenerCount=V;function V(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?b(this._events):[]};function X(e,t){for(var n=new Array(t),s=0;s<t;++s)n[s]=e[s];return n}function ot(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function at(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function it(e,t){return new Promise(function(n,s){function r(a){e.removeListener(t,o),s(a)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",r),n([].slice.call(arguments))}ee(e,t,o,{once:!0}),t!=="error"&&ct(e,r,{once:!0})})}function ct(e,t,n){typeof e.on=="function"&&ee(e,"error",t,n)}function ee(e,t,n,s){if(typeof e.on=="function")s.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function r(o){s.once&&e.removeEventListener(t,r),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var ut=E.exports;const lt=nt(ut),pt=(e,t=new lt)=>{const n={emit:(o,...a)=>(t.emit(o.toString(),...a),n)},s=e(n),r=Object.assign(s,{on:(o,a)=>(t.on(o.toString(),(...l)=>a(...l)),r),once:(o,a)=>(t.once(o.toString(),(...l)=>a(...l)),r),off:(o,a)=>(t.off(o.toString(),(...l)=>a(...l)),r)});return r},dt=e=>new Promise(t=>{setTimeout(t,e)}),ft=e=>({start:u(e.start),end:u(e.end)}),gt=e=>({...e,createdAt:u(e.createdAt),destroyAt:u(e.destroyAt),period:e.period?ft(e.period):void 0}),R=e=>({...e,detail:gt(e.detail)}),te=(e,t,n)=>{var r,o;const s=typeof e=="string"?e:e.id;return i.$post(`/tasks/${s}/_run`,null,{params:{test_emails:t==null?void 0:t.testEmails,period_start:(r=t==null?void 0:t.period)==null?void 0:r.start,period_end:(o=t==null?void 0:t.period)==null?void 0:o.end,namespaces:n}})},yt=(...e)=>pt(async t=>{const{content:{id:n,queue:s}}=await te(...e);t.emit("started",{id:n,queue:s});let r;do{const{content:{progress:o,status:a,result:l}}=await w(s,n,e[2]);r={progress:o,status:a,result:l},t.emit("progress",{progress:o,status:a});let p=1e3;r.status==="active"&&(p=250),await dt(p)}while(["completed","failed","stuck"].includes(r.status)===!1);if(!r.result)throw new Error("Generation failed with weird error");return R(r.result)}),v=async(e,t,n)=>(await f("get",`/reports/${e}`,{responseType:n,params:{namespaces:t}})).data,mt=(e,t,n,s="pdf")=>v(`${e}.rep.${s}`,t,n),vt=async(e,t,n,s)=>{var o;const{content:{result:r}}=await w(e,t,n);if(!r)throw new Error("Job have no result");return v(((o=r.detail)==null?void 0:o.files.report)??"",n,s)},ht=async(e,t,n)=>{const s=await v(`${e}.det.json`,t,n);return!n||n==="json"?R(s):s},wt=async(e,t,n,s)=>{var a;const{content:{result:r}}=await w(e,t,n);if(!r)throw new Error("Job have no result");const o=await v(((a=r.detail)==null?void 0:a.files.detail)??"",n,s);return!s||s==="json"?R(o):o},_t=(e,t,n)=>v(`${e}.deb.json`,t,n),bt=async(e,t,n,s)=>{var o;const{content:{result:r}}=await w(e,t,n);if(!r)throw new Error("Job have no result");return v(((o=r.detail)==null?void 0:o.files.debug)??"",n,s)},$t=Object.freeze(Object.defineProperty({__proto__:null,getReportDebugByJob:bt,getReportDebugByName:_t,getReportDetailByJob:wt,getReportDetailByName:ht,getReportFileByJob:vt,getReportFileByName:mt,startAndListenGeneration:yt,startGeneration:te},Symbol.toStringTag,{value:"Module"})),Tt=e=>{i.defaults.baseURL=e},Lt=()=>{i.defaults.baseURL=void 0},At=()=>!!i.defaults.baseURL,kt=Object.freeze(Object.defineProperty({__proto__:null,isLogged:W,isURLset:At,login:z,logout:F,setURL:Tt,unsetURL:Lt},Symbol.toStringTag,{value:"Module"})),C=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),D=e=>{const{body:t,tasks:n,...s}=e;return{...C(s),tasks:n.map($),body:t}},Et=async()=>{const{content:e,...t}=await i.$get("/templates");return{...t,content:e.map(C)}},Rt=async e=>{const t=typeof e=="string"?e:e.id,{content:n,...s}=await i.$get(`/templates/${t}`);return{...s,content:D(n)}},Ct=async e=>{const{content:t,...n}=await i.$post("/templates",e);return{...n,content:D(t)}},ne=async e=>{const{id:t,...n}=e,{content:s,...r}=await i.$put(`/templates/${t}`,n);return{...r,content:D(s)}},Dt=ne,St=async e=>{const t=typeof e=="string"?e:e.id;await i.$delete(`/templates/${t}`)},g=e=>{const{activity:t,template:n,targets:s,extends:r,...o}=e;return{...Q(o),extends:C(r),activity:t.map(Ue),template:n,targets:s}},jt=async(e,t)=>{const{data:{content:n,...s}}=await f("get","/tasks",{params:{namespaces:t,...e??{}}});return{...s,content:n.map(({tags:r,_count:o,...a})=>({tags:r,_count:o,...$(a)}))}},xt=e=>i.$get("/tasks/_targets",{params:{namespaces:e}}),Nt=async(e,t)=>{const{content:n,...s}=await i.$get(`/tasks/_targets/${e}/tasks`,{params:{namespaces:t}});return{...s,content:n.map(({tags:r,...o})=>({tags:r,...$(o)}))}},Pt=async(e,t,n)=>{const s=typeof t=="string"?t:t.id;await i.$delete(`/tasks/_targets/${e}/tasks/${s}`,{params:{namespaces:n}})},Mt=async(e,t)=>{const{content:n,...s}=await i.$post("/tasks",e,{params:{namespaces:t}});return{...s,content:g(n)}},Ut=async(e,t,n)=>{const{content:s,...r}=await i.$post(`/tasks/_from-preset/${e}`,t,{params:{namespaces:n}});return{...r,content:g(s)}},Yt=async(e,t)=>{const n=typeof e=="string"?e:e.id,{content:s,...r}=await i.$get(`/tasks/${n}`,{params:{namespaces:t}});return{...r,content:g(s)}},se=async(e,t)=>{const{id:n,...s}=e,{content:r,...o}=await i.$put(`/tasks/${n}`,s,{params:{namespaces:t}});return{...o,content:g(r)}},zt=se,Ft=async(e,t)=>{const n=typeof e=="string"?e:e.id;await i.$delete(`/tasks/${n}`,{params:{namespaces:t}})},Wt=async(e,t)=>{const n=typeof e=="string"?e:e.id,{content:s,...r}=await i.$put(`/tasks/${n}/_enable`,void 0,{params:{namespaces:t}});return{...r,content:g(s)}},Jt=async(e,t)=>{const n=typeof e=="string"?e:e.id,{content:s,...r}=await i.$put(`/tasks/${n}/_disable`,void 0,{params:{namespaces:t}});return{...r,content:g(s)}},Bt=async(e,t,n)=>{const s=typeof e=="string"?e:e.id,r=typeof t=="string"?t:t.id,{content:o,...a}=await i.$put(`/tasks/${s}/_link/${r}`,void 0,{params:{namespaces:n}});return{...a,content:g(o)}},Ot=async(e,t,n)=>{const s=typeof e=="string"?e:e.id,r=typeof t=="string"?t:t.id;await i.$delete(`/tasks/${s}/_link/${r}`,{params:{namespaces:n}})},Qt=Object.freeze(Object.defineProperty({__proto__:null,Recurrence:O,createTask:Mt,createTaskFromPreset:Ut,deleteTask:Ft,disableTask:Jt,enableTask:Wt,getAllTargets:xt,getAllTasks:jt,getTask:Yt,getTasksOfTarget:Nt,linkTaskToTemplate:Bt,unlinkTaskToTemplate:Ot,unsubTargetOfTask:Pt,updateTask:zt,upsertTask:se},Symbol.toStringTag,{value:"Module"})),qt=Object.freeze(Object.defineProperty({__proto__:null,createTemplate:Ct,deleteTemplate:St,getAllTemplates:Et,getTemplate:Rt,updateTemplate:Dt,upsertTemplate:ne},Symbol.toStringTag,{value:"Module"})),Kt=e=>i.$get("/elastic/indices",{params:{namespace:e}}),Ht=(e,t)=>i.$get(`/elastic/indices/${e}`,{params:{namespace:t}}),Zt=(e,t)=>i.$get(`/elastic/indices/_resolve/${e}`,{params:{namespace:t}}),Gt=Object.freeze(Object.defineProperty({__proto__:null,getAllIndices:Kt,getIndexMapping:Ht,resolveIndex:Zt},Symbol.toStringTag,{value:"Module"})),It=oe;exports.auth=ke;exports.crons=xe;exports.elastic=Gt;exports.health=Me;exports.history=q;exports.namespaces=Ke;exports.queues=tt;exports.reports=$t;exports.setup=kt;exports.tasks=Qt;exports.tasksActivity=q;exports.tasksPresets=qe;exports.templates=qt;exports.version=It;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("axios"),oe="1.2.0-rc.1",N=6e4,P=36e5;function u(e,t){const n=(t==null?void 0:t.additionalDigits)??2,s=ue(e);let r;if(s.date){const p=le(s.date,n);r=pe(p.restDateString,p.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);const o=r.getTime();let a=0,l;if(s.time&&(a=de(s.time),isNaN(a)))return new Date(NaN);if(s.timezone){if(l=fe(s.timezone),isNaN(l))return new Date(NaN)}else{const p=new Date(o+a),d=new Date(0);return d.setFullYear(p.getUTCFullYear(),p.getUTCMonth(),p.getUTCDate()),d.setHours(p.getUTCHours(),p.getUTCMinutes(),p.getUTCSeconds(),p.getUTCMilliseconds()),d}return new Date(o+a+l)}const _={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},ae=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,ie=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ce=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ue(e){const t={},n=e.split(_.dateTimeDelimiter);let s;if(n.length>2)return t;if(/:/.test(n[0])?s=n[0]:(t.date=n[0],s=n[1],_.timeZoneDelimiter.test(t.date)&&(t.date=e.split(_.timeZoneDelimiter)[0],s=e.substr(t.date.length,e.length))),s){const r=_.timezone.exec(s);r?(t.time=s.replace(r[1],""),t.timezone=r[1]):t.time=s}return t}function le(e,t){const n=new RegExp("^(?:(\\d{4}|[+-]\\d{"+(4+t)+"})|(\\d{2}|[+-]\\d{"+(2+t)+"})$)"),s=e.match(n);if(!s)return{year:NaN,restDateString:""};const r=s[1]?parseInt(s[1]):null,o=s[2]?parseInt(s[2]):null;return{year:o===null?r:o*100,restDateString:e.slice((s[1]||s[2]).length)}}function pe(e,t){if(t===null)return new Date(NaN);const n=e.match(ae);if(!n)return new Date(NaN);const s=!!n[4],r=h(n[1]),o=h(n[2])-1,a=h(n[3]),l=h(n[4]),p=h(n[5])-1;if(s)return he(t,l,p)?ge(t,l,p):new Date(NaN);{const d=new Date(0);return!me(t,o,a)||!ve(t,r)?new Date(NaN):(d.setUTCFullYear(t,o,Math.max(r,a)),d)}}function h(e){return e?parseInt(e):1}function de(e){const t=e.match(ie);if(!t)return NaN;const n=L(t[1]),s=L(t[2]),r=L(t[3]);return we(n,s,r)?n*P+s*N+r*1e3:NaN}function L(e){return e&&parseFloat(e.replace(",","."))||0}function fe(e){if(e==="Z")return 0;const t=e.match(ce);if(!t)return 0;const n=t[1]==="+"?-1:1,s=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return _e(s,r)?n*(s*P+r*N):NaN}function ge(e,t,n){const s=new Date(0);s.setUTCFullYear(e,0,4);const r=s.getUTCDay()||7,o=(t-1)*7+n+1-r;return s.setUTCDate(s.getUTCDate()+o),s}const ye=[31,null,31,30,31,30,31,31,30,31,30,31];function M(e){return e%400===0||e%4===0&&e%100!==0}function me(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(ye[t]||(M(e)?29:28))}function ve(e,t){return t>=1&&t<=(M(e)?366:365)}function he(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function we(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function _e(e,t){return t>=0&&t<=59}const U=x.create({headers:{"Content-Type":"application/json"}}),f=async(e,...t)=>{try{return await U[e](...t)}catch(n){if(!(n instanceof x.AxiosError)||!n.response)throw n;const s=n.response;let r="";switch(s.status){case 400:r="Check parameters or API token";break;case 401:r="You must be logged before using this function, use `auth.login(token)`";break;case 403:r="You dont have enough permissions";break;case 404:r="Check parameters";break;case 409:r="Request conflit with current state";break;case 500:r="Something went wrong with server";break}throw r=`${n.code} (${s.status}) - ${r}: ${s.data.content.message}`,new Error(r)}},i=Object.assign(U,{$get:async(...e)=>(await f("get",...e)).data,$post:async(...e)=>(await f("post",...e)).data,$put:async(...e)=>(await f("put",...e)).data,$patch:async(...e)=>(await f("patch",...e)).data,$delete:async(...e)=>(await f("delete",...e)).data}),Y=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),be=e=>({...e,namespace:Y(e.namespace),createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),$e=e=>({...e,memberships:(e==null?void 0:e.memberships.map(be))??[],createdAt:u(e.createdAt),updatedAt:e!=null&&e.updatedAt?u(e.updatedAt):void 0}),z=e=>{i.defaults.headers.common.authorization=`Bearer ${e}`},F=()=>{i.defaults.headers.common.authorization=void 0},W=()=>{const e=i.defaults.headers.common.authorization;if(!e||typeof e!="string")return!1;const[,t]=e.split("Bearer ");return!!t},Te=async()=>{const{content:e,...t}=await i.$get("/me");return{...t,content:$e(e)}},Le=()=>i.$get("/me/permissions"),Ae=()=>i.$get("/me/namespaces"),ke=Object.freeze(Object.defineProperty({__proto__:null,getCurrentNamespaces:Ae,getCurrentPermissions:Le,getCurrentUser:Te,isLogged:W,login:z,logout:F},Symbol.toStringTag,{value:"Module"})),m=e=>({...e,nextRun:e.nextRun?u(e.nextRun):void 0,lastRun:e.lastRun?u(e.lastRun):void 0}),Ee=async()=>{const{content:e,...t}=await i.$get("/crons");return{...t,content:e.map(m)}},Re=async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$get(`/crons/${t}`);return{...s,content:m(n)}},Ce=async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$put(`/crons/${t}/start`,{});return{...s,content:m(n)}},De=async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$put(`/crons/${t}/stop`,{});return{...s,content:m(n)}},Se=async e=>{const{name:t,...n}=e,{content:s,...r}=await i.$patch(`/crons/${t}`,n);return{...r,content:m(s)}},je=async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$post(`/crons/${t}/_force`,{});return{...s,content:m(n)}},xe=Object.freeze(Object.defineProperty({__proto__:null,forceCron:je,getAllCrons:Ee,getCron:Re,startCron:Ce,stopCron:De,updateCron:Se},Symbol.toStringTag,{value:"Module"})),J=()=>i.$get("/health"),Ne=()=>i.$get("/health/_all"),B=e=>i.$get(`/health/${e}`),Pe=async()=>{const{content:{current:e}}=await J();return B(e)},Me=Object.freeze(Object.defineProperty({__proto__:null,checkAllConnectedService:Ne,checkConnectedService:B,checkCurrentService:Pe,getAllConnectedServices:J},Symbol.toStringTag,{value:"Module"}));var O=(e=>(e.DAILY="DAILY",e.WEEKLY="WEEKLY",e.MONTHLY="MONTHLY",e.QUARTERLY="QUARTERLY",e.BIENNIAL="BIENNIAL",e.YEARLY="YEARLY",e))(O||{});const $=e=>({...e,nextRun:u(e.nextRun),lastRun:e.lastRun?u(e.lastRun):void 0,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),Q=e=>{const{namespace:t,...n}=e,{namespaceId:s,...r}=$({namespaceId:t.id,...n});return{...r,namespace:Y(t)}},Ue=e=>({...e,createdAt:u(e.createdAt)}),Ye=e=>({...e,task:Q(e.task),createdAt:u(e.createdAt)}),ze=async(e,t)=>{const{data:{content:n,...s}}=await f("get","/tasks-activity",{params:{namespaces:t,...e??{}}});return{...s,content:n.map(Ye)}},q=Object.freeze(Object.defineProperty({__proto__:null,getAllEntries:ze},Symbol.toStringTag,{value:"Module"})),Fe=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),A=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),We=async()=>{const{content:e,...t}=await i.$get("/tasks-presets");return{...t,content:e.map(Fe)}},Je=async e=>{const t=typeof e=="string"?e:e.id,{content:n,...s}=await i.$get(`/tasks-presets/${t}`);return{...s,content:A(n)}},Be=async e=>{const{content:t,...n}=await i.$post("/tasks-presets/",e);return{...n,content:A(t)}},Oe=async e=>{const{id:t,...n}=e,{content:s,...r}=await i.$put(`/tasks-presets/${t}`,n);return{...r,content:A(s)}},Qe=async e=>{const t=typeof e=="string"?e:e.id;await i.$delete(`/tasks-presets/${t}`)},qe=Object.freeze(Object.defineProperty({__proto__:null,createTasksPreset:Be,deleteTasksPreset:Qe,getAllTasksPresets:We,getTasksPreset:Je,upsertTasksPreset:Oe},Symbol.toStringTag,{value:"Module"})),Ke=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),k=e=>({...e,added:u(e.added),started:e.started?u(e.started):void 0,ended:e.ended?u(e.ended):void 0}),He=()=>i.$get("/queues"),Ze=async e=>{const t=typeof e=="string"?e:e.name;return i.$get(`/queues/${t}`)},Ge=async e=>{const{name:t,...n}=e;return i.$patch(`/queues/${t}`,n)},Ie=async e=>{const t=typeof e=="string"?e:e.name;return i.$put(`/queues/${t}/pause`)},Ve=async e=>{const t=typeof e=="string"?e:e.name;return i.$put(`/queues/${t}/resume`)},Xe=async(e,t)=>{const n=typeof e=="string"?e:e.name,{data:{content:s,...r}}=await f("get",`/queues/${n}/jobs`,{params:t});return{...r,content:s.map(k)}},w=async(e,t,n)=>{const s=typeof e=="string"?e:e.name,r=typeof t=="string"||typeof t=="number"?t:t.id,{content:o,...a}=await i.$get(`/queues/${s}/jobs/${r}`,{params:{namespaces:n}});return{...a,content:k(o)}},et=async(e,t,n)=>{const s=typeof e=="string"?e:e.name,r=typeof t=="string"||typeof t=="number"?t:t.id,{content:o,...a}=await i.$post(`/queues/${s}/jobs/${r}/_retry`,{params:{namespaces:n}});return{...a,content:k(o)}},tt=Object.freeze(Object.defineProperty({__proto__:null,getAllQueues:He,getJob:w,getQueue:Ze,getQueueJobs:Xe,pauseQueue:Ie,resumeQueue:Ve,retryJob:et,updateQueue:Ge},Symbol.toStringTag,{value:"Module"}));function nt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E={exports:{}},y=typeof Reflect=="object"?Reflect:null,S=y&&typeof y.apply=="function"?y.apply:function(t,n,s){return Function.prototype.apply.call(t,n,s)},b;y&&typeof y.ownKeys=="function"?b=y.ownKeys:Object.getOwnPropertySymbols?b=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:b=function(t){return Object.getOwnPropertyNames(t)};function st(e){console&&console.warn&&console.warn(e)}var K=Number.isNaN||function(t){return t!==t};function c(){c.init.call(this)}E.exports=c;E.exports.once=it;c.EventEmitter=c;c.prototype._events=void 0;c.prototype._eventsCount=0;c.prototype._maxListeners=void 0;var j=10;function T(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return j},set:function(e){if(typeof e!="number"||e<0||K(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");j=e}});c.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};c.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||K(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function H(e){return e._maxListeners===void 0?c.defaultMaxListeners:e._maxListeners}c.prototype.getMaxListeners=function(){return H(this)};c.prototype.emit=function(t){for(var n=[],s=1;s<arguments.length;s++)n.push(arguments[s]);var r=t==="error",o=this._events;if(o!==void 0)r=r&&o.error===void 0;else if(!r)return!1;if(r){var a;if(n.length>0&&(a=n[0]),a instanceof Error)throw a;var l=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw l.context=a,l}var p=o[t];if(p===void 0)return!1;if(typeof p=="function")S(p,this,n);else for(var d=p.length,re=X(p,d),s=0;s<d;++s)S(re[s],this,n);return!0};function Z(e,t,n,s){var r,o,a;if(T(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),a=o[t]),a===void 0)a=o[t]=n,++e._eventsCount;else if(typeof a=="function"?a=o[t]=s?[n,a]:[a,n]:s?a.unshift(n):a.push(n),r=H(e),r>0&&a.length>r&&!a.warned){a.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=t,l.count=a.length,st(l)}return e}c.prototype.addListener=function(t,n){return Z(this,t,n,!1)};c.prototype.on=c.prototype.addListener;c.prototype.prependListener=function(t,n){return Z(this,t,n,!0)};function rt(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function G(e,t,n){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=rt.bind(s);return r.listener=n,s.wrapFn=r,r}c.prototype.once=function(t,n){return T(n),this.on(t,G(this,t,n)),this};c.prototype.prependOnceListener=function(t,n){return T(n),this.prependListener(t,G(this,t,n)),this};c.prototype.removeListener=function(t,n){var s,r,o,a,l;if(T(n),r=this._events,r===void 0)return this;if(s=r[t],s===void 0)return this;if(s===n||s.listener===n)--this._eventsCount===0?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,s.listener||n));else if(typeof s!="function"){for(o=-1,a=s.length-1;a>=0;a--)if(s[a]===n||s[a].listener===n){l=s[a].listener,o=a;break}if(o<0)return this;o===0?s.shift():ot(s,o),s.length===1&&(r[t]=s[0]),r.removeListener!==void 0&&this.emit("removeListener",t,l||n)}return this};c.prototype.off=c.prototype.removeListener;c.prototype.removeAllListeners=function(t){var n,s,r;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[t]),this;if(arguments.length===0){var o=Object.keys(s),a;for(r=0;r<o.length;++r)a=o[r],a!=="removeListener"&&this.removeAllListeners(a);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(n=s[t],typeof n=="function")this.removeListener(t,n);else if(n!==void 0)for(r=n.length-1;r>=0;r--)this.removeListener(t,n[r]);return this};function I(e,t,n){var s=e._events;if(s===void 0)return[];var r=s[t];return r===void 0?[]:typeof r=="function"?n?[r.listener||r]:[r]:n?at(r):X(r,r.length)}c.prototype.listeners=function(t){return I(this,t,!0)};c.prototype.rawListeners=function(t){return I(this,t,!1)};c.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):V.call(e,t)};c.prototype.listenerCount=V;function V(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n=="function")return 1;if(n!==void 0)return n.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?b(this._events):[]};function X(e,t){for(var n=new Array(t),s=0;s<t;++s)n[s]=e[s];return n}function ot(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function at(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function it(e,t){return new Promise(function(n,s){function r(a){e.removeListener(t,o),s(a)}function o(){typeof e.removeListener=="function"&&e.removeListener("error",r),n([].slice.call(arguments))}ee(e,t,o,{once:!0}),t!=="error"&&ct(e,r,{once:!0})})}function ct(e,t,n){typeof e.on=="function"&&ee(e,"error",t,n)}function ee(e,t,n,s){if(typeof e.on=="function")s.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener=="function")e.addEventListener(t,function r(o){s.once&&e.removeEventListener(t,r),n(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var ut=E.exports;const lt=nt(ut),pt=(e,t=new lt)=>{const n={emit:(o,...a)=>(t.emit(o.toString(),...a),n)},s=e(n),r=Object.assign(s,{on:(o,a)=>(t.on(o.toString(),(...l)=>a(...l)),r),once:(o,a)=>(t.once(o.toString(),(...l)=>a(...l)),r),off:(o,a)=>(t.off(o.toString(),(...l)=>a(...l)),r)});return r},dt=e=>new Promise(t=>{setTimeout(t,e)}),ft=e=>({start:u(e.start),end:u(e.end)}),gt=e=>({...e,createdAt:u(e.createdAt),destroyAt:u(e.destroyAt),period:e.period?ft(e.period):void 0}),R=e=>({...e,detail:gt(e.detail)}),te=(e,t,n)=>{var r,o;const s=typeof e=="string"?e:e.id;return i.$post(`/tasks/${s}/_run`,null,{params:{test_emails:t==null?void 0:t.testEmails,period_start:(r=t==null?void 0:t.period)==null?void 0:r.start,period_end:(o=t==null?void 0:t.period)==null?void 0:o.end,namespaces:n}})},yt=(...e)=>pt(async t=>{const{content:{id:n,queue:s}}=await te(...e);t.emit("started",{id:n,queue:s});let r;do{const{content:{progress:o,status:a,result:l}}=await w(s,n,e[2]);r={progress:o,status:a,result:l},t.emit("progress",{progress:o,status:a});let p=1e3;r.status==="active"&&(p=250),await dt(p)}while(["completed","failed","stuck"].includes(r.status)===!1);if(!r.result)throw new Error("Generation failed with weird error");return R(r.result)}),v=async(e,t,n)=>(await f("get",`/reports/${e}`,{responseType:n,params:{namespaces:t}})).data,mt=(e,t,n,s="pdf")=>v(`${e}.rep.${s}`,t,n),vt=async(e,t,n,s)=>{var o;const{content:{result:r}}=await w(e,t,n);if(!r)throw new Error("Job have no result");return v(((o=r.detail)==null?void 0:o.files.report)??"",n,s)},ht=async(e,t,n)=>{const s=await v(`${e}.det.json`,t,n);return!n||n==="json"?R(s):s},wt=async(e,t,n,s)=>{var a;const{content:{result:r}}=await w(e,t,n);if(!r)throw new Error("Job have no result");const o=await v(((a=r.detail)==null?void 0:a.files.detail)??"",n,s);return!s||s==="json"?R(o):o},_t=(e,t,n)=>v(`${e}.deb.json`,t,n),bt=async(e,t,n,s)=>{var o;const{content:{result:r}}=await w(e,t,n);if(!r)throw new Error("Job have no result");return v(((o=r.detail)==null?void 0:o.files.debug)??"",n,s)},$t=Object.freeze(Object.defineProperty({__proto__:null,getReportDebugByJob:bt,getReportDebugByName:_t,getReportDetailByJob:wt,getReportDetailByName:ht,getReportFileByJob:vt,getReportFileByName:mt,startAndListenGeneration:yt,startGeneration:te},Symbol.toStringTag,{value:"Module"})),Tt=e=>{i.defaults.baseURL=e},Lt=()=>{i.defaults.baseURL=void 0},At=()=>!!i.defaults.baseURL,kt=Object.freeze(Object.defineProperty({__proto__:null,isLogged:W,isURLset:At,login:z,logout:F,setURL:Tt,unsetURL:Lt},Symbol.toStringTag,{value:"Module"})),C=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),D=e=>{const{body:t,tasks:n,...s}=e;return{...C(s),tasks:n.map($),body:t}},Et=async()=>{const{content:e,...t}=await i.$get("/templates");return{...t,content:e.map(C)}},Rt=async e=>{const t=typeof e=="string"?e:e.id,{content:n,...s}=await i.$get(`/templates/${t}`);return{...s,content:D(n)}},Ct=async e=>{const{content:t,...n}=await i.$post("/templates",e);return{...n,content:D(t)}},ne=async e=>{const{id:t,...n}=e,{content:s,...r}=await i.$put(`/templates/${t}`,n);return{...r,content:D(s)}},Dt=ne,St=async e=>{const t=typeof e=="string"?e:e.id;await i.$delete(`/templates/${t}`)},g=e=>{const{activity:t,template:n,targets:s,extends:r,...o}=e;return{...Q(o),extends:C(r),activity:t.map(Ue),template:n,targets:s}},jt=async(e,t)=>{const{data:{content:n,...s}}=await f("get","/tasks",{params:{namespaces:t,...e??{}}});return{...s,content:n.map(({tags:r,_count:o,...a})=>({tags:r,_count:o,...$(a)}))}},xt=e=>i.$get("/tasks/_targets",{params:{namespaces:e}}),Nt=async(e,t)=>{const{content:n,...s}=await i.$get(`/tasks/_targets/${e}/tasks`,{params:{namespaces:t}});return{...s,content:n.map(({tags:r,...o})=>({tags:r,...$(o)}))}},Pt=async(e,t,n)=>{const s=typeof t=="string"?t:t.id;await i.$delete(`/tasks/_targets/${e}/tasks/${s}`,{params:{namespaces:n}})},Mt=async(e,t)=>{const{content:n,...s}=await i.$post("/tasks",e,{params:{namespaces:t}});return{...s,content:g(n)}},Ut=async(e,t,n)=>{const{content:s,...r}=await i.$post(`/tasks/_from-preset/${e}`,t,{params:{namespaces:n}});return{...r,content:g(s)}},Yt=async(e,t)=>{const n=typeof e=="string"?e:e.id,{content:s,...r}=await i.$get(`/tasks/${n}`,{params:{namespaces:t}});return{...r,content:g(s)}},se=async(e,t)=>{const{id:n,...s}=e,{content:r,...o}=await i.$put(`/tasks/${n}`,s,{params:{namespaces:t}});return{...o,content:g(r)}},zt=se,Ft=async(e,t)=>{const n=typeof e=="string"?e:e.id;await i.$delete(`/tasks/${n}`,{params:{namespaces:t}})},Wt=async(e,t)=>{const n=typeof e=="string"?e:e.id,{content:s,...r}=await i.$put(`/tasks/${n}/_enable`,void 0,{params:{namespaces:t}});return{...r,content:g(s)}},Jt=async(e,t)=>{const n=typeof e=="string"?e:e.id,{content:s,...r}=await i.$put(`/tasks/${n}/_disable`,void 0,{params:{namespaces:t}});return{...r,content:g(s)}},Bt=async(e,t,n)=>{const s=typeof e=="string"?e:e.id,r=typeof t=="string"?t:t.id,{content:o,...a}=await i.$put(`/tasks/${s}/_link/${r}`,void 0,{params:{namespaces:n}});return{...a,content:g(o)}},Ot=async(e,t,n)=>{const s=typeof e=="string"?e:e.id,r=typeof t=="string"?t:t.id;await i.$delete(`/tasks/${s}/_link/${r}`,{params:{namespaces:n}})},Qt=Object.freeze(Object.defineProperty({__proto__:null,Recurrence:O,createTask:Mt,createTaskFromPreset:Ut,deleteTask:Ft,disableTask:Jt,enableTask:Wt,getAllTargets:xt,getAllTasks:jt,getTask:Yt,getTasksOfTarget:Nt,linkTaskToTemplate:Bt,unlinkTaskToTemplate:Ot,unsubTargetOfTask:Pt,updateTask:zt,upsertTask:se},Symbol.toStringTag,{value:"Module"})),qt=Object.freeze(Object.defineProperty({__proto__:null,createTemplate:Ct,deleteTemplate:St,getAllTemplates:Et,getTemplate:Rt,updateTemplate:Dt,upsertTemplate:ne},Symbol.toStringTag,{value:"Module"})),Kt=e=>i.$get("/elastic/indices",{params:{namespace:e}}),Ht=(e,t)=>i.$get(`/elastic/indices/${e}`,{params:{namespace:t}}),Zt=(e,t)=>i.$get(`/elastic/indices/_resolve/${e}`,{params:{namespace:t}}),Gt=Object.freeze(Object.defineProperty({__proto__:null,getAllIndices:Kt,getIndexMapping:Ht,resolveIndex:Zt},Symbol.toStringTag,{value:"Module"})),It=oe;exports.auth=ke;exports.crons=xe;exports.elastic=Gt;exports.health=Me;exports.history=q;exports.namespaces=Ke;exports.queues=tt;exports.reports=$t;exports.setup=kt;exports.tasks=Qt;exports.tasksActivity=q;exports.tasksPresets=qe;exports.templates=qt;exports.version=It;
2
2
  //# sourceMappingURL=ezreeport-sdk-js.js.map