@vizzly/services 0.15.0-dev-21f63b84088b40b7cb4e9022125e04e1004ac6c9 → 0.15.0-dev-06b713fa3824fa3b950ea5edd24ac98715341051

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.
@@ -133,4 +133,4 @@ For example, this should be added within the <head> tag;
133
133
  <script src="https://static.app.vizzly.co/query-engine/0.8.29/vizzly-in-memory-db.umd.js"><\/script>
134
134
 
135
135
  Note, you can change the version of the in-memory database by changing '0.8.3' to the version you require.
136
- `);return t},JB=async(t,e)=>{if("measure"in t&&t.measure.length===0)return[[]];const o={id:e.id,fields:e.fields.map(b=>({id:b.id,address:["_",e.id,b.id],dataType:b.dataType})),joins:[]};return(await pO().queryV2(t,o))?.[0]?.values||[]},tf=(t,e)=>`${t}::${e}`,eS=async(t,e,o)=>{const n=[...t].map(async a=>{const[O]=Ku(e,a.dataSetId),A=tf(o,a.dataSetId);return Ua[A]&&O?{content:await JB(a,O),hasMoreResults:!1}:(console.warn("Returning an empty result."),{content:[],hasMoreResults:null})});return{results:await Promise.all(n)}},tS=async(t,e,o,n)=>(await pO().init(e.map(b=>({id:b?.id,fields:b?.fields.map(a=>({id:a.id,dataType:a.dataType}))}))),await Promise.all([...t].flatMap(async b=>{const[a]=Ku(e,b.dataSetId);if(a){const O=await QB(a,o,tf(n,b.dataSetId)),A={id:a?.id,fields:a?.fields.map(c=>({id:c.id,dataType:c.dataType}))};await pO().ingest(A,O||[])}return[]})),await eS(t,e,n)),oS=async(t,e,o)=>{const{queries:n,resultFields:b}=JO(e,bM,o);let a=await e3(n,A=>!0,async A=>await tS(A,o.dataSets,t.loadData,t.cacheKeyNamespace),A=>({query:A,cacheKeyNamespace:t.cacheKeyNamespace}));return a===null&&(a=n.map(()=>null)),[...n].map((A,c)=>{if(a===null)return null;const R=a[c];return R==null?null:{content:R.content,fields:b[c],hasMoreResults:R.hasMoreResults}})},rS=async(t,e,o)=>{const{queries:n,resultFields:b}=JO(e,t.queryEngineConfig,o),a=await e3(n,O=>(O.type=="preparedQuery"&&sO("Custom query engine does not support prepared queries."),O.type=="query"),async O=>{const A=await t.runQueries(O,{...o,dataAccessToken:t.dataAccessToken});return A==null?{results:O.map(()=>null)}:{results:A.map((c,R)=>Array.isArray(c)?{fields:b[R],content:c,hasMoreResults:null}:c)}},O=>({query:O,cacheKeyNamespace:t.cacheKeyNamespace}));return a===null?n.map(()=>null):a};async function Is(t,e,o){return t.type=="vizzlyQueryEngine"?await AB(t,e,o):t.type=="vizzlyJsQueryEngine"?await oS(t,e,o):t.type=="custom"?await rS(t,e,o):[]}const nS=(t,e,o,n,b,a,O,A,c)=>{let R=X7(t.dashboardAccess);if(a)return async(v,N)=>await Is({type:"custom",queryEngineConfig:e,runQueries:a,dataAccessToken:t.dataAccess?.signature,cacheKeyNamespace:R},v,{abortSignal:N.abortSignal,dataSets:N.dataSets,filterConfig:N.filterConfig||{},timeRangeOptions:o,timeZone:c,variables:n,aliasFields:b});if(O)return async(v,N)=>await Is({type:"vizzlyJsQueryEngine",loadData:O,cacheKeyNamespace:R},v,{abortSignal:N.abortSignal,dataSets:N.dataSets,filterConfig:N.filterConfig||{},timeRangeOptions:o,timeZone:c,variables:n,aliasFields:b});if(A&&t.dataAccess?.signature)return async(v,N)=>await Is({type:"vizzlyQueryEngine",queryEngineConfig:e,dataAccessToken:t.dataAccess?.signature,queryEngineEndpoint:A,cacheKeyNamespace:R},v,{abortSignal:N.abortSignal,dataSets:N.dataSets,filterConfig:N.filterConfig||{},timeRangeOptions:o,timeZone:c,variables:n,aliasFields:b});throw"Missing required props."},iS=(t,e)=>{const o=new Date(t.getTime()-e*24*60*60*1e3);return new Date(o.getFullYear(),o.getMonth(),o.getDate())},aO=t=>new Date(t.getFullYear(),t.getMonth(),t.getDate()),Ps={today:!1,past_1_day:!0,yesterday:!0,past_3_days:!0,past_7_days:!0,past_30_days:!0,past_90_days:!0,past_3_months:!1,past_6_months:!1,past_12_months:!1,past_18_months:!1},bS=(t,e)=>{const o=aO(t),n=new Date(o);return n.setDate(n.getDate()+1),n.setMilliseconds(n.getMilliseconds()-1),{description:e,range:{before:n,after:o}}},pS=(t,e)=>({description:e,range:{before:aO(t),after:aO(iS(t,1))}}),bo=(t,e,o)=>{const n=new Date;let b=new Date(n);return e>0&&b.setMonth(n.getMonth()-e),t>0&&(b=new Date(n.getTime()-t*24*60*60*1e3)),{description:o,range:{before:n,after:b}}},aS=t=>({today:bS(new Date,t("filter.today","Today")),past_1_day:bo(1,0,t("filter.past_1_day","Last 24 hours")),yesterday:pS(new Date,t("filter.yesterday","Yesterday")),past_3_days:bo(3,0,t("filter.past_3_days","Last 3 days")),past_7_days:bo(7,0,t("filter.past_7_days","Last 7 days")),past_30_days:bo(30,0,t("filter.past_30_days","Last 30 days")),past_90_days:bo(90,0,t("filter.past_90_days","Last 90 days")),past_3_months:bo(0,3,t("filter.past_3_months","Last 3 months")),past_6_months:bo(0,6,t("filter.past_6_months","Last 6 months")),past_12_months:bo(0,12,t("filter.past_12_months","Last 12 months")),past_18_months:bo(0,18,t("filter.past_18_months","Last 18 months"))}),MS=(t,e)=>{const o=aS(t),n=Object.keys(Ps).map(A=>A in o?`_vizzly_${A}`:A),b=n.indexOf("_vizzly_today");b>-1&&(n.splice(b,1),n.unshift("_vizzly_today"));let a={},O={};for(const A of n){const c=A.replace("_vizzly_",""),R=o[c],v=e?.[c];typeof v=="boolean"?v&&(O[A]=R):v!=null?O[A]=v:Ps[c]!==!1&&(O[A]=R)}if(e)for(const[A,c]of Object.entries(e))A in Ps||(n.push(A),O[A]=c);for(const A of n)A in O&&(a[A]=O[A]);return a},zS=(t,e)=>{const o=d7(t);if(o&&e.dashboardAccess.scope==="read")return{type:"exact",globalLibrary:o};if(o&&e.dashboardAccess.scope==="read_write"&&e.dashboardAccess.accessType!=="admin")return{type:"exact",globalLibrary:u7(t)[0]};if(o&&e.dashboardAccess.accessType==="admin")return{type:"exact",globalLibrary:o};throw"No strategy found."},$i="default";N2.VizzlyApiClientLogger.UserAgentProduct="Services";const cS={apiHost:"https://api.vizzly.co"};class Ho{static{this._instanceStore={}}static{this.DEFAULT_INSTANCE_ID=$i}static{this.eventBus=[]}constructor(e,o,n,b,a,O){this.programmaticDashboard=a,this.dataSets=n,this.queryEngineConfig=o,this.identityConfig=e,this.vizzlyAPIClient=gm(e,b,O)}getDataSets(){return this.dataSets}static async load(e,o=cS){G1("Starting load process for the services package.");const{queryEngine:n,dataSets:b,identity:a,programmaticDashboard:O,extraCustomFields:A}=e,c=new G7(n,a,b,A,o),{queryEngineConfig:R,dataSets:v,identityConfig:N,dashboardStorageStrategy:s}=await c.load(),d=new Pe(N,R,v,s,O,{host:o.apiHost});return Pe._instanceStore[o.instanceId||$i]=d,Pe.queryEngine=n,G1("Loaded services package and added it to the instance store."),d}static use(e=$i){const o=Pe._instanceStore[e];if(!o)throw new Kd(e);return o}static async waitToUse(e=$i,o=1e4){const n=Ho._instanceStore,b=e;return new Promise((a,O)=>{if(n.hasOwnProperty(b)){a(n[b]);return}const A=setTimeout(()=>{clearTimeout(A),O(new TT(e,o))},o),c=setInterval(()=>{n.hasOwnProperty(b)&&(clearTimeout(A),clearInterval(c),a(n[b]))},10)})}static clearInstances(){Pe._instanceStore={},R1.setQueryEngineConfig(null)}async createDashboard(e){BT(e,this.queryEngineConfig);const n=this.vizzlyAPIClient.getDashboardManager(),{dashboard:b}=await n.create({metadata:e.metadata||e.meta,definition:e.definition,parentDashboardId:e.parentDashboardId,permissions:[{scope:"read_write"}],usage_metadata:e.definition?Ul(e.definition,this.dataSets):void 0}),a=Bs(b,this.queryEngineConfig);return Pa(a,this.dataSets,b.definition?.customFields||{})}async updateDashboard(e){ST(e,this.queryEngineConfig);const b=await this.vizzlyAPIClient.getDashboardManager().update({dashboardId:e.dashboardId,metadata:e.metadata||e.meta,definition:e.definition,deleted:e.deleted,abortSignal:e.abortSignal,name:e.name,usage_metadata:e.definition?Ul(e.definition,this.dataSets):void 0}),a=Bs(b,this.queryEngineConfig);return Pa(a,this.dataSets,b.definition?.customFields||{})}async updateScheduledReport(e,o,n){const a=await this.vizzlyAPIClient.getAPIs().vizzlyApi.saveScheduledReport({scheduledReportId:o,cronSchedule:n,dashboardAccessToken:e});if(a.status===200)return n===null?!0:a.body}async getScheduledReports(e){if(this.vizzlyAPIClient){const n=await this.vizzlyAPIClient.getAPIs().vizzlyApi.getScheduledReports({dashboardAccessToken:e});if(n.status===200)return n.body}return{reports:[]}}async getDashboards(e){const a=(await this.vizzlyAPIClient.getDashboardManager().getDashboards(e?.abortController?{abortSignal:e?.abortController.signal}:{})).flatMap(O=>Ho.upcastDashboard(O,this.dataSets,this.queryEngineConfig));return this.programmaticDashboard?p7(a,n7(await this.programmaticDashboard(this.dataSets),this.dataSets)):a}async createGlobalLibrary(e){return await this.vizzlyAPIClient.getGlobalLibraryManager().create(e)}async getGlobalLibraries(e){const b=await this.vizzlyAPIClient.getGlobalLibraryManager().getGlobalLibraries(e?.abortController?{abortSignal:e?.abortController.signal}:{});this.globalLibraryPermissions=b.permissions;const a=b.global_libraries.map(A=>M7(A));return[zS(a,this.getIdentityConfig()).globalLibrary]}getViewConfiguration(){return{queryEngineConfig:this.queryEngineConfig}}getIdentityConfig(){return this.identityConfig}async query(e,o){G1("[Services] Querying data with queries:",e);let n=$i;o?.instanceId&&(n=o.instanceId);const b=Ho._instanceStore[n],a=nS(b.identityConfig,b.queryEngineConfig,MS(LN,o?.dateFilterOptions),o?.variables||{},o?.aliasFields||{},o?.runQueries,o?.data,o?.queryEngineEndpoint);return{results:await(async()=>{try{return await a(e,{abortSignal:o?.abortController?.signal,dataSets:this.dataSets,filterConfig:o?.filterConfig})}catch(A){return dt("[Services] Error fetching data on query:",A),null}})()}}static upcastDashboard(e,o,n){try{const b=Bs(e,n);return[Pa(b,o,e.definition?.customFields||{})]}catch(b){return dt(`Failed to upcast dashboard ${e.id}. This dashboard will not be available for use.`,b),[]}}static filterDashboards(e,o){let n=P0.cloneDeep(e);return o.onlyParentDashboards&&(n=n.filter(b=>b.parentDashboardId===null)),o.onlyChildDashboards&&(n=n.filter(b=>b.parentDashboardId!==null)),o.onlyChildDashboardsForParent&&(n=n.filter(b=>b.parentDashboardId===o.onlyChildDashboardsForParent)),o.onlyAllowScope&&(n=n.filter(b=>b.permission?.scope===o.onlyAllowScope)),o.onlyDashboardsIncludingMetadata&&(n=n.filter(b=>{const a=Object.keys(o.onlyDashboardsIncludingMetadata||{});return P0.every(a,O=>b.metadata[O]===o?.onlyDashboardsIncludingMetadata?.[O])})),n}async updateGlobalLibrary(e){try{return await this.vizzlyAPIClient.getGlobalLibraryManager().update(e)}catch(o){dt("Error updating global library:",o)}}static async eventBusController(e,o){try{const n=Ho.use();if((e.action==="addComponentToLibrary"||e.action==="deleteComponentFromLibrary")&&n.globalLibraryPermissions){Pe.publish({data:{action:"updateToGlobalLibraryStatus",state:ja.SAVING}});const[b]=await Promise.all([await n.getGlobalLibraries({abortController:o?.abortController})]);let a=KO(b);e.action==="addComponentToLibrary"&&(a=c7(b,e.component,e.customFields)),e.action==="deleteComponentFromLibrary"&&(a=l7(b,e.component));const O=z7(n.globalLibraryPermissions,[a]);N6("library and tokens for update",{libraryForUpdate:a,tokenForLibrary:O});const A={globalLibraryId:a.id,library:a.library,abortSignal:o?.abortController?.signal,globalLibrarySessionToken:O};if(await n.updateGlobalLibrary(A)){let R=ja.SAVED;e.action==="deleteComponentFromLibrary"&&(R=ja.DELETED),Pe.publish({data:{action:"newViewsInGlobalLibrary"}}),Pe.publish({data:{action:"updateToGlobalLibraryStatus",state:R}})}}}catch(n){dt("Error handling event:",n)}}static publish(e){Pe.eventBus.map(o=>{o(e)}),Pe.eventBusController(e.data).catch(o=>{dt("Failed to handle event:",o)})}static subscription(e){return Pe.eventBus.push(e),()=>{Pe.eventBus=Pe.eventBus.filter(o=>o!==e)}}static{this.Row=Hd}static{this.Cell=iO}static{this.Dashboard=Y7}static{this.Editor=Q7}static{this.Header=Yd}static{this.Library=K7}static{this.View=R1}static{this.AreaChart=bT}static{this.AreaChartV2=pT}static{this.LineChart=aT}static{this.LineChartV2=MT}static{this.BarChart=zT}static{this.BarChartV2=cT}static{this.PieChart=sT}static{this.BubbleChart=OT}static{this.BubbleChartV2=lT}static{this.ScatterChart=uT}static{this.ComboChart=dT}static{this.ComboChartV2=fT}static{this.PivotTable=qT}static{this.BasicTable=WT}static{this.HorizontalBarChart=hT}static{this.HorizontalBarChartV2=mT}static{this.MercatorMap=gT}static{this.SingleStat=yT}static{this.Progress=RT}static{this.RichText=LT}static{this.WaterfallChart=vT}static{this.FunnelChart=NT}static{this.SunburstChart=AT}static{this.RadarChart=_T}}typeof window<"u"&&!window.Vizzly&&(window.Vizzly=Ho);const Pe=typeof window<"u"&&window.Vizzly||Ho;exports.Vizzly=Pe;exports.VizzlyInstanceNotLoaded=Kd;
136
+ `);return t},JB=async(t,e)=>{if("measure"in t&&t.measure.length===0)return[[]];const o={id:e.id,fields:e.fields.map(b=>({id:b.id,address:["_",e.id,b.id],dataType:b.dataType})),joins:[]};return(await pO().queryV2(t,o))?.[0]?.values||[]},tf=(t,e)=>`${t}::${e}`,eS=async(t,e,o)=>{const n=[...t].map(async a=>{const[O]=Ku(e,a.dataSetId),A=tf(o,a.dataSetId);return Ua[A]&&O?{content:await JB(a,O),hasMoreResults:!1}:(console.warn("Returning an empty result."),{content:[],hasMoreResults:null})});return{results:await Promise.all(n)}},tS=async(t,e,o,n)=>(await pO().init(e.map(b=>({id:b?.id,fields:b?.fields.map(a=>({id:a.id,dataType:a.dataType}))}))),await Promise.all([...t].flatMap(async b=>{const[a]=Ku(e,b.dataSetId);if(a){const O=await QB(a,o,tf(n,b.dataSetId)),A={id:a?.id,fields:a?.fields.map(c=>({id:c.id,dataType:c.dataType}))};await pO().ingest(A,O||[])}return[]})),await eS(t,e,n)),oS=async(t,e,o)=>{const{queries:n,resultFields:b}=JO(e,bM,o);let a=await e3(n,A=>!0,async A=>await tS(A,o.dataSets,t.loadData,t.cacheKeyNamespace),A=>({query:A,cacheKeyNamespace:t.cacheKeyNamespace}));return a===null&&(a=n.map(()=>null)),[...n].map((A,c)=>{if(a===null)return null;const R=a[c];return R==null?null:{content:R.content,fields:b[c],hasMoreResults:R.hasMoreResults}})},rS=async(t,e,o)=>{const{queries:n,resultFields:b}=JO(e,t.queryEngineConfig,o),a=await e3(n,O=>(O.type=="preparedQuery"&&sO("Custom query engine does not support prepared queries."),O.type=="query"),async O=>{const A=await t.runQueries(O,{...o,dataAccessToken:t.dataAccessToken});return A==null?{results:O.map(()=>null)}:{results:A.map((c,R)=>Array.isArray(c)?{fields:b[R],content:c,hasMoreResults:null}:c)}},O=>({query:O,cacheKeyNamespace:t.cacheKeyNamespace}));return a===null?n.map(()=>null):a};async function Is(t,e,o){return t.type=="vizzlyQueryEngine"?await AB(t,e,o):t.type=="vizzlyJsQueryEngine"?await oS(t,e,o):t.type=="custom"?await rS(t,e,o):[]}const nS=(t,e,o,n,b,a,O,A,c,R)=>{let v=X7(t.dashboardAccess)+`:::${JSON.stringify(R)}`;if(a)return async(N,s)=>await Is({type:"custom",queryEngineConfig:e,runQueries:a,dataAccessToken:t.dataAccess?.signature,cacheKeyNamespace:v},N,{abortSignal:s.abortSignal,dataSets:s.dataSets,filterConfig:s.filterConfig||{},timeRangeOptions:o,timeZone:c,variables:n,aliasFields:b});if(O)return async(N,s)=>await Is({type:"vizzlyJsQueryEngine",loadData:O,cacheKeyNamespace:v},N,{abortSignal:s.abortSignal,dataSets:s.dataSets,filterConfig:s.filterConfig||{},timeRangeOptions:o,timeZone:c,variables:n,aliasFields:b});if(A&&t.dataAccess?.signature)return async(N,s)=>await Is({type:"vizzlyQueryEngine",queryEngineConfig:e,dataAccessToken:t.dataAccess?.signature,queryEngineEndpoint:A,cacheKeyNamespace:v},N,{abortSignal:s.abortSignal,dataSets:s.dataSets,filterConfig:s.filterConfig||{},timeRangeOptions:o,timeZone:c,variables:n,aliasFields:b});throw"Missing required props."},iS=(t,e)=>{const o=new Date(t.getTime()-e*24*60*60*1e3);return new Date(o.getFullYear(),o.getMonth(),o.getDate())},aO=t=>new Date(t.getFullYear(),t.getMonth(),t.getDate()),Ps={today:!1,past_1_day:!0,yesterday:!0,past_3_days:!0,past_7_days:!0,past_30_days:!0,past_90_days:!0,past_3_months:!1,past_6_months:!1,past_12_months:!1,past_18_months:!1},bS=(t,e)=>{const o=aO(t),n=new Date(o);return n.setDate(n.getDate()+1),n.setMilliseconds(n.getMilliseconds()-1),{description:e,range:{before:n,after:o}}},pS=(t,e)=>({description:e,range:{before:aO(t),after:aO(iS(t,1))}}),bo=(t,e,o)=>{const n=new Date;let b=new Date(n);return e>0&&b.setMonth(n.getMonth()-e),t>0&&(b=new Date(n.getTime()-t*24*60*60*1e3)),{description:o,range:{before:n,after:b}}},aS=t=>({today:bS(new Date,t("filter.today","Today")),past_1_day:bo(1,0,t("filter.past_1_day","Last 24 hours")),yesterday:pS(new Date,t("filter.yesterday","Yesterday")),past_3_days:bo(3,0,t("filter.past_3_days","Last 3 days")),past_7_days:bo(7,0,t("filter.past_7_days","Last 7 days")),past_30_days:bo(30,0,t("filter.past_30_days","Last 30 days")),past_90_days:bo(90,0,t("filter.past_90_days","Last 90 days")),past_3_months:bo(0,3,t("filter.past_3_months","Last 3 months")),past_6_months:bo(0,6,t("filter.past_6_months","Last 6 months")),past_12_months:bo(0,12,t("filter.past_12_months","Last 12 months")),past_18_months:bo(0,18,t("filter.past_18_months","Last 18 months"))}),MS=(t,e)=>{const o=aS(t),n=Object.keys(Ps).map(A=>A in o?`_vizzly_${A}`:A),b=n.indexOf("_vizzly_today");b>-1&&(n.splice(b,1),n.unshift("_vizzly_today"));let a={},O={};for(const A of n){const c=A.replace("_vizzly_",""),R=o[c],v=e?.[c];typeof v=="boolean"?v&&(O[A]=R):v!=null?O[A]=v:Ps[c]!==!1&&(O[A]=R)}if(e)for(const[A,c]of Object.entries(e))A in Ps||(n.push(A),O[A]=c);for(const A of n)A in O&&(a[A]=O[A]);return a},zS=(t,e)=>{const o=d7(t);if(o&&e.dashboardAccess.scope==="read")return{type:"exact",globalLibrary:o};if(o&&e.dashboardAccess.scope==="read_write"&&e.dashboardAccess.accessType!=="admin")return{type:"exact",globalLibrary:u7(t)[0]};if(o&&e.dashboardAccess.accessType==="admin")return{type:"exact",globalLibrary:o};throw"No strategy found."},$i="default";N2.VizzlyApiClientLogger.UserAgentProduct="Services";const cS={apiHost:"https://api.vizzly.co"};class Ho{static{this._instanceStore={}}static{this.DEFAULT_INSTANCE_ID=$i}static{this.eventBus=[]}constructor(e,o,n,b,a,O){this.programmaticDashboard=a,this.dataSets=n,this.queryEngineConfig=o,this.identityConfig=e,this.vizzlyAPIClient=gm(e,b,O)}getDataSets(){return this.dataSets}static async load(e,o=cS){G1("Starting load process for the services package.");const{queryEngine:n,dataSets:b,identity:a,programmaticDashboard:O,extraCustomFields:A}=e,c=new G7(n,a,b,A,o),{queryEngineConfig:R,dataSets:v,identityConfig:N,dashboardStorageStrategy:s}=await c.load(),d=new Pe(N,R,v,s,O,{host:o.apiHost});return Pe._instanceStore[o.instanceId||$i]=d,Pe.queryEngine=n,G1("Loaded services package and added it to the instance store."),d}static use(e=$i){const o=Pe._instanceStore[e];if(!o)throw new Kd(e);return o}static async waitToUse(e=$i,o=1e4){const n=Ho._instanceStore,b=e;return new Promise((a,O)=>{if(n.hasOwnProperty(b)){a(n[b]);return}const A=setTimeout(()=>{clearTimeout(A),O(new TT(e,o))},o),c=setInterval(()=>{n.hasOwnProperty(b)&&(clearTimeout(A),clearInterval(c),a(n[b]))},10)})}static clearInstances(){Pe._instanceStore={},R1.setQueryEngineConfig(null)}async createDashboard(e){BT(e,this.queryEngineConfig);const n=this.vizzlyAPIClient.getDashboardManager(),{dashboard:b}=await n.create({metadata:e.metadata||e.meta,definition:e.definition,parentDashboardId:e.parentDashboardId,permissions:[{scope:"read_write"}],usage_metadata:e.definition?Ul(e.definition,this.dataSets):void 0}),a=Bs(b,this.queryEngineConfig);return Pa(a,this.dataSets,b.definition?.customFields||{})}async updateDashboard(e){ST(e,this.queryEngineConfig);const b=await this.vizzlyAPIClient.getDashboardManager().update({dashboardId:e.dashboardId,metadata:e.metadata||e.meta,definition:e.definition,deleted:e.deleted,abortSignal:e.abortSignal,name:e.name,usage_metadata:e.definition?Ul(e.definition,this.dataSets):void 0}),a=Bs(b,this.queryEngineConfig);return Pa(a,this.dataSets,b.definition?.customFields||{})}async updateScheduledReport(e,o,n){const a=await this.vizzlyAPIClient.getAPIs().vizzlyApi.saveScheduledReport({scheduledReportId:o,cronSchedule:n,dashboardAccessToken:e});if(a.status===200)return n===null?!0:a.body}async getScheduledReports(e){if(this.vizzlyAPIClient){const n=await this.vizzlyAPIClient.getAPIs().vizzlyApi.getScheduledReports({dashboardAccessToken:e});if(n.status===200)return n.body}return{reports:[]}}async getDashboards(e){const a=(await this.vizzlyAPIClient.getDashboardManager().getDashboards(e?.abortController?{abortSignal:e?.abortController.signal}:{})).flatMap(O=>Ho.upcastDashboard(O,this.dataSets,this.queryEngineConfig));return this.programmaticDashboard?p7(a,n7(await this.programmaticDashboard(this.dataSets),this.dataSets)):a}async createGlobalLibrary(e){return await this.vizzlyAPIClient.getGlobalLibraryManager().create(e)}async getGlobalLibraries(e){const b=await this.vizzlyAPIClient.getGlobalLibraryManager().getGlobalLibraries(e?.abortController?{abortSignal:e?.abortController.signal}:{});this.globalLibraryPermissions=b.permissions;const a=b.global_libraries.map(A=>M7(A));return[zS(a,this.getIdentityConfig()).globalLibrary]}getViewConfiguration(){return{queryEngineConfig:this.queryEngineConfig}}getIdentityConfig(){return this.identityConfig}async query(e,o){G1("[Services] Querying data with queries:",e);let n=$i;o?.instanceId&&(n=o.instanceId);const b=Ho._instanceStore[n],a=nS(b.identityConfig,b.queryEngineConfig,MS(LN,o?.dateFilterOptions),o?.variables||{},o?.aliasFields||{},o?.runQueries,o?.data,o?.queryEngineEndpoint,void 0,{instanceId:n});return{results:await(async()=>{try{return await a(e,{abortSignal:o?.abortController?.signal,dataSets:this.dataSets,filterConfig:o?.filterConfig})}catch(A){return dt("[Services] Error fetching data on query:",A),null}})()}}static upcastDashboard(e,o,n){try{const b=Bs(e,n);return[Pa(b,o,e.definition?.customFields||{})]}catch(b){return dt(`Failed to upcast dashboard ${e.id}. This dashboard will not be available for use.`,b),[]}}static filterDashboards(e,o){let n=P0.cloneDeep(e);return o.onlyParentDashboards&&(n=n.filter(b=>b.parentDashboardId===null)),o.onlyChildDashboards&&(n=n.filter(b=>b.parentDashboardId!==null)),o.onlyChildDashboardsForParent&&(n=n.filter(b=>b.parentDashboardId===o.onlyChildDashboardsForParent)),o.onlyAllowScope&&(n=n.filter(b=>b.permission?.scope===o.onlyAllowScope)),o.onlyDashboardsIncludingMetadata&&(n=n.filter(b=>{const a=Object.keys(o.onlyDashboardsIncludingMetadata||{});return P0.every(a,O=>b.metadata[O]===o?.onlyDashboardsIncludingMetadata?.[O])})),n}async updateGlobalLibrary(e){try{return await this.vizzlyAPIClient.getGlobalLibraryManager().update(e)}catch(o){dt("Error updating global library:",o)}}static async eventBusController(e,o){try{const n=Ho.use();if((e.action==="addComponentToLibrary"||e.action==="deleteComponentFromLibrary")&&n.globalLibraryPermissions){Pe.publish({data:{action:"updateToGlobalLibraryStatus",state:ja.SAVING}});const[b]=await Promise.all([await n.getGlobalLibraries({abortController:o?.abortController})]);let a=KO(b);e.action==="addComponentToLibrary"&&(a=c7(b,e.component,e.customFields)),e.action==="deleteComponentFromLibrary"&&(a=l7(b,e.component));const O=z7(n.globalLibraryPermissions,[a]);N6("library and tokens for update",{libraryForUpdate:a,tokenForLibrary:O});const A={globalLibraryId:a.id,library:a.library,abortSignal:o?.abortController?.signal,globalLibrarySessionToken:O};if(await n.updateGlobalLibrary(A)){let R=ja.SAVED;e.action==="deleteComponentFromLibrary"&&(R=ja.DELETED),Pe.publish({data:{action:"newViewsInGlobalLibrary"}}),Pe.publish({data:{action:"updateToGlobalLibraryStatus",state:R}})}}}catch(n){dt("Error handling event:",n)}}static publish(e){Pe.eventBus.map(o=>{o(e)}),Pe.eventBusController(e.data).catch(o=>{dt("Failed to handle event:",o)})}static subscription(e){return Pe.eventBus.push(e),()=>{Pe.eventBus=Pe.eventBus.filter(o=>o!==e)}}static{this.Row=Hd}static{this.Cell=iO}static{this.Dashboard=Y7}static{this.Editor=Q7}static{this.Header=Yd}static{this.Library=K7}static{this.View=R1}static{this.AreaChart=bT}static{this.AreaChartV2=pT}static{this.LineChart=aT}static{this.LineChartV2=MT}static{this.BarChart=zT}static{this.BarChartV2=cT}static{this.PieChart=sT}static{this.BubbleChart=OT}static{this.BubbleChartV2=lT}static{this.ScatterChart=uT}static{this.ComboChart=dT}static{this.ComboChartV2=fT}static{this.PivotTable=qT}static{this.BasicTable=WT}static{this.HorizontalBarChart=hT}static{this.HorizontalBarChartV2=mT}static{this.MercatorMap=gT}static{this.SingleStat=yT}static{this.Progress=RT}static{this.RichText=LT}static{this.WaterfallChart=vT}static{this.FunnelChart=NT}static{this.SunburstChart=AT}static{this.RadarChart=_T}}typeof window<"u"&&!window.Vizzly&&(window.Vizzly=Ho);const Pe=typeof window<"u"&&window.Vizzly||Ho;exports.Vizzly=Pe;exports.VizzlyInstanceNotLoaded=Kd;
@@ -29333,22 +29333,22 @@ Note, you can change the version of the in-memory database by changing '0.8.3' t
29333
29333
  async function Is(t, e, o) {
29334
29334
  return t.type == "vizzlyQueryEngine" ? await AB(t, e, o) : t.type == "vizzlyJsQueryEngine" ? await oS(t, e, o) : t.type == "custom" ? await rS(t, e, o) : [];
29335
29335
  }
29336
- const nS = (t, e, o, n, b, a, O, A, c) => {
29337
- let R = x7(t.dashboardAccess);
29336
+ const nS = (t, e, o, n, b, a, O, A, c, R) => {
29337
+ let v = x7(t.dashboardAccess) + `:::${JSON.stringify(R)}`;
29338
29338
  if (a)
29339
- return async (v, N) => await Is(
29339
+ return async (N, s) => await Is(
29340
29340
  {
29341
29341
  type: "custom",
29342
29342
  queryEngineConfig: e,
29343
29343
  runQueries: a,
29344
29344
  dataAccessToken: t.dataAccess?.signature,
29345
- cacheKeyNamespace: R
29345
+ cacheKeyNamespace: v
29346
29346
  },
29347
- v,
29347
+ N,
29348
29348
  {
29349
- abortSignal: N.abortSignal,
29350
- dataSets: N.dataSets,
29351
- filterConfig: N.filterConfig || {},
29349
+ abortSignal: s.abortSignal,
29350
+ dataSets: s.dataSets,
29351
+ filterConfig: s.filterConfig || {},
29352
29352
  timeRangeOptions: o,
29353
29353
  timeZone: c,
29354
29354
  variables: n,
@@ -29356,17 +29356,17 @@ const nS = (t, e, o, n, b, a, O, A, c) => {
29356
29356
  }
29357
29357
  );
29358
29358
  if (O)
29359
- return async (v, N) => await Is(
29359
+ return async (N, s) => await Is(
29360
29360
  {
29361
29361
  type: "vizzlyJsQueryEngine",
29362
29362
  loadData: O,
29363
- cacheKeyNamespace: R
29363
+ cacheKeyNamespace: v
29364
29364
  },
29365
- v,
29365
+ N,
29366
29366
  {
29367
- abortSignal: N.abortSignal,
29368
- dataSets: N.dataSets,
29369
- filterConfig: N.filterConfig || {},
29367
+ abortSignal: s.abortSignal,
29368
+ dataSets: s.dataSets,
29369
+ filterConfig: s.filterConfig || {},
29370
29370
  timeRangeOptions: o,
29371
29371
  timeZone: c,
29372
29372
  variables: n,
@@ -29374,19 +29374,19 @@ const nS = (t, e, o, n, b, a, O, A, c) => {
29374
29374
  }
29375
29375
  );
29376
29376
  if (A && t.dataAccess?.signature)
29377
- return async (v, N) => await Is(
29377
+ return async (N, s) => await Is(
29378
29378
  {
29379
29379
  type: "vizzlyQueryEngine",
29380
29380
  queryEngineConfig: e,
29381
29381
  dataAccessToken: t.dataAccess?.signature,
29382
29382
  queryEngineEndpoint: A,
29383
- cacheKeyNamespace: R
29383
+ cacheKeyNamespace: v
29384
29384
  },
29385
- v,
29385
+ N,
29386
29386
  {
29387
- abortSignal: N.abortSignal,
29388
- dataSets: N.dataSets,
29389
- filterConfig: N.filterConfig || {},
29387
+ abortSignal: s.abortSignal,
29388
+ dataSets: s.dataSets,
29389
+ filterConfig: s.filterConfig || {},
29390
29390
  timeRangeOptions: o,
29391
29391
  timeZone: c,
29392
29392
  variables: n,
@@ -29647,7 +29647,9 @@ class Ho {
29647
29647
  o?.aliasFields || {},
29648
29648
  o?.runQueries,
29649
29649
  o?.data,
29650
- o?.queryEngineEndpoint
29650
+ o?.queryEngineEndpoint,
29651
+ void 0,
29652
+ { instanceId: n }
29651
29653
  );
29652
29654
  return {
29653
29655
  results: await (async () => {
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "fix-type-alias": "tsc-alias -p tsconfig.types.json",
31
31
  "prepare": "yarn build"
32
32
  },
33
- "version": "0.15.0-dev-21f63b84088b40b7cb4e9022125e04e1004ac6c9",
33
+ "version": "0.15.0-dev-06b713fa3824fa3b950ea5edd24ac98715341051",
34
34
  "dependencies": {
35
35
  "@vizzly/api-client": "0.0.57",
36
36
  "@vizzly/joi": "^17.11.0",