@ezpaarse-project/ezreeport-sdk-js 1.1.0-beta.1 → 1.1.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/LICENCE.txt +550 -0
- package/LICENSE.txt +519 -0
- package/dist/browser/ezreeport-sdk-js.mjs +1 -1
- package/dist/browser/ezreeport-sdk-js.mjs.map +1 -1
- package/dist/browser/ezreeport-sdk-js.umd.js +1 -1
- package/dist/browser/ezreeport-sdk-js.umd.js.map +1 -1
- package/dist/node/ezreeport-sdk-js.js +1 -1
- package/dist/node/ezreeport-sdk-js.js.map +1 -1
- package/dist/node/ezreeport-sdk-js.mjs +1 -1
- package/dist/node/ezreeport-sdk-js.mjs.map +1 -1
- package/dist/types/lib/axios.d.ts +1 -1
- package/dist/types/lib/promises.d.ts +1 -1
- package/dist/types/modules/queues.d.ts +3 -3
- package/dist/types/modules/reports.d.ts +4 -4
- package/package.json +14 -14
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(p,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],y):(p=typeof globalThis<"u"?globalThis:p||self,y(p.ezReeportSDK={},p.axios))})(this,function(p,y){"use strict";const se="1.1.0-beta.1";function u(e,t){const n=(t==null?void 0:t.additionalDigits)??2,s=ie(e);let r;if(s.date){const d=ce(s.date,n);r=ue(d.restDateString,d.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);const o=r.getTime();let a=0,l;if(s.time&&(a=le(s.time),isNaN(a)))return new Date(NaN);if(s.timezone){if(l=de(s.timezone),isNaN(l))return new Date(NaN)}else{const d=new Date(o+a),g=new Date(0);return g.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),g.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),g}return new Date(o+a+l)}const T={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},re=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,oe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ae=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ie(e){const t={},n=e.split(T.dateTimeDelimiter);let s;if(n.length>2)return t;if(/:/.test(n[0])?s=n[0]:(t.date=n[0],s=n[1],T.timeZoneDelimiter.test(t.date)&&(t.date=e.split(T.timeZoneDelimiter)[0],s=e.substr(t.date.length,e.length))),s){const r=T.timezone.exec(s);r?(t.time=s.replace(r[1],""),t.timezone=r[1]):t.time=s}return t}function ce(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 ue(e,t){if(t===null)return new Date(NaN);const n=e.match(re);if(!n)return new Date(NaN);const s=!!n[4],r=w(n[1]),o=w(n[2])-1,a=w(n[3]),l=w(n[4]),d=w(n[5])-1;if(s)return ye(t,l,d)?pe(t,l,d):new Date(NaN);{const g=new Date(0);return!ge(t,o,a)||!me(t,r)?new Date(NaN):(g.setUTCFullYear(t,o,Math.max(r,a)),g)}}function w(e){return e?parseInt(e):1}function le(e){const t=e.match(oe);if(!t)return NaN;const n=k(t[1]),s=k(t[2]),r=k(t[3]);return ve(n,s,r)?n*36e5+s*6e4+r*1e3:NaN}function k(e){return e&&parseFloat(e.replace(",","."))||0}function de(e){if(e==="Z")return 0;const t=e.match(ae);if(!t)return 0;const n=t[1]==="+"?-1:1,s=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return he(s,r)?n*(s*36e5+r*6e4):NaN}function pe(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 fe=[31,null,31,30,31,30,31,31,30,31,30,31];function j(e){return e%400===0||e%4===0&&e%100!==0}function ge(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(fe[t]||(j(e)?29:28))}function me(e,t){return t>=1&&t<=(j(e)?366:365)}function ye(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function ve(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function he(e,t){return t>=0&&t<=59}const N=y.create({headers:{"Content-Type":"application/json"}}),f=async(e,...t)=>{try{return await N[e](...t)}catch(n){if(!(n instanceof y.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(N,{$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}),M=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),be=e=>({...e,namespace:M(e.namespace),createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),we=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}),x=e=>{i.defaults.headers.common.authorization=`Bearer ${e}`},U=()=>{i.defaults.headers.common.authorization=void 0},z=()=>{const e=i.defaults.headers.common.authorization;if(!e||typeof e!="string")return!1;const[,t]=e.split("Bearer ");return!!t},_e=Object.freeze(Object.defineProperty({__proto__:null,getCurrentNamespaces:()=>i.$get("/me/namespaces"),getCurrentPermissions:()=>i.$get("/me/permissions"),getCurrentUser:async()=>{const{content:e,...t}=await i.$get("/me");return{...t,content:we(e)}},isLogged:z,login:x,logout:U},Symbol.toStringTag,{value:"Module"})),v=e=>({...e,nextRun:e.nextRun?u(e.nextRun):void 0,lastRun:e.lastRun?u(e.lastRun):void 0}),Te=Object.freeze(Object.defineProperty({__proto__:null,forceCron:async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$post(`/crons/${t}/_force`,{});return{...s,content:v(n)}},getAllCrons:async()=>{const{content:e,...t}=await i.$get("/crons");return{...t,content:e.map(v)}},getCron:async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$get(`/crons/${t}`);return{...s,content:v(n)}},startCron:async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$put(`/crons/${t}/start`,{});return{...s,content:v(n)}},stopCron:async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$put(`/crons/${t}/stop`,{});return{...s,content:v(n)}},updateCron:async e=>{const{name:t,...n}=e,{content:s,...r}=await i.$patch(`/crons/${t}`,n);return{...r,content:v(s)}}},Symbol.toStringTag,{value:"Module"})),Y=()=>i.$get("/health"),$e=()=>i.$get("/health/_all"),F=e=>i.$get(`/health/${e}`),Ae=Object.freeze(Object.defineProperty({__proto__:null,checkAllConnectedService:$e,checkConnectedService:F,checkCurrentService:async()=>{const{content:{current:e}}=await Y();return F(e)},getAllConnectedServices:Y},Symbol.toStringTag,{value:"Module"}));var B=(e=>(e.DAILY="DAILY",e.WEEKLY="WEEKLY",e.MONTHLY="MONTHLY",e.QUARTERLY="QUARTERLY",e.BIENNIAL="BIENNIAL",e.YEARLY="YEARLY",e))(B||{});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}),J=e=>{const{namespace:t,...n}=e,{namespaceId:s,...r}=$({namespaceId:t.id,...n});return{...r,namespace:M(t)}},Le=e=>({...e,createdAt:u(e.createdAt)}),ke=e=>({...e,task:J(e.task),createdAt:u(e.createdAt)}),W=Object.freeze(Object.defineProperty({__proto__:null,getAllEntries:async(e,t)=>{const{data:{content:n,...s}}=await f("get","/tasks-activity",{params:{namespaces:t,...e??{}}});return{...s,content:n.map(ke)}}},Symbol.toStringTag,{value:"Module"})),Re=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),R=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),Ce=Object.freeze(Object.defineProperty({__proto__:null,createTasksPreset:async e=>{const{content:t,...n}=await i.$post("/tasks-presets/",e);return{...n,content:R(t)}},deleteTasksPreset:async e=>{const t=typeof e=="string"?e:e.id;await i.$delete(`/tasks-presets/${t}`)},getAllTasksPresets:async()=>{const{content:e,...t}=await i.$get("/tasks-presets");return{...t,content:e.map(Re)}},getTasksPreset:async e=>{const t=typeof e=="string"?e:e.id,{content:n,...s}=await i.$get(`/tasks-presets/${t}`);return{...s,content:R(n)}},upsertTasksPreset:async e=>{const{id:t,...n}=e,{content:s,...r}=await i.$put(`/tasks-presets/${t}`,n);return{...r,content:R(s)}}},Symbol.toStringTag,{value:"Module"})),Ee=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),C=e=>({...e,added:u(e.added),started:e.started?u(e.started):void 0,ended:e.ended?u(e.ended):void 0}),De=()=>i.$get("/queues"),Se=async e=>{const t=typeof e=="string"?e:e.name;return i.$get(`/queues/${t}`)},Pe=async e=>{const{name:t,...n}=e;return i.$patch(`/queues/${t}`,n)},je=async e=>{const t=typeof e=="string"?e:e.name;return i.$put(`/queues/${t}/pause`)},Ne=async e=>{const t=typeof e=="string"?e:e.name;return i.$put(`/queues/${t}/resume`)},Me=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(C)}},_=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:C(o)}},xe=Object.freeze(Object.defineProperty({__proto__:null,getAllQueues:De,getJob:_,getQueue:Se,getQueueJobs:Me,pauseQueue:je,resumeQueue:Ne,retryJob: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:C(o)}},updateQueue:Pe},Symbol.toStringTag,{value:"Module"}));function Ue(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E={exports:{}},h=typeof Reflect=="object"?Reflect:null,O=h&&typeof h.apply=="function"?h.apply:function(t,n,s){return Function.prototype.apply.call(t,n,s)},A;h&&typeof h.ownKeys=="function"?A=h.ownKeys:Object.getOwnPropertySymbols?A=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:A=function(t){return Object.getOwnPropertyNames(t)};function ze(e){console&&console.warn&&console.warn(e)}var H=Number.isNaN||function(t){return t!==t};function c(){c.init.call(this)}E.exports=c,E.exports.once=Je,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var K=10;function L(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 K},set:function(e){if(typeof e!="number"||e<0||H(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");K=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||H(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 Q(e){return e._maxListeners===void 0?c.defaultMaxListeners:e._maxListeners}c.prototype.getMaxListeners=function(){return Q(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 d=o[t];if(d===void 0)return!1;if(typeof d=="function")O(d,this,n);else for(var g=d.length,mt=V(d,g),s=0;s<g;++s)O(mt[s],this,n);return!0};function q(e,t,n,s){var r,o,a;if(L(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=Q(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,ze(l)}return e}c.prototype.addListener=function(t,n){return q(this,t,n,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(t,n){return q(this,t,n,!0)};function Ye(){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 I(e,t,n){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=Ye.bind(s);return r.listener=n,s.wrapFn=r,r}c.prototype.once=function(t,n){return L(n),this.on(t,I(this,t,n)),this},c.prototype.prependOnceListener=function(t,n){return L(n),this.prependListener(t,I(this,t,n)),this},c.prototype.removeListener=function(t,n){var s,r,o,a,l;if(L(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():Fe(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 Z(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?Be(r):V(r,r.length)}c.prototype.listeners=function(t){return Z(this,t,!0)},c.prototype.rawListeners=function(t){return Z(this,t,!1)},c.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):G.call(e,t)},c.prototype.listenerCount=G;function G(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?A(this._events):[]};function V(e,t){for(var n=new Array(t),s=0;s<t;++s)n[s]=e[s];return n}function Fe(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function Be(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Je(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))}X(e,t,o,{once:!0}),t!=="error"&&We(e,r,{once:!0})})}function We(e,t,n){typeof e.on=="function"&&X(e,"error",t,n)}function X(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 Oe=E.exports;const He=Ue(Oe),Ke=(e,t=new He)=>{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},Qe=e=>new Promise(t=>{setTimeout(t,e)}),qe=e=>({start:u(e.start),end:u(e.end)}),Ie=e=>({...e,createdAt:u(e.createdAt),destroyAt:u(e.destroyAt),period:e.period?qe(e.period):void 0}),D=e=>({...e,detail:Ie(e.detail)}),ee=(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}})},Ze=(...e)=>Ke(async t=>{const{content:{id:n,queue:s}}=await ee(...e);t.emit("started",{id:n,queue:s});let r;do{const{content:{progress:o,status:a,result:l}}=await _(s,n,e[2]);r={progress:o,status:a,result:l},t.emit("progress",{progress:o,status:a});let d=1e3;r.status==="active"&&(d=250),await Qe(d)}while(["completed","failed","stuck"].includes(r.status)===!1);if(!r.result)throw new Error("Generation failed with weird error");return D(r.result)}),b=async(e,t,n)=>(await f("get",`/reports/${e}`,{responseType:n,params:{namespaces:t}})).data,Ge=Object.freeze(Object.defineProperty({__proto__:null,getReportDebugByJob:async(e,t,n,s)=>{var o;const{content:{result:r}}=await _(e,t,n);if(!r)throw new Error("Job have no result");return b(((o=r.detail)==null?void 0:o.files.debug)??"",n,s)},getReportDebugByName:(e,t,n)=>b(`${e}.deb.json`,t,n),getReportDetailByJob:async(e,t,n,s)=>{var a;const{content:{result:r}}=await _(e,t,n);if(!r)throw new Error("Job have no result");const o=await b(((a=r.detail)==null?void 0:a.files.detail)??"",n,s);return!s||s==="json"?D(o):o},getReportDetailByName:async(e,t,n)=>{const s=await b(`${e}.det.json`,t,n);return!n||n==="json"?D(s):s},getReportFileByJob:async(e,t,n,s)=>{var o;const{content:{result:r}}=await _(e,t,n);if(!r)throw new Error("Job have no result");return b(((o=r.detail)==null?void 0:o.files.report)??"",n,s)},getReportFileByName:(e,t,n,s="pdf")=>b(`${e}.rep.${s}`,t,n),startAndListenGeneration:Ze,startGeneration:ee},Symbol.toStringTag,{value:"Module"})),Ve=Object.freeze(Object.defineProperty({__proto__:null,isLogged:z,isURLset:()=>!!i.defaults.baseURL,login:x,logout:U,setURL:e=>{i.defaults.baseURL=e},unsetURL:()=>{i.defaults.baseURL=void 0}},Symbol.toStringTag,{value:"Module"})),S=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),P=e=>{const{body:t,tasks:n,...s}=e;return{...S(s),tasks:n.map($),body:t}},Xe=async()=>{const{content:e,...t}=await i.$get("/templates");return{...t,content:e.map(S)}},et=async e=>{const t=typeof e=="string"?e:e.id,{content:n,...s}=await i.$get(`/templates/${t}`);return{...s,content:P(n)}},tt=async e=>{const{content:t,...n}=await i.$post("/templates",e);return{...n,content:P(t)}},te=async e=>{const{id:t,...n}=e,{content:s,...r}=await i.$put(`/templates/${t}`,n);return{...r,content:P(s)}},nt=te,st=async e=>{const t=typeof e=="string"?e:e.id;await i.$delete(`/templates/${t}`)},m=e=>{const{activity:t,template:n,targets:s,extends:r,...o}=e;return{...J(o),extends:S(r),activity:t.map(Le),template:n,targets:s}},rt=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)}))}},ot=e=>i.$get("/tasks/_targets",{params:{namespaces:e}}),at=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)}))}},it=async(e,t,n)=>{const s=typeof t=="string"?t:t.id;await i.$delete(`/tasks/_targets/${e}/tasks/${s}`,{params:{namespaces:n}})},ct=async(e,t)=>{const{content:n,...s}=await i.$post("/tasks",e,{params:{namespaces:t}});return{...s,content:m(n)}},ut=async(e,t,n)=>{const{content:s,...r}=await i.$post(`/tasks/_from-preset/${e}`,t,{params:{namespaces:n}});return{...r,content:m(s)}},lt=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:m(s)}},ne=async(e,t)=>{const{id:n,...s}=e,{content:r,...o}=await i.$put(`/tasks/${n}`,s,{params:{namespaces:t}});return{...o,content:m(r)}},dt=Object.freeze(Object.defineProperty({__proto__:null,Recurrence:B,createTask:ct,createTaskFromPreset:ut,deleteTask:async(e,t)=>{const n=typeof e=="string"?e:e.id;await i.$delete(`/tasks/${n}`,{params:{namespaces:t}})},disableTask: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:m(s)}},enableTask: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:m(s)}},getAllTargets:ot,getAllTasks:rt,getTask:lt,getTasksOfTarget:at,linkTaskToTemplate: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:m(o)}},unlinkTaskToTemplate: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}})},unsubTargetOfTask:it,updateTask:ne,upsertTask:ne},Symbol.toStringTag,{value:"Module"})),pt=Object.freeze(Object.defineProperty({__proto__:null,createTemplate:tt,deleteTemplate:st,getAllTemplates:Xe,getTemplate:et,updateTemplate:nt,upsertTemplate:te},Symbol.toStringTag,{value:"Module"})),ft=Object.freeze(Object.defineProperty({__proto__:null,getAllIndices:e=>i.$get("/elastic/indices",{params:{namespace:e}}),getIndexMapping:(e,t)=>i.$get(`/elastic/indices/${e}`,{params:{namespace:t}}),resolveIndex:(e,t)=>i.$get(`/elastic/indices/_resolve/${e}`,{params:{namespace:t}})},Symbol.toStringTag,{value:"Module"})),gt=se;p.auth=_e,p.crons=Te,p.elastic=ft,p.health=Ae,p.history=W,p.namespaces=Ee,p.queues=xe,p.reports=Ge,p.setup=Ve,p.tasks=dt,p.tasksActivity=W,p.tasksPresets=Ce,p.templates=pt,p.version=gt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(p,y){typeof exports=="object"&&typeof module<"u"?y(exports,require("axios")):typeof define=="function"&&define.amd?define(["exports","axios"],y):(p=typeof globalThis<"u"?globalThis:p||self,y(p.ezReeportSDK={},p.axios))})(this,function(p,y){"use strict";const se="1.1.0";function u(e,t){const n=(t==null?void 0:t.additionalDigits)??2,s=ie(e);let r;if(s.date){const d=ce(s.date,n);r=ue(d.restDateString,d.year)}if(!r||isNaN(r.getTime()))return new Date(NaN);const o=r.getTime();let a=0,l;if(s.time&&(a=le(s.time),isNaN(a)))return new Date(NaN);if(s.timezone){if(l=de(s.timezone),isNaN(l))return new Date(NaN)}else{const d=new Date(o+a),g=new Date(0);return g.setFullYear(d.getUTCFullYear(),d.getUTCMonth(),d.getUTCDate()),g.setHours(d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds(),d.getUTCMilliseconds()),g}return new Date(o+a+l)}const T={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},re=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,oe=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,ae=/^([+-])(\d{2})(?::?(\d{2}))?$/;function ie(e){const t={},n=e.split(T.dateTimeDelimiter);let s;if(n.length>2)return t;if(/:/.test(n[0])?s=n[0]:(t.date=n[0],s=n[1],T.timeZoneDelimiter.test(t.date)&&(t.date=e.split(T.timeZoneDelimiter)[0],s=e.substr(t.date.length,e.length))),s){const r=T.timezone.exec(s);r?(t.time=s.replace(r[1],""),t.timezone=r[1]):t.time=s}return t}function ce(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 ue(e,t){if(t===null)return new Date(NaN);const n=e.match(re);if(!n)return new Date(NaN);const s=!!n[4],r=w(n[1]),o=w(n[2])-1,a=w(n[3]),l=w(n[4]),d=w(n[5])-1;if(s)return ye(t,l,d)?pe(t,l,d):new Date(NaN);{const g=new Date(0);return!ge(t,o,a)||!me(t,r)?new Date(NaN):(g.setUTCFullYear(t,o,Math.max(r,a)),g)}}function w(e){return e?parseInt(e):1}function le(e){const t=e.match(oe);if(!t)return NaN;const n=k(t[1]),s=k(t[2]),r=k(t[3]);return ve(n,s,r)?n*36e5+s*6e4+r*1e3:NaN}function k(e){return e&&parseFloat(e.replace(",","."))||0}function de(e){if(e==="Z")return 0;const t=e.match(ae);if(!t)return 0;const n=t[1]==="+"?-1:1,s=parseInt(t[2]),r=t[3]&&parseInt(t[3])||0;return he(s,r)?n*(s*36e5+r*6e4):NaN}function pe(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 fe=[31,null,31,30,31,30,31,31,30,31,30,31];function j(e){return e%400===0||e%4===0&&e%100!==0}function ge(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(fe[t]||(j(e)?29:28))}function me(e,t){return t>=1&&t<=(j(e)?366:365)}function ye(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function ve(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function he(e,t){return t>=0&&t<=59}const N=y.create({headers:{"Content-Type":"application/json"}}),f=async(e,...t)=>{try{return await N[e](...t)}catch(n){if(!(n instanceof y.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(N,{$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}),M=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),be=e=>({...e,namespace:M(e.namespace),createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),we=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}),x=e=>{i.defaults.headers.common.authorization=`Bearer ${e}`},U=()=>{i.defaults.headers.common.authorization=void 0},z=()=>{const e=i.defaults.headers.common.authorization;if(!e||typeof e!="string")return!1;const[,t]=e.split("Bearer ");return!!t},_e=Object.freeze(Object.defineProperty({__proto__:null,getCurrentNamespaces:()=>i.$get("/me/namespaces"),getCurrentPermissions:()=>i.$get("/me/permissions"),getCurrentUser:async()=>{const{content:e,...t}=await i.$get("/me");return{...t,content:we(e)}},isLogged:z,login:x,logout:U},Symbol.toStringTag,{value:"Module"})),v=e=>({...e,nextRun:e.nextRun?u(e.nextRun):void 0,lastRun:e.lastRun?u(e.lastRun):void 0}),Te=Object.freeze(Object.defineProperty({__proto__:null,forceCron:async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$post(`/crons/${t}/_force`,{});return{...s,content:v(n)}},getAllCrons:async()=>{const{content:e,...t}=await i.$get("/crons");return{...t,content:e.map(v)}},getCron:async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$get(`/crons/${t}`);return{...s,content:v(n)}},startCron:async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$put(`/crons/${t}/start`,{});return{...s,content:v(n)}},stopCron:async e=>{const t=typeof e=="string"?e:e.name,{content:n,...s}=await i.$put(`/crons/${t}/stop`,{});return{...s,content:v(n)}},updateCron:async e=>{const{name:t,...n}=e,{content:s,...r}=await i.$patch(`/crons/${t}`,n);return{...r,content:v(s)}}},Symbol.toStringTag,{value:"Module"})),Y=()=>i.$get("/health"),$e=()=>i.$get("/health/_all"),F=e=>i.$get(`/health/${e}`),Ae=Object.freeze(Object.defineProperty({__proto__:null,checkAllConnectedService:$e,checkConnectedService:F,checkCurrentService:async()=>{const{content:{current:e}}=await Y();return F(e)},getAllConnectedServices:Y},Symbol.toStringTag,{value:"Module"}));var B=(e=>(e.DAILY="DAILY",e.WEEKLY="WEEKLY",e.MONTHLY="MONTHLY",e.QUARTERLY="QUARTERLY",e.BIENNIAL="BIENNIAL",e.YEARLY="YEARLY",e))(B||{});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}),J=e=>{const{namespace:t,...n}=e,{namespaceId:s,...r}=$({namespaceId:t.id,...n});return{...r,namespace:M(t)}},Le=e=>({...e,createdAt:u(e.createdAt)}),ke=e=>({...e,task:J(e.task),createdAt:u(e.createdAt)}),W=Object.freeze(Object.defineProperty({__proto__:null,getAllEntries:async(e,t)=>{const{data:{content:n,...s}}=await f("get","/tasks-activity",{params:{namespaces:t,...e??{}}});return{...s,content:n.map(ke)}}},Symbol.toStringTag,{value:"Module"})),Re=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),R=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),Ce=Object.freeze(Object.defineProperty({__proto__:null,createTasksPreset:async e=>{const{content:t,...n}=await i.$post("/tasks-presets/",e);return{...n,content:R(t)}},deleteTasksPreset:async e=>{const t=typeof e=="string"?e:e.id;await i.$delete(`/tasks-presets/${t}`)},getAllTasksPresets:async()=>{const{content:e,...t}=await i.$get("/tasks-presets");return{...t,content:e.map(Re)}},getTasksPreset:async e=>{const t=typeof e=="string"?e:e.id,{content:n,...s}=await i.$get(`/tasks-presets/${t}`);return{...s,content:R(n)}},upsertTasksPreset:async e=>{const{id:t,...n}=e,{content:s,...r}=await i.$put(`/tasks-presets/${t}`,n);return{...r,content:R(s)}}},Symbol.toStringTag,{value:"Module"})),Ee=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),C=e=>({...e,added:u(e.added),started:e.started?u(e.started):void 0,ended:e.ended?u(e.ended):void 0}),De=()=>i.$get("/queues"),Se=async e=>{const t=typeof e=="string"?e:e.name;return i.$get(`/queues/${t}`)},Pe=async e=>{const{name:t,...n}=e;return i.$patch(`/queues/${t}`,n)},je=async e=>{const t=typeof e=="string"?e:e.name;return i.$put(`/queues/${t}/pause`)},Ne=async e=>{const t=typeof e=="string"?e:e.name;return i.$put(`/queues/${t}/resume`)},Me=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(C)}},_=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:C(o)}},xe=Object.freeze(Object.defineProperty({__proto__:null,getAllQueues:De,getJob:_,getQueue:Se,getQueueJobs:Me,pauseQueue:je,resumeQueue:Ne,retryJob: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:C(o)}},updateQueue:Pe},Symbol.toStringTag,{value:"Module"}));function Ue(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var E={exports:{}},h=typeof Reflect=="object"?Reflect:null,O=h&&typeof h.apply=="function"?h.apply:function(t,n,s){return Function.prototype.apply.call(t,n,s)},A;h&&typeof h.ownKeys=="function"?A=h.ownKeys:Object.getOwnPropertySymbols?A=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:A=function(t){return Object.getOwnPropertyNames(t)};function ze(e){console&&console.warn&&console.warn(e)}var H=Number.isNaN||function(t){return t!==t};function c(){c.init.call(this)}E.exports=c,E.exports.once=Je,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var K=10;function L(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 K},set:function(e){if(typeof e!="number"||e<0||H(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");K=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||H(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 Q(e){return e._maxListeners===void 0?c.defaultMaxListeners:e._maxListeners}c.prototype.getMaxListeners=function(){return Q(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 d=o[t];if(d===void 0)return!1;if(typeof d=="function")O(d,this,n);else for(var g=d.length,mt=V(d,g),s=0;s<g;++s)O(mt[s],this,n);return!0};function q(e,t,n,s){var r,o,a;if(L(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=Q(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,ze(l)}return e}c.prototype.addListener=function(t,n){return q(this,t,n,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(t,n){return q(this,t,n,!0)};function Ye(){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 I(e,t,n){var s={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},r=Ye.bind(s);return r.listener=n,s.wrapFn=r,r}c.prototype.once=function(t,n){return L(n),this.on(t,I(this,t,n)),this},c.prototype.prependOnceListener=function(t,n){return L(n),this.prependListener(t,I(this,t,n)),this},c.prototype.removeListener=function(t,n){var s,r,o,a,l;if(L(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():Fe(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 Z(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?Be(r):V(r,r.length)}c.prototype.listeners=function(t){return Z(this,t,!0)},c.prototype.rawListeners=function(t){return Z(this,t,!1)},c.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):G.call(e,t)},c.prototype.listenerCount=G;function G(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?A(this._events):[]};function V(e,t){for(var n=new Array(t),s=0;s<t;++s)n[s]=e[s];return n}function Fe(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function Be(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function Je(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))}X(e,t,o,{once:!0}),t!=="error"&&We(e,r,{once:!0})})}function We(e,t,n){typeof e.on=="function"&&X(e,"error",t,n)}function X(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 Oe=E.exports;const He=Ue(Oe),Ke=(e,t=new He)=>{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},Qe=e=>new Promise(t=>{setTimeout(t,e)}),qe=e=>({start:u(e.start),end:u(e.end)}),Ie=e=>({...e,createdAt:u(e.createdAt),destroyAt:u(e.destroyAt),period:e.period?qe(e.period):void 0}),D=e=>({...e,detail:Ie(e.detail)}),ee=(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}})},Ze=(...e)=>Ke(async t=>{const{content:{id:n,queue:s}}=await ee(...e);t.emit("started",{id:n,queue:s});let r;do{const{content:{progress:o,status:a,result:l}}=await _(s,n,e[2]);r={progress:o,status:a,result:l},t.emit("progress",{progress:o,status:a});let d=1e3;r.status==="active"&&(d=250),await Qe(d)}while(["completed","failed","stuck"].includes(r.status)===!1);if(!r.result)throw new Error("Generation failed with weird error");return D(r.result)}),b=async(e,t,n)=>(await f("get",`/reports/${e}`,{responseType:n,params:{namespaces:t}})).data,Ge=Object.freeze(Object.defineProperty({__proto__:null,getReportDebugByJob:async(e,t,n,s)=>{var o;const{content:{result:r}}=await _(e,t,n);if(!r)throw new Error("Job have no result");return b(((o=r.detail)==null?void 0:o.files.debug)??"",n,s)},getReportDebugByName:(e,t,n)=>b(`${e}.deb.json`,t,n),getReportDetailByJob:async(e,t,n,s)=>{var a;const{content:{result:r}}=await _(e,t,n);if(!r)throw new Error("Job have no result");const o=await b(((a=r.detail)==null?void 0:a.files.detail)??"",n,s);return!s||s==="json"?D(o):o},getReportDetailByName:async(e,t,n)=>{const s=await b(`${e}.det.json`,t,n);return!n||n==="json"?D(s):s},getReportFileByJob:async(e,t,n,s)=>{var o;const{content:{result:r}}=await _(e,t,n);if(!r)throw new Error("Job have no result");return b(((o=r.detail)==null?void 0:o.files.report)??"",n,s)},getReportFileByName:(e,t,n,s="pdf")=>b(`${e}.rep.${s}`,t,n),startAndListenGeneration:Ze,startGeneration:ee},Symbol.toStringTag,{value:"Module"})),Ve=Object.freeze(Object.defineProperty({__proto__:null,isLogged:z,isURLset:()=>!!i.defaults.baseURL,login:x,logout:U,setURL:e=>{i.defaults.baseURL=e},unsetURL:()=>{i.defaults.baseURL=void 0}},Symbol.toStringTag,{value:"Module"})),S=e=>({...e,createdAt:u(e.createdAt),updatedAt:e.updatedAt?u(e.updatedAt):void 0}),P=e=>{const{body:t,tasks:n,...s}=e;return{...S(s),tasks:n.map($),body:t}},Xe=async()=>{const{content:e,...t}=await i.$get("/templates");return{...t,content:e.map(S)}},et=async e=>{const t=typeof e=="string"?e:e.id,{content:n,...s}=await i.$get(`/templates/${t}`);return{...s,content:P(n)}},tt=async e=>{const{content:t,...n}=await i.$post("/templates",e);return{...n,content:P(t)}},te=async e=>{const{id:t,...n}=e,{content:s,...r}=await i.$put(`/templates/${t}`,n);return{...r,content:P(s)}},nt=te,st=async e=>{const t=typeof e=="string"?e:e.id;await i.$delete(`/templates/${t}`)},m=e=>{const{activity:t,template:n,targets:s,extends:r,...o}=e;return{...J(o),extends:S(r),activity:t.map(Le),template:n,targets:s}},rt=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)}))}},ot=e=>i.$get("/tasks/_targets",{params:{namespaces:e}}),at=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)}))}},it=async(e,t,n)=>{const s=typeof t=="string"?t:t.id;await i.$delete(`/tasks/_targets/${e}/tasks/${s}`,{params:{namespaces:n}})},ct=async(e,t)=>{const{content:n,...s}=await i.$post("/tasks",e,{params:{namespaces:t}});return{...s,content:m(n)}},ut=async(e,t,n)=>{const{content:s,...r}=await i.$post(`/tasks/_from-preset/${e}`,t,{params:{namespaces:n}});return{...r,content:m(s)}},lt=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:m(s)}},ne=async(e,t)=>{const{id:n,...s}=e,{content:r,...o}=await i.$put(`/tasks/${n}`,s,{params:{namespaces:t}});return{...o,content:m(r)}},dt=Object.freeze(Object.defineProperty({__proto__:null,Recurrence:B,createTask:ct,createTaskFromPreset:ut,deleteTask:async(e,t)=>{const n=typeof e=="string"?e:e.id;await i.$delete(`/tasks/${n}`,{params:{namespaces:t}})},disableTask: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:m(s)}},enableTask: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:m(s)}},getAllTargets:ot,getAllTasks:rt,getTask:lt,getTasksOfTarget:at,linkTaskToTemplate: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:m(o)}},unlinkTaskToTemplate: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}})},unsubTargetOfTask:it,updateTask:ne,upsertTask:ne},Symbol.toStringTag,{value:"Module"})),pt=Object.freeze(Object.defineProperty({__proto__:null,createTemplate:tt,deleteTemplate:st,getAllTemplates:Xe,getTemplate:et,updateTemplate:nt,upsertTemplate:te},Symbol.toStringTag,{value:"Module"})),ft=Object.freeze(Object.defineProperty({__proto__:null,getAllIndices:e=>i.$get("/elastic/indices",{params:{namespace:e}}),getIndexMapping:(e,t)=>i.$get(`/elastic/indices/${e}`,{params:{namespace:t}}),resolveIndex:(e,t)=>i.$get(`/elastic/indices/_resolve/${e}`,{params:{namespace:t}})},Symbol.toStringTag,{value:"Module"})),gt=se;p.auth=_e,p.crons=Te,p.elastic=ft,p.health=Ae,p.history=W,p.namespaces=Ee,p.queues=xe,p.reports=Ge,p.setup=Ve,p.tasks=dt,p.tasksActivity=W,p.tasksPresets=Ce,p.templates=pt,p.version=gt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
|
|
2
2
|
//# sourceMappingURL=ezreeport-sdk-js.umd.js.map
|