@perses-dev/greptimedb-plugin 0.1.0-rc.1 → 0.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.
Files changed (17) hide show
  1. package/__mf/js/{GreptimeDB.a67edbbe.js → GreptimeDB.d666b53a.js} +2 -2
  2. package/__mf/js/async/{3981.aaddf982.js → 3981.66746f5c.js} +2 -2
  3. package/__mf/js/async/{4475.e4e0e724.js → 4475.52c68e1f.js} +3 -3
  4. package/__mf/js/async/{7984.f9d8277f.js → 7984.802dfa3c.js} +3 -3
  5. package/__mf/js/async/{__federation_expose_GreptimeDBDatasource.aa453acf.js → __federation_expose_GreptimeDBDatasource.7d12e7b8.js} +2 -2
  6. package/__mf/js/async/{__federation_expose_GreptimeDBLogQuery.9ace8a1f.js → __federation_expose_GreptimeDBLogQuery.f7fa9b26.js} +2 -2
  7. package/__mf/js/async/{__federation_expose_GreptimeDBTimeSeriesQuery.7d5a3e5d.js → __federation_expose_GreptimeDBTimeSeriesQuery.867c743e.js} +2 -2
  8. package/__mf/js/async/{__federation_expose_GreptimeDBTraceQuery.24f3bce3.js → __federation_expose_GreptimeDBTraceQuery.a1f7328d.js} +2 -2
  9. package/__mf/js/{main.22ea8e89.js → main.7dfdd439.js} +2 -2
  10. package/mf-manifest.json +21 -21
  11. package/mf-stats.json +21 -21
  12. package/package.json +6 -6
  13. /package/__mf/js/async/{7984.f9d8277f.js.LICENSE.txt → 7984.802dfa3c.js.LICENSE.txt} +0 -0
  14. /package/__mf/js/async/{__federation_expose_GreptimeDBDatasource.aa453acf.js.LICENSE.txt → __federation_expose_GreptimeDBDatasource.7d12e7b8.js.LICENSE.txt} +0 -0
  15. /package/__mf/js/async/{__federation_expose_GreptimeDBLogQuery.9ace8a1f.js.LICENSE.txt → __federation_expose_GreptimeDBLogQuery.f7fa9b26.js.LICENSE.txt} +0 -0
  16. /package/__mf/js/async/{__federation_expose_GreptimeDBTimeSeriesQuery.7d5a3e5d.js.LICENSE.txt → __federation_expose_GreptimeDBTimeSeriesQuery.867c743e.js.LICENSE.txt} +0 -0
  17. /package/__mf/js/async/{__federation_expose_GreptimeDBTraceQuery.24f3bce3.js.LICENSE.txt → __federation_expose_GreptimeDBTraceQuery.a1f7328d.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
- /*! For license information please see __federation_expose_GreptimeDBDatasource.aa453acf.js.LICENSE.txt */
2
- "use strict";(self.chunk_GreptimeDB=self.chunk_GreptimeDB||[]).push([["9371"],{2192(e,t,r){var o=r(70451),i=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=o.__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 o,n={},u=null,c=null;for(o in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)s.call(t,o)&&!l.hasOwnProperty(o)&&(n[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===n[o]&&(n[o]=t[o]);return{$$typeof:i,type:e,key:u,ref:c,props:n,_owner:a.current}}t.Fragment=n,t.jsx=u,t.jsxs=u},62540(e,t,r){e.exports=r(2192)},26599(e,t,r){async function o(e){var t;let r=null==(t=e.headers)?void 0:t.get("content-type");if(r&&r.includes("application/json")){let t=await e.json();return`GreptimeDB error: ${e.status} ${e.statusText} - ${JSON.stringify(t)}`}let o=await e.text();return`GreptimeDB error: ${e.status} ${e.statusText} - ${o}`}async function i(e,t){var r;let i,{datasourceUrl:n,headers:s}=t,a=(i=(r=n).endsWith("/")?`${r}v1/sql`:`${r}/v1/sql`).startsWith("http://")||i.startsWith("https://")?new URL(i):new URL(i,window.location.origin);if(!e.query)throw Error("No query provided in params");let l={method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...s??{}},body:new URLSearchParams({sql:e.query}).toString()};try{let e=await fetch(a.toString(),l);if(!e.ok){let t=await o(e);return console.error("GreptimeDB error response:",t),{status:"error",data:{output:[]},error:t}}let t=await e.json();return{status:(null==t?void 0:t.status)??"success",data:t}}catch(e){throw Error(`GreptimeDB query failed: ${e}`)}}r.r(t),r.d(t,{GreptimeDBDatasource:()=>l,GreptimeDBDatasourceEditor:()=>a});var n=r(62540),s=r(90617);function a(e){let{value:t,onChange:r,isReadonly:o}=e;return(0,n.jsx)(s.HTTPSettingsEditor,{value:t,onChange:r,isReadonly:o,initialSpecDirect:{directUrl:""},initialSpecProxy:{proxy:{kind:"HTTPProxy",spec:{allowedEndpoints:[{endpointPattern:"/v1/sql",method:"POST"}],url:""}}}})}let l={createClient:(e,t)=>{let{directUrl:r,headers:o,proxy:n}=e,{proxyUrl:s}=t,a=r??s;if(void 0===a)throw Error("No URL specified for GreptimeDBDatasource client. You can use directUrl in the spec to configure it.");let l={...(null==n?void 0:n.spec.headers)??{},...o??{}};return{options:{datasourceUrl:a},query:(e,t)=>i(e,{datasourceUrl:a,headers:t??l})}},OptionsEditorComponent:a,createInitialOptions:()=>({directUrl:""})}}}]);
1
+ /*! For license information please see __federation_expose_GreptimeDBDatasource.7d12e7b8.js.LICENSE.txt */
2
+ "use strict";(self.chunk_GreptimeDB=self.chunk_GreptimeDB||[]).push([["9371"],{2192(e,t,r){var o=r(70451),i=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=o.__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 o,n={},u=null,c=null;for(o in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(c=t.ref),t)s.call(t,o)&&!l.hasOwnProperty(o)&&(n[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===n[o]&&(n[o]=t[o]);return{$$typeof:i,type:e,key:u,ref:c,props:n,_owner:a.current}}t.Fragment=n,t.jsx=u,t.jsxs=u},62540(e,t,r){e.exports=r(2192)},26599(e,t,r){async function o(e){var t;let r=null==(t=e.headers)?void 0:t.get("content-type");if(r&&r.includes("application/json")){let t=await e.json();return`GreptimeDB error: ${e.status} ${e.statusText} - ${JSON.stringify(t)}`}let o=await e.text();return`GreptimeDB error: ${e.status} ${e.statusText} - ${o}`}async function i(e,t){var r;let i,{datasourceUrl:n,headers:s}=t,a=(i=(r=n).endsWith("/")?`${r}v1/sql`:`${r}/v1/sql`).startsWith("http://")||i.startsWith("https://")?new URL(i):new URL(i,window.location.origin);if(!e.query)throw Error("No query provided in params");let l={method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",...s??{}},body:new URLSearchParams({sql:e.query}).toString()};try{let e=await fetch(a.toString(),l);if(!e.ok){let t=await o(e);return console.error("GreptimeDB error response:",t),{status:"error",data:{output:[]},error:t}}let t=await e.json();return{status:(null==t?void 0:t.status)??"success",data:t}}catch(e){throw Error(`GreptimeDB query failed: ${e}`)}}r.r(t),r.d(t,{GreptimeDBDatasource:()=>l,GreptimeDBDatasourceEditor:()=>a});var n=r(62540),s=r(19848);function a(e){let{value:t,onChange:r,isReadonly:o}=e;return(0,n.jsx)(s.HTTPSettingsEditor,{value:t,onChange:r,isReadonly:o,initialSpecDirect:{directUrl:""},initialSpecProxy:{proxy:{kind:"HTTPProxy",spec:{allowedEndpoints:[{endpointPattern:"/v1/sql",method:"POST"}],url:""}}}})}let l={createClient:(e,t)=>{let{directUrl:r,headers:o,proxy:n}=e,{proxyUrl:s}=t,a=r??s;if(void 0===a)throw Error("No URL specified for GreptimeDBDatasource client. You can use directUrl in the spec to configure it.");let l={...(null==n?void 0:n.spec.headers)??{},...o??{}};return{options:{datasourceUrl:a},query:(e,t)=>i(e,{datasourceUrl:a,headers:t??l})}},OptionsEditorComponent:a,createInitialOptions:()=>({directUrl:""})}}}]);
@@ -1,4 +1,4 @@
1
- /*! For license information please see __federation_expose_GreptimeDBLogQuery.9ace8a1f.js.LICENSE.txt */
1
+ /*! For license information please see __federation_expose_GreptimeDBLogQuery.f7fa9b26.js.LICENSE.txt */
2
2
  "use strict";(self.chunk_GreptimeDB=self.chunk_GreptimeDB||[]).push([["5396"],{2192(e,t,r){var n=r(70451),a=Symbol.for("react.element"),i=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var n,i={},s=null,m=null;for(n in void 0!==r&&(s=""+r),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(m=t.ref),t)o.call(t,n)&&!u.hasOwnProperty(n)&&(i[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===i[n]&&(i[n]=t[n]);return{$$typeof:a,type:e,key:s,ref:m,props:i,_owner:l.current}}t.Fragment=i,t.jsx=s,t.jsxs=s},62540(e,t,r){e.exports=r(2192)},15062(e,t,r){r.d(t,{t:()=>n});let n=`-- Time Series Query
3
3
  SELECT
4
4
  date_bin(INTERVAL '1 minute', ts) as ts,
@@ -18,4 +18,4 @@ SELECT
18
18
  FROM application_logs
19
19
  WHERE ts BETWEEN to_timestamp_millis($__from) AND to_timestamp_millis($__to)
20
20
  ORDER BY ts DESC
21
- LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>s});var n=r(62540),a=r(29068),i=r(41865),o=r(56599),l=r(315),u=r(54227);function s(e){let t=(0,o.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(l.A,{position:"relative",children:[(0,n.jsx)(u.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(a.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 GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>a});let n="GreptimeDBDatasource",a={kind:n}},64279(e,t,r){r.r(t),r.d(t,{GreptimeDBLogQuery:()=>y,GreptimeDBLogQueryEditor:()=>g,getGreptimeDBLogData:()=>o});var n=r(90617),a=r(7140),i=r(57748);let o=async(e,t)=>{if(!e.query)return{logs:{entries:[],totalCount:0},timeRange:{start:t.timeRange.start,end:t.timeRange.end}};let{start:r,end:n}=t.timeRange,o=(0,i.EY)(e.query,t.variableState,t.timeRange),l=await t.datasourceStore.getDatasourceClient(e.datasource??a.S),u=await l.query({start:r.getTime().toString(),end:n.getTime().toString(),query:o});if("error"===u.status)throw Error(u.error??"GreptimeDB query failed");return{timeRange:{start:r,end:n},logs:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return{entries:[],totalCount:0};let a=(0,i.nu)(r);if(-1===a)return{entries:[],totalCount:0};let o=n.map(e=>{var t;let n=(0,i.W0)(null==e?void 0:e[a],null==(t=r[a])?void 0:t.data_type);if(null===n)return null;let o={},l=[];return r.forEach((t,r)=>{if(r===a)return;let n=null==e?void 0:e[r],i=null==n?"":String(n);o[t.name]=i,l.push(`${t.name}=${""===i?"--":i}`)}),{timestamp:Math.floor(n/1e3),labels:o,line:l.join(" ")}}).filter(e=>null!==e);return{entries:o,totalCount:o.length}}((0,i.qV)(u.data)),metadata:{executedQueryString:o}}};var l=r(62540),u=r(70451),s=r(38662),m=r(56599),d=r(315),p=r(71122),c=r(15062),f=r(64383);function g(e){let t=(0,m.A)(),{onChange:r,value:i}=e,{datasource:o}=i,g=o??a.S,{query:y,handleQueryChange:_,handleQueryBlur:h}=(0,f.Z)(e),v=(0,u.useCallback)(e=>{_(e)},[_]),x={fontSize:"11px",color:t.palette.text.secondary,backgroundColor:t.palette.background.code,padding:"8px",borderRadius:"4px",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',whiteSpace:"pre-wrap",lineHeight:"1.3"};return(0,l.jsxs)(d.A,{spacing:1.5,children:[(0,l.jsx)(n.DatasourceSelect,{datasourcePluginKind:a.N,value:g,onChange:e=>{if(!(0,n.isVariableDatasource)(e)&&e.kind===a.N)return void r((0,s.jM)(i,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,l.jsx)(p.M,{value:y,onChange:v,onBlur:h,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),r((0,s.jM)(i,e=>{e.query=y})))},placeholder:"Enter GreptimeDB SQL query"}),(0,l.jsxs)("details",{children:[(0,l.jsx)("summary",{style:{cursor:"pointer",fontSize:"12px",color:t.palette.text.secondary,marginBottom:"8px"},children:"Query Examples"}),(0,l.jsx)("div",{style:x,children:c.t})]})]})}let y={getLogData:o,OptionsEditorComponent:g,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set([...(0,n.parseVariables)(e.query)])]})}},57748(e,t,r){r.d(t,{EY:()=>a,W0:()=>function e(t,r){if(null==t)return null;let n=i(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let a=new Date(t).getTime();return Number.isNaN(a)?null:a},nu:()=>l,qV:()=>o});var n=r(90617);function a(e,t,r){let a,i,o,l,u,{start:s,end:m}=r,d=m.valueOf()-s.valueOf(),p={__from:{value:s.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:d.toString(),loading:!1},__range_s:{value:Math.floor(d/1e3).toString(),loading:!1},__range:{value:(i=Math.floor((a=Math.floor(d/1e3))/3600),o=Math.floor(a%3600/60),l=a%60,u="",i>0&&(u+=`${i}h`),o>0&&(u+=`${o}m`),(l>0||""===u)&&(u+=`${l}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...p,...t})}function i(e){return e?e.toLowerCase():null}function o(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function l(e){let t=-1,r=e.filter(e=>{let t=i(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=["greptime_timestamp","timestamp","ts","time"];t=e.findIndex(e=>r.includes(e.name.toLowerCase()))}return t}},64383(e,t,r){r.d(t,{Z:()=>i});var n=r(38662),a=r(70451);function i(e){let{onChange:t,value:r}=e,[i,o]=(0,a.useState)(r.query||""),[l,u]=(0,a.useState)(r.query);return r.query!==l&&(o(r.query||""),u(r.query)),{query:i,handleQueryChange:e=>{o(e)},handleQueryBlur:()=>{u(i),t((0,n.jM)(r,e=>{e.query=i}))}}}}}]);
21
+ LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>s});var n=r(62540),a=r(29068),i=r(41865),o=r(56599),l=r(315),u=r(54227);function s(e){let t=(0,o.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(l.A,{position:"relative",children:[(0,n.jsx)(u.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(a.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 GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>a});let n="GreptimeDBDatasource",a={kind:n}},64279(e,t,r){r.r(t),r.d(t,{GreptimeDBLogQuery:()=>y,GreptimeDBLogQueryEditor:()=>g,getGreptimeDBLogData:()=>o});var n=r(19848),a=r(7140),i=r(57748);let o=async(e,t)=>{if(!e.query)return{logs:{entries:[],totalCount:0},timeRange:{start:t.timeRange.start,end:t.timeRange.end}};let{start:r,end:n}=t.timeRange,o=(0,i.EY)(e.query,t.variableState,t.timeRange),l=await t.datasourceStore.getDatasourceClient(e.datasource??a.S),u=await l.query({start:r.getTime().toString(),end:n.getTime().toString(),query:o});if("error"===u.status)throw Error(u.error??"GreptimeDB query failed");return{timeRange:{start:r,end:n},logs:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return{entries:[],totalCount:0};let a=(0,i.nu)(r);if(-1===a)return{entries:[],totalCount:0};let o=n.map(e=>{var t;let n=(0,i.W0)(null==e?void 0:e[a],null==(t=r[a])?void 0:t.data_type);if(null===n)return null;let o={},l=[];return r.forEach((t,r)=>{if(r===a)return;let n=null==e?void 0:e[r],i=null==n?"":String(n);o[t.name]=i,l.push(`${t.name}=${""===i?"--":i}`)}),{timestamp:Math.floor(n/1e3),labels:o,line:l.join(" ")}}).filter(e=>null!==e);return{entries:o,totalCount:o.length}}((0,i.qV)(u.data)),metadata:{executedQueryString:o}}};var l=r(62540),u=r(70451),s=r(38662),m=r(56599),d=r(315),p=r(71122),c=r(15062),f=r(64383);function g(e){let t=(0,m.A)(),{onChange:r,value:i}=e,{datasource:o}=i,g=o??a.S,{query:y,handleQueryChange:_,handleQueryBlur:h}=(0,f.Z)(e),v=(0,u.useCallback)(e=>{_(e)},[_]),x={fontSize:"11px",color:t.palette.text.secondary,backgroundColor:t.palette.background.code,padding:"8px",borderRadius:"4px",fontFamily:'Monaco, Menlo, "Ubuntu Mono", monospace',whiteSpace:"pre-wrap",lineHeight:"1.3"};return(0,l.jsxs)(d.A,{spacing:1.5,children:[(0,l.jsx)(n.DatasourceSelect,{datasourcePluginKind:a.N,value:g,onChange:e=>{if(!(0,n.isVariableDatasource)(e)&&e.kind===a.N)return void r((0,s.jM)(i,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,l.jsx)(p.M,{value:y,onChange:v,onBlur:h,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),r((0,s.jM)(i,e=>{e.query=y})))},placeholder:"Enter GreptimeDB SQL query"}),(0,l.jsxs)("details",{children:[(0,l.jsx)("summary",{style:{cursor:"pointer",fontSize:"12px",color:t.palette.text.secondary,marginBottom:"8px"},children:"Query Examples"}),(0,l.jsx)("div",{style:x,children:c.t})]})]})}let y={getLogData:o,OptionsEditorComponent:g,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set([...(0,n.parseVariables)(e.query)])]})}},57748(e,t,r){r.d(t,{EY:()=>a,W0:()=>function e(t,r){if(null==t)return null;let n=i(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let a=new Date(t).getTime();return Number.isNaN(a)?null:a},nu:()=>l,qV:()=>o});var n=r(19848);function a(e,t,r){let a,i,o,l,u,{start:s,end:m}=r,d=m.valueOf()-s.valueOf(),p={__from:{value:s.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:d.toString(),loading:!1},__range_s:{value:Math.floor(d/1e3).toString(),loading:!1},__range:{value:(i=Math.floor((a=Math.floor(d/1e3))/3600),o=Math.floor(a%3600/60),l=a%60,u="",i>0&&(u+=`${i}h`),o>0&&(u+=`${o}m`),(l>0||""===u)&&(u+=`${l}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...p,...t})}function i(e){return e?e.toLowerCase():null}function o(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function l(e){let t=-1,r=e.filter(e=>{let t=i(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=["greptime_timestamp","timestamp","ts","time"];t=e.findIndex(e=>r.includes(e.name.toLowerCase()))}return t}},64383(e,t,r){r.d(t,{Z:()=>i});var n=r(38662),a=r(70451);function i(e){let{onChange:t,value:r}=e,[i,o]=(0,a.useState)(r.query||""),[l,u]=(0,a.useState)(r.query);return r.query!==l&&(o(r.query||""),u(r.query)),{query:i,handleQueryChange:e=>{o(e)},handleQueryBlur:()=>{u(i),t((0,n.jM)(r,e=>{e.query=i}))}}}}}]);
@@ -1,4 +1,4 @@
1
- /*! For license information please see __federation_expose_GreptimeDBTimeSeriesQuery.7d5a3e5d.js.LICENSE.txt */
1
+ /*! For license information please see __federation_expose_GreptimeDBTimeSeriesQuery.867c743e.js.LICENSE.txt */
2
2
  "use strict";(self.chunk_GreptimeDB=self.chunk_GreptimeDB||[]).push([["9548"],{2192(e,t,r){var n=r(70451),i=Symbol.for("react.element"),l=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var n,l={},s=null,m=null;for(n in void 0!==r&&(s=""+r),void 0!==t.key&&(s=""+t.key),void 0!==t.ref&&(m=t.ref),t)a.call(t,n)&&!u.hasOwnProperty(n)&&(l[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===l[n]&&(l[n]=t[n]);return{$$typeof:i,type:e,key:s,ref:m,props:l,_owner:o.current}}t.Fragment=l,t.jsx=s,t.jsxs=s},62540(e,t,r){e.exports=r(2192)},15062(e,t,r){r.d(t,{t:()=>n});let n=`-- Time Series Query
3
3
  SELECT
4
4
  date_bin(INTERVAL '1 minute', ts) as ts,
@@ -18,4 +18,4 @@ SELECT
18
18
  FROM application_logs
19
19
  WHERE ts BETWEEN to_timestamp_millis($__from) AND to_timestamp_millis($__to)
20
20
  ORDER BY ts DESC
21
- LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>s});var n=r(62540),i=r(29068),l=r(41865),a=r(56599),o=r(315),u=r(54227);function s(e){let t=(0,a.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(o.A,{position:"relative",children:[(0,n.jsx)(u.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(i.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[l.Lz.lineWrapping,l.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>i});let n="GreptimeDBDatasource",i={kind:n}},57748(e,t,r){r.d(t,{EY:()=>i,W0:()=>function e(t,r){if(null==t)return null;let n=l(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let i=new Date(t).getTime();return Number.isNaN(i)?null:i},nu:()=>o,qV:()=>a});var n=r(90617);function i(e,t,r){let i,l,a,o,u,{start:s,end:m}=r,d=m.valueOf()-s.valueOf(),c={__from:{value:s.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:d.toString(),loading:!1},__range_s:{value:Math.floor(d/1e3).toString(),loading:!1},__range:{value:(l=Math.floor((i=Math.floor(d/1e3))/3600),a=Math.floor(i%3600/60),o=i%60,u="",l>0&&(u+=`${l}h`),a>0&&(u+=`${a}m`),(o>0||""===u)&&(u+=`${o}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...c,...t})}function l(e){return e?e.toLowerCase():null}function a(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function o(e){let t=-1,r=e.filter(e=>{let t=l(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=["greptime_timestamp","timestamp","ts","time"];t=e.findIndex(e=>r.includes(e.name.toLowerCase()))}return t}},85816(e,t,r){r.r(t),r.d(t,{GreptimeDBTimeSeriesQueryEditor:()=>g,getTimeSeriesData:()=>a,GreptimeDBTimeSeriesQuery:()=>v});var n=r(7140),i=r(57748);function l(e){if(!e)return!1;let t=e.toLowerCase();return t.includes("int")||t.includes("float")||t.includes("double")||t.includes("decimal")||t.includes("number")}let a=async(e,t)=>{var r;if(!e.query)return{series:[]};let{start:a,end:o}=t.timeRange,u=(0,i.EY)(e.query,t.variableState,t.timeRange),s=await t.datasourceStore.getDatasourceClient(e.datasource??n.S),m=await s.query({start:a.getTime().toString(),end:o.getTime().toString(),query:u});if("error"===m.status)throw Error(m.error??"GreptimeDB query failed");let d=(0,i.qV)(m.data),c=(null==d||null==(r=d.schema)?void 0:r.column_schemas)??[],f=(null==d?void 0:d.rows)??[],p=function(e,t){var r,n,a,o;let u=(null==e||null==(r=e.schema)?void 0:r.column_schemas)??[],s=(null==e?void 0:e.rows)??[];if(!u.length||!s.length)return[];let m=(0,i.nu)(u);if(-1===m){let e=u.findIndex(e=>l(e.data_type));if(-1===e)return[];let r=(null==(a=u[e])?void 0:a.name)??"value",n=[];return(s.forEach((r,i)=>{let l=null==r?void 0:r[e],a="number"==typeof l?l:Number(l);Number.isFinite(a)&&n.push([t+i,a])}),0===n.length)?[]:[{name:r,labels:{},values:n}]}let d=u.findIndex((e,t)=>t!==m&&"greptime_value"===e.name.toLowerCase());-1===d&&(d=u.findIndex((e,t)=>t!==m&&"value"===e.name.toLowerCase())),-1===d&&(d=u.findIndex((e,t)=>t!==m&&l(e.data_type))),-1===d&&(d=u.findIndex((e,t)=>t!==m));let c=(null==(n=u[d])?void 0:n.name)??"value",f=new Map;for(let e of s){let t=(0,i.W0)(null==e?void 0:e[m],null==(o=u[m])?void 0:o.data_type);if(null===t)continue;let r=null==e?void 0:e[d],n="number"==typeof r?r:Number(r);if(!Number.isFinite(n))continue;let l={};u.forEach((t,r)=>{if(r===m||r===d)return;let n=null==e?void 0:e[r];l[t.name]=null==n?"":String(n)});let a=u.filter((e,t)=>t!==m&&t!==d).map(e=>`${e.name}=${l[e.name]??""}`).join("|"),s=`${c}|${a}`,p=f.get(s);p?p.values.push([t,n]):f.set(s,{name:function(e,t){let r=Object.entries(t);return 0===r.length?e:r.map(e=>{let[t,r]=e;return`${t}=${r}`}).join(",")}(c,l),labels:l,values:[[t,n]]})}return Array.from(f.values()).filter(e=>e.values.length>0)}(d,o.getTime()),g=function(e,t){let r=1/0;for(let t of e){let e=[...t.values.map(e=>{let[t]=e;return t})].sort((e,t)=>e-t);for(let t=1;t<e.length;t++){let n=e[t]-e[t-1];n>0&&n<r&&(r=n)}}return Number.isFinite(r)?r:t}(p,t.suggestedStepMs||3e4);return{series:p,timeRange:{start:a,end:o},stepMs:g,metadata:{executedQueryString:u,records:d,table:{columns:c,rows:f}}}};var o=r(90617),u=r(62540),s=r(70451),m=r(38662),d=r(315),c=r(71122),f=r(15062),p=r(64383);function g(e){let{onChange:t,value:r}=e,{datasource:i}=r,l=i??n.S,{query:a,handleQueryChange:g,handleQueryBlur:v}=(0,p.Z)(e),y=(0,s.useCallback)(e=>{g(e)},[g]);return(0,u.jsxs)(d.A,{spacing:1.5,children:[(0,u.jsx)(o.DatasourceSelect,{datasourcePluginKind:n.N,value:l,onChange:e=>{if(!(0,o.isVariableDatasource)(e)&&e.kind===n.N)return void t((0,m.jM)(r,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,u.jsx)(c.M,{value:a,onChange:y,onBlur:v,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),t((0,m.jM)(r,e=>{e.query=a})))},placeholder:"Enter GreptimeDB SQL query"}),(0,u.jsxs)("details",{children:[(0,u.jsx)("summary",{style:{cursor:"pointer",fontSize:"12px",color:"#666",marginBottom:"8px"},children:"Query Examples"}),(0,u.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:f.t})]})]})}let v={getTimeSeriesData:a,OptionsEditorComponent:g,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set([...(0,o.parseVariables)(e.query)])]})}},64383(e,t,r){r.d(t,{Z:()=>l});var n=r(38662),i=r(70451);function l(e){let{onChange:t,value:r}=e,[l,a]=(0,i.useState)(r.query||""),[o,u]=(0,i.useState)(r.query);return r.query!==o&&(a(r.query||""),u(r.query)),{query:l,handleQueryChange:e=>{a(e)},handleQueryBlur:()=>{u(l),t((0,n.jM)(r,e=>{e.query=l}))}}}}}]);
21
+ LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>s});var n=r(62540),i=r(29068),l=r(41865),a=r(56599),o=r(315),u=r(54227);function s(e){let t=(0,a.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(o.A,{position:"relative",children:[(0,n.jsx)(u.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(i.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[l.Lz.lineWrapping,l.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>i});let n="GreptimeDBDatasource",i={kind:n}},57748(e,t,r){r.d(t,{EY:()=>i,W0:()=>function e(t,r){if(null==t)return null;let n=l(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let i=new Date(t).getTime();return Number.isNaN(i)?null:i},nu:()=>o,qV:()=>a});var n=r(19848);function i(e,t,r){let i,l,a,o,u,{start:s,end:m}=r,d=m.valueOf()-s.valueOf(),c={__from:{value:s.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:d.toString(),loading:!1},__range_s:{value:Math.floor(d/1e3).toString(),loading:!1},__range:{value:(l=Math.floor((i=Math.floor(d/1e3))/3600),a=Math.floor(i%3600/60),o=i%60,u="",l>0&&(u+=`${l}h`),a>0&&(u+=`${a}m`),(o>0||""===u)&&(u+=`${o}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...c,...t})}function l(e){return e?e.toLowerCase():null}function a(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function o(e){let t=-1,r=e.filter(e=>{let t=l(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=["greptime_timestamp","timestamp","ts","time"];t=e.findIndex(e=>r.includes(e.name.toLowerCase()))}return t}},85816(e,t,r){r.r(t),r.d(t,{GreptimeDBTimeSeriesQueryEditor:()=>g,getTimeSeriesData:()=>a,GreptimeDBTimeSeriesQuery:()=>v});var n=r(7140),i=r(57748);function l(e){if(!e)return!1;let t=e.toLowerCase();return t.includes("int")||t.includes("float")||t.includes("double")||t.includes("decimal")||t.includes("number")}let a=async(e,t)=>{var r;if(!e.query)return{series:[]};let{start:a,end:o}=t.timeRange,u=(0,i.EY)(e.query,t.variableState,t.timeRange),s=await t.datasourceStore.getDatasourceClient(e.datasource??n.S),m=await s.query({start:a.getTime().toString(),end:o.getTime().toString(),query:u});if("error"===m.status)throw Error(m.error??"GreptimeDB query failed");let d=(0,i.qV)(m.data),c=(null==d||null==(r=d.schema)?void 0:r.column_schemas)??[],f=(null==d?void 0:d.rows)??[],p=function(e,t){var r,n,a,o;let u=(null==e||null==(r=e.schema)?void 0:r.column_schemas)??[],s=(null==e?void 0:e.rows)??[];if(!u.length||!s.length)return[];let m=(0,i.nu)(u);if(-1===m){let e=u.findIndex(e=>l(e.data_type));if(-1===e)return[];let r=(null==(a=u[e])?void 0:a.name)??"value",n=[];return(s.forEach((r,i)=>{let l=null==r?void 0:r[e],a="number"==typeof l?l:Number(l);Number.isFinite(a)&&n.push([t+i,a])}),0===n.length)?[]:[{name:r,labels:{},values:n}]}let d=u.findIndex((e,t)=>t!==m&&"greptime_value"===e.name.toLowerCase());-1===d&&(d=u.findIndex((e,t)=>t!==m&&"value"===e.name.toLowerCase())),-1===d&&(d=u.findIndex((e,t)=>t!==m&&l(e.data_type))),-1===d&&(d=u.findIndex((e,t)=>t!==m));let c=(null==(n=u[d])?void 0:n.name)??"value",f=new Map;for(let e of s){let t=(0,i.W0)(null==e?void 0:e[m],null==(o=u[m])?void 0:o.data_type);if(null===t)continue;let r=null==e?void 0:e[d],n="number"==typeof r?r:Number(r);if(!Number.isFinite(n))continue;let l={};u.forEach((t,r)=>{if(r===m||r===d)return;let n=null==e?void 0:e[r];l[t.name]=null==n?"":String(n)});let a=u.filter((e,t)=>t!==m&&t!==d).map(e=>`${e.name}=${l[e.name]??""}`).join("|"),s=`${c}|${a}`,p=f.get(s);p?p.values.push([t,n]):f.set(s,{name:function(e,t){let r=Object.entries(t);return 0===r.length?e:r.map(e=>{let[t,r]=e;return`${t}=${r}`}).join(",")}(c,l),labels:l,values:[[t,n]]})}return Array.from(f.values()).filter(e=>e.values.length>0)}(d,o.getTime()),g=function(e,t){let r=1/0;for(let t of e){let e=[...t.values.map(e=>{let[t]=e;return t})].sort((e,t)=>e-t);for(let t=1;t<e.length;t++){let n=e[t]-e[t-1];n>0&&n<r&&(r=n)}}return Number.isFinite(r)?r:t}(p,t.suggestedStepMs||3e4);return{series:p,timeRange:{start:a,end:o},stepMs:g,metadata:{executedQueryString:u,records:d,table:{columns:c,rows:f}}}};var o=r(19848),u=r(62540),s=r(70451),m=r(38662),d=r(315),c=r(71122),f=r(15062),p=r(64383);function g(e){let{onChange:t,value:r}=e,{datasource:i}=r,l=i??n.S,{query:a,handleQueryChange:g,handleQueryBlur:v}=(0,p.Z)(e),y=(0,s.useCallback)(e=>{g(e)},[g]);return(0,u.jsxs)(d.A,{spacing:1.5,children:[(0,u.jsx)(o.DatasourceSelect,{datasourcePluginKind:n.N,value:l,onChange:e=>{if(!(0,o.isVariableDatasource)(e)&&e.kind===n.N)return void t((0,m.jM)(r,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,u.jsx)(c.M,{value:a,onChange:y,onBlur:v,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),t((0,m.jM)(r,e=>{e.query=a})))},placeholder:"Enter GreptimeDB SQL query"}),(0,u.jsxs)("details",{children:[(0,u.jsx)("summary",{style:{cursor:"pointer",fontSize:"12px",color:"#666",marginBottom:"8px"},children:"Query Examples"}),(0,u.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:f.t})]})]})}let v={getTimeSeriesData:a,OptionsEditorComponent:g,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set([...(0,o.parseVariables)(e.query)])]})}},64383(e,t,r){r.d(t,{Z:()=>l});var n=r(38662),i=r(70451);function l(e){let{onChange:t,value:r}=e,[l,a]=(0,i.useState)(r.query||""),[o,u]=(0,i.useState)(r.query);return r.query!==o&&(a(r.query||""),u(r.query)),{query:l,handleQueryChange:e=>{a(e)},handleQueryBlur:()=>{u(l),t((0,n.jM)(r,e=>{e.query=l}))}}}}}]);
@@ -1,4 +1,4 @@
1
- /*! For license information please see __federation_expose_GreptimeDBTraceQuery.24f3bce3.js.LICENSE.txt */
1
+ /*! For license information please see __federation_expose_GreptimeDBTraceQuery.a1f7328d.js.LICENSE.txt */
2
2
  "use strict";(self.chunk_GreptimeDB=self.chunk_GreptimeDB||[]).push([["3361"],{64560(e,t,r){r.r(t),r.d(t,{StatusCodeError:()=>a,StatusCodeOk:()=>i,StatusCodeUnset:()=>n});let n="STATUS_CODE_UNSET",i="STATUS_CODE_OK",a="STATUS_CODE_ERROR"},2192(e,t,r){var n=r(70451),i=Symbol.for("react.element"),a=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,u={key:!0,ref:!0,__self:!0,__source:!0};function l(e,t,r){var n,a={},l=null,m=null;for(n in void 0!==r&&(l=""+r),void 0!==t.key&&(l=""+t.key),void 0!==t.ref&&(m=t.ref),t)s.call(t,n)&&!u.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:i,type:e,key:l,ref:m,props:a,_owner:o.current}}t.Fragment=a,t.jsx=l,t.jsxs=l},62540(e,t,r){e.exports=r(2192)},15062(e,t,r){r.d(t,{t:()=>n});let n=`-- Time Series Query
3
3
  SELECT
4
4
  date_bin(INTERVAL '1 minute', ts) as ts,
@@ -18,4 +18,4 @@ SELECT
18
18
  FROM application_logs
19
19
  WHERE ts BETWEEN to_timestamp_millis($__from) AND to_timestamp_millis($__to)
20
20
  ORDER BY ts DESC
21
- LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>l});var n=r(62540),i=r(29068),a=r(41865),s=r(56599),o=r(315),u=r(54227);function l(e){let t=(0,s.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(o.A,{position:"relative",children:[(0,n.jsx)(u.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(i.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[a.Lz.lineWrapping,a.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>i});let n="GreptimeDBDatasource",i={kind:n}},57748(e,t,r){r.d(t,{EY:()=>i,W0:()=>function e(t,r){if(null==t)return null;let n=a(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let i=new Date(t).getTime();return Number.isNaN(i)?null:i},nu:()=>o,qV:()=>s});var n=r(90617);function i(e,t,r){let i,a,s,o,u,{start:l,end:m}=r,c=m.valueOf()-l.valueOf(),d={__from:{value:l.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:c.toString(),loading:!1},__range_s:{value:Math.floor(c/1e3).toString(),loading:!1},__range:{value:(a=Math.floor((i=Math.floor(c/1e3))/3600),s=Math.floor(i%3600/60),o=i%60,u="",a>0&&(u+=`${a}h`),s>0&&(u+=`${s}m`),(o>0||""===u)&&(u+=`${o}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...d,...t})}function a(e){return e?e.toLowerCase():null}function s(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function o(e){let t=-1,r=e.filter(e=>{let t=a(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=["greptime_timestamp","timestamp","ts","time"];t=e.findIndex(e=>r.includes(e.name.toLowerCase()))}return t}},8741(e,t,r){r.r(t),r.d(t,{GreptimeDBTraceQuery:()=>M,toNanoString:()=>_,GreptimeDBTraceQueryEditor:()=>T,getGreptimeDBTraceData:()=>o});var n=r(90617),i=r(64560),a=r(7140),s=r(57748);let o=async(e,t)=>{var r,o;let v=(0,n.replaceVariables)(e.query??"",t.variableState).trim();if(0===v.length)return{searchResult:[]};let S=function(e){if(e){if("string"==typeof e.name&&""===e.name.trim()){let{kind:t}=e;return t?{kind:t}:void 0}return e}}(e.datasource),h=await t.datasourceStore.getDatasourceClient(S??a.S),y=(null==(r=t.absoluteTimeRange)?void 0:r.start.getTime().toString())??"0",x=(null==(o=t.absoluteTimeRange)?void 0:o.end.getTime().toString())??"0",E=await h.query({query:v,start:y,end:x});if("error"===E.status)throw Error(E.error??"GreptimeDB trace query failed");let T=(0,s.qV)(E.data);return/where[\s\S]*trace_id\s*=/i.test(v)&&function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[];if(0===r.length)return!1;let n=u(r);return void 0!==n.trace_id&&void 0!==n.span_id}(T)?{trace:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return{resourceSpans:[]};let a=u(r),s=r.filter(e=>e.name.startsWith("span_attributes.")),o=r.filter(e=>e.name.startsWith("resource_attributes.")),p=new Map;return n.forEach(e=>{let t=c(m(e,a,["trace_id","traceid","traceId"])),n=c(m(e,a,["span_id","spanid","spanId"]));if(!t||!n)return;let u=c(m(e,a,["parent_span_id","parentspanid","parentSpanId"])),v=c(m(e,a,["span_name","name","operation_name"]))??"(unknown span)",S=c(m(e,a,["span_kind","kind"]))??"SPAN_KIND_UNSPECIFIED",h=c(m(e,a,["service_name"]))??"unknown",y=c(m(e,a,["scope_name"]))??"",x=c(m(e,a,["scope_version"]))??"",E=a.timestamp??a.start_time??a.start_time_unix_nano,T=a.timestamp_end??a.end_time??a.end_time_unix_nano,M=a.duration_nano??a.duration_ns,C=void 0!==E?_(e[E],l(r,E))??"0":"0",N=(void 0!==T?_(e[T],l(r,T))??"0":void 0)??(void 0!==M?String(BigInt(C)+BigInt(_(e[M],l(r,M))??"0")):C),D=s.map(t=>{let r=a[t.name.toLowerCase()];if(void 0===r)return;let n=e[r];if(null!=n&&""!==n)return g(t.name.replace(/^span_attributes\./,""),n)}).filter(e=>void 0!==e),O=f(m(e,a,["span_events"])).map(e=>{let t=function(e){if(null==e)return;let t=d(e);if(void 0!==t)return String(BigInt(Math.trunc(t)));let r=new Date(String(e)).getTime();if(!Number.isNaN(r))return String(1000000n*BigInt(Math.trunc(r)))}(e.timeUnixNano??e.time_unix_nano)??C,r=c(e.name)??"event",n=e.attributes;return{timeUnixNano:t,name:r,attributes:n?Object.entries(n).map(e=>{let[t,r]=e;return g(t,r)}):[]}}),b=f(m(e,a,["span_links"])).map(e=>{let t=e.attributes,r=t?Object.entries(t).map(e=>{let[t,r]=e;return g(t,r)}):[];return{traceId:c(e.traceId??e.trace_id)??"",spanId:c(e.spanId??e.span_id)??"",attributes:r}}),R=c(m(e,a,["span_status_message"]))??"",w=function(e){let t=String(e??"").trim().toUpperCase();if(t)return"STATUS_CODE_OK"===t||"OK"===t||"1"===t?i.StatusCodeOk:"STATUS_CODE_ERROR"===t||"ERROR"===t||"2"===t?i.StatusCodeError:i.StatusCodeUnset}(m(e,a,["span_status_code","status_code"]));if(!p.has(h)){let t=[g("service.name",h)];o.forEach(r=>{let n=a[r.name.toLowerCase()];if(void 0===n)return;let i=e[n];null!=i&&""!==i&&t.push(g(r.name.replace(/^resource_attributes\./,""),i))}),p.set(h,{resourceAttrs:t,scopeSpans:new Map})}let B=p.get(h),I=`${y}|${x}`;B.scopeSpans.has(I)||B.scopeSpans.set(I,{scope:{name:y,version:x},spans:[]}),B.scopeSpans.get(I).spans.push({traceId:t,spanId:n,parentSpanId:u,name:v,kind:S,startTimeUnixNano:C,endTimeUnixNano:N,attributes:D,events:O,links:b,status:{message:R,code:w}})}),{resourceSpans:Array.from(p.entries()).map(e=>{let[t,r]=e;return{resource:{attributes:r.resourceAttrs},scopeSpans:Array.from(r.scopeSpans.values())}})}}(T),metadata:{executedQueryString:v}}:{searchResult:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return[];let i=u(r),a=new Map;return n.forEach(e=>{let t=c(m(e,i,["trace_id","traceid","traceId"]));if(!t)return;let n=function(e,t,r){for(let n of["timestamp","start_time","start_time_unix_nano","start_time_unix_ns","start_time_unix_ms","start_time_unix"]){let i=r[n];if(void 0===i||!t)continue;let a=(0,s.W0)(e[i],l(t,i));if(null!==a)return a}}(e,r,i),o=function(e,t,r){let n=d(m(e,r,["duration_ms"]));if(void 0!==n)return n;let i=d(m(e,r,["duration_nano","duration_ns"]));if(void 0!==i)return i/1e6;let a=r.timestamp??r.start_time??r.start_time_unix_nano,o=r.timestamp_end??r.end_time??r.end_time_unix_nano;if(t&&void 0!==a&&void 0!==o){let r=(0,s.W0)(e[a],l(t,a)),n=(0,s.W0)(e[o],l(t,o));if(null!==r&&null!==n)return Math.max(0,n-r)}return 0}(e,r,i),u=function(e,t,r){for(let n of["timestamp_end","end_time","end_time_unix_nano","end_time_unix_ns","end_time_unix_ms"]){let i=r[n];if(void 0===i||!t)continue;let a=(0,s.W0)(e[i],l(t,i));if(null!==a)return a}}(e,r,i)??(void 0!==n?n+o:void 0),_=c(m(e,i,["service_name","root_service_name"]))??"unknown",f=c(m(e,i,["span_name","root_trace_name","operation_name","name"]))??"(unknown span)",g=c(m(e,i,["parent_span_id","parentspanid","parentSpanId"])),v=a.get(t);v?(void 0!==n&&(v.startTimeUnixMs=0===v.startTimeUnixMs?n:Math.min(v.startTimeUnixMs,n)),void 0!==u&&(v.endTimeUnixMs=Math.max(v.endTimeUnixMs,u)),g||(v.rootTraceName=f,v.rootServiceName=_),v.serviceStats[_]||(v.serviceStats[_]={spanCount:0,errorCount:0}),v.serviceStats[_].spanCount+=1,p(m(e,i,["span_status_code","status_code"]))&&(v.serviceStats[_].errorCount+=1)):a.set(t,{traceId:t,startTimeUnixMs:n??0,endTimeUnixMs:u??n??0,rootServiceName:_,rootTraceName:f,serviceStats:{[_]:{spanCount:1,errorCount:+!!p(m(e,i,["span_status_code","status_code"]))}}})}),Array.from(a.values()).map(e=>({traceId:e.traceId,startTimeUnixMs:e.startTimeUnixMs,durationMs:Math.max(0,e.endTimeUnixMs-e.startTimeUnixMs),rootServiceName:e.rootServiceName,rootTraceName:e.rootTraceName,serviceStats:e.serviceStats})).sort((e,t)=>t.startTimeUnixMs-e.startTimeUnixMs)}(T),metadata:{executedQueryString:v}}};function u(e){let t={};return(e??[]).forEach((e,r)=>{t[e.name.toLowerCase()]=r}),t}function l(e,t){let r=e[t];if(!r)throw Error(`GreptimeDB SQL response missing column at index ${t}`);let n=r.data_type;if(!n)throw Error(`GreptimeDB SQL response missing data_type for column "${r.name}"`);return n}function m(e,t,r){for(let n of r){let r=t[n.toLowerCase()];if(void 0!==r)return e[r]}}function c(e){if(null!=e)return String(e)}function d(e){if(null==e)return;if("number"==typeof e)return Number.isFinite(e)?e:void 0;let t=Number(e);return Number.isFinite(t)?t:void 0}function p(e){let t=String(e??"").trim().toUpperCase();return"STATUS_CODE_ERROR"===t||"ERROR"===t||"2"===t}function _(e,t){let r;if(null==e)return;let n=d(e);if(void 0===n)return;let i=t.toLowerCase();if(i.includes("nanosecond"))return String(BigInt(Math.trunc(n)));if(i.includes("microsecond"))return String(1000n*BigInt(Math.trunc(n)));if(i.includes("millisecond"))return String(1000000n*BigInt(Math.trunc(n)));if(i.includes("second"))return String(1000000000n*BigInt(Math.trunc(n)));if((r=t.toLowerCase()).includes("int")||r.includes("uint")||"bigint"===r)return String(BigInt(Math.trunc(n)));throw Error(`Unsupported GreptimeDB data_type: ${t}`)}function f(e){if(Array.isArray(e))return e;if("string"==typeof e)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{}return[]}function g(e,t){return{key:e,value:{stringValue:"string"==typeof t?t:JSON.stringify(t)}}}var v=r(62540),S=r(315),h=r(38662),y=r(70451),x=r(71122),E=r(64383);function T(e){let{onChange:t,value:r}=e,{datasource:i}=r,s=i??a.S,{query:o,handleQueryChange:u,handleQueryBlur:l}=(0,E.Z)(e),m=(0,y.useCallback)(e=>{u(e)},[u]);return(0,v.jsxs)(S.A,{spacing:1.5,children:[(0,v.jsx)(n.DatasourceSelect,{datasourcePluginKind:a.N,value:s,onChange:e=>{if(!(0,n.isVariableDatasource)(e)&&e.kind===a.N)return void t((0,h.jM)(r,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,v.jsx)(x.M,{value:o,onChange:m,onBlur:l,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),t((0,h.jM)(r,e=>{e.query=o})))},placeholder:"Enter SQL for trace search or trace details"})]})}let M={getTraceData:o,OptionsEditorComponent:T,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set((0,n.parseVariables)(e.query))]})}},64383(e,t,r){r.d(t,{Z:()=>a});var n=r(38662),i=r(70451);function a(e){let{onChange:t,value:r}=e,[a,s]=(0,i.useState)(r.query||""),[o,u]=(0,i.useState)(r.query);return r.query!==o&&(s(r.query||""),u(r.query)),{query:a,handleQueryChange:e=>{s(e)},handleQueryBlur:()=>{u(a),t((0,n.jM)(r,e=>{e.query=a}))}}}}}]);
21
+ LIMIT 1000`},71122(e,t,r){r.d(t,{M:()=>l});var n=r(62540),i=r(29068),a=r(41865),s=r(56599),o=r(315),u=r(54227);function l(e){let t=(0,s.A)(),r="dark"===t.palette.mode;return(0,n.jsxs)(o.A,{position:"relative",children:[(0,n.jsx)(u.A,{sx:{fontWeight:500,marginBottom:"4px",color:t.palette.text.primary},children:"GreptimeDB SQL Query"}),(0,n.jsx)(i.Ay,{...e,style:{border:`1px solid ${t.palette.divider}`},theme:r?"dark":"light",basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1,foldGutter:!1,syntaxHighlighting:!0},extensions:[a.Lz.lineWrapping,a.Lz.theme({".cm-content":{paddingTop:"8px",paddingBottom:"8px",paddingRight:"40px"}})],placeholder:"Write GreptimeDB SQL Query Here..."})]})}r(15062)},7140(e,t,r){r.d(t,{N:()=>n,S:()=>i});let n="GreptimeDBDatasource",i={kind:n}},57748(e,t,r){r.d(t,{EY:()=>i,W0:()=>function e(t,r){if(null==t)return null;let n=a(r);if("number"==typeof t){if(n){if(n.includes("nanosecond"))return Math.floor(t/1e6);if(n.includes("microsecond"))return Math.floor(t/1e3);if(n.includes("millisecond"))return t;if(n.includes("second"))return 1e3*t}return t>1e15?Math.floor(t/1e6):t>1e12?t:t>1e9?1e3*t:t}if("string"==typeof t){let n=Number(t);if(!Number.isNaN(n))return e(n,r)}let i=new Date(t).getTime();return Number.isNaN(i)?null:i},nu:()=>o,qV:()=>s});var n=r(19848);function i(e,t,r){let i,a,s,o,u,{start:l,end:m}=r,c=m.valueOf()-l.valueOf(),d={__from:{value:l.valueOf().toString(),loading:!1},__to:{value:m.valueOf().toString(),loading:!1},__range_ms:{value:c.toString(),loading:!1},__range_s:{value:Math.floor(c/1e3).toString(),loading:!1},__range:{value:(a=Math.floor((i=Math.floor(c/1e3))/3600),s=Math.floor(i%3600/60),o=i%60,u="",a>0&&(u+=`${a}h`),s>0&&(u+=`${s}m`),(o>0||""===u)&&(u+=`${o}s`),u),loading:!1}};return(0,n.replaceVariables)(e,{...d,...t})}function a(e){return e?e.toLowerCase():null}function s(e){var t,r;if(e&&"object"==typeof e)return null==(r=e.output)||null==(t=r[0])?void 0:t.records}function o(e){let t=-1,r=e.filter(e=>{let t=a(e.data_type);return null!==t&&t.startsWith("timestamp")});if(r.length>0){let n=r.find(e=>{var t;return(null==(t=e.semantic_type)?void 0:t.toLowerCase())==="timestamp"})??r[0];t=e.findIndex(e=>e.name===n.name)}if(-1===t){let r=["greptime_timestamp","timestamp","ts","time"];t=e.findIndex(e=>r.includes(e.name.toLowerCase()))}return t}},8741(e,t,r){r.r(t),r.d(t,{GreptimeDBTraceQuery:()=>M,toNanoString:()=>_,GreptimeDBTraceQueryEditor:()=>T,getGreptimeDBTraceData:()=>o});var n=r(19848),i=r(64560),a=r(7140),s=r(57748);let o=async(e,t)=>{var r,o;let v=(0,n.replaceVariables)(e.query??"",t.variableState).trim();if(0===v.length)return{searchResult:[]};let S=function(e){if(e){if("string"==typeof e.name&&""===e.name.trim()){let{kind:t}=e;return t?{kind:t}:void 0}return e}}(e.datasource),h=await t.datasourceStore.getDatasourceClient(S??a.S),y=(null==(r=t.absoluteTimeRange)?void 0:r.start.getTime().toString())??"0",x=(null==(o=t.absoluteTimeRange)?void 0:o.end.getTime().toString())??"0",E=await h.query({query:v,start:y,end:x});if("error"===E.status)throw Error(E.error??"GreptimeDB trace query failed");let T=(0,s.qV)(E.data);return/where[\s\S]*trace_id\s*=/i.test(v)&&function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[];if(0===r.length)return!1;let n=u(r);return void 0!==n.trace_id&&void 0!==n.span_id}(T)?{trace:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return{resourceSpans:[]};let a=u(r),s=r.filter(e=>e.name.startsWith("span_attributes.")),o=r.filter(e=>e.name.startsWith("resource_attributes.")),p=new Map;return n.forEach(e=>{let t=c(m(e,a,["trace_id","traceid","traceId"])),n=c(m(e,a,["span_id","spanid","spanId"]));if(!t||!n)return;let u=c(m(e,a,["parent_span_id","parentspanid","parentSpanId"])),v=c(m(e,a,["span_name","name","operation_name"]))??"(unknown span)",S=c(m(e,a,["span_kind","kind"]))??"SPAN_KIND_UNSPECIFIED",h=c(m(e,a,["service_name"]))??"unknown",y=c(m(e,a,["scope_name"]))??"",x=c(m(e,a,["scope_version"]))??"",E=a.timestamp??a.start_time??a.start_time_unix_nano,T=a.timestamp_end??a.end_time??a.end_time_unix_nano,M=a.duration_nano??a.duration_ns,C=void 0!==E?_(e[E],l(r,E))??"0":"0",N=(void 0!==T?_(e[T],l(r,T))??"0":void 0)??(void 0!==M?String(BigInt(C)+BigInt(_(e[M],l(r,M))??"0")):C),D=s.map(t=>{let r=a[t.name.toLowerCase()];if(void 0===r)return;let n=e[r];if(null!=n&&""!==n)return g(t.name.replace(/^span_attributes\./,""),n)}).filter(e=>void 0!==e),O=f(m(e,a,["span_events"])).map(e=>{let t=function(e){if(null==e)return;let t=d(e);if(void 0!==t)return String(BigInt(Math.trunc(t)));let r=new Date(String(e)).getTime();if(!Number.isNaN(r))return String(1000000n*BigInt(Math.trunc(r)))}(e.timeUnixNano??e.time_unix_nano)??C,r=c(e.name)??"event",n=e.attributes;return{timeUnixNano:t,name:r,attributes:n?Object.entries(n).map(e=>{let[t,r]=e;return g(t,r)}):[]}}),b=f(m(e,a,["span_links"])).map(e=>{let t=e.attributes,r=t?Object.entries(t).map(e=>{let[t,r]=e;return g(t,r)}):[];return{traceId:c(e.traceId??e.trace_id)??"",spanId:c(e.spanId??e.span_id)??"",attributes:r}}),R=c(m(e,a,["span_status_message"]))??"",w=function(e){let t=String(e??"").trim().toUpperCase();if(t)return"STATUS_CODE_OK"===t||"OK"===t||"1"===t?i.StatusCodeOk:"STATUS_CODE_ERROR"===t||"ERROR"===t||"2"===t?i.StatusCodeError:i.StatusCodeUnset}(m(e,a,["span_status_code","status_code"]));if(!p.has(h)){let t=[g("service.name",h)];o.forEach(r=>{let n=a[r.name.toLowerCase()];if(void 0===n)return;let i=e[n];null!=i&&""!==i&&t.push(g(r.name.replace(/^resource_attributes\./,""),i))}),p.set(h,{resourceAttrs:t,scopeSpans:new Map})}let B=p.get(h),I=`${y}|${x}`;B.scopeSpans.has(I)||B.scopeSpans.set(I,{scope:{name:y,version:x},spans:[]}),B.scopeSpans.get(I).spans.push({traceId:t,spanId:n,parentSpanId:u,name:v,kind:S,startTimeUnixNano:C,endTimeUnixNano:N,attributes:D,events:O,links:b,status:{message:R,code:w}})}),{resourceSpans:Array.from(p.entries()).map(e=>{let[t,r]=e;return{resource:{attributes:r.resourceAttrs},scopeSpans:Array.from(r.scopeSpans.values())}})}}(T),metadata:{executedQueryString:v}}:{searchResult:function(e){var t;let r=(null==e||null==(t=e.schema)?void 0:t.column_schemas)??[],n=(null==e?void 0:e.rows)??[];if(!r.length||!n.length)return[];let i=u(r),a=new Map;return n.forEach(e=>{let t=c(m(e,i,["trace_id","traceid","traceId"]));if(!t)return;let n=function(e,t,r){for(let n of["timestamp","start_time","start_time_unix_nano","start_time_unix_ns","start_time_unix_ms","start_time_unix"]){let i=r[n];if(void 0===i||!t)continue;let a=(0,s.W0)(e[i],l(t,i));if(null!==a)return a}}(e,r,i),o=function(e,t,r){let n=d(m(e,r,["duration_ms"]));if(void 0!==n)return n;let i=d(m(e,r,["duration_nano","duration_ns"]));if(void 0!==i)return i/1e6;let a=r.timestamp??r.start_time??r.start_time_unix_nano,o=r.timestamp_end??r.end_time??r.end_time_unix_nano;if(t&&void 0!==a&&void 0!==o){let r=(0,s.W0)(e[a],l(t,a)),n=(0,s.W0)(e[o],l(t,o));if(null!==r&&null!==n)return Math.max(0,n-r)}return 0}(e,r,i),u=function(e,t,r){for(let n of["timestamp_end","end_time","end_time_unix_nano","end_time_unix_ns","end_time_unix_ms"]){let i=r[n];if(void 0===i||!t)continue;let a=(0,s.W0)(e[i],l(t,i));if(null!==a)return a}}(e,r,i)??(void 0!==n?n+o:void 0),_=c(m(e,i,["service_name","root_service_name"]))??"unknown",f=c(m(e,i,["span_name","root_trace_name","operation_name","name"]))??"(unknown span)",g=c(m(e,i,["parent_span_id","parentspanid","parentSpanId"])),v=a.get(t);v?(void 0!==n&&(v.startTimeUnixMs=0===v.startTimeUnixMs?n:Math.min(v.startTimeUnixMs,n)),void 0!==u&&(v.endTimeUnixMs=Math.max(v.endTimeUnixMs,u)),g||(v.rootTraceName=f,v.rootServiceName=_),v.serviceStats[_]||(v.serviceStats[_]={spanCount:0,errorCount:0}),v.serviceStats[_].spanCount+=1,p(m(e,i,["span_status_code","status_code"]))&&(v.serviceStats[_].errorCount+=1)):a.set(t,{traceId:t,startTimeUnixMs:n??0,endTimeUnixMs:u??n??0,rootServiceName:_,rootTraceName:f,serviceStats:{[_]:{spanCount:1,errorCount:+!!p(m(e,i,["span_status_code","status_code"]))}}})}),Array.from(a.values()).map(e=>({traceId:e.traceId,startTimeUnixMs:e.startTimeUnixMs,durationMs:Math.max(0,e.endTimeUnixMs-e.startTimeUnixMs),rootServiceName:e.rootServiceName,rootTraceName:e.rootTraceName,serviceStats:e.serviceStats})).sort((e,t)=>t.startTimeUnixMs-e.startTimeUnixMs)}(T),metadata:{executedQueryString:v}}};function u(e){let t={};return(e??[]).forEach((e,r)=>{t[e.name.toLowerCase()]=r}),t}function l(e,t){let r=e[t];if(!r)throw Error(`GreptimeDB SQL response missing column at index ${t}`);let n=r.data_type;if(!n)throw Error(`GreptimeDB SQL response missing data_type for column "${r.name}"`);return n}function m(e,t,r){for(let n of r){let r=t[n.toLowerCase()];if(void 0!==r)return e[r]}}function c(e){if(null!=e)return String(e)}function d(e){if(null==e)return;if("number"==typeof e)return Number.isFinite(e)?e:void 0;let t=Number(e);return Number.isFinite(t)?t:void 0}function p(e){let t=String(e??"").trim().toUpperCase();return"STATUS_CODE_ERROR"===t||"ERROR"===t||"2"===t}function _(e,t){let r;if(null==e)return;let n=d(e);if(void 0===n)return;let i=t.toLowerCase();if(i.includes("nanosecond"))return String(BigInt(Math.trunc(n)));if(i.includes("microsecond"))return String(1000n*BigInt(Math.trunc(n)));if(i.includes("millisecond"))return String(1000000n*BigInt(Math.trunc(n)));if(i.includes("second"))return String(1000000000n*BigInt(Math.trunc(n)));if((r=t.toLowerCase()).includes("int")||r.includes("uint")||"bigint"===r)return String(BigInt(Math.trunc(n)));throw Error(`Unsupported GreptimeDB data_type: ${t}`)}function f(e){if(Array.isArray(e))return e;if("string"==typeof e)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{}return[]}function g(e,t){return{key:e,value:{stringValue:"string"==typeof t?t:JSON.stringify(t)}}}var v=r(62540),S=r(315),h=r(38662),y=r(70451),x=r(71122),E=r(64383);function T(e){let{onChange:t,value:r}=e,{datasource:i}=r,s=i??a.S,{query:o,handleQueryChange:u,handleQueryBlur:l}=(0,E.Z)(e),m=(0,y.useCallback)(e=>{u(e)},[u]);return(0,v.jsxs)(S.A,{spacing:1.5,children:[(0,v.jsx)(n.DatasourceSelect,{datasourcePluginKind:a.N,value:s,onChange:e=>{if(!(0,n.isVariableDatasource)(e)&&e.kind===a.N)return void t((0,h.jM)(r,t=>{t.datasource=e}));throw Error("Got unexpected non GreptimeDB datasource selection")},label:"GreptimeDB Datasource",notched:!0}),(0,v.jsx)(x.M,{value:o,onChange:m,onBlur:l,onKeyDown:e=>{"Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),t((0,h.jM)(r,e=>{e.query=o})))},placeholder:"Enter SQL for trace search or trace details"})]})}let M={getTraceData:o,OptionsEditorComponent:T,createInitialOptions:()=>({query:""}),dependsOn:e=>({variables:[...new Set((0,n.parseVariables)(e.query))]})}},64383(e,t,r){r.d(t,{Z:()=>a});var n=r(38662),i=r(70451);function a(e){let{onChange:t,value:r}=e,[a,s]=(0,i.useState)(r.query||""),[o,u]=(0,i.useState)(r.query);return r.query!==o&&(s(r.query||""),u(r.query)),{query:a,handleQueryChange:e=>{s(e)},handleQueryBlur:()=>{u(a),t((0,n.jM)(r,e=>{e.query=a}))}}}}}]);