@vizzly/services 0.15.0-dev-dff507f80d240e8e0f91b6d6c4eec2c82f49374f → 0.15.0-dev-94e739b956ca7a1d1481a1e3ac4958988a883fe5

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]=Kd(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]=Kd(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 y=a[c];return y==null?null:{content:y.content,fields:b[c],hasMoreResults:y.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,y)=>Array.isArray(c)?{fields:b[y],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 y=X7(t.dashboardAccess);if(a)return async(v,N)=>await Is({type:"custom",queryEngineConfig:e,runQueries:a,dataAccessToken:t.dataAccess?.signature,cacheKeyNamespace:y},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:y},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:y},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_",""),y=o[c],v=e?.[c];typeof v=="boolean"?v&&(O[A]=y):v!=null?O[A]=v:Ps[c]!==!1&&(O[A]=y)}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=u7(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:d7(t)[0]};if(o&&e.dashboardAccess.accessType==="admin")return{type:"exact",globalLibrary:o};throw"No strategy found."},$i="default";_2.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:y,dataSets:v,identityConfig:N,dashboardStorageStrategy:s}=await c.load(),u=new Ie(N,y,v,s,O,{host:o.apiHost});return Ie._instanceStore[o.instanceId||$i]=u,Ie.queryEngine=n,G1("Loaded services package and added it to the instance store."),u}static use(e=$i){const o=Ie._instanceStore[e];if(!o)throw new Ku(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(){Ie._instanceStore={},y1.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){Ie.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 y=ja.SAVED;e.action==="deleteComponentFromLibrary"&&(y=ja.DELETED),Ie.publish({data:{action:"newViewsInGlobalLibrary"}}),Ie.publish({data:{action:"updateToGlobalLibraryStatus",state:y}})}}}catch(n){dt("Error handling event:",n)}}static publish(e){Ie.eventBus.map(o=>{o(e)}),Ie.eventBusController(e.data).catch(o=>{dt("Failed to handle event:",o)})}static subscription(e){return Ie.eventBus.push(e),()=>{Ie.eventBus=Ie.eventBus.filter(o=>o!==e)}}static{this.Row=Hu}static{this.Cell=iO}static{this.Dashboard=Y7}static{this.Editor=Q7}static{this.Header=Yu}static{this.Library=K7}static{this.View=y1}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=dT}static{this.ComboChart=uT}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 Ie=typeof window<"u"&&window.Vizzly||Ho;exports.Vizzly=Ie;exports.VizzlyInstanceNotLoaded=Ku;
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]=Kd(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]=Kd(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 y=a[c];return y==null?null:{content:y.content,fields:b[c],hasMoreResults:y.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,y)=>Array.isArray(c)?{fields:b[y],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,y)=>{let v=X7(t.dashboardAccess)+`:::${JSON.stringify(y)}`;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_",""),y=o[c],v=e?.[c];typeof v=="boolean"?v&&(O[A]=y):v!=null?O[A]=v:Ps[c]!==!1&&(O[A]=y)}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=u7(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:d7(t)[0]};if(o&&e.dashboardAccess.accessType==="admin")return{type:"exact",globalLibrary:o};throw"No strategy found."},$i="default";_2.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:y,dataSets:v,identityConfig:N,dashboardStorageStrategy:s}=await c.load(),u=new Ie(N,y,v,s,O,{host:o.apiHost});return Ie._instanceStore[o.instanceId||$i]=u,Ie.queryEngine=n,G1("Loaded services package and added it to the instance store."),u}static use(e=$i){const o=Ie._instanceStore[e];if(!o)throw new Ku(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(){Ie._instanceStore={},y1.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){Ie.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 y=ja.SAVED;e.action==="deleteComponentFromLibrary"&&(y=ja.DELETED),Ie.publish({data:{action:"newViewsInGlobalLibrary"}}),Ie.publish({data:{action:"updateToGlobalLibraryStatus",state:y}})}}}catch(n){dt("Error handling event:",n)}}static publish(e){Ie.eventBus.map(o=>{o(e)}),Ie.eventBusController(e.data).catch(o=>{dt("Failed to handle event:",o)})}static subscription(e){return Ie.eventBus.push(e),()=>{Ie.eventBus=Ie.eventBus.filter(o=>o!==e)}}static{this.Row=Hu}static{this.Cell=iO}static{this.Dashboard=Y7}static{this.Editor=Q7}static{this.Header=Yu}static{this.Library=K7}static{this.View=y1}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=dT}static{this.ComboChart=uT}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 Ie=typeof window<"u"&&window.Vizzly||Ho;exports.Vizzly=Ie;exports.VizzlyInstanceNotLoaded=Ku;
@@ -29189,22 +29189,22 @@ Note, you can change the version of the in-memory database by changing '0.8.3' t
29189
29189
  async function Is(t, e, o) {
29190
29190
  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) : [];
29191
29191
  }
29192
- const nS = (t, e, o, n, b, a, O, A, c) => {
29193
- let y = x7(t.dashboardAccess);
29192
+ const nS = (t, e, o, n, b, a, O, A, c, y) => {
29193
+ let v = x7(t.dashboardAccess) + `:::${JSON.stringify(y)}`;
29194
29194
  if (a)
29195
- return async (v, N) => await Is(
29195
+ return async (N, s) => await Is(
29196
29196
  {
29197
29197
  type: "custom",
29198
29198
  queryEngineConfig: e,
29199
29199
  runQueries: a,
29200
29200
  dataAccessToken: t.dataAccess?.signature,
29201
- cacheKeyNamespace: y
29201
+ cacheKeyNamespace: v
29202
29202
  },
29203
- v,
29203
+ N,
29204
29204
  {
29205
- abortSignal: N.abortSignal,
29206
- dataSets: N.dataSets,
29207
- filterConfig: N.filterConfig || {},
29205
+ abortSignal: s.abortSignal,
29206
+ dataSets: s.dataSets,
29207
+ filterConfig: s.filterConfig || {},
29208
29208
  timeRangeOptions: o,
29209
29209
  timeZone: c,
29210
29210
  variables: n,
@@ -29212,17 +29212,17 @@ const nS = (t, e, o, n, b, a, O, A, c) => {
29212
29212
  }
29213
29213
  );
29214
29214
  if (O)
29215
- return async (v, N) => await Is(
29215
+ return async (N, s) => await Is(
29216
29216
  {
29217
29217
  type: "vizzlyJsQueryEngine",
29218
29218
  loadData: O,
29219
- cacheKeyNamespace: y
29219
+ cacheKeyNamespace: v
29220
29220
  },
29221
- v,
29221
+ N,
29222
29222
  {
29223
- abortSignal: N.abortSignal,
29224
- dataSets: N.dataSets,
29225
- filterConfig: N.filterConfig || {},
29223
+ abortSignal: s.abortSignal,
29224
+ dataSets: s.dataSets,
29225
+ filterConfig: s.filterConfig || {},
29226
29226
  timeRangeOptions: o,
29227
29227
  timeZone: c,
29228
29228
  variables: n,
@@ -29230,19 +29230,19 @@ const nS = (t, e, o, n, b, a, O, A, c) => {
29230
29230
  }
29231
29231
  );
29232
29232
  if (A && t.dataAccess?.signature)
29233
- return async (v, N) => await Is(
29233
+ return async (N, s) => await Is(
29234
29234
  {
29235
29235
  type: "vizzlyQueryEngine",
29236
29236
  queryEngineConfig: e,
29237
29237
  dataAccessToken: t.dataAccess?.signature,
29238
29238
  queryEngineEndpoint: A,
29239
- cacheKeyNamespace: y
29239
+ cacheKeyNamespace: v
29240
29240
  },
29241
- v,
29241
+ N,
29242
29242
  {
29243
- abortSignal: N.abortSignal,
29244
- dataSets: N.dataSets,
29245
- filterConfig: N.filterConfig || {},
29243
+ abortSignal: s.abortSignal,
29244
+ dataSets: s.dataSets,
29245
+ filterConfig: s.filterConfig || {},
29246
29246
  timeRangeOptions: o,
29247
29247
  timeZone: c,
29248
29248
  variables: n,
@@ -29503,7 +29503,9 @@ class Ho {
29503
29503
  o?.aliasFields || {},
29504
29504
  o?.runQueries,
29505
29505
  o?.data,
29506
- o?.queryEngineEndpoint
29506
+ o?.queryEngineEndpoint,
29507
+ void 0,
29508
+ { instanceId: n }
29507
29509
  );
29508
29510
  return {
29509
29511
  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-dff507f80d240e8e0f91b6d6c4eec2c82f49374f",
33
+ "version": "0.15.0-dev-94e739b956ca7a1d1481a1e3ac4958988a883fe5",
34
34
  "dependencies": {
35
35
  "@vizzly/api-client": "0.0.57",
36
36
  "@vizzly/joi": "^17.11.0",