@perses-dev/clickhouse-plugin 0.7.0-beta.2 → 0.7.0-beta.3
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/__mf/js/{ClickHouse.d554fc35.js → ClickHouse.a6c480ad.js} +5 -5
- package/__mf/js/async/{1616.8ee37fc2.js → 1616.23f7de52.js} +1 -1
- package/__mf/js/async/{2043.33c976ff.js → 2043.26d24ddf.js} +2 -2
- package/__mf/js/async/2830.3d2bf599.js +22 -0
- package/__mf/js/async/{2901.98424a07.js → 2901.3320690d.js} +1 -1
- package/__mf/js/async/{3181.7b46b8e9.js → 3181.2599a4a9.js} +2 -2
- package/__mf/js/async/{392.54a0693e.js → 392.7209554a.js} +2 -2
- package/__mf/js/async/{3944.f70c2037.js → 3944.8f01cc6e.js} +2 -2
- package/__mf/js/async/{4077.5b0edb67.js → 4077.f5bd3b11.js} +1 -1
- package/__mf/js/async/{4121.0b653ee5.js → 4121.30e542cb.js} +2 -2
- package/__mf/js/async/{4496.23de7e47.js → 4496.179671a3.js} +1 -1
- package/__mf/js/async/{4569.ffd2c654.js → 4569.4421e9a6.js} +5 -5
- package/__mf/js/async/{5002.2cee2f35.js → 5002.813659a3.js} +1 -1
- package/__mf/js/async/{5071.fe3eb282.js → 5071.b020cbe8.js} +1 -1
- package/__mf/js/async/{5440.6cfd6f26.js → 5440.3299c0d0.js} +2 -2
- package/__mf/js/async/{5562.c5ce26e1.js → 5562.e7586a74.js} +2 -2
- package/__mf/js/async/5587.b5e55a70.js +1 -0
- package/__mf/js/async/{560.acc0c2d1.js → 560.6a7b55b4.js} +1 -1
- package/__mf/js/async/{6045.93765a0a.js → 6045.54b5f54e.js} +1 -1
- package/__mf/js/async/{6274.35dc924b.js → 6274.70ea8472.js} +2 -2
- package/__mf/js/async/{7192.f4e0055e.js → 7192.0b02dc71.js} +1 -1
- package/__mf/js/async/7607.a84a3b43.js +52 -0
- package/__mf/js/async/{7862.306edb3f.js → 7862.67d1d011.js} +2 -2
- package/__mf/js/async/{7943.a43cb4a7.js → 7943.4e169018.js} +2 -2
- package/__mf/js/async/7968.20aaea11.js +1 -0
- package/__mf/js/async/{7978.e22f59c6.js → 7978.e405be26.js} +1 -1
- package/__mf/js/async/8356.3a749ed5.js +1 -0
- package/__mf/js/async/{8470.4652ca18.js → 8470.d544d733.js} +2 -2
- package/__mf/js/async/{873.cae3f07a.js → 873.4aa46ed8.js} +1 -1
- package/__mf/js/async/9207.852c8ee7.js +1 -0
- package/__mf/js/async/{9235.0aff6249.js → 9235.0b860082.js} +1 -1
- package/__mf/js/async/{941.26e4a6ef.js → 941.044f316f.js} +2 -2
- package/__mf/js/async/{9588.a36eacf5.js → 9588.f7cd69d8.js} +1 -1
- package/__mf/js/async/975.e890184f.js +102 -0
- package/__mf/js/async/{__federation_expose_ClickHouseDatasource.1eba91f6.js → __federation_expose_ClickHouseDatasource.9041036d.js} +2 -2
- package/__mf/js/async/{__federation_expose_ClickHouseLogQuery.27676311.js → __federation_expose_ClickHouseLogQuery.c862afff.js} +3 -3
- package/__mf/js/async/{__federation_expose_ClickHouseTimeSeriesQuery.3d225a5d.js → __federation_expose_ClickHouseTimeSeriesQuery.1faab3a8.js} +3 -3
- package/__mf/js/{main.5353a8fc.js → main.49d818cc.js} +5 -5
- package/mf-manifest.json +69 -69
- package/mf-stats.json +69 -69
- package/package.json +9 -9
- package/__mf/js/async/1522.d8e80570.js +0 -22
- package/__mf/js/async/2650.27d5a53e.js +0 -3
- package/__mf/js/async/5587.9797bc5a.js +0 -1
- package/__mf/js/async/7968.a73d7acd.js +0 -1
- package/__mf/js/async/8356.d102e817.js +0 -1
- package/__mf/js/async/9001.0b1d67e2.js +0 -102
- package/__mf/js/async/9207.b184be58.js +0 -1
- /package/__mf/js/async/{2043.33c976ff.js.LICENSE.txt → 2043.26d24ddf.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{1522.d8e80570.js.LICENSE.txt → 2830.3d2bf599.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3181.7b46b8e9.js.LICENSE.txt → 3181.2599a4a9.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.54a0693e.js.LICENSE.txt → 392.7209554a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3944.f70c2037.js.LICENSE.txt → 3944.8f01cc6e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4121.0b653ee5.js.LICENSE.txt → 4121.30e542cb.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4569.ffd2c654.js.LICENSE.txt → 4569.4421e9a6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5440.6cfd6f26.js.LICENSE.txt → 5440.3299c0d0.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5562.c5ce26e1.js.LICENSE.txt → 5562.e7586a74.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6274.35dc924b.js.LICENSE.txt → 6274.70ea8472.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7862.306edb3f.js.LICENSE.txt → 7862.67d1d011.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7943.a43cb4a7.js.LICENSE.txt → 7943.4e169018.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8470.4652ca18.js.LICENSE.txt → 8470.d544d733.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.26e4a6ef.js.LICENSE.txt → 941.044f316f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_ClickHouseDatasource.1eba91f6.js.LICENSE.txt → __federation_expose_ClickHouseDatasource.9041036d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_ClickHouseLogQuery.27676311.js.LICENSE.txt → __federation_expose_ClickHouseLogQuery.c862afff.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_ClickHouseTimeSeriesQuery.3d225a5d.js.LICENSE.txt → __federation_expose_ClickHouseTimeSeriesQuery.1faab3a8.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! For license information please see __federation_expose_ClickHouseDatasource.
|
|
2
|
-
"use strict";(self.
|
|
1
|
+
/*! For license information please see __federation_expose_ClickHouseDatasource.9041036d.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.chunk_ClickHouse_0_7_0_beta_3=self.chunk_ClickHouse_0_7_0_beta_3||[]).push([["3568"],{2192(e,r,t){var o=t(70451),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,i=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,r,t){var o,s={},c=null,u=null;for(o in void 0!==t&&(c=""+t),void 0!==r.key&&(c=""+r.key),void 0!==r.ref&&(u=r.ref),r)n.call(r,o)&&!l.hasOwnProperty(o)&&(s[o]=r[o]);if(e&&e.defaultProps)for(o in r=e.defaultProps)void 0===s[o]&&(s[o]=r[o]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:i.current}}r.Fragment=s,r.jsx=c,r.jsxs=c},62540(e,r,t){e.exports=t(2192)},74480(e,r,t){t.r(r),t.d(r,{ClickHouseDatasourceEditor:()=>n,ClickHouseDatasource:()=>i});var o=t(32325),a=t(62540),s=t(23724);function n(e){let{value:r,onChange:t,isReadonly:o}=e;return(0,a.jsx)(s.HTTPSettingsEditor,{value:r,onChange:t,isReadonly:o,initialSpecDirect:{directUrl:""},initialSpecProxy:{proxy:{kind:"HTTPProxy",spec:{allowedEndpoints:[{endpointPattern:"/",method:"GET"}],url:""}}}})}let i={createClient:(e,r)=>{let{directUrl:t,proxy:a}=e,{proxyUrl:s}=r,n=t??s;if(void 0===n)throw Error("No URL specified for ClickHouseDatasource client. You can use directUrl in the spec to configure it.");let i=(null==a?void 0:a.spec.headers)||{};return{options:{datasourceUrl:n},query:(e,r)=>(0,o.P)(e,{datasourceUrl:n,headers:r??i})}},OptionsEditorComponent:n,createInitialOptions:()=>({directUrl:""})}},32325(e,r,t){function o(e,r,t){return e.replaceAll("{start}",r??"{start}").replaceAll("{end}",t??"{end}")}function a(e){return e.toISOString().replace("T"," ").replace(/\.\d{3}Z$/,"")}async function s(e,r){var t;let{datasourceUrl:a,headers:s}=r,n=(t=a).startsWith("http://")||t.startsWith("https://")?new URL(t):new URL(t,window.location.origin);if(!e.query)throw Error("No query provided in params");let i=o(e.query.trim(),e.start,e.end);i.toUpperCase().includes("FORMAT")||(i+=" FORMAT JSON"),n.searchParams.set("query",i),n.searchParams.set("database",e.database||"default");let l={method:"GET",headers:{...s}};try{let e=await fetch(n.toString(),l);if(!e.ok){let r=await e.text();return console.error("ClickHouse error response:",r),{status:"error",data:[]}}let r=await e.json();return{status:"success",data:r.data||r}}catch(e){throw Error(`ClickHouse query failed: ${e}`,{cause:e})}}t.d(r,{P:()=>s,Vv:()=>a,f7:()=>o})}}]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! For license information please see __federation_expose_ClickHouseLogQuery.
|
|
2
|
-
"use strict";(self.
|
|
1
|
+
/*! For license information please see __federation_expose_ClickHouseLogQuery.c862afff.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.chunk_ClickHouse_0_7_0_beta_3=self.chunk_ClickHouse_0_7_0_beta_3||[]).push([["5547"],{2192(e,t,r){var a=r(70451),o=Symbol.for("react.element"),i=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var a,i={},u=null,c=null;for(a in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)n.call(t,a)&&!l.hasOwnProperty(a)&&(i[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===i[a]&&(i[a]=t[a]);return{$$typeof:o,type:e,key:u,ref:c,props:i,_owner:s.current}}t.Fragment=i,t.jsx=u,t.jsxs=u},62540(e,t,r){e.exports=r(2192)},15062(e,t,r){r.d(t,{t:()=>a});let a=`-- Time Series Query
|
|
3
3
|
SELECT
|
|
4
4
|
toStartOfMinute(timestamp) as time,
|
|
5
5
|
avg(cpu_usage) as avg_cpu,
|
|
@@ -17,4 +17,4 @@ SELECT
|
|
|
17
17
|
SeverityText
|
|
18
18
|
FROM application_logs
|
|
19
19
|
WHERE timestamp >= '{start}'
|
|
20
|
-
ORDER BY time DESC LIMIT 1000`},21261(e,t,r){r.d(t,{N:()=>u});var a=r(62540),o=r(41865),i=r(56599),n=r(315),s=r(54227),l=r(29068);function u(e){let t=(0,i.A)(),r="dark"===t.palette.mode;return(0,a.jsxs)(n.A,{position:"relative",children:[(0,a.jsx)(s.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"ClickHouse Query"}),(0,a.jsx)(l.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[o.Lz.lineWrapping,o.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write ClickHouse Query Here..."})]})}},32325(e,t,r){function a(e,t,r){return e.replaceAll("{start}",t??"{start}").replaceAll("{end}",r??"{end}")}function o(e){return e.toISOString().replace("T"," ").replace(/\.\d{3}Z$/,"")}async function i(e,t){var r;let{datasourceUrl:o,headers:i}=t,n=(r=o).startsWith("http://")||r.startsWith("https://")?new URL(r):new URL(r,window.location.origin);if(!e.query)throw Error("No query provided in params");let s=a(e.query.trim(),e.start,e.end);s.toUpperCase().includes("FORMAT")||(s+=" FORMAT JSON"),n.searchParams.set("query",s),n.searchParams.set("database",e.database||"default");let l={method:"GET",headers:{...i}};try{let e=await fetch(n.toString(),l);if(!e.ok){let t=await e.text();return console.error("ClickHouse error response:",t),{status:"error",data:[]}}let t=await e.json();return{status:"success",data:t.data||t}}catch(e){throw Error(`ClickHouse query failed: ${e}`,{cause:e})}}r.d(t,{P:()=>i,Vv:()=>o,f7:()=>a})},90916(e,t,r){r.r(t),r.d(t,{ClickHouseLogQuery:()=>h,getClickHouseLogData:()=>g,ClickHouseLogQueryEditor:()=>m});var a=r(
|
|
20
|
+
ORDER BY time DESC LIMIT 1000`},21261(e,t,r){r.d(t,{N:()=>u});var a=r(62540),o=r(41865),i=r(56599),n=r(315),s=r(54227),l=r(29068);function u(e){let t=(0,i.A)(),r="dark"===t.palette.mode;return(0,a.jsxs)(n.A,{position:"relative",children:[(0,a.jsx)(s.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"ClickHouse Query"}),(0,a.jsx)(l.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[o.Lz.lineWrapping,o.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write ClickHouse Query Here..."})]})}},32325(e,t,r){function a(e,t,r){return e.replaceAll("{start}",t??"{start}").replaceAll("{end}",r??"{end}")}function o(e){return e.toISOString().replace("T"," ").replace(/\.\d{3}Z$/,"")}async function i(e,t){var r;let{datasourceUrl:o,headers:i}=t,n=(r=o).startsWith("http://")||r.startsWith("https://")?new URL(r):new URL(r,window.location.origin);if(!e.query)throw Error("No query provided in params");let s=a(e.query.trim(),e.start,e.end);s.toUpperCase().includes("FORMAT")||(s+=" FORMAT JSON"),n.searchParams.set("query",s),n.searchParams.set("database",e.database||"default");let l={method:"GET",headers:{...i}};try{let e=await fetch(n.toString(),l);if(!e.ok){let t=await e.text();return console.error("ClickHouse error response:",t),{status:"error",data:[]}}let t=await e.json();return{status:"success",data:t.data||t}}catch(e){throw Error(`ClickHouse query failed: ${e}`,{cause:e})}}r.d(t,{P:()=>i,Vv:()=>o,f7:()=>a})},90916(e,t,r){r.r(t),r.d(t,{ClickHouseLogQuery:()=>h,getClickHouseLogData:()=>g,ClickHouseLogQueryEditor:()=>m});var a=r(23724),o=r(62540),i=r(315),n=r(46244),s=r(38662),l=r(70451),u=r(21261),c=r(15062),d=r(7140),p=r(64383);function m(e){let{onChange:t,value:r}=e,{datasource:m}=r,y=m??d.S,{query:g,handleQueryChange:h,handleQueryBlur:f}=(0,p.Z)(e),_=(0,l.useCallback)(e=>{h(e)},[h]);return(0,o.jsxs)(i.A,{spacing:1.5,children:[(0,o.jsx)(a.DatasourceSelect,{datasourcePluginKind:d.N,value:y,onChange:e=>{if(!(0,a.isVariableDatasource)(e)&&e.kind===d.N)return void t((0,s.produce)(r,t=>{t.datasource=e}));throw Error("Got unexpected non ClickHouse datasource selection")},label:"ClickHouse Datasource",notched:!0}),(0,o.jsx)(u.N,{value:g,onChange:_,onBlur:f,onKeyDown:(0,n.createModEnterHandler)(()=>{t((0,s.produce)(r,e=>{e.query=g}))}),placeholder:"Enter ClickHouse SQL query"}),(0,o.jsxs)("details",{children:[(0,o.jsx)("summary",{style:{cursor:"pointer",fontSize:"12px",color:"#666",marginBottom:"8px"},children:"Query Examples"}),(0,o.jsx)("div",{style:{fontSize:"11px",color:"#777",backgroundColor:"#f5f5f5",padding:"8px",borderRadius:"4px",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',whiteSpace:"pre-wrap",lineHeight:"1.3"},children:c.t})]})]})}var y=r(32325);let g=async(e,t)=>{let r;if(void 0===e.query||null===e.query||""===e.query)return{logs:{entries:[],totalCount:0},timeRange:{start:t.timeRange.start,end:t.timeRange.end}};let o=(0,a.replaceVariables)(e.query,t.variableState),i=await t.datasourceStore.getDatasourceClient(e.datasource??d.S),{start:n,end:s}=t.timeRange,l=(0,y.Vv)(n),u=(0,y.Vv)(s),c=(0,y.f7)(o,l,u);return{timeRange:{start:n,end:s},logs:{entries:r=(await i.query({start:l,end:u,query:c})).data.map(e=>{let t=function e(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(let[o,i]of Object.entries(t)){let t=r?`${r}.${o}`:o;i&&"object"==typeof i&&!Array.isArray(i)?e(i,t,a):a[t]=i}return a}(e);!t.Timestamp&&t.log_time&&(t.Timestamp=t.log_time);let r={};Object.keys(t).toSorted((e,t)=>e.localeCompare(t)).forEach(e=>{r[e]=t[e]});let a=Object.entries(r).filter(e=>{let[t]=e;return"Timestamp"!==t}).map(e=>{let[t,r]=e;return`<${t}> ${""===r||null==r?"--":r}`}).join(" ");return{timestamp:null==r?void 0:r.Timestamp,labels:r,line:a}}),totalCount:r.length},metadata:{executedQueryString:c}}},h={getLogData:g,OptionsEditorComponent:m,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set((0,a.parseVariables)(e.query))]}),createVolumeQuery:()=>null}},7140(e,t,r){r.d(t,{N:()=>a,S:()=>o});let a="ClickHouseDatasource",o={kind:a}},64383(e,t,r){r.d(t,{Z:()=>i});var a=r(38662),o=r(70451);function i(e){let{onChange:t,value:r}=e,[i,n]=(0,o.useState)(r.query||""),[s,l]=(0,o.useState)(r.query);return r.query!==s&&(n(r.query||""),l(r.query)),{query:i,handleQueryChange:e=>{n(e)},handleQueryBlur:()=>{l(i),t((0,a.produce)(r,e=>{e.query=i}))}}}}}]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*! For license information please see __federation_expose_ClickHouseTimeSeriesQuery.
|
|
2
|
-
"use strict";(self.
|
|
1
|
+
/*! For license information please see __federation_expose_ClickHouseTimeSeriesQuery.1faab3a8.js.LICENSE.txt */
|
|
2
|
+
"use strict";(self.chunk_ClickHouse_0_7_0_beta_3=self.chunk_ClickHouse_0_7_0_beta_3||[]).push([["293"],{2192(e,t,r){var a=r(70451),i=Symbol.for("react.element"),n=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,s=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var a,n={},u=null,c=null;for(a in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)o.call(t,a)&&!l.hasOwnProperty(a)&&(n[a]=t[a]);if(e&&e.defaultProps)for(a in t=e.defaultProps)void 0===n[a]&&(n[a]=t[a]);return{$$typeof:i,type:e,key:u,ref:c,props:n,_owner:s.current}}t.Fragment=n,t.jsx=u,t.jsxs=u},62540(e,t,r){e.exports=r(2192)},15062(e,t,r){r.d(t,{t:()=>a});let a=`-- Time Series Query
|
|
3
3
|
SELECT
|
|
4
4
|
toStartOfMinute(timestamp) as time,
|
|
5
5
|
avg(cpu_usage) as avg_cpu,
|
|
@@ -17,4 +17,4 @@ SELECT
|
|
|
17
17
|
SeverityText
|
|
18
18
|
FROM application_logs
|
|
19
19
|
WHERE timestamp >= '{start}'
|
|
20
|
-
ORDER BY time DESC LIMIT 1000`},21261(e,t,r){r.d(t,{N:()=>u});var a=r(62540),i=r(41865),n=r(56599),o=r(315),s=r(54227),l=r(29068);function u(e){let t=(0,n.A)(),r="dark"===t.palette.mode;return(0,a.jsxs)(o.A,{position:"relative",children:[(0,a.jsx)(s.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"ClickHouse Query"}),(0,a.jsx)(l.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[i.Lz.lineWrapping,i.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write ClickHouse Query Here..."})]})}},32325(e,t,r){function a(e,t,r){return e.replaceAll("{start}",t??"{start}").replaceAll("{end}",r??"{end}")}function i(e){return e.toISOString().replace("T"," ").replace(/\.\d{3}Z$/,"")}async function n(e,t){var r;let{datasourceUrl:i,headers:n}=t,o=(r=i).startsWith("http://")||r.startsWith("https://")?new URL(r):new URL(r,window.location.origin);if(!e.query)throw Error("No query provided in params");let s=a(e.query.trim(),e.start,e.end);s.toUpperCase().includes("FORMAT")||(s+=" FORMAT JSON"),o.searchParams.set("query",s),o.searchParams.set("database",e.database||"default");let l={method:"GET",headers:{...n}};try{let e=await fetch(o.toString(),l);if(!e.ok){let t=await e.text();return console.error("ClickHouse error response:",t),{status:"error",data:[]}}let t=await e.json();return{status:"success",data:t.data||t}}catch(e){throw Error(`ClickHouse query failed: ${e}`,{cause:e})}}r.d(t,{P:()=>n,Vv:()=>i,f7:()=>a})},20398(e,t,r){r.r(t),r.d(t,{ClickHouseTimeSeriesQuery:()=>h,ClickHouseTimeSeriesQueryEditor:()=>f,getTimeSeriesData:()=>o});var a=r(
|
|
20
|
+
ORDER BY time DESC LIMIT 1000`},21261(e,t,r){r.d(t,{N:()=>u});var a=r(62540),i=r(41865),n=r(56599),o=r(315),s=r(54227),l=r(29068);function u(e){let t=(0,n.A)(),r="dark"===t.palette.mode;return(0,a.jsxs)(o.A,{position:"relative",children:[(0,a.jsx)(s.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"ClickHouse Query"}),(0,a.jsx)(l.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[i.Lz.lineWrapping,i.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write ClickHouse Query Here..."})]})}},32325(e,t,r){function a(e,t,r){return e.replaceAll("{start}",t??"{start}").replaceAll("{end}",r??"{end}")}function i(e){return e.toISOString().replace("T"," ").replace(/\.\d{3}Z$/,"")}async function n(e,t){var r;let{datasourceUrl:i,headers:n}=t,o=(r=i).startsWith("http://")||r.startsWith("https://")?new URL(r):new URL(r,window.location.origin);if(!e.query)throw Error("No query provided in params");let s=a(e.query.trim(),e.start,e.end);s.toUpperCase().includes("FORMAT")||(s+=" FORMAT JSON"),o.searchParams.set("query",s),o.searchParams.set("database",e.database||"default");let l={method:"GET",headers:{...n}};try{let e=await fetch(o.toString(),l);if(!e.ok){let t=await e.text();return console.error("ClickHouse error response:",t),{status:"error",data:[]}}let t=await e.json();return{status:"success",data:t.data||t}}catch(e){throw Error(`ClickHouse query failed: ${e}`,{cause:e})}}r.d(t,{P:()=>n,Vv:()=>i,f7:()=>a})},20398(e,t,r){r.r(t),r.d(t,{ClickHouseTimeSeriesQuery:()=>h,ClickHouseTimeSeriesQueryEditor:()=>f,getTimeSeriesData:()=>o});var a=r(23724),i=r(32325),n=r(7140);let o=async(e,t)=>{let r;if(void 0===e.query||null===e.query||""===e.query)return{series:[]};let o=(0,a.replaceVariables)(e.query,t.variableState),s=await t.datasourceStore.getDatasourceClient(e.datasource??n.S),{start:l,end:u}=t.timeRange,c=(0,i.Vv)(l),d=(0,i.Vv)(u),p=(0,i.f7)(o,c,d),m=await s.query({start:c,end:d,query:p});return{series:(r=null==m?void 0:m.data,m&&r&&0!==r.length?Object.keys(r[0]??{}).filter(e=>"time"!==e).map(e=>{let t=r.map(t=>[new Date(t.time).getTime(),function(e){if(null==e||""===e)return null;let t=Number(e);return Number.isFinite(t)?t:null}(t[e])]);return{name:e,values:t}}).filter(e=>e.values.some(e=>{let[,t]=e;return null!==t})):[]),timeRange:{start:l,end:u},stepMs:function(e){var t;let r=null==e?void 0:e.data;if(!e||!r||r.length<2)return 3e4;let a=r.map(e=>new Date(e.time).getTime()).filter(Number.isFinite).toSorted((e,t)=>e-t);if(a.length<2)return 3e4;let i=[];for(let e=1;e<a.length;e++){let t=a[e-1],r=a[e];void 0===t||void 0===r||r<=t||i.push(r-t)}if(0===i.length)return 3e4;let n=new Map;for(let e of i)n.set(e,(n.get(e)??0)+1);return(null==(t=Array.from(n.entries()).toSorted((e,t)=>{let[r,a]=e,[i,n]=t;return a!==n?n-a:i-r})[0])?void 0:t[0])??3e4}(m),metadata:{executedQueryString:p}}};var s=r(62540),l=r(315),u=r(46244),c=r(38662),d=r(70451),p=r(21261),m=r(15062),y=r(64383);function f(e){let{onChange:t,value:r}=e,{datasource:i}=r,o=i??n.S,{query:f,handleQueryChange:h,handleQueryBlur:g}=(0,y.Z)(e),v=(0,d.useCallback)(e=>{h(e)},[h]);return(0,s.jsxs)(l.A,{spacing:1.5,children:[(0,s.jsx)(a.DatasourceSelect,{datasourcePluginKind:n.N,value:o,onChange:e=>{if(!(0,a.isVariableDatasource)(e)&&e.kind===n.N)return void t((0,c.produce)(r,t=>{t.datasource=e}));throw Error("Got unexpected non ClickHouse datasource selection")},label:"ClickHouse Datasource",notched:!0}),(0,s.jsx)(p.N,{value:f,onChange:v,onBlur:g,onKeyDown:(0,u.createModEnterHandler)(()=>{t((0,c.produce)(r,e=>{e.query=f}))}),placeholder:"Enter ClickHouse SQL query"}),(0,s.jsxs)("details",{children:[(0,s.jsx)("summary",{style:{cursor:"pointer",fontSize:"12px",color:"#666",marginBottom:"8px"},children:"Query Examples"}),(0,s.jsx)("div",{style:{fontSize:"11px",color:"#777",backgroundColor:"#f5f5f5",padding:"8px",borderRadius:"4px",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',whiteSpace:"pre-wrap",lineHeight:"1.3"},children:m.t})]})]})}let h={getTimeSeriesData:o,OptionsEditorComponent:f,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set((0,a.parseVariables)(e.query))]})}},7140(e,t,r){r.d(t,{N:()=>a,S:()=>i});let a="ClickHouseDatasource",i={kind:a}},64383(e,t,r){r.d(t,{Z:()=>n});var a=r(38662),i=r(70451);function n(e){let{onChange:t,value:r}=e,[n,o]=(0,i.useState)(r.query||""),[s,l]=(0,i.useState)(r.query);return r.query!==s&&(o(r.query||""),l(r.query)),{query:n,handleQueryChange:e=>{o(e)},handleQueryBlur:()=>{l(n),t((0,a.produce)(r,e=>{e.query=n}))}}}}}]);
|