@perses-dev/victorialogs-plugin 0.5.0-beta.6 → 0.5.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/VictoriaLogs.635392ce.js +7 -0
- package/__mf/js/async/1433.3d2ebb70.js +7 -0
- package/__mf/js/async/1616.0258fe9a.js +1 -0
- package/__mf/js/async/198.cc78ac12.js +2 -0
- package/__mf/js/async/2043.2c73ebfe.js +2 -0
- package/__mf/js/async/2377.2348cb20.js +1 -0
- package/__mf/js/async/2786.5f881482.js +2 -0
- package/__mf/js/async/2901.9c427b40.js +1 -0
- package/__mf/js/async/3286.38c055b9.js +2 -0
- package/__mf/js/async/392.49d52d98.js +2 -0
- package/__mf/js/async/4077.39e0efff.js +1 -0
- package/__mf/js/async/4121.356a5dcc.js +2 -0
- package/__mf/js/async/4248.847c390d.js +1 -0
- package/__mf/js/async/4496.af265a24.js +1 -0
- package/__mf/js/async/4960.f43ba55c.js +2 -0
- package/__mf/js/async/5019.644f7b0c.js +1 -0
- package/__mf/js/async/5071.6670fa87.js +1 -0
- package/__mf/js/async/5440.1ca84a65.js +2 -0
- package/__mf/js/async/{5440.09f0226b.js.LICENSE.txt → 5440.1ca84a65.js.LICENSE.txt} +3 -3
- package/__mf/js/async/5587.3f86da0e.js +1 -0
- package/__mf/js/async/5706.87cad874.js +1 -0
- package/__mf/js/async/6274.a464d64f.js +2 -0
- package/__mf/js/async/6609.6f2adcdd.js +88 -0
- package/__mf/js/async/6854.207d90c8.js +1 -0
- package/__mf/js/async/7192.92d05ad2.js +1 -0
- package/__mf/js/async/{7740.0ea3301c.js → 7740.57961d20.js} +1 -1
- package/__mf/js/async/7817.4a21d143.js +2 -0
- package/__mf/js/async/7862.f33fc6ee.js +2 -0
- package/__mf/js/async/7958.426f9f71.js +52 -0
- package/__mf/js/async/7968.62aeba5d.js +1 -0
- package/__mf/js/async/7978.f0523bd3.js +1 -0
- package/__mf/js/async/{8253.cd3d4c47.js → 8253.66844887.js} +1 -1
- package/__mf/js/async/8356.b320d176.js +1 -0
- package/__mf/js/async/8470.ccd01079.js +2 -0
- package/__mf/js/async/873.d1c527eb.js +1 -0
- package/__mf/js/async/9207.3c630cde.js +1 -0
- package/__mf/js/async/9235.ce1cdbe4.js +1 -0
- package/__mf/js/async/941.fd358e10.js +2 -0
- package/__mf/js/async/{9440.af442e76.js → 9440.c066de88.js} +2 -2
- package/__mf/js/async/9588.453d5d98.js +1 -0
- package/__mf/js/async/__federation_expose_VictoriaLogsDatasource.049ba3c8.js +2 -0
- package/__mf/js/async/__federation_expose_VictoriaLogsFieldNamesVariable.ae8c52fb.js +2 -0
- package/__mf/js/async/__federation_expose_VictoriaLogsFieldValuesVariable.975e3794.js +2 -0
- package/__mf/js/async/__federation_expose_VictoriaLogsLogQuery.08f75beb.js +1 -0
- package/__mf/js/async/__federation_expose_VictoriaLogsTimeSeriesQuery.d266fd53.js +1 -0
- package/__mf/js/main.4f60490d.js +7 -0
- package/lib/components/logsql-editor.js +2 -2
- package/lib/components/logsql-editor.js.map +1 -1
- package/lib/components/logsql-extension.d.ts +1 -1
- package/lib/components/logsql-extension.d.ts.map +1 -1
- package/lib/components/logsql-extension.js +1 -1
- package/lib/components/logsql-extension.js.map +1 -1
- package/lib/datasources/victorialogs-datasource/VictoriaLogsDatasource.d.ts.map +1 -1
- package/lib/datasources/victorialogs-datasource/VictoriaLogsDatasource.js +9 -5
- package/lib/datasources/victorialogs-datasource/VictoriaLogsDatasource.js.map +1 -1
- package/lib/model/client.d.ts +2 -0
- package/lib/model/client.d.ts.map +1 -1
- package/lib/model/client.js +8 -4
- package/lib/model/client.js.map +1 -1
- package/lib/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.d.ts.map +1 -1
- package/lib/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.js +5 -6
- package/lib/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.js.map +1 -1
- package/lib/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.d.ts.map +1 -1
- package/lib/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.js +5 -6
- package/lib/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.js.map +1 -1
- package/mf-manifest.json +138 -138
- package/mf-stats.json +138 -138
- package/package.json +6 -6
- package/__mf/js/VictoriaLogs.4c495bed.js +0 -7
- package/__mf/js/async/1616.82d4415e.js +0 -1
- package/__mf/js/async/198.eaf0c6e9.js +0 -2
- package/__mf/js/async/2043.c7890092.js +0 -2
- package/__mf/js/async/2377.4d92bfcb.js +0 -1
- package/__mf/js/async/2786.773d9359.js +0 -2
- package/__mf/js/async/2901.608f45ff.js +0 -1
- package/__mf/js/async/3068.988451f7.js +0 -88
- package/__mf/js/async/3286.c737c09b.js +0 -2
- package/__mf/js/async/392.6731d83c.js +0 -2
- package/__mf/js/async/4077.a42401ce.js +0 -1
- package/__mf/js/async/4121.770269c0.js +0 -2
- package/__mf/js/async/4248.91e6cc6e.js +0 -1
- package/__mf/js/async/4496.9fae4748.js +0 -1
- package/__mf/js/async/4960.cb8a05de.js +0 -2
- package/__mf/js/async/5019.ac272b15.js +0 -1
- package/__mf/js/async/5071.560c053a.js +0 -1
- package/__mf/js/async/537.1c481610.js +0 -7
- package/__mf/js/async/5440.09f0226b.js +0 -2
- package/__mf/js/async/5587.64d39b17.js +0 -1
- package/__mf/js/async/5706.75b5373a.js +0 -1
- package/__mf/js/async/6274.d7d67416.js +0 -2
- package/__mf/js/async/6854.1894c973.js +0 -1
- package/__mf/js/async/7192.ed537c4a.js +0 -1
- package/__mf/js/async/7817.f8e5f9c1.js +0 -2
- package/__mf/js/async/7862.7dae5507.js +0 -2
- package/__mf/js/async/7968.01e0eae9.js +0 -1
- package/__mf/js/async/7978.3243a72e.js +0 -1
- package/__mf/js/async/8356.a177b6d1.js +0 -1
- package/__mf/js/async/8470.45505eb5.js +0 -2
- package/__mf/js/async/8555.1f58e1a5.js +0 -52
- package/__mf/js/async/873.dc975fe1.js +0 -1
- package/__mf/js/async/9207.037948df.js +0 -1
- package/__mf/js/async/9235.a48b3e89.js +0 -1
- package/__mf/js/async/941.cce123a8.js +0 -2
- package/__mf/js/async/9588.4997a7af.js +0 -1
- package/__mf/js/async/__federation_expose_VictoriaLogsDatasource.9377181e.js +0 -2
- package/__mf/js/async/__federation_expose_VictoriaLogsFieldNamesVariable.129a25d1.js +0 -2
- package/__mf/js/async/__federation_expose_VictoriaLogsFieldValuesVariable.06a1024e.js +0 -2
- package/__mf/js/async/__federation_expose_VictoriaLogsLogQuery.b36ca46c.js +0 -1
- package/__mf/js/async/__federation_expose_VictoriaLogsTimeSeriesQuery.cd896f43.js +0 -1
- package/__mf/js/main.b2110334.js +0 -7
- /package/__mf/css/async/{537.85c2cbf6.css → 1433.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{537.1c481610.js.LICENSE.txt → 1433.3d2ebb70.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{198.eaf0c6e9.js.LICENSE.txt → 198.cc78ac12.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2043.c7890092.js.LICENSE.txt → 2043.2c73ebfe.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2786.773d9359.js.LICENSE.txt → 2786.5f881482.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.6731d83c.js.LICENSE.txt → 392.49d52d98.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4121.770269c0.js.LICENSE.txt → 4121.356a5dcc.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4960.cb8a05de.js.LICENSE.txt → 4960.f43ba55c.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6274.d7d67416.js.LICENSE.txt → 6274.a464d64f.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3068.988451f7.js.LICENSE.txt → 6609.6f2adcdd.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7817.f8e5f9c1.js.LICENSE.txt → 7817.4a21d143.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{7862.7dae5507.js.LICENSE.txt → 7862.f33fc6ee.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8470.45505eb5.js.LICENSE.txt → 8470.ccd01079.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.cce123a8.js.LICENSE.txt → 941.fd358e10.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{9440.af442e76.js.LICENSE.txt → 9440.c066de88.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_VictoriaLogsDatasource.9377181e.js.LICENSE.txt → __federation_expose_VictoriaLogsDatasource.049ba3c8.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_VictoriaLogsFieldNamesVariable.129a25d1.js.LICENSE.txt → __federation_expose_VictoriaLogsFieldNamesVariable.ae8c52fb.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{__federation_expose_VictoriaLogsFieldValuesVariable.06a1024e.js.LICENSE.txt → __federation_expose_VictoriaLogsFieldValuesVariable.975e3794.js.LICENSE.txt} +0 -0
package/lib/model/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/model/client.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type {\n VictoriaLogsStreamQueryRangeResponse,\n VictoriaLogsStatsQueryRangeResponse,\n VictoriaLogsFieldNamesResponse,\n VictoriaLogsFieldValuesResponse,\n VictoriaLogsRequestHeaders,\n} from './types';\n\nexport interface VictoriaLogsBaseParams {\n start: string;\n end: string;\n}\n\nexport interface VictoriaLogsStreamQueryRangeParams extends VictoriaLogsBaseParams {\n query: string;\n limit?: number;\n offset?: number;\n}\n\nexport interface VictoriaLogsStatsQueryRangeParams extends VictoriaLogsBaseParams {\n query: string;\n step?: string;\n}\n\nexport interface VictoriaLogsFieldNamesParams extends VictoriaLogsBaseParams {\n query: string;\n}\n\nexport interface VictoriaLogsFieldValuesParams extends VictoriaLogsBaseParams {\n query: string;\n field: string;\n}\n\nexport interface VictoriaLogsApiOptions {\n datasourceUrl: string;\n headers?: VictoriaLogsRequestHeaders;\n}\n\nexport interface VictoriaLogsClient {\n options: {\n datasourceUrl: string;\n };\n streamQueryRange: (\n params: VictoriaLogsStreamQueryRangeParams,\n headers?: VictoriaLogsRequestHeaders,\n ) => Promise<VictoriaLogsStreamQueryRangeResponse>;\n statsQueryRange: (\n params: VictoriaLogsStatsQueryRangeParams,\n headers?: VictoriaLogsRequestHeaders,\n ) => Promise<VictoriaLogsStatsQueryRangeResponse>;\n fieldNames: (\n params: VictoriaLogsFieldNamesParams,\n headers?: VictoriaLogsRequestHeaders,\n ) => Promise<VictoriaLogsFieldNamesResponse>;\n fieldValues: (\n params: VictoriaLogsFieldValuesParams,\n headers?: VictoriaLogsRequestHeaders,\n ) => Promise<VictoriaLogsFieldValuesResponse>;\n}\n\nfunction buildUrl(path: string, datasourceUrl: string): URL {\n if (datasourceUrl.startsWith('http://') || datasourceUrl.startsWith('https://')) {\n return new URL(path, datasourceUrl);\n }\n\n let fullPath = datasourceUrl;\n // Assume relative path, ensure no double slashes\n if (datasourceUrl.endsWith('/') && path.startsWith('/')) {\n fullPath = datasourceUrl + path.slice(1);\n } else if (!datasourceUrl.endsWith('/') && !path.startsWith('/')) {\n fullPath = datasourceUrl + '/' + path;\n } else {\n fullPath = datasourceUrl + path;\n }\n\n return new URL(fullPath, window.location.origin);\n}\n\nexport async function streamQueryRange(\n params: VictoriaLogsStreamQueryRangeParams,\n options: VictoriaLogsApiOptions,\n): Promise<VictoriaLogsStreamQueryRangeResponse> {\n const url = buildUrl('/select/logsql/query', options.datasourceUrl);\n const postData: Record<string, string> = {\n query: params.query,\n start: params.start,\n end: params.end,\n };\n if (params?.limit) postData['limit'] = params.limit.toString();\n if (params?.offset) postData['offset'] = params.offset.toString();\n\n const data = new URLSearchParams(postData).toString();\n const response = await fetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Accept: 'application/stream+json',\n ...options.headers,\n },\n body: data,\n });\n if (response.status !== 200) {\n throw new Error(await response.text());\n }\n const output: VictoriaLogsStreamQueryRangeResponse = [];\n\n if (!response?.body) return output;\n const reader = response.body.getReader();\n const decoder = new TextDecoder('utf-8');\n let buffer = '';\n\n let result = await reader.read();\n while (!result.done) {\n buffer += decoder.decode(result.value, { stream: true });\n let boundary = buffer.indexOf('\\n');\n while (boundary !== -1) {\n const line = buffer.slice(0, boundary);\n buffer = buffer.slice(boundary + 1);\n output.push(JSON.parse(line));\n boundary = buffer.indexOf('\\n');\n }\n result = await reader.read();\n }\n if (buffer.trim().length > 0) {\n output.push(JSON.parse(buffer));\n }\n return output;\n}\n\nexport async function statsQueryRange(\n params: VictoriaLogsStatsQueryRangeParams,\n options: VictoriaLogsApiOptions,\n): Promise<VictoriaLogsStatsQueryRangeResponse> {\n const url = buildUrl('/select/logsql/stats_query_range', options.datasourceUrl);\n const postData: Record<string, string> = {\n query: params.query,\n start: params.start,\n end: params.end,\n };\n if (params?.step) postData['step'] = params.step.toString();\n\n const data = new URLSearchParams(postData).toString();\n const response = await fetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Accept: 'application/json',\n ...options.headers,\n },\n body: data,\n });\n return await response.json();\n}\n\nexport async function fieldNames(\n params: VictoriaLogsFieldNamesParams,\n options: VictoriaLogsApiOptions,\n): Promise<VictoriaLogsFieldNamesResponse> {\n const url = buildUrl('/select/logsql/field_names', options.datasourceUrl);\n const postData: Record<string, string> = {\n query: params.query,\n };\n if (params.start) postData['start'] = params.start;\n if (params.end) postData['end'] = params.end;\n\n const data = new URLSearchParams(postData).toString();\n const response = await fetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Accept: 'application/json',\n ...options.headers,\n },\n body: data,\n });\n return await response.json();\n}\n\nexport async function fieldValues(\n params: VictoriaLogsFieldValuesParams,\n options: VictoriaLogsApiOptions,\n): Promise<VictoriaLogsFieldValuesResponse> {\n const url = buildUrl(`/select/logsql/field_values`, options.datasourceUrl);\n const postData: Record<string, string> = {\n query: params.query,\n field: params.field,\n };\n if (params.start) postData['start'] = params.start;\n if (params.end) postData['end'] = params.end;\n\n const data = new URLSearchParams(postData).toString();\n const response = await fetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Accept: 'application/json',\n ...options.headers,\n },\n body: data,\n });\n return await response.json();\n}\n"],"names":["buildUrl","path","datasourceUrl","startsWith","URL","fullPath","endsWith","slice","window","location","origin","streamQueryRange","params","options","url","postData","query","start","end","limit","toString","offset","data","URLSearchParams","response","fetch","method","headers","Accept","body","status","Error","text","output","reader","getReader","decoder","TextDecoder","buffer","result","read","done","decode","value","stream","boundary","indexOf","line","push","JSON","parse","trim","length","statsQueryRange","step","json","fieldNames","fieldValues","field"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA8DjC,SAASA,SAASC,IAAY,EAAEC,aAAqB;IACnD,IAAIA,cAAcC,UAAU,CAAC,cAAcD,cAAcC,UAAU,CAAC,aAAa;QAC/E,OAAO,IAAIC,IAAIH,MAAMC;IACvB;IAEA,IAAIG,WAAWH;IACf,iDAAiD;IACjD,IAAIA,cAAcI,QAAQ,CAAC,QAAQL,KAAKE,UAAU,CAAC,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AOM,GAAG,EAAEH,QAAQ,CAAC,MAAM,GAAGH,OAAOM,GAAG;IAE5C,MAAMI,OAAO,IAAIC,gBAAgBR,UAAUK,QAAQ;IACnD,MAAMI,WAAW,MAAMC,MAAMX,IAAIM,QAAQ,IAAI;QAC3CM,QAAQ;QACRC,SAAS;YACP,gBAAgB;YAChBC,QAAQ;YACR,GAAGf,QAAQc,OAAO;QACpB;QACAE,MAAMP;IACR;IACA,OAAO,MAAME,SAAS+B,IAAI;AAC5B;AAEA,OAAO,eAAeE,YACpB7C,MAAqC,EACrCC,OAA+B;IAE/B,MAAMC,MAAMd,SAAS,CAAC,2BAA2B,CAAC,EAAEa,QAAQX,aAAa;IACzE,MAAMa,WAAmC;QACvCC,OAAOJ,OAAOI,KAAK;QACnB0C,OAAO9C,OAAO8C,KAAK;IACrB;IACA,IAAI9C,OAAOK,KAAK,EAAEF,QAAQ,CAAC,QAAQ,GAAGH,OAAOK,KAAK;IAClD,IAAIL,OAAOM,GAAG,EAAEH,QAAQ,CAAC,MAAM,GAAGH,OAAOM,GAAG;IAE5C,MAAMI,OAAO,IAAIC,gBAAgBR,UAAUK,QAAQ;IACnD,MAAMI,WAAW,MAAMC,MAAMX,IAAIM,QAAQ,IAAI;QAC3CM,QAAQ;QACRC,SAAS;YACP,gBAAgB;YAChBC,QAAQ;YACR,GAAGf,QAAQc,OAAO;QACpB;QACAE,MAAMP;IACR;IACA,OAAO,MAAME,SAAS+B,IAAI;AAC5B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/model/client.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport type { FetchFn } from '@perses-dev/client';\n\nimport type {\n VictoriaLogsStreamQueryRangeResponse,\n VictoriaLogsStatsQueryRangeResponse,\n VictoriaLogsFieldNamesResponse,\n VictoriaLogsFieldValuesResponse,\n VictoriaLogsRequestHeaders,\n} from './types';\n\nexport interface VictoriaLogsBaseParams {\n start: string;\n end: string;\n}\n\nexport interface VictoriaLogsStreamQueryRangeParams extends VictoriaLogsBaseParams {\n query: string;\n limit?: number;\n offset?: number;\n}\n\nexport interface VictoriaLogsStatsQueryRangeParams extends VictoriaLogsBaseParams {\n query: string;\n step?: string;\n}\n\nexport interface VictoriaLogsFieldNamesParams extends VictoriaLogsBaseParams {\n query: string;\n}\n\nexport interface VictoriaLogsFieldValuesParams extends VictoriaLogsBaseParams {\n query: string;\n field: string;\n}\n\nexport interface VictoriaLogsApiOptions {\n datasourceUrl: string;\n headers?: VictoriaLogsRequestHeaders;\n fetch?: FetchFn;\n}\n\nexport interface VictoriaLogsClient {\n options: {\n datasourceUrl: string;\n };\n streamQueryRange: (\n params: VictoriaLogsStreamQueryRangeParams,\n headers?: VictoriaLogsRequestHeaders,\n ) => Promise<VictoriaLogsStreamQueryRangeResponse>;\n statsQueryRange: (\n params: VictoriaLogsStatsQueryRangeParams,\n headers?: VictoriaLogsRequestHeaders,\n ) => Promise<VictoriaLogsStatsQueryRangeResponse>;\n fieldNames: (\n params: VictoriaLogsFieldNamesParams,\n headers?: VictoriaLogsRequestHeaders,\n ) => Promise<VictoriaLogsFieldNamesResponse>;\n fieldValues: (\n params: VictoriaLogsFieldValuesParams,\n headers?: VictoriaLogsRequestHeaders,\n ) => Promise<VictoriaLogsFieldValuesResponse>;\n}\n\nfunction buildUrl(path: string, datasourceUrl: string): URL {\n if (datasourceUrl.startsWith('http://') || datasourceUrl.startsWith('https://')) {\n return new URL(path, datasourceUrl);\n }\n\n let fullPath = datasourceUrl;\n // Assume relative path, ensure no double slashes\n if (datasourceUrl.endsWith('/') && path.startsWith('/')) {\n fullPath = datasourceUrl + path.slice(1);\n } else if (!datasourceUrl.endsWith('/') && !path.startsWith('/')) {\n fullPath = datasourceUrl + '/' + path;\n } else {\n fullPath = datasourceUrl + path;\n }\n\n return new URL(fullPath, window.location.origin);\n}\n\nexport async function streamQueryRange(\n params: VictoriaLogsStreamQueryRangeParams,\n options: VictoriaLogsApiOptions,\n): Promise<VictoriaLogsStreamQueryRangeResponse> {\n const url = buildUrl('/select/logsql/query', options.datasourceUrl);\n const postData: Record<string, string> = {\n query: params.query,\n start: params.start,\n end: params.end,\n };\n if (params?.limit) postData['limit'] = params.limit.toString();\n if (params?.offset) postData['offset'] = params.offset.toString();\n\n const data = new URLSearchParams(postData).toString();\n const doFetch = options.fetch ?? fetch;\n const response = await doFetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Accept: 'application/stream+json',\n ...options.headers,\n },\n body: data,\n });\n if (response.status !== 200) {\n throw new Error(await response.text());\n }\n const output: VictoriaLogsStreamQueryRangeResponse = [];\n\n if (!response?.body) return output;\n const reader = response.body.getReader();\n const decoder = new TextDecoder('utf-8');\n let buffer = '';\n\n let result = await reader.read();\n while (!result.done) {\n buffer += decoder.decode(result.value, { stream: true });\n let boundary = buffer.indexOf('\\n');\n while (boundary !== -1) {\n const line = buffer.slice(0, boundary);\n buffer = buffer.slice(boundary + 1);\n output.push(JSON.parse(line));\n boundary = buffer.indexOf('\\n');\n }\n result = await reader.read();\n }\n if (buffer.trim().length > 0) {\n output.push(JSON.parse(buffer));\n }\n return output;\n}\n\nexport async function statsQueryRange(\n params: VictoriaLogsStatsQueryRangeParams,\n options: VictoriaLogsApiOptions,\n): Promise<VictoriaLogsStatsQueryRangeResponse> {\n const url = buildUrl('/select/logsql/stats_query_range', options.datasourceUrl);\n const postData: Record<string, string> = {\n query: params.query,\n start: params.start,\n end: params.end,\n };\n if (params?.step) postData['step'] = params.step.toString();\n\n const data = new URLSearchParams(postData).toString();\n const doFetch = options.fetch ?? fetch;\n const response = await doFetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Accept: 'application/json',\n ...options.headers,\n },\n body: data,\n });\n return await response.json();\n}\n\nexport async function fieldNames(\n params: VictoriaLogsFieldNamesParams,\n options: VictoriaLogsApiOptions,\n): Promise<VictoriaLogsFieldNamesResponse> {\n const url = buildUrl('/select/logsql/field_names', options.datasourceUrl);\n const postData: Record<string, string> = {\n query: params.query,\n };\n if (params.start) postData['start'] = params.start;\n if (params.end) postData['end'] = params.end;\n\n const data = new URLSearchParams(postData).toString();\n const doFetch = options.fetch ?? fetch;\n const response = await doFetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Accept: 'application/json',\n ...options.headers,\n },\n body: data,\n });\n return await response.json();\n}\n\nexport async function fieldValues(\n params: VictoriaLogsFieldValuesParams,\n options: VictoriaLogsApiOptions,\n): Promise<VictoriaLogsFieldValuesResponse> {\n const url = buildUrl(`/select/logsql/field_values`, options.datasourceUrl);\n const postData: Record<string, string> = {\n query: params.query,\n field: params.field,\n };\n if (params.start) postData['start'] = params.start;\n if (params.end) postData['end'] = params.end;\n\n const data = new URLSearchParams(postData).toString();\n const doFetch = options.fetch ?? fetch;\n const response = await doFetch(url.toString(), {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Accept: 'application/json',\n ...options.headers,\n },\n body: data,\n });\n return await response.json();\n}\n"],"names":["buildUrl","path","datasourceUrl","startsWith","URL","fullPath","endsWith","slice","window","location","origin","streamQueryRange","params","options","url","postData","query","start","end","limit","toString","offset","data","URLSearchParams","doFetch","fetch","response","method","headers","Accept","body","status","Error","text","output","reader","getReader","decoder","TextDecoder","buffer","result","read","done","decode","value","stream","boundary","indexOf","line","push","JSON","parse","trim","length","statsQueryRange","step","json","fieldNames","fieldValues","field"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C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AAMC,WAAW,MAAMF,QAAQV,IAAIM,QAAQ,IAAI;QAC7CO,QAAQ;QACRC,SAAS;YACP,gBAAgB;YAChBC,QAAQ;YACR,GAAGhB,QAAQe,OAAO;QACpB;QACAE,MAAMR;IACR;IACA,OAAO,MAAMI,SAAS8B,IAAI;AAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VictoriaLogsLogQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAyB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,KAAK,4BAA4B,GAAG,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;AAEjF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,4BAA4B,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"VictoriaLogsLogQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAyB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAExD,KAAK,4BAA4B,GAAG,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;AAEjF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,4BAA4B,GAAG,YAAY,CAqF5F"}
|
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import { InputLabel, Stack } from "@mui/material";
|
|
15
15
|
import { createModEnterHandler } from "@perses-dev/dashboards";
|
|
16
16
|
import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from "@perses-dev/plugin-system";
|
|
17
|
-
import { useCallback, useState
|
|
17
|
+
import { useCallback, useState } from "react";
|
|
18
18
|
import { LogsQLEditor } from "../../components/logsql-editor.js";
|
|
19
19
|
import { VICTORIALOGS_DATASOURCE_KIND } from "../../model/index.js";
|
|
20
20
|
import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from "../constants.js";
|
|
@@ -27,12 +27,11 @@ export function VictoriaLogsLogQueryEditor(props) {
|
|
|
27
27
|
// const victorialogsURL = client?.options.datasourceUrl;
|
|
28
28
|
// Local state for editor value to prevent query_range calls on every keystroke
|
|
29
29
|
const [localQuery, setLocalQuery] = useState(value.query);
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const [previousQuery, setPreviousQuery] = useState(value.query);
|
|
31
|
+
if (value.query !== previousQuery) {
|
|
32
|
+
setPreviousQuery(value.query);
|
|
32
33
|
setLocalQuery(value.query);
|
|
33
|
-
}
|
|
34
|
-
value.query
|
|
35
|
-
]);
|
|
34
|
+
}
|
|
36
35
|
const handleDatasourceChange = (newDatasourceSelection)=>{
|
|
37
36
|
if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {
|
|
38
37
|
onChange({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { InputLabel, Stack } from '@mui/material';\nimport { createModEnterHandler } from '@perses-dev/dashboards';\nimport type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system';\nimport type { ReactElement } from 'react';\nimport { useCallback, useState
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { InputLabel, Stack } from '@mui/material';\nimport { createModEnterHandler } from '@perses-dev/dashboards';\nimport type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system';\nimport type { ReactElement } from 'react';\nimport { useCallback, useState } from 'react';\n\nimport { LogsQLEditor } from '../../components/logsql-editor';\nimport type { VictoriaLogsDatasourceSelector } from '../../model';\nimport { VICTORIALOGS_DATASOURCE_KIND } from '../../model';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport type { VictoriaLogsLogQuerySpec } from './types';\n\ntype VictoriaLogsQueryEditorProps = OptionsEditorProps<VictoriaLogsLogQuerySpec>;\n\nexport function VictoriaLogsLogQueryEditor(props: VictoriaLogsQueryEditorProps): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n VICTORIALOGS_DATASOURCE_KIND,\n ) as VictoriaLogsDatasourceSelector;\n\n // const { data: client } = useDatasourceClient<VictoriaLogsClient>(selectedDatasource);\n // const victorialogsURL = client?.options.datasourceUrl;\n\n // Local state for editor value to prevent query_range calls on every keystroke\n const [localQuery, setLocalQuery] = useState(value.query);\n\n const [previousQuery, setPreviousQuery] = useState(value.query);\n if (value.query !== previousQuery) {\n setPreviousQuery(value.query);\n setLocalQuery(value.query);\n }\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (newDatasourceSelection) => {\n if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {\n onChange({ ...value, datasource: newDatasourceSelection });\n return;\n }\n\n throw new Error('Got unexpected non VictoriaLogsQuery datasource selection');\n };\n\n // Debounced query change handler to prevent excessive query_range calls\n const handleQueryChange = useCallback((newQuery: string) => {\n setLocalQuery(newQuery);\n }, []);\n\n // Immediate query execution on Enter or blur\n const handleQueryExecute = useCallback(\n (query: string) => {\n onChange({ ...value, query });\n },\n [onChange, value],\n );\n\n return (\n <Stack spacing={1.5} paddingBottom={1}>\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n Datasource\n </InputLabel>\n <DatasourceSelect\n datasourcePluginKind={DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n label=\"VictoriaLogs Datasource\"\n notched\n />\n </div>\n\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n LogsQL Query\n </InputLabel>\n <LogsQLEditor\n value={localQuery}\n onChange={handleQueryChange}\n onBlur={() => handleQueryExecute(localQuery)}\n onKeyDown={createModEnterHandler(() => handleQueryExecute(localQuery))}\n placeholder='Enter LogsQL query (e.g. {job=\"mysql\"} |= \"error\")'\n // height=\"120px\"\n />\n </div>\n </Stack>\n );\n}\n"],"names":["InputLabel","Stack","createModEnterHandler","DatasourceSelect","isVariableDatasource","useDatasourceSelectValueToSelector","useCallback","useState","LogsQLEditor","VICTORIALOGS_DATASOURCE_KIND","DATASOURCE_KIND","DEFAULT_DATASOURCE","VictoriaLogsLogQueryEditor","props","onChange","value","datasource","datasourceSelectValue","selectedDatasource","localQuery","setLocalQuery","query","previousQuery","setPreviousQuery","handleDatasourceChange","newDatasourceSelection","kind","Error","handleQueryChange","newQuery","handleQueryExecute","spacing","paddingBottom","div","sx","display","marginBottom","fontWeight","datasourcePluginKind","label","notched","onBlur","onKeyDown","placeholder"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,EAAEC,KAAK,QAAQ,gBAAgB;AAClD,SAASC,qBAAqB,QAAQ,yBAAyB;AAE/D,SAASC,gBAAgB,EAAEC,oBAAoB,EAAEC,kCAAkC,QAAQ,4BAA4B;AAEvH,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAE9C,SAASC,YAAY,QAAQ,oCAAiC;AAE9D,SAASC,4BAA4B,QAAQ,uBAAc;AAC3D,SAASC,eAAe,EAAEC,kBAAkB,QAAQ,kBAAe;AAKnE,OAAO,SAASC,2BAA2BC,KAAmC;IAC5E,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGF;IAC5B,MAAM,EAAEG,UAAU,EAAE,GAAGD;IACvB,MAAME,wBAAwBD,cAAcL;IAC5C,MAAMO,qBAAqBb,mCACzBY,uBACAR;IAGF,wFAAwF;IACxF,yDAAyD;IAEzD,+EAA+E;IAC/E,MAAM,CAACU,YAAYC,cAAc,GAAGb,SAASQ,MAAMM,KAAK;IAExD,MAAM,CAACC,eAAeC,iBAAiB,GAAGhB,SAASQ,MAAMM,KAAK;IAC9D,IAAIN,MAAMM,KAAK,KAAKC,eAAe;QACjCC,iBAAiBR,MAAMM,KAAK;QAC5BD,cAAcL,MAAMM,KAAK;IAC3B;IAEA,MAAMG,yBAA4D,CAACC;QACjE,IAAI,CAACrB,qBAAqBqB,2BAA2BA,uBAAuBC,IAAI,KAAKhB,iBAAiB;YACpGI,SAAS;gBAAE,GAAGC,KAAK;gBAAEC,YAAYS;YAAuB;YACxD;QACF;QAEA,MAAM,IAAIE,MAAM;IAClB;IAEA,wEAAwE;IACxE,MAAMC,oBAAoBtB,YAAY,CAACuB;QACrCT,cAAcS;IAChB,GAAG,EAAE;IAEL,6CAA6C;IAC7C,MAAMC,qBAAqBxB,YACzB,CAACe;QACCP,SAAS;YAAE,GAAGC,KAAK;YAAEM;QAAM;IAC7B,GACA;QAACP;QAAUC;KAAM;IAGnB,qBACE,MAACd;QAAM8B,SAAS;QAAKC,eAAe;;0BAClC,MAACC;;kCACC,KAACjC;wBACCkC,IAAI;4BACFC,SAAS;4BACTC,cAAc;4BACdC,YAAY;wBACd;kCACD;;kCAGD,KAAClC;wBACCmC,sBAAsB5B;wBACtBK,OAAOG;wBACPJ,UAAUU;wBACVe,OAAM;wBACNC,OAAO;;;;0BAIX,MAACP;;kCACC,KAACjC;wBACCkC,IAAI;4BACFC,SAAS;4BACTC,cAAc;4BACdC,YAAY;wBACd;kCACD;;kCAGD,KAAC7B;wBACCO,OAAOI;wBACPL,UAAUc;wBACVa,QAAQ,IAAMX,mBAAmBX;wBACjCuB,WAAWxC,sBAAsB,IAAM4B,mBAAmBX;wBAC1DwB,aAAY;;;;;;AAMtB"}
|
package/lib/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VictoriaLogsTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAyB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAE/D,KAAK,4BAA4B,GAAG,kBAAkB,CAAC,+BAA+B,CAAC,CAAC;AAExF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"VictoriaLogsTimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../../src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAyB,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAE/D,KAAK,4BAA4B,GAAG,kBAAkB,CAAC,+BAA+B,CAAC,CAAC;AAExF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,4BAA4B,GAAG,YAAY,CAkFzF"}
|
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import { InputLabel, Stack } from "@mui/material";
|
|
15
15
|
import { createModEnterHandler } from "@perses-dev/dashboards";
|
|
16
16
|
import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from "@perses-dev/plugin-system";
|
|
17
|
-
import { useCallback, useState
|
|
17
|
+
import { useCallback, useState } from "react";
|
|
18
18
|
import { LogsQLEditor } from "../../components/logsql-editor.js";
|
|
19
19
|
import { VICTORIALOGS_DATASOURCE_KIND } from "../../model/index.js";
|
|
20
20
|
import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from "../constants.js";
|
|
@@ -25,12 +25,11 @@ export function VictoriaLogsQueryEditor(props) {
|
|
|
25
25
|
const selectedDatasource = useDatasourceSelectValueToSelector(datasourceSelectValue, VICTORIALOGS_DATASOURCE_KIND);
|
|
26
26
|
// Local state for editor value to prevent query_range calls on every keystroke
|
|
27
27
|
const [localQuery, setLocalQuery] = useState(value.query);
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const [previousQuery, setPreviousQuery] = useState(value.query);
|
|
29
|
+
if (value.query !== previousQuery) {
|
|
30
|
+
setPreviousQuery(value.query);
|
|
30
31
|
setLocalQuery(value.query);
|
|
31
|
-
}
|
|
32
|
-
value.query
|
|
33
|
-
]);
|
|
32
|
+
}
|
|
34
33
|
const handleDatasourceChange = (newDatasourceSelection)=>{
|
|
35
34
|
if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {
|
|
36
35
|
onChange({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { InputLabel, Stack } from '@mui/material';\nimport { createModEnterHandler } from '@perses-dev/dashboards';\nimport type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system';\nimport type { ReactElement } from 'react';\nimport { useCallback, useState
|
|
1
|
+
{"version":3,"sources":["../../../../src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { InputLabel, Stack } from '@mui/material';\nimport { createModEnterHandler } from '@perses-dev/dashboards';\nimport type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system';\nimport type { ReactElement } from 'react';\nimport { useCallback, useState } from 'react';\n\nimport { LogsQLEditor } from '../../components/logsql-editor';\nimport type { VictoriaLogsDatasourceSelector } from '../../model';\nimport { VICTORIALOGS_DATASOURCE_KIND } from '../../model';\nimport { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants';\nimport type { VictoriaLogsTimeSeriesQuerySpec } from './types';\n\ntype VictoriaLogsQueryEditorProps = OptionsEditorProps<VictoriaLogsTimeSeriesQuerySpec>;\n\nexport function VictoriaLogsQueryEditor(props: VictoriaLogsQueryEditorProps): ReactElement {\n const { onChange, value } = props;\n const { datasource } = value;\n const datasourceSelectValue = datasource ?? DEFAULT_DATASOURCE;\n const selectedDatasource = useDatasourceSelectValueToSelector(\n datasourceSelectValue,\n VICTORIALOGS_DATASOURCE_KIND,\n ) as VictoriaLogsDatasourceSelector;\n\n // Local state for editor value to prevent query_range calls on every keystroke\n const [localQuery, setLocalQuery] = useState(value.query);\n\n const [previousQuery, setPreviousQuery] = useState(value.query);\n if (value.query !== previousQuery) {\n setPreviousQuery(value.query);\n setLocalQuery(value.query);\n }\n\n const handleDatasourceChange: DatasourceSelectProps['onChange'] = (newDatasourceSelection) => {\n if (!isVariableDatasource(newDatasourceSelection) && newDatasourceSelection.kind === DATASOURCE_KIND) {\n onChange({ ...value, datasource: newDatasourceSelection });\n return;\n }\n\n throw new Error('Got unexpected non VictoriaLogsQuery datasource selection');\n };\n\n // Debounced query change handler to prevent excessive query_range calls\n const handleQueryChange = useCallback((newQuery: string) => {\n setLocalQuery(newQuery);\n }, []);\n\n // Immediate query execution on Enter or blur\n const handleQueryExecute = useCallback(\n (query: string) => {\n onChange({ ...value, query });\n },\n [onChange, value],\n );\n\n return (\n <Stack spacing={1.5} paddingBottom={1}>\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n Datasource\n </InputLabel>\n <DatasourceSelect\n datasourcePluginKind={DATASOURCE_KIND}\n value={selectedDatasource}\n onChange={handleDatasourceChange}\n label=\"VictoriaLogs Datasource\"\n notched\n />\n </div>\n\n <div>\n <InputLabel\n sx={{\n display: 'block',\n marginBottom: '4px',\n fontWeight: 500,\n }}\n >\n LogsQL Query\n </InputLabel>\n <LogsQLEditor\n value={localQuery}\n onChange={handleQueryChange}\n onBlur={() => handleQueryExecute(localQuery)}\n onKeyDown={createModEnterHandler(() => handleQueryExecute(localQuery))}\n placeholder='Enter LogsQL query (e.g. {job=\"mysql\"} |= \"error\")'\n // height=\"120px\"\n />\n </div>\n </Stack>\n );\n}\n"],"names":["InputLabel","Stack","createModEnterHandler","DatasourceSelect","isVariableDatasource","useDatasourceSelectValueToSelector","useCallback","useState","LogsQLEditor","VICTORIALOGS_DATASOURCE_KIND","DATASOURCE_KIND","DEFAULT_DATASOURCE","VictoriaLogsQueryEditor","props","onChange","value","datasource","datasourceSelectValue","selectedDatasource","localQuery","setLocalQuery","query","previousQuery","setPreviousQuery","handleDatasourceChange","newDatasourceSelection","kind","Error","handleQueryChange","newQuery","handleQueryExecute","spacing","paddingBottom","div","sx","display","marginBottom","fontWeight","datasourcePluginKind","label","notched","onBlur","onKeyDown","placeholder"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;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