@perses-dev/plugin-system 0.0.0-snapshot-profile-89b306f → 0.0.0-snapshot-panel-actions-520389b
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/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +2 -2
- package/dist/cjs/components/Variables/variable-model.js +4 -2
- package/dist/cjs/model/index.js +0 -1
- package/dist/cjs/remote/PluginRuntime.js +18 -10
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +2 -10
- package/dist/cjs/runtime/DataQueriesProvider/model.js +4 -17
- package/dist/cjs/runtime/index.js +0 -1
- package/dist/cjs/runtime/time-series-queries.js +1 -1
- package/dist/cjs/test/mock-data.js +0 -23
- package/dist/cjs/{model/profile-queries.js → test/render-hook.js} +16 -1
- package/dist/cjs/test/render.js +4 -21
- package/dist/cjs/test/utils.js +49 -0
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +2 -2
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +4 -2
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +0 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/panels.d.ts +8 -0
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugins.d.ts +0 -2
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +18 -10
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +2 -10
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +4 -17
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +0 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +1 -1
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +2 -2
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/test/mock-data.d.ts +1 -2
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +0 -20
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render-hook.d.ts +8 -0
- package/dist/test/render-hook.d.ts.map +1 -0
- package/dist/test/render-hook.js +26 -0
- package/dist/test/render-hook.js.map +1 -0
- package/dist/test/render.d.ts +1 -5
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +4 -21
- package/dist/test/render.js.map +1 -1
- package/dist/test/utils.d.ts +9 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/test/utils.js +41 -0
- package/dist/test/utils.js.map +1 -0
- package/package.json +5 -5
- package/dist/cjs/runtime/profile-queries.js +0 -65
- package/dist/model/profile-queries.d.ts +0 -19
- package/dist/model/profile-queries.d.ts.map +0 -1
- package/dist/model/profile-queries.js +0 -15
- package/dist/model/profile-queries.js.map +0 -1
- package/dist/runtime/profile-queries.d.ts +0 -10
- package/dist/runtime/profile-queries.d.ts.map +0 -1
- package/dist/runtime/profile-queries.js +0 -52
- package/dist/runtime/profile-queries.js.map +0 -1
package/dist/test/mock-data.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TimeSeriesData, TraceData } from '@perses-dev/core';
|
|
2
2
|
export declare const MOCK_TIME_SERIES_DATA: TimeSeriesData;
|
|
3
3
|
export declare const MOCK_TRACE_DATA: TraceData;
|
|
4
|
-
export declare const MOCK_PROFILE_DATA: ProfileData;
|
|
5
4
|
//# sourceMappingURL=mock-data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-data.d.ts","sourceRoot":"","sources":["../../src/test/mock-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"mock-data.d.ts","sourceRoot":"","sources":["../../src/test/mock-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7D,eAAO,MAAM,qBAAqB,EAAE,cAsBnC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SAmC7B,CAAC"}
|
package/dist/test/mock-data.js
CHANGED
|
@@ -81,25 +81,5 @@ export const MOCK_TRACE_DATA = {
|
|
|
81
81
|
executedQueryString: '{ duration > 1000ms }'
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
-
export const MOCK_PROFILE_DATA = {
|
|
85
|
-
profile: {
|
|
86
|
-
stackTrace: {
|
|
87
|
-
id: 0,
|
|
88
|
-
name: 'root',
|
|
89
|
-
level: 0,
|
|
90
|
-
start: 1699916103945861,
|
|
91
|
-
end: 1699916105065861,
|
|
92
|
-
total: 1000,
|
|
93
|
-
self: 500,
|
|
94
|
-
children: []
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
metadata: {
|
|
98
|
-
spyName: '',
|
|
99
|
-
sampleRate: 1000000000,
|
|
100
|
-
units: 'samples',
|
|
101
|
-
name: 'cpu'
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
84
|
|
|
105
85
|
//# sourceMappingURL=mock-data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/mock-data.ts"],"sourcesContent":["// Copyright 2023 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 {
|
|
1
|
+
{"version":3,"sources":["../../src/test/mock-data.ts"],"sourcesContent":["// Copyright 2023 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 { TimeSeriesData, TraceData } from '@perses-dev/core';\n\nexport const MOCK_TIME_SERIES_DATA: TimeSeriesData = {\n timeRange: {\n start: new Date(1666625490000),\n end: new Date(1666625535000),\n },\n stepMs: 24379,\n series: [\n {\n name: 'device=\"/dev/vda1\", env=\"demo\", fstype=\"ext4\", instance=\"demo.do.prometheus.io:9100\", job=\"node\", mountpoint=\"/\"',\n values: [\n [1666479357903, 0.27700745551584494],\n [1666479382282, 0.27701284657366565],\n ],\n },\n {\n name: 'device=\"/dev/vda15\", env=\"demo\", fstype=\"vfat\", instance=\"demo.do.prometheus.io:9100\", job=\"node\", mountpoint=\"/boot/efi\"',\n values: [\n [1666479357903, 0.08486496097624885],\n [1666479382282, 0.08486496097624885],\n ],\n },\n ],\n};\n\nexport const MOCK_TRACE_DATA: TraceData = {\n searchResult: [\n {\n durationMs: 1120,\n serviceStats: {\n 'shop-backend': {\n spanCount: 4,\n errorCount: 0,\n },\n 'cart-service': {\n spanCount: 2,\n errorCount: 0,\n },\n 'article-service': {\n spanCount: 2,\n errorCount: 0,\n },\n 'auth-service': {\n spanCount: 1,\n errorCount: 0,\n },\n postgres: {\n spanCount: 1,\n errorCount: 0,\n },\n },\n startTimeUnixMs: 1699916103945861,\n traceId: '95ba9202315c29c801b5aa41452aa775',\n rootServiceName: 'shop-backend',\n rootTraceName: 'article-to-cart',\n },\n ],\n metadata: {\n executedQueryString: '{ duration > 1000ms }',\n },\n};\n"],"names":["MOCK_TIME_SERIES_DATA","timeRange","start","Date","end","stepMs","series","name","values","MOCK_TRACE_DATA","searchResult","durationMs","serviceStats","spanCount","errorCount","postgres","startTimeUnixMs","traceId","rootServiceName","rootTraceName","metadata","executedQueryString"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,MAAMA,wBAAwC;IACnDC,WAAW;QACTC,OAAO,IAAIC,KAAK;QAChBC,KAAK,IAAID,KAAK;IAChB;IACAE,QAAQ;IACRC,QAAQ;QACN;YACEC,MAAM;YACNC,QAAQ;gBACN;oBAAC;oBAAe;iBAAoB;gBACpC;oBAAC;oBAAe;iBAAoB;aACrC;QACH;QACA;YACED,MAAM;YACNC,QAAQ;gBACN;oBAAC;oBAAe;iBAAoB;gBACpC;oBAAC;oBAAe;iBAAoB;aACrC;QACH;KACD;AACH,EAAE;AAEF,OAAO,MAAMC,kBAA6B;IACxCC,cAAc;QACZ;YACEC,YAAY;YACZC,cAAc;gBACZ,gBAAgB;oBACdC,WAAW;oBACXC,YAAY;gBACd;gBACA,gBAAgB;oBACdD,WAAW;oBACXC,YAAY;gBACd;gBACA,mBAAmB;oBACjBD,WAAW;oBACXC,YAAY;gBACd;gBACA,gBAAgB;oBACdD,WAAW;oBACXC,YAAY;gBACd;gBACAC,UAAU;oBACRF,WAAW;oBACXC,YAAY;gBACd;YACF;YACAE,iBAAiB;YACjBC,SAAS;YACTC,iBAAiB;YACjBC,eAAe;QACjB;KACD;IACDC,UAAU;QACRC,qBAAqB;IACvB;AACF,EAAE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderHookOptions, RenderHookResult } from '@testing-library/react';
|
|
2
|
+
import { ContextOptions } from './utils';
|
|
3
|
+
/**
|
|
4
|
+
* Test helper to render a React hook with common app-level providers, including the PluginRegistry,
|
|
5
|
+
* wrapped around it. Useful for testing hooks that rely on context such as QueryClientProvider or PluginRegistry.
|
|
6
|
+
*/
|
|
7
|
+
export declare function renderHookWithContext<TProps, TResult>(callback: (props: TProps) => TResult, contextOptions?: ContextOptions, renderHookOptions?: Omit<RenderHookOptions<TProps>, 'wrapper'>): RenderHookResult<TResult, TProps>;
|
|
8
|
+
//# sourceMappingURL=render-hook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-hook.d.ts","sourceRoot":"","sources":["../../src/test/render-hook.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAc,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,cAAc,EAAyB,MAAM,SAAS,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,OAAO,EACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,EACpC,cAAc,CAAC,EAAE,cAAc,EAC/B,iBAAiB,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,GAC7D,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,CAGnC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { renderHook } from '@testing-library/react';
|
|
14
|
+
import { getTestContextWrapper } from './utils';
|
|
15
|
+
/**
|
|
16
|
+
* Test helper to render a React hook with common app-level providers, including the PluginRegistry,
|
|
17
|
+
* wrapped around it. Useful for testing hooks that rely on context such as QueryClientProvider or PluginRegistry.
|
|
18
|
+
*/ export function renderHookWithContext(callback, contextOptions, renderHookOptions) {
|
|
19
|
+
const wrapper = getTestContextWrapper(contextOptions);
|
|
20
|
+
return renderHook(callback, {
|
|
21
|
+
wrapper,
|
|
22
|
+
...renderHookOptions
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=render-hook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/test/render-hook.tsx"],"sourcesContent":["// Copyright 2023 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 { renderHook, RenderHookOptions, RenderHookResult } from '@testing-library/react';\nimport { ContextOptions, getTestContextWrapper } from './utils';\n\n/**\n * Test helper to render a React hook with common app-level providers, including the PluginRegistry,\n * wrapped around it. Useful for testing hooks that rely on context such as QueryClientProvider or PluginRegistry.\n */\nexport function renderHookWithContext<TProps, TResult>(\n callback: (props: TProps) => TResult,\n contextOptions?: ContextOptions,\n renderHookOptions?: Omit<RenderHookOptions<TProps>, 'wrapper'>\n): RenderHookResult<TResult, TProps> {\n const wrapper = getTestContextWrapper(contextOptions);\n return renderHook(callback, { wrapper, ...renderHookOptions });\n}\n"],"names":["renderHook","getTestContextWrapper","renderHookWithContext","callback","contextOptions","renderHookOptions","wrapper"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,UAAU,QAA6C,yBAAyB;AACzF,SAAyBC,qBAAqB,QAAQ,UAAU;AAEhE;;;CAGC,GACD,OAAO,SAASC,sBACdC,QAAoC,EACpCC,cAA+B,EAC/BC,iBAA8D;IAE9D,MAAMC,UAAUL,sBAAsBG;IACtC,OAAOJ,WAAWG,UAAU;QAAEG;QAAS,GAAGD,iBAAiB;IAAC;AAC9D"}
|
package/dist/test/render.d.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import { RenderOptions, RenderResult } from '@testing-library/react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
type ContextOptions = {
|
|
5
|
-
defaultPluginKinds?: DefaultPluginKinds;
|
|
6
|
-
};
|
|
3
|
+
import { ContextOptions } from './utils';
|
|
7
4
|
/**
|
|
8
5
|
* Test helper to render a React component with some common app-level providers, as well as the PluginRegistry
|
|
9
6
|
* wrapped around it.
|
|
10
7
|
*/
|
|
11
8
|
export declare function renderWithContext(ui: ReactNode, renderOptions?: Omit<RenderOptions, 'queries'>, contextOptions?: ContextOptions): RenderResult;
|
|
12
|
-
export {};
|
|
13
9
|
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAU,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAU,aAAa,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAyB,MAAM,SAAS,CAAC;AAEhE;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,SAAS,EACb,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAC9C,cAAc,CAAC,EAAE,cAAc,GAC9B,YAAY,CAGd"}
|
package/dist/test/render.js
CHANGED
|
@@ -12,31 +12,14 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { render } from '@testing-library/react';
|
|
15
|
-
import {
|
|
16
|
-
import { PluginRegistry } from '../components/PluginRegistry';
|
|
17
|
-
import { testPluginLoader } from './test-plugins';
|
|
15
|
+
import { getTestContextWrapper } from './utils';
|
|
18
16
|
/**
|
|
19
17
|
* Test helper to render a React component with some common app-level providers, as well as the PluginRegistry
|
|
20
18
|
* wrapped around it.
|
|
21
19
|
*/ export function renderWithContext(ui, renderOptions, contextOptions) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
queries: {
|
|
26
|
-
refetchOnWindowFocus: false,
|
|
27
|
-
retry: false
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return render(/*#__PURE__*/ _jsx(QueryClientProvider, {
|
|
32
|
-
client: queryClient,
|
|
33
|
-
children: /*#__PURE__*/ _jsx(PluginRegistry, {
|
|
34
|
-
pluginLoader: testPluginLoader,
|
|
35
|
-
defaultPluginKinds: contextOptions?.defaultPluginKinds ?? {
|
|
36
|
-
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
37
|
-
},
|
|
38
|
-
children: ui
|
|
39
|
-
})
|
|
20
|
+
const Wrapper = getTestContextWrapper(contextOptions);
|
|
21
|
+
return render(/*#__PURE__*/ _jsx(Wrapper, {
|
|
22
|
+
children: ui
|
|
40
23
|
}), renderOptions);
|
|
41
24
|
}
|
|
42
25
|
|
package/dist/test/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 2023 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 { render, RenderOptions, RenderResult } from '@testing-library/react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 2023 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 { render, RenderOptions, RenderResult } from '@testing-library/react';\nimport { ReactNode } from 'react';\nimport { ContextOptions, getTestContextWrapper } from './utils';\n\n/**\n * Test helper to render a React component with some common app-level providers, as well as the PluginRegistry\n * wrapped around it.\n */\nexport function renderWithContext(\n ui: ReactNode,\n renderOptions?: Omit<RenderOptions, 'queries'>,\n contextOptions?: ContextOptions\n): RenderResult {\n const Wrapper = getTestContextWrapper(contextOptions);\n return render(<Wrapper>{ui}</Wrapper>, renderOptions);\n}\n"],"names":["render","getTestContextWrapper","renderWithContext","ui","renderOptions","contextOptions","Wrapper"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,MAAM,QAAqC,yBAAyB;AAE7E,SAAyBC,qBAAqB,QAAQ,UAAU;AAEhE;;;CAGC,GACD,OAAO,SAASC,kBACdC,EAAa,EACbC,aAA8C,EAC9CC,cAA+B;IAE/B,MAAMC,UAAUL,sBAAsBI;IACtC,OAAOL,qBAAO,KAACM;kBAASH;QAAeC;AACzC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { DefaultPluginKinds } from '../model';
|
|
3
|
+
export type ContextOptions = {
|
|
4
|
+
defaultPluginKinds?: DefaultPluginKinds;
|
|
5
|
+
};
|
|
6
|
+
export declare function getTestContextWrapper(contextOptions?: ContextOptions): ({ children }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}) => ReactNode;
|
|
9
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/test/utils.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,MAAM,cAAc,GAAG;IAC3B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,cAAc,CAAC,EAAE,cAAc,kBAM7B;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,KAAG,SAAS,CAgB1E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
15
|
+
import { PluginRegistry } from '../components';
|
|
16
|
+
import { testPluginLoader } from './test-plugins';
|
|
17
|
+
export function getTestContextWrapper(contextOptions) {
|
|
18
|
+
// Create a new QueryClient for each test to avoid caching issues
|
|
19
|
+
const queryClient = new QueryClient({
|
|
20
|
+
defaultOptions: {
|
|
21
|
+
queries: {
|
|
22
|
+
refetchOnWindowFocus: false,
|
|
23
|
+
retry: false
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return function Wrapper({ children }) {
|
|
28
|
+
return /*#__PURE__*/ _jsx(QueryClientProvider, {
|
|
29
|
+
client: queryClient,
|
|
30
|
+
children: /*#__PURE__*/ _jsx(PluginRegistry, {
|
|
31
|
+
pluginLoader: testPluginLoader,
|
|
32
|
+
defaultPluginKinds: contextOptions?.defaultPluginKinds ?? {
|
|
33
|
+
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
34
|
+
},
|
|
35
|
+
children: children
|
|
36
|
+
})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/test/utils.tsx"],"sourcesContent":["// Copyright 2023 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 { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ReactNode } from 'react';\nimport { PluginRegistry } from '../components';\nimport { DefaultPluginKinds } from '../model';\nimport { testPluginLoader } from './test-plugins';\n\nexport type ContextOptions = {\n defaultPluginKinds?: DefaultPluginKinds;\n};\n\nexport function getTestContextWrapper(contextOptions?: ContextOptions) {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({\n defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } },\n });\n\n return function Wrapper({ children }: { children: ReactNode }): ReactNode {\n return (\n <QueryClientProvider client={queryClient}>\n <PluginRegistry\n pluginLoader={testPluginLoader}\n defaultPluginKinds={\n contextOptions?.defaultPluginKinds ?? {\n TimeSeriesQuery: 'PrometheusTimeSeriesQuery',\n }\n }\n >\n {children}\n </PluginRegistry>\n </QueryClientProvider>\n );\n };\n}\n"],"names":["QueryClient","QueryClientProvider","PluginRegistry","testPluginLoader","getTestContextWrapper","contextOptions","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","Wrapper","children","client","pluginLoader","defaultPluginKinds","TimeSeriesQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,WAAW,EAAEC,mBAAmB,QAAQ,wBAAwB;AAEzE,SAASC,cAAc,QAAQ,gBAAgB;AAE/C,SAASC,gBAAgB,QAAQ,iBAAiB;AAMlD,OAAO,SAASC,sBAAsBC,cAA+B;IACnE,iEAAiE;IACjE,MAAMC,cAAc,IAAIN,YAAY;QAClCO,gBAAgB;YAAEC,SAAS;gBAAEC,sBAAsB;gBAAOC,OAAO;YAAM;QAAE;IAC3E;IAEA,OAAO,SAASC,QAAQ,EAAEC,QAAQ,EAA2B;QAC3D,qBACE,KAACX;YAAoBY,QAAQP;sBAC3B,cAAA,KAACJ;gBACCY,cAAcX;gBACdY,oBACEV,gBAAgBU,sBAAsB;oBACpCC,iBAAiB;gBACnB;0BAGDJ;;;IAIT;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/plugin-system",
|
|
3
|
-
"version": "0.0.0-snapshot-
|
|
3
|
+
"version": "0.0.0-snapshot-panel-actions-520389b",
|
|
4
4
|
"description": "The plugin feature in Pereses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@module-federation/enhanced": "^0.
|
|
32
|
-
"@perses-dev/components": "0.0.0-snapshot-
|
|
33
|
-
"@perses-dev/core": "0.0.0-snapshot-
|
|
31
|
+
"@module-federation/enhanced": "^0.14.3",
|
|
32
|
+
"@perses-dev/components": "0.0.0-snapshot-panel-actions-520389b",
|
|
33
|
+
"@perses-dev/core": "0.0.0-snapshot-panel-actions-520389b",
|
|
34
34
|
"date-fns": "^4.1.0",
|
|
35
35
|
"date-fns-tz": "^3.2.0",
|
|
36
36
|
"immer": "^10.1.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@mui/material": "^6.1.10",
|
|
44
|
-
"@tanstack/react-query": "^
|
|
44
|
+
"@tanstack/react-query": "^4.39.1",
|
|
45
45
|
"react": "^17.0.2 || ^18.0.0",
|
|
46
46
|
"react-dom": "^17.0.2 || ^18.0.0"
|
|
47
47
|
},
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
function _export(target, all) {
|
|
18
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
PROFILE_QUERY_KEY: function() {
|
|
25
|
-
return PROFILE_QUERY_KEY;
|
|
26
|
-
},
|
|
27
|
-
useProfileQueries: function() {
|
|
28
|
-
return useProfileQueries;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const _reactquery = require("@tanstack/react-query");
|
|
32
|
-
const _datasources = require("./datasources");
|
|
33
|
-
const _pluginregistry = require("./plugin-registry");
|
|
34
|
-
const _TimeRangeProvider = require("./TimeRangeProvider");
|
|
35
|
-
const PROFILE_QUERY_KEY = 'ProfileQuery';
|
|
36
|
-
function useProfileQueries(definitions) {
|
|
37
|
-
const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
|
|
38
|
-
const datasourceStore = (0, _datasources.useDatasourceStore)();
|
|
39
|
-
const { absoluteTimeRange } = (0, _TimeRangeProvider.useTimeRange)();
|
|
40
|
-
const context = {
|
|
41
|
-
datasourceStore,
|
|
42
|
-
absoluteTimeRange
|
|
43
|
-
};
|
|
44
|
-
// useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)
|
|
45
|
-
// https://tanstack.com/query/v4/docs/react/reference/useQuery
|
|
46
|
-
return (0, _reactquery.useQueries)({
|
|
47
|
-
queries: definitions.map((definition)=>{
|
|
48
|
-
const queryKey = [
|
|
49
|
-
definition,
|
|
50
|
-
datasourceStore,
|
|
51
|
-
absoluteTimeRange
|
|
52
|
-
]; // `queryKey` watches and reruns `queryFn` if keys in the array change
|
|
53
|
-
const profileQueryKind = definition?.spec?.plugin?.kind;
|
|
54
|
-
return {
|
|
55
|
-
queryKey: queryKey,
|
|
56
|
-
queryFn: async ()=>{
|
|
57
|
-
const plugin = await getPlugin(PROFILE_QUERY_KEY, profileQueryKind);
|
|
58
|
-
const data = await plugin.getProfileData(definition.spec.plugin.spec, context);
|
|
59
|
-
return data;
|
|
60
|
-
},
|
|
61
|
-
structuralSharing: false
|
|
62
|
-
};
|
|
63
|
-
})
|
|
64
|
-
});
|
|
65
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Query, QueryKey } from '@tanstack/react-query';
|
|
2
|
-
import { UnknownSpec, ProfileData, AbsoluteTimeRange } from '@perses-dev/core';
|
|
3
|
-
import { DatasourceStore } from '../runtime';
|
|
4
|
-
import { Plugin } from './plugin-base';
|
|
5
|
-
/**
|
|
6
|
-
* A plugin for running profile queries.
|
|
7
|
-
*/
|
|
8
|
-
export interface ProfileQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {
|
|
9
|
-
getProfileData: (spec: Spec, ctx: ProfileQueryContext) => Promise<ProfileData>;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Context available to ProfileQuery plugins at runtime.
|
|
13
|
-
*/
|
|
14
|
-
export interface ProfileQueryContext {
|
|
15
|
-
datasourceStore: DatasourceStore;
|
|
16
|
-
absoluteTimeRange?: AbsoluteTimeRange;
|
|
17
|
-
}
|
|
18
|
-
export type ProfileDataQuery = Query<ProfileData, unknown, ProfileData, QueryKey>;
|
|
19
|
-
//# sourceMappingURL=profile-queries.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile-queries.d.ts","sourceRoot":"","sources":["../../src/model/profile-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IAC1E,cAAc,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;CAChF;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,eAAe,CAAC;IACjC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
export { };
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=profile-queries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/profile-queries.ts"],"sourcesContent":["// Copyright 2025 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 { Query, QueryKey } from '@tanstack/react-query';\nimport { UnknownSpec, ProfileData, AbsoluteTimeRange } from '@perses-dev/core';\nimport { DatasourceStore } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * A plugin for running profile queries.\n */\nexport interface ProfileQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getProfileData: (spec: Spec, ctx: ProfileQueryContext) => Promise<ProfileData>;\n}\n\n/**\n * Context available to ProfileQuery plugins at runtime.\n */\nexport interface ProfileQueryContext {\n datasourceStore: DatasourceStore;\n absoluteTimeRange?: AbsoluteTimeRange;\n}\n\nexport type ProfileDataQuery = Query<ProfileData, unknown, ProfileData, QueryKey>;\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAsBjC,WAAkF"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { QueryDefinition, UnknownSpec, ProfileData } from '@perses-dev/core';
|
|
2
|
-
import { UseQueryResult } from '@tanstack/react-query';
|
|
3
|
-
export type ProfileQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'ProfileQuery', PluginSpec>;
|
|
4
|
-
export declare const PROFILE_QUERY_KEY = "ProfileQuery";
|
|
5
|
-
/**
|
|
6
|
-
* Run a profile query using a ProfileQuery plugin and return the results
|
|
7
|
-
* @param definitions: dashboard defintion for a profile query
|
|
8
|
-
*/
|
|
9
|
-
export declare function useProfileQueries(definitions: ProfileQueryDefinition[]): Array<UseQueryResult<ProfileData>>;
|
|
10
|
-
//# sourceMappingURL=profile-queries.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profile-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/profile-queries.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAc,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAInE,MAAM,MAAM,sBAAsB,CAAC,UAAU,GAAG,WAAW,IAAI,eAAe,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC;AAC3G,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,sBAAsB,EAAE,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CA4B3G"}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
// Copyright 2025 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { useQueries } from '@tanstack/react-query';
|
|
14
|
-
import { useDatasourceStore } from './datasources';
|
|
15
|
-
import { usePluginRegistry } from './plugin-registry';
|
|
16
|
-
import { useTimeRange } from './TimeRangeProvider';
|
|
17
|
-
export const PROFILE_QUERY_KEY = 'ProfileQuery';
|
|
18
|
-
/**
|
|
19
|
-
* Run a profile query using a ProfileQuery plugin and return the results
|
|
20
|
-
* @param definitions: dashboard defintion for a profile query
|
|
21
|
-
*/ export function useProfileQueries(definitions) {
|
|
22
|
-
const { getPlugin } = usePluginRegistry();
|
|
23
|
-
const datasourceStore = useDatasourceStore();
|
|
24
|
-
const { absoluteTimeRange } = useTimeRange();
|
|
25
|
-
const context = {
|
|
26
|
-
datasourceStore,
|
|
27
|
-
absoluteTimeRange
|
|
28
|
-
};
|
|
29
|
-
// useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)
|
|
30
|
-
// https://tanstack.com/query/v4/docs/react/reference/useQuery
|
|
31
|
-
return useQueries({
|
|
32
|
-
queries: definitions.map((definition)=>{
|
|
33
|
-
const queryKey = [
|
|
34
|
-
definition,
|
|
35
|
-
datasourceStore,
|
|
36
|
-
absoluteTimeRange
|
|
37
|
-
]; // `queryKey` watches and reruns `queryFn` if keys in the array change
|
|
38
|
-
const profileQueryKind = definition?.spec?.plugin?.kind;
|
|
39
|
-
return {
|
|
40
|
-
queryKey: queryKey,
|
|
41
|
-
queryFn: async ()=>{
|
|
42
|
-
const plugin = await getPlugin(PROFILE_QUERY_KEY, profileQueryKind);
|
|
43
|
-
const data = await plugin.getProfileData(definition.spec.plugin.spec, context);
|
|
44
|
-
return data;
|
|
45
|
-
},
|
|
46
|
-
structuralSharing: false
|
|
47
|
-
};
|
|
48
|
-
})
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
//# sourceMappingURL=profile-queries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/profile-queries.tsx"],"sourcesContent":["// Copyright 2025 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 { QueryDefinition, UnknownSpec, ProfileData } from '@perses-dev/core';\nimport { useQueries, UseQueryResult } from '@tanstack/react-query';\nimport { useDatasourceStore } from './datasources';\nimport { usePluginRegistry } from './plugin-registry';\nimport { useTimeRange } from './TimeRangeProvider';\nexport type ProfileQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'ProfileQuery', PluginSpec>;\nexport const PROFILE_QUERY_KEY = 'ProfileQuery';\n\n/**\n * Run a profile query using a ProfileQuery plugin and return the results\n * @param definitions: dashboard defintion for a profile query\n */\nexport function useProfileQueries(definitions: ProfileQueryDefinition[]): Array<UseQueryResult<ProfileData>> {\n const { getPlugin } = usePluginRegistry();\n const datasourceStore = useDatasourceStore();\n const { absoluteTimeRange } = useTimeRange();\n\n const context = {\n datasourceStore,\n absoluteTimeRange,\n };\n\n // useQueries() handles data fetching from query plugins (e.g. traceQL queries, promQL queries)\n // https://tanstack.com/query/v4/docs/react/reference/useQuery\n return useQueries({\n queries: definitions.map((definition) => {\n const queryKey = [definition, datasourceStore, absoluteTimeRange] as const; // `queryKey` watches and reruns `queryFn` if keys in the array change\n const profileQueryKind = definition?.spec?.plugin?.kind;\n return {\n queryKey: queryKey,\n queryFn: async (): Promise<ProfileData> => {\n const plugin = await getPlugin(PROFILE_QUERY_KEY, profileQueryKind);\n const data = await plugin.getProfileData(definition.spec.plugin.spec, context);\n return data;\n },\n\n structuralSharing: false,\n };\n }),\n });\n}\n"],"names":["useQueries","useDatasourceStore","usePluginRegistry","useTimeRange","PROFILE_QUERY_KEY","useProfileQueries","definitions","getPlugin","datasourceStore","absoluteTimeRange","context","queries","map","definition","queryKey","profileQueryKind","spec","plugin","kind","queryFn","data","getProfileData","structuralSharing"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,UAAU,QAAwB,wBAAwB;AACnE,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,iBAAiB,QAAQ,oBAAoB;AACtD,SAASC,YAAY,QAAQ,sBAAsB;AAEnD,OAAO,MAAMC,oBAAoB,eAAe;AAEhD;;;CAGC,GACD,OAAO,SAASC,kBAAkBC,WAAqC;IACrE,MAAM,EAAEC,SAAS,EAAE,GAAGL;IACtB,MAAMM,kBAAkBP;IACxB,MAAM,EAAEQ,iBAAiB,EAAE,GAAGN;IAE9B,MAAMO,UAAU;QACdF;QACAC;IACF;IAEA,+FAA+F;IAC/F,8DAA8D;IAC9D,OAAOT,WAAW;QAChBW,SAASL,YAAYM,GAAG,CAAC,CAACC;YACxB,MAAMC,WAAW;gBAACD;gBAAYL;gBAAiBC;aAAkB,EAAW,sEAAsE;YAClJ,MAAMM,mBAAmBF,YAAYG,MAAMC,QAAQC;YACnD,OAAO;gBACLJ,UAAUA;gBACVK,SAAS;oBACP,MAAMF,SAAS,MAAMV,UAAUH,mBAAmBW;oBAClD,MAAMK,OAAO,MAAMH,OAAOI,cAAc,CAACR,WAAWG,IAAI,CAACC,MAAM,CAACD,IAAI,EAAEN;oBACtE,OAAOU;gBACT;gBAEAE,mBAAmB;YACrB;QACF;IACF;AACF"}
|