diff --git a/.cjs.swcrc b/.cjs.swcrc deleted file mode 100644 index 2ed65083d..000000000 --- a/.cjs.swcrc +++ /dev/null @@ -1,20 +0,0 @@ -{ - "$schema": "https://json.schemastore.org/swcrc", - "jsc": { - "parser": { - "syntax": "typescript", - "tsx": true - }, - "target": "es2022", - "transform": { - "react": { - "runtime": "automatic", - "useBuiltins": true - } - } - }, - "module": { - "type": "commonjs" - }, - "exclude": ["\\.(stories|test)\\."] -} diff --git a/.nvmrc b/.nvmrc index c5ddcef4e..3648bfc34 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v22.14.0 \ No newline at end of file +v24.19.0 diff --git a/.oxlintrc.json b/.oxlintrc.json index 314540119..2ec28ddcb 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -8,7 +8,6 @@ "perf": "warn" }, "env": { - "commonjs": true, "es6": true, "vitest": true, "node": true, @@ -18,6 +17,15 @@ "typescript/explicit-function-return-type": "error", "typescript/explicit-module-boundary-types": "error", "typescript/array-type": ["error", { "default": "array-simple" }], + "typescript/consistent-type-imports": [ + "error", + { + "prefer": "type-imports", + "fixStyle": "separate-type-imports", + "disallowTypeAnnotations": true + } + ], + "typescript/no-import-type-side-effects": "error", "eqeqeq": ["error", "always"], "no-unused-vars": [ "error", @@ -43,6 +51,7 @@ "error", { "props": "never", "children": "never", "propElementValues": "always" } ], + "import/consistent-type-specifier-style": ["error", "prefer-top-level"], "import/no-duplicates": "error", "no-restricted-imports": [ "error", diff --git a/.swcrc b/.swcrc index feaf67637..390c92b8b 100644 --- a/.swcrc +++ b/.swcrc @@ -1,20 +1,26 @@ { "$schema": "https://json.schemastore.org/swcrc", "jsc": { + "baseUrl": ".", "parser": { "syntax": "typescript", "tsx": true }, - "target": "es2022", + "target": "es2023", "transform": { "react": { "runtime": "automatic", "useBuiltins": true } + }, + "experimental": { + "keepImportAttributes": true } }, "module": { - "type": "es6" + "type": "es6", + "resolveFully": true, + "outFileExtension": "js" }, "sourceMaps": true, "exclude": ["\\.(stories|test)\\."] diff --git a/README.md b/README.md index 5fb2d2558..1153f25ea 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ This repository contains the core plugins for [Perses](https://github.com/perses As prerequisites, you need: -- NodeJS [version 22 or greater](https://nodejs.org/). -- npm [version 10 or greater](https://www.npmjs.com/). +- NodeJS [version 24 or greater](https://nodejs.org/). +- npm [version 11 or greater](https://www.npmjs.com/). You should first run `npm install` at the root of the repository. diff --git a/alertmanager/package.json b/alertmanager/package.json index a218c7418..f168dc11b 100644 --- a/alertmanager/package.json +++ b/alertmanager/package.json @@ -15,24 +15,24 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "lodash": "^4.17.21", diff --git a/alertmanager/src/components/ColumnsEditor.tsx b/alertmanager/src/components/ColumnsEditor.tsx index 4274c0f8a..e3abb391f 100644 --- a/alertmanager/src/components/ColumnsEditor.tsx +++ b/alertmanager/src/components/ColumnsEditor.tsx @@ -31,7 +31,8 @@ import ArrowDownIcon from 'mdi-material-ui/ArrowDown'; import ArrowUpIcon from 'mdi-material-ui/ArrowUp'; import DeleteIcon from 'mdi-material-ui/Delete'; import PlusIcon from 'mdi-material-ui/Plus'; -import { ReactElement, useCallback, useRef } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useRef } from 'react'; export interface BaseColumnDefinition { name: string; diff --git a/alertmanager/src/components/LazyTextField.tsx b/alertmanager/src/components/LazyTextField.tsx index 719b79d75..02bcab7fe 100644 --- a/alertmanager/src/components/LazyTextField.tsx +++ b/alertmanager/src/components/LazyTextField.tsx @@ -12,7 +12,8 @@ // limitations under the License. import { TextField } from '@mui/material'; -import { ChangeEvent, ReactElement, useCallback, useEffect, useState } from 'react'; +import type { ChangeEvent, ReactElement } from 'react'; +import { useCallback, useEffect, useState } from 'react'; export interface LazyTextFieldProps { label: string; diff --git a/alertmanager/src/components/MatcherEditor.tsx b/alertmanager/src/components/MatcherEditor.tsx index 028dabb68..2b347f744 100644 --- a/alertmanager/src/components/MatcherEditor.tsx +++ b/alertmanager/src/components/MatcherEditor.tsx @@ -11,18 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - IconButton, - MenuItem, - Stack, - TextField, - Select, - FormControl, - InputLabel, - SelectChangeEvent, -} from '@mui/material'; +import type { SelectChangeEvent } from '@mui/material'; +import { IconButton, MenuItem, Stack, TextField, Select, FormControl, InputLabel } from '@mui/material'; import DeleteIcon from 'mdi-material-ui/Delete'; -import { ReactElement, useId } from 'react'; +import type { ReactElement } from 'react'; +import { useId } from 'react'; export interface MatcherValue { name: string; diff --git a/alertmanager/src/components/MatchersList.tsx b/alertmanager/src/components/MatchersList.tsx index 25d85c9c8..b6d872186 100644 --- a/alertmanager/src/components/MatchersList.tsx +++ b/alertmanager/src/components/MatchersList.tsx @@ -12,8 +12,8 @@ // limitations under the License. import { Chip, Stack } from '@mui/material'; -import { SilenceMatcher } from '@perses-dev/spec'; -import { ReactElement } from 'react'; +import type { SilenceMatcher } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; export interface MatchersListProps { matchers: SilenceMatcher[]; diff --git a/alertmanager/src/components/SilenceForm.tsx b/alertmanager/src/components/SilenceForm.tsx index 60e25a588..6429da894 100644 --- a/alertmanager/src/components/SilenceForm.tsx +++ b/alertmanager/src/components/SilenceForm.tsx @@ -13,10 +13,12 @@ import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, TextField, Typography } from '@mui/material'; import AddIcon from 'mdi-material-ui/Plus'; -import { ReactElement, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useState } from 'react'; -import { PostableSilence } from '../model/api-types'; -import { MatcherEditor, MatcherValue } from './MatcherEditor'; +import type { PostableSilence } from '../model/api-types'; +import type { MatcherValue } from './MatcherEditor'; +import { MatcherEditor } from './MatcherEditor'; export interface SilenceFormProps { open: boolean; diff --git a/alertmanager/src/components/StatusBadge.tsx b/alertmanager/src/components/StatusBadge.tsx index f6d0b54d9..0847fd607 100644 --- a/alertmanager/src/components/StatusBadge.tsx +++ b/alertmanager/src/components/StatusBadge.tsx @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Chip, ChipProps } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ChipProps } from '@mui/material'; +import { Chip } from '@mui/material'; +import type { ReactElement } from 'react'; export interface StatusBadgeProps { status: string; diff --git a/alertmanager/src/explore/AlertManagerAlertsExplorer.tsx b/alertmanager/src/explore/AlertManagerAlertsExplorer.tsx index 613777b6f..0cce82cc6 100644 --- a/alertmanager/src/explore/AlertManagerAlertsExplorer.tsx +++ b/alertmanager/src/explore/AlertManagerAlertsExplorer.tsx @@ -15,8 +15,9 @@ import { Box, Stack } from '@mui/material'; import { Panel } from '@perses-dev/dashboards'; import { useExplorerManagerContext } from '@perses-dev/explore'; import { DataQueriesProvider, MultiQueryEditor } from '@perses-dev/plugin-system'; -import { QueryDefinition } from '@perses-dev/spec'; -import { ReactElement, useState } from 'react'; +import type { QueryDefinition } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; +import { useState } from 'react'; interface AlertsExplorerQueryParams { queries?: QueryDefinition[]; diff --git a/alertmanager/src/explore/AlertManagerSilencesExplorer.tsx b/alertmanager/src/explore/AlertManagerSilencesExplorer.tsx index 500c35900..86ebda342 100644 --- a/alertmanager/src/explore/AlertManagerSilencesExplorer.tsx +++ b/alertmanager/src/explore/AlertManagerSilencesExplorer.tsx @@ -16,13 +16,15 @@ import { useSnackbar } from '@perses-dev/components'; import { Panel } from '@perses-dev/dashboards'; import { useExplorerManagerContext } from '@perses-dev/explore'; import { DataQueriesProvider, MultiQueryEditor, useDatasourceClient } from '@perses-dev/plugin-system'; -import { DatasourceSelector, QueryDefinition } from '@perses-dev/spec'; +import type { DatasourceSelector, QueryDefinition } from '@perses-dev/spec'; import { useQueryClient } from '@tanstack/react-query'; import BellOffIcon from 'mdi-material-ui/BellOff'; -import { ReactElement, useCallback, useMemo, useRef, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useMemo, useRef, useState } from 'react'; import { SilenceForm } from '../components/SilenceForm'; -import { AlertManagerClient, DEFAULT_ALERTMANAGER, PostableSilence } from '../model'; +import type { AlertManagerClient, PostableSilence } from '../model'; +import { DEFAULT_ALERTMANAGER } from '../model'; interface SilencesExplorerQueryParams { queries?: QueryDefinition[]; diff --git a/alertmanager/src/getPluginModule.ts b/alertmanager/src/getPluginModule.ts index 2c762611b..87533706e 100644 --- a/alertmanager/src/getPluginModule.ts +++ b/alertmanager/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; export function getPluginModule(): PluginModuleResource { const { name, version, perses } = packageJson; diff --git a/alertmanager/src/model/alertmanager-client.test.ts b/alertmanager/src/model/alertmanager-client.test.ts index 15c780701..31f90fe5c 100644 --- a/alertmanager/src/model/alertmanager-client.test.ts +++ b/alertmanager/src/model/alertmanager-client.test.ts @@ -11,6 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type * as ClientModule from '@perses-dev/client'; + import { createSilence, deleteSilence, getAlerts, getSilence, getSilences, getStatus } from './alertmanager-client'; type FetchResponse = { @@ -22,7 +24,7 @@ type FetchResponse = { const fetchMock = vi.hoisted(() => vi.fn()); vi.mock('@perses-dev/client', async (importOriginal) => ({ - ...(await importOriginal()), + ...(await importOriginal()), fetch: (...args: unknown[]): Promise => fetchMock(...args), })); diff --git a/alertmanager/src/model/alertmanager-client.ts b/alertmanager/src/model/alertmanager-client.ts index 68d52ece2..4dc529656 100644 --- a/alertmanager/src/model/alertmanager-client.ts +++ b/alertmanager/src/model/alertmanager-client.ts @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { fetch, RequestHeaders } from '@perses-dev/client'; -import { DatasourceClient } from '@perses-dev/plugin-system'; +import type { RequestHeaders } from '@perses-dev/client'; +import { fetch } from '@perses-dev/client'; +import type { DatasourceClient } from '@perses-dev/plugin-system'; -import { +import type { AlertManagerStatus, AlertsQueryParams, GettableAlert, diff --git a/alertmanager/src/model/alertmanager-selectors.ts b/alertmanager/src/model/alertmanager-selectors.ts index 49e30ca9e..007110ac7 100644 --- a/alertmanager/src/model/alertmanager-selectors.ts +++ b/alertmanager/src/model/alertmanager-selectors.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system'; -import { DatasourceSelector, QueryDefinition } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import { isVariableDatasource } from '@perses-dev/plugin-system'; +import type { DatasourceSelector, QueryDefinition } from '@perses-dev/spec'; export const ALERTMANAGER_DATASOURCE_KIND = 'AlertManagerDatasource' as const; diff --git a/alertmanager/src/plugins/AlertManagerDatasourceEditor.tsx b/alertmanager/src/plugins/AlertManagerDatasourceEditor.tsx index ff83ce0ea..34822118f 100644 --- a/alertmanager/src/plugins/AlertManagerDatasourceEditor.tsx +++ b/alertmanager/src/plugins/AlertManagerDatasourceEditor.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { AlertManagerDatasourceSpec } from './types'; +import type { AlertManagerDatasourceSpec } from './types'; export interface AlertManagerDatasourceEditorProps { value: AlertManagerDatasourceSpec; diff --git a/alertmanager/src/plugins/alert-table/AlertTable.ts b/alertmanager/src/plugins/alert-table/AlertTable.ts index b267de2c4..417d3651d 100644 --- a/alertmanager/src/plugins/alert-table/AlertTable.ts +++ b/alertmanager/src/plugins/alert-table/AlertTable.ts @@ -11,14 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { AlertTableOptions } from './alert-table-model'; +import type { AlertTableOptions } from './alert-table-model'; import { AlertTableColumnsEditor } from './AlertTableColumnsEditor'; import { AlertTableDeduplicationEditor } from './AlertTableDeduplicationEditor'; import { AlertTableLabelsEditor } from './AlertTableLabelsEditor'; import { AlertTableOptionsEditor } from './AlertTableOptionsEditor'; -import { AlertTablePanel, AlertTablePanelProps } from './AlertTablePanel'; +import type { AlertTablePanelProps } from './AlertTablePanel'; +import { AlertTablePanel } from './AlertTablePanel'; /** * Panel plugin for displaying Alert Manager alerts in a hierarchical table. diff --git a/alertmanager/src/plugins/alert-table/AlertTableColumnsEditor.tsx b/alertmanager/src/plugins/alert-table/AlertTableColumnsEditor.tsx index d59180666..be3da071f 100644 --- a/alertmanager/src/plugins/alert-table/AlertTableColumnsEditor.tsx +++ b/alertmanager/src/plugins/alert-table/AlertTableColumnsEditor.tsx @@ -12,12 +12,13 @@ // limitations under the License. import { TextField } from '@mui/material'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { ColumnsEditor } from '../../components/ColumnsEditor'; -import { AlertTableOptions, ColumnDefinition, ColumnSortMode } from './alert-table-model'; +import type { AlertTableOptions, ColumnDefinition, ColumnSortMode } from './alert-table-model'; const SORT_MODE_LABELS: Record = { alphabetical: 'Alphabetical', diff --git a/alertmanager/src/plugins/alert-table/AlertTableDeduplicationEditor.tsx b/alertmanager/src/plugins/alert-table/AlertTableDeduplicationEditor.tsx index b56a58beb..3f7caa7a2 100644 --- a/alertmanager/src/plugins/alert-table/AlertTableDeduplicationEditor.tsx +++ b/alertmanager/src/plugins/alert-table/AlertTableDeduplicationEditor.tsx @@ -13,11 +13,12 @@ import { Autocomplete, Chip, FormControl, InputLabel, MenuItem, Select, TextField, Typography } from '@mui/material'; import { OptionsEditorGroup } from '@perses-dev/components'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, SyntheticEvent, useCallback } from 'react'; +import type { ReactElement, SyntheticEvent } from 'react'; +import { useCallback } from 'react'; -import { AlertDeduplicationConfig, AlertTableOptions } from './alert-table-model'; +import type { AlertDeduplicationConfig, AlertTableOptions } from './alert-table-model'; const MODE_DESCRIPTIONS: Record = { none: 'No deduplication. All alerts from all datasources are shown as-is.', diff --git a/alertmanager/src/plugins/alert-table/AlertTableLabelsEditor.tsx b/alertmanager/src/plugins/alert-table/AlertTableLabelsEditor.tsx index 87f6e97ef..3ff5d39e1 100644 --- a/alertmanager/src/plugins/alert-table/AlertTableLabelsEditor.tsx +++ b/alertmanager/src/plugins/alert-table/AlertTableLabelsEditor.tsx @@ -27,13 +27,14 @@ import { Typography, } from '@mui/material'; import { OptionsEditorGroup } from '@perses-dev/components'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import DeleteIcon from 'mdi-material-ui/Delete'; import PlusIcon from 'mdi-material-ui/Plus'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; -import { AlertTableOptions, LabelColorMapping, LabelColorOverride } from './alert-table-model'; +import type { AlertTableOptions, LabelColorMapping, LabelColorOverride } from './alert-table-model'; const MODE_LABELS: Record = { auto: 'Auto (hash-derived colors)', diff --git a/alertmanager/src/plugins/alert-table/AlertTableOptionsEditor.tsx b/alertmanager/src/plugins/alert-table/AlertTableOptionsEditor.tsx index 84e0c1b8f..735fddee3 100644 --- a/alertmanager/src/plugins/alert-table/AlertTableOptionsEditor.tsx +++ b/alertmanager/src/plugins/alert-table/AlertTableOptionsEditor.tsx @@ -13,11 +13,13 @@ import { Autocomplete, Checkbox, Chip, FormControlLabel, TextField } from '@mui/material'; import { OptionsEditorGroup } from '@perses-dev/components'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ChangeEvent, ReactElement, SyntheticEvent, useCallback } from 'react'; +import type { ChangeEvent, ReactElement, SyntheticEvent } from 'react'; +import { useCallback } from 'react'; -import { AlertAction, AlertTableOptions, ALL_ALERT_ACTIONS } from './alert-table-model'; +import type { AlertAction, AlertTableOptions } from './alert-table-model'; +import { ALL_ALERT_ACTIONS } from './alert-table-model'; const ACTION_LABELS: Record = { silence: 'Silence alert', diff --git a/alertmanager/src/plugins/alert-table/AlertTablePanel.tsx b/alertmanager/src/plugins/alert-table/AlertTablePanel.tsx index fe71967b2..a1b3edd88 100644 --- a/alertmanager/src/plugins/alert-table/AlertTablePanel.tsx +++ b/alertmanager/src/plugins/alert-table/AlertTablePanel.tsx @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { SelectChangeEvent } from '@mui/material'; import { Box, Chip, @@ -20,7 +21,6 @@ import { InputLabel, MenuItem, Select, - SelectChangeEvent, Stack, Table, TableBody, @@ -34,14 +34,14 @@ import { Typography, } from '@mui/material'; import { useSnackbar } from '@perses-dev/components'; +import type { PanelProps } from '@perses-dev/plugin-system'; import { - PanelProps, parseVariables, replaceVariablesInString, useAllVariableValues, useDatasourceClient, } from '@perses-dev/plugin-system'; -import { Alert, AlertsData } from '@perses-dev/spec'; +import type { Alert, AlertsData } from '@perses-dev/spec'; import { useQueryClient } from '@tanstack/react-query'; import BellOffIcon from 'mdi-material-ui/BellOff'; import BookOpenIcon from 'mdi-material-ui/BookOpen'; @@ -50,31 +50,35 @@ import ChevronRightIcon from 'mdi-material-ui/ChevronRight'; import MagnifyIcon from 'mdi-material-ui/Magnify'; import UnfoldLessHorizontalIcon from 'mdi-material-ui/UnfoldLessHorizontal'; import UnfoldMoreHorizontalIcon from 'mdi-material-ui/UnfoldMoreHorizontal'; -import { ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { SilenceForm } from '../../components/SilenceForm'; import { StatusBadge } from '../../components/StatusBadge'; -import { AlertManagerClient, extractDatasourceSelector } from '../../model'; -import { PostableSilence } from '../../model/api-types'; -import { +import type { AlertManagerClient } from '../../model'; +import { extractDatasourceSelector } from '../../model'; +import type { PostableSilence } from '../../model/api-types'; +import type { AlertAction, AlertTableOptions, - ALL_ALERT_ACTIONS, ColumnDefinition, ColumnSortMode, + GroupSummary, + LabelColorMapping, +} from './alert-table-model'; +import { + ALL_ALERT_ACTIONS, deduplicateAlerts, extractLabelKeys, getGroupKey, getGroupSummary, - GroupSummary, - LabelColorMapping, } from './alert-table-model'; +import type { SortState } from './alert-table-sorting'; import { compareAlertsByColumn, compareGroupsByColumn, SORT_COL_ALERTNAME, SORT_COL_STATUS, - SortState, } from './alert-table-sorting'; import { getLabelColor } from './label-colors'; diff --git a/alertmanager/src/plugins/alert-table/alert-table-model.test.ts b/alertmanager/src/plugins/alert-table/alert-table-model.test.ts index 647f19673..8ec5e017d 100644 --- a/alertmanager/src/plugins/alert-table/alert-table-model.test.ts +++ b/alertmanager/src/plugins/alert-table/alert-table-model.test.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Alert } from '@perses-dev/spec'; +import type { Alert } from '@perses-dev/spec'; import { deduplicateAlerts, extractLabelKeys, getGroupKey, getGroupSummary } from './alert-table-model'; diff --git a/alertmanager/src/plugins/alert-table/alert-table-model.ts b/alertmanager/src/plugins/alert-table/alert-table-model.ts index 243d77db7..6020328c9 100644 --- a/alertmanager/src/plugins/alert-table/alert-table-model.ts +++ b/alertmanager/src/plugins/alert-table/alert-table-model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Alert } from '@perses-dev/spec'; +import type { Alert } from '@perses-dev/spec'; import { getEffectiveStatus, SORT_COL_ALERTNAME, SORT_COL_STATUS } from './alert-table-sorting'; diff --git a/alertmanager/src/plugins/alert-table/alert-table-sorting.test.ts b/alertmanager/src/plugins/alert-table/alert-table-sorting.test.ts index 26f3c2d45..059c09a37 100644 --- a/alertmanager/src/plugins/alert-table/alert-table-sorting.test.ts +++ b/alertmanager/src/plugins/alert-table/alert-table-sorting.test.ts @@ -11,14 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Alert } from '@perses-dev/spec'; +import type { Alert } from '@perses-dev/spec'; +import type { SortState } from './alert-table-sorting'; import { compareAlertsByColumn, compareGroupsByColumn, SORT_COL_ALERTNAME, SORT_COL_STATUS, - SortState, } from './alert-table-sorting'; const makeAlert = ( diff --git a/alertmanager/src/plugins/alert-table/alert-table-sorting.ts b/alertmanager/src/plugins/alert-table/alert-table-sorting.ts index d620e07c3..d03c6c339 100644 --- a/alertmanager/src/plugins/alert-table/alert-table-sorting.ts +++ b/alertmanager/src/plugins/alert-table/alert-table-sorting.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Alert } from '@perses-dev/spec'; +import type { Alert } from '@perses-dev/spec'; -import { ColumnSortMode, SortDirection } from './alert-table-model'; +import type { ColumnSortMode, SortDirection } from './alert-table-model'; import { getSeverityWeight, SEVERITY_ORDER } from './label-colors'; export const SORT_COL_STATUS = '__status__'; diff --git a/alertmanager/src/plugins/alert-table/label-colors.ts b/alertmanager/src/plugins/alert-table/label-colors.ts index 703e93bd4..106e5adb5 100644 --- a/alertmanager/src/plugins/alert-table/label-colors.ts +++ b/alertmanager/src/plugins/alert-table/label-colors.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LabelColorMapping } from './alert-table-model'; +import type { LabelColorMapping } from './alert-table-model'; const SEVERITY_LEVEL_COLORS: Record = { critical: '#d32f2f', diff --git a/alertmanager/src/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.ts b/alertmanager/src/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.ts index 6ee098be4..cd5b43dc9 100644 --- a/alertmanager/src/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.ts +++ b/alertmanager/src/plugins/alertmanager-alerts-query/AlertManagerAlertsQuery.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AlertsQueryPlugin, isVariableDatasource, parseVariables } from '@perses-dev/plugin-system'; +import type { AlertsQueryPlugin } from '@perses-dev/plugin-system'; +import { isVariableDatasource, parseVariables } from '@perses-dev/plugin-system'; -import { AlertManagerAlertsQuerySpec } from '../types'; +import type { AlertManagerAlertsQuerySpec } from '../types'; import { AlertManagerAlertsQueryEditor } from './AlertManagerAlertsQueryEditor'; import { getAlertsData } from './get-alerts-data'; diff --git a/alertmanager/src/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.tsx b/alertmanager/src/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.tsx index 2c3d4027f..e700865b9 100644 --- a/alertmanager/src/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.tsx +++ b/alertmanager/src/plugins/alertmanager-alerts-query/AlertManagerAlertsQueryEditor.tsx @@ -13,9 +13,11 @@ import { Checkbox, FormControl, FormControlLabel, Stack } from '@mui/material'; import { useId } from '@perses-dev/components'; -import { DatasourceSelect, DatasourceSelectProps } from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { LazyTextField } from '../../components/LazyTextField'; import { @@ -24,7 +26,7 @@ import { isAlertManagerDatasourceSelector, isDefaultAlertManagerSelector, } from '../../model'; -import { AlertManagerAlertsQuerySpec } from '../types'; +import type { AlertManagerAlertsQuerySpec } from '../types'; interface AlertManagerAlertsQueryEditorProps { value: AlertManagerAlertsQuerySpec; diff --git a/alertmanager/src/plugins/alertmanager-alerts-query/get-alerts-data.test.ts b/alertmanager/src/plugins/alertmanager-alerts-query/get-alerts-data.test.ts index c5929822c..511ef5822 100644 --- a/alertmanager/src/plugins/alertmanager-alerts-query/get-alerts-data.test.ts +++ b/alertmanager/src/plugins/alertmanager-alerts-query/get-alerts-data.test.ts @@ -11,11 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AlertsQueryContext } from '@perses-dev/plugin-system'; +import type { AlertsQueryContext } from '@perses-dev/plugin-system'; -import { AlertManagerClient, GettableAlert } from '../../model'; +import type { AlertManagerClient, GettableAlert } from '../../model'; import { AlertManagerDatasource } from '../alertmanager-datasource'; -import { AlertManagerAlertsQuerySpec } from '../types'; +import type { AlertManagerAlertsQuerySpec } from '../types'; import { getAlertsData } from './get-alerts-data'; const datasource = { directUrl: 'http://am.example' }; diff --git a/alertmanager/src/plugins/alertmanager-alerts-query/get-alerts-data.ts b/alertmanager/src/plugins/alertmanager-alerts-query/get-alerts-data.ts index 9b676f8e1..1dfa7cc6a 100644 --- a/alertmanager/src/plugins/alertmanager-alerts-query/get-alerts-data.ts +++ b/alertmanager/src/plugins/alertmanager-alerts-query/get-alerts-data.ts @@ -11,11 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AlertsQueryContext, datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; -import { Alert, AlertState, AlertsData, SuppressionRule } from '@perses-dev/spec'; +import type { AlertsQueryContext } from '@perses-dev/plugin-system'; +import { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; +import type { Alert, AlertState, AlertsData, SuppressionRule } from '@perses-dev/spec'; -import { ALERTMANAGER_DATASOURCE_KIND, AlertManagerClient, DEFAULT_ALERTMANAGER, GettableAlert } from '../../model'; -import { AlertManagerAlertsQuerySpec } from '../types'; +import type { AlertManagerClient, GettableAlert } from '../../model'; +import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER } from '../../model'; +import type { AlertManagerAlertsQuerySpec } from '../types'; /** * Map Alertmanager API alert state to the generic AlertState. diff --git a/alertmanager/src/plugins/alertmanager-datasource.tsx b/alertmanager/src/plugins/alertmanager-datasource.tsx index 1044659e1..1e97c41a1 100644 --- a/alertmanager/src/plugins/alertmanager-datasource.tsx +++ b/alertmanager/src/plugins/alertmanager-datasource.tsx @@ -11,19 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; -import { - AlertManagerClient, - getAlerts, - getSilences, - getSilence, - createSilence, - deleteSilence, - getStatus, -} from '../model'; +import type { AlertManagerClient } from '../model'; +import { getAlerts, getSilences, getSilence, createSilence, deleteSilence, getStatus } from '../model'; import { AlertManagerDatasourceEditor } from './AlertManagerDatasourceEditor'; -import { AlertManagerDatasourceSpec } from './types'; +import type { AlertManagerDatasourceSpec } from './types'; const createClient: DatasourcePlugin['createClient'] = ( spec, diff --git a/alertmanager/src/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.ts b/alertmanager/src/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.ts index 7ee086f32..19839ad31 100644 --- a/alertmanager/src/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.ts +++ b/alertmanager/src/plugins/alertmanager-silences-query/AlertManagerSilencesQuery.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { isVariableDatasource, parseVariables, SilencesQueryPlugin } from '@perses-dev/plugin-system'; +import type { SilencesQueryPlugin } from '@perses-dev/plugin-system'; +import { isVariableDatasource, parseVariables } from '@perses-dev/plugin-system'; -import { AlertManagerSilencesQuerySpec } from '../types'; +import type { AlertManagerSilencesQuerySpec } from '../types'; import { AlertManagerSilencesQueryEditor } from './AlertManagerSilencesQueryEditor'; import { getSilencesData } from './get-silences-data'; diff --git a/alertmanager/src/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.tsx b/alertmanager/src/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.tsx index 196a9ad56..6831ef6b0 100644 --- a/alertmanager/src/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.tsx +++ b/alertmanager/src/plugins/alertmanager-silences-query/AlertManagerSilencesQueryEditor.tsx @@ -13,9 +13,11 @@ import { FormControl, Stack } from '@mui/material'; import { useId } from '@perses-dev/components'; -import { DatasourceSelect, DatasourceSelectProps } from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { LazyTextField } from '../../components/LazyTextField'; import { @@ -24,7 +26,7 @@ import { isAlertManagerDatasourceSelector, isDefaultAlertManagerSelector, } from '../../model'; -import { AlertManagerSilencesQuerySpec } from '../types'; +import type { AlertManagerSilencesQuerySpec } from '../types'; interface AlertManagerSilencesQueryEditorProps { value: AlertManagerSilencesQuerySpec; diff --git a/alertmanager/src/plugins/alertmanager-silences-query/get-silences-data.test.ts b/alertmanager/src/plugins/alertmanager-silences-query/get-silences-data.test.ts index 8a4a37d0a..e886be754 100644 --- a/alertmanager/src/plugins/alertmanager-silences-query/get-silences-data.test.ts +++ b/alertmanager/src/plugins/alertmanager-silences-query/get-silences-data.test.ts @@ -11,11 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { SilencesQueryContext } from '@perses-dev/plugin-system'; +import type { SilencesQueryContext } from '@perses-dev/plugin-system'; -import { AlertManagerClient } from '../../model'; +import type { AlertManagerClient } from '../../model'; import { AlertManagerDatasource } from '../alertmanager-datasource'; -import { AlertManagerSilencesQuerySpec } from '../types'; +import type { AlertManagerSilencesQuerySpec } from '../types'; import { getSilencesData } from './get-silences-data'; const datasource = { directUrl: 'http://am.example' }; diff --git a/alertmanager/src/plugins/alertmanager-silences-query/get-silences-data.ts b/alertmanager/src/plugins/alertmanager-silences-query/get-silences-data.ts index a074c0e4d..ee7ca1a4f 100644 --- a/alertmanager/src/plugins/alertmanager-silences-query/get-silences-data.ts +++ b/alertmanager/src/plugins/alertmanager-silences-query/get-silences-data.ts @@ -11,11 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { datasourceSelectValueToSelector, replaceVariables, SilencesQueryContext } from '@perses-dev/plugin-system'; -import { Silence, SilencesData } from '@perses-dev/spec'; +import type { SilencesQueryContext } from '@perses-dev/plugin-system'; +import { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; +import type { Silence, SilencesData } from '@perses-dev/spec'; -import { ALERTMANAGER_DATASOURCE_KIND, AlertManagerClient, DEFAULT_ALERTMANAGER, GettableSilence } from '../../model'; -import { AlertManagerSilencesQuerySpec } from '../types'; +import type { AlertManagerClient, GettableSilence } from '../../model'; +import { ALERTMANAGER_DATASOURCE_KIND, DEFAULT_ALERTMANAGER } from '../../model'; +import type { AlertManagerSilencesQuerySpec } from '../types'; /** * Transform a GettableSilence from the Alertmanager API into our normalized Silence format. */ diff --git a/alertmanager/src/plugins/silence-table/SilenceTable.ts b/alertmanager/src/plugins/silence-table/SilenceTable.ts index e928d4686..67bcbfb4a 100644 --- a/alertmanager/src/plugins/silence-table/SilenceTable.ts +++ b/alertmanager/src/plugins/silence-table/SilenceTable.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { SilenceTableOptions } from './silence-table-model'; +import type { SilenceTableOptions } from './silence-table-model'; import { SilenceTableColumnsEditor } from './SilenceTableColumnsEditor'; import { SilenceTableOptionsEditor } from './SilenceTableOptionsEditor'; import { SilenceTablePanel } from './SilenceTablePanel'; diff --git a/alertmanager/src/plugins/silence-table/SilenceTableColumnsEditor.tsx b/alertmanager/src/plugins/silence-table/SilenceTableColumnsEditor.tsx index 70678604e..a528d8345 100644 --- a/alertmanager/src/plugins/silence-table/SilenceTableColumnsEditor.tsx +++ b/alertmanager/src/plugins/silence-table/SilenceTableColumnsEditor.tsx @@ -12,20 +12,19 @@ // limitations under the License. import { FormControl, InputLabel, MenuItem, Select } from '@mui/material'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { ColumnsEditor } from '../../components/ColumnsEditor'; -import { - DEFAULT_COLUMN_HEADERS, - DEFAULT_SILENCE_COLUMNS, +import type { SilenceColumnDefinition, SilenceColumnSortMode, SilenceFieldName, SilenceTableOptions, - inferSortMode, } from './silence-table-model'; +import { DEFAULT_COLUMN_HEADERS, DEFAULT_SILENCE_COLUMNS, inferSortMode } from './silence-table-model'; const DEFAULT_FIELD_NAMES = new Set(DEFAULT_SILENCE_COLUMNS.map((c) => c.name)); diff --git a/alertmanager/src/plugins/silence-table/SilenceTableOptionsEditor.tsx b/alertmanager/src/plugins/silence-table/SilenceTableOptionsEditor.tsx index fd12f8bca..5ab11437a 100644 --- a/alertmanager/src/plugins/silence-table/SilenceTableOptionsEditor.tsx +++ b/alertmanager/src/plugins/silence-table/SilenceTableOptionsEditor.tsx @@ -13,11 +13,13 @@ import { Checkbox, FormControlLabel } from '@mui/material'; import { OptionsEditorGroup } from '@perses-dev/components'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; -import { ALL_SILENCE_ACTIONS, SilenceAction, SilenceTableOptions } from './silence-table-model'; +import type { SilenceAction, SilenceTableOptions } from './silence-table-model'; +import { ALL_SILENCE_ACTIONS } from './silence-table-model'; const ACTION_LABELS: Record = { expire: 'Expire silence', diff --git a/alertmanager/src/plugins/silence-table/SilenceTablePanel.tsx b/alertmanager/src/plugins/silence-table/SilenceTablePanel.tsx index 9aa38cde2..6f1dd5283 100644 --- a/alertmanager/src/plugins/silence-table/SilenceTablePanel.tsx +++ b/alertmanager/src/plugins/silence-table/SilenceTablePanel.tsx @@ -28,28 +28,34 @@ import { Typography, } from '@mui/material'; import { Dialog, useSnackbar } from '@perses-dev/components'; -import { PanelProps, useDatasourceClient } from '@perses-dev/plugin-system'; -import { Silence, SilencesData } from '@perses-dev/spec'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import { useDatasourceClient } from '@perses-dev/plugin-system'; +import type { Silence, SilencesData } from '@perses-dev/spec'; import { useQueryClient } from '@tanstack/react-query'; import DeleteIcon from 'mdi-material-ui/Delete'; import MagnifyIcon from 'mdi-material-ui/Magnify'; -import { ReactElement, useCallback, useMemo, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useMemo, useState } from 'react'; import { MatchersList } from '../../components/MatchersList'; import { StatusBadge } from '../../components/StatusBadge'; -import { AlertManagerClient, extractDatasourceSelector } from '../../model'; -import { - ALL_SILENCE_ACTIONS, - DEFAULT_COLUMN_HEADERS, - DEFAULT_SILENCE_COLUMNS, +import type { AlertManagerClient } from '../../model'; +import { extractDatasourceSelector } from '../../model'; +import type { SilenceAction, SilenceColumnDefinition, SilenceFieldName, SilenceTableOptions, +} from './silence-table-model'; +import { + ALL_SILENCE_ACTIONS, + DEFAULT_COLUMN_HEADERS, + DEFAULT_SILENCE_COLUMNS, getSilenceDuration, inferSortMode, } from './silence-table-model'; -import { SilenceSortState, compareSilencesByColumn } from './silence-table-sorting'; +import type { SilenceSortState } from './silence-table-sorting'; +import { compareSilencesByColumn } from './silence-table-sorting'; export type SilenceTablePanelProps = PanelProps; diff --git a/alertmanager/src/plugins/silence-table/silence-table-model.test.ts b/alertmanager/src/plugins/silence-table/silence-table-model.test.ts index ff8e8447b..3349dd64f 100644 --- a/alertmanager/src/plugins/silence-table/silence-table-model.test.ts +++ b/alertmanager/src/plugins/silence-table/silence-table-model.test.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Silence } from '@perses-dev/spec'; +import type { Silence } from '@perses-dev/spec'; import { getSilenceDuration, getSilenceFieldValue, inferSortMode } from './silence-table-model'; diff --git a/alertmanager/src/plugins/silence-table/silence-table-model.ts b/alertmanager/src/plugins/silence-table/silence-table-model.ts index b8833dcf7..4b11c1c5b 100644 --- a/alertmanager/src/plugins/silence-table/silence-table-model.ts +++ b/alertmanager/src/plugins/silence-table/silence-table-model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Silence } from '@perses-dev/spec'; +import type { Silence } from '@perses-dev/spec'; export type SilenceAction = 'expire'; diff --git a/alertmanager/src/plugins/silence-table/silence-table-sorting.test.ts b/alertmanager/src/plugins/silence-table/silence-table-sorting.test.ts index 68c969ee3..e404a3060 100644 --- a/alertmanager/src/plugins/silence-table/silence-table-sorting.test.ts +++ b/alertmanager/src/plugins/silence-table/silence-table-sorting.test.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Silence } from '@perses-dev/spec'; +import type { Silence } from '@perses-dev/spec'; -import { compareSilencesByColumn, SilenceSortState } from './silence-table-sorting'; +import type { SilenceSortState } from './silence-table-sorting'; +import { compareSilencesByColumn } from './silence-table-sorting'; const makeSilence = (overrides: Partial = {}): Silence => ({ id: 'silence-1', diff --git a/alertmanager/src/plugins/silence-table/silence-table-sorting.ts b/alertmanager/src/plugins/silence-table/silence-table-sorting.ts index 7ccaf1a9f..76fc57e06 100644 --- a/alertmanager/src/plugins/silence-table/silence-table-sorting.ts +++ b/alertmanager/src/plugins/silence-table/silence-table-sorting.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Silence } from '@perses-dev/spec'; +import type { Silence } from '@perses-dev/spec'; -import { SilenceColumnSortMode, SilenceFieldName, SortDirection, getSilenceFieldValue } from './silence-table-model'; +import type { SilenceColumnSortMode, SilenceFieldName, SortDirection } from './silence-table-model'; +import { getSilenceFieldValue } from './silence-table-model'; export interface SilenceSortState { fieldName: SilenceFieldName; diff --git a/alertmanager/src/plugins/types.ts b/alertmanager/src/plugins/types.ts index 5820b7fa6..0f3056204 100644 --- a/alertmanager/src/plugins/types.ts +++ b/alertmanager/src/plugins/types.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue } from '@perses-dev/plugin-system'; -import { HTTPProxy } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import type { HTTPProxy } from '@perses-dev/spec'; -import { AlertManagerDatasourceSelector } from '../model/alertmanager-selectors'; +import type { AlertManagerDatasourceSelector } from '../model/alertmanager-selectors'; /** * Datasource spec for the Alert Manager datasource plugin. diff --git a/alertmanager/tsconfig.build.json b/alertmanager/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/alertmanager/tsconfig.build.json +++ b/alertmanager/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/alertmanager/tsconfig.json b/alertmanager/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/alertmanager/tsconfig.json +++ b/alertmanager/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/alertmanager/vitest.config.ts b/alertmanager/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/alertmanager/vitest.config.ts +++ b/alertmanager/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/barchart/package.json b/barchart/package.json index af51fbd39..7a3509756 100644 --- a/barchart/package.json +++ b/barchart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,8 +29,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/barchart/src/BarChart.ts b/barchart/src/BarChart.ts index e2b46880c..5cc0649f9 100644 --- a/barchart/src/BarChart.ts +++ b/barchart/src/BarChart.ts @@ -11,12 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { createInitialBarChartOptions, BarChartOptions } from './bar-chart-model'; +import type { BarChartOptions } from './bar-chart-model'; +import { createInitialBarChartOptions } from './bar-chart-model'; import { BarChartExportAction } from './BarChartExportAction'; import { BarChartOptionsEditorSettings } from './BarChartOptionsEditorSettings'; -import { BarChartPanel, BarChartPanelProps } from './BarChartPanel'; +import type { BarChartPanelProps } from './BarChartPanel'; +import { BarChartPanel } from './BarChartPanel'; /** * The core BarChart panel plugin for Perses. diff --git a/barchart/src/BarChartBase.tsx b/barchart/src/BarChartBase.tsx index 2e4ebd8c0..e14d49e1f 100644 --- a/barchart/src/BarChartBase.tsx +++ b/barchart/src/BarChartBase.tsx @@ -12,21 +12,17 @@ // limitations under the License. import { Box } from '@mui/material'; -import { - EChart, - FormatOptions, - ModeOption, - formatValue, - getFormattedAxis, - useChartsTheme, -} from '@perses-dev/components'; +import type { FormatOptions, ModeOption } from '@perses-dev/components'; +import { EChart, formatValue, getFormattedAxis, useChartsTheme } from '@perses-dev/components'; import { BarChart as EChartsBarChart } from 'echarts/charts'; import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent, LegendComponent } from 'echarts/components'; -import { use as registerECharts, EChartsCoreOption } from 'echarts/core'; +import type { EChartsCoreOption } from 'echarts/core'; +import { use as registerECharts } from 'echarts/core'; import { CanvasRenderer } from 'echarts/renderers'; -import { ReactElement, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { ColorOverride } from './bar-chart-model'; +import type { ColorOverride } from './bar-chart-model'; import { getOverrideColor } from './utils'; registerECharts([ diff --git a/barchart/src/BarChartExportAction.tsx b/barchart/src/BarChartExportAction.tsx index b9f406c0a..27cd7a4d7 100644 --- a/barchart/src/BarChartExportAction.tsx +++ b/barchart/src/BarChartExportAction.tsx @@ -17,7 +17,7 @@ import { exportDataAsCSV, extractExportableData, isExportableData, sanitizeFilen import DownloadIcon from 'mdi-material-ui/Download'; import React, { useCallback, useMemo } from 'react'; -import { BarChartPanelProps } from './BarChartPanel'; +import type { BarChartPanelProps } from './BarChartPanel'; export const BarChartExportAction: React.FC = ({ queryResults, definition }) => { const exportableData = useMemo(() => { diff --git a/barchart/src/BarChartOptionsEditorSettings.test.tsx b/barchart/src/BarChartOptionsEditorSettings.test.tsx index 85aee1c0e..958192992 100644 --- a/barchart/src/BarChartOptionsEditorSettings.test.tsx +++ b/barchart/src/BarChartOptionsEditorSettings.test.tsx @@ -15,7 +15,7 @@ import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { BarChartOptions } from './bar-chart-model'; +import type { BarChartOptions } from './bar-chart-model'; import { BarChartOptionsEditorSettings } from './BarChartOptionsEditorSettings'; describe('BarChartOptionsEditorSettings', () => { diff --git a/barchart/src/BarChartOptionsEditorSettings.tsx b/barchart/src/BarChartOptionsEditorSettings.tsx index 8371a5328..495d9e415 100644 --- a/barchart/src/BarChartOptionsEditorSettings.tsx +++ b/barchart/src/BarChartOptionsEditorSettings.tsx @@ -23,39 +23,36 @@ import { ToggleButton, ToggleButtonGroup, } from '@mui/material'; -import { - FormatControls, +import type { FormatControlsProps, FormatOptions, + ModeOption, + ModeSelectorProps, + SortOption, + SortSelectorProps, +} from '@perses-dev/components'; +import { + FormatControls, isPercentUnit, isUnitWithShortValues, - ModeOption, ModeSelector, - ModeSelectorProps, OptionsColorPicker, OptionsEditorColumn, OptionsEditorGrid, OptionsEditorGroup, - SortOption, SortSelector, - SortSelectorProps, } from '@perses-dev/components'; -import { - CalculationSelector, - CalculationSelectorProps, - CalculationType, - DEFAULT_CALCULATION, -} from '@perses-dev/plugin-system'; +import type { CalculationSelectorProps, CalculationType } from '@perses-dev/plugin-system'; +import { CalculationSelector, DEFAULT_CALCULATION } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import merge from 'lodash/merge'; import omit from 'lodash/omit'; import DeleteIcon from 'mdi-material-ui/DeleteOutline'; import AddIcon from 'mdi-material-ui/Plus'; -import { MouseEventHandler, ReactElement } from 'react'; +import type { MouseEventHandler, ReactElement } from 'react'; +import type { BarChartOptions, BarChartOptionsEditorProps } from './bar-chart-model'; import { - BarChartOptions, - BarChartOptionsEditorProps, DEFAULT_FORMAT, DEFAULT_MODE, DEFAULT_ORIENTATION, diff --git a/barchart/src/BarChartPanel.tsx b/barchart/src/BarChartPanel.tsx index c245b258c..bb725dedc 100644 --- a/barchart/src/BarChartPanel.tsx +++ b/barchart/src/BarChartPanel.tsx @@ -13,12 +13,15 @@ import { Box } from '@mui/material'; import { useChartsTheme } from '@perses-dev/components'; -import { CalculationsMap, CalculationType, PanelProps } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; -import { ReactElement, useMemo } from 'react'; - -import { BarChartOptions } from './bar-chart-model'; -import { BarChartBase, BarChartData, StackedBarChartData, StackedBarChartSeries } from './BarChartBase'; +import type { CalculationType, PanelProps } from '@perses-dev/plugin-system'; +import { CalculationsMap } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; + +import type { BarChartOptions } from './bar-chart-model'; +import type { BarChartData, StackedBarChartData, StackedBarChartSeries } from './BarChartBase'; +import { BarChartBase } from './BarChartBase'; import { calculatePercentages, sortSeriesData } from './utils'; export type BarChartPanelProps = PanelProps; diff --git a/barchart/src/bar-chart-model.ts b/barchart/src/bar-chart-model.ts index aa4f85e28..8eb7d4d6f 100644 --- a/barchart/src/bar-chart-model.ts +++ b/barchart/src/bar-chart-model.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions, ModeOption, SortOption } from '@perses-dev/components'; -import { CalculationType, DEFAULT_CALCULATION, OptionsEditorProps } from '@perses-dev/plugin-system'; -import { Definition } from '@perses-dev/spec'; +import type { FormatOptions, ModeOption, SortOption } from '@perses-dev/components'; +import type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DEFAULT_CALCULATION } from '@perses-dev/plugin-system'; +import type { Definition } from '@perses-dev/spec'; export const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal', shortValues: true }; export const DEFAULT_SORT: SortOption = 'desc'; diff --git a/barchart/src/getPluginModule.ts b/barchart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/barchart/src/getPluginModule.ts +++ b/barchart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/barchart/src/tresholds.ts b/barchart/src/tresholds.ts index afe2d9d52..ec450747b 100644 --- a/barchart/src/tresholds.ts +++ b/barchart/src/tresholds.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components'; +import type { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components'; import zip from 'lodash/zip'; export type GaugeColorStop = [number, string]; diff --git a/barchart/src/utils.test.ts b/barchart/src/utils.test.ts index 40febe5ed..4d2eae4c7 100644 --- a/barchart/src/utils.test.ts +++ b/barchart/src/utils.test.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { BarChartData } from './BarChartBase'; +import type { BarChartData } from './BarChartBase'; import { calculatePercentages, getOverrideColor, sortSeriesData } from './utils'; const MOCK_DATA: BarChartData[] = [ diff --git a/barchart/src/utils.ts b/barchart/src/utils.ts index 7011c64fc..33656a64d 100644 --- a/barchart/src/utils.ts +++ b/barchart/src/utils.ts @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { SortOption } from '@perses-dev/components'; +import type { SortOption } from '@perses-dev/components'; -import { ColorOverride, DEFAULT_SORT } from './bar-chart-model'; -import { BarChartData } from './BarChartBase'; +import type { ColorOverride } from './bar-chart-model'; +import { DEFAULT_SORT } from './bar-chart-model'; +import type { BarChartData } from './BarChartBase'; export function calculatePercentages(data: BarChartData[]): Array<{ label: string; value: number }> { const sum = data.reduce((accumulator, { value }) => accumulator + (value ?? 0), 0); diff --git a/barchart/tsconfig.build.json b/barchart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/barchart/tsconfig.build.json +++ b/barchart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/barchart/tsconfig.json b/barchart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/barchart/tsconfig.json +++ b/barchart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/barchart/vitest.config.ts b/barchart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/barchart/vitest.config.ts +++ b/barchart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/clickhouse/package.json b/clickhouse/package.json index f14a267b7..d58d6a8a2 100644 --- a/clickhouse/package.json +++ b/clickhouse/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,11 +29,11 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/client": "^0.55.0-beta.6", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/clickhouse/src/components/ClickQLEditor.tsx b/clickhouse/src/components/ClickQLEditor.tsx index de08f5bfa..8da728ae3 100644 --- a/clickhouse/src/components/ClickQLEditor.tsx +++ b/clickhouse/src/components/ClickQLEditor.tsx @@ -13,8 +13,9 @@ import { EditorView } from '@codemirror/view'; import { useTheme, InputLabel, Stack } from '@mui/material'; -import CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror'; -import { ReactElement } from 'react'; +import type { ReactCodeMirrorProps } from '@uiw/react-codemirror'; +import CodeMirror from '@uiw/react-codemirror'; +import type { ReactElement } from 'react'; export type ClickQLEditorProps = Omit; diff --git a/clickhouse/src/datasources/click-house-datasource/ClickHouseDatasource.tsx b/clickhouse/src/datasources/click-house-datasource/ClickHouseDatasource.tsx index 0a6ef9a96..5cf41e0a2 100644 --- a/clickhouse/src/datasources/click-house-datasource/ClickHouseDatasource.tsx +++ b/clickhouse/src/datasources/click-house-datasource/ClickHouseDatasource.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; import { query } from '../../model/click-house-client'; -import { ClickHouseDatasourceSpec, ClickHouseDatasourceClient } from './click-house-datasource-types'; +import type { ClickHouseDatasourceSpec, ClickHouseDatasourceClient } from './click-house-datasource-types'; import { ClickHouseDatasourceEditor } from './ClickHouseDatasourceEditor'; const createClient: DatasourcePlugin['createClient'] = ( diff --git a/clickhouse/src/datasources/click-house-datasource/ClickHouseDatasourceEditor.tsx b/clickhouse/src/datasources/click-house-datasource/ClickHouseDatasourceEditor.tsx index dc8b5e65e..280894581 100644 --- a/clickhouse/src/datasources/click-house-datasource/ClickHouseDatasourceEditor.tsx +++ b/clickhouse/src/datasources/click-house-datasource/ClickHouseDatasourceEditor.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { ClickHouseDatasourceSpec } from './click-house-datasource-types'; +import type { ClickHouseDatasourceSpec } from './click-house-datasource-types'; export interface ClickHouseDatasourceEditorProps { value: ClickHouseDatasourceSpec; diff --git a/clickhouse/src/datasources/click-house-datasource/click-house-datasource-types.ts b/clickhouse/src/datasources/click-house-datasource/click-house-datasource-types.ts index 782adbafd..7145f8771 100644 --- a/clickhouse/src/datasources/click-house-datasource/click-house-datasource-types.ts +++ b/clickhouse/src/datasources/click-house-datasource/click-house-datasource-types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { RequestHeaders } from '@perses-dev/client'; -import { DatasourceClient } from '@perses-dev/plugin-system'; -import { HTTPProxy } from '@perses-dev/spec'; +import type { RequestHeaders } from '@perses-dev/client'; +import type { DatasourceClient } from '@perses-dev/plugin-system'; +import type { HTTPProxy } from '@perses-dev/spec'; export interface ClickHouseDatasourceSpec { directUrl?: string; diff --git a/clickhouse/src/getPluginModule.ts b/clickhouse/src/getPluginModule.ts index 515511f2f..6dee4f848 100644 --- a/clickhouse/src/getPluginModule.ts +++ b/clickhouse/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/clickhouse/src/model/click-house-client.ts b/clickhouse/src/model/click-house-client.ts index 2576575f6..23e7bcf1d 100644 --- a/clickhouse/src/model/click-house-client.ts +++ b/clickhouse/src/model/click-house-client.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { RequestHeaders } from '@perses-dev/client'; +import type { RequestHeaders } from '@perses-dev/client'; export interface ClickHouseQueryParams { query: string; diff --git a/clickhouse/src/model/click-house-data-types.ts b/clickhouse/src/model/click-house-data-types.ts index 8a501cfdd..0827850aa 100644 --- a/clickhouse/src/model/click-house-data-types.ts +++ b/clickhouse/src/model/click-house-data-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogData, TimeSeriesData } from '@perses-dev/spec'; +import type { LogData, TimeSeriesData } from '@perses-dev/spec'; export interface ClickHouseTimeSeriesData extends TimeSeriesData { logs?: LogData; diff --git a/clickhouse/src/queries/click-house-log-query/ClickHouseLogQuery.tsx b/clickhouse/src/queries/click-house-log-query/ClickHouseLogQuery.tsx index 6837afe0b..b5ee6ad4f 100644 --- a/clickhouse/src/queries/click-house-log-query/ClickHouseLogQuery.tsx +++ b/clickhouse/src/queries/click-house-log-query/ClickHouseLogQuery.tsx @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { parseVariables, LogQueryPlugin } from '@perses-dev/plugin-system'; +import type { LogQueryPlugin } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; -import { ClickHouseLogQuerySpec } from './click-house-log-query-types'; +import type { ClickHouseLogQuerySpec } from './click-house-log-query-types'; import { ClickHouseLogQueryEditor } from './ClickHouseLogQueryEditor'; import { getClickHouseLogData } from './get-click-house-log-data'; diff --git a/clickhouse/src/queries/click-house-log-query/ClickHouseLogQueryEditor.tsx b/clickhouse/src/queries/click-house-log-query/ClickHouseLogQueryEditor.tsx index 76f87a03c..936003d15 100644 --- a/clickhouse/src/queries/click-house-log-query/ClickHouseLogQueryEditor.tsx +++ b/clickhouse/src/queries/click-house-log-query/ClickHouseLogQueryEditor.tsx @@ -13,20 +13,17 @@ import { Stack } from '@mui/material'; import { createModEnterHandler } from '@perses-dev/dashboards'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { ClickQLEditor } from '../../components'; import { queryExample } from '../../components/constants'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; import { useQueryState } from '../query-editor-model'; -import { ClickHouseLogQuerySpec } from './click-house-log-query-types'; +import type { ClickHouseLogQuerySpec } from './click-house-log-query-types'; type ClickHouseQueryEditorProps = OptionsEditorProps; diff --git a/clickhouse/src/queries/click-house-log-query/click-house-log-query-types.test.ts b/clickhouse/src/queries/click-house-log-query/click-house-log-query-types.test.ts index c0e8329d9..33b08dbfb 100644 --- a/clickhouse/src/queries/click-house-log-query/click-house-log-query-types.test.ts +++ b/clickhouse/src/queries/click-house-log-query/click-house-log-query-types.test.ts @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogQueryContext } from '@perses-dev/plugin-system'; +import type { LogQueryContext } from '@perses-dev/plugin-system'; import type { Mock } from 'vitest'; -import { ClickHouseDatasource, ClickHouseDatasourceSpec } from '../../datasources/click-house-datasource'; -import { ClickHouseQueryResponse } from '../../model/click-house-client'; +import type { ClickHouseDatasourceSpec } from '../../datasources/click-house-datasource'; +import { ClickHouseDatasource } from '../../datasources/click-house-datasource'; +import type { ClickHouseQueryResponse } from '../../model/click-house-client'; import { ClickHouseLogQuery } from './ClickHouseLogQuery'; const datasource: ClickHouseDatasourceSpec = { diff --git a/clickhouse/src/queries/click-house-log-query/click-house-log-query-types.ts b/clickhouse/src/queries/click-house-log-query/click-house-log-query-types.ts index 56621f585..a7cc7aec3 100644 --- a/clickhouse/src/queries/click-house-log-query/click-house-log-query-types.ts +++ b/clickhouse/src/queries/click-house-log-query/click-house-log-query-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export interface ClickHouseLogQuerySpec { query: string; diff --git a/clickhouse/src/queries/click-house-log-query/get-click-house-log-data.ts b/clickhouse/src/queries/click-house-log-query/get-click-house-log-data.ts index 1ccd96889..ea81c40bf 100644 --- a/clickhouse/src/queries/click-house-log-query/get-click-house-log-data.ts +++ b/clickhouse/src/queries/click-house-log-query/get-click-house-log-data.ts @@ -11,17 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { replaceVariables, LogQueryPlugin } from '@perses-dev/plugin-system'; -import { LogData, LogEntry } from '@perses-dev/spec'; - -import { - ClickHouseClient, - ClickHouseQueryResponse, - formatClickHouseDateTime, - replaceTimeRangePlaceholders, -} from '../../model/click-house-client'; +import type { LogQueryPlugin } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { LogData, LogEntry } from '@perses-dev/spec'; + +import type { ClickHouseClient, ClickHouseQueryResponse } from '../../model/click-house-client'; +import { formatClickHouseDateTime, replaceTimeRangePlaceholders } from '../../model/click-house-client'; import { DEFAULT_DATASOURCE } from '../constants'; -import { ClickHouseLogQuerySpec } from './click-house-log-query-types'; +import type { ClickHouseLogQuerySpec } from './click-house-log-query-types'; function flattenObject( obj: Record, diff --git a/clickhouse/src/queries/click-house-time-series-query/ClickHouseQuery.tsx b/clickhouse/src/queries/click-house-time-series-query/ClickHouseQuery.tsx index 8a9fee3b2..02cf9e428 100644 --- a/clickhouse/src/queries/click-house-time-series-query/ClickHouseQuery.tsx +++ b/clickhouse/src/queries/click-house-time-series-query/ClickHouseQuery.tsx @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, parseVariables } from '@perses-dev/plugin-system'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; -import { ClickHouseTimeSeriesQuerySpec } from './click-house-query-types'; +import type { ClickHouseTimeSeriesQuerySpec } from './click-house-query-types'; import { ClickHouseTimeSeriesQueryEditor } from './ClickHouseQueryEditor'; import { getTimeSeriesData } from './get-click-house-data'; diff --git a/clickhouse/src/queries/click-house-time-series-query/ClickHouseQueryEditor.tsx b/clickhouse/src/queries/click-house-time-series-query/ClickHouseQueryEditor.tsx index dbf7e3ff0..1ccd43a10 100644 --- a/clickhouse/src/queries/click-house-time-series-query/ClickHouseQueryEditor.tsx +++ b/clickhouse/src/queries/click-house-time-series-query/ClickHouseQueryEditor.tsx @@ -13,20 +13,17 @@ import { Stack } from '@mui/material'; import { createModEnterHandler } from '@perses-dev/dashboards'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { ClickQLEditor } from '../../components'; import { queryExample } from '../../components/constants'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; import { useQueryState } from '../query-editor-model'; -import { ClickHouseTimeSeriesQuerySpec } from './click-house-query-types'; +import type { ClickHouseTimeSeriesQuerySpec } from './click-house-query-types'; type ClickHouseTimeSeriesQueryEditorProps = OptionsEditorProps; diff --git a/clickhouse/src/queries/click-house-time-series-query/click-house-query-types.test.ts b/clickhouse/src/queries/click-house-time-series-query/click-house-query-types.test.ts index 8778cc4bb..963e0e957 100644 --- a/clickhouse/src/queries/click-house-time-series-query/click-house-query-types.test.ts +++ b/clickhouse/src/queries/click-house-time-series-query/click-house-query-types.test.ts @@ -15,12 +15,13 @@ vi.mock('echarts/core'); -import { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock } from 'vitest'; -import { ClickHouseDatasource, ClickHouseDatasourceSpec } from '../../datasources'; -import { ClickHouseQueryResponse } from '../../model/click-house-client'; +import type { ClickHouseDatasourceSpec } from '../../datasources'; +import { ClickHouseDatasource } from '../../datasources'; +import type { ClickHouseQueryResponse } from '../../model/click-house-client'; import { ClickHouseTimeSeriesQuery } from './ClickHouseQuery'; const datasource: ClickHouseDatasourceSpec = { diff --git a/clickhouse/src/queries/click-house-time-series-query/click-house-query-types.ts b/clickhouse/src/queries/click-house-time-series-query/click-house-query-types.ts index 2e74bd7b1..0911df27f 100644 --- a/clickhouse/src/queries/click-house-time-series-query/click-house-query-types.ts +++ b/clickhouse/src/queries/click-house-time-series-query/click-house-query-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export interface ClickHouseTimeSeriesQuerySpec { query: string; diff --git a/clickhouse/src/queries/click-house-time-series-query/get-click-house-data.ts b/clickhouse/src/queries/click-house-time-series-query/get-click-house-data.ts index 8a54695e0..3b0387d92 100644 --- a/clickhouse/src/queries/click-house-time-series-query/get-click-house-data.ts +++ b/clickhouse/src/queries/click-house-time-series-query/get-click-house-data.ts @@ -11,18 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, replaceVariables } from '@perses-dev/plugin-system'; -import { TimeSeries } from '@perses-dev/spec'; - -import { - ClickHouseClient, - ClickHouseQueryResponse, - formatClickHouseDateTime, - replaceTimeRangePlaceholders, -} from '../../model/click-house-client'; -import { TimeSeriesEntry } from '../../model/click-house-data-types'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { TimeSeries } from '@perses-dev/spec'; + +import type { ClickHouseClient, ClickHouseQueryResponse } from '../../model/click-house-client'; +import { formatClickHouseDateTime, replaceTimeRangePlaceholders } from '../../model/click-house-client'; +import type { TimeSeriesEntry } from '../../model/click-house-data-types'; import { DEFAULT_DATASOURCE } from '../constants'; -import { ClickHouseTimeSeriesQuerySpec, DatasourceQueryResponse } from './click-house-query-types'; +import type { ClickHouseTimeSeriesQuerySpec, DatasourceQueryResponse } from './click-house-query-types'; const DEFAULT_STEP_MS = 30 * 1000; diff --git a/clickhouse/src/queries/query-editor-model.ts b/clickhouse/src/queries/query-editor-model.ts index 4305c3313..5609beda8 100644 --- a/clickhouse/src/queries/query-editor-model.ts +++ b/clickhouse/src/queries/query-editor-model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import { useState } from 'react'; diff --git a/clickhouse/tsconfig.build.json b/clickhouse/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/clickhouse/tsconfig.build.json +++ b/clickhouse/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/clickhouse/tsconfig.json b/clickhouse/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/clickhouse/tsconfig.json +++ b/clickhouse/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/clickhouse/vitest.config.ts b/clickhouse/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/clickhouse/vitest.config.ts +++ b/clickhouse/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/datasourcevariable/package.json b/datasourcevariable/package.json index 575426fa5..fa5753ea2 100644 --- a/datasourcevariable/package.json +++ b/datasourcevariable/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,7 +29,7 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", + "@perses-dev/plugin-system": "^0.55.0-beta.6", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/datasourcevariable/src/DatasourceVariable.tsx b/datasourcevariable/src/DatasourceVariable.tsx index 27a0971b8..af531e818 100644 --- a/datasourcevariable/src/DatasourceVariable.tsx +++ b/datasourcevariable/src/DatasourceVariable.tsx @@ -12,8 +12,10 @@ // limitations under the License. import { Autocomplete, TextField } from '@mui/material'; -import { OptionsEditorProps, useListPluginMetadata, VariablePlugin } from '@perses-dev/plugin-system'; -import { ReactElement, useEffect, useMemo } from 'react'; +import type { OptionsEditorProps, VariablePlugin } from '@perses-dev/plugin-system'; +import { useListPluginMetadata } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; +import { useEffect, useMemo } from 'react'; type StaticListVariableOptions = { datasourcePluginKind: string; diff --git a/datasourcevariable/src/getPluginModule.ts b/datasourcevariable/src/getPluginModule.ts index 515511f2f..6dee4f848 100644 --- a/datasourcevariable/src/getPluginModule.ts +++ b/datasourcevariable/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/datasourcevariable/tsconfig.build.json b/datasourcevariable/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/datasourcevariable/tsconfig.build.json +++ b/datasourcevariable/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/datasourcevariable/tsconfig.json b/datasourcevariable/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/datasourcevariable/tsconfig.json +++ b/datasourcevariable/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/datasourcevariable/vitest.config.ts b/datasourcevariable/vitest.config.ts index d6b9f6786..c64d8cc04 100644 --- a/datasourcevariable/vitest.config.ts +++ b/datasourcevariable/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, passWithNoTests: true, }); diff --git a/e2e/package.json b/e2e/package.json index 151fdc1c9..a65a4619f 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -11,6 +11,7 @@ "bugs": { "url": "https://github.com/perses/plugins/issues" }, + "type": "module", "scripts": { "test:ci": "npx playwright test --workers=1 --reporter=github,list", "test:install": "npx playwright install --with-deps", @@ -20,6 +21,6 @@ }, "devDependencies": { "@playwright/test": "^1.58.2", - "@types/node": "^25.2.3" + "@types/node": "^24.0.0" } } diff --git a/flamechart/package.json b/flamechart/package.json index d3f16942b..5078ca2b1 100644 --- a/flamechart/package.json +++ b/flamechart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "devDependencies": { @@ -32,8 +32,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-table": "^8.20.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/flamechart/src/FlameChart.ts b/flamechart/src/FlameChart.ts index b443a943b..be82488c6 100644 --- a/flamechart/src/FlameChart.ts +++ b/flamechart/src/FlameChart.ts @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { FlameChartPanel, FlameChartPanelProps, FlameChartOptionsEditorSettings } from './components'; -import { createInitialFlameChartOptions, FlameChartOptions } from './flame-chart-model'; +import type { FlameChartPanelProps } from './components'; +import { FlameChartPanel, FlameChartOptionsEditorSettings } from './components'; +import type { FlameChartOptions } from './flame-chart-model'; +import { createInitialFlameChartOptions } from './flame-chart-model'; /** * The core FlameChart panel plugin for Perses. diff --git a/flamechart/src/components/CustomBreadcrumb.tsx b/flamechart/src/components/CustomBreadcrumb.tsx index c04280cfe..4f0b552f5 100644 --- a/flamechart/src/components/CustomBreadcrumb.tsx +++ b/flamechart/src/components/CustomBreadcrumb.tsx @@ -18,7 +18,7 @@ import { formatValue } from '@perses-dev/components'; import ChevronRightIcon from 'mdi-material-ui/ChevronRight'; import CloseIcon from 'mdi-material-ui/Close'; import EyeIcon from 'mdi-material-ui/EyeOutline'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; export interface CustomBreadcrumbProps { totalValue: string; diff --git a/flamechart/src/components/FlameChart.tsx b/flamechart/src/components/FlameChart.tsx index 8a69679d9..5e77a3138 100644 --- a/flamechart/src/components/FlameChart.tsx +++ b/flamechart/src/components/FlameChart.tsx @@ -12,21 +12,23 @@ // limitations under the License. import { Stack, Box, Menu, MenuItem, Divider, useTheme } from '@mui/material'; -import { useChartsTheme, EChart, MouseEventsParameters } from '@perses-dev/components'; -import { ProfileData } from '@perses-dev/spec'; -import { +import type { MouseEventsParameters } from '@perses-dev/components'; +import { useChartsTheme, EChart } from '@perses-dev/components'; +import type { ProfileData } from '@perses-dev/spec'; +import type { CustomSeriesRenderItem, CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams, CustomSeriesRenderItemReturn, } from 'echarts'; -import { EChartsCoreOption } from 'echarts/core'; +import type { EChartsCoreOption } from 'echarts/core'; import ContentCopyIcon from 'mdi-material-ui/ContentCopy'; import EyeIcon from 'mdi-material-ui/EyeOutline'; import RefreshIcon from 'mdi-material-ui/Refresh'; -import { ReactElement, useState, useMemo, MouseEvent } from 'react'; +import type { ReactElement, MouseEvent } from 'react'; +import { useState, useMemo } from 'react'; -import { FlameChartSample as Sample } from '../utils/data-model'; +import type { FlameChartSample as Sample } from '../utils/data-model'; import { buildSamples, findTotalSampleByName } from '../utils/data-transform'; import { generateTooltip } from '../utils/tooltip'; import { CustomBreadcrumb } from './CustomBreadcrumb'; diff --git a/flamechart/src/components/FlameChartOptionsEditorSettings.tsx b/flamechart/src/components/FlameChartOptionsEditorSettings.tsx index 3f06f687b..cd333e4cf 100644 --- a/flamechart/src/components/FlameChartOptionsEditorSettings.tsx +++ b/flamechart/src/components/FlameChartOptionsEditorSettings.tsx @@ -18,9 +18,9 @@ import { OptionsEditorColumn, OptionsEditorControl, } from '@perses-dev/components'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { FlameChartOptionsEditorProps } from '../flame-chart-model'; +import type { FlameChartOptionsEditorProps } from '../flame-chart-model'; import { usePaletteState, useShowSettingsState, diff --git a/flamechart/src/components/FlameChartPanel.tsx b/flamechart/src/components/FlameChartPanel.tsx index 0db2ddd58..6ac9995b2 100644 --- a/flamechart/src/components/FlameChartPanel.tsx +++ b/flamechart/src/components/FlameChartPanel.tsx @@ -11,14 +11,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Stack, Typography, SxProps, useMediaQuery, useTheme } from '@mui/material'; +import type { SxProps } from '@mui/material'; +import { Stack, Typography, useMediaQuery, useTheme } from '@mui/material'; import { useChartsTheme } from '@perses-dev/components'; -import { PanelProps } from '@perses-dev/plugin-system'; -import { ProfileData, StackTrace } from '@perses-dev/spec'; -import { TitleComponentOption } from 'echarts'; -import { FC, useState, useEffect, useMemo } from 'react'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import type { ProfileData, StackTrace } from '@perses-dev/spec'; +import type { TitleComponentOption } from 'echarts'; +import type { FC } from 'react'; +import { useState, useEffect, useMemo } from 'react'; -import { FlameChartOptions } from '../flame-chart-model'; +import type { FlameChartOptions } from '../flame-chart-model'; import { filterStackTraceById, getMaxDepth } from '../utils/data-transform'; import { FlameChart } from './FlameChart'; import { SeriesChart } from './SeriesChart'; diff --git a/flamechart/src/components/PaletteSelector.tsx b/flamechart/src/components/PaletteSelector.tsx index 28e429717..67712a049 100644 --- a/flamechart/src/components/PaletteSelector.tsx +++ b/flamechart/src/components/PaletteSelector.tsx @@ -12,7 +12,7 @@ // limitations under the License. import { OptionsEditorControl, SettingsAutocomplete } from '@perses-dev/components'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; const PALETTE_OPTIONS: Array<{ id: PaletteOption; label: string }> = [ { id: 'package-name', label: 'By Package Name' }, diff --git a/flamechart/src/components/SearchBar.tsx b/flamechart/src/components/SearchBar.tsx index c03766330..a8545b749 100644 --- a/flamechart/src/components/SearchBar.tsx +++ b/flamechart/src/components/SearchBar.tsx @@ -13,7 +13,7 @@ import { TextField, InputAdornment, Chip } from '@mui/material'; import Magnify from 'mdi-material-ui/Magnify'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; export interface SearchBarProps { searchValue: string; diff --git a/flamechart/src/components/SeriesChart.tsx b/flamechart/src/components/SeriesChart.tsx index 96a545826..deca1fbe9 100644 --- a/flamechart/src/components/SeriesChart.tsx +++ b/flamechart/src/components/SeriesChart.tsx @@ -12,15 +12,20 @@ // limitations under the License. import { Stack, useTheme } from '@mui/material'; -import { useChartsTheme, EChart, ZoomEventData, OnEventsType, enableDataZoom } from '@perses-dev/components'; +import type { ZoomEventData, OnEventsType } from '@perses-dev/components'; +import { useChartsTheme, EChart, enableDataZoom } from '@perses-dev/components'; import { useTimeRange } from '@perses-dev/plugin-system'; -import { ProfileData, Timeline } from '@perses-dev/spec'; -import type { EChartsCoreOption, LineSeriesOption } from 'echarts'; -import { ECharts as EChartsInstance } from 'echarts/core'; -import { CallbackDataParams } from 'echarts/types/dist/shared'; -import { ReactElement, useMemo, useRef } from 'react'; +import type { ProfileData, Timeline } from '@perses-dev/spec'; +import type { + DefaultLabelFormatterCallbackParams as CallbackDataParams, + EChartsCoreOption, + LineSeriesOption, +} from 'echarts'; +import type { ECharts as EChartsInstance } from 'echarts/core'; +import type { ReactElement } from 'react'; +import { useMemo, useRef } from 'react'; -import { SeriesSample } from '../utils/data-model'; +import type { SeriesSample } from '../utils/data-model'; import { formatItemValue } from '../utils/format'; import { getSeriesTooltip } from '../utils/series-tooltip'; diff --git a/flamechart/src/components/Settings.tsx b/flamechart/src/components/Settings.tsx index 39d83594f..4ded9580e 100644 --- a/flamechart/src/components/Settings.tsx +++ b/flamechart/src/components/Settings.tsx @@ -15,9 +15,10 @@ import { Stack, Button, useTheme, MenuItem, Menu, Fade } from '@mui/material'; import { ToolbarIconButton, InfoTooltip } from '@perses-dev/components'; import PaletteIcon from 'mdi-material-ui/Palette'; import RefreshIcon from 'mdi-material-ui/Refresh'; -import { ReactElement, useState, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useState, useMemo } from 'react'; -import { FlameChartOptions } from '../flame-chart-model'; +import type { FlameChartOptions } from '../flame-chart-model'; import { TOOLTIP_TEXT } from '../utils/ui-text'; export interface SettingsProps { diff --git a/flamechart/src/components/SwitchSelector.tsx b/flamechart/src/components/SwitchSelector.tsx index 745bb27c0..b30e5dbdb 100644 --- a/flamechart/src/components/SwitchSelector.tsx +++ b/flamechart/src/components/SwitchSelector.tsx @@ -13,7 +13,7 @@ import { Switch } from '@mui/material'; import { OptionsEditorControl } from '@perses-dev/components'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; export interface SwitchSelectorProps { onChange: (newValue: boolean) => void; diff --git a/flamechart/src/components/TableChart.tsx b/flamechart/src/components/TableChart.tsx index 172f8fd22..da3f3c8b6 100644 --- a/flamechart/src/components/TableChart.tsx +++ b/flamechart/src/components/TableChart.tsx @@ -12,12 +12,14 @@ // limitations under the License. import { Stack, useTheme, Link } from '@mui/material'; -import { Table, TableColumnConfig } from '@perses-dev/components'; -import { ProfileData } from '@perses-dev/spec'; -import { SortingState } from '@tanstack/react-table'; -import { ReactElement, useMemo, useState } from 'react'; +import type { TableColumnConfig } from '@perses-dev/components'; +import { Table } from '@perses-dev/components'; +import type { ProfileData } from '@perses-dev/spec'; +import type { SortingState } from '@tanstack/react-table'; +import type { ReactElement } from 'react'; +import { useMemo, useState } from 'react'; -import { TableChartSample } from '../utils/data-model'; +import type { TableChartSample } from '../utils/data-model'; import { tableRecursionJson } from '../utils/data-transform'; import { formatItemValue } from '../utils/format'; import { SearchBar } from './SearchBar'; diff --git a/flamechart/src/flame-chart-model.ts b/flamechart/src/flame-chart-model.ts index a561fffdb..b501acc4b 100644 --- a/flamechart/src/flame-chart-model.ts +++ b/flamechart/src/flame-chart-model.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { Definition } from '@perses-dev/spec'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { Definition } from '@perses-dev/spec'; /** * The schema for a FlameChart panel. diff --git a/flamechart/src/getPluginModule.ts b/flamechart/src/getPluginModule.ts index 515511f2f..6dee4f848 100644 --- a/flamechart/src/getPluginModule.ts +++ b/flamechart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/flamechart/src/utils/data-transform.test.ts b/flamechart/src/utils/data-transform.test.ts index 996362057..2f9cd3133 100644 --- a/flamechart/src/utils/data-transform.test.ts +++ b/flamechart/src/utils/data-transform.test.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { StackTrace } from '@perses-dev/spec'; +import type { StackTrace } from '@perses-dev/spec'; -import { FlameChartSample as Sample } from './data-model'; +import type { FlameChartSample as Sample } from './data-model'; import { filterStackTraceById, buildSamples } from './data-transform'; import { getSpanColor } from './palette-gen'; diff --git a/flamechart/src/utils/data-transform.ts b/flamechart/src/utils/data-transform.ts index b0b9ffda9..dbf3e7afc 100644 --- a/flamechart/src/utils/data-transform.ts +++ b/flamechart/src/utils/data-transform.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ProfileMetaData, StackTrace } from '@perses-dev/spec'; +import type { ProfileMetaData, StackTrace } from '@perses-dev/spec'; -import { FlameChartSample as Sample, TableChartSample } from './data-model'; +import type { FlameChartSample as Sample, TableChartSample } from './data-model'; import { formatItemValue } from './format'; import { getSpanColor } from './palette-gen'; diff --git a/flamechart/src/utils/series-tooltip.ts b/flamechart/src/utils/series-tooltip.ts index 650d6e2f3..6282c803d 100644 --- a/flamechart/src/utils/series-tooltip.ts +++ b/flamechart/src/utils/series-tooltip.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { SeriesSample } from './data-model'; +import type { SeriesSample } from './data-model'; import { formatItemValue } from './format'; export function getSeriesTooltip( diff --git a/flamechart/src/utils/tooltip.ts b/flamechart/src/utils/tooltip.ts index 0f898189e..3141be39c 100644 --- a/flamechart/src/utils/tooltip.ts +++ b/flamechart/src/utils/tooltip.ts @@ -13,7 +13,7 @@ import * as echarts from 'echarts'; -import { FlameChartSample } from './data-model'; +import type { FlameChartSample } from './data-model'; import { formatItemValue } from './format'; /** diff --git a/flamechart/src/utils/utils.ts b/flamechart/src/utils/utils.ts index b54cdcdde..b772d041a 100644 --- a/flamechart/src/utils/utils.ts +++ b/flamechart/src/utils/utils.ts @@ -12,9 +12,9 @@ // limitations under the License. import { produce } from 'immer'; -import { ChangeEventHandler } from 'react'; +import type { ChangeEventHandler } from 'react'; -import { FlameChartOptionsEditorProps } from '../flame-chart-model'; +import type { FlameChartOptionsEditorProps } from '../flame-chart-model'; /** * Hook to manage `palette` state. diff --git a/flamechart/tsconfig.build.json b/flamechart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/flamechart/tsconfig.build.json +++ b/flamechart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/flamechart/tsconfig.json b/flamechart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/flamechart/tsconfig.json +++ b/flamechart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/flamechart/vitest.config.ts b/flamechart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/flamechart/vitest.config.ts +++ b/flamechart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/gaugechart/package.json b/gaugechart/package.json index 1aef88a4d..c9ad35b8a 100644 --- a/gaugechart/package.json +++ b/gaugechart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,8 +29,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/plugin-system": "^0.55.0-beta.3", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/plugin-system": "^0.55.0-beta.6", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/gaugechart/src/GaugeChart.ts b/gaugechart/src/GaugeChart.ts index f94ec4e30..5da0dcf10 100644 --- a/gaugechart/src/GaugeChart.ts +++ b/gaugechart/src/GaugeChart.ts @@ -11,11 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { createInitialGaugeChartOptions, GaugeChartOptions } from './gauge-chart-model'; +import type { GaugeChartOptions } from './gauge-chart-model'; +import { createInitialGaugeChartOptions } from './gauge-chart-model'; import { GaugeChartOptionsEditorSettings } from './GaugeChartOptionsEditorSettings'; -import { GaugeChartLoading, GaugeChartPanel, GaugeChartPanelProps } from './GaugeChartPanel'; +import type { GaugeChartPanelProps } from './GaugeChartPanel'; +import { GaugeChartLoading, GaugeChartPanel } from './GaugeChartPanel'; /** * The core GaugeChart panel plugin for Perses. diff --git a/gaugechart/src/GaugeChartBase.tsx b/gaugechart/src/GaugeChartBase.tsx index ceccadbe1..67df981bd 100644 --- a/gaugechart/src/GaugeChartBase.tsx +++ b/gaugechart/src/GaugeChartBase.tsx @@ -11,12 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { EChart, FormatOptions, formatValue, useChartsTheme, useDeepMemo } from '@perses-dev/components'; -import { GaugeChart as EChartsGaugeChart, GaugeSeriesOption } from 'echarts/charts'; +import type { FormatOptions } from '@perses-dev/components'; +import { EChart, formatValue, useChartsTheme, useDeepMemo } from '@perses-dev/components'; +import type { GaugeSeriesOption } from 'echarts/charts'; +import { GaugeChart as EChartsGaugeChart } from 'echarts/charts'; import { GridComponent, TitleComponent, TooltipComponent } from 'echarts/components'; -import { use as registerECharts, EChartsCoreOption } from 'echarts/core'; +import type { EChartsCoreOption } from 'echarts/core'; +import { use as registerECharts } from 'echarts/core'; import { CanvasRenderer } from 'echarts/renderers'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; registerECharts([EChartsGaugeChart, GridComponent, TitleComponent, TooltipComponent, CanvasRenderer]); diff --git a/gaugechart/src/GaugeChartOptionsEditorSettings.test.tsx b/gaugechart/src/GaugeChartOptionsEditorSettings.test.tsx index 9abfbfc49..b97fa994b 100644 --- a/gaugechart/src/GaugeChartOptionsEditorSettings.test.tsx +++ b/gaugechart/src/GaugeChartOptionsEditorSettings.test.tsx @@ -16,7 +16,7 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; -import { GaugeChartOptions } from './gauge-chart-model'; +import type { GaugeChartOptions } from './gauge-chart-model'; import { GaugeChartOptionsEditorSettings } from './GaugeChartOptionsEditorSettings'; describe('GaugeChartOptionsEditorSettings', () => { diff --git a/gaugechart/src/GaugeChartOptionsEditorSettings.tsx b/gaugechart/src/GaugeChartOptionsEditorSettings.tsx index 6a9ef6c20..80bb275d2 100644 --- a/gaugechart/src/GaugeChartOptionsEditorSettings.tsx +++ b/gaugechart/src/GaugeChartOptionsEditorSettings.tsx @@ -12,28 +12,23 @@ // limitations under the License. import { Switch, TextField } from '@mui/material'; +import type { FormatControlsProps, ThresholdOptions } from '@perses-dev/components'; import { FormatControls, - FormatControlsProps, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, - ThresholdOptions, ThresholdsEditor, } from '@perses-dev/components'; -import { CalculationSelector, CalculationSelectorProps } from '@perses-dev/plugin-system'; +import type { CalculationSelectorProps } from '@perses-dev/plugin-system'; +import { CalculationSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import merge from 'lodash/merge'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { - DEFAULT_FORMAT, - DEFAULT_MAX_PERCENT, - DEFAULT_MAX_PERCENT_DECIMAL, - GaugeChartOptions, - GaugeChartOptionsEditorProps, -} from './gauge-chart-model'; +import type { GaugeChartOptions, GaugeChartOptionsEditorProps } from './gauge-chart-model'; +import { DEFAULT_FORMAT, DEFAULT_MAX_PERCENT, DEFAULT_MAX_PERCENT_DECIMAL } from './gauge-chart-model'; export function GaugeChartOptionsEditorSettings(props: GaugeChartOptionsEditorProps): ReactElement { const { onChange, value } = props; diff --git a/gaugechart/src/GaugeChartPanel.tsx b/gaugechart/src/GaugeChartPanel.tsx index 3f3afe823..5e6904186 100644 --- a/gaugechart/src/GaugeChartPanel.tsx +++ b/gaugechart/src/GaugeChartPanel.tsx @@ -12,20 +12,20 @@ // limitations under the License. import { Box, Skeleton, Stack } from '@mui/material'; -import { FormatOptions, formatValue, useChartsTheme } from '@perses-dev/components'; -import { CalculationsMap, DEFAULT_CALCULATION, PanelProps } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type { FormatOptions } from '@perses-dev/components'; +import { formatValue, useChartsTheme } from '@perses-dev/components'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import { CalculationsMap, DEFAULT_CALCULATION } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; import type { GaugeSeriesOption } from 'echarts'; import merge from 'lodash/merge'; -import { ReactElement, useMemo } from 'react'; - -import { - DEFAULT_FORMAT, - DEFAULT_MAX_PERCENT, - DEFAULT_MAX_PERCENT_DECIMAL, - GaugeChartOptions, -} from './gauge-chart-model'; -import { GaugeChartBase, GaugeSeries } from './GaugeChartBase'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; + +import type { GaugeChartOptions } from './gauge-chart-model'; +import { DEFAULT_FORMAT, DEFAULT_MAX_PERCENT, DEFAULT_MAX_PERCENT_DECIMAL } from './gauge-chart-model'; +import type { GaugeSeries } from './GaugeChartBase'; +import { GaugeChartBase } from './GaugeChartBase'; import { convertThresholds, defaultThresholdInput } from './thresholds'; const EMPTY_GAUGE_SERIES: GaugeSeries = { label: '', value: undefined }; diff --git a/gaugechart/src/gauge-chart-model.ts b/gaugechart/src/gauge-chart-model.ts index d76e1853d..55d79cda9 100644 --- a/gaugechart/src/gauge-chart-model.ts +++ b/gaugechart/src/gauge-chart-model.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions, ThresholdOptions } from '@perses-dev/components'; -import { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system'; -import { Definition } from '@perses-dev/spec'; +import type { FormatOptions, ThresholdOptions } from '@perses-dev/components'; +import type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { Definition } from '@perses-dev/spec'; export const DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' }; export const DEFAULT_MAX_PERCENT = 100; diff --git a/gaugechart/src/getPluginModule.ts b/gaugechart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/gaugechart/src/getPluginModule.ts +++ b/gaugechart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/gaugechart/src/thresholds.ts b/gaugechart/src/thresholds.ts index a03106983..11d5687cb 100644 --- a/gaugechart/src/thresholds.ts +++ b/gaugechart/src/thresholds.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components'; +import type { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components'; import zip from 'lodash/zip'; export type GaugeColorStop = [number, string]; diff --git a/gaugechart/tsconfig.build.json b/gaugechart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/gaugechart/tsconfig.build.json +++ b/gaugechart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/gaugechart/tsconfig.json b/gaugechart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/gaugechart/tsconfig.json +++ b/gaugechart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/gaugechart/vitest.config.ts b/gaugechart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/gaugechart/vitest.config.ts +++ b/gaugechart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/greptimedb/package.json b/greptimedb/package.json index 594c3685f..7d5c0f787 100644 --- a/greptimedb/package.json +++ b/greptimedb/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,10 +29,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/client": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/client": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/greptimedb/src/components/GreptimeDBQLEditor.tsx b/greptimedb/src/components/GreptimeDBQLEditor.tsx index db0d21715..222893da1 100644 --- a/greptimedb/src/components/GreptimeDBQLEditor.tsx +++ b/greptimedb/src/components/GreptimeDBQLEditor.tsx @@ -13,8 +13,9 @@ import { EditorView } from '@codemirror/view'; import { InputLabel, Stack, useTheme } from '@mui/material'; -import CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror'; -import { ReactElement } from 'react'; +import type { ReactCodeMirrorProps } from '@uiw/react-codemirror'; +import CodeMirror from '@uiw/react-codemirror'; +import type { ReactElement } from 'react'; export function GreptimeDBQLEditor(props: ReactCodeMirrorProps): ReactElement { const theme = useTheme(); diff --git a/greptimedb/src/datasources/greptimedb-datasource/GreptimeDBDatasource.tsx b/greptimedb/src/datasources/greptimedb-datasource/GreptimeDBDatasource.tsx index 723440917..ff021ef1e 100644 --- a/greptimedb/src/datasources/greptimedb-datasource/GreptimeDBDatasource.tsx +++ b/greptimedb/src/datasources/greptimedb-datasource/GreptimeDBDatasource.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; import { greptimedbQuery } from '../../model/greptimedb-client'; -import { GreptimeDBDatasourceClient, GreptimeDBDatasourceSpec } from './greptimedb-datasource-types'; +import type { GreptimeDBDatasourceClient, GreptimeDBDatasourceSpec } from './greptimedb-datasource-types'; import { GreptimeDBDatasourceEditor } from './GreptimeDBDatasourceEditor'; const createClient: DatasourcePlugin['createClient'] = ( diff --git a/greptimedb/src/datasources/greptimedb-datasource/GreptimeDBDatasourceEditor.tsx b/greptimedb/src/datasources/greptimedb-datasource/GreptimeDBDatasourceEditor.tsx index 379bd1d4f..60ccd88d0 100644 --- a/greptimedb/src/datasources/greptimedb-datasource/GreptimeDBDatasourceEditor.tsx +++ b/greptimedb/src/datasources/greptimedb-datasource/GreptimeDBDatasourceEditor.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { GreptimeDBDatasourceSpec } from './greptimedb-datasource-types'; +import type { GreptimeDBDatasourceSpec } from './greptimedb-datasource-types'; export interface GreptimeDBDatasourceEditorProps { value: GreptimeDBDatasourceSpec; diff --git a/greptimedb/src/datasources/greptimedb-datasource/greptimedb-datasource-types.ts b/greptimedb/src/datasources/greptimedb-datasource/greptimedb-datasource-types.ts index fb5c98a2a..697b57178 100644 --- a/greptimedb/src/datasources/greptimedb-datasource/greptimedb-datasource-types.ts +++ b/greptimedb/src/datasources/greptimedb-datasource/greptimedb-datasource-types.ts @@ -11,11 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { RequestHeaders } from '@perses-dev/client'; -import { DatasourceClient } from '@perses-dev/plugin-system'; -import { HTTPProxy } from '@perses-dev/spec'; +import type { RequestHeaders } from '@perses-dev/client'; +import type { DatasourceClient } from '@perses-dev/plugin-system'; +import type { HTTPProxy } from '@perses-dev/spec'; -import { GreptimeDBResponseData } from '../../model/greptimedb-data-types'; +import type { GreptimeDBResponseData } from '../../model/greptimedb-data-types'; export interface GreptimeDBDatasourceSpec { directUrl?: string; diff --git a/greptimedb/src/getPluginModule.ts b/greptimedb/src/getPluginModule.ts index 515511f2f..6dee4f848 100644 --- a/greptimedb/src/getPluginModule.ts +++ b/greptimedb/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/greptimedb/src/model/greptimedb-client.ts b/greptimedb/src/model/greptimedb-client.ts index c11206553..889731d4d 100644 --- a/greptimedb/src/model/greptimedb-client.ts +++ b/greptimedb/src/model/greptimedb-client.ts @@ -11,10 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { RequestHeaders } from '@perses-dev/client'; +import type { RequestHeaders } from '@perses-dev/client'; -import { GreptimeDBDatasourceResponse, GreptimeDBQueryRequestParameters } from '../datasources/greptimedb-datasource'; -import { GreptimeDBResponseData } from './greptimedb-data-types'; +import type { + GreptimeDBDatasourceResponse, + GreptimeDBQueryRequestParameters, +} from '../datasources/greptimedb-datasource'; +import type { GreptimeDBResponseData } from './greptimedb-data-types'; export interface GreptimeDBQueryOptions { datasourceUrl: string; diff --git a/greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQuery.tsx b/greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQuery.tsx index 32994ef27..e0274b280 100644 --- a/greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQuery.tsx +++ b/greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQuery.tsx @@ -14,9 +14,9 @@ import { parseVariables } from '@perses-dev/plugin-system'; import { getGreptimeDBLogData } from './get-greptimedb-log-data'; -import { GreptimeDBLogQuerySpec } from './greptimedb-log-query-types'; +import type { GreptimeDBLogQuerySpec } from './greptimedb-log-query-types'; import { GreptimeDBLogQueryEditor } from './GreptimeDBLogQueryEditor'; -import { LogQueryPlugin } from './log-query-plugin-interface'; +import type { LogQueryPlugin } from './log-query-plugin-interface'; export const GreptimeDBLogQuery: LogQueryPlugin = { getLogData: getGreptimeDBLogData, diff --git a/greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQueryEditor.tsx b/greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQueryEditor.tsx index 3cde6a09e..11dda8b7a 100644 --- a/greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQueryEditor.tsx +++ b/greptimedb/src/queries/greptimedb-log-query/GreptimeDBLogQueryEditor.tsx @@ -12,20 +12,17 @@ // limitations under the License. import { Stack, useTheme } from '@mui/material'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { GreptimeDBQLEditor } from '../../components'; import { queryExample } from '../../components/constants'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; import { useQueryState } from '../query-editor-model'; -import { GreptimeDBLogQuerySpec } from './greptimedb-log-query-types'; +import type { GreptimeDBLogQuerySpec } from './greptimedb-log-query-types'; type GreptimeDBLogQueryEditorProps = OptionsEditorProps; diff --git a/greptimedb/src/queries/greptimedb-log-query/get-greptimedb-log-data.ts b/greptimedb/src/queries/greptimedb-log-query/get-greptimedb-log-data.ts index 7c2f69c09..9b4283c91 100644 --- a/greptimedb/src/queries/greptimedb-log-query/get-greptimedb-log-data.ts +++ b/greptimedb/src/queries/greptimedb-log-query/get-greptimedb-log-data.ts @@ -11,19 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogData, LogEntry } from '@perses-dev/spec'; +import type { LogData, LogEntry } from '@perses-dev/spec'; -import { GreptimeDBClient, GreptimeDBQueryResponse } from '../../model/greptimedb-client'; +import type { GreptimeDBClient, GreptimeDBQueryResponse } from '../../model/greptimedb-client'; import { DEFAULT_DATASOURCE } from '../constants'; +import type { GreptimeDBRecords } from '../greptimedb-query-data-model'; import { findTimeColumnIndex, - GreptimeDBRecords, normalizeRecords, replaceQueryVariables, toTimestampMs, } from '../greptimedb-query-data-model'; -import { GreptimeDBLogQuerySpec } from './greptimedb-log-query-types'; -import { LogQueryPlugin } from './log-query-plugin-interface'; +import type { GreptimeDBLogQuerySpec } from './greptimedb-log-query-types'; +import type { LogQueryPlugin } from './log-query-plugin-interface'; function buildLogs(records: GreptimeDBRecords | undefined): LogData { const columnSchemas = records?.schema?.column_schemas ?? []; diff --git a/greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.test.ts b/greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.test.ts index e33f7012d..bec0c0ef6 100644 --- a/greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.test.ts +++ b/greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.test.ts @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSpec } from '@perses-dev/spec'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock } from 'vitest'; -import { GreptimeDBDatasource, GreptimeDBDatasourceSpec } from '../../datasources'; -import { GreptimeDBQueryResponse } from '../../model/greptimedb-client'; +import type { GreptimeDBDatasourceSpec } from '../../datasources'; +import { GreptimeDBDatasource } from '../../datasources'; +import type { GreptimeDBQueryResponse } from '../../model/greptimedb-client'; import { GreptimeDBLogQuery } from './GreptimeDBLogQuery'; -import { GreptimeDBQueryContext } from './log-query-plugin-interface'; +import type { GreptimeDBQueryContext } from './log-query-plugin-interface'; const datasource: GreptimeDBDatasourceSpec = { directUrl: '/test', diff --git a/greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.ts b/greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.ts index 75b939fa2..9b2880803 100644 --- a/greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.ts +++ b/greptimedb/src/queries/greptimedb-log-query/greptimedb-log-query-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export interface GreptimeDBLogQuerySpec { query: string; diff --git a/greptimedb/src/queries/greptimedb-log-query/log-query-plugin-interface.ts b/greptimedb/src/queries/greptimedb-log-query/log-query-plugin-interface.ts index bf911b159..d2d6db31c 100644 --- a/greptimedb/src/queries/greptimedb-log-query/log-query-plugin-interface.ts +++ b/greptimedb/src/queries/greptimedb-log-query/log-query-plugin-interface.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system'; -import { AbsoluteTimeRange, LogData, UnknownSpec } from '@perses-dev/spec'; +import type { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system'; +import type { AbsoluteTimeRange, LogData, UnknownSpec } from '@perses-dev/spec'; export interface LogQueryResult { logs: LogData; diff --git a/greptimedb/src/queries/greptimedb-query-data-model.ts b/greptimedb/src/queries/greptimedb-query-data-model.ts index aed85126c..8c4bb338b 100644 --- a/greptimedb/src/queries/greptimedb-query-data-model.ts +++ b/greptimedb/src/queries/greptimedb-query-data-model.ts @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { replaceVariables, VariableStateMap } from '@perses-dev/plugin-system'; -import { AbsoluteTimeRange } from '@perses-dev/spec'; +import type { VariableStateMap } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { AbsoluteTimeRange } from '@perses-dev/spec'; -import { GreptimeDBColumnSchema, GreptimeDBRecords, GreptimeDBResponseData } from '../model/greptimedb-data-types'; +import type { GreptimeDBColumnSchema, GreptimeDBRecords, GreptimeDBResponseData } from '../model/greptimedb-data-types'; export type { GreptimeDBColumnSchema, GreptimeDBRecords, GreptimeDBResponseData }; diff --git a/greptimedb/src/queries/greptimedb-time-series-query/GreptimeDBQuery.tsx b/greptimedb/src/queries/greptimedb-time-series-query/GreptimeDBQuery.tsx index 045cbab3e..ad990076f 100644 --- a/greptimedb/src/queries/greptimedb-time-series-query/GreptimeDBQuery.tsx +++ b/greptimedb/src/queries/greptimedb-time-series-query/GreptimeDBQuery.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { parseVariables, TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; import { getTimeSeriesData } from './get-greptimedb-data'; -import { GreptimeDBTimeSeriesQuerySpec } from './greptimedb-query-types'; +import type { GreptimeDBTimeSeriesQuerySpec } from './greptimedb-query-types'; import { GreptimeDBTimeSeriesQueryEditor } from './GreptimeDBQueryEditor'; export const GreptimeDBTimeSeriesQuery: TimeSeriesQueryPlugin = { diff --git a/greptimedb/src/queries/greptimedb-time-series-query/GreptimeDBQueryEditor.tsx b/greptimedb/src/queries/greptimedb-time-series-query/GreptimeDBQueryEditor.tsx index 8907558d1..23a613652 100644 --- a/greptimedb/src/queries/greptimedb-time-series-query/GreptimeDBQueryEditor.tsx +++ b/greptimedb/src/queries/greptimedb-time-series-query/GreptimeDBQueryEditor.tsx @@ -12,20 +12,17 @@ // limitations under the License. import { Stack } from '@mui/material'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { GreptimeDBQLEditor } from '../../components'; import { queryExample } from '../../components/constants'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; import { useQueryState } from '../query-editor-model'; -import { GreptimeDBTimeSeriesQuerySpec } from './greptimedb-query-types'; +import type { GreptimeDBTimeSeriesQuerySpec } from './greptimedb-query-types'; type GreptimeDBTimeSeriesQueryEditorProps = OptionsEditorProps; diff --git a/greptimedb/src/queries/greptimedb-time-series-query/get-greptimedb-data.ts b/greptimedb/src/queries/greptimedb-time-series-query/get-greptimedb-data.ts index 29613fe12..1d6c43ec7 100644 --- a/greptimedb/src/queries/greptimedb-time-series-query/get-greptimedb-data.ts +++ b/greptimedb/src/queries/greptimedb-time-series-query/get-greptimedb-data.ts @@ -11,18 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; -import { GreptimeDBClient, GreptimeDBQueryResponse } from '../../model/greptimedb-client'; +import type { GreptimeDBClient, GreptimeDBQueryResponse } from '../../model/greptimedb-client'; import { DEFAULT_DATASOURCE } from '../constants'; +import type { GreptimeDBRecords } from '../greptimedb-query-data-model'; import { findTimeColumnIndex, - GreptimeDBRecords, normalizeRecords, replaceQueryVariables, toTimestampMs, } from '../greptimedb-query-data-model'; -import { GreptimeDBTimeSeriesQuerySpec } from './greptimedb-query-types'; +import type { GreptimeDBTimeSeriesQuerySpec } from './greptimedb-query-types'; function isLikelyNumericType(dataType: string | undefined): boolean { if (!dataType) return false; diff --git a/greptimedb/src/queries/greptimedb-time-series-query/greptimedb-query-types.test.ts b/greptimedb/src/queries/greptimedb-time-series-query/greptimedb-query-types.test.ts index 7fb9ff8fc..c92827b89 100644 --- a/greptimedb/src/queries/greptimedb-time-series-query/greptimedb-query-types.test.ts +++ b/greptimedb/src/queries/greptimedb-time-series-query/greptimedb-query-types.test.ts @@ -11,12 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock } from 'vitest'; -import { GreptimeDBDatasource, GreptimeDBDatasourceSpec } from '../../datasources'; -import { GreptimeDBQueryResponse } from '../../model/greptimedb-client'; +import type { GreptimeDBDatasourceSpec } from '../../datasources'; +import { GreptimeDBDatasource } from '../../datasources'; +import type { GreptimeDBQueryResponse } from '../../model/greptimedb-client'; import { GreptimeDBTimeSeriesQuery } from './GreptimeDBQuery'; const datasource: GreptimeDBDatasourceSpec = { diff --git a/greptimedb/src/queries/greptimedb-time-series-query/greptimedb-query-types.ts b/greptimedb/src/queries/greptimedb-time-series-query/greptimedb-query-types.ts index cb7d69e3c..f32f21e66 100644 --- a/greptimedb/src/queries/greptimedb-time-series-query/greptimedb-query-types.ts +++ b/greptimedb/src/queries/greptimedb-time-series-query/greptimedb-query-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export interface GreptimeDBTimeSeriesQuerySpec { query: string; diff --git a/greptimedb/src/queries/greptimedb-trace-query/GreptimeDBTraceQuery.tsx b/greptimedb/src/queries/greptimedb-trace-query/GreptimeDBTraceQuery.tsx index 3bc023f5a..4456f6ac6 100644 --- a/greptimedb/src/queries/greptimedb-trace-query/GreptimeDBTraceQuery.tsx +++ b/greptimedb/src/queries/greptimedb-trace-query/GreptimeDBTraceQuery.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { parseVariables, TraceQueryPlugin } from '@perses-dev/plugin-system'; +import type { TraceQueryPlugin } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; import { getGreptimeDBTraceData } from './get-greptimedb-trace-data'; -import { GreptimeDBTraceQuerySpec } from './greptimedb-trace-query-types'; +import type { GreptimeDBTraceQuerySpec } from './greptimedb-trace-query-types'; import { GreptimeDBTraceQueryEditor } from './GreptimeDBTraceQueryEditor'; export const GreptimeDBTraceQuery: TraceQueryPlugin = { diff --git a/greptimedb/src/queries/greptimedb-trace-query/GreptimeDBTraceQueryEditor.tsx b/greptimedb/src/queries/greptimedb-trace-query/GreptimeDBTraceQueryEditor.tsx index 31cc19bc6..25956df19 100644 --- a/greptimedb/src/queries/greptimedb-trace-query/GreptimeDBTraceQueryEditor.tsx +++ b/greptimedb/src/queries/greptimedb-trace-query/GreptimeDBTraceQueryEditor.tsx @@ -12,19 +12,16 @@ // limitations under the License. import { Stack } from '@mui/material'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { GreptimeDBQLEditor } from '../../components'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; import { useQueryState } from '../query-editor-model'; -import { GreptimeDBTraceQuerySpec } from './greptimedb-trace-query-types'; +import type { GreptimeDBTraceQuerySpec } from './greptimedb-trace-query-types'; type GreptimeDBTraceQueryEditorProps = OptionsEditorProps; diff --git a/greptimedb/src/queries/greptimedb-trace-query/get-greptimedb-trace-data.ts b/greptimedb/src/queries/greptimedb-trace-query/get-greptimedb-trace-data.ts index 7e0be61b0..faa2d0478 100644 --- a/greptimedb/src/queries/greptimedb-trace-query/get-greptimedb-trace-data.ts +++ b/greptimedb/src/queries/greptimedb-trace-query/get-greptimedb-trace-data.ts @@ -11,20 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { replaceVariables, TraceQueryPlugin } from '@perses-dev/plugin-system'; -import { TraceSearchResult } from '@perses-dev/spec'; -import * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; +import type { TraceQueryPlugin } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { TraceSearchResult } from '@perses-dev/spec'; +import type * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; -import { GreptimeDBClient, GreptimeDBQueryResponse } from '../../model/greptimedb-client'; +import type { GreptimeDBClient, GreptimeDBQueryResponse } from '../../model/greptimedb-client'; import { DEFAULT_DATASOURCE } from '../constants'; -import { - GreptimeDBColumnSchema, - GreptimeDBRecords, - normalizeRecords, - toTimestampMs, -} from '../greptimedb-query-data-model'; -import { GreptimeDBTraceQuerySpec } from './greptimedb-trace-query-types'; +import type { GreptimeDBColumnSchema, GreptimeDBRecords } from '../greptimedb-query-data-model'; +import { normalizeRecords, toTimestampMs } from '../greptimedb-query-data-model'; +import type { GreptimeDBTraceQuerySpec } from './greptimedb-trace-query-types'; import { isLikelyTraceDetailSQL } from './trace-query-sql'; type Row = unknown[]; diff --git a/greptimedb/src/queries/greptimedb-trace-query/greptimedb-trace-query-types.ts b/greptimedb/src/queries/greptimedb-trace-query/greptimedb-trace-query-types.ts index 1e51ee2b8..dd3b07289 100644 --- a/greptimedb/src/queries/greptimedb-trace-query/greptimedb-trace-query-types.ts +++ b/greptimedb/src/queries/greptimedb-trace-query/greptimedb-trace-query-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export interface GreptimeDBTraceQuerySpec { query: string; diff --git a/greptimedb/src/queries/greptimedb-trace-query/greptimedb-trace-query.test.ts b/greptimedb/src/queries/greptimedb-trace-query/greptimedb-trace-query.test.ts index fe3cc3d72..ba2f86f6d 100644 --- a/greptimedb/src/queries/greptimedb-trace-query/greptimedb-trace-query.test.ts +++ b/greptimedb/src/queries/greptimedb-trace-query/greptimedb-trace-query.test.ts @@ -11,12 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TraceQueryContext } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type { TraceQueryContext } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock } from 'vitest'; -import { GreptimeDBDatasource, GreptimeDBDatasourceSpec } from '../../datasources'; -import { GreptimeDBQueryResponse } from '../../model/greptimedb-client'; +import type { GreptimeDBDatasourceSpec } from '../../datasources'; +import { GreptimeDBDatasource } from '../../datasources'; +import type { GreptimeDBQueryResponse } from '../../model/greptimedb-client'; import { GreptimeDBTraceQuery } from './GreptimeDBTraceQuery'; const datasource: GreptimeDBDatasourceSpec = { diff --git a/greptimedb/tsconfig.build.json b/greptimedb/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/greptimedb/tsconfig.build.json +++ b/greptimedb/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/greptimedb/tsconfig.json b/greptimedb/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/greptimedb/tsconfig.json +++ b/greptimedb/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/greptimedb/vitest.config.ts b/greptimedb/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/greptimedb/vitest.config.ts +++ b/greptimedb/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/heatmapchart/package.json b/heatmapchart/package.json index 1071eec41..593e5d5a4 100644 --- a/heatmapchart/package.json +++ b/heatmapchart/package.json @@ -14,20 +14,20 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "echarts": "5.5.0", "lodash": "^4.17.21", "react": "^17.0.2 || ^18.0.0", diff --git a/heatmapchart/src/HeatMapChart.ts b/heatmapchart/src/HeatMapChart.ts index af8ec88b5..222d40dcb 100644 --- a/heatmapchart/src/HeatMapChart.ts +++ b/heatmapchart/src/HeatMapChart.ts @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { HeatMapChartOptionsEditorSettings, HeatMapChartPanel, HeatMapChartPanelProps } from './components'; -import { createInitialHeatMapChartOptions, HeatMapChartOptions } from './heat-map-chart-model'; +import type { HeatMapChartPanelProps } from './components'; +import { HeatMapChartOptionsEditorSettings, HeatMapChartPanel } from './components'; +import type { HeatMapChartOptions } from './heat-map-chart-model'; +import { createInitialHeatMapChartOptions } from './heat-map-chart-model'; /** * The core HeatMapChart panel plugin for Perses. diff --git a/heatmapchart/src/components/HeatMapChart.tsx b/heatmapchart/src/components/HeatMapChart.tsx index cb90d33cf..829d2abdf 100644 --- a/heatmapchart/src/components/HeatMapChart.tsx +++ b/heatmapchart/src/components/HeatMapChart.tsx @@ -12,15 +12,17 @@ // limitations under the License. import { useTheme } from '@mui/material'; -import { EChart, FormatOptions, formatValue, useChartsTheme, useTimeZone } from '@perses-dev/components'; -import { TimeScale } from '@perses-dev/spec'; -import type { CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams } from 'echarts'; +import type { FormatOptions } from '@perses-dev/components'; +import { EChart, formatValue, useChartsTheme, useTimeZone } from '@perses-dev/components'; +import type { TimeScale } from '@perses-dev/spec'; +import type { CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams, CustomSeriesRenderItemReturn } from 'echarts'; import { CustomChart } from 'echarts/charts'; -import { use as registerECharts, EChartsCoreOption } from 'echarts/core'; -import { CustomSeriesRenderItemReturn } from 'echarts/types/dist/echarts'; -import { ReactElement, useMemo } from 'react'; +import type { EChartsCoreOption } from 'echarts/core'; +import { use as registerECharts } from 'echarts/core'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { LOG_BASE } from '../heat-map-chart-model'; +import type { LOG_BASE } from '../heat-map-chart-model'; import { getFormattedHeatmapAxisLabel } from '../utils'; import { generateTooltipHTML } from './HeatMapTooltip'; diff --git a/heatmapchart/src/components/HeatMapChartOptionsEditorSettings.test.tsx b/heatmapchart/src/components/HeatMapChartOptionsEditorSettings.test.tsx index 9006eb51c..880efdb05 100644 --- a/heatmapchart/src/components/HeatMapChartOptionsEditorSettings.test.tsx +++ b/heatmapchart/src/components/HeatMapChartOptionsEditorSettings.test.tsx @@ -16,7 +16,8 @@ import { fireEvent, render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React, { act } from 'react'; -import { DEFAULT_FORMAT, HeatMapChartOptions } from '../heat-map-chart-model'; +import type { HeatMapChartOptions } from '../heat-map-chart-model'; +import { DEFAULT_FORMAT } from '../heat-map-chart-model'; import { HeatMapChartOptionsEditorSettings } from './HeatMapChartOptionsEditorSettings'; describe('HeatMapChartOptionsEditorSettings', () => { diff --git a/heatmapchart/src/components/HeatMapChartOptionsEditorSettings.tsx b/heatmapchart/src/components/HeatMapChartOptionsEditorSettings.tsx index a4ef9752d..0eb5a728b 100644 --- a/heatmapchart/src/components/HeatMapChartOptionsEditorSettings.tsx +++ b/heatmapchart/src/components/HeatMapChartOptionsEditorSettings.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Switch, SwitchProps, TextField } from '@mui/material'; +import type { SwitchProps } from '@mui/material'; +import { Switch, TextField } from '@mui/material'; +import type { FormatControlsProps } from '@perses-dev/components'; import { FormatControls, - FormatControlsProps, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, @@ -23,15 +24,10 @@ import { } from '@perses-dev/components'; import { produce } from 'immer'; import merge from 'lodash/merge'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { - DEFAULT_FORMAT, - HeatMapChartOptions, - HeatMapChartOptionsEditorProps, - LOG_BASE_CONFIG, - LOG_BASE_OPTIONS, -} from '../heat-map-chart-model'; +import type { HeatMapChartOptions, HeatMapChartOptionsEditorProps } from '../heat-map-chart-model'; +import { DEFAULT_FORMAT, LOG_BASE_CONFIG, LOG_BASE_OPTIONS } from '../heat-map-chart-model'; export function HeatMapChartOptionsEditorSettings(props: HeatMapChartOptionsEditorProps): ReactElement { const { onChange, value } = props; diff --git a/heatmapchart/src/components/HeatMapChartPanel.tsx b/heatmapchart/src/components/HeatMapChartPanel.tsx index 8795e280a..c1d54b1f0 100644 --- a/heatmapchart/src/components/HeatMapChartPanel.tsx +++ b/heatmapchart/src/components/HeatMapChartPanel.tsx @@ -12,14 +12,17 @@ // limitations under the License. import { Stack, Typography } from '@mui/material'; -import { PanelProps } from '@perses-dev/plugin-system'; -import { TimeScale, TimeSeries, TimeSeriesData } from '@perses-dev/spec'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import type { TimeScale, TimeSeries, TimeSeriesData } from '@perses-dev/spec'; import merge from 'lodash/merge'; -import { ReactElement, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { DEFAULT_FORMAT, HeatMapChartOptions, LOG_BASE } from '../heat-map-chart-model'; +import type { HeatMapChartOptions, LOG_BASE } from '../heat-map-chart-model'; +import { DEFAULT_FORMAT } from '../heat-map-chart-model'; import { generateCompleteTimestamps, getCommonTimeScaleForQueries } from '../utils'; -import { HeatMapChart, HeatMapDataItem } from './HeatMapChart'; +import type { HeatMapDataItem } from './HeatMapChart'; +import { HeatMapChart } from './HeatMapChart'; /** * Helper function to get the effective lower bound for log scale. diff --git a/heatmapchart/src/components/HeatMapTooltip.ts b/heatmapchart/src/components/HeatMapTooltip.ts index 19d7dc648..e8ab9763d 100644 --- a/heatmapchart/src/components/HeatMapTooltip.ts +++ b/heatmapchart/src/components/HeatMapTooltip.ts @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { css, Theme } from '@mui/material'; -import { FormatOptions, formatValue, getDateAndTime } from '@perses-dev/components'; +import type { Theme } from '@mui/material'; +import { css } from '@mui/material'; +import type { FormatOptions } from '@perses-dev/components'; +import { formatValue, getDateAndTime } from '@perses-dev/components'; -import { HeatMapData } from './HeatMapChart'; +import type { HeatMapData } from './HeatMapChart'; interface CustomTooltipProps { data: HeatMapData; diff --git a/heatmapchart/src/getPluginModule.ts b/heatmapchart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/heatmapchart/src/getPluginModule.ts +++ b/heatmapchart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/heatmapchart/src/heat-map-chart-model.ts b/heatmapchart/src/heat-map-chart-model.ts index d828f5a8e..43aca7840 100644 --- a/heatmapchart/src/heat-map-chart-model.ts +++ b/heatmapchart/src/heat-map-chart-model.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions } from '@perses-dev/components'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { Definition } from '@perses-dev/spec'; +import type { FormatOptions } from '@perses-dev/components'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { Definition } from '@perses-dev/spec'; export const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal' }; export const DEFAULT_MIN_PERCENT = 0; diff --git a/heatmapchart/src/utils/data-transform.ts b/heatmapchart/src/utils/data-transform.ts index 79e039eb2..e5f0b59e1 100644 --- a/heatmapchart/src/utils/data-transform.ts +++ b/heatmapchart/src/utils/data-transform.ts @@ -12,8 +12,8 @@ // limitations under the License. import { getCommonTimeScale } from '@perses-dev/components'; -import { PanelData } from '@perses-dev/plugin-system'; -import { TimeScale, TimeSeriesData } from '@perses-dev/spec'; +import type { PanelData } from '@perses-dev/plugin-system'; +import type { TimeScale, TimeSeriesData } from '@perses-dev/spec'; export function getCommonTimeScaleForQueries(queries: Array>): TimeScale | undefined { const seriesData = queries.map((query) => query.data); diff --git a/heatmapchart/src/utils/thresholds.ts b/heatmapchart/src/utils/thresholds.ts index a19f7c4ee..125f9a2ac 100644 --- a/heatmapchart/src/utils/thresholds.ts +++ b/heatmapchart/src/utils/thresholds.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PersesChartsTheme, ThresholdOptions } from '@perses-dev/components'; +import type { PersesChartsTheme, ThresholdOptions } from '@perses-dev/components'; export function getColorFromThresholds( value: number, diff --git a/heatmapchart/tsconfig.build.json b/heatmapchart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/heatmapchart/tsconfig.build.json +++ b/heatmapchart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/heatmapchart/tsconfig.json b/heatmapchart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/heatmapchart/tsconfig.json +++ b/heatmapchart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/heatmapchart/vitest.config.ts b/heatmapchart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/heatmapchart/vitest.config.ts +++ b/heatmapchart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/histogramchart/package.json b/histogramchart/package.json index 3976de54a..f3e628bb8 100644 --- a/histogramchart/package.json +++ b/histogramchart/package.json @@ -14,20 +14,20 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "echarts": "5.5.0", "lodash": "^4.17.21", "react": "^17.0.2 || ^18.0.0", diff --git a/histogramchart/src/HistogramChart.ts b/histogramchart/src/HistogramChart.ts index d12ad1861..f04de8ab9 100644 --- a/histogramchart/src/HistogramChart.ts +++ b/histogramchart/src/HistogramChart.ts @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { HistogramChartOptionsEditorSettings, HistogramChartPanel, HistogramChartPanelProps } from './components'; -import { createInitialHistogramChartOptions, HistogramChartOptions } from './histogram-chart-model'; +import type { HistogramChartPanelProps } from './components'; +import { HistogramChartOptionsEditorSettings, HistogramChartPanel } from './components'; +import type { HistogramChartOptions } from './histogram-chart-model'; +import { createInitialHistogramChartOptions } from './histogram-chart-model'; /** * The core HistogramChart panel plugin for Perses. diff --git a/histogramchart/src/components/HistogramChart.tsx b/histogramchart/src/components/HistogramChart.tsx index 5d86428af..67fdca2ee 100644 --- a/histogramchart/src/components/HistogramChart.tsx +++ b/histogramchart/src/components/HistogramChart.tsx @@ -11,15 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { EChart, FormatOptions, getFormattedAxis, ThresholdOptions, useChartsTheme } from '@perses-dev/components'; -import { BucketTuple } from '@perses-dev/spec'; -import { CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams } from 'echarts'; +import type { FormatOptions, ThresholdOptions } from '@perses-dev/components'; +import { EChart, getFormattedAxis, useChartsTheme } from '@perses-dev/components'; +import type { BucketTuple } from '@perses-dev/spec'; +import type { CustomSeriesRenderItemAPI, CustomSeriesRenderItemParams, CustomSeriesRenderItemReturn } from 'echarts'; import { CustomChart } from 'echarts/charts'; -import { use as registerECharts, EChartsCoreOption } from 'echarts/core'; -import { CustomSeriesRenderItemReturn } from 'echarts/types/dist/echarts'; -import { ReactElement, useMemo } from 'react'; +import type { EChartsCoreOption } from 'echarts/core'; +import { use as registerECharts } from 'echarts/core'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { LOG_BASE } from '../histogram-chart-model'; +import type { LOG_BASE } from '../histogram-chart-model'; import { getColorFromThresholds } from '../utils'; registerECharts([CustomChart]); diff --git a/histogramchart/src/components/HistogramChartOptionsEditorSettings.test.tsx b/histogramchart/src/components/HistogramChartOptionsEditorSettings.test.tsx index a0ce4e966..045d67060 100644 --- a/histogramchart/src/components/HistogramChartOptionsEditorSettings.test.tsx +++ b/histogramchart/src/components/HistogramChartOptionsEditorSettings.test.tsx @@ -15,7 +15,7 @@ import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { HistogramChartOptions } from '../histogram-chart-model'; +import type { HistogramChartOptions } from '../histogram-chart-model'; import { HistogramChartOptionsEditorSettings } from './HistogramChartOptionsEditorSettings'; describe('HistogramChartOptionsEditorSettings', () => { diff --git a/histogramchart/src/components/HistogramChartOptionsEditorSettings.tsx b/histogramchart/src/components/HistogramChartOptionsEditorSettings.tsx index 0f0486193..0f18e30a9 100644 --- a/histogramchart/src/components/HistogramChartOptionsEditorSettings.tsx +++ b/histogramchart/src/components/HistogramChartOptionsEditorSettings.tsx @@ -12,21 +12,21 @@ // limitations under the License. import { TextField } from '@mui/material'; +import type { FormatControlsProps, ThresholdsEditorProps } from '@perses-dev/components'; import { FormatControls, - FormatControlsProps, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, ThresholdsEditor, - ThresholdsEditorProps, SettingsAutocomplete, } from '@perses-dev/components'; import { produce } from 'immer'; import merge from 'lodash/merge'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; +import type { HistogramChartOptions, HistogramChartOptionsEditorProps } from '../histogram-chart-model'; import { DEFAULT_FORMAT, DEFAULT_MAX_PERCENT, @@ -34,8 +34,6 @@ import { DEFAULT_MIN_PERCENT, DEFAULT_MIN_PERCENT_DECIMAL, DEFAULT_THRESHOLDS, - HistogramChartOptions, - HistogramChartOptionsEditorProps, LOG_BASE_CONFIG, LOG_BASE_OPTIONS, } from '../histogram-chart-model'; diff --git a/histogramchart/src/components/HistogramChartPanel.tsx b/histogramchart/src/components/HistogramChartPanel.tsx index 4ad6acfe3..f5ce0924a 100644 --- a/histogramchart/src/components/HistogramChartPanel.tsx +++ b/histogramchart/src/components/HistogramChartPanel.tsx @@ -13,13 +13,16 @@ import { Box, Stack, Typography } from '@mui/material'; import { useChartsTheme } from '@perses-dev/components'; -import { PanelProps } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; import merge from 'lodash/merge'; -import { ReactElement, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { DEFAULT_FORMAT, DEFAULT_THRESHOLDS, HistogramChartOptions } from '../histogram-chart-model'; -import { HistogramChart, HistogramChartData } from './HistogramChart'; +import type { HistogramChartOptions } from '../histogram-chart-model'; +import { DEFAULT_FORMAT, DEFAULT_THRESHOLDS } from '../histogram-chart-model'; +import type { HistogramChartData } from './HistogramChart'; +import { HistogramChart } from './HistogramChart'; const HISTOGRAM_MIN_WIDTH = 90; diff --git a/histogramchart/src/getPluginModule.ts b/histogramchart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/histogramchart/src/getPluginModule.ts +++ b/histogramchart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/histogramchart/src/histogram-chart-model.ts b/histogramchart/src/histogram-chart-model.ts index e33475d93..1b4afbfd1 100644 --- a/histogramchart/src/histogram-chart-model.ts +++ b/histogramchart/src/histogram-chart-model.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions, ThresholdOptions } from '@perses-dev/components'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { Definition } from '@perses-dev/spec'; +import type { FormatOptions, ThresholdOptions } from '@perses-dev/components'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { Definition } from '@perses-dev/spec'; export const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal' }; export const DEFAULT_THRESHOLDS: ThresholdOptions = { defaultColor: '#56b4e9' }; diff --git a/histogramchart/src/utils/thresholds.ts b/histogramchart/src/utils/thresholds.ts index a19f7c4ee..125f9a2ac 100644 --- a/histogramchart/src/utils/thresholds.ts +++ b/histogramchart/src/utils/thresholds.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PersesChartsTheme, ThresholdOptions } from '@perses-dev/components'; +import type { PersesChartsTheme, ThresholdOptions } from '@perses-dev/components'; export function getColorFromThresholds( value: number, diff --git a/histogramchart/tsconfig.build.json b/histogramchart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/histogramchart/tsconfig.build.json +++ b/histogramchart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/histogramchart/tsconfig.json b/histogramchart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/histogramchart/tsconfig.json +++ b/histogramchart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/histogramchart/vitest.config.ts b/histogramchart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/histogramchart/vitest.config.ts +++ b/histogramchart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/jaeger/package.json b/jaeger/package.json index 8dccf61e0..062e7db99 100644 --- a/jaeger/package.json +++ b/jaeger/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,11 +29,11 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/client": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/client": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/jaeger/src/getPluginModule.ts b/jaeger/src/getPluginModule.ts index 2c762611b..87533706e 100644 --- a/jaeger/src/getPluginModule.ts +++ b/jaeger/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; export function getPluginModule(): PluginModuleResource { const { name, version, perses } = packageJson; diff --git a/jaeger/src/model/jaeger-client.ts b/jaeger/src/model/jaeger-client.ts index 22606f74e..1746cb890 100644 --- a/jaeger/src/model/jaeger-client.ts +++ b/jaeger/src/model/jaeger-client.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { RequestHeaders } from '@perses-dev/client'; -import { DatasourceClient } from '@perses-dev/plugin-system'; +import type { RequestHeaders } from '@perses-dev/client'; +import type { DatasourceClient } from '@perses-dev/plugin-system'; -import { JaegerApiResponse, JaegerOperation, JaegerSearchRequestParameters, JaegerTrace } from './api-types'; +import type { JaegerApiResponse, JaegerOperation, JaegerSearchRequestParameters, JaegerTrace } from './api-types'; interface JaegerClientOptions { datasourceUrl: string; diff --git a/jaeger/src/model/jaeger-selectors.ts b/jaeger/src/model/jaeger-selectors.ts index 1b181e18c..cc162819c 100644 --- a/jaeger/src/model/jaeger-selectors.ts +++ b/jaeger/src/model/jaeger-selectors.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import { isVariableDatasource } from '@perses-dev/plugin-system'; +import type { DatasourceSelector } from '@perses-dev/spec'; export const JAEGER_DATASOURCE_KIND = 'JaegerDatasource' as const; diff --git a/jaeger/src/model/trace-query-model.ts b/jaeger/src/model/trace-query-model.ts index 159e1f6f3..0530761f3 100644 --- a/jaeger/src/model/trace-query-model.ts +++ b/jaeger/src/model/trace-query-model.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; -import { JaegerDatasourceSelector } from './jaeger-selectors'; +import type { JaegerDatasourceSelector } from './jaeger-selectors'; export interface JaegerTraceQuerySpec { datasource?: DatasourceSelectValue; diff --git a/jaeger/src/plugins/JaegerDatasourceEditor.tsx b/jaeger/src/plugins/JaegerDatasourceEditor.tsx index 864d8a240..9ef7c2b96 100644 --- a/jaeger/src/plugins/JaegerDatasourceEditor.tsx +++ b/jaeger/src/plugins/JaegerDatasourceEditor.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { JaegerDatasourceSpec } from './jaeger-datasource-types'; +import type { JaegerDatasourceSpec } from './jaeger-datasource-types'; export interface JaegerDatasourceEditorProps { value: JaegerDatasourceSpec; diff --git a/jaeger/src/plugins/JaegerTraceQuery.ts b/jaeger/src/plugins/JaegerTraceQuery.ts index efdabfbc3..8ade00874 100644 --- a/jaeger/src/plugins/JaegerTraceQuery.ts +++ b/jaeger/src/plugins/JaegerTraceQuery.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { isVariableDatasource, parseVariables, TraceQueryPlugin } from '@perses-dev/plugin-system'; +import type { TraceQueryPlugin } from '@perses-dev/plugin-system'; +import { isVariableDatasource, parseVariables } from '@perses-dev/plugin-system'; -import { JaegerTraceQuerySpec } from '../model'; +import type { JaegerTraceQuerySpec } from '../model'; import { getTraceData } from './get-trace-data'; import { JaegerTraceQueryEditor } from './JaegerTraceQueryEditor'; diff --git a/jaeger/src/plugins/JaegerTraceQueryEditor.tsx b/jaeger/src/plugins/JaegerTraceQueryEditor.tsx index fd375d7fa..b2ce00aaf 100644 --- a/jaeger/src/plugins/JaegerTraceQueryEditor.tsx +++ b/jaeger/src/plugins/JaegerTraceQueryEditor.tsx @@ -11,34 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - Autocomplete, - FormControl, - InputLabel, - MenuItem, - Select, - Stack, - TextField, - TextFieldProps, -} from '@mui/material'; +import type { TextFieldProps } from '@mui/material'; +import { Autocomplete, FormControl, InputLabel, MenuItem, Select, Stack, TextField } from '@mui/material'; import { useId } from '@perses-dev/components'; -import { - DatasourceSelect, - DatasourceSelectProps, - useDatasourceClient, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, useDatasourceClient, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ChangeEvent, ReactElement, SyntheticEvent, useCallback, useEffect, useMemo, useState } from 'react'; - -import { - DEFAULT_JAEGER, - JaegerClient, - isDefaultJaegerSelector, - isJaegerDatasourceSelector, - JAEGER_DATASOURCE_KIND, - JaegerTraceQuerySpec, -} from '../model'; +import type { ChangeEvent, ReactElement, SyntheticEvent } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; + +import type { JaegerClient, JaegerTraceQuerySpec } from '../model'; +import { DEFAULT_JAEGER, isDefaultJaegerSelector, isJaegerDatasourceSelector, JAEGER_DATASOURCE_KIND } from '../model'; interface JaegerTraceQueryEditorProps { value: JaegerTraceQuerySpec; diff --git a/jaeger/src/plugins/get-trace-data.test.ts b/jaeger/src/plugins/get-trace-data.test.ts index 4f5bb8ea8..daa7438ed 100644 --- a/jaeger/src/plugins/get-trace-data.test.ts +++ b/jaeger/src/plugins/get-trace-data.test.ts @@ -11,16 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { replaceVariables, TraceQueryContext } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type * as PluginSystemModule from '@perses-dev/plugin-system'; +import type { TraceQueryContext } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock, MockedFunction } from 'vitest'; -import { JaegerClient } from '../model'; +import type { JaegerClient } from '../model'; import { getTraceData, jaegerTraceToOTLP } from './get-trace-data'; import { JaegerDatasource } from './jaeger-datasource'; vi.mock('@perses-dev/plugin-system', async (importOriginal) => { - const actual = await importOriginal(); + const actual = await importOriginal(); return { ...actual, replaceVariables: vi.fn((query: string) => query), diff --git a/jaeger/src/plugins/get-trace-data.ts b/jaeger/src/plugins/get-trace-data.ts index b68010675..7e7bf9131 100644 --- a/jaeger/src/plugins/get-trace-data.ts +++ b/jaeger/src/plugins/get-trace-data.ts @@ -11,20 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - datasourceSelectValueToSelector, - replaceVariables, - TraceQueryPlugin, - VariableStateMap, -} from '@perses-dev/plugin-system'; -import { AbsoluteTimeRange, Notice, TraceSearchResult } from '@perses-dev/spec'; -import * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; - -import { - DEFAULT_JAEGER, - DEFAULT_SEARCH_LIMIT, - JAEGER_DATASOURCE_KIND, +import type { TraceQueryPlugin, VariableStateMap } from '@perses-dev/plugin-system'; +import { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; +import type { AbsoluteTimeRange, Notice, TraceSearchResult } from '@perses-dev/spec'; +import type * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; + +import type { JaegerApiResponse, JaegerClient, JaegerLog, @@ -36,6 +29,7 @@ import { JaegerTrace, JaegerTraceQuerySpec, } from '../model'; +import { DEFAULT_JAEGER, DEFAULT_SEARCH_LIMIT, JAEGER_DATASOURCE_KIND } from '../model'; const TRACE_ID_PATTERN = /^[a-fA-F0-9]{16}(?:[a-fA-F0-9]{16})?$/; diff --git a/jaeger/src/plugins/jaeger-datasource-types.ts b/jaeger/src/plugins/jaeger-datasource-types.ts index 03ca9538a..5b57fabd5 100644 --- a/jaeger/src/plugins/jaeger-datasource-types.ts +++ b/jaeger/src/plugins/jaeger-datasource-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { HTTPProxy } from '@perses-dev/spec'; +import type { HTTPProxy } from '@perses-dev/spec'; export interface JaegerDatasourceSpec { directUrl?: string; diff --git a/jaeger/src/plugins/jaeger-datasource.tsx b/jaeger/src/plugins/jaeger-datasource.tsx index 9f8870bd6..6ae618afe 100644 --- a/jaeger/src/plugins/jaeger-datasource.tsx +++ b/jaeger/src/plugins/jaeger-datasource.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; -import { getTrace, JaegerClient, searchOperations, searchServices, searchTraces } from '../model'; -import { JaegerDatasourceSpec } from './jaeger-datasource-types'; +import type { JaegerClient } from '../model'; +import { getTrace, searchOperations, searchServices, searchTraces } from '../model'; +import type { JaegerDatasourceSpec } from './jaeger-datasource-types'; import { JaegerDatasourceEditor } from './JaegerDatasourceEditor'; const createClient: DatasourcePlugin['createClient'] = (spec, options) => { diff --git a/jaeger/tsconfig.build.json b/jaeger/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/jaeger/tsconfig.build.json +++ b/jaeger/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/jaeger/tsconfig.json b/jaeger/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/jaeger/tsconfig.json +++ b/jaeger/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/jaeger/vitest.config.ts b/jaeger/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/jaeger/vitest.config.ts +++ b/jaeger/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/logexplorer/package.json b/logexplorer/package.json index 43873038a..dfada0ba9 100644 --- a/logexplorer/package.json +++ b/logexplorer/package.json @@ -13,14 +13,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "devDependencies": { @@ -31,10 +31,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/logexplorer/src/explore/log-explorer/LogExplorer.tsx b/logexplorer/src/explore/log-explorer/LogExplorer.tsx index d2bc0c446..aa53d6548 100644 --- a/logexplorer/src/explore/log-explorer/LogExplorer.tsx +++ b/logexplorer/src/explore/log-explorer/LogExplorer.tsx @@ -14,9 +14,9 @@ import { Box, Stack } from '@mui/material'; import { Panel } from '@perses-dev/dashboards'; import { useExplorerManagerContext } from '@perses-dev/explore'; +import type { LogQueryContext } from '@perses-dev/plugin-system'; import { DataQueriesProvider, - LogQueryContext, MultiQueryEditor, useAllVariableValues, useDatasourceStore, @@ -24,9 +24,10 @@ import { usePluginRegistry, useTimeRange, } from '@perses-dev/plugin-system'; -import { QueryDefinition } from '@perses-dev/spec'; +import type { QueryDefinition } from '@perses-dev/spec'; import { useQuery } from '@tanstack/react-query'; -import { ReactElement, useState, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useState, useMemo } from 'react'; interface LogExplorerQueryParams { queries?: QueryDefinition[]; diff --git a/logexplorer/src/getPluginModule.ts b/logexplorer/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/logexplorer/src/getPluginModule.ts +++ b/logexplorer/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/logexplorer/tsconfig.build.json b/logexplorer/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/logexplorer/tsconfig.build.json +++ b/logexplorer/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/logexplorer/tsconfig.json b/logexplorer/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/logexplorer/tsconfig.json +++ b/logexplorer/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/logexplorer/vitest.config.ts b/logexplorer/vitest.config.ts index 66516c66b..6fc8ebf97 100644 --- a/logexplorer/vitest.config.ts +++ b/logexplorer/vitest.config.ts @@ -11,12 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, passWithNoTests: true, setupFiles: ['src/setup-tests.ts'], }); diff --git a/logstable/package.json b/logstable/package.json index 5a9f6cb4f..9f335a286 100644 --- a/logstable/package.json +++ b/logstable/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -33,9 +33,9 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/logstable/src/LogsTable.ts b/logstable/src/LogsTable.ts index 82cdd7bf2..e65d22200 100644 --- a/logstable/src/LogsTable.ts +++ b/logstable/src/LogsTable.ts @@ -11,14 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; import { LogsTableComponent } from './LogsTableComponent'; import { LogsTableCsvExportAction } from './LogsTableCsvExportAction'; import { LogsTableExportAction } from './LogsTableExportAction'; import { LogsTableItemSelectionActionsEditor } from './LogsTableItemSelectionActionsEditor'; import { LogsTableSettingsEditor } from './LogsTableSettingsEditor'; -import { LogsTableOptions, LogsTableProps } from './model'; +import type { LogsTableOptions, LogsTableProps } from './model'; export const LogsTable: PanelPlugin = { PanelComponent: LogsTableComponent, diff --git a/logstable/src/LogsTableComponent.tsx b/logstable/src/LogsTableComponent.tsx index 4baae4525..1ee1f159c 100644 --- a/logstable/src/LogsTableComponent.tsx +++ b/logstable/src/LogsTableComponent.tsx @@ -12,10 +12,10 @@ // limitations under the License. import { Box, Typography } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { LogsList } from './components/LogsList'; -import { LogsTableProps } from './model'; +import type { LogsTableProps } from './model'; export function LogsTableComponent(props: LogsTableProps): ReactElement | null { const { queryResults, spec } = props; diff --git a/logstable/src/LogsTableCsvExportAction.test.ts b/logstable/src/LogsTableCsvExportAction.test.ts index e31a558bc..99deb534a 100644 --- a/logstable/src/LogsTableCsvExportAction.test.ts +++ b/logstable/src/LogsTableCsvExportAction.test.ts @@ -18,7 +18,7 @@ vi.mock('@perses-dev/plugin-system', async () => { escapeCsvValue: (value: unknown) => string; formatTimestampISO: (timestamp: number) => string; sanitizeFilename: (filename: string) => string; - }>('@perses-dev/plugin-system/dist/cjs/utils/csv-export'); + }>('@perses-dev/plugin-system/dist/utils/csv-export.js'); return { escapeCsvValue: csvExport.escapeCsvValue, formatTimestampISO: csvExport.formatTimestampISO, @@ -26,7 +26,7 @@ vi.mock('@perses-dev/plugin-system', async () => { }; }); -import { LogEntry } from '@perses-dev/spec'; +import type { LogEntry } from '@perses-dev/spec'; import { collectLabelKeys, buildLogsCsvString } from './LogsTableCsvExportAction'; diff --git a/logstable/src/LogsTableCsvExportAction.tsx b/logstable/src/LogsTableCsvExportAction.tsx index 0344408b8..0453d913b 100644 --- a/logstable/src/LogsTableCsvExportAction.tsx +++ b/logstable/src/LogsTableCsvExportAction.tsx @@ -14,11 +14,11 @@ import { IconButton } from '@mui/material'; import { InfoTooltip } from '@perses-dev/components'; import { escapeCsvValue, formatTimestampISO, sanitizeFilename } from '@perses-dev/plugin-system'; -import { LogEntry } from '@perses-dev/spec'; +import type { LogEntry } from '@perses-dev/spec'; import FileDelimitedOutline from 'mdi-material-ui/FileDelimitedOutline'; import { useCallback, useMemo } from 'react'; -import { LogsTableProps } from './model'; +import type { LogsTableProps } from './model'; import { stripAnsi } from './utils/ansi'; export function collectLabelKeys(entries: LogEntry[]): string[] { diff --git a/logstable/src/LogsTableExportAction.tsx b/logstable/src/LogsTableExportAction.tsx index f30a41d92..3c44a4644 100644 --- a/logstable/src/LogsTableExportAction.tsx +++ b/logstable/src/LogsTableExportAction.tsx @@ -17,7 +17,7 @@ import { sanitizeFilename } from '@perses-dev/plugin-system'; import DownloadIcon from 'mdi-material-ui/Download'; import { useCallback, useMemo } from 'react'; -import { LogsTableProps } from './model'; +import type { LogsTableProps } from './model'; export const LogsTableExportAction: React.FC = ({ queryResults, definition }) => { const exportedResult = useMemo(() => { diff --git a/logstable/src/LogsTableItemSelectionActionsEditor.tsx b/logstable/src/LogsTableItemSelectionActionsEditor.tsx index d0eb68196..5cfc0472d 100644 --- a/logstable/src/LogsTableItemSelectionActionsEditor.tsx +++ b/logstable/src/LogsTableItemSelectionActionsEditor.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ActionOptions, ItemSelectionActionsEditor, SelectionOptions } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ActionOptions, SelectionOptions } from '@perses-dev/plugin-system'; +import { ItemSelectionActionsEditor } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; -import { LogsTableSettingsEditorProps } from './model'; +import type { LogsTableSettingsEditorProps } from './model'; export function LogsTableItemSelectionActionsEditor({ value, onChange }: LogsTableSettingsEditorProps): ReactElement { function handleActionsChange(actions: ActionOptions | undefined): void { diff --git a/logstable/src/LogsTablePanel.test.tsx b/logstable/src/LogsTablePanel.test.tsx index 74a10c476..8d76194a5 100644 --- a/logstable/src/LogsTablePanel.test.tsx +++ b/logstable/src/LogsTablePanel.test.tsx @@ -24,7 +24,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { fireEvent, render, screen } from '@testing-library/react'; import { LogsTablePanel } from './LogsTablePanel'; -import { LogsQueryData, LogsTableProps } from './model'; +import type { LogsQueryData, LogsTableProps } from './model'; import { MOCK_LOGS_QUERY_DEFINITION, MOCK_LOGS_QUERY_RESULT, MOCK_LOGS_QUERY_RESULTS } from './test/mock-query-results'; // Mock clipboard API diff --git a/logstable/src/LogsTablePanel.tsx b/logstable/src/LogsTablePanel.tsx index b624ec3c6..06006fdd5 100644 --- a/logstable/src/LogsTablePanel.tsx +++ b/logstable/src/LogsTablePanel.tsx @@ -13,10 +13,10 @@ import { Box } from '@mui/material'; import { useChartsTheme } from '@perses-dev/components'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { LogsTableComponent } from './LogsTableComponent'; -import { LogsTableProps } from './model'; +import type { LogsTableProps } from './model'; export function LogsTablePanel(props: LogsTableProps): ReactElement { const { contentDimensions, queryResults, spec } = props; diff --git a/logstable/src/LogsTableSettingsEditor.tsx b/logstable/src/LogsTableSettingsEditor.tsx index 8bb8dd271..1dc4443f6 100644 --- a/logstable/src/LogsTableSettingsEditor.tsx +++ b/logstable/src/LogsTableSettingsEditor.tsx @@ -11,16 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - OptionsEditorColumn, - OptionsEditorGrid, - ThresholdsEditor, - ThresholdsEditorProps, -} from '@perses-dev/components'; -import { LegendOptionsEditor, LegendOptionsEditorProps, OptionsEditorProps } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ThresholdsEditorProps } from '@perses-dev/components'; +import { OptionsEditorColumn, OptionsEditorGrid, ThresholdsEditor } from '@perses-dev/components'; +import type { LegendOptionsEditorProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { LegendOptionsEditor } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; -import { LogsTableOptions } from './model'; +import type { LogsTableOptions } from './model'; type LogsTableSettingsEditorProps = OptionsEditorProps; diff --git a/logstable/src/components/LogRow/LogDetailsTable.tsx b/logstable/src/components/LogRow/LogDetailsTable.tsx index 2aaaab8f7..21e299a13 100644 --- a/logstable/src/components/LogRow/LogDetailsTable.tsx +++ b/logstable/src/components/LogRow/LogDetailsTable.tsx @@ -12,7 +12,7 @@ // limitations under the License. import { Table, TableBody, TableRow, TableCell, useTheme, alpha } from '@mui/material'; -import { Labels } from '@perses-dev/spec'; +import type { Labels } from '@perses-dev/spec'; import './ansiColors.css'; import React, { useMemo } from 'react'; diff --git a/logstable/src/components/LogRow/LogRow.test.tsx b/logstable/src/components/LogRow/LogRow.test.tsx index a870eea60..cf2ae9d99 100644 --- a/logstable/src/components/LogRow/LogRow.test.tsx +++ b/logstable/src/components/LogRow/LogRow.test.tsx @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogEntry } from '@perses-dev/spec'; -import { render, screen, waitFor, fireEvent, RenderResult } from '@testing-library/react'; +import type { LogEntry } from '@perses-dev/spec'; +import type { RenderResult } from '@testing-library/react'; +import { render, screen, waitFor, fireEvent } from '@testing-library/react'; import { LogRow } from './LogRow'; diff --git a/logstable/src/components/LogRow/LogRow.tsx b/logstable/src/components/LogRow/LogRow.tsx index 5f4f35315..a18c71573 100644 --- a/logstable/src/components/LogRow/LogRow.tsx +++ b/logstable/src/components/LogRow/LogRow.tsx @@ -22,14 +22,15 @@ import { Tooltip, useTheme, } from '@mui/material'; -import { LogEntry } from '@perses-dev/spec'; +import type { LogEntry } from '@perses-dev/spec'; import Check from 'mdi-material-ui/Check'; import ChevronDown from 'mdi-material-ui/ChevronDown'; import ChevronRight from 'mdi-material-ui/ChevronRight'; import CodeJson from 'mdi-material-ui/CodeJson'; import ContentCopy from 'mdi-material-ui/ContentCopy'; import FormatQuoteClose from 'mdi-material-ui/FormatQuoteClose'; -import React, { memo, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import type { ReactNode } from 'react'; +import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { ansiToSanitizedHtml } from '../../utils/ansi'; import { formatLogAsJson, formatLogEntry, formatLogMessage } from '../../utils/copyHelpers'; diff --git a/logstable/src/components/LogsList.tsx b/logstable/src/components/LogsList.tsx index 551bdff8d..ca16d5c73 100644 --- a/logstable/src/components/LogsList.tsx +++ b/logstable/src/components/LogsList.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogEntry } from '@perses-dev/spec'; +import type { LogEntry } from '@perses-dev/spec'; import React from 'react'; -import { LogsTableOptions } from '../model'; +import type { LogsTableOptions } from '../model'; import { EmptyLogsState } from './EmptyLogsState'; import { useExpandedRows } from './hooks/useExpandedRows'; import { VirtualizedLogsList } from './VirtualizedLogsList'; diff --git a/logstable/src/components/VirtualizedLogsList.tsx b/logstable/src/components/VirtualizedLogsList.tsx index 1ef92e47a..5a2a99b18 100644 --- a/logstable/src/components/VirtualizedLogsList.tsx +++ b/logstable/src/components/VirtualizedLogsList.tsx @@ -14,13 +14,15 @@ import { Box, useTheme, Popover, Button, ButtonGroup, IconButton } from '@mui/material'; import { useSelection } from '@perses-dev/components'; import { formatForDisplay, useSelectionItemActions } from '@perses-dev/dashboards'; -import { ActionOptions, useAllVariableValues } from '@perses-dev/plugin-system'; -import { LogEntry } from '@perses-dev/spec'; +import type { ActionOptions } from '@perses-dev/plugin-system'; +import { useAllVariableValues } from '@perses-dev/plugin-system'; +import type { LogEntry } from '@perses-dev/spec'; import CloseIcon from 'mdi-material-ui/Close'; -import React, { useCallback, useState, useEffect, useRef, ReactNode } from 'react'; +import type { ReactNode } from 'react'; +import React, { useCallback, useState, useEffect, useRef } from 'react'; import { Virtuoso } from 'react-virtuoso'; -import { LogsTableOptions } from '../model'; +import type { LogsTableOptions } from '../model'; import { formatLogEntries, formatLogMessage } from '../utils/copyHelpers'; import { LogRow } from './LogRow'; diff --git a/logstable/src/components/hooks/useSeverity.ts b/logstable/src/components/hooks/useSeverity.ts index 0d29dedd6..8f105233f 100644 --- a/logstable/src/components/hooks/useSeverity.ts +++ b/logstable/src/components/hooks/useSeverity.ts @@ -12,7 +12,7 @@ // limitations under the License. import { useTheme } from '@mui/material'; -import { LogEntry } from '@perses-dev/spec'; +import type { LogEntry } from '@perses-dev/spec'; import { getSeverity } from '../utils'; diff --git a/logstable/src/components/utils.ts b/logstable/src/components/utils.ts index 1f7996153..fd0bc4abd 100644 --- a/logstable/src/components/utils.ts +++ b/logstable/src/components/utils.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogEntry } from '@perses-dev/spec'; +import type { LogEntry } from '@perses-dev/spec'; export type Severity = 'critical' | 'error' | 'warning' | 'info' | 'debug' | 'trace' | 'unknown' | 'other'; diff --git a/logstable/src/getPluginModule.ts b/logstable/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/logstable/src/getPluginModule.ts +++ b/logstable/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/logstable/src/model.ts b/logstable/src/model.ts index 5db2fb156..628fd8bdf 100644 --- a/logstable/src/model.ts +++ b/logstable/src/model.ts @@ -11,15 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ThresholdOptions } from '@perses-dev/components'; -import { +import type { ThresholdOptions } from '@perses-dev/components'; +import type { PanelProps, LegendSpecOptions, SelectionOptions, OptionsEditorProps, ActionOptions, } from '@perses-dev/plugin-system'; -import { LogData } from '@perses-dev/spec'; +import type { LogData } from '@perses-dev/spec'; export type LogsTableProps = PanelProps; diff --git a/logstable/src/test/mock-query-results.ts b/logstable/src/test/mock-query-results.ts index c790ea86e..268b4a134 100644 --- a/logstable/src/test/mock-query-results.ts +++ b/logstable/src/test/mock-query-results.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogsQueryData } from '../model'; +import type { LogsQueryData } from '../model'; export const MOCK_LOGS_QUERY_RESULT: LogsQueryData = { logs: { diff --git a/logstable/src/utils/copyHelpers.test.ts b/logstable/src/utils/copyHelpers.test.ts index 9e26a16cd..a877061ee 100644 --- a/logstable/src/utils/copyHelpers.test.ts +++ b/logstable/src/utils/copyHelpers.test.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogEntry } from '@perses-dev/spec'; +import type { LogEntry } from '@perses-dev/spec'; import { formatTimestamp, diff --git a/logstable/src/utils/copyHelpers.ts b/logstable/src/utils/copyHelpers.ts index 8d3302e4d..2ffa02566 100644 --- a/logstable/src/utils/copyHelpers.ts +++ b/logstable/src/utils/copyHelpers.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogEntry } from '@perses-dev/spec'; +import type { LogEntry } from '@perses-dev/spec'; import { stripAnsi } from './ansi'; diff --git a/logstable/tsconfig.build.json b/logstable/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/logstable/tsconfig.build.json +++ b/logstable/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/logstable/tsconfig.json b/logstable/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/logstable/tsconfig.json +++ b/logstable/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/logstable/vitest.config.ts b/logstable/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/logstable/vitest.config.ts +++ b/logstable/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/loki/package.json b/loki/package.json index dae6254f0..cbbb0d2b2 100644 --- a/loki/package.json +++ b/loki/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -32,10 +32,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/loki/src/components/complete.ts b/loki/src/components/complete.ts index 33e6f3efb..d6787a4e7 100644 --- a/loki/src/components/complete.ts +++ b/loki/src/components/complete.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Completion, CompletionContext, CompletionResult, insertCompletionText } from '@codemirror/autocomplete'; +import type { Completion, CompletionContext, CompletionResult } from '@codemirror/autocomplete'; +import { insertCompletionText } from '@codemirror/autocomplete'; import { syntaxTree } from '@codemirror/language'; -import { EditorState } from '@codemirror/state'; +import type { EditorState } from '@codemirror/state'; import { Selector, Matchers, @@ -26,11 +27,11 @@ import { String as StringType, Pipe, } from '@grafana/lezer-logql'; -import { SyntaxNode, Tree } from '@lezer/common'; -import { EditorView } from '@uiw/react-codemirror'; +import type { SyntaxNode, Tree } from '@lezer/common'; +import type { EditorView } from '@uiw/react-codemirror'; import { toUnixSeconds } from '../model'; -import { CompletionConfig } from './logql-extension'; +import type { CompletionConfig } from './logql-extension'; /** CompletionScope specifies the completion kind, e.g. whether to complete label names or values */ type CompletionScope = diff --git a/loki/src/components/logql-editor.tsx b/loki/src/components/logql-editor.tsx index ada2e4bbe..c42a4f1f1 100644 --- a/loki/src/components/logql-editor.tsx +++ b/loki/src/components/logql-editor.tsx @@ -12,10 +12,13 @@ // limitations under the License. import { useTheme } from '@mui/material'; -import CodeMirror, { EditorView, ReactCodeMirrorProps } from '@uiw/react-codemirror'; -import { ReactElement, useMemo } from 'react'; +import type { ReactCodeMirrorProps } from '@uiw/react-codemirror'; +import CodeMirror, { EditorView } from '@uiw/react-codemirror'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { LogQLExtension, CompletionConfig } from './logql-extension'; +import type { CompletionConfig } from './logql-extension'; +import { LogQLExtension } from './logql-extension'; export type LogQLEditorProps = Omit & { completionConfig?: CompletionConfig; diff --git a/loki/src/components/logql-extension.ts b/loki/src/components/logql-extension.ts index 06acc72aa..3d32c5920 100644 --- a/loki/src/components/logql-extension.ts +++ b/loki/src/components/logql-extension.ts @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CompletionContext } from '@codemirror/autocomplete'; +import type { CompletionContext } from '@codemirror/autocomplete'; import { LRLanguage } from '@codemirror/language'; import { parser } from '@grafana/lezer-logql'; -import { AbsoluteTimeRange } from '@perses-dev/spec'; -import { Extension } from '@uiw/react-codemirror'; +import type { AbsoluteTimeRange } from '@perses-dev/spec'; +import type { Extension } from '@uiw/react-codemirror'; -import { LokiClient } from '../model'; +import type { LokiClient } from '../model'; import { complete } from './complete'; import { logqlHighlight } from './logql-highlight'; diff --git a/loki/src/datasources/loki-datasource/LokiDatasource.tsx b/loki/src/datasources/loki-datasource/LokiDatasource.tsx index a97c1ec14..de636af2f 100644 --- a/loki/src/datasources/loki-datasource/LokiDatasource.tsx +++ b/loki/src/datasources/loki-datasource/LokiDatasource.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { LokiClient } from '../../model/loki-client'; import { - LokiClient, query, queryRange, labels, @@ -24,7 +24,7 @@ import { volumeRange, indexStats, } from '../../model/loki-client'; -import { LokiDatasourceSpec } from './loki-datasource-types'; +import type { LokiDatasourceSpec } from './loki-datasource-types'; import { LokiDatasourceEditor } from './LokiDatasourceEditor'; const createClient: DatasourcePlugin['createClient'] = (spec, options) => { diff --git a/loki/src/datasources/loki-datasource/LokiDatasourceEditor.tsx b/loki/src/datasources/loki-datasource/LokiDatasourceEditor.tsx index 9767458f6..002a4e079 100644 --- a/loki/src/datasources/loki-datasource/LokiDatasourceEditor.tsx +++ b/loki/src/datasources/loki-datasource/LokiDatasourceEditor.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { LokiDatasourceSpec } from './loki-datasource-types'; +import type { LokiDatasourceSpec } from './loki-datasource-types'; export interface LokiDatasourceEditorProps { value: LokiDatasourceSpec; diff --git a/loki/src/datasources/loki-datasource/loki-datasource-types.ts b/loki/src/datasources/loki-datasource/loki-datasource-types.ts index 2cee492c4..6105b442c 100644 --- a/loki/src/datasources/loki-datasource/loki-datasource-types.ts +++ b/loki/src/datasources/loki-datasource/loki-datasource-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { HTTPProxy } from '@perses-dev/spec'; +import type { HTTPProxy } from '@perses-dev/spec'; export interface LokiDatasourceSpec { directUrl?: string; diff --git a/loki/src/getPluginModule.ts b/loki/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/loki/src/getPluginModule.ts +++ b/loki/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/loki/src/model/loki-client.test.ts b/loki/src/model/loki-client.test.ts index 82a332ec8..e621bffc6 100644 --- a/loki/src/model/loki-client.test.ts +++ b/loki/src/model/loki-client.test.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AbsoluteTimeRange } from '@perses-dev/spec'; +import type { AbsoluteTimeRange } from '@perses-dev/spec'; import { toUnixSeconds, getLokiTimeRange, labels, labelValues } from './loki-client'; diff --git a/loki/src/model/loki-client.ts b/loki/src/model/loki-client.ts index 6131b129b..f4c1f05a0 100644 --- a/loki/src/model/loki-client.ts +++ b/loki/src/model/loki-client.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AbsoluteTimeRange } from '@perses-dev/spec'; +import type { AbsoluteTimeRange } from '@perses-dev/spec'; -import { +import type { LokiQueryResponse, LokiQueryRangeResponse, LokiLabelsResponse, diff --git a/loki/src/model/loki-data-types.ts b/loki/src/model/loki-data-types.ts index 0daa42880..e4410a9e6 100644 --- a/loki/src/model/loki-data-types.ts +++ b/loki/src/model/loki-data-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AbsoluteTimeRange, LogData, TimeSeries, TimeSeriesData, TimeSeriesMetadata } from '@perses-dev/spec'; +import type { AbsoluteTimeRange, LogData, TimeSeries, TimeSeriesData, TimeSeriesMetadata } from '@perses-dev/spec'; export interface LokiTimeSeriesData extends TimeSeriesData { logs?: LogData; diff --git a/loki/src/model/loki-selectors.ts b/loki/src/model/loki-selectors.ts index f3340e7fd..67d3762b2 100644 --- a/loki/src/model/loki-selectors.ts +++ b/loki/src/model/loki-selectors.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import { isVariableDatasource } from '@perses-dev/plugin-system'; +import type { DatasourceSelector } from '@perses-dev/spec'; export const LOKI_DATASOURCE_KIND = 'LokiDatasource' as const; diff --git a/loki/src/queries/loki-log-query/LokiLogQuery.tsx b/loki/src/queries/loki-log-query/LokiLogQuery.tsx index 55d513a0f..9365b7a99 100644 --- a/loki/src/queries/loki-log-query/LokiLogQuery.tsx +++ b/loki/src/queries/loki-log-query/LokiLogQuery.tsx @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogQueryPlugin, LogQueryContext, calculateVolumeInterval, parseVariables } from '@perses-dev/plugin-system'; -import { QueryDefinition } from '@perses-dev/spec'; +import type { LogQueryPlugin, LogQueryContext } from '@perses-dev/plugin-system'; +import { calculateVolumeInterval, parseVariables } from '@perses-dev/plugin-system'; +import type { QueryDefinition } from '@perses-dev/spec'; import { getLokiLogData } from './get-loki-log-data'; -import { LokiLogQuerySpec } from './loki-log-query-types'; +import type { LokiLogQuerySpec } from './loki-log-query-types'; import { LokiLogQueryEditor } from './LokiLogQueryEditor'; export const LokiLogQuery: LogQueryPlugin = { diff --git a/loki/src/queries/loki-log-query/LokiLogQueryEditor.tsx b/loki/src/queries/loki-log-query/LokiLogQueryEditor.tsx index 8e9644f9a..5685f9a5d 100644 --- a/loki/src/queries/loki-log-query/LokiLogQueryEditor.tsx +++ b/loki/src/queries/loki-log-query/LokiLogQueryEditor.tsx @@ -14,23 +14,24 @@ import { InputLabel, Stack, ToggleButton, ToggleButtonGroup } from '@mui/material'; import { OptionsEditorControl } from '@perses-dev/components'; import { createModEnterHandler } from '@perses-dev/dashboards'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; import { DatasourceSelect, - DatasourceSelectProps, isVariableDatasource, - OptionsEditorProps, useDatasourceSelectValueToSelector, useDatasourceClient, useTimeRange, } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useMemo } from 'react'; import { LogQLEditor } from '../../components'; -import { isDefaultLokiSelector, LOKI_DATASOURCE_KIND, LokiDatasourceSelector, LokiClient } from '../../model'; +import type { LokiDatasourceSelector, LokiClient } from '../../model'; +import { isDefaultLokiSelector, LOKI_DATASOURCE_KIND } from '../../model'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; import { useQueryState } from '../query-editor-model'; -import { LokiLogQuerySpec } from './loki-log-query-types'; +import type { LokiLogQuerySpec } from './loki-log-query-types'; type LokiQueryEditorProps = OptionsEditorProps; diff --git a/loki/src/queries/loki-log-query/get-loki-log-data.ts b/loki/src/queries/loki-log-query/get-loki-log-data.ts index 8e36f84f4..87cf4c620 100644 --- a/loki/src/queries/loki-log-query/get-loki-log-data.ts +++ b/loki/src/queries/loki-log-query/get-loki-log-data.ts @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { replaceVariables, LogQueryPlugin, LogQueryContext } from '@perses-dev/plugin-system'; -import { LogData, LogEntry } from '@perses-dev/spec'; +import type { LogQueryPlugin, LogQueryContext } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { LogData, LogEntry } from '@perses-dev/spec'; -import { LokiClient } from '../../model/loki-client'; -import { LokiStreamResult } from '../../model/loki-client-types'; +import type { LokiClient } from '../../model/loki-client'; +import type { LokiStreamResult } from '../../model/loki-client-types'; import { DEFAULT_DATASOURCE } from '../constants'; -import { LokiLogQuerySpec } from './loki-log-query-types'; +import type { LokiLogQuerySpec } from './loki-log-query-types'; function convertStreamsToLogs(streams: LokiStreamResult[]): LogData { const entries: LogEntry[] = []; diff --git a/loki/src/queries/loki-log-query/loki-log-query-types.test.ts b/loki/src/queries/loki-log-query/loki-log-query-types.test.ts index f1b50d0f3..0569b0628 100644 --- a/loki/src/queries/loki-log-query/loki-log-query-types.test.ts +++ b/loki/src/queries/loki-log-query/loki-log-query-types.test.ts @@ -11,12 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogQueryContext } from '@perses-dev/plugin-system'; +import type { LogQueryContext } from '@perses-dev/plugin-system'; import type { Mock } from 'vitest'; import { LokiDatasource } from '../../datasources/loki-datasource'; -import { LokiDatasourceSpec } from '../../datasources/loki-datasource/loki-datasource-types'; -import { LokiQueryRangeStreamsResponse, LokiQueryRangeResponse } from '../../model/loki-client-types'; +import type { LokiDatasourceSpec } from '../../datasources/loki-datasource/loki-datasource-types'; +import type { LokiQueryRangeStreamsResponse, LokiQueryRangeResponse } from '../../model/loki-client-types'; import { LokiLogQuery } from './LokiLogQuery'; const datasource: LokiDatasourceSpec = { diff --git a/loki/src/queries/loki-log-query/loki-log-query-types.ts b/loki/src/queries/loki-log-query/loki-log-query-types.ts index c8fa5ef45..43f56cbd4 100644 --- a/loki/src/queries/loki-log-query/loki-log-query-types.ts +++ b/loki/src/queries/loki-log-query/loki-log-query-types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; -import { LokiQueryRangeStreamsResponse } from '../../model/loki-client-types'; +import type { LokiQueryRangeStreamsResponse } from '../../model/loki-client-types'; export interface LokiLogQuerySpec { query: string; diff --git a/loki/src/queries/loki-time-series-query/LokiTimeSeriesQuery.tsx b/loki/src/queries/loki-time-series-query/LokiTimeSeriesQuery.tsx index 7cb4ebb68..823fc0967 100644 --- a/loki/src/queries/loki-time-series-query/LokiTimeSeriesQuery.tsx +++ b/loki/src/queries/loki-time-series-query/LokiTimeSeriesQuery.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, parseVariables } from '@perses-dev/plugin-system'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; import { getLokiTimeSeriesData } from './get-loki-time-series-data'; -import { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types'; +import type { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types'; import { LokiQueryEditor } from './LokiTimeSeriesQueryEditor'; export const LokiTimeSeriesQuery: TimeSeriesQueryPlugin = { diff --git a/loki/src/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.tsx b/loki/src/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.tsx index 7125b9530..27b6c8d0c 100644 --- a/loki/src/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.tsx +++ b/loki/src/queries/loki-time-series-query/LokiTimeSeriesQueryEditor.tsx @@ -13,21 +13,18 @@ import { InputLabel, Stack } from '@mui/material'; import { createModEnterHandler } from '@perses-dev/dashboards'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; import { LogQLEditor } from '../../components'; -import { LOKI_DATASOURCE_KIND, LokiDatasourceSelector } from '../../model'; +import type { LokiDatasourceSelector } from '../../model'; +import { LOKI_DATASOURCE_KIND } from '../../model'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; import { useQueryState } from '../query-editor-model'; -import { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types'; +import type { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types'; type LokiQueryEditorProps = OptionsEditorProps; diff --git a/loki/src/queries/loki-time-series-query/get-loki-time-series-data.ts b/loki/src/queries/loki-time-series-query/get-loki-time-series-data.ts index 82f95ef6a..6eab2a362 100644 --- a/loki/src/queries/loki-time-series-query/get-loki-time-series-data.ts +++ b/loki/src/queries/loki-time-series-query/get-loki-time-series-data.ts @@ -11,14 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, replaceVariables } from '@perses-dev/plugin-system'; -import { DurationString, parseDurationString, TimeSeries } from '@perses-dev/spec'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { DurationString, TimeSeries } from '@perses-dev/spec'; +import { parseDurationString } from '@perses-dev/spec'; import { milliseconds } from 'date-fns'; -import { LokiClient, toUnixSeconds } from '../../model/loki-client'; -import { LokiMatrixResult, LokiVectorResult } from '../../model/loki-client-types'; +import type { LokiClient } from '../../model/loki-client'; +import { toUnixSeconds } from '../../model/loki-client'; +import type { LokiMatrixResult, LokiVectorResult } from '../../model/loki-client-types'; import { DEFAULT_DATASOURCE } from '../constants'; -import { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types'; +import type { LokiTimeSeriesQuerySpec } from './loki-time-series-query-types'; export type LokiMatrixResponse = { resultType: 'matrix'; diff --git a/loki/src/queries/loki-time-series-query/loki-time-series-query-types.test.ts b/loki/src/queries/loki-time-series-query/loki-time-series-query-types.test.ts index b211989b8..7072f3196 100644 --- a/loki/src/queries/loki-time-series-query/loki-time-series-query-types.test.ts +++ b/loki/src/queries/loki-time-series-query/loki-time-series-query-types.test.ts @@ -15,13 +15,17 @@ vi.mock('echarts/core'); -import { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock } from 'vitest'; import { LokiDatasource } from '../../datasources/loki-datasource'; -import { LokiDatasourceSpec } from '../../datasources/loki-datasource/loki-datasource-types'; -import { LokiQueryRangeMatrixResponse, LokiQueryRangeResponse, LokiQueryResponse } from '../../model/loki-client-types'; +import type { LokiDatasourceSpec } from '../../datasources/loki-datasource/loki-datasource-types'; +import type { + LokiQueryRangeMatrixResponse, + LokiQueryRangeResponse, + LokiQueryResponse, +} from '../../model/loki-client-types'; import { LokiTimeSeriesQuery } from './LokiTimeSeriesQuery'; const datasource: LokiDatasourceSpec = { diff --git a/loki/src/queries/loki-time-series-query/loki-time-series-query-types.ts b/loki/src/queries/loki-time-series-query/loki-time-series-query-types.ts index af5ec3c7e..887308a73 100644 --- a/loki/src/queries/loki-time-series-query/loki-time-series-query-types.ts +++ b/loki/src/queries/loki-time-series-query/loki-time-series-query-types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; -import { LokiQueryRangeMatrixResponse, LokiQueryResponse } from '../../model/loki-client-types'; +import type { LokiQueryRangeMatrixResponse, LokiQueryResponse } from '../../model/loki-client-types'; export interface LokiTimeSeriesQuerySpec { query: string; diff --git a/loki/src/queries/query-editor-model.ts b/loki/src/queries/query-editor-model.ts index c14dee91d..61df71037 100644 --- a/loki/src/queries/query-editor-model.ts +++ b/loki/src/queries/query-editor-model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import { useState } from 'react'; diff --git a/loki/src/variables/LokiLabelNamesVariable.tsx b/loki/src/variables/LokiLabelNamesVariable.tsx index fc4c06911..81638792b 100644 --- a/loki/src/variables/LokiLabelNamesVariable.tsx +++ b/loki/src/variables/LokiLabelNamesVariable.tsx @@ -11,17 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { VariablePlugin } from '@perses-dev/plugin-system'; import { - VariablePlugin, replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource, } from '@perses-dev/plugin-system'; -import { LokiClient, DEFAULT_LOKI, getLokiTimeRange, LOKI_DATASOURCE_KIND } from '../model'; +import type { LokiClient } from '../model'; +import { DEFAULT_LOKI, getLokiTimeRange, LOKI_DATASOURCE_KIND } from '../model'; import { stringArrayToVariableOptions, LokiLabelNamesVariableEditor } from './loki-variables'; -import { LokiLabelNamesVariableOptions } from './types'; +import type { LokiLabelNamesVariableOptions } from './types'; export const LokiLabelNamesVariable: VariablePlugin = { getVariableOptions: async (spec, ctx) => { diff --git a/loki/src/variables/LokiLabelValuesVariable.tsx b/loki/src/variables/LokiLabelValuesVariable.tsx index f317d2011..3dc960ea1 100644 --- a/loki/src/variables/LokiLabelValuesVariable.tsx +++ b/loki/src/variables/LokiLabelValuesVariable.tsx @@ -11,17 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { VariablePlugin } from '@perses-dev/plugin-system'; import { - VariablePlugin, replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource, } from '@perses-dev/plugin-system'; -import { LokiClient, DEFAULT_LOKI, getLokiTimeRange, LOKI_DATASOURCE_KIND } from '../model'; +import type { LokiClient } from '../model'; +import { DEFAULT_LOKI, getLokiTimeRange, LOKI_DATASOURCE_KIND } from '../model'; import { stringArrayToVariableOptions, LokiLabelValuesVariableEditor } from './loki-variables'; -import { LokiLabelValuesVariableOptions } from './types'; +import type { LokiLabelValuesVariableOptions } from './types'; export const LokiLabelValuesVariable: VariablePlugin = { getVariableOptions: async (spec, ctx) => { diff --git a/loki/src/variables/LokiLogQLVariable.tsx b/loki/src/variables/LokiLogQLVariable.tsx index 33cf0fbdf..e6f27d469 100644 --- a/loki/src/variables/LokiLogQLVariable.tsx +++ b/loki/src/variables/LokiLogQLVariable.tsx @@ -11,22 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { VariablePlugin } from '@perses-dev/plugin-system'; import { - VariablePlugin, replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource, } from '@perses-dev/plugin-system'; -import { LokiClient, DEFAULT_LOKI, LOKI_DATASOURCE_KIND, getLokiTimeRange } from '../model'; +import type { LokiClient } from '../model'; +import { DEFAULT_LOKI, LOKI_DATASOURCE_KIND, getLokiTimeRange } from '../model'; import { capturingMetric, capturingStreams, stringArrayToVariableOptions, LokiLogQLVariableEditor, } from './loki-variables'; -import { LokiLogQLVariableOptions } from './types'; +import type { LokiLogQLVariableOptions } from './types'; export const LokiLogQLVariable: VariablePlugin = { getVariableOptions: async (spec, ctx) => { diff --git a/loki/src/variables/MatcherEditor.tsx b/loki/src/variables/MatcherEditor.tsx index d1c4c8d29..e2ad1b3e0 100644 --- a/loki/src/variables/MatcherEditor.tsx +++ b/loki/src/variables/MatcherEditor.tsx @@ -14,7 +14,7 @@ import { Stack, TextField, Button, IconButton } from '@mui/material'; import { produce } from 'immer'; import TrashIcon from 'mdi-material-ui/TrashCan'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; type MatcherEditorProps = { matchers: string[]; diff --git a/loki/src/variables/loki-variables.test.ts b/loki/src/variables/loki-variables.test.ts index 90164f356..f2f4d9751 100644 --- a/loki/src/variables/loki-variables.test.ts +++ b/loki/src/variables/loki-variables.test.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { GetVariableOptionsContext } from '@perses-dev/plugin-system'; +import type { GetVariableOptionsContext } from '@perses-dev/plugin-system'; -import { LokiStreamResult } from '../model/loki-client-types'; +import type { LokiStreamResult } from '../model/loki-client-types'; import { stringArrayToVariableOptions, capturingMetric, capturingStreams } from './loki-variables'; import { LokiLabelNamesVariable } from './LokiLabelNamesVariable'; import { LokiLabelValuesVariable } from './LokiLabelValuesVariable'; diff --git a/loki/src/variables/loki-variables.tsx b/loki/src/variables/loki-variables.tsx index 51f644c8d..9da96c5e3 100644 --- a/loki/src/variables/loki-variables.tsx +++ b/loki/src/variables/loki-variables.tsx @@ -12,30 +12,22 @@ // limitations under the License. import { FormControl, Stack, TextField } from '@mui/material'; +import type { DatasourceSelectProps, OptionsEditorProps, VariableOption } from '@perses-dev/plugin-system'; import { DatasourceSelect, - DatasourceSelectProps, isVariableDatasource, - OptionsEditorProps, useDatasourceClient, useDatasourceSelectValueToSelector, - VariableOption, } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback, ChangeEvent, FocusEvent } from 'react'; +import type { ReactElement, ChangeEvent, FocusEvent } from 'react'; +import { useCallback } from 'react'; import { LogQLEditor } from '../components'; -import { - DEFAULT_LOKI, - isDefaultLokiSelector, - isLokiDatasourceSelector, - LOKI_DATASOURCE_KIND, - LokiDatasourceSelector, - LokiClient, - LokiStreamResult, -} from '../model'; +import type { LokiDatasourceSelector, LokiClient, LokiStreamResult } from '../model'; +import { DEFAULT_LOKI, isDefaultLokiSelector, isLokiDatasourceSelector, LOKI_DATASOURCE_KIND } from '../model'; import { MatcherEditor } from './MatcherEditor'; -import { +import type { LokiLabelNamesVariableOptions, LokiLabelValuesVariableOptions, LokiLogQLVariableOptions, diff --git a/loki/src/variables/types.ts b/loki/src/variables/types.ts index d27fb0a6d..dad8d529a 100644 --- a/loki/src/variables/types.ts +++ b/loki/src/variables/types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; -import { LokiDatasourceSelector } from '../model/loki-selectors'; +import type { LokiDatasourceSelector } from '../model/loki-selectors'; export interface LokiVariableOptionsBase { datasource?: DatasourceSelectValue; diff --git a/loki/tsconfig.build.json b/loki/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/loki/tsconfig.build.json +++ b/loki/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/loki/tsconfig.json b/loki/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/loki/tsconfig.json +++ b/loki/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/loki/vitest.config.ts b/loki/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/loki/vitest.config.ts +++ b/loki/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/markdown/package.json b/markdown/package.json index a3f6cd250..277d16828 100644 --- a/markdown/package.json +++ b/markdown/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -33,8 +33,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/markdown/src/Markdown.ts b/markdown/src/Markdown.ts index 31df3563d..80284a63b 100644 --- a/markdown/src/Markdown.ts +++ b/markdown/src/Markdown.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { createInitialMarkdownPanelOptions, MarkdownPanelOptions } from './markdown-panel-model'; +import type { MarkdownPanelOptions } from './markdown-panel-model'; +import { createInitialMarkdownPanelOptions } from './markdown-panel-model'; import { MarkdownPanel } from './MarkdownPanel'; import { MarkdownPanelOptionsEditor } from './MarkdownPanelOptionsEditor'; diff --git a/markdown/src/MarkdownPanel.tsx b/markdown/src/MarkdownPanel.tsx index d2f9e286f..4ff9a46b3 100644 --- a/markdown/src/MarkdownPanel.tsx +++ b/markdown/src/MarkdownPanel.tsx @@ -11,14 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Box, Theme } from '@mui/material'; -import { PersesChartsTheme, useChartsTheme } from '@perses-dev/components'; -import { PanelProps, useReplaceVariablesInString } from '@perses-dev/plugin-system'; +import type { Theme } from '@mui/material'; +import { Box } from '@mui/material'; +import type { PersesChartsTheme } from '@perses-dev/components'; +import { useChartsTheme } from '@perses-dev/components'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import { useReplaceVariablesInString } from '@perses-dev/plugin-system'; import DOMPurify from 'dompurify'; import { marked } from 'marked'; -import React, { ReactElement, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import React, { useMemo } from 'react'; -import { MarkdownPanelOptions } from './markdown-panel-model'; +import type { MarkdownPanelOptions } from './markdown-panel-model'; export type MarkdownPanelProps = PanelProps; diff --git a/markdown/src/MarkdownPanelOptionsEditor.tsx b/markdown/src/MarkdownPanelOptionsEditor.tsx index 8d8bd2145..e2e94b97f 100644 --- a/markdown/src/MarkdownPanelOptionsEditor.tsx +++ b/markdown/src/MarkdownPanelOptionsEditor.tsx @@ -12,10 +12,10 @@ // limitations under the License. import { Link, Stack, TextField } from '@mui/material'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { ChangeEvent, ReactElement } from 'react'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { ChangeEvent, ReactElement } from 'react'; -import { MarkdownPanelOptions } from './markdown-panel-model'; +import type { MarkdownPanelOptions } from './markdown-panel-model'; export type MarkdownPanelOptionsEditorProps = OptionsEditorProps; diff --git a/markdown/src/getPluginModule.ts b/markdown/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/markdown/src/getPluginModule.ts +++ b/markdown/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/markdown/src/markdown-panel-model.ts b/markdown/src/markdown-panel-model.ts index 42135ec4f..8d8dd3be4 100644 --- a/markdown/src/markdown-panel-model.ts +++ b/markdown/src/markdown-panel-model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Definition } from '@perses-dev/spec'; +import type { Definition } from '@perses-dev/spec'; /** * The schema for a Markdown panel. diff --git a/markdown/tsconfig.build.json b/markdown/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/markdown/tsconfig.build.json +++ b/markdown/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/markdown/tsconfig.json b/markdown/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/markdown/tsconfig.json +++ b/markdown/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/markdown/vitest.config.ts b/markdown/vitest.config.ts index 66516c66b..6fc8ebf97 100644 --- a/markdown/vitest.config.ts +++ b/markdown/vitest.config.ts @@ -11,12 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, passWithNoTests: true, setupFiles: ['src/setup-tests.ts'], }); diff --git a/opensearch/package.json b/opensearch/package.json index 97e9ace70..4dccd9af8 100644 --- a/opensearch/package.json +++ b/opensearch/package.json @@ -15,14 +15,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -30,10 +30,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/opensearch/src/datasources/opensearch-datasource/OpenSearchDatasource.tsx b/opensearch/src/datasources/opensearch-datasource/OpenSearchDatasource.tsx index 48917c0fe..00e0f8f56 100644 --- a/opensearch/src/datasources/opensearch-datasource/OpenSearchDatasource.tsx +++ b/opensearch/src/datasources/opensearch-datasource/OpenSearchDatasource.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; -import { OpenSearchClient, ppl } from '../../model/opensearch-client'; -import { OpenSearchDatasourceSpec } from './opensearch-datasource-types'; +import type { OpenSearchClient } from '../../model/opensearch-client'; +import { ppl } from '../../model/opensearch-client'; +import type { OpenSearchDatasourceSpec } from './opensearch-datasource-types'; import { OpenSearchDatasourceEditor } from './OpenSearchDatasourceEditor'; const createClient: DatasourcePlugin['createClient'] = (spec, options) => { diff --git a/opensearch/src/datasources/opensearch-datasource/OpenSearchDatasourceEditor.tsx b/opensearch/src/datasources/opensearch-datasource/OpenSearchDatasourceEditor.tsx index 5d97e3165..fe91dd8f6 100644 --- a/opensearch/src/datasources/opensearch-datasource/OpenSearchDatasourceEditor.tsx +++ b/opensearch/src/datasources/opensearch-datasource/OpenSearchDatasourceEditor.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { OpenSearchDatasourceSpec } from './opensearch-datasource-types'; +import type { OpenSearchDatasourceSpec } from './opensearch-datasource-types'; export interface OpenSearchDatasourceEditorProps { value: OpenSearchDatasourceSpec; diff --git a/opensearch/src/datasources/opensearch-datasource/opensearch-datasource-types.ts b/opensearch/src/datasources/opensearch-datasource/opensearch-datasource-types.ts index d3a588fcb..de4b9357d 100644 --- a/opensearch/src/datasources/opensearch-datasource/opensearch-datasource-types.ts +++ b/opensearch/src/datasources/opensearch-datasource/opensearch-datasource-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { HTTPProxy } from '@perses-dev/spec'; +import type { HTTPProxy } from '@perses-dev/spec'; export interface OpenSearchDatasourceSpec { directUrl?: string; diff --git a/opensearch/src/getPluginModule.ts b/opensearch/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/opensearch/src/getPluginModule.ts +++ b/opensearch/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/opensearch/src/model/opensearch-client.ts b/opensearch/src/model/opensearch-client.ts index 8a286eaa5..6eee66fee 100644 --- a/opensearch/src/model/opensearch-client.ts +++ b/opensearch/src/model/opensearch-client.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OpenSearchPPLResponse, OpenSearchRequestHeaders } from './opensearch-client-types'; +import type { OpenSearchPPLResponse, OpenSearchRequestHeaders } from './opensearch-client-types'; export interface OpenSearchPPLParams { query: string; diff --git a/opensearch/src/model/opensearch-selectors.ts b/opensearch/src/model/opensearch-selectors.ts index 1fe6356a4..8b1e1e8de 100644 --- a/opensearch/src/model/opensearch-selectors.ts +++ b/opensearch/src/model/opensearch-selectors.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import { isVariableDatasource } from '@perses-dev/plugin-system'; +import type { DatasourceSelector } from '@perses-dev/spec'; export const OPENSEARCH_DATASOURCE_KIND = 'OpenSearchDatasource' as const; diff --git a/opensearch/src/queries/opensearch-log-query/OpenSearchLogQuery.tsx b/opensearch/src/queries/opensearch-log-query/OpenSearchLogQuery.tsx index 83da38d4f..94963ab9a 100644 --- a/opensearch/src/queries/opensearch-log-query/OpenSearchLogQuery.tsx +++ b/opensearch/src/queries/opensearch-log-query/OpenSearchLogQuery.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { parseVariables, LogQueryPlugin } from '@perses-dev/plugin-system'; +import type { LogQueryPlugin } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; import { getOpenSearchLogData } from './get-opensearch-log-data'; -import { OpenSearchLogQuerySpec } from './opensearch-log-query-types'; +import type { OpenSearchLogQuerySpec } from './opensearch-log-query-types'; import { OpenSearchLogQueryEditor } from './OpenSearchLogQueryEditor'; export const OpenSearchLogQuery: LogQueryPlugin = { diff --git a/opensearch/src/queries/opensearch-log-query/OpenSearchLogQueryEditor.test.tsx b/opensearch/src/queries/opensearch-log-query/OpenSearchLogQueryEditor.test.tsx index a38122120..4b924feb3 100644 --- a/opensearch/src/queries/opensearch-log-query/OpenSearchLogQueryEditor.test.tsx +++ b/opensearch/src/queries/opensearch-log-query/OpenSearchLogQueryEditor.test.tsx @@ -11,15 +11,16 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type * as PluginSystemModule from '@perses-dev/plugin-system'; import { render, screen, fireEvent } from '@testing-library/react'; import type { Mock } from 'vitest'; import { PPL_DOCS_URL } from '../constants'; -import { OpenSearchLogQuerySpec } from './opensearch-log-query-types'; +import type { OpenSearchLogQuerySpec } from './opensearch-log-query-types'; import { OpenSearchLogQueryEditor } from './OpenSearchLogQueryEditor'; vi.mock('@perses-dev/plugin-system', async (importOriginal) => ({ - ...(await importOriginal()), + ...(await importOriginal()), DatasourceSelect: (): JSX.Element =>
, useDatasourceSelectValueToSelector: (): undefined => undefined, isVariableDatasource: (): boolean => false, diff --git a/opensearch/src/queries/opensearch-log-query/OpenSearchLogQueryEditor.tsx b/opensearch/src/queries/opensearch-log-query/OpenSearchLogQueryEditor.tsx index 9400e50c7..b048bcc43 100644 --- a/opensearch/src/queries/opensearch-log-query/OpenSearchLogQueryEditor.tsx +++ b/opensearch/src/queries/opensearch-log-query/OpenSearchLogQueryEditor.tsx @@ -13,20 +13,16 @@ import { Box, Checkbox, FormControlLabel, InputLabel, Link, Stack, TextField, Typography } from '@mui/material'; import { createModEnterHandler } from '@perses-dev/dashboards'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { isDefaultOpenSearchSelector, OPENSEARCH_DATASOURCE_KIND, OpenSearchDatasourceSelector } from '../../model'; +import type { OpenSearchDatasourceSelector } from '../../model'; +import { isDefaultOpenSearchSelector, OPENSEARCH_DATASOURCE_KIND } from '../../model'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE, PPL_DOCS_URL, PPL_QUERY_EXAMPLES } from '../constants'; import { useQueryState } from '../query-editor-model'; -import { OpenSearchLogQuerySpec } from './opensearch-log-query-types'; +import type { OpenSearchLogQuerySpec } from './opensearch-log-query-types'; type OpenSearchQueryEditorProps = OptionsEditorProps; diff --git a/opensearch/src/queries/opensearch-log-query/get-opensearch-log-data.test.ts b/opensearch/src/queries/opensearch-log-query/get-opensearch-log-data.test.ts index 76f8b8188..84e892511 100644 --- a/opensearch/src/queries/opensearch-log-query/get-opensearch-log-data.test.ts +++ b/opensearch/src/queries/opensearch-log-query/get-opensearch-log-data.test.ts @@ -11,12 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogQueryContext } from '@perses-dev/plugin-system'; +import type { LogQueryContext } from '@perses-dev/plugin-system'; import type { Mock } from 'vitest'; import { OpenSearchDatasource } from '../../datasources/opensearch-datasource'; -import { OpenSearchDatasourceSpec } from '../../datasources/opensearch-datasource/opensearch-datasource-types'; -import { OpenSearchPPLResponse } from '../../model/opensearch-client-types'; +import type { OpenSearchDatasourceSpec } from '../../datasources/opensearch-datasource/opensearch-datasource-types'; +import type { OpenSearchPPLResponse } from '../../model/opensearch-client-types'; import { buildBoundedPPL, convertPPLToLogs, parseTimestamp } from './get-opensearch-log-data'; import { OpenSearchLogQuery } from './OpenSearchLogQuery'; diff --git a/opensearch/src/queries/opensearch-log-query/get-opensearch-log-data.ts b/opensearch/src/queries/opensearch-log-query/get-opensearch-log-data.ts index c37c16bf3..af085d7a6 100644 --- a/opensearch/src/queries/opensearch-log-query/get-opensearch-log-data.ts +++ b/opensearch/src/queries/opensearch-log-query/get-opensearch-log-data.ts @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { replaceVariables, LogQueryPlugin, LogQueryContext } from '@perses-dev/plugin-system'; -import { LogEntry, LogData } from '@perses-dev/spec'; +import type { LogQueryPlugin, LogQueryContext } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { LogEntry, LogData } from '@perses-dev/spec'; -import { OpenSearchClient } from '../../model/opensearch-client'; -import { OpenSearchPPLResponse } from '../../model/opensearch-client-types'; +import type { OpenSearchClient } from '../../model/opensearch-client'; +import type { OpenSearchPPLResponse } from '../../model/opensearch-client-types'; import { DEFAULT_DATASOURCE, DEFAULT_MESSAGE_FIELDS, DEFAULT_TIMESTAMP_FIELDS } from '../constants'; -import { OpenSearchLogQuerySpec } from './opensearch-log-query-types'; +import type { OpenSearchLogQuerySpec } from './opensearch-log-query-types'; /** * Bound the query to the panel time range using a PPL `where` clause on the diff --git a/opensearch/src/queries/opensearch-log-query/opensearch-log-query-types.ts b/opensearch/src/queries/opensearch-log-query/opensearch-log-query-types.ts index f8608f048..386360994 100644 --- a/opensearch/src/queries/opensearch-log-query/opensearch-log-query-types.ts +++ b/opensearch/src/queries/opensearch-log-query/opensearch-log-query-types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; -import { OpenSearchPPLResponse } from '../../model/opensearch-client-types'; +import type { OpenSearchPPLResponse } from '../../model/opensearch-client-types'; export interface OpenSearchLogQuerySpec { query: string; diff --git a/opensearch/src/queries/query-editor-model.ts b/opensearch/src/queries/query-editor-model.ts index 01289460a..f8c056274 100644 --- a/opensearch/src/queries/query-editor-model.ts +++ b/opensearch/src/queries/query-editor-model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import { useState } from 'react'; diff --git a/opensearch/tsconfig.build.json b/opensearch/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/opensearch/tsconfig.build.json +++ b/opensearch/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/opensearch/tsconfig.json b/opensearch/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/opensearch/tsconfig.json +++ b/opensearch/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/opensearch/vitest.config.ts b/opensearch/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/opensearch/vitest.config.ts +++ b/opensearch/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/package-lock.json b/package-lock.json index d63fb6747..293d4c5da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,12 +42,12 @@ ], "devDependencies": { "@module-federation/rsbuild-plugin": "^2.6.0", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/client": "^0.55.0-beta.6", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@rsbuild/core": "^1.6.7", "@rsbuild/plugin-react": "^1.4.2", "@swc/cli": "^0.8.1", @@ -77,6 +77,10 @@ "typescript": "^5.4.2", "vitest": "^4.1.11" }, + "engines": { + "node": ">=24", + "npm": ">=11" + }, "peerDependencies": { "@types/react-dom": "^18.3.0", "react": "^17.0.2 || ^18.0.0", @@ -91,10 +95,10 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "lodash": "^4.17.21", @@ -111,8 +115,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -131,12 +135,12 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/client": "^0.55.0-beta.6", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -158,7 +162,7 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", + "@perses-dev/plugin-system": "^0.55.0-beta.6", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -173,19 +177,23 @@ "version": "0.2.0-beta.0", "devDependencies": { "@playwright/test": "^1.58.2", - "@types/node": "^25.2.3" + "@types/node": "^24.0.0" } }, "e2e/node_modules/@types/node": { - "version": "25.9.4", + "version": "24.13.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.13.3.tgz", + "integrity": "sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": ">=7.24.0 <7.24.7" + "undici-types": "~7.18.0" } }, "e2e/node_modules/undici-types": { - "version": "7.24.6", + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz", + "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==", "dev": true, "license": "MIT" }, @@ -201,8 +209,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-table": "^8.20.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -223,8 +231,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -243,11 +251,11 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/client": "^0.55.0-beta.6", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -266,8 +274,8 @@ "license": "Apache-2.0", "peerDependencies": { "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "echarts": "5.5.0", "immer": "^10.1.1", "lodash": "^4.17.21", @@ -281,8 +289,8 @@ "license": "Apache-2.0", "peerDependencies": { "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "echarts": "5.5.0", "immer": "^10.1.1", "lodash": "^4.17.21", @@ -298,12 +306,12 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/client": "^0.55.0-beta.6", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -327,10 +335,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -356,9 +364,9 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -380,10 +388,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -409,8 +417,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -3237,12 +3245,12 @@ "link": true }, "node_modules/@perses-dev/client": { - "version": "0.55.0-beta.3", - "resolved": "https://registry.npmjs.org/@perses-dev/client/-/client-0.55.0-beta.3.tgz", - "integrity": "sha512-oTvdGFzu/IH559Saz/0gDu3hego7G1W+YkSpd/nDVcWQuF7JAvzYTvhZhU5mxGO1QQeEs2c6mR0ySXNlDgzeEQ==", + "version": "0.55.0-beta.6", + "resolved": "https://registry.npmjs.org/@perses-dev/client/-/client-0.55.0-beta.6.tgz", + "integrity": "sha512-6U8k0WFv6v3T628eLmhgSrEMXnVYhj7dVjJTdJ9rEt4tjqOlGFyp0Hf3EMZ/ZrfeisU+06RkgjQvhRfOSpYy3A==", "license": "Apache-2.0", "dependencies": { - "@perses-dev/spec": "0.3.0-beta.4", + "@perses-dev/spec": "0.3.0-beta.5", "zod": "^3.21.4" }, "peerDependencies": { @@ -3250,9 +3258,9 @@ } }, "node_modules/@perses-dev/components": { - "version": "0.55.0-beta.3", - "resolved": "https://registry.npmjs.org/@perses-dev/components/-/components-0.55.0-beta.3.tgz", - "integrity": "sha512-t+zvO/TpEp/kZaxIBxUeDzc95DymZdjAc2dgXnNiXtIWz+WxcV17EvIAtGi4zKQtkybuOXRODlj8C0ZvE1C6vg==", + "version": "0.55.0-beta.6", + "resolved": "https://registry.npmjs.org/@perses-dev/components/-/components-0.55.0-beta.6.tgz", + "integrity": "sha512-a9wh/FMKVmcnbG0TgSNE+n39artwS3gag/0TiMI8TLvU9qEfrzOTMvQVHOTWfcj6PDKKCC5lEEPjFVkqi2vDiQ==", "license": "Apache-2.0", "dependencies": { "@atlaskit/pragmatic-drag-and-drop": "^1.4.0", @@ -3261,8 +3269,8 @@ "@date-fns/tz": "^1.4.1", "@fontsource/inter": "^5.0.0", "@mui/x-date-pickers": "^7.23.1", - "@perses-dev/client": "0.55.0-beta.3", - "@perses-dev/spec": "0.3.0-beta.4", + "@perses-dev/client": "0.55.0-beta.6", + "@perses-dev/spec": "0.3.0-beta.5", "@tanstack/match-sorter-utils": "^8.19.4", "@tanstack/react-table": "^8.20.5", "@uiw/react-codemirror": "^4.19.1", @@ -3288,15 +3296,15 @@ } }, "node_modules/@perses-dev/dashboards": { - "version": "0.55.0-beta.3", - "resolved": "https://registry.npmjs.org/@perses-dev/dashboards/-/dashboards-0.55.0-beta.3.tgz", - "integrity": "sha512-6fx18SkQXdN+hIZTyTAtzkuy1Y8SzIdheYSiqUwGfIPuEpGOYFzYMF4h+WFCEvB5udvpwmO/MJoo4T6hN9nouQ==", + "version": "0.55.0-beta.6", + "resolved": "https://registry.npmjs.org/@perses-dev/dashboards/-/dashboards-0.55.0-beta.6.tgz", + "integrity": "sha512-3X9/2NvzyLDzpdpktvGK4BBmzsTlla8IF/uwag/30llDg8rfQwVlDPtdxhmXaAhpWxsN56pCdzXC897GVHOeZA==", "license": "Apache-2.0", "dependencies": { - "@perses-dev/client": "0.55.0-beta.3", - "@perses-dev/components": "0.55.0-beta.3", - "@perses-dev/plugin-system": "0.55.0-beta.3", - "@perses-dev/spec": "0.3.0-beta.4", + "@perses-dev/client": "0.55.0-beta.6", + "@perses-dev/components": "0.55.0-beta.6", + "@perses-dev/plugin-system": "0.55.0-beta.6", + "@perses-dev/spec": "0.3.0-beta.5", "@tanstack/hotkeys": "^0.8.0", "@tanstack/react-hotkeys": "^0.9.1", "immer": "^10.1.1", @@ -3322,15 +3330,15 @@ "link": true }, "node_modules/@perses-dev/explore": { - "version": "0.55.0-beta.3", - "resolved": "https://registry.npmjs.org/@perses-dev/explore/-/explore-0.55.0-beta.3.tgz", - "integrity": "sha512-nRSlHk/Foraz3HInQqR+BGM0rmnLG4RI5L2kvtKRXUqBwlu0+LrT3sVOfS28xubww6YaZQht/B5NxqzEt7yWDA==", + "version": "0.55.0-beta.6", + "resolved": "https://registry.npmjs.org/@perses-dev/explore/-/explore-0.55.0-beta.6.tgz", + "integrity": "sha512-Bynsv3X3ASsNWPDEGunUgMLKC7nokogmJ6OvviiTR4kmIVt1jECDFgkUt8L7rCORY4KJRNyEAp/PTK047FmWHQ==", "license": "Apache-2.0", "dependencies": { "@nexucis/fuzzy": "^0.5.1", - "@perses-dev/components": "0.55.0-beta.3", - "@perses-dev/dashboards": "0.55.0-beta.3", - "@perses-dev/plugin-system": "0.55.0-beta.3", + "@perses-dev/components": "0.55.0-beta.6", + "@perses-dev/dashboards": "0.55.0-beta.6", + "@perses-dev/plugin-system": "0.55.0-beta.6", "mdi-material-ui": "^7.9.2", "qs": "^6.14.0", "react-virtuoso": "^4.12.2", @@ -3393,15 +3401,15 @@ "link": true }, "node_modules/@perses-dev/plugin-system": { - "version": "0.55.0-beta.3", - "resolved": "https://registry.npmjs.org/@perses-dev/plugin-system/-/plugin-system-0.55.0-beta.3.tgz", - "integrity": "sha512-oZddkeMpJcYY/ezKHJWls93BW54WWBccVXcfAcexfUNIurdSlo/VLVJILboNInJWB5wJyCCrfiO8eUCFzYT8gA==", + "version": "0.55.0-beta.6", + "resolved": "https://registry.npmjs.org/@perses-dev/plugin-system/-/plugin-system-0.55.0-beta.6.tgz", + "integrity": "sha512-LJ/Hu0BKH8pxUUELLK6C7ruenQcEodMZCDKVN+9mJm4TjNCtiHqGwXBdsKu0TEMPvqNHOra5ID/268iQuN6A1Q==", "license": "Apache-2.0", "dependencies": { "@module-federation/enhanced": "^2.8.0", - "@perses-dev/client": "0.55.0-beta.3", - "@perses-dev/components": "0.55.0-beta.3", - "@perses-dev/spec": "0.3.0-beta.4", + "@perses-dev/client": "0.55.0-beta.6", + "@perses-dev/components": "0.55.0-beta.6", + "@perses-dev/spec": "0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "immer": "^10.1.1", @@ -3676,9 +3684,9 @@ "link": true }, "node_modules/@perses-dev/spec": { - "version": "0.3.0-beta.4", - "resolved": "https://registry.npmjs.org/@perses-dev/spec/-/spec-0.3.0-beta.4.tgz", - "integrity": "sha512-6SSKTYXYxHJkPu0kcp6lggxvA9miL5jRZmolKXyYGgBYfTFcjkX5JgjYacXIyvMOQHcs32YQGSh5nQz3uS4RBg==", + "version": "0.3.0-beta.5", + "resolved": "https://registry.npmjs.org/@perses-dev/spec/-/spec-0.3.0-beta.5.tgz", + "integrity": "sha512-ZBUUe2wU4/Yvf5nhF+FcCWUmSd07jMhNkYTO3pwtJ5BEmHMEszEPzw8xpzQupPSjYdtwWyum+w0sXgE2rMVjWg==", "license": "Apache-2.0", "dependencies": { "date-fns": "^4.1.0", @@ -11055,10 +11063,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -11080,8 +11088,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11110,12 +11118,12 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/client": "^0.55.0-beta.6", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -11141,12 +11149,12 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/client": "^0.55.0-beta.6", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "@uiw/react-codemirror": "^4.19.1", "date-fns": "^4.1.0", @@ -11175,8 +11183,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11193,8 +11201,8 @@ "devDependencies": {}, "peerDependencies": { "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "immer": "^10.1.1", "react": "^17.0.2 || ^18.0.0" } @@ -11214,8 +11222,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11238,7 +11246,7 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", + "@perses-dev/plugin-system": "^0.55.0-beta.6", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11257,8 +11265,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11278,9 +11286,9 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-table": "^8.20.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", @@ -11304,12 +11312,12 @@ "@emotion/react": "^11.7.1", "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/client": "^0.55.0-beta.6", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "@uiw/react-codemirror": "^4.25.3", "date-fns": "^4.1.0", @@ -11335,9 +11343,9 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11357,9 +11365,9 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11384,8 +11392,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11411,8 +11419,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", @@ -11434,10 +11442,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/package.json b/package.json index 79c1b3601..b0f63ab76 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,11 @@ "bugs": { "url": "https://github.com/perses/plugins/issues" }, + "type": "module", + "engines": { + "node": ">=24", + "npm": ">=11" + }, "scripts": { "dev": "turbo run dev --concurrency 20", "build": "turbo run build", @@ -63,12 +68,12 @@ }, "devDependencies": { "@module-federation/rsbuild-plugin": "^2.6.0", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/client": "^0.55.0-beta.6", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@rsbuild/core": "^1.6.7", "@rsbuild/plugin-react": "^1.4.2", "@swc/cli": "^0.8.1", @@ -103,5 +108,5 @@ "node-fetch": "^3.3.2" } }, - "packageManager": "npm@10.9.2" + "packageManager": "npm@11.17.0" } diff --git a/piechart/package.json b/piechart/package.json index e9a951885..1e5a3bc24 100644 --- a/piechart/package.json +++ b/piechart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,8 +29,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/piechart/src/PieChart.ts b/piechart/src/PieChart.ts index bb63d6d31..84b4a6ebb 100644 --- a/piechart/src/PieChart.ts +++ b/piechart/src/PieChart.ts @@ -11,11 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { createInitialPieChartOptions, PieChartOptions } from './pie-chart-model'; +import type { PieChartOptions } from './pie-chart-model'; +import { createInitialPieChartOptions } from './pie-chart-model'; import { PieChartOptionsEditorSettings } from './PieChartOptionsEditorSettings'; -import { PieChartPanel, PieChartPanelProps } from './PieChartPanel'; +import type { PieChartPanelProps } from './PieChartPanel'; +import { PieChartPanel } from './PieChartPanel'; /** * The core PieChart panel plugin for Perses. diff --git a/piechart/src/PieChartBase.tsx b/piechart/src/PieChartBase.tsx index 9c3f002c8..b2ec6a0d6 100644 --- a/piechart/src/PieChartBase.tsx +++ b/piechart/src/PieChartBase.tsx @@ -12,12 +12,13 @@ // limitations under the License. import { Box, useTheme } from '@mui/material'; -import { EChart, FormatOptions, ModeOption, useChartsTheme } from '@perses-dev/components'; +import type { FormatOptions, ModeOption } from '@perses-dev/components'; +import { EChart, useChartsTheme } from '@perses-dev/components'; import { PieChart as EChartsPieChart } from 'echarts/charts'; import { DatasetComponent, GridComponent, LegendComponent, TitleComponent, TooltipComponent } from 'echarts/components'; import { use as registerECharts } from 'echarts/core'; import { CanvasRenderer } from 'echarts/renderers'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { getLabelFormatter, getTooltipFormatter } from './utils'; diff --git a/piechart/src/PieChartOptionsEditorSettings.tsx b/piechart/src/PieChartOptionsEditorSettings.tsx index ccae3f772..c768c7190 100644 --- a/piechart/src/PieChartOptionsEditorSettings.tsx +++ b/piechart/src/PieChartOptionsEditorSettings.tsx @@ -11,49 +11,39 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - Button, - FormControl, - InputLabel, - MenuItem, - Select, - Stack, - Switch, - SwitchProps, - Typography, -} from '@mui/material'; +import type { SwitchProps } from '@mui/material'; +import { Button, FormControl, InputLabel, MenuItem, Select, Stack, Switch, Typography } from '@mui/material'; +import type { + FormatControlsProps, + SortSelectorProps, + ModeSelectorProps, + ModeOption, + SortOption, + FormatOptions, +} from '@perses-dev/components'; import { FormatControls, - FormatControlsProps, OptionsColorPicker, OptionsEditorGroup, OptionsEditorGrid, OptionsEditorColumn, SortSelector, - SortSelectorProps, ModeSelector, - ModeSelectorProps, - ModeOption, - SortOption, OptionsEditorControl, useChartsTheme, - FormatOptions, isPercentUnit, isUnitWithShortValues, } from '@perses-dev/components'; -import { - CalculationSelector, - CalculationSelectorProps, - CalculationType, - LegendOptionsEditor, - LegendOptionsEditorProps, -} from '@perses-dev/plugin-system'; +import type { CalculationSelectorProps, CalculationType, LegendOptionsEditorProps } from '@perses-dev/plugin-system'; +import { CalculationSelector, LegendOptionsEditor } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import merge from 'lodash/merge'; import omit from 'lodash/omit'; -import { ReactElement, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { PieChartOptions, PieChartOptionsEditorProps, DEFAULT_FORMAT } from './pie-chart-model'; +import type { PieChartOptions, PieChartOptionsEditorProps } from './pie-chart-model'; +import { DEFAULT_FORMAT } from './pie-chart-model'; export function PieChartOptionsEditorSettings(props: PieChartOptionsEditorProps): ReactElement { const { onChange, value } = props; diff --git a/piechart/src/PieChartPanel.tsx b/piechart/src/PieChartPanel.tsx index e092e1a4c..eedc1f561 100644 --- a/piechart/src/PieChartPanel.tsx +++ b/piechart/src/PieChartPanel.tsx @@ -12,24 +12,21 @@ // limitations under the License. import { Box } from '@mui/material'; -import { - ChartInstance, - ContentWithLegend, - DEFAULT_LEGEND, - LegendProps, - SelectedLegendItemState, - useChartsTheme, - useId, -} from '@perses-dev/components'; -import { CalculationsMap, CalculationType, PanelProps, validateLegendSpec } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type { ChartInstance, LegendProps, SelectedLegendItemState } from '@perses-dev/components'; +import { ContentWithLegend, DEFAULT_LEGEND, useChartsTheme, useId } from '@perses-dev/components'; +import type { CalculationType, PanelProps } from '@perses-dev/plugin-system'; +import { CalculationsMap, validateLegendSpec } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; import merge from 'lodash/merge'; -import { ReactElement, useMemo, useRef, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo, useRef, useState } from 'react'; import { getSeriesColor } from './colors'; -import { PieChartOptions } from './pie-chart-model'; -import { PieChartBase, PieChartData } from './PieChartBase'; -import { PieChartLegendMapper, PieChartListLegendMapper, PieChartTableLegendMapper, sortSeriesData } from './utils'; +import type { PieChartOptions } from './pie-chart-model'; +import type { PieChartData } from './PieChartBase'; +import { PieChartBase } from './PieChartBase'; +import type { PieChartLegendMapper } from './utils'; +import { PieChartListLegendMapper, PieChartTableLegendMapper, sortSeriesData } from './utils'; export type PieChartPanelProps = PanelProps; diff --git a/piechart/src/getPluginModule.ts b/piechart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/piechart/src/getPluginModule.ts +++ b/piechart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/piechart/src/pie-chart-model.ts b/piechart/src/pie-chart-model.ts index 4752113fc..273d8dc49 100644 --- a/piechart/src/pie-chart-model.ts +++ b/piechart/src/pie-chart-model.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions, ModeOption, SortOption } from '@perses-dev/components'; -import { CalculationType, DEFAULT_CALCULATION, LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system'; -import { Definition } from '@perses-dev/spec'; +import type { FormatOptions, ModeOption, SortOption } from '@perses-dev/components'; +import type { CalculationType, LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DEFAULT_CALCULATION } from '@perses-dev/plugin-system'; +import type { Definition } from '@perses-dev/spec'; export const DEFAULT_FORMAT: FormatOptions = { unit: 'decimal', shortValues: true }; export const DEFAULT_SORT: SortOption = 'desc'; diff --git a/piechart/src/utils.test.ts b/piechart/src/utils.test.ts index 33e9b7feb..1b7995b8e 100644 --- a/piechart/src/utils.test.ts +++ b/piechart/src/utils.test.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CellContext, ColumnDefTemplate } from '@tanstack/react-table'; +import type { CellContext, ColumnDefTemplate } from '@tanstack/react-table'; -import { PieChartData } from './PieChartBase'; +import type { PieChartData } from './PieChartBase'; import { PieChartListLegendMapper, PieChartTableLegendMapper, sortSeriesData } from './utils'; const MOCK_DATA: Array> = [ diff --git a/piechart/src/utils.ts b/piechart/src/utils.ts index ff82196e5..33a8931f3 100644 --- a/piechart/src/utils.ts +++ b/piechart/src/utils.ts @@ -11,19 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - FormatOptions, - formatValue, - LegendItem, - ModeOption, - SortOption, - TableColumnConfig, -} from '@perses-dev/components'; -import { comparisonLegends, ComparisonValues, LegendValue } from '@perses-dev/plugin-system'; +import type { FormatOptions, LegendItem, ModeOption, SortOption, TableColumnConfig } from '@perses-dev/components'; +import { formatValue } from '@perses-dev/components'; +import type { ComparisonValues, LegendValue } from '@perses-dev/plugin-system'; +import { comparisonLegends } from '@perses-dev/plugin-system'; import { format } from 'echarts'; import { DEFAULT_SORT } from './pie-chart-model'; -import { PieChartData } from './PieChartBase'; +import type { PieChartData } from './PieChartBase'; export function sortSeriesData(data: T[], sortOrder: SortOption = DEFAULT_SORT): T[] { return data.toSorted((a, b) => { diff --git a/piechart/tsconfig.build.json b/piechart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/piechart/tsconfig.build.json +++ b/piechart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/piechart/tsconfig.json b/piechart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/piechart/tsconfig.json +++ b/piechart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/piechart/vitest.config.ts b/piechart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/piechart/vitest.config.ts +++ b/piechart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/prometheus/package.json b/prometheus/package.json index eb566a406..ab4bf3238 100644 --- a/prometheus/package.json +++ b/prometheus/package.json @@ -15,14 +15,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -37,11 +37,11 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/client": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/client": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/prometheus/src/annotations/PrometheusPromQLAnnotation.tsx b/prometheus/src/annotations/PrometheusPromQLAnnotation.tsx index 362539474..c02d678e9 100644 --- a/prometheus/src/annotations/PrometheusPromQLAnnotation.tsx +++ b/prometheus/src/annotations/PrometheusPromQLAnnotation.tsx @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AnnotationPlugin, AnnotationQueryPluginDependencies, parseVariables } from '@perses-dev/plugin-system'; +import type { AnnotationPlugin, AnnotationQueryPluginDependencies } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; -import { PrometheusPromQLAnnotationOptions } from '../plugins'; +import type { PrometheusPromQLAnnotationOptions } from '../plugins'; import { getAnnotationData } from './get-annotation-data'; import { PrometheusPromQLAnnotationOptionEditor } from './PrometheusPromQLAnnotationOptionEditor'; diff --git a/prometheus/src/annotations/PrometheusPromQLAnnotationOptionEditor.tsx b/prometheus/src/annotations/PrometheusPromQLAnnotationOptionEditor.tsx index 14bf28e13..6998243b4 100644 --- a/prometheus/src/annotations/PrometheusPromQLAnnotationOptionEditor.tsx +++ b/prometheus/src/annotations/PrometheusPromQLAnnotationOptionEditor.tsx @@ -13,26 +13,14 @@ import { Autocomplete, FormControl, Stack, TextField } from '@mui/material'; import { useId } from '@perses-dev/components'; -import { - DatasourceSelect, - DatasourceSelectProps, - DatasourceSelectValue, - OptionsEditorProps, - useDatasourceClient, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, DatasourceSelectValue, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, useDatasourceClient, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { PromQLEditor } from '../components'; -import { - DEFAULT_PROM, - isDefaultPromSelector, - isPrometheusDatasourceSelector, - PROM_DATASOURCE_KIND, - PrometheusClient, - PrometheusDatasourceSelector, -} from '../model'; +import type { PrometheusClient, PrometheusDatasourceSelector } from '../model'; +import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../model'; export interface PrometheusAnnotationsQuerySpec { expr: string; diff --git a/prometheus/src/annotations/get-annotation-data.ts b/prometheus/src/annotations/get-annotation-data.ts index a5e992c4b..17e3d2f1e 100644 --- a/prometheus/src/annotations/get-annotation-data.ts +++ b/prometheus/src/annotations/get-annotation-data.ts @@ -11,12 +11,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AnnotationContext, datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; -import { AnnotationData, DatasourceSpec, parseDurationString } from '@perses-dev/spec'; +import type { AnnotationContext } from '@perses-dev/plugin-system'; +import { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; +import type { AnnotationData, DatasourceSpec } from '@perses-dev/spec'; +import { parseDurationString } from '@perses-dev/spec'; import { milliseconds } from 'date-fns'; -import { DEFAULT_PROM, getPrometheusTimeRange, getRangeStep, PROM_DATASOURCE_KIND, PrometheusClient } from '../model'; -import { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec, PrometheusPromQLAnnotationOptions } from '../plugins'; +import type { PrometheusClient } from '../model'; +import { DEFAULT_PROM, getPrometheusTimeRange, getRangeStep, PROM_DATASOURCE_KIND } from '../model'; +import type { PrometheusDatasourceSpec, PrometheusPromQLAnnotationOptions } from '../plugins'; +import { DEFAULT_SCRAPE_INTERVAL } from '../plugins'; import { interpolateDatasourceProxyParams } from '../plugins/interpolation'; import { formatSeriesName } from '../utils'; diff --git a/prometheus/src/components/PromQLEditor.tsx b/prometheus/src/components/PromQLEditor.tsx index 50858c387..e516f6bc7 100644 --- a/prometheus/src/components/PromQLEditor.tsx +++ b/prometheus/src/components/PromQLEditor.tsx @@ -15,13 +15,16 @@ import { EditorView } from '@codemirror/view'; import { useTheme, CircularProgress, InputLabel, Stack, IconButton, Tooltip } from '@mui/material'; import { ErrorAlert } from '@perses-dev/components'; import { useReplaceVariablesInString } from '@perses-dev/plugin-system'; -import { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql'; -import CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror'; +import type { CompleteConfiguration } from '@prometheus-io/codemirror-promql'; +import { PromQLExtension } from '@prometheus-io/codemirror-promql'; +import type { ReactCodeMirrorProps } from '@uiw/react-codemirror'; +import CodeMirror from '@uiw/react-codemirror'; import CloseIcon from 'mdi-material-ui/Close'; import FileTreeIcon from 'mdi-material-ui/FileTree'; -import { ReactElement, useMemo, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo, useState } from 'react'; -import { PrometheusDatasourceSelector } from '../model'; +import type { PrometheusDatasourceSelector } from '../model'; import { replacePromBuiltinVariables } from '../plugins/prometheus-time-series-query/replace-prom-builtin-variables'; import { useParseQuery } from './query'; import TreeNode from './TreeNode'; diff --git a/prometheus/src/components/TreeNode.tsx b/prometheus/src/components/TreeNode.tsx index 102ab480f..def175d77 100644 --- a/prometheus/src/components/TreeNode.tsx +++ b/prometheus/src/components/TreeNode.tsx @@ -14,13 +14,15 @@ // Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx import { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material'; -import { StatusError } from '@perses-dev/client'; +import type { StatusError } from '@perses-dev/client'; import AlertCircle from 'mdi-material-ui/AlertCircle'; import CircleIcon from 'mdi-material-ui/Circle'; -import { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react'; -import { PrometheusDatasourceSelector } from '../model'; -import ASTNode, { nodeType } from './promql/ast'; +import type { PrometheusDatasourceSelector } from '../model'; +import type ASTNode from './promql/ast'; +import { nodeType } from './promql/ast'; import { formatNode } from './promql/format'; import { functionSignatures } from './promql/functionSignatures'; import serializeNode from './promql/serialize'; diff --git a/prometheus/src/components/promql/ast.ts b/prometheus/src/components/promql/ast.ts index c50e7fa7a..2c8bf62a0 100644 --- a/prometheus/src/components/promql/ast.ts +++ b/prometheus/src/components/promql/ast.ts @@ -223,4 +223,4 @@ type ASTNode = | VectorSelector | Placeholder; -export default ASTNode; +export type { ASTNode as default }; diff --git a/prometheus/src/components/promql/format.tsx b/prometheus/src/components/promql/format.tsx index c28fec944..e240ead09 100644 --- a/prometheus/src/components/promql/format.tsx +++ b/prometheus/src/components/promql/format.tsx @@ -15,16 +15,12 @@ import { styled } from '@mui/material'; import { convertTimeToDuration, formatDuration } from '@perses-dev/spec'; -import React, { ReactElement, ReactNode } from 'react'; +import type { ReactElement, ReactNode } from 'react'; +import React from 'react'; -import ASTNode, { - VectorSelector, - matchType, - vectorMatchCardinality, - nodeType, - StartOrEnd, - MatrixSelector, -} from './ast'; +import type { VectorSelector, StartOrEnd, MatrixSelector } from './ast'; +import type ASTNode from './ast'; +import { matchType, vectorMatchCardinality, nodeType } from './ast'; import { maybeParenthesizeBinopChild, escapeString } from './utils'; // Styled components that reproduce the theming of CodeMirror: diff --git a/prometheus/src/components/promql/functionSignatures.ts b/prometheus/src/components/promql/functionSignatures.ts index 1d5a74b70..93223c9aa 100644 --- a/prometheus/src/components/promql/functionSignatures.ts +++ b/prometheus/src/components/promql/functionSignatures.ts @@ -13,7 +13,8 @@ // Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/functionSignatures.ts -import { valueType, Func } from './ast'; +import type { Func } from './ast'; +import { valueType } from './ast'; export const functionSignatures: Record = { abs: { name: 'abs', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector }, diff --git a/prometheus/src/components/promql/serialize.ts b/prometheus/src/components/promql/serialize.ts index c1d33cb0a..98971b6b0 100644 --- a/prometheus/src/components/promql/serialize.ts +++ b/prometheus/src/components/promql/serialize.ts @@ -15,14 +15,9 @@ import { convertTimeToDuration, formatDuration } from '@perses-dev/spec'; -import ASTNode, { - VectorSelector, - matchType, - vectorMatchCardinality, - nodeType, - StartOrEnd, - MatrixSelector, -} from './ast'; +import type { VectorSelector, StartOrEnd, MatrixSelector } from './ast'; +import type ASTNode from './ast'; +import { matchType, vectorMatchCardinality, nodeType } from './ast'; import { aggregatorsWithParam, maybeParenthesizeBinopChild, escapeString } from './utils'; const serializeAtAndOffset = (timestamp: number | null, startOrEnd: StartOrEnd, offset: number): string => { diff --git a/prometheus/src/components/promql/utils.ts b/prometheus/src/components/promql/utils.ts index ff0a20915..3c7e70f37 100644 --- a/prometheus/src/components/promql/utils.ts +++ b/prometheus/src/components/promql/utils.ts @@ -13,7 +13,8 @@ // Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/utils.ts -import ASTNode, { binaryOperatorType, nodeType } from './ast'; +import type ASTNode from './ast'; +import { binaryOperatorType, nodeType } from './ast'; const binOpPrecedence = { [binaryOperatorType.add]: 3, diff --git a/prometheus/src/components/query.ts b/prometheus/src/components/query.ts index 7bd29f565..a27f30976 100644 --- a/prometheus/src/components/query.ts +++ b/prometheus/src/components/query.ts @@ -11,12 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { StatusError } from '@perses-dev/client'; +import type { StatusError } from '@perses-dev/client'; import { useDatasourceClient, useDatasourceStore, useVariableValues } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; -import { useQuery, UseQueryResult } from '@tanstack/react-query'; +import type { DatasourceSelector } from '@perses-dev/spec'; +import type { UseQueryResult } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; -import { +import type { InstantQueryRequestParameters, MonitoredInstantQueryResponse, ParseQueryRequestParameters, diff --git a/prometheus/src/explore/PrometheusExplorer.tsx b/prometheus/src/explore/PrometheusExplorer.tsx index 8938b1429..d34bbb52e 100644 --- a/prometheus/src/explore/PrometheusExplorer.tsx +++ b/prometheus/src/explore/PrometheusExplorer.tsx @@ -15,13 +15,14 @@ import { Box, Stack, Tab, Tabs, ToggleButton, ToggleButtonGroup } from '@mui/mat import { Panel } from '@perses-dev/dashboards'; import { useExplorerManagerContext } from '@perses-dev/explore'; import { DataQueriesProvider, MultiQueryEditor, useSuggestedStepMs } from '@perses-dev/plugin-system'; -import { QueryDefinition } from '@perses-dev/spec'; -import { ReactElement, useState } from 'react'; +import type { QueryDefinition } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; +import { useState } from 'react'; import useResizeObserver from 'use-resize-observer'; import { DEFAULT_PROM } from '../model/prometheus-selectors'; import { PrometheusMetricsFinder } from './PrometheusMetricsFinder'; -import { FinderQueryParams } from './PrometheusMetricsFinder/types'; +import type { FinderQueryParams } from './PrometheusMetricsFinder/types'; interface MetricsExplorerQueryParams extends FinderQueryParams { tab?: string; diff --git a/prometheus/src/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.tsx b/prometheus/src/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.tsx index da286e417..7d3bf995a 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.tsx @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { StackProps } from '@mui/material'; import { Button, Checkbox, @@ -21,25 +22,26 @@ import { Menu, MenuItem, Stack, - StackProps, TextField, useMediaQuery, useTheme, } from '@mui/material'; -import { Fuzzy, FuzzyMatchingInterval } from '@nexucis/fuzzy'; +import type { FuzzyMatchingInterval } from '@nexucis/fuzzy'; +import { Fuzzy } from '@nexucis/fuzzy'; import { useExplorerQueryParams } from '@perses-dev/explore'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; import ArrowLeftIcon from 'mdi-material-ui/ArrowLeft'; import CogIcon from 'mdi-material-ui/Cog'; import Magnify from 'mdi-material-ui/Magnify'; -import { MouseEvent, ReactElement, useMemo, useState } from 'react'; +import type { MouseEvent, ReactElement } from 'react'; +import { useMemo, useState } from 'react'; import { Link as RouterLink } from 'react-router-dom'; import { DEFAULT_PROM } from '../../model'; import { MetricList } from './display/list/MetricList'; import { FinderFilters } from './filter/FinderFilters'; import { MetricOverview } from './overview/MetricOverview'; -import { LabelFilter, Settings } from './types'; +import type { LabelFilter, Settings } from './types'; import { useLabelValues } from './utils'; const PERSES_METRICS_FINDER_SETTINGS = 'PERSES_METRICS_FINDER_SETTINGS'; diff --git a/prometheus/src/explore/PrometheusMetricsFinder/display/MetricChip.tsx b/prometheus/src/explore/PrometheusMetricsFinder/display/MetricChip.tsx index d0409da86..0e762fce9 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/display/MetricChip.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/display/MetricChip.tsx @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Chip, ChipProps } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ChipProps } from '@mui/material'; +import { Chip } from '@mui/material'; +import type { ReactElement } from 'react'; export function MetricChip({ label, ...props }: ChipProps): ReactElement { if (label === 'gauge') { diff --git a/prometheus/src/explore/PrometheusMetricsFinder/display/list/MetricList.test.tsx b/prometheus/src/explore/PrometheusMetricsFinder/display/list/MetricList.test.tsx index 45487f753..38b5f0221 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/display/list/MetricList.test.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/display/list/MetricList.test.tsx @@ -11,12 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { render, RenderResult, screen } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import { VirtuosoMockContext } from 'react-virtuoso'; import { DEFAULT_PROM } from '../../../../model/prometheus-selectors'; -import { MetricList, MetricListProps } from './MetricList'; +import type { MetricListProps } from './MetricList'; +import { MetricList } from './MetricList'; vi.mock('../../utils', () => ({ useMetricMetadata: vi diff --git a/prometheus/src/explore/PrometheusMetricsFinder/display/list/MetricList.tsx b/prometheus/src/explore/PrometheusMetricsFinder/display/list/MetricList.tsx index fdbe341cc..560b45ffe 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/display/list/MetricList.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/display/list/MetricList.tsx @@ -11,16 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Button, Divider, Skeleton, Stack, StackProps, TableCell, Typography } from '@mui/material'; -import { Fuzzy, FuzzyMatchingInterval } from '@nexucis/fuzzy'; +import type { StackProps } from '@mui/material'; +import { Button, Divider, Skeleton, Stack, TableCell, Typography } from '@mui/material'; +import type { FuzzyMatchingInterval } from '@nexucis/fuzzy'; +import { Fuzzy } from '@nexucis/fuzzy'; import { useExplorerQueryParams } from '@perses-dev/explore'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; import CompassIcon from 'mdi-material-ui/Compass'; -import { ReactElement, ReactNode, useMemo } from 'react'; +import type { ReactElement, ReactNode } from 'react'; +import { useMemo } from 'react'; import { Link as RouterLink } from 'react-router-dom'; import { TableVirtuoso } from 'react-virtuoso'; -import { LabelFilter } from '../../types'; +import type { LabelFilter } from '../../types'; import { useMetricMetadata } from '../../utils'; import { MetricChip } from '../MetricChip'; diff --git a/prometheus/src/explore/PrometheusMetricsFinder/filter/FilterInputs.test.tsx b/prometheus/src/explore/PrometheusMetricsFinder/filter/FilterInputs.test.tsx index 81b301f15..fbe79d3d7 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/filter/FilterInputs.test.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/filter/FilterInputs.test.tsx @@ -13,7 +13,8 @@ import { act, fireEvent, render, screen } from '@testing-library/react'; -import { RawFilterInput, RawFilterInputProps } from './FilterInputs'; +import type { RawFilterInputProps } from './FilterInputs'; +import { RawFilterInput } from './FilterInputs'; describe('FilterInputs', () => { const renderInputs = ({ diff --git a/prometheus/src/explore/PrometheusMetricsFinder/filter/FilterInputs.tsx b/prometheus/src/explore/PrometheusMetricsFinder/filter/FilterInputs.tsx index da5bfe12e..89daa9b57 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/filter/FilterInputs.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/filter/FilterInputs.tsx @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { SelectChangeEvent } from '@mui/material'; import { Autocomplete, CircularProgress, @@ -18,25 +19,16 @@ import { InputAdornment, MenuItem, Select, - SelectChangeEvent, Stack, TextField, } from '@mui/material'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; import DeleteIcon from 'mdi-material-ui/Delete'; -import { - cloneElement, - forwardRef, - HTMLAttributes, - ReactElement, - SyntheticEvent, - useMemo, - useRef, - useState, -} from 'react'; +import type { HTMLAttributes, ReactElement, SyntheticEvent } from 'react'; +import { cloneElement, forwardRef, useMemo, useRef, useState } from 'react'; import { Virtuoso } from 'react-virtuoso'; -import { LabelFilter, Operator } from '../types'; +import type { LabelFilter, Operator } from '../types'; import { useLabels, useLabelValues } from '../utils'; export interface LabelFilterInputProps { diff --git a/prometheus/src/explore/PrometheusMetricsFinder/filter/FinderFilters.tsx b/prometheus/src/explore/PrometheusMetricsFinder/filter/FinderFilters.tsx index b479845de..d370e13f7 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/filter/FinderFilters.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/filter/FinderFilters.tsx @@ -11,19 +11,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Button, FormControl, Stack, StackProps } from '@mui/material'; +import type { StackProps } from '@mui/material'; +import { Button, FormControl, Stack } from '@mui/material'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; import { DatasourceSelect, - DatasourceSelectValue, datasourceSelectValueToSelector, useListDatasourceSelectItems, } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; import PlusIcon from 'mdi-material-ui/Plus'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { PROM_DATASOURCE_KIND } from '../../../model/prometheus-selectors'; -import { LabelFilter } from '../types'; +import type { LabelFilter } from '../types'; import { LabelFilterInput } from './FilterInputs'; export interface ExplorerFiltersProps extends StackProps { diff --git a/prometheus/src/explore/PrometheusMetricsFinder/overview/MetricOverview.tsx b/prometheus/src/explore/PrometheusMetricsFinder/overview/MetricOverview.tsx index f5d49e9dd..70b267202 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/overview/MetricOverview.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/overview/MetricOverview.tsx @@ -11,15 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Checkbox, FormControlLabel, Skeleton, Stack, StackProps, Tab, Tabs, Tooltip } from '@mui/material'; +import type { StackProps } from '@mui/material'; +import { Checkbox, FormControlLabel, Skeleton, Stack, Tab, Tabs, Tooltip } from '@mui/material'; import { Panel } from '@perses-dev/dashboards'; import { DataQueriesProvider, useSuggestedStepMs } from '@perses-dev/plugin-system'; -import { DatasourceSelector, QueryDefinition } from '@perses-dev/spec'; +import type { DatasourceSelector, QueryDefinition } from '@perses-dev/spec'; import HelpCircleOutlineIcon from 'mdi-material-ui/HelpCircleOutline'; -import { ReactElement, useMemo, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo, useState } from 'react'; import useResizeObserver from 'use-resize-observer'; -import { computeFilterExpr, LabelFilter } from '../types'; +import type { LabelFilter } from '../types'; +import { computeFilterExpr } from '../types'; import { useMetricMetadata } from '../utils'; import { JobTab } from './tabs/JobTab'; import { OverviewTab } from './tabs/OverviewTab'; diff --git a/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/JobTab.tsx b/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/JobTab.tsx index 484b9de03..31ff3a228 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/JobTab.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/JobTab.tsx @@ -11,21 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - CircularProgress, - FormControl, - InputLabel, - MenuItem, - Select, - Stack, - StackProps, - Typography, -} from '@mui/material'; -import { DatasourceSelector } from '@perses-dev/spec'; -import { ReactElement, useMemo, useState } from 'react'; +import type { StackProps } from '@mui/material'; +import { CircularProgress, FormControl, InputLabel, MenuItem, Select, Stack, Typography } from '@mui/material'; +import type { DatasourceSelector } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; +import { useMemo, useState } from 'react'; import { MetricList } from '../../display/list/MetricList'; -import { LabelFilter } from '../../types'; +import type { LabelFilter } from '../../types'; import { useLabelValues } from '../../utils'; export interface JobList extends StackProps { diff --git a/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.tsx b/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.tsx index d91fcfcaa..c7d775512 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.tsx @@ -11,6 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { SelectChangeEvent, StackProps } from '@mui/material'; import { Autocomplete, Button, @@ -20,25 +21,24 @@ import { IconButton, MenuItem, Select, - SelectChangeEvent, Skeleton, Stack, - StackProps, TextField, Typography, useMediaQuery, useTheme, } from '@mui/material'; import { ErrorAlert } from '@perses-dev/components'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; import CheckIcon from 'mdi-material-ui/Check'; import CloseIcon from 'mdi-material-ui/Close'; import PlusIcon from 'mdi-material-ui/Plus'; -import { ReactElement, useMemo, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo, useState } from 'react'; import { MetricChip } from '../../display/MetricChip'; import { ListboxComponent } from '../../filter/FilterInputs'; -import { LabelFilter, LabelValueCounter, Operator } from '../../types'; +import type { LabelFilter, LabelValueCounter, Operator } from '../../types'; import { useMetricMetadata, useSeriesStates } from '../../utils'; export interface LabelValuesRowProps extends StackProps { diff --git a/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.tsx b/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.tsx index 5f56d5279..db0a62bcf 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.tsx +++ b/prometheus/src/explore/PrometheusMetricsFinder/overview/tabs/SimilarTab.tsx @@ -11,12 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CircularProgress, Stack, StackProps } from '@mui/material'; -import { DatasourceSelector } from '@perses-dev/spec'; -import { ReactElement, useMemo } from 'react'; +import type { StackProps } from '@mui/material'; +import { CircularProgress, Stack } from '@mui/material'; +import type { DatasourceSelector } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; import { MetricList } from '../../display/list/MetricList'; -import { LabelFilter } from '../../types'; +import type { LabelFilter } from '../../types'; import { useLabelValues } from '../../utils'; export interface SimilarTabProps extends StackProps { diff --git a/prometheus/src/explore/PrometheusMetricsFinder/types.ts b/prometheus/src/explore/PrometheusMetricsFinder/types.ts index bda314440..f2029b802 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/types.ts +++ b/prometheus/src/explore/PrometheusMetricsFinder/types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export type Operator = '=' | '!=' | '=~' | '!~'; diff --git a/prometheus/src/explore/PrometheusMetricsFinder/utils.ts b/prometheus/src/explore/PrometheusMetricsFinder/utils.ts index 6626aee99..a55c253fa 100644 --- a/prometheus/src/explore/PrometheusMetricsFinder/utils.ts +++ b/prometheus/src/explore/PrometheusMetricsFinder/utils.ts @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { StatusError } from '@perses-dev/client'; +import type { StatusError } from '@perses-dev/client'; import { useDatasourceClient, useTimeRange, useVariableValues, useDatasourceStore } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; -import { useQuery, UseQueryResult } from '@tanstack/react-query'; +import type { DatasourceSelector } from '@perses-dev/spec'; +import type { UseQueryResult } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; import { useMemo } from 'react'; -import { +import type { LabelNamesRequestParameters, LabelValuesRequestParameters, LabelValuesResponse, @@ -30,7 +31,8 @@ import { SeriesResponse, } from '../../model'; import { getInterpolatedRequestOptions } from '../../plugins/interpolation'; -import { computeFilterExpr, LabelFilter, LabelValueCounter } from './types'; +import type { LabelFilter, LabelValueCounter } from './types'; +import { computeFilterExpr } from './types'; // Retrieve metric metadata from the Prometheus API export function useMetricMetadata( diff --git a/prometheus/src/getPluginModule.ts b/prometheus/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/prometheus/src/getPluginModule.ts +++ b/prometheus/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/prometheus/src/model/api-types.ts b/prometheus/src/model/api-types.ts index 994e780e2..eb0e30778 100644 --- a/prometheus/src/model/api-types.ts +++ b/prometheus/src/model/api-types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DurationString } from '@perses-dev/spec'; +import type { DurationString } from '@perses-dev/spec'; -import ASTNode from '../components/promql/ast'; +import type ASTNode from '../components/promql/ast'; // Just reuse dashboard model's type and re-export export type { DurationString }; diff --git a/prometheus/src/model/parse-sample-values.ts b/prometheus/src/model/parse-sample-values.ts index 91b79dfaa..bce2a8910 100644 --- a/prometheus/src/model/parse-sample-values.ts +++ b/prometheus/src/model/parse-sample-values.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ValueTuple } from './api-types'; +import type { ValueTuple } from './api-types'; /** * ValueTuple from the Prom server, parsed into ms and floating point number diff --git a/prometheus/src/model/prometheus-client.ts b/prometheus/src/model/prometheus-client.ts index 3a6669099..39b76740d 100644 --- a/prometheus/src/model/prometheus-client.ts +++ b/prometheus/src/model/prometheus-client.ts @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { fetchJson, RequestHeaders } from '@perses-dev/client'; -import { QueryParamValues } from '@perses-dev/components'; -import { DatasourceClient } from '@perses-dev/plugin-system'; +import type { RequestHeaders } from '@perses-dev/client'; +import { fetchJson } from '@perses-dev/client'; +import type { QueryParamValues } from '@perses-dev/components'; +import type { DatasourceClient } from '@perses-dev/plugin-system'; -import { +import type { InstantQueryRequestParameters, InstantQueryResponse, LabelNamesRequestParameters, diff --git a/prometheus/src/model/prometheus-selectors.ts b/prometheus/src/model/prometheus-selectors.ts index 75300a238..5b40ebef6 100644 --- a/prometheus/src/model/prometheus-selectors.ts +++ b/prometheus/src/model/prometheus-selectors.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import { isVariableDatasource } from '@perses-dev/plugin-system'; +import type { DatasourceSelector } from '@perses-dev/spec'; export const PROM_DATASOURCE_KIND = 'PrometheusDatasource' as const; diff --git a/prometheus/src/model/time.ts b/prometheus/src/model/time.ts index 2de0f912f..17a275bcf 100644 --- a/prometheus/src/model/time.ts +++ b/prometheus/src/model/time.ts @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AbsoluteTimeRange, DurationString, parseDurationString } from '@perses-dev/spec'; +import type { AbsoluteTimeRange, DurationString } from '@perses-dev/spec'; +import { parseDurationString } from '@perses-dev/spec'; import { milliseconds, getUnixTime } from 'date-fns'; -import { UnixTimestampSeconds } from './api-types'; +import type { UnixTimestampSeconds } from './api-types'; export interface PrometheusTimeRange { start: UnixTimestampSeconds; diff --git a/prometheus/src/plugins/MatcherEditor.tsx b/prometheus/src/plugins/MatcherEditor.tsx index 5b3f9e410..db9c04629 100644 --- a/prometheus/src/plugins/MatcherEditor.tsx +++ b/prometheus/src/plugins/MatcherEditor.tsx @@ -14,7 +14,7 @@ import { Stack, TextField, Button, Box, IconButton } from '@mui/material'; import { produce } from 'immer'; import TrashIcon from 'mdi-material-ui/TrashCan'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; type MatcherEditorProps = { matchers: string[]; diff --git a/prometheus/src/plugins/PrometheusDatasourceEditor.tsx b/prometheus/src/plugins/PrometheusDatasourceEditor.tsx index f4df21a72..dcc99b39f 100644 --- a/prometheus/src/plugins/PrometheusDatasourceEditor.tsx +++ b/prometheus/src/plugins/PrometheusDatasourceEditor.tsx @@ -12,14 +12,16 @@ // limitations under the License. import { Box, IconButton, TextField, Typography } from '@mui/material'; -import { QueryParamValues } from '@perses-dev/components'; +import type { QueryParamValues } from '@perses-dev/components'; import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { DurationString } from '@perses-dev/spec'; +import type { DurationString } from '@perses-dev/spec'; import MinusIcon from 'mdi-material-ui/Minus'; import PlusIcon from 'mdi-material-ui/Plus'; -import { ReactElement, useRef, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useRef, useState } from 'react'; -import { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from './types'; +import type { PrometheusDatasourceSpec } from './types'; +import { DEFAULT_SCRAPE_INTERVAL } from './types'; interface QueryParamEntry { // Unique identifier for the entry, added to avoid using array index as key diff --git a/prometheus/src/plugins/PrometheusLabelNamesVariable.tsx b/prometheus/src/plugins/PrometheusLabelNamesVariable.tsx index 29e09740a..bd4c962c8 100644 --- a/prometheus/src/plugins/PrometheusLabelNamesVariable.tsx +++ b/prometheus/src/plugins/PrometheusLabelNamesVariable.tsx @@ -11,9 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { VariablePlugin, GetVariableOptionsContext } from '@perses-dev/plugin-system'; import { - VariablePlugin, - GetVariableOptionsContext, replaceVariables, parseVariables, datasourceSelectValueToSelector, @@ -23,7 +22,7 @@ import { import { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model'; import { resolvePrometheusDatasource } from './interpolation'; import { stringArrayToVariableOptions, PrometheusLabelNamesVariableEditor } from './prometheus-variables'; -import { PrometheusLabelNamesVariableOptions } from './types'; +import type { PrometheusLabelNamesVariableOptions } from './types'; export const PrometheusLabelNamesVariable: VariablePlugin = { getVariableOptions: async (spec: PrometheusLabelNamesVariableOptions, ctx: GetVariableOptionsContext) => { diff --git a/prometheus/src/plugins/PrometheusLabelValuesVariable.tsx b/prometheus/src/plugins/PrometheusLabelValuesVariable.tsx index d9e58464c..7fb00d96d 100644 --- a/prometheus/src/plugins/PrometheusLabelValuesVariable.tsx +++ b/prometheus/src/plugins/PrometheusLabelValuesVariable.tsx @@ -11,21 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { VariablePlugin, GetVariableOptionsContext, DatasourceStore } from '@perses-dev/plugin-system'; import { - VariablePlugin, - GetVariableOptionsContext, replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource, - DatasourceStore, } from '@perses-dev/plugin-system'; -import { DatasourceSelector, DatasourceSpec } from '@perses-dev/spec'; +import type { DatasourceSelector, DatasourceSpec } from '@perses-dev/spec'; import { DEFAULT_PROM, getPrometheusTimeRange, PROM_DATASOURCE_KIND } from '../model'; import { resolvePrometheusDatasource } from './interpolation'; import { stringArrayToVariableOptions, PrometheusLabelValuesVariableEditor } from './prometheus-variables'; -import { PrometheusLabelValuesVariableOptions, PrometheusDatasourceSpec } from './types'; +import type { PrometheusLabelValuesVariableOptions, PrometheusDatasourceSpec } from './types'; function extractDatasourceVariables(datasourceSpec: DatasourceSpec): string[] { try { diff --git a/prometheus/src/plugins/PrometheusPromQLVariable.tsx b/prometheus/src/plugins/PrometheusPromQLVariable.tsx index d28796fc3..025e3267e 100644 --- a/prometheus/src/plugins/PrometheusPromQLVariable.tsx +++ b/prometheus/src/plugins/PrometheusPromQLVariable.tsx @@ -11,9 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { VariablePlugin, GetVariableOptionsContext } from '@perses-dev/plugin-system'; import { - VariablePlugin, - GetVariableOptionsContext, replaceVariables, parseVariables, datasourceSelectValueToSelector, @@ -28,7 +27,7 @@ import { stringArrayToVariableOptions, PrometheusPromQLVariableEditor, } from './prometheus-variables'; -import { PrometheusPromQLVariableOptions } from './types'; +import type { PrometheusPromQLVariableOptions } from './types'; export const PrometheusPromQLVariable: VariablePlugin = { getVariableOptions: async (spec: PrometheusPromQLVariableOptions, ctx: GetVariableOptionsContext) => { diff --git a/prometheus/src/plugins/interpolation.ts b/prometheus/src/plugins/interpolation.ts index 18098d14a..ed90772d5 100644 --- a/prometheus/src/plugins/interpolation.ts +++ b/prometheus/src/plugins/interpolation.ts @@ -11,12 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { interpolateHeaders, interpolateQueryParams, VariableStateMap } from '@perses-dev/components'; -import { DatasourceStore } from '@perses-dev/plugin-system'; -import { DatasourceSelector, DatasourceSpec } from '@perses-dev/spec'; +import type { VariableStateMap } from '@perses-dev/components'; +import { interpolateHeaders, interpolateQueryParams } from '@perses-dev/components'; +import type { DatasourceStore } from '@perses-dev/plugin-system'; +import type { DatasourceSelector, DatasourceSpec } from '@perses-dev/spec'; -import { ClientRequestOptions, PrometheusClient } from '../model'; -import { PrometheusDatasourceSpec } from './types'; +import type { ClientRequestOptions, PrometheusClient } from '../model'; +import type { PrometheusDatasourceSpec } from './types'; export interface ResolvedPrometheusDatasource { client: PrometheusClient; diff --git a/prometheus/src/plugins/prometheus-datasource.test.ts b/prometheus/src/plugins/prometheus-datasource.test.ts index b5dc9048b..58b84af50 100644 --- a/prometheus/src/plugins/prometheus-datasource.test.ts +++ b/prometheus/src/plugins/prometheus-datasource.test.ts @@ -12,7 +12,7 @@ // limitations under the License. import { PrometheusDatasource } from './prometheus-datasource'; -import { PrometheusDatasourceSpec } from './types'; +import type { PrometheusDatasourceSpec } from './types'; describe('PrometheusDatasource query parameters', () => { it('should not alter the base URL', () => { diff --git a/prometheus/src/plugins/prometheus-datasource.tsx b/prometheus/src/plugins/prometheus-datasource.tsx index cf7648261..6ef4da748 100644 --- a/prometheus/src/plugins/prometheus-datasource.tsx +++ b/prometheus/src/plugins/prometheus-datasource.tsx @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { RequestHeaders } from '@perses-dev/client'; -import { QueryParamValues } from '@perses-dev/components'; -import { DatasourcePlugin } from '@perses-dev/plugin-system'; -import { BuiltinVariableDefinition } from '@perses-dev/spec'; +import type { RequestHeaders } from '@perses-dev/client'; +import type { QueryParamValues } from '@perses-dev/components'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { BuiltinVariableDefinition } from '@perses-dev/spec'; +import type { ClientRequestOptions, PrometheusClient, QueryOptions } from '../model'; import { - ClientRequestOptions, healthCheck, instantQuery, labelNames, @@ -25,13 +25,11 @@ import { mergeQueryParams, metricMetadata, parseQuery, - PrometheusClient, - QueryOptions, rangeQuery, series, } from '../model'; import { PrometheusDatasourceEditor } from './PrometheusDatasourceEditor'; -import { PrometheusDatasourceSpec } from './types'; +import type { PrometheusDatasourceSpec } from './types'; function wrapClientMethod( fn: (params: P, opts: QueryOptions) => Promise, diff --git a/prometheus/src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts b/prometheus/src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts index 101964be6..3c0eec620 100644 --- a/prometheus/src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts +++ b/prometheus/src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.ts @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, isVariableDatasource, parseVariables } from '@perses-dev/plugin-system'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { isVariableDatasource, parseVariables } from '@perses-dev/plugin-system'; import { getTimeSeriesData } from './get-time-series-data'; import { PrometheusTimeSeriesQueryEditor } from './PrometheusTimeSeriesQueryEditor'; -import { PrometheusTimeSeriesQuerySpec } from './time-series-query-model'; +import type { PrometheusTimeSeriesQuerySpec } from './time-series-query-model'; /** * The core Prometheus TimeSeriesQuery plugin for Perses. diff --git a/prometheus/src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx b/prometheus/src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx index d821ff105..84944addc 100644 --- a/prometheus/src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx +++ b/prometheus/src/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.tsx @@ -14,9 +14,9 @@ import { Button, ButtonGroup, FormControl, Stack, TextField } from '@mui/material'; import { useId } from '@perses-dev/components'; import { PanelEditorContext } from '@perses-dev/dashboards'; +import type { DatasourceSelectProps } from '@perses-dev/plugin-system'; import { DatasourceSelect, - DatasourceSelectProps, replaceVariables, useAllVariableValues, useDatasource, @@ -26,29 +26,24 @@ import { useTimeRange, } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useContext, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useContext, useMemo } from 'react'; import { PromQLEditor } from '../../components'; +import type { DurationString, PrometheusClient, PrometheusDatasourceSelector } from '../../model'; import { DEFAULT_PROM, - DurationString, getDurationStringSeconds, getPrometheusTimeRange, getRangeStep, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND, - PrometheusClient, - PrometheusDatasourceSelector, } from '../../model'; -import { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types'; -import { - PrometheusTimeSeriesQueryEditorProps, - useQueryState, - useFormatState, - useMinStepState, - useInstantState, -} from './query-editor-model'; +import type { PrometheusDatasourceSpec } from '../types'; +import { DEFAULT_SCRAPE_INTERVAL } from '../types'; +import type { PrometheusTimeSeriesQueryEditorProps } from './query-editor-model'; +import { useQueryState, useFormatState, useMinStepState, useInstantState } from './query-editor-model'; /** * The options editor component for editing a PrometheusTimeSeriesQuery's spec. */ diff --git a/prometheus/src/plugins/prometheus-time-series-query/get-time-series-data.ts b/prometheus/src/plugins/prometheus-time-series-query/get-time-series-data.ts index 5c7b730dc..107679142 100644 --- a/prometheus/src/plugins/prometheus-time-series-query/get-time-series-data.ts +++ b/prometheus/src/plugins/prometheus-time-series-query/get-time-series-data.ts @@ -11,35 +11,27 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; -import { - DatasourceSpec, - DurationString, - Notice, - parseDurationString, - TimeSeries, - TimeSeriesData, -} from '@perses-dev/spec'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; +import type { DatasourceSpec, DurationString, Notice, TimeSeries, TimeSeriesData } from '@perses-dev/spec'; +import { parseDurationString } from '@perses-dev/spec'; import { fromUnixTime, milliseconds } from 'date-fns'; +import type { PrometheusClient, MatrixData, VectorData, ScalarData, InstantQueryResultType } from '../../model'; import { parseValueTuple, - PrometheusClient, getDurationStringSeconds, getPrometheusTimeRange, getRangeStep, DEFAULT_PROM, - MatrixData, - VectorData, - ScalarData, - InstantQueryResultType, PROM_DATASOURCE_KIND, } from '../../model'; import { getFormattedPrometheusSeriesName } from '../../utils'; import { interpolateDatasourceProxyParams } from '../interpolation'; -import { DEFAULT_SCRAPE_INTERVAL, PrometheusDatasourceSpec } from '../types'; +import type { PrometheusDatasourceSpec } from '../types'; +import { DEFAULT_SCRAPE_INTERVAL } from '../types'; import { replacePromBuiltinVariables } from './replace-prom-builtin-variables'; -import { PrometheusTimeSeriesQuerySpec } from './time-series-query-model'; +import type { PrometheusTimeSeriesQuerySpec } from './time-series-query-model'; export const getTimeSeriesData: TimeSeriesQueryPlugin['getTimeSeriesData'] = async ( spec, diff --git a/prometheus/src/plugins/prometheus-time-series-query/plugin.test.ts b/prometheus/src/plugins/prometheus-time-series-query/plugin.test.ts index b20710055..2b037c676 100644 --- a/prometheus/src/plugins/prometheus-time-series-query/plugin.test.ts +++ b/prometheus/src/plugins/prometheus-time-series-query/plugin.test.ts @@ -15,13 +15,13 @@ vi.mock('echarts/core'); -import { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock } from 'vitest'; -import { RangeQueryResponse, InstantQueryResponse } from '../../model'; +import type { RangeQueryResponse, InstantQueryResponse } from '../../model'; import { PrometheusDatasource } from '../prometheus-datasource'; -import { PrometheusDatasourceSpec } from '../types'; +import type { PrometheusDatasourceSpec } from '../types'; import { PrometheusTimeSeriesQuery } from './'; const datasource: PrometheusDatasourceSpec = { diff --git a/prometheus/src/plugins/prometheus-time-series-query/query-editor-model.ts b/prometheus/src/plugins/prometheus-time-series-query/query-editor-model.ts index dabdc459c..f5b94736f 100644 --- a/prometheus/src/plugins/prometheus-time-series-query/query-editor-model.ts +++ b/prometheus/src/plugins/prometheus-time-series-query/query-editor-model.ts @@ -11,12 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { DurationString } from '@perses-dev/spec'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { DurationString } from '@perses-dev/spec'; import { produce } from 'immer'; import { useState } from 'react'; -import { PrometheusTimeSeriesQuerySpec } from './time-series-query-model'; +import type { PrometheusTimeSeriesQuerySpec } from './time-series-query-model'; export type PrometheusTimeSeriesQueryEditorProps = OptionsEditorProps; diff --git a/prometheus/src/plugins/prometheus-time-series-query/time-series-query-model.ts b/prometheus/src/plugins/prometheus-time-series-query/time-series-query-model.ts index 1fc694d01..05f6d793f 100644 --- a/prometheus/src/plugins/prometheus-time-series-query/time-series-query-model.ts +++ b/prometheus/src/plugins/prometheus-time-series-query/time-series-query-model.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue } from '@perses-dev/plugin-system'; -import { DurationString } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import type { DurationString } from '@perses-dev/spec'; -import { PrometheusDatasourceSelector } from '../../model'; +import type { PrometheusDatasourceSelector } from '../../model'; /** * The spec/options for the PrometheusTimeSeriesQuery plugin. */ diff --git a/prometheus/src/plugins/prometheus-variables.tsx b/prometheus/src/plugins/prometheus-variables.tsx index ccbca741e..99d47c9da 100644 --- a/prometheus/src/plugins/prometheus-variables.tsx +++ b/prometheus/src/plugins/prometheus-variables.tsx @@ -11,31 +11,22 @@ // See the License for the specific language governing permissions and // limitations under the License. import { FormControl, Stack, TextField } from '@mui/material'; +import type { DatasourceSelectProps, OptionsEditorProps, VariableOption } from '@perses-dev/plugin-system'; import { DatasourceSelect, - DatasourceSelectProps, isVariableDatasource, - OptionsEditorProps, useDatasourceClient, useDatasourceSelectValueToSelector, - VariableOption, } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback, ChangeEvent, FocusEvent } from 'react'; +import type { ReactElement, ChangeEvent, FocusEvent } from 'react'; +import { useCallback } from 'react'; import { PromQLEditor } from '../components'; -import { - DEFAULT_PROM, - isDefaultPromSelector, - isPrometheusDatasourceSelector, - MatrixData, - PROM_DATASOURCE_KIND, - PrometheusClient, - PrometheusDatasourceSelector, - VectorData, -} from '../model'; +import type { MatrixData, PrometheusClient, PrometheusDatasourceSelector, VectorData } from '../model'; +import { DEFAULT_PROM, isDefaultPromSelector, isPrometheusDatasourceSelector, PROM_DATASOURCE_KIND } from '../model'; import { MatcherEditor } from './MatcherEditor'; -import { +import type { PrometheusLabelNamesVariableOptions, PrometheusLabelValuesVariableOptions, PrometheusPromQLVariableOptions, diff --git a/prometheus/src/plugins/types.ts b/prometheus/src/plugins/types.ts index f87cae989..90004731f 100644 --- a/prometheus/src/plugins/types.ts +++ b/prometheus/src/plugins/types.ts @@ -11,11 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { QueryParamValues } from '@perses-dev/components'; -import { DatasourceSelectValue } from '@perses-dev/plugin-system'; -import { DurationString, HTTPProxy } from '@perses-dev/spec'; +import type { QueryParamValues } from '@perses-dev/components'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import type { DurationString, HTTPProxy } from '@perses-dev/spec'; -import { PrometheusDatasourceSelector } from '../model'; +import type { PrometheusDatasourceSelector } from '../model'; export const DEFAULT_SCRAPE_INTERVAL: DurationString = '1m'; diff --git a/prometheus/src/plugins/variable.tsx b/prometheus/src/plugins/variable.tsx index 1bf34f395..69b135e06 100644 --- a/prometheus/src/plugins/variable.tsx +++ b/prometheus/src/plugins/variable.tsx @@ -12,8 +12,8 @@ // limitations under the License. import { Autocomplete, TextField } from '@mui/material'; -import { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; type StaticListOption = string | VariableOption; diff --git a/prometheus/src/utils/utils.test.ts b/prometheus/src/utils/utils.test.ts index 4037afc46..ab3048f1a 100644 --- a/prometheus/src/utils/utils.test.ts +++ b/prometheus/src/utils/utils.test.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Metric } from '../model/api-types'; +import type { Metric } from '../model/api-types'; import { formatSeriesName, getFormattedPrometheusSeriesName, getUniqueKeyForPrometheusResult } from './utils'; describe('formatSeriesName', () => { diff --git a/prometheus/src/utils/utils.ts b/prometheus/src/utils/utils.ts index 84109fdee..b71a328e2 100644 --- a/prometheus/src/utils/utils.ts +++ b/prometheus/src/utils/utils.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Metric } from '../model/api-types'; +import type { Metric } from '../model/api-types'; /** * Types for metric labels, used in seriesNameFormat implementation diff --git a/prometheus/tsconfig.build.json b/prometheus/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/prometheus/tsconfig.build.json +++ b/prometheus/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/prometheus/tsconfig.json b/prometheus/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/prometheus/tsconfig.json +++ b/prometheus/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/prometheus/vitest.config.ts b/prometheus/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/prometheus/vitest.config.ts +++ b/prometheus/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/pyroscope/package.json b/pyroscope/package.json index d95a4936b..0030e4b33 100644 --- a/pyroscope/package.json +++ b/pyroscope/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -33,11 +33,11 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/client": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/explore": "^0.55.0-beta.3", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/client": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/explore": "^0.55.0-beta.6", "@tanstack/react-query": "^4.39.1", "@uiw/react-codemirror": "^4.19.1", "date-fns": "^4.1.0", diff --git a/pyroscope/src/components/AddFilterItem.tsx b/pyroscope/src/components/AddFilterItem.tsx index d480d34ad..1db253008 100644 --- a/pyroscope/src/components/AddFilterItem.tsx +++ b/pyroscope/src/components/AddFilterItem.tsx @@ -13,7 +13,7 @@ import { ToolbarIconButton } from '@perses-dev/components'; import PlusIcon from 'mdi-material-ui/Plus'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; export interface AddFilterItemProps { onClick: () => void; diff --git a/pyroscope/src/components/DeleteFilterItem.tsx b/pyroscope/src/components/DeleteFilterItem.tsx index 87d1ca418..bf8da603f 100644 --- a/pyroscope/src/components/DeleteFilterItem.tsx +++ b/pyroscope/src/components/DeleteFilterItem.tsx @@ -13,7 +13,7 @@ import { ToolbarIconButton } from '@perses-dev/components'; import CloseIcon from 'mdi-material-ui/Close'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; export interface DeleteFilterItemProps { onClick: () => void; diff --git a/pyroscope/src/components/FilterItem.tsx b/pyroscope/src/components/FilterItem.tsx index 36bf064ae..48cc73bd5 100644 --- a/pyroscope/src/components/FilterItem.tsx +++ b/pyroscope/src/components/FilterItem.tsx @@ -12,10 +12,10 @@ // limitations under the License. import { Grid2 as Grid, Stack } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { PyroscopeDatasourceSelector } from '../model'; -import { LabelFilter, OperatorType } from '../utils/types'; +import type { PyroscopeDatasourceSelector } from '../model'; +import type { LabelFilter, OperatorType } from '../utils/types'; import { DeleteFilterItem } from './DeleteFilterItem'; import { LabelName } from './LabelName'; import { LabelValue } from './LabelValue'; diff --git a/pyroscope/src/components/Filters.tsx b/pyroscope/src/components/Filters.tsx index d470925b3..b8e5ebae2 100644 --- a/pyroscope/src/components/Filters.tsx +++ b/pyroscope/src/components/Filters.tsx @@ -12,10 +12,10 @@ // limitations under the License. import { InputLabel, Stack, useTheme } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { PyroscopeDatasourceSelector } from '../model'; -import { LabelFilter } from '../utils/types'; +import type { PyroscopeDatasourceSelector } from '../model'; +import type { LabelFilter } from '../utils/types'; import { AddFilterItem } from './AddFilterItem'; import { FilterItem } from './FilterItem'; diff --git a/pyroscope/src/components/LabelName.tsx b/pyroscope/src/components/LabelName.tsx index bcd26b700..e1477e5de 100644 --- a/pyroscope/src/components/LabelName.tsx +++ b/pyroscope/src/components/LabelName.tsx @@ -12,9 +12,10 @@ // limitations under the License. import { TextField, Autocomplete } from '@mui/material'; -import { ReactElement, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { PyroscopeDatasourceSelector } from '../model'; +import type { PyroscopeDatasourceSelector } from '../model'; import { useLabelNames, filterLabelNamesOptions } from '../utils/use-query'; export interface LabelNameProps { diff --git a/pyroscope/src/components/LabelValue.tsx b/pyroscope/src/components/LabelValue.tsx index aa91003fd..99cd9fb0b 100644 --- a/pyroscope/src/components/LabelValue.tsx +++ b/pyroscope/src/components/LabelValue.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { TextField, Autocomplete } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { PyroscopeDatasourceSelector } from '../model'; +import type { PyroscopeDatasourceSelector } from '../model'; import { useLabelValues } from '../utils/use-query'; export interface LabelValueProps { diff --git a/pyroscope/src/components/Operator.tsx b/pyroscope/src/components/Operator.tsx index baa6c4096..65f3fa411 100644 --- a/pyroscope/src/components/Operator.tsx +++ b/pyroscope/src/components/Operator.tsx @@ -12,7 +12,7 @@ // limitations under the License. import { Select, MenuItem } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; export interface OperatorProps { value: string; diff --git a/pyroscope/src/components/ProfileTypeSelector.tsx b/pyroscope/src/components/ProfileTypeSelector.tsx index 506fe8a7a..a7a7aa85f 100644 --- a/pyroscope/src/components/ProfileTypeSelector.tsx +++ b/pyroscope/src/components/ProfileTypeSelector.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { Stack, TextField, MenuItem, CircularProgress } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { PyroscopeDatasourceSelector } from '../model'; +import type { PyroscopeDatasourceSelector } from '../model'; import { useProfileTypes } from '../utils/use-query'; export interface ProfileTypeSelectorProps { diff --git a/pyroscope/src/components/Service.tsx b/pyroscope/src/components/Service.tsx index 88b8ef786..3e6c27e84 100644 --- a/pyroscope/src/components/Service.tsx +++ b/pyroscope/src/components/Service.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { Stack, TextField, Autocomplete } from '@mui/material'; -import { ReactElement, SyntheticEvent } from 'react'; +import type { ReactElement, SyntheticEvent } from 'react'; -import { PyroscopeDatasourceSelector } from '../model'; +import type { PyroscopeDatasourceSelector } from '../model'; import { useServices } from '../utils/use-query'; export interface ServiceProps { diff --git a/pyroscope/src/explore/PyroscopeExplorer.tsx b/pyroscope/src/explore/PyroscopeExplorer.tsx index 4d057b64a..8eacf5970 100644 --- a/pyroscope/src/explore/PyroscopeExplorer.tsx +++ b/pyroscope/src/explore/PyroscopeExplorer.tsx @@ -15,10 +15,12 @@ import { Alert, Box, Stack } from '@mui/material'; import { Panel } from '@perses-dev/dashboards'; import { useExplorerManagerContext } from '@perses-dev/explore'; import { DataQueriesProvider, MultiQueryEditor } from '@perses-dev/plugin-system'; -import { QueryDefinition } from '@perses-dev/spec'; -import { ReactElement, useState } from 'react'; +import type { QueryDefinition } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; +import { useState } from 'react'; -import { isProfileQueryComplete, PyroscopeProfileQuerySpec } from '../model'; +import type { PyroscopeProfileQuerySpec } from '../model'; +import { isProfileQueryComplete } from '../model'; interface ProfilesExplorerQueryParams { queries?: QueryDefinition[]; diff --git a/pyroscope/src/getPluginModule.ts b/pyroscope/src/getPluginModule.ts index 515511f2f..6dee4f848 100644 --- a/pyroscope/src/getPluginModule.ts +++ b/pyroscope/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/pyroscope/src/model/profile-query-model.ts b/pyroscope/src/model/profile-query-model.ts index cdbf9507a..dad0ae169 100644 --- a/pyroscope/src/model/profile-query-model.ts +++ b/pyroscope/src/model/profile-query-model.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LabelFilter } from '../utils/types'; -import { PyroscopeDatasourceSelector } from './pyroscope-selectors'; +import type { LabelFilter } from '../utils/types'; +import type { PyroscopeDatasourceSelector } from './pyroscope-selectors'; /** * The spec/options for the PyroscopeProfileQuery plugin. */ diff --git a/pyroscope/src/model/pyroscope-client.ts b/pyroscope/src/model/pyroscope-client.ts index 571ffe925..ac2facd3f 100644 --- a/pyroscope/src/model/pyroscope-client.ts +++ b/pyroscope/src/model/pyroscope-client.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { RequestHeaders } from '@perses-dev/client'; -import { DatasourceClient } from '@perses-dev/plugin-system'; +import type { RequestHeaders } from '@perses-dev/client'; +import type { DatasourceClient } from '@perses-dev/plugin-system'; -import { +import type { SearchProfileTypesParameters, SearchProfileTypesResponse, SearchLabelNamesParameters, diff --git a/pyroscope/src/model/pyroscope-selectors.ts b/pyroscope/src/model/pyroscope-selectors.ts index b2a68091f..00fe6bc35 100644 --- a/pyroscope/src/model/pyroscope-selectors.ts +++ b/pyroscope/src/model/pyroscope-selectors.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export const PYROSCOPE_DATASOURCE_KIND = 'PyroscopeDatasource' as const; diff --git a/pyroscope/src/plugins/PyroscopeDatasourceEditor.tsx b/pyroscope/src/plugins/PyroscopeDatasourceEditor.tsx index 2af9eb7ad..9c5b1b93b 100644 --- a/pyroscope/src/plugins/PyroscopeDatasourceEditor.tsx +++ b/pyroscope/src/plugins/PyroscopeDatasourceEditor.tsx @@ -12,9 +12,10 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import React, { ReactElement } from 'react'; +import type { ReactElement } from 'react'; +import React from 'react'; -import { PyroscopeDatasourceSpec } from './pyroscope-datasource-types'; +import type { PyroscopeDatasourceSpec } from './pyroscope-datasource-types'; export interface PyroscopeDatasourceEditorProps { value: PyroscopeDatasourceSpec; diff --git a/pyroscope/src/plugins/pyroscope-datasource-types.tsx b/pyroscope/src/plugins/pyroscope-datasource-types.tsx index a364afc41..139355c57 100644 --- a/pyroscope/src/plugins/pyroscope-datasource-types.tsx +++ b/pyroscope/src/plugins/pyroscope-datasource-types.tsx @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { HTTPProxy } from '@perses-dev/spec'; +import type { HTTPProxy } from '@perses-dev/spec'; export interface PyroscopeDatasourceSpec { directUrl?: string; diff --git a/pyroscope/src/plugins/pyroscope-datasource.tsx b/pyroscope/src/plugins/pyroscope-datasource.tsx index 15c6a59e1..bc678d3c5 100644 --- a/pyroscope/src/plugins/pyroscope-datasource.tsx +++ b/pyroscope/src/plugins/pyroscope-datasource.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { PyroscopeClient } from '../model/pyroscope-client'; import { - PyroscopeClient, selectMergeStacktraces, selectSeries, searchProfileTypes, @@ -22,7 +22,7 @@ import { searchLabelValues, searchServices, } from '../model/pyroscope-client'; -import { PyroscopeDatasourceSpec } from './pyroscope-datasource-types'; +import type { PyroscopeDatasourceSpec } from './pyroscope-datasource-types'; import { PyroscopeDatasourceEditor } from './PyroscopeDatasourceEditor'; /** diff --git a/pyroscope/src/plugins/pyroscope-profile-query/PyroscopeProfileQuery.ts b/pyroscope/src/plugins/pyroscope-profile-query/PyroscopeProfileQuery.ts index 61a3228e8..def110ac8 100644 --- a/pyroscope/src/plugins/pyroscope-profile-query/PyroscopeProfileQuery.ts +++ b/pyroscope/src/plugins/pyroscope-profile-query/PyroscopeProfileQuery.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LabelFilter } from '../../utils/types'; +import type { LabelFilter } from '../../utils/types'; import { getProfileData } from './get-profile-data'; import { PyroscopeProfileQueryEditor } from './PyroscopeProfileQueryEditor'; diff --git a/pyroscope/src/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.tsx b/pyroscope/src/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.tsx index dee22327b..f6ce06805 100644 --- a/pyroscope/src/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.tsx +++ b/pyroscope/src/plugins/pyroscope-profile-query/PyroscopeProfileQueryEditor.tsx @@ -13,25 +13,21 @@ import { FormControl, InputLabel, Stack, TextField, useTheme } from '@mui/material'; import { useId } from '@perses-dev/components'; -import { DatasourceSelect, DatasourceSelectProps, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { ProfileTypeSelector, Service, Filters } from '../../components'; +import type { PyroscopeDatasourceSelector } from '../../model'; import { DEFAULT_PYROSCOPE, isDefaultPyroscopeSelector, isPyroscopeDatasourceSelector, PYROSCOPE_DATASOURCE_KIND, - PyroscopeDatasourceSelector, } from '../../model'; -import { - ProfileQueryEditorProps, - useMaxNodesState, - useProfileTypeState, - useServiceState, - useFiltersState, -} from './query-editor-model'; +import type { ProfileQueryEditorProps } from './query-editor-model'; +import { useMaxNodesState, useProfileTypeState, useServiceState, useFiltersState } from './query-editor-model'; export function PyroscopeProfileQueryEditor(props: ProfileQueryEditorProps): ReactElement { const { onChange, value } = props; diff --git a/pyroscope/src/plugins/pyroscope-profile-query/get-profile-data.test.ts b/pyroscope/src/plugins/pyroscope-profile-query/get-profile-data.test.ts index 323ef3eea..0f0ff26ed 100644 --- a/pyroscope/src/plugins/pyroscope-profile-query/get-profile-data.test.ts +++ b/pyroscope/src/plugins/pyroscope-profile-query/get-profile-data.test.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ProfileQueryContext } from '@perses-dev/plugin-system'; -import { StackTrace } from '@perses-dev/spec'; +import type { ProfileQueryContext } from '@perses-dev/plugin-system'; +import type { StackTrace } from '@perses-dev/spec'; -import { +import type { FlameGraph, Series, PyroscopeClient, diff --git a/pyroscope/src/plugins/pyroscope-profile-query/get-profile-data.ts b/pyroscope/src/plugins/pyroscope-profile-query/get-profile-data.ts index d7c3395a0..706081b8b 100644 --- a/pyroscope/src/plugins/pyroscope-profile-query/get-profile-data.ts +++ b/pyroscope/src/plugins/pyroscope-profile-query/get-profile-data.ts @@ -11,20 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ProfileQueryPlugin } from '@perses-dev/plugin-system'; -import { AbsoluteTimeRange, ProfileData, StackTrace, Timeline } from '@perses-dev/spec'; +import type { ProfileQueryPlugin } from '@perses-dev/plugin-system'; +import type { AbsoluteTimeRange, ProfileData, StackTrace, Timeline } from '@perses-dev/spec'; import { getUnixTime } from 'date-fns'; -import { +import type { PyroscopeProfileQuerySpec, - isProfileQueryComplete, - DEFAULT_PYROSCOPE, PyroscopeClient, SelectMergeStacktracesRequest, SelectSeriesRequest, FlameGraph, Series, } from '../../model'; +import { DEFAULT_PYROSCOPE, isProfileQueryComplete } from '../../model'; import { computeFilterExpr } from '../../utils/types'; // Pyroscope's Connect API expects timestamps in milliseconds; Perses time ranges are in seconds. diff --git a/pyroscope/src/plugins/pyroscope-profile-query/query-editor-model.ts b/pyroscope/src/plugins/pyroscope-profile-query/query-editor-model.ts index b2e1b1320..fc8df2c81 100644 --- a/pyroscope/src/plugins/pyroscope-profile-query/query-editor-model.ts +++ b/pyroscope/src/plugins/pyroscope-profile-query/query-editor-model.ts @@ -11,12 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import { useState } from 'react'; -import { PyroscopeProfileQuerySpec } from '../../model/profile-query-model'; -import { LabelFilter } from '../../utils/types'; +import type { PyroscopeProfileQuerySpec } from '../../model/profile-query-model'; +import type { LabelFilter } from '../../utils/types'; export type ProfileQueryEditorProps = OptionsEditorProps; diff --git a/pyroscope/src/test/mock-data.ts b/pyroscope/src/test/mock-data.ts index 19718ed68..1ab83ba88 100644 --- a/pyroscope/src/test/mock-data.ts +++ b/pyroscope/src/test/mock-data.ts @@ -11,7 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { SearchProfileTypesResponse, SearchLabelNamesResponse, SearchLabelValuesResponse } from '../model/api-types'; +import type { + SearchProfileTypesResponse, + SearchLabelNamesResponse, + SearchLabelValuesResponse, +} from '../model/api-types'; export const MOCK_PROFILE_TYPES_RESPONSE: SearchProfileTypesResponse = { profileTypes: [ diff --git a/pyroscope/src/utils/use-query.ts b/pyroscope/src/utils/use-query.ts index a3bd00454..9f23fe595 100644 --- a/pyroscope/src/utils/use-query.ts +++ b/pyroscope/src/utils/use-query.ts @@ -11,12 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { StatusError } from '@perses-dev/client'; +import type { StatusError } from '@perses-dev/client'; import { useDatasourceClient, useTimeRange } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; -import { useQuery, UseQueryResult } from '@tanstack/react-query'; +import type { DatasourceSelector } from '@perses-dev/spec'; +import type { UseQueryResult } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; -import { +import type { SearchLabelNamesResponse, SearchLabelValuesResponse, SearchProfileTypesResponse, diff --git a/pyroscope/tsconfig.build.json b/pyroscope/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/pyroscope/tsconfig.build.json +++ b/pyroscope/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/pyroscope/tsconfig.json b/pyroscope/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/pyroscope/tsconfig.json +++ b/pyroscope/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/pyroscope/vitest.config.ts b/pyroscope/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/pyroscope/vitest.config.ts +++ b/pyroscope/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/scatterchart/package.json b/scatterchart/package.json index 249672cf9..78a4e00d5 100644 --- a/scatterchart/package.json +++ b/scatterchart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -32,8 +32,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/scatterchart/src/ScatterChart.ts b/scatterchart/src/ScatterChart.ts index ea7306eb7..46c97c6b2 100644 --- a/scatterchart/src/ScatterChart.ts +++ b/scatterchart/src/ScatterChart.ts @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { createInitialScatterChartOptions, ScatterChartOptions } from './scatter-chart-model'; -import { ScatterChartPanel, ScatterChartPanelProps } from './ScatterChartPanel'; +import type { ScatterChartOptions } from './scatter-chart-model'; +import { createInitialScatterChartOptions } from './scatter-chart-model'; +import type { ScatterChartPanelProps } from './ScatterChartPanel'; +import { ScatterChartPanel } from './ScatterChartPanel'; /** * The core ScatterChart panel plugin for Perses. diff --git a/scatterchart/src/ScatterChartPanel.test.tsx b/scatterchart/src/ScatterChartPanel.test.tsx index 25b940fee..4bbde22c6 100644 --- a/scatterchart/src/ScatterChartPanel.test.tsx +++ b/scatterchart/src/ScatterChartPanel.test.tsx @@ -13,14 +13,16 @@ import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; import { VariableProvider } from '@perses-dev/dashboards'; -import { PanelData, ReactRouterProvider, TimeRangeProviderBasic } from '@perses-dev/plugin-system'; -import { TraceData } from '@perses-dev/spec'; +import type { PanelData } from '@perses-dev/plugin-system'; +import { ReactRouterProvider, TimeRangeProviderBasic } from '@perses-dev/plugin-system'; +import type { TraceData } from '@perses-dev/spec'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { screen, render } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import { MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT, MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT_EMPTY } from './mock-trace-data'; -import { getSymbolSize, ScatterChartPanel, ScatterChartPanelProps } from './ScatterChartPanel'; +import type { ScatterChartPanelProps } from './ScatterChartPanel'; +import { getSymbolSize, ScatterChartPanel } from './ScatterChartPanel'; const TEST_SCATTER_PANEL: Omit = { contentDimensions: { diff --git a/scatterchart/src/ScatterChartPanel.tsx b/scatterchart/src/ScatterChartPanel.tsx index 4aa6daaf0..22cef2a37 100644 --- a/scatterchart/src/ScatterChartPanel.tsx +++ b/scatterchart/src/ScatterChartPanel.tsx @@ -12,12 +12,13 @@ // limitations under the License. import { NoDataOverlay, useChartsTheme } from '@perses-dev/components'; -import { PanelProps } from '@perses-dev/plugin-system'; -import { TraceData, TraceSearchResult } from '@perses-dev/spec'; -import { EChartsOption, SeriesOption } from 'echarts'; -import { ReactElement, useMemo } from 'react'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import type { TraceData, TraceSearchResult } from '@perses-dev/spec'; +import type { EChartsOption, SeriesOption } from 'echarts'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { ScatterChartOptions } from './scatter-chart-model'; +import type { ScatterChartOptions } from './scatter-chart-model'; import { Scatterplot } from './Scatterplot'; export interface EChartTraceValue extends Omit { diff --git a/scatterchart/src/Scatterplot.tsx b/scatterchart/src/Scatterplot.tsx index fe52484fd..2d8d20e5a 100644 --- a/scatterchart/src/Scatterplot.tsx +++ b/scatterchart/src/Scatterplot.tsx @@ -11,14 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { EChart, formatValue, OnEventsType, useChartsTheme, useTimeZone } from '@perses-dev/components'; +import type { OnEventsType } from '@perses-dev/components'; +import { EChart, formatValue, useChartsTheme, useTimeZone } from '@perses-dev/components'; import { replaceVariablesInString, useAllVariableValues, useRouterContext, useTimeRange, } from '@perses-dev/plugin-system'; -import { EChartsOption, ScatterSeriesOption } from 'echarts'; +import type { EChartsOption, ScatterSeriesOption } from 'echarts'; import { ScatterChart as EChartsScatterChart } from 'echarts/charts'; import { DatasetComponent, @@ -28,11 +29,13 @@ import { TitleComponent, TooltipComponent, } from 'echarts/components'; -import { use as registerECharts, EChartsCoreOption } from 'echarts/core'; +import type { EChartsCoreOption } from 'echarts/core'; +import { use as registerECharts } from 'echarts/core'; import { CanvasRenderer } from 'echarts/renderers'; -import { ReactElement, useCallback, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useMemo } from 'react'; -import { EChartTraceValue } from './ScatterChartPanel'; +import type { EChartTraceValue } from './ScatterChartPanel'; import { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter'; registerECharts([ diff --git a/scatterchart/src/getPluginModule.ts b/scatterchart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/scatterchart/src/getPluginModule.ts +++ b/scatterchart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/scatterchart/src/mock-trace-data.ts b/scatterchart/src/mock-trace-data.ts index 362241309..6dc225d89 100644 --- a/scatterchart/src/mock-trace-data.ts +++ b/scatterchart/src/mock-trace-data.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TraceData } from '@perses-dev/spec'; +import type { TraceData } from '@perses-dev/spec'; /** * Mock data we get from getTraceData() in @perses/tempo-plugin. diff --git a/scatterchart/src/scatter-chart-model.ts b/scatterchart/src/scatter-chart-model.ts index bf37198ab..74908828c 100644 --- a/scatterchart/src/scatter-chart-model.ts +++ b/scatterchart/src/scatter-chart-model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { QueryDefinition, UnknownSpec } from '@perses-dev/spec'; +import type { QueryDefinition, UnknownSpec } from '@perses-dev/spec'; export type TraceQueryDefinition = QueryDefinition<'TraceQuery', PluginSpec>; diff --git a/scatterchart/tsconfig.build.json b/scatterchart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/scatterchart/tsconfig.build.json +++ b/scatterchart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/scatterchart/tsconfig.json b/scatterchart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/scatterchart/tsconfig.json +++ b/scatterchart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/scatterchart/vitest.config.ts b/scatterchart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/scatterchart/vitest.config.ts +++ b/scatterchart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/splunk/package.json b/splunk/package.json index 85ca0688d..0ca3debee 100644 --- a/splunk/package.json +++ b/splunk/package.json @@ -14,21 +14,21 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": {}, "peerDependencies": { "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "immer": "^10.1.1", "react": "^17.0.2 || ^18.0.0" }, diff --git a/splunk/src/datasources/splunk-datasource/SplunkDatasource.tsx b/splunk/src/datasources/splunk-datasource/SplunkDatasource.tsx index 7ee9593b1..ee6cddd8b 100644 --- a/splunk/src/datasources/splunk-datasource/SplunkDatasource.tsx +++ b/splunk/src/datasources/splunk-datasource/SplunkDatasource.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { SplunkClient } from '../../model/splunk-client'; import { - SplunkClient, createJob, getJobStatus, getJobResults, @@ -22,7 +22,7 @@ import { exportSearch, getIndexes, } from '../../model/splunk-client'; -import { SplunkDatasourceSpec } from './splunk-datasource-types'; +import type { SplunkDatasourceSpec } from './splunk-datasource-types'; import { SplunkDatasourceEditor } from './SplunkDatasourceEditor'; const createClient: DatasourcePlugin['createClient'] = (spec, options) => { diff --git a/splunk/src/datasources/splunk-datasource/SplunkDatasourceEditor.tsx b/splunk/src/datasources/splunk-datasource/SplunkDatasourceEditor.tsx index c88d389af..ed0330bee 100644 --- a/splunk/src/datasources/splunk-datasource/SplunkDatasourceEditor.tsx +++ b/splunk/src/datasources/splunk-datasource/SplunkDatasourceEditor.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { SplunkDatasourceSpec } from './splunk-datasource-types'; +import type { SplunkDatasourceSpec } from './splunk-datasource-types'; export interface SplunkDatasourceEditorProps { value: SplunkDatasourceSpec; diff --git a/splunk/src/datasources/splunk-datasource/splunk-datasource-types.ts b/splunk/src/datasources/splunk-datasource/splunk-datasource-types.ts index 87d8ceed0..bb0c6a0d8 100644 --- a/splunk/src/datasources/splunk-datasource/splunk-datasource-types.ts +++ b/splunk/src/datasources/splunk-datasource/splunk-datasource-types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { HTTPProxy } from '@perses-dev/spec'; +import type { HTTPProxy } from '@perses-dev/spec'; export interface SplunkDatasourceSpec { directUrl?: string; diff --git a/splunk/src/getPluginModule.ts b/splunk/src/getPluginModule.ts index 515511f2f..6dee4f848 100644 --- a/splunk/src/getPluginModule.ts +++ b/splunk/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/splunk/src/model/splunk-client.ts b/splunk/src/model/splunk-client.ts index c01bf6e4e..84595576c 100644 --- a/splunk/src/model/splunk-client.ts +++ b/splunk/src/model/splunk-client.ts @@ -13,7 +13,7 @@ import { fetchJson } from '@perses-dev/client'; -import { +import type { SplunkJobCreateResponse, SplunkJobStatusResponse, SplunkResultsResponse, diff --git a/splunk/src/queries/splunk-log-query/SplunkLogQuery.test.ts b/splunk/src/queries/splunk-log-query/SplunkLogQuery.test.ts index d0ec2b15f..99cfd91e5 100644 --- a/splunk/src/queries/splunk-log-query/SplunkLogQuery.test.ts +++ b/splunk/src/queries/splunk-log-query/SplunkLogQuery.test.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogQueryContext } from './log-query-plugin-interface'; +import type { LogQueryContext } from './log-query-plugin-interface'; import { SplunkLogQuery } from './SplunkLogQuery'; const createStubContext = (): LogQueryContext => ({ diff --git a/splunk/src/queries/splunk-log-query/SplunkLogQuery.tsx b/splunk/src/queries/splunk-log-query/SplunkLogQuery.tsx index d1a84a969..afff6cd8a 100644 --- a/splunk/src/queries/splunk-log-query/SplunkLogQuery.tsx +++ b/splunk/src/queries/splunk-log-query/SplunkLogQuery.tsx @@ -14,8 +14,8 @@ import { parseVariables } from '@perses-dev/plugin-system'; import { getSplunkLogData } from './get-splunk-log-data'; -import { LogQueryPlugin } from './log-query-plugin-interface'; -import { SplunkLogQuerySpec } from './splunk-log-query-types'; +import type { LogQueryPlugin } from './log-query-plugin-interface'; +import type { SplunkLogQuerySpec } from './splunk-log-query-types'; import { SplunkLogQueryEditor } from './SplunkLogQueryEditor'; export const SplunkLogQuery: LogQueryPlugin = { diff --git a/splunk/src/queries/splunk-log-query/SplunkLogQueryEditor.tsx b/splunk/src/queries/splunk-log-query/SplunkLogQueryEditor.tsx index 837c455c4..29a1b0d90 100644 --- a/splunk/src/queries/splunk-log-query/SplunkLogQueryEditor.tsx +++ b/splunk/src/queries/splunk-log-query/SplunkLogQueryEditor.tsx @@ -12,17 +12,12 @@ // limitations under the License. import { Box, InputLabel, Stack, TextField } from '@mui/material'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { SplunkLogQuerySpec } from './splunk-log-query-types'; +import type { SplunkLogQuerySpec } from './splunk-log-query-types'; const DATASOURCE_KIND = 'SplunkDatasource'; const DEFAULT_DATASOURCE = { kind: DATASOURCE_KIND }; diff --git a/splunk/src/queries/splunk-log-query/get-splunk-log-data.ts b/splunk/src/queries/splunk-log-query/get-splunk-log-data.ts index e63177f80..97ce03c47 100644 --- a/splunk/src/queries/splunk-log-query/get-splunk-log-data.ts +++ b/splunk/src/queries/splunk-log-query/get-splunk-log-data.ts @@ -12,19 +12,19 @@ // limitations under the License. import { replaceVariables } from '@perses-dev/plugin-system'; -import { HTTPAllowedEndpoint, LogData, LogEntry } from '@perses-dev/spec'; +import type { HTTPAllowedEndpoint, LogData, LogEntry } from '@perses-dev/spec'; -import { SplunkDatasourceSpec } from '../../datasources/splunk-datasource/splunk-datasource-types'; -import { SplunkClient } from '../../model/splunk-client'; -import { +import type { SplunkDatasourceSpec } from '../../datasources/splunk-datasource/splunk-datasource-types'; +import type { SplunkClient } from '../../model/splunk-client'; +import type { SplunkIndexResponse, SplunkJobCreateResponse, SplunkJobStatusResponse, SplunkResultsResponse, } from '../../model/splunk-client-types'; import { DEFAULT_DATASOURCE } from '../constants'; -import { LogQueryPlugin, LogQueryContext } from './log-query-plugin-interface'; -import { SplunkLogQuerySpec } from './splunk-log-query-types'; +import type { LogQueryPlugin, LogQueryContext } from './log-query-plugin-interface'; +import type { SplunkLogQuerySpec } from './splunk-log-query-types'; function convertResultsToLogs( results: diff --git a/splunk/src/queries/splunk-log-query/log-query-plugin-interface.ts b/splunk/src/queries/splunk-log-query/log-query-plugin-interface.ts index add4b175b..91f2073ac 100644 --- a/splunk/src/queries/splunk-log-query/log-query-plugin-interface.ts +++ b/splunk/src/queries/splunk-log-query/log-query-plugin-interface.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system'; -import { AbsoluteTimeRange, LogData, UnknownSpec } from '@perses-dev/spec'; +import type { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system'; +import type { AbsoluteTimeRange, LogData, UnknownSpec } from '@perses-dev/spec'; export interface LogQueryResult { logs: LogData; diff --git a/splunk/src/queries/splunk-log-query/splunk-log-query-types.ts b/splunk/src/queries/splunk-log-query/splunk-log-query-types.ts index 16209b050..121385b25 100644 --- a/splunk/src/queries/splunk-log-query/splunk-log-query-types.ts +++ b/splunk/src/queries/splunk-log-query/splunk-log-query-types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; -import { SplunkLogResults } from '../../model/splunk-client-types'; +import type { SplunkLogResults } from '../../model/splunk-client-types'; export interface SplunkLogQuerySpec { query: string; diff --git a/splunk/src/queries/splunk-time-series-query/SplunkTimeSeriesQuery.tsx b/splunk/src/queries/splunk-time-series-query/SplunkTimeSeriesQuery.tsx index 0970f56a8..242bc1390 100644 --- a/splunk/src/queries/splunk-time-series-query/SplunkTimeSeriesQuery.tsx +++ b/splunk/src/queries/splunk-time-series-query/SplunkTimeSeriesQuery.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, parseVariables } from '@perses-dev/plugin-system'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; import { getSplunkTimeSeriesData } from './get-splunk-time-series-data'; -import { SplunkTimeSeriesQuerySpec } from './splunk-time-series-query-types'; +import type { SplunkTimeSeriesQuerySpec } from './splunk-time-series-query-types'; import { SplunkTimeSeriesQueryEditor } from './SplunkTimeSeriesQueryEditor'; export const SplunkTimeSeriesQuery: TimeSeriesQueryPlugin = { diff --git a/splunk/src/queries/splunk-time-series-query/SplunkTimeSeriesQueryEditor.tsx b/splunk/src/queries/splunk-time-series-query/SplunkTimeSeriesQueryEditor.tsx index 99260261e..56899ca54 100644 --- a/splunk/src/queries/splunk-time-series-query/SplunkTimeSeriesQueryEditor.tsx +++ b/splunk/src/queries/splunk-time-series-query/SplunkTimeSeriesQueryEditor.tsx @@ -12,17 +12,12 @@ // limitations under the License. import { Box, InputLabel, Stack, TextField } from '@mui/material'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { SplunkTimeSeriesQuerySpec } from './splunk-time-series-query-types'; +import type { SplunkTimeSeriesQuerySpec } from './splunk-time-series-query-types'; const DATASOURCE_KIND = 'SplunkDatasource'; const DEFAULT_DATASOURCE = { kind: DATASOURCE_KIND }; diff --git a/splunk/src/queries/splunk-time-series-query/get-splunk-time-series-data.ts b/splunk/src/queries/splunk-time-series-query/get-splunk-time-series-data.ts index 3a91d9190..12730db8b 100644 --- a/splunk/src/queries/splunk-time-series-query/get-splunk-time-series-data.ts +++ b/splunk/src/queries/splunk-time-series-query/get-splunk-time-series-data.ts @@ -11,14 +11,15 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, replaceVariables } from '@perses-dev/plugin-system'; -import { HTTPAllowedEndpoint, TimeSeries } from '@perses-dev/spec'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { HTTPAllowedEndpoint, TimeSeries } from '@perses-dev/spec'; -import { SplunkDatasourceSpec } from '../../datasources/splunk-datasource/splunk-datasource-types'; -import { SplunkJobCreateResponse, SplunkJobStatusResponse, SplunkResultsResponse } from '../../model'; -import { SplunkClient } from '../../model/splunk-client'; +import type { SplunkDatasourceSpec } from '../../datasources/splunk-datasource/splunk-datasource-types'; +import type { SplunkJobCreateResponse, SplunkJobStatusResponse, SplunkResultsResponse } from '../../model'; +import type { SplunkClient } from '../../model/splunk-client'; import { DEFAULT_DATASOURCE } from '../constants'; -import { SplunkTimeSeriesQuerySpec } from './splunk-time-series-query-types'; +import type { SplunkTimeSeriesQuerySpec } from './splunk-time-series-query-types'; function convertResultsToTimeSeries( results: Array<{ _time: string; [key: string]: string | number }> | { _time: string; [key: string]: string | number }, diff --git a/splunk/src/queries/splunk-time-series-query/splunk-time-series-query-types.ts b/splunk/src/queries/splunk-time-series-query/splunk-time-series-query-types.ts index 46bc70edc..67b2ceaea 100644 --- a/splunk/src/queries/splunk-time-series-query/splunk-time-series-query-types.ts +++ b/splunk/src/queries/splunk-time-series-query/splunk-time-series-query-types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; -import { SplunkTimeSeriesResults } from '../../model/splunk-client-types'; +import type { SplunkTimeSeriesResults } from '../../model/splunk-client-types'; export interface SplunkTimeSeriesQuerySpec { query: string; diff --git a/splunk/tsconfig.build.json b/splunk/tsconfig.build.json index 444018379..e1e5de66b 100644 --- a/splunk/tsconfig.build.json +++ b/splunk/tsconfig.build.json @@ -1,7 +1,11 @@ { "extends": "./tsconfig.json", "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "declaration": true, - "emitDeclarationOnly": true + "emitDeclarationOnly": true, + "declarationMap": true } } diff --git a/splunk/tsconfig.json b/splunk/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/splunk/tsconfig.json +++ b/splunk/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/splunk/vitest.config.ts b/splunk/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/splunk/vitest.config.ts +++ b/splunk/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/statchart/package.json b/statchart/package.json index c4a832765..958120b8c 100644 --- a/statchart/package.json +++ b/statchart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,8 +29,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/statchart/src/StatChart.ts b/statchart/src/StatChart.ts index 074a8ac50..9b953e0ed 100644 --- a/statchart/src/StatChart.ts +++ b/statchart/src/StatChart.ts @@ -11,11 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { createInitialStatChartOptions, StatChartOptions } from './stat-chart-model'; +import type { StatChartOptions } from './stat-chart-model'; +import { createInitialStatChartOptions } from './stat-chart-model'; import { StatChartOptionsEditorSettings } from './StatChartOptionsEditorSettings'; -import { StatChartPanel, StatChartPanelProps } from './StatChartPanel'; +import type { StatChartPanelProps } from './StatChartPanel'; +import { StatChartPanel } from './StatChartPanel'; import { StatChartValueMappingEditor } from './StatChartValueMappingEditor'; /** diff --git a/statchart/src/StatChartBase.test.tsx b/statchart/src/StatChartBase.test.tsx index db886999e..fa1f41b0c 100644 --- a/statchart/src/StatChartBase.test.tsx +++ b/statchart/src/StatChartBase.test.tsx @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ChartsProvider, FormatOptions, testChartsTheme } from '@perses-dev/components'; +import type { FormatOptions } from '@perses-dev/components'; +import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; import { render, screen } from '@testing-library/react'; -import { StatChartBase, StatChartData } from './StatChartBase'; +import type { StatChartData } from './StatChartBase'; +import { StatChartBase } from './StatChartBase'; vi.mock('./utils/calculate-font-size', () => ({ useOptimalFontSize: vi.fn().mockImplementation(() => 12), diff --git a/statchart/src/StatChartBase.tsx b/statchart/src/StatChartBase.tsx index 12d6ae7bc..2ac458ee1 100644 --- a/statchart/src/StatChartBase.tsx +++ b/statchart/src/StatChartBase.tsx @@ -12,16 +12,20 @@ // limitations under the License. import { Box, Typography, styled, useTheme } from '@mui/material'; -import { EChart, FontSizeOption, FormatOptions, GraphSeries, useChartsTheme } from '@perses-dev/components'; +import type { FontSizeOption, FormatOptions, GraphSeries } from '@perses-dev/components'; +import { EChart, useChartsTheme } from '@perses-dev/components'; import chroma from 'chroma-js'; -import { LineChart as EChartsLineChart, LineSeriesOption } from 'echarts/charts'; +import type { LineSeriesOption } from 'echarts/charts'; +import { LineChart as EChartsLineChart } from 'echarts/charts'; import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent } from 'echarts/components'; -import { use as registerECharts, EChartsCoreOption } from 'echarts/core'; +import type { EChartsCoreOption } from 'echarts/core'; +import { use as registerECharts } from 'echarts/core'; import { CanvasRenderer } from 'echarts/renderers'; import merge from 'lodash/merge'; -import { FC, ReactNode, useMemo } from 'react'; +import type { FC, ReactNode } from 'react'; +import { useMemo } from 'react'; -import { ColorMode } from './stat-chart-model'; +import type { ColorMode } from './stat-chart-model'; import { useOptimalFontSize } from './utils/calculate-font-size'; import { formatStatChartValue } from './utils/format-stat-chart-value'; diff --git a/statchart/src/StatChartOptionsEditorSettings.test.tsx b/statchart/src/StatChartOptionsEditorSettings.test.tsx index 5ed962b09..40e70cc04 100644 --- a/statchart/src/StatChartOptionsEditorSettings.test.tsx +++ b/statchart/src/StatChartOptionsEditorSettings.test.tsx @@ -15,7 +15,7 @@ import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { StatChartOptions } from './stat-chart-model'; +import type { StatChartOptions } from './stat-chart-model'; import { StatChartOptionsEditorSettings } from './StatChartOptionsEditorSettings'; describe('StatChartOptionsEditorSettings', () => { diff --git a/statchart/src/StatChartOptionsEditorSettings.tsx b/statchart/src/StatChartOptionsEditorSettings.tsx index 38c5a63a7..b965a2ff9 100644 --- a/statchart/src/StatChartOptionsEditorSettings.tsx +++ b/statchart/src/StatChartOptionsEditorSettings.tsx @@ -11,40 +11,39 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Switch, SwitchProps } from '@mui/material'; -import { +import type { SwitchProps } from '@mui/material'; +import { Switch } from '@mui/material'; +import type { FontSizeOption, - FontSizeSelector, FontSizeSelectorProps, - FormatControls, FormatControlsProps, FormatOptions, + ThresholdsEditorProps, +} from '@perses-dev/components'; +import { + FontSizeSelector, + FormatControls, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, SettingsAutocomplete, ThresholdsEditor, - ThresholdsEditorProps, } from '@perses-dev/components'; -import { - CalculationSelector, - CalculationSelectorProps, - MetricLabelInput, - MetricLabelInputProps, -} from '@perses-dev/plugin-system'; +import type { CalculationSelectorProps, MetricLabelInputProps } from '@perses-dev/plugin-system'; +import { CalculationSelector, MetricLabelInput } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import merge from 'lodash/merge'; -import { ReactElement, useCallback, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useMemo } from 'react'; -import { - COLOR_MODE_LABELS, +import type { ColorModeLabelItem, - SHOW_LEGEND_LABELS, ShowLegendLabelItem, StatChartOptions, StatChartOptionsEditorProps, } from './stat-chart-model'; +import { COLOR_MODE_LABELS, SHOW_LEGEND_LABELS } from './stat-chart-model'; const DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' }; diff --git a/statchart/src/StatChartPanel.tsx b/statchart/src/StatChartPanel.tsx index ceda33823..93cbe6ea1 100644 --- a/statchart/src/StatChartPanel.tsx +++ b/statchart/src/StatChartPanel.tsx @@ -11,22 +11,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Stack, Typography, SxProps } from '@mui/material'; -import { - useChartsTheme, - GraphSeries, - PersesChartsTheme, - ValueMapping, - applyValueMapping, - createRegexFromString, -} from '@perses-dev/components'; -import { PanelProps, PanelData } from '@perses-dev/plugin-system'; -import { Labels, TimeSeriesData } from '@perses-dev/spec'; -import { TitleComponentOption } from 'echarts'; -import { FC, useMemo } from 'react'; - -import { StatChartOptions } from './stat-chart-model'; -import { StatChartBase, StatChartData } from './StatChartBase'; +import type { SxProps } from '@mui/material'; +import { Stack, Typography } from '@mui/material'; +import type { GraphSeries, PersesChartsTheme, ValueMapping } from '@perses-dev/components'; +import { useChartsTheme, applyValueMapping, createRegexFromString } from '@perses-dev/components'; +import type { PanelProps, PanelData } from '@perses-dev/plugin-system'; +import type { Labels, TimeSeriesData } from '@perses-dev/spec'; +import type { TitleComponentOption } from 'echarts'; +import type { FC } from 'react'; +import { useMemo } from 'react'; + +import type { StatChartOptions } from './stat-chart-model'; +import type { StatChartData } from './StatChartBase'; +import { StatChartBase } from './StatChartBase'; import { calculateValue } from './utils/calculate-value'; import { convertSparkline } from './utils/data-transform'; import { getStatChartColor } from './utils/get-color'; diff --git a/statchart/src/StatChartValueMappingEditor.tsx b/statchart/src/StatChartValueMappingEditor.tsx index 37ea15070..67af0a34d 100644 --- a/statchart/src/StatChartValueMappingEditor.tsx +++ b/statchart/src/StatChartValueMappingEditor.tsx @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ValueMapping, ValueMappingsEditor } from '@perses-dev/components'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { FC } from 'react'; +import type { ValueMapping } from '@perses-dev/components'; +import { ValueMappingsEditor } from '@perses-dev/components'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { FC } from 'react'; -import { StatChartOptions } from './stat-chart-model'; +import type { StatChartOptions } from './stat-chart-model'; export type StatChartValueMappingEditorProps = OptionsEditorProps; diff --git a/statchart/src/getPluginModule.ts b/statchart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/statchart/src/getPluginModule.ts +++ b/statchart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/statchart/src/stat-chart-model.ts b/statchart/src/stat-chart-model.ts index b7ff3ff61..dee7a575f 100644 --- a/statchart/src/stat-chart-model.ts +++ b/statchart/src/stat-chart-model.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FontSizeOption, FormatOptions, ThresholdOptions, ValueMapping } from '@perses-dev/components'; -import { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system'; -import { Definition } from '@perses-dev/spec'; +import type { FontSizeOption, FormatOptions, ThresholdOptions, ValueMapping } from '@perses-dev/components'; +import type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { Definition } from '@perses-dev/spec'; /** * The schema for a StatChart panel. diff --git a/statchart/src/utils/calculate-font-size.test.ts b/statchart/src/utils/calculate-font-size.test.ts index 670485111..1d8819099 100644 --- a/statchart/src/utils/calculate-font-size.test.ts +++ b/statchart/src/utils/calculate-font-size.test.ts @@ -11,10 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type * as ComponentsModule from '@perses-dev/components'; + import { useOptimalFontSize } from './calculate-font-size'; vi.mock('@perses-dev/components', async (importOriginal) => { - const actual = await importOriginal(); + const actual = await importOriginal(); return { ...actual, useChartsTheme: vi.fn().mockReturnValue(actual.testChartsTheme), diff --git a/statchart/src/utils/calculate-font-size.ts b/statchart/src/utils/calculate-font-size.ts index 0d2fd5523..c5ef2ca8c 100644 --- a/statchart/src/utils/calculate-font-size.ts +++ b/statchart/src/utils/calculate-font-size.ts @@ -11,7 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FontSizeOption, useChartsTheme } from '@perses-dev/components'; +import type { FontSizeOption } from '@perses-dev/components'; +import { useChartsTheme } from '@perses-dev/components'; interface CalculateFontSize { text: string; diff --git a/statchart/src/utils/calculate-value.ts b/statchart/src/utils/calculate-value.ts index 76810902b..906357279 100644 --- a/statchart/src/utils/calculate-value.ts +++ b/statchart/src/utils/calculate-value.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CalculationsMap, CalculationType, DEFAULT_CALCULATION } from '@perses-dev/plugin-system'; -import { TimeSeries } from '@perses-dev/spec'; +import type { CalculationType } from '@perses-dev/plugin-system'; +import { CalculationsMap, DEFAULT_CALCULATION } from '@perses-dev/plugin-system'; +import type { TimeSeries } from '@perses-dev/spec'; export const calculateValue = ( calculation: CalculationType, diff --git a/statchart/src/utils/data-transform.test.ts b/statchart/src/utils/data-transform.test.ts index 691b40946..e69c0fc03 100644 --- a/statchart/src/utils/data-transform.test.ts +++ b/statchart/src/utils/data-transform.test.ts @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { testChartsTheme, ThresholdOptions } from '@perses-dev/components'; -import { LineSeriesOption } from 'echarts'; +import type { ThresholdOptions } from '@perses-dev/components'; +import { testChartsTheme } from '@perses-dev/components'; +import type { LineSeriesOption } from 'echarts'; -import { StatChartOptions, StatChartSparklineOptions } from '../stat-chart-model'; +import type { StatChartOptions, StatChartSparklineOptions } from '../stat-chart-model'; import { convertSparkline } from './data-transform'; import { getStatChartColor } from './get-color'; diff --git a/statchart/src/utils/data-transform.ts b/statchart/src/utils/data-transform.ts index ec49836d6..245cf78dd 100644 --- a/statchart/src/utils/data-transform.ts +++ b/statchart/src/utils/data-transform.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PersesChartsTheme } from '@perses-dev/components'; -import { LineSeriesOption } from 'echarts/charts'; +import type { PersesChartsTheme } from '@perses-dev/components'; +import type { LineSeriesOption } from 'echarts/charts'; -import { StatChartSparklineOptions } from '../stat-chart-model'; +import type { StatChartSparklineOptions } from '../stat-chart-model'; export function convertSparkline( chartsTheme: PersesChartsTheme, diff --git a/statchart/src/utils/format-stat-chart-value.ts b/statchart/src/utils/format-stat-chart-value.ts index f921725dc..3a80fa2c4 100644 --- a/statchart/src/utils/format-stat-chart-value.ts +++ b/statchart/src/utils/format-stat-chart-value.ts @@ -11,7 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions, formatValue } from '@perses-dev/components'; +import type { FormatOptions } from '@perses-dev/components'; +import { formatValue } from '@perses-dev/components'; export const formatStatChartValue = (value?: string | number | null, format?: FormatOptions): string => { if (value === null) { diff --git a/statchart/src/utils/get-color.ts b/statchart/src/utils/get-color.ts index f4d2ee84f..ed86e3086 100644 --- a/statchart/src/utils/get-color.ts +++ b/statchart/src/utils/get-color.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { applyValueMapping, PersesChartsTheme, ThresholdOptions, ValueMapping } from '@perses-dev/components'; +import type { PersesChartsTheme, ThresholdOptions, ValueMapping } from '@perses-dev/components'; +import { applyValueMapping } from '@perses-dev/components'; -import { StatChartOptions } from '../stat-chart-model'; +import type { StatChartOptions } from '../stat-chart-model'; type StatChartValue = number | string | null; diff --git a/statchart/tsconfig.build.json b/statchart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/statchart/tsconfig.build.json +++ b/statchart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/statchart/tsconfig.json b/statchart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/statchart/tsconfig.json +++ b/statchart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/statchart/vitest.config.ts b/statchart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/statchart/vitest.config.ts +++ b/statchart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/staticlistvariable/package.json b/staticlistvariable/package.json index b73dd8a68..8725ac924 100644 --- a/staticlistvariable/package.json +++ b/staticlistvariable/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -32,7 +32,7 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", + "@perses-dev/plugin-system": "^0.55.0-beta.6", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/staticlistvariable/src/StaticListVariable.tsx b/staticlistvariable/src/StaticListVariable.tsx index cc1c58e67..e5e892297 100644 --- a/staticlistvariable/src/StaticListVariable.tsx +++ b/staticlistvariable/src/StaticListVariable.tsx @@ -13,9 +13,10 @@ import { Autocomplete, Chip, IconButton, TextField, Typography } from '@mui/material'; /* eslint-disable jsx-a11y/no-autofocus */ -import { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { VariablePlugin, VariableOption, OptionsEditorProps } from '@perses-dev/plugin-system'; import PlusCircleIcon from 'mdi-material-ui/PlusCircle'; -import { ReactElement, useCallback, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useState } from 'react'; type StaticListOption = string | VariableOption; diff --git a/staticlistvariable/src/getPluginModule.ts b/staticlistvariable/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/staticlistvariable/src/getPluginModule.ts +++ b/staticlistvariable/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/staticlistvariable/tsconfig.build.json b/staticlistvariable/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/staticlistvariable/tsconfig.build.json +++ b/staticlistvariable/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/staticlistvariable/tsconfig.json b/staticlistvariable/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/staticlistvariable/tsconfig.json +++ b/staticlistvariable/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/staticlistvariable/vitest.config.ts b/staticlistvariable/vitest.config.ts index d6b9f6786..c64d8cc04 100644 --- a/staticlistvariable/vitest.config.ts +++ b/staticlistvariable/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, passWithNoTests: true, }); diff --git a/statushistorychart/package.json b/statushistorychart/package.json index 4b1e97170..cf0f6084c 100644 --- a/statushistorychart/package.json +++ b/statushistorychart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,8 +29,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/statushistorychart/src/StatusHistoryChart.ts b/statushistorychart/src/StatusHistoryChart.ts index c71135af6..b1771575f 100644 --- a/statushistorychart/src/StatusHistoryChart.ts +++ b/statushistorychart/src/StatusHistoryChart.ts @@ -11,11 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { createInitialStatusHistoryChartOptions, StatusHistoryChartOptions } from './status-history-model'; +import type { StatusHistoryChartOptions } from './status-history-model'; +import { createInitialStatusHistoryChartOptions } from './status-history-model'; import { StatusHistoryChartOptionsEditorSettings } from './StatusHistoryChartOptionsEditorSettings'; -import { StatusHistoryChartPanelProps, StatusHistoryPanel } from './StatusHistoryPanel'; +import type { StatusHistoryChartPanelProps } from './StatusHistoryPanel'; +import { StatusHistoryPanel } from './StatusHistoryPanel'; import { StatusHistoryValueMappingEditor } from './StatusHistoryValueMappingEditor'; export const StatusHistoryChart: PanelPlugin = { diff --git a/statushistorychart/src/StatusHistoryChartBase.tsx b/statushistorychart/src/StatusHistoryChartBase.tsx index 0562f8653..a6c12a1ff 100644 --- a/statushistorychart/src/StatusHistoryChartBase.tsx +++ b/statushistorychart/src/StatusHistoryChartBase.tsx @@ -11,22 +11,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Box, SxProps, Typography, useTheme } from '@mui/material'; +import type { SxProps } from '@mui/material'; +import { Box, Typography, useTheme } from '@mui/material'; import { EChart, useChartsTheme, useTimeZone } from '@perses-dev/components'; -import { TimeScale } from '@perses-dev/spec'; -import { EChartsCoreOption, TitleComponentOption } from 'echarts'; +import type { TimeScale } from '@perses-dev/spec'; +import type { EChartsCoreOption, TitleComponentOption } from 'echarts'; import { HeatmapChart as EChartsHeatmapChart } from 'echarts/charts'; +import type { LegendComponentOption } from 'echarts/components'; import { GridComponent, DatasetComponent, TitleComponent, TooltipComponent, VisualMapComponent, - LegendComponentOption, } from 'echarts/components'; import { use as registerECharts } from 'echarts/core'; import { CanvasRenderer } from 'echarts/renderers'; -import { FC } from 'react'; +import type { FC } from 'react'; import { generateTooltipHTML } from './StatusHistoryTooltip'; import { getFormattedStatusHistoryAxisLabel } from './utils/get-formatted-axis-label'; diff --git a/statushistorychart/src/StatusHistoryChartOptionsEditorSettings.tsx b/statushistorychart/src/StatusHistoryChartOptionsEditorSettings.tsx index 5895aea04..e7a4f695e 100644 --- a/statushistorychart/src/StatusHistoryChartOptionsEditorSettings.tsx +++ b/statushistorychart/src/StatusHistoryChartOptionsEditorSettings.tsx @@ -12,19 +12,14 @@ // limitations under the License. import { Button } from '@mui/material'; -import { - OptionsEditorGroup, - OptionsEditorGrid, - OptionsEditorColumn, - SortSelector, - SortOption, - SortSelectorProps, -} from '@perses-dev/components'; -import { LegendOptionsEditor, LegendOptionsEditorProps } from '@perses-dev/plugin-system'; +import type { SortOption, SortSelectorProps } from '@perses-dev/components'; +import { OptionsEditorGroup, OptionsEditorGrid, OptionsEditorColumn, SortSelector } from '@perses-dev/components'; +import type { LegendOptionsEditorProps } from '@perses-dev/plugin-system'; +import { LegendOptionsEditor } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { StatusHistoryChartOptions, StatusHistroyChartEditorProps } from './status-history-model.js'; +import type { StatusHistoryChartOptions, StatusHistroyChartEditorProps } from './status-history-model.js'; export function StatusHistoryChartOptionsEditorSettings(props: StatusHistroyChartEditorProps): ReactElement { const { onChange, value } = props; diff --git a/statushistorychart/src/StatusHistoryPanel.tsx b/statushistorychart/src/StatusHistoryPanel.tsx index 1b6868094..d000c2af5 100644 --- a/statushistorychart/src/StatusHistoryPanel.tsx +++ b/statushistorychart/src/StatusHistoryPanel.tsx @@ -13,12 +13,14 @@ import { Box } from '@mui/material'; import { ContentWithLegend, useChartsTheme } from '@perses-dev/components'; -import { PanelProps, validateLegendSpec } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import { validateLegendSpec } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; import { merge } from 'lodash'; -import { ReactElement, useMemo } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { StatusHistoryChartOptions } from './status-history-model.js'; +import type { StatusHistoryChartOptions } from './status-history-model.js'; import { StatusHistoryChartBase } from './StatusHistoryChartBase'; import { useStatusHistoryDataModel } from './utils/data-transform'; diff --git a/statushistorychart/src/StatusHistoryTooltip.ts b/statushistorychart/src/StatusHistoryTooltip.ts index d19e929f4..cc1f0c398 100644 --- a/statushistorychart/src/StatusHistoryTooltip.ts +++ b/statushistorychart/src/StatusHistoryTooltip.ts @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { css, Theme } from '@mui/material'; +import type { Theme } from '@mui/material'; +import { css } from '@mui/material'; import { getDateAndTime } from '@perses-dev/components'; -import { StatusHistoryData } from './StatusHistoryChartBase'; +import type { StatusHistoryData } from './StatusHistoryChartBase'; interface CustomTooltipProps { data: StatusHistoryData; diff --git a/statushistorychart/src/StatusHistoryValueMappingEditor.tsx b/statushistorychart/src/StatusHistoryValueMappingEditor.tsx index ee2bf28ec..aedb5e3b9 100644 --- a/statushistorychart/src/StatusHistoryValueMappingEditor.tsx +++ b/statushistorychart/src/StatusHistoryValueMappingEditor.tsx @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ValueMapping, ValueMappingsEditor } from '@perses-dev/components'; -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { FC } from 'react'; +import type { ValueMapping } from '@perses-dev/components'; +import { ValueMappingsEditor } from '@perses-dev/components'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { FC } from 'react'; -import { StatusHistoryChartOptions } from './status-history-model'; +import type { StatusHistoryChartOptions } from './status-history-model'; export type StatusHistoryValueMappingEditorProps = OptionsEditorProps; diff --git a/statushistorychart/src/getPluginModule.ts b/statushistorychart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/statushistorychart/src/getPluginModule.ts +++ b/statushistorychart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/statushistorychart/src/status-history-model.ts b/statushistorychart/src/status-history-model.ts index ab3fba84b..b496ad249 100644 --- a/statushistorychart/src/status-history-model.ts +++ b/statushistorychart/src/status-history-model.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ValueMapping } from '@perses-dev/components'; -import { LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { ValueMapping } from '@perses-dev/components'; +import type { LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system'; export function createInitialStatusHistoryChartOptions(): Record { return {}; diff --git a/statushistorychart/src/utils/data-transform.test.ts b/statushistorychart/src/utils/data-transform.test.ts index 231cc534f..e324a12d4 100644 --- a/statushistorychart/src/utils/data-transform.test.ts +++ b/statushistorychart/src/utils/data-transform.test.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelData } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type { PanelData } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; import { renderHook } from '@testing-library/react'; import { useStatusHistoryDataModel } from './data-transform'; diff --git a/statushistorychart/src/utils/data-transform.ts b/statushistorychart/src/utils/data-transform.ts index 5ad8c7023..eedbc3f9f 100644 --- a/statushistorychart/src/utils/data-transform.ts +++ b/statushistorychart/src/utils/data-transform.ts @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { applyValueMapping, LegendItem } from '@perses-dev/components'; -import { PanelData } from '@perses-dev/plugin-system'; -import { TimeScale, TimeSeriesData } from '@perses-dev/spec'; +import type { LegendItem } from '@perses-dev/components'; +import { applyValueMapping } from '@perses-dev/components'; +import type { PanelData } from '@perses-dev/plugin-system'; +import type { TimeScale, TimeSeriesData } from '@perses-dev/spec'; import { useMemo } from 'react'; -import { StatusHistoryChartOptions } from '../status-history-model'; -import { StatusHistoryDataItem } from '../StatusHistoryChartBase'; +import type { StatusHistoryChartOptions } from '../status-history-model'; +import type { StatusHistoryDataItem } from '../StatusHistoryChartBase'; import { FALLBACK_COLOR, getColorsForValues } from './get-color'; import { getCommonTimeScaleForQueries } from './get-timescale'; diff --git a/statushistorychart/src/utils/get-timescale.ts b/statushistorychart/src/utils/get-timescale.ts index a6bac4e97..3276fb79d 100644 --- a/statushistorychart/src/utils/get-timescale.ts +++ b/statushistorychart/src/utils/get-timescale.ts @@ -12,8 +12,8 @@ // limitations under the License. import { getCommonTimeScale } from '@perses-dev/components'; -import { PanelData } from '@perses-dev/plugin-system'; -import { TimeScale, TimeSeriesData } from '@perses-dev/spec'; +import type { PanelData } from '@perses-dev/plugin-system'; +import type { TimeScale, TimeSeriesData } from '@perses-dev/spec'; export function getCommonTimeScaleForQueries(queries: Array>): TimeScale | undefined { const seriesData = queries.map((query) => query.data); diff --git a/statushistorychart/src/utils/get-tooltip-position.ts b/statushistorychart/src/utils/get-tooltip-position.ts index d92c358e5..4fb05c495 100644 --- a/statushistorychart/src/utils/get-tooltip-position.ts +++ b/statushistorychart/src/utils/get-tooltip-position.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TooltipComponentOption } from 'echarts'; +import type { TooltipComponentOption } from 'echarts'; export const getTooltipPosition: TooltipComponentOption['position'] = (...data) => { const point = data[0]; diff --git a/statushistorychart/tsconfig.build.json b/statushistorychart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/statushistorychart/tsconfig.build.json +++ b/statushistorychart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/statushistorychart/tsconfig.json b/statushistorychart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/statushistorychart/tsconfig.json +++ b/statushistorychart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/statushistorychart/vitest.config.ts b/statushistorychart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/statushistorychart/vitest.config.ts +++ b/statushistorychart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/table/package.json b/table/package.json index 744442bd6..eb9aa29b9 100644 --- a/table/package.json +++ b/table/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,9 +29,9 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/dashboards": "^0.55.0-beta.6", "@tanstack/react-table": "^8.20.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/table/src/Table.ts b/table/src/Table.ts index af02d8021..b42f494e5 100644 --- a/table/src/Table.ts +++ b/table/src/Table.ts @@ -11,19 +11,20 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; +import type { TableProps } from './components'; import { getTablePanelQueryOptions, TableCellsEditor, TableColumnsEditor, TablePanel, - TableProps, TableSettingsEditor, TableTransformsEditor, } from './components'; import { TableItemSelectionActionsEditor } from './components/TableItemSelectionActionsEditor'; -import { createInitialTableOptions, TableOptions } from './models'; +import type { TableOptions } from './models'; +import { createInitialTableOptions } from './models'; import { TableExportAction } from './TableExportAction'; /** diff --git a/table/src/TableExportAction.test.ts b/table/src/TableExportAction.test.ts index 59f067783..73d82464b 100644 --- a/table/src/TableExportAction.test.ts +++ b/table/src/TableExportAction.test.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelData } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type { PanelData } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; -import { TableOptions } from './models'; +import type { TableOptions } from './models'; import { buildTableData } from './TableExportAction'; function makePanelData(series: TimeSeriesData['series']): PanelData { diff --git a/table/src/TableExportAction.tsx b/table/src/TableExportAction.tsx index d33e53ab2..edaacf72e 100644 --- a/table/src/TableExportAction.tsx +++ b/table/src/TableExportAction.tsx @@ -13,12 +13,13 @@ import { IconButton } from '@mui/material'; import { InfoTooltip, transformData } from '@perses-dev/components'; -import { escapeCsvValue, PanelData, sanitizeFilename } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type { PanelData } from '@perses-dev/plugin-system'; +import { escapeCsvValue, sanitizeFilename } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; import DownloadIcon from 'mdi-material-ui/Download'; import React, { useCallback, useMemo } from 'react'; -import { TableProps } from './components'; +import type { TableProps } from './components'; import type { TableOptions } from './models'; import { buildRawTableData } from './table-data-utils'; diff --git a/table/src/components/CellsEditor/CellsEditor.tsx b/table/src/components/CellsEditor/CellsEditor.tsx index a3bf4ba87..09e5a1f30 100644 --- a/table/src/components/CellsEditor/CellsEditor.tsx +++ b/table/src/components/CellsEditor/CellsEditor.tsx @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { CellSettings } from '../../models'; +import type { CellSettings } from '../../models'; import { ConditionalPanel } from '../ConditionalPanel'; export interface CellsEditorProps { diff --git a/table/src/components/ColumnsEditor/ColumnEditor.tsx b/table/src/components/ColumnsEditor/ColumnEditor.tsx index 511dbbeb0..3f94d6c50 100644 --- a/table/src/components/ColumnsEditor/ColumnEditor.tsx +++ b/table/src/components/ColumnsEditor/ColumnEditor.tsx @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Button, ButtonGroup, Stack, StackProps, Switch, TextField, Typography } from '@mui/material'; +import type { StackProps } from '@mui/material'; +import { Button, ButtonGroup, Stack, Switch, TextField, Typography } from '@mui/material'; +import type { FormatOptions } from '@perses-dev/components'; import { AlignSelector, FormatControls, - FormatOptions, OptionsEditorColumn, OptionsEditorControl, OptionsEditorGrid, @@ -23,9 +24,10 @@ import { SortSelectorButtons, } from '@perses-dev/components'; import { PluginKindSelect } from '@perses-dev/plugin-system'; -import { ReactElement, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useState } from 'react'; -import { ColumnSettings } from '../../models'; +import type { ColumnSettings } from '../../models'; import { ConditionalPanel } from '../ConditionalPanel'; import { DataLinkEditor } from './DataLinkEditorDialog'; import { EmbeddedPanelOptionsEditor } from './EmbeddedPanelOptionsEditor'; diff --git a/table/src/components/ColumnsEditor/ColumnEditorContainer.tsx b/table/src/components/ColumnsEditor/ColumnEditorContainer.tsx index 741e4370f..7bac0e2c2 100644 --- a/table/src/components/ColumnsEditor/ColumnEditorContainer.tsx +++ b/table/src/components/ColumnsEditor/ColumnEditorContainer.tsx @@ -18,9 +18,10 @@ import ChevronRight from 'mdi-material-ui/ChevronRight'; import DeleteIcon from 'mdi-material-ui/DeleteOutline'; import EyeOffIcon from 'mdi-material-ui/EyeOffOutline'; import EyeIcon from 'mdi-material-ui/EyeOutline'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { ColumnEditor, ColumnEditorProps } from './ColumnEditor'; +import type { ColumnEditorProps } from './ColumnEditor'; +import { ColumnEditor } from './ColumnEditor'; export interface ColumnEditorContainerProps extends ColumnEditorProps { isCollapsed: boolean; diff --git a/table/src/components/ColumnsEditor/ColumnsEditor.tsx b/table/src/components/ColumnsEditor/ColumnsEditor.tsx index 7fe77cc47..313a882e8 100644 --- a/table/src/components/ColumnsEditor/ColumnsEditor.tsx +++ b/table/src/components/ColumnsEditor/ColumnsEditor.tsx @@ -14,9 +14,10 @@ import { Button, Stack } from '@mui/material'; import { handleMoveDown, handleMoveUp, useDragAndDropMonitor } from '@perses-dev/components'; import AddIcon from 'mdi-material-ui/Plus'; -import { ReactElement, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useState } from 'react'; -import { ColumnSettings } from '../../models'; +import type { ColumnSettings } from '../../models'; import { ColumnEditorContainer } from './ColumnEditorContainer'; export interface ColumnsEditorProps { diff --git a/table/src/components/ColumnsEditor/DataLinkEditorDialog.tsx b/table/src/components/ColumnsEditor/DataLinkEditorDialog.tsx index a12ab1cfc..2a439d511 100644 --- a/table/src/components/ColumnsEditor/DataLinkEditorDialog.tsx +++ b/table/src/components/ColumnsEditor/DataLinkEditorDialog.tsx @@ -15,9 +15,9 @@ import { IconButton, Stack, Typography } from '@mui/material'; import { LinkEditorForm } from '@perses-dev/components'; import MinusIcon from 'mdi-material-ui/Minus'; import PlusIcon from 'mdi-material-ui/Plus'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { ColumnEditorProps } from './ColumnEditor'; +import type { ColumnEditorProps } from './ColumnEditor'; export type Props = Pick; diff --git a/table/src/components/ColumnsEditor/EmbeddedPanelOptionsEditor.tsx b/table/src/components/ColumnsEditor/EmbeddedPanelOptionsEditor.tsx index 00a4fd6b0..26456dece 100644 --- a/table/src/components/ColumnsEditor/EmbeddedPanelOptionsEditor.tsx +++ b/table/src/components/ColumnsEditor/EmbeddedPanelOptionsEditor.tsx @@ -12,10 +12,12 @@ // limitations under the License. import { CircularProgress, Stack, Typography } from '@mui/material'; -import { OptionsEditorTabs, PanelPlugin, usePlugin } from '@perses-dev/plugin-system'; -import { UnknownSpec } from '@perses-dev/spec'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; +import { OptionsEditorTabs, usePlugin } from '@perses-dev/plugin-system'; +import type { UnknownSpec } from '@perses-dev/spec'; import merge from 'lodash/merge'; -import { ReactElement, useEffect, useMemo, useRef } from 'react'; +import type { ReactElement } from 'react'; +import { useEffect, useMemo, useRef } from 'react'; export interface EmbeddedPanelOptionsEditorProps { kind: string; diff --git a/table/src/components/ConditionalPanel.tsx b/table/src/components/ConditionalPanel.tsx index 87397499f..0f6397fa3 100644 --- a/table/src/components/ConditionalPanel.tsx +++ b/table/src/components/ConditionalPanel.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { Grid2Props as GridProps } from '@mui/material'; import { Button, Divider, - Grid2Props as GridProps, IconButton, MenuItem, Stack, @@ -26,9 +26,11 @@ import { import { OptionsColorPicker } from '@perses-dev/components'; import DeleteIcon from 'mdi-material-ui/DeleteOutline'; import AddIcon from 'mdi-material-ui/Plus'; -import React, { ReactElement } from 'react'; +import type { ReactElement } from 'react'; +import React from 'react'; -import { CellSettings, renderConditionEditor } from '../models'; +import type { CellSettings } from '../models'; +import { renderConditionEditor } from '../models'; // Individual conditional formatting rule component export interface ConditionalRuleProps extends Omit { diff --git a/table/src/components/EmbeddedPanel.tsx b/table/src/components/EmbeddedPanel.tsx index d0ffbe262..0f1f4d90b 100644 --- a/table/src/components/EmbeddedPanel.tsx +++ b/table/src/components/EmbeddedPanel.tsx @@ -13,9 +13,9 @@ import { ErrorAlert, ErrorBoundary } from '@perses-dev/components'; import { PanelPluginLoader } from '@perses-dev/dashboards'; -import { PanelData } from '@perses-dev/plugin-system'; -import { QueryDataType, UnknownSpec } from '@perses-dev/spec'; -import { ReactElement } from 'react'; +import type { PanelData } from '@perses-dev/plugin-system'; +import type { QueryDataType, UnknownSpec } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; import useResizeObserver from 'use-resize-observer'; interface EmbeddedPanelProps { diff --git a/table/src/components/TableCellsEditor.tsx b/table/src/components/TableCellsEditor.tsx index add90d78a..642293416 100644 --- a/table/src/components/TableCellsEditor.tsx +++ b/table/src/components/TableCellsEditor.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; -import { CellSettings, TableOptions } from '../models'; +import type { CellSettings, TableOptions } from '../models'; import { CellsEditor } from './CellsEditor'; export type TableCellsEditorProps = OptionsEditorProps; diff --git a/table/src/components/TableColumnsEditor.test.tsx b/table/src/components/TableColumnsEditor.test.tsx index db6552f94..ba9323604 100644 --- a/table/src/components/TableColumnsEditor.test.tsx +++ b/table/src/components/TableColumnsEditor.test.tsx @@ -13,7 +13,7 @@ import { fireEvent, render, screen } from '@testing-library/react'; -import { TableOptions } from '../models'; +import type { TableOptions } from '../models'; import { TableColumnsEditor } from './TableColumnsEditor'; describe('TableColumnsEditor', () => { diff --git a/table/src/components/TableColumnsEditor.tsx b/table/src/components/TableColumnsEditor.tsx index 73e7186c0..c76ce8377 100644 --- a/table/src/components/TableColumnsEditor.tsx +++ b/table/src/components/TableColumnsEditor.tsx @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; -import { ColumnSettings, TableOptions } from '../models'; +import type { ColumnSettings, TableOptions } from '../models'; import { ColumnsEditor } from './ColumnsEditor'; export type TableColumnsEditorProps = OptionsEditorProps; diff --git a/table/src/components/TableItemSelectionActionsEditor.tsx b/table/src/components/TableItemSelectionActionsEditor.tsx index eeb0d2ac5..1995c1008 100644 --- a/table/src/components/TableItemSelectionActionsEditor.tsx +++ b/table/src/components/TableItemSelectionActionsEditor.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ActionOptions, ItemSelectionActionsEditor, SelectionOptions } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ActionOptions, SelectionOptions } from '@perses-dev/plugin-system'; +import { ItemSelectionActionsEditor } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; -import { TableSettingsEditorProps } from '../models'; +import type { TableSettingsEditorProps } from '../models'; export function TableItemSelectionActionsEditor({ value, onChange }: TableSettingsEditorProps): ReactElement { function handleActionsChange(actions: ActionOptions | undefined): void { diff --git a/table/src/components/TablePanel.test.tsx b/table/src/components/TablePanel.test.tsx index 3ca3783dd..ca1b176ad 100644 --- a/table/src/components/TablePanel.test.tsx +++ b/table/src/components/TablePanel.test.tsx @@ -12,20 +12,16 @@ // limitations under the License. import { ChartsProvider, ItemActionsProvider, SelectionProvider, testChartsTheme } from '@perses-dev/components'; -import { - dynamicImportPluginLoader, - PluginLoader, - PluginModuleResource, - PluginRegistry, - VariableStateMap, -} from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type * as PluginSystemModule from '@perses-dev/plugin-system'; +import type { PluginLoader, PluginModuleResource, VariableStateMap } from '@perses-dev/plugin-system'; +import { dynamicImportPluginLoader, PluginRegistry } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { render, screen, waitFor, within } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { VirtuosoMockContext } from 'react-virtuoso'; -import { TableOptions, TimeSeriesTableProps } from '../models'; +import type { TableOptions, TimeSeriesTableProps } from '../models'; import { MOCK_MULTI_QUERY_DATA_EMPTY, MOCK_MULTI_QUERY_DATA_Q1, @@ -45,7 +41,7 @@ const MOCK_VARIABLE_STATE_MAP = vi.hoisted( }), ); vi.mock('@perses-dev/plugin-system', async (importOriginal) => ({ - ...(await importOriginal()), + ...(await importOriginal()), // Return a stable reference (like the real hook, which memoizes) so consumers // that depend on it in a useMemo/useEffect dependency array don't recompute/rerun on every render. useAllVariableValues: (): VariableStateMap => MOCK_VARIABLE_STATE_MAP, diff --git a/table/src/components/TablePanel.tsx b/table/src/components/TablePanel.tsx index 5ffac5299..330b55894 100644 --- a/table/src/components/TablePanel.tsx +++ b/table/src/components/TablePanel.tsx @@ -11,32 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Box, Theme, Typography, useTheme } from '@mui/material'; -import { - FormatOptions, - formatValue, - Table, - TableCellConfigs, - TableColumnConfig, - transformData, - useSelection, -} from '@perses-dev/components'; +import type { Theme } from '@mui/material'; +import { Box, Typography, useTheme } from '@mui/material'; +import type { FormatOptions, TableCellConfigs, TableColumnConfig } from '@perses-dev/components'; +import { formatValue, Table, transformData, useSelection } from '@perses-dev/components'; import { useSelectionItemActions } from '@perses-dev/dashboards'; -import { - ActionOptions, - CalculationsMap, - PanelData, - PanelProps, - replaceVariablesInString, - useAllVariableValues, - VariableStateMap, -} from '@perses-dev/plugin-system'; -import { QueryDataType, TimeSeriesData } from '@perses-dev/spec'; -import { ColumnFiltersState, PaginationState, RowSelectionState, SortingState } from '@tanstack/react-table'; -import { ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import type { ActionOptions, PanelData, PanelProps, VariableStateMap } from '@perses-dev/plugin-system'; +import { CalculationsMap, replaceVariablesInString, useAllVariableValues } from '@perses-dev/plugin-system'; +import type { QueryDataType, TimeSeriesData } from '@perses-dev/spec'; +import type { ColumnFiltersState, PaginationState, RowSelectionState, SortingState } from '@tanstack/react-table'; +import type { ReactElement } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; -import { CellSettings, ColumnSettings, evaluateConditionalFormatting, TableOptions } from '../models'; +import type { CellSettings, ColumnSettings, TableOptions } from '../models'; +import { evaluateConditionalFormatting } from '../models'; import { buildRawTableData, getTablePanelQueryMode } from '../table-data-utils'; import { EmbeddedPanel } from './EmbeddedPanel'; diff --git a/table/src/components/TableSettingsEditor.tsx b/table/src/components/TableSettingsEditor.tsx index 2d865dd1f..d8eaef0f4 100644 --- a/table/src/components/TableSettingsEditor.tsx +++ b/table/src/components/TableSettingsEditor.tsx @@ -12,6 +12,7 @@ // limitations under the License. import { Switch, TextField } from '@mui/material'; +import type { TableDensity } from '@perses-dev/components'; import { DEFAULT_COLUMN_HEIGHT, DEFAULT_COLUMN_WIDTH, @@ -20,11 +21,10 @@ import { OptionsEditorControl, OptionsEditorGrid, OptionsEditorGroup, - TableDensity, } from '@perses-dev/components'; -import { ChangeEvent, ReactElement } from 'react'; +import type { ChangeEvent, ReactElement } from 'react'; -import { TableSettingsEditorProps } from '../models'; +import type { TableSettingsEditorProps } from '../models'; interface DefaultColumnsDimensionsControlProps { label: string; diff --git a/table/src/components/TableTransformsEditor.tsx b/table/src/components/TableTransformsEditor.tsx index f689ce2df..f07416be3 100644 --- a/table/src/components/TableTransformsEditor.tsx +++ b/table/src/components/TableTransformsEditor.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Transform, TransformsEditor } from '@perses-dev/components'; -import { ReactElement } from 'react'; +import type { Transform } from '@perses-dev/components'; +import { TransformsEditor } from '@perses-dev/components'; +import type { ReactElement } from 'react'; -import { TableSettingsEditorProps } from '../models'; +import type { TableSettingsEditorProps } from '../models'; export function TableTransformsEditor({ value, onChange }: TableSettingsEditorProps): ReactElement { function handleTransformsChange(transforms: Transform[]): void { diff --git a/table/src/getPluginModule.ts b/table/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/table/src/getPluginModule.ts +++ b/table/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/table/src/models/model.ts b/table/src/models/model.ts index 0d3d6fc4e..04065d032 100644 --- a/table/src/models/model.ts +++ b/table/src/models/model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelProps } from '@perses-dev/plugin-system'; +import type { PanelProps } from '@perses-dev/plugin-system'; // eslint-disable-next-line @typescript-eslint/no-empty-object-type interface TimeSeriesTableOptions {} diff --git a/table/src/models/table-model.ts b/table/src/models/table-model.ts index c28f712a2..44539f627 100644 --- a/table/src/models/table-model.ts +++ b/table/src/models/table-model.ts @@ -12,9 +12,9 @@ // limitations under the License. import { TextField, Stack, MenuItem, Typography } from '@mui/material'; -import { TableDensity, TableCellConfig, FormatOptions, Transform } from '@perses-dev/components'; -import { ActionOptions, OptionsEditorProps, SelectionOptions } from '@perses-dev/plugin-system'; -import { Definition, UnknownSpec } from '@perses-dev/spec'; +import type { TableDensity, TableCellConfig, FormatOptions, Transform } from '@perses-dev/components'; +import type { ActionOptions, OptionsEditorProps, SelectionOptions } from '@perses-dev/plugin-system'; +import type { Definition, UnknownSpec } from '@perses-dev/spec'; import React from 'react'; export interface ColumnSettings { diff --git a/table/src/table-data-utils.ts b/table/src/table-data-utils.ts index 744bb0399..8079805e8 100644 --- a/table/src/table-data-utils.ts +++ b/table/src/table-data-utils.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Labels, PanelData } from '@perses-dev/plugin-system'; -import { TimeSeries, TimeSeriesData } from '@perses-dev/spec'; +import type { Labels, PanelData } from '@perses-dev/plugin-system'; +import type { TimeSeries, TimeSeriesData } from '@perses-dev/spec'; -import { TableOptions } from './models'; +import type { TableOptions } from './models'; /** * Options for building raw table data. diff --git a/table/src/test/mock-query-results.ts b/table/src/test/mock-query-results.ts index 433511f3c..6a7503e86 100644 --- a/table/src/test/mock-query-results.ts +++ b/table/src/test/mock-query-results.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesData } from '@perses-dev/spec'; +import type { TimeSeriesData } from '@perses-dev/spec'; export const MOCK_TIME_SERIES_QUERY_RESULT_MULTIVALUE = [ { diff --git a/table/tsconfig.build.json b/table/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/table/tsconfig.build.json +++ b/table/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/table/tsconfig.json b/table/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/table/tsconfig.json +++ b/table/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/table/vitest.config.ts b/table/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/table/vitest.config.ts +++ b/table/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/tempo/package.json b/tempo/package.json index 3e36066af..0625e3779 100644 --- a/tempo/package.json +++ b/tempo/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -34,11 +34,11 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/client": "^0.55.0-beta.3", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/client": "^0.55.0-beta.6", "@tanstack/react-query": "^4.39.1", "@uiw/react-codemirror": "^4.25.3", "date-fns": "^4.1.0", diff --git a/tempo/src/components/AttributeFilters.tsx b/tempo/src/components/AttributeFilters.tsx index b308e5ccf..3bc9f9de5 100644 --- a/tempo/src/components/AttributeFilters.tsx +++ b/tempo/src/components/AttributeFilters.tsx @@ -11,14 +11,18 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Autocomplete, Checkbox, Stack, TextField, TextFieldProps } from '@mui/material'; +import type { TextFieldProps } from '@mui/material'; +import { Autocomplete, Checkbox, Stack, TextField } from '@mui/material'; import { useTimeRange } from '@perses-dev/plugin-system'; -import { useQuery, UseQueryResult } from '@tanstack/react-query'; -import { ReactElement, SyntheticEvent, useCallback, useEffect, useState } from 'react'; +import type { UseQueryResult } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; +import type { ReactElement, SyntheticEvent } from 'react'; +import { useCallback, useEffect, useState } from 'react'; -import { TempoClient } from '../model'; +import type { TempoClient } from '../model'; import { getUnixTimeRange } from '../plugins'; -import { filterToTraceQL, traceQLToFilter, DurationField, Filter, splitByUnquotedWhitespace } from './filter'; +import type { DurationField, Filter } from './filter'; +import { filterToTraceQL, traceQLToFilter, splitByUnquotedWhitespace } from './filter'; const statusOptions = ['unset', 'ok', 'error']; diff --git a/tempo/src/components/ClosableAlert.tsx b/tempo/src/components/ClosableAlert.tsx index 659e9d518..816970b47 100644 --- a/tempo/src/components/ClosableAlert.tsx +++ b/tempo/src/components/ClosableAlert.tsx @@ -11,8 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Alert, AlertProps } from '@mui/material'; -import { ReactElement, useCallback, useState } from 'react'; +import type { AlertProps } from '@mui/material'; +import { Alert } from '@mui/material'; +import type { ReactElement } from 'react'; +import { useCallback, useState } from 'react'; export function ClosableAlert(props: AlertProps): ReactElement | null { const [isVisible, setVisible] = useState(true); diff --git a/tempo/src/components/TraceQLEditor.tsx b/tempo/src/components/TraceQLEditor.tsx index 50ddefdc5..ac4193399 100644 --- a/tempo/src/components/TraceQLEditor.tsx +++ b/tempo/src/components/TraceQLEditor.tsx @@ -14,10 +14,12 @@ import { InputLabel, Stack, useTheme } from '@mui/material'; import { useTimeRange } from '@perses-dev/plugin-system'; import { isValidTraceId } from '@perses-dev/spec'; -import CodeMirror, { EditorView, ReactCodeMirrorProps } from '@uiw/react-codemirror'; -import { ReactElement, useMemo } from 'react'; +import type { ReactCodeMirrorProps } from '@uiw/react-codemirror'; +import CodeMirror, { EditorView } from '@uiw/react-codemirror'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { TempoClient } from '../model'; +import type { TempoClient } from '../model'; import { TraceQLExtension } from './TraceQLExtension'; export interface TraceQLEditorProps extends Omit { diff --git a/tempo/src/components/TraceQLExtension.ts b/tempo/src/components/TraceQLExtension.ts index a10dd9145..883a07d87 100644 --- a/tempo/src/components/TraceQLExtension.ts +++ b/tempo/src/components/TraceQLExtension.ts @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { CompletionContext } from '@codemirror/autocomplete'; +import type { CompletionContext } from '@codemirror/autocomplete'; import { LRLanguage } from '@codemirror/language'; import { parser } from '@grafana/lezer-traceql'; -import { AbsoluteTimeRange } from '@perses-dev/spec'; -import { Extension } from '@uiw/react-codemirror'; +import type { AbsoluteTimeRange } from '@perses-dev/spec'; +import type { Extension } from '@uiw/react-codemirror'; -import { TempoClient } from '../model/tempo-client'; +import type { TempoClient } from '../model/tempo-client'; import { complete } from './complete'; import { traceQLHighlight } from './highlight'; diff --git a/tempo/src/components/complete.ts b/tempo/src/components/complete.ts index c37eb95d5..c4a22e79f 100644 --- a/tempo/src/components/complete.ts +++ b/tempo/src/components/complete.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Completion, CompletionContext, CompletionResult, insertCompletionText } from '@codemirror/autocomplete'; +import type { Completion, CompletionContext, CompletionResult } from '@codemirror/autocomplete'; +import { insertCompletionText } from '@codemirror/autocomplete'; import { syntaxTree } from '@codemirror/language'; -import { EditorState } from '@codemirror/state'; +import type { EditorState } from '@codemirror/state'; import { String as StringType, FieldExpression, @@ -24,11 +25,11 @@ import { SpansetFilter, FieldOp, } from '@grafana/lezer-traceql'; -import { Tree } from '@lezer/common'; -import { EditorView } from '@uiw/react-codemirror'; +import type { Tree } from '@lezer/common'; +import type { EditorView } from '@uiw/react-codemirror'; import { getUnixTimeRange } from '../plugins'; -import { CompletionConfig } from './TraceQLExtension'; +import type { CompletionConfig } from './TraceQLExtension'; /** CompletionScope specifies the completion kind, e.g. whether to complete tag names or values etc. */ type CompletionScope = diff --git a/tempo/src/components/filter/filter_to_traceql.ts b/tempo/src/components/filter/filter_to_traceql.ts index 84756d143..68048dcb8 100644 --- a/tempo/src/components/filter/filter_to_traceql.ts +++ b/tempo/src/components/filter/filter_to_traceql.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DurationField, Filter } from './filter'; +import type { DurationField, Filter } from './filter'; /** * Construct a TraceQL query from a filter. diff --git a/tempo/src/components/filter/traceql_to_filter.ts b/tempo/src/components/filter/traceql_to_filter.ts index cae7c2c70..fa1cbefbc 100644 --- a/tempo/src/components/filter/traceql_to_filter.ts +++ b/tempo/src/components/filter/traceql_to_filter.ts @@ -13,7 +13,7 @@ import { AttributeField, FieldExpression, FieldOp, IntrinsicField, Static, parser } from '@grafana/lezer-traceql'; -import { DurationField, Filter } from './filter'; +import type { DurationField, Filter } from './filter'; interface Matcher { operator: string; diff --git a/tempo/src/explore/TempoExplorer.tsx b/tempo/src/explore/TempoExplorer.tsx index 30dae7419..afe839a05 100644 --- a/tempo/src/explore/TempoExplorer.tsx +++ b/tempo/src/explore/TempoExplorer.tsx @@ -16,11 +16,13 @@ import { ErrorAlert, ErrorBoundary, LoadingOverlay, NoDataOverlay, useTimeZone } import { Panel } from '@perses-dev/dashboards'; import { useExplorerManagerContext } from '@perses-dev/explore'; import { DataQueriesProvider, MultiQueryEditor, useDataQueries } from '@perses-dev/plugin-system'; -import { isValidTraceId, QueryDefinition } from '@perses-dev/spec'; -import { ReactElement, useState } from 'react'; +import type { QueryDefinition } from '@perses-dev/spec'; +import { isValidTraceId } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; +import { useState } from 'react'; import { ClosableAlert } from '../components/ClosableAlert'; -import { TempoTraceQuerySpec } from '../model'; +import type { TempoTraceQuerySpec } from '../model'; import { linkToSpan, linkToTrace } from './links'; interface TracesExplorerQueryParams { diff --git a/tempo/src/getPluginModule.ts b/tempo/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/tempo/src/getPluginModule.ts +++ b/tempo/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/tempo/src/model/api-types.ts b/tempo/src/model/api-types.ts index 32cd52330..d07cb9d1c 100644 --- a/tempo/src/model/api-types.ts +++ b/tempo/src/model/api-types.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; /** * Request parameters of Tempo HTTP API endpoint GET /api/search diff --git a/tempo/src/model/tempo-client.ts b/tempo/src/model/tempo-client.ts index 8337761fe..095984009 100644 --- a/tempo/src/model/tempo-client.ts +++ b/tempo/src/model/tempo-client.ts @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { fetchJson, RequestHeaders, UserFriendlyError } from '@perses-dev/client'; -import { DatasourceClient } from '@perses-dev/plugin-system'; +import type { RequestHeaders } from '@perses-dev/client'; +import { fetchJson, UserFriendlyError } from '@perses-dev/client'; +import type { DatasourceClient } from '@perses-dev/plugin-system'; -import { +import type { QueryRequestParameters, SearchRequestParameters, SearchTagsRequestParameters, diff --git a/tempo/src/model/tempo-selectors.ts b/tempo/src/model/tempo-selectors.ts index 06260029e..bdfe588eb 100644 --- a/tempo/src/model/tempo-selectors.ts +++ b/tempo/src/model/tempo-selectors.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import { isVariableDatasource } from '@perses-dev/plugin-system'; +import type { DatasourceSelector } from '@perses-dev/spec'; export const TEMPO_DATASOURCE_KIND = 'TempoDatasource' as const; diff --git a/tempo/src/model/trace-query-model.ts b/tempo/src/model/trace-query-model.ts index b3cdbfaf3..5810ee307 100644 --- a/tempo/src/model/trace-query-model.ts +++ b/tempo/src/model/trace-query-model.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; -import { TempoDatasourceSelector } from './tempo-selectors'; +import type { TempoDatasourceSelector } from './tempo-selectors'; /** * The spec/options for the TempoTraceQuery plugin. */ diff --git a/tempo/src/plugins/TempoDatasourceEditor.tsx b/tempo/src/plugins/TempoDatasourceEditor.tsx index b157491a3..9afeccb03 100644 --- a/tempo/src/plugins/TempoDatasourceEditor.tsx +++ b/tempo/src/plugins/TempoDatasourceEditor.tsx @@ -12,9 +12,10 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import React, { ReactElement } from 'react'; +import type { ReactElement } from 'react'; +import React from 'react'; -import { TempoDatasourceSpec } from './tempo-datasource-types'; +import type { TempoDatasourceSpec } from './tempo-datasource-types'; export interface TempoDatasourceEditorProps { value: TempoDatasourceSpec; diff --git a/tempo/src/plugins/plugin.test.ts b/tempo/src/plugins/plugin.test.ts index 0101f0b44..7d20c276d 100644 --- a/tempo/src/plugins/plugin.test.ts +++ b/tempo/src/plugins/plugin.test.ts @@ -11,13 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TraceQueryContext } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type { TraceQueryContext } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock } from 'vitest'; import { MOCK_SEARCH_RESPONSE_VPARQUET4, MOCK_TRACE_DATA_SEARCHRESULT, MOCK_TRACE_RESPONSE_SMALL } from '../test'; import { TempoDatasource } from './tempo-datasource'; -import { TempoDatasourceSpec } from './tempo-datasource-types'; +import type { TempoDatasourceSpec } from './tempo-datasource-types'; import { TempoTraceQuery } from './tempo-trace-query/TempoTraceQuery'; vi.mock('echarts/core'); diff --git a/tempo/src/plugins/tempo-datasource-types.tsx b/tempo/src/plugins/tempo-datasource-types.tsx index bbd710495..11c958718 100644 --- a/tempo/src/plugins/tempo-datasource-types.tsx +++ b/tempo/src/plugins/tempo-datasource-types.tsx @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { HTTPProxy } from '@perses-dev/spec'; +import type { HTTPProxy } from '@perses-dev/spec'; export interface TempoDatasourceSpec { directUrl?: string; diff --git a/tempo/src/plugins/tempo-datasource.tsx b/tempo/src/plugins/tempo-datasource.tsx index b7bd5e5ca..1d0a8b596 100644 --- a/tempo/src/plugins/tempo-datasource.tsx +++ b/tempo/src/plugins/tempo-datasource.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; -import { TempoClient, query, search, searchTagValues, searchTags } from '../model/tempo-client'; -import { TempoDatasourceSpec } from './tempo-datasource-types'; +import type { TempoClient } from '../model/tempo-client'; +import { query, search, searchTagValues, searchTags } from '../model/tempo-client'; +import type { TempoDatasourceSpec } from './tempo-datasource-types'; import { TempoDatasourceEditor } from './TempoDatasourceEditor'; /** diff --git a/tempo/src/plugins/tempo-trace-query/TempoTraceQuery.ts b/tempo/src/plugins/tempo-trace-query/TempoTraceQuery.ts index b2ed8649e..039cbb3a6 100644 --- a/tempo/src/plugins/tempo-trace-query/TempoTraceQuery.ts +++ b/tempo/src/plugins/tempo-trace-query/TempoTraceQuery.ts @@ -11,9 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { isVariableDatasource, parseVariables, TraceQueryPlugin } from '@perses-dev/plugin-system'; +import type { TraceQueryPlugin } from '@perses-dev/plugin-system'; +import { isVariableDatasource, parseVariables } from '@perses-dev/plugin-system'; -import { TempoTraceQuerySpec } from '../../model'; +import type { TempoTraceQuerySpec } from '../../model'; import { getTraceData } from './get-trace-data'; import { TempoTraceQueryEditor } from './TempoTraceQueryEditor'; diff --git a/tempo/src/plugins/tempo-trace-query/TempoTraceQueryEditor.tsx b/tempo/src/plugins/tempo-trace-query/TempoTraceQueryEditor.tsx index 83ed12dd0..450a4d887 100644 --- a/tempo/src/plugins/tempo-trace-query/TempoTraceQueryEditor.tsx +++ b/tempo/src/plugins/tempo-trace-query/TempoTraceQueryEditor.tsx @@ -13,25 +13,18 @@ import { Box, Button, FormControl, InputLabel, MenuItem, Select, Stack } from '@mui/material'; import { useId } from '@perses-dev/components'; -import { - DatasourceSelect, - DatasourceSelectProps, - useDatasourceClient, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, useDatasourceClient, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useState } from 'react'; import { TraceQLEditor, filterToTraceQL, traceQLToFilter } from '../../components'; import { AttributeFilters } from '../../components/AttributeFilters'; -import { - TempoClient, - DEFAULT_TEMPO, - isDefaultTempoSelector, - isTempoDatasourceSelector, - TEMPO_DATASOURCE_KIND, -} from '../../model'; -import { TraceQueryEditorProps, useQueryState } from './query-editor-model'; +import type { TempoClient } from '../../model'; +import { DEFAULT_TEMPO, isDefaultTempoSelector, isTempoDatasourceSelector, TEMPO_DATASOURCE_KIND } from '../../model'; +import type { TraceQueryEditorProps } from './query-editor-model'; +import { useQueryState } from './query-editor-model'; export function TempoTraceQueryEditor(props: TraceQueryEditorProps): ReactElement { const { diff --git a/tempo/src/plugins/tempo-trace-query/get-trace-data.test.ts b/tempo/src/plugins/tempo-trace-query/get-trace-data.test.ts index b69eb39dc..b4b9c8c29 100644 --- a/tempo/src/plugins/tempo-trace-query/get-trace-data.test.ts +++ b/tempo/src/plugins/tempo-trace-query/get-trace-data.test.ts @@ -11,18 +11,21 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TraceQueryContext, replaceVariables } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type * as PluginSystemModule from '@perses-dev/plugin-system'; +import type { TraceQueryContext } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock, MockedFunction } from 'vitest'; -import { TempoClient } from '../../model'; -import { DEFAULT_SEARCH_LIMIT, SearchResponse } from '../../model/api-types'; +import type { TempoClient } from '../../model'; +import type { SearchResponse } from '../../model/api-types'; +import { DEFAULT_SEARCH_LIMIT } from '../../model/api-types'; import { TempoDatasource } from '../tempo-datasource'; -import { TempoDatasourceSpec } from '../tempo-datasource-types'; +import type { TempoDatasourceSpec } from '../tempo-datasource-types'; import { getTraceData } from './get-trace-data'; vi.mock('@perses-dev/plugin-system', async (importOriginal) => { - const actual = await importOriginal(); + const actual = await importOriginal(); return { ...actual, replaceVariables: vi.fn((query: string) => query), diff --git a/tempo/src/plugins/tempo-trace-query/get-trace-data.ts b/tempo/src/plugins/tempo-trace-query/get-trace-data.ts index 723b1da05..07cae5178 100644 --- a/tempo/src/plugins/tempo-trace-query/get-trace-data.ts +++ b/tempo/src/plugins/tempo-trace-query/get-trace-data.ts @@ -11,21 +11,22 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { datasourceSelectValueToSelector, replaceVariables, TraceQueryPlugin } from '@perses-dev/plugin-system'; -import { AbsoluteTimeRange, isValidTraceId, Notice, TraceSearchResult } from '@perses-dev/spec'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type { TraceQueryPlugin } from '@perses-dev/plugin-system'; +import { datasourceSelectValueToSelector, replaceVariables } from '@perses-dev/plugin-system'; +import type { AbsoluteTimeRange, Notice, TraceSearchResult } from '@perses-dev/spec'; +import { isValidTraceId } from '@perses-dev/spec'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { getUnixTime } from 'date-fns'; -import { - TEMPO_DATASOURCE_KIND, +import type { TempoDatasourceSelector, TempoTraceQuerySpec, TempoClient, - DEFAULT_SEARCH_LIMIT, QueryResponse, SearchRequestParameters, SearchResponse, } from '../../model'; +import { TEMPO_DATASOURCE_KIND, DEFAULT_SEARCH_LIMIT } from '../../model'; export function getUnixTimeRange(timeRange: AbsoluteTimeRange): { start: number; end: number } { const { start, end } = timeRange; diff --git a/tempo/src/plugins/tempo-trace-query/query-editor-model.ts b/tempo/src/plugins/tempo-trace-query/query-editor-model.ts index 652a44aa3..ea666c3c8 100644 --- a/tempo/src/plugins/tempo-trace-query/query-editor-model.ts +++ b/tempo/src/plugins/tempo-trace-query/query-editor-model.ts @@ -11,11 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { OptionsEditorProps } from '@perses-dev/plugin-system'; +import type { OptionsEditorProps } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import { useState } from 'react'; -import { TempoTraceQuerySpec } from '../../model/trace-query-model'; +import type { TempoTraceQuerySpec } from '../../model/trace-query-model'; export type TraceQueryEditorProps = OptionsEditorProps; diff --git a/tempo/src/test/mock-data.ts b/tempo/src/test/mock-data.ts index 307bff7b8..518064129 100644 --- a/tempo/src/test/mock-data.ts +++ b/tempo/src/test/mock-data.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TraceData } from '@perses-dev/spec'; +import type { TraceData } from '@perses-dev/spec'; -import { QueryResponse, SearchResponse } from '../model/api-types'; +import type { QueryResponse, SearchResponse } from '../model/api-types'; export const MOCK_TRACE_RESPONSE: QueryResponse = { trace: { diff --git a/tempo/tsconfig.build.json b/tempo/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/tempo/tsconfig.build.json +++ b/tempo/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/tempo/tsconfig.json b/tempo/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/tempo/tsconfig.json +++ b/tempo/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/tempo/vitest.config.ts b/tempo/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/tempo/vitest.config.ts +++ b/tempo/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/timeserieschart/package.json b/timeserieschart/package.json index bd8aa75fd..17d60d3d9 100644 --- a/timeserieschart/package.json +++ b/timeserieschart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -32,9 +32,9 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/timeserieschart/src/GeneralSettingsEditor.tsx b/timeserieschart/src/GeneralSettingsEditor.tsx index c700f7daa..c6f0a197f 100644 --- a/timeserieschart/src/GeneralSettingsEditor.tsx +++ b/timeserieschart/src/GeneralSettingsEditor.tsx @@ -12,25 +12,19 @@ // limitations under the License. import { Button } from '@mui/material'; -import { - OptionsEditorGroup, - OptionsEditorGrid, - OptionsEditorColumn, - ThresholdsEditor, - ThresholdsEditorProps, -} from '@perses-dev/components'; -import { LegendOptionsEditor, LegendOptionsEditorProps } from '@perses-dev/plugin-system'; +import type { ThresholdsEditorProps } from '@perses-dev/components'; +import { OptionsEditorGroup, OptionsEditorGrid, OptionsEditorColumn, ThresholdsEditor } from '@perses-dev/components'; +import type { LegendOptionsEditorProps } from '@perses-dev/plugin-system'; +import { LegendOptionsEditor } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { - TimeSeriesChartOptions, - DEFAULT_VISUAL, - DEFAULT_Y_AXIS, - TimeSeriesChartOptionsEditorProps, -} from './time-series-chart-model'; -import { VisualOptionsEditor, VisualOptionsEditorProps } from './VisualOptionsEditor'; -import { YAxisOptionsEditor, YAxisOptionsEditorProps } from './YAxisOptionsEditor'; +import type { TimeSeriesChartOptions, TimeSeriesChartOptionsEditorProps } from './time-series-chart-model'; +import { DEFAULT_VISUAL, DEFAULT_Y_AXIS } from './time-series-chart-model'; +import type { VisualOptionsEditorProps } from './VisualOptionsEditor'; +import { VisualOptionsEditor } from './VisualOptionsEditor'; +import type { YAxisOptionsEditorProps } from './YAxisOptionsEditor'; +import { YAxisOptionsEditor } from './YAxisOptionsEditor'; export function TimeSeriesChartGeneralSettings(props: TimeSeriesChartOptionsEditorProps): ReactElement { const { onChange, value } = props; diff --git a/timeserieschart/src/QuerySettingsEditor.tsx b/timeserieschart/src/QuerySettingsEditor.tsx index 5547db4bf..9d24c7395 100644 --- a/timeserieschart/src/QuerySettingsEditor.tsx +++ b/timeserieschart/src/QuerySettingsEditor.tsx @@ -26,22 +26,22 @@ import { Typography, useTheme, } from '@mui/material'; -import { FormatControls, FormatOptions, OptionsColorPicker } from '@perses-dev/components'; +import type { FormatOptions } from '@perses-dev/components'; +import { FormatControls, OptionsColorPicker } from '@perses-dev/components'; import { generateQueryNames, useDataQueriesContext } from '@perses-dev/plugin-system'; import { produce } from 'immer'; import CloseIcon from 'mdi-material-ui/Close'; import DeleteIcon from 'mdi-material-ui/DeleteOutline'; import AddIcon from 'mdi-material-ui/Plus'; -import React, { ReactElement, useEffect, useMemo, useRef, useState } from 'react'; +import type { ReactElement } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; -import { - DEFAULT_AREA_OPACITY, - LINE_STYLE_CONFIG, - OPACITY_CONFIG, +import type { QuerySettingsOptions, TimeSeriesChartOptions, TimeSeriesChartOptionsEditorProps, } from './time-series-chart-model'; +import { DEFAULT_AREA_OPACITY, LINE_STYLE_CONFIG, OPACITY_CONFIG } from './time-series-chart-model'; const DEFAULT_COLOR_VALUE = '#555'; const NO_INDEX_AVAILABLE = -1; // invalid array index value used to represent the fact that no query index is available diff --git a/timeserieschart/src/TimeSeriesChart.ts b/timeserieschart/src/TimeSeriesChart.ts index 366db5866..19acbbc2e 100644 --- a/timeserieschart/src/TimeSeriesChart.ts +++ b/timeserieschart/src/TimeSeriesChart.ts @@ -11,12 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; import { TimeSeriesChartGeneralSettings } from './GeneralSettingsEditor'; import { QuerySettingsEditor } from './QuerySettingsEditor'; -import { createInitialTimeSeriesChartOptions, TimeSeriesChartOptions } from './time-series-chart-model'; -import { TimeSeriesChartPanel, TimeSeriesChartProps } from './TimeSeriesChartPanel'; +import type { TimeSeriesChartOptions } from './time-series-chart-model'; +import { createInitialTimeSeriesChartOptions } from './time-series-chart-model'; +import type { TimeSeriesChartProps } from './TimeSeriesChartPanel'; +import { TimeSeriesChartPanel } from './TimeSeriesChartPanel'; import { TimeSeriesExportAction } from './TimeSeriesExportAction'; export const TimeSeriesChart: PanelPlugin = { diff --git a/timeserieschart/src/TimeSeriesChartBase.tsx b/timeserieschart/src/TimeSeriesChartBase.tsx index ef2f9a2f5..c4ecf7af5 100644 --- a/timeserieschart/src/TimeSeriesChartBase.tsx +++ b/timeserieschart/src/TimeSeriesChartBase.tsx @@ -12,31 +12,34 @@ // limitations under the License. import { Box } from '@mui/material'; -import { +import type { ChartInstance, ChartInstanceFocusOpts, - clearHighlightedSeries, CursorCoordinates, + FormatOptions, + OnEventsType, + TimeChartSeriesMapping, + TooltipConfig, + ZoomEventData, +} from '@perses-dev/components'; +import { + clearHighlightedSeries, DEFAULT_PINNED_CROSSHAIR, DEFAULT_TOOLTIP_CONFIG, EChart, enableDataZoom, - FormatOptions, getClosestTimestamp, getCommonTimeScale, getFormattedAxis, getPointInGrid, - OnEventsType, restoreChart, - TimeChartSeriesMapping, TimeChartTooltip, - TooltipConfig, useChartsContext, useTimeZone, - ZoomEventData, } from '@perses-dev/components'; -import { TimeScale, TimeSeries } from '@perses-dev/spec'; +import type { TimeScale, TimeSeries } from '@perses-dev/spec'; import type { + DatasetComponentOption as DatasetOption, EChartsCoreOption, GridComponentOption, LineSeriesOption, @@ -55,15 +58,16 @@ import { ToolboxComponent, TooltipComponent, } from 'echarts/components'; -import { ECharts as EChartsInstance, use as registerECharts } from 'echarts/core'; +import type { ECharts as EChartsInstance } from 'echarts/core'; +import { use as registerECharts } from 'echarts/core'; import { CanvasRenderer } from 'echarts/renderers'; -import { DatasetOption } from 'echarts/types/dist/shared'; import isEqual from 'lodash/isEqual'; import merge from 'lodash/merge'; -import { forwardRef, MouseEvent, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'; +import type { MouseEvent } from 'react'; +import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react'; import { AnnotationTooltip, buildAnnotationSeries } from './annotations/AnnotationTooltip'; -import { TimeSeriesAnnotation } from './utils/annotation'; +import type { TimeSeriesAnnotation } from './utils/annotation'; import { createTimezoneAwareAxisFormatter } from './utils/timezone-formatter'; registerECharts([ diff --git a/timeserieschart/src/TimeSeriesChartPanel.test.tsx b/timeserieschart/src/TimeSeriesChartPanel.test.tsx index b16a1122d..1b71f5fc8 100644 --- a/timeserieschart/src/TimeSeriesChartPanel.test.tsx +++ b/timeserieschart/src/TimeSeriesChartPanel.test.tsx @@ -12,21 +12,24 @@ // limitations under the License. import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; -import { AnnotationSpecWithData } from '@perses-dev/dashboards'; +import type * as DashboardsModule from '@perses-dev/dashboards'; +import type { AnnotationSpecWithData } from '@perses-dev/dashboards'; import { TimeRangeContext } from '@perses-dev/plugin-system'; -import { TimeRangeValue, toAbsoluteTimeRange } from '@perses-dev/spec'; +import type { TimeRangeValue } from '@perses-dev/spec'; +import { toAbsoluteTimeRange } from '@perses-dev/spec'; import { screen, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { VirtuosoMockContext } from 'react-virtuoso'; import { MOCK_TIME_SERIES_DATA_MULTIVALUE } from './test/mock-query-results'; -import { TimeSeriesChartPanel, TimeSeriesChartProps } from './TimeSeriesChartPanel'; +import type { TimeSeriesChartProps } from './TimeSeriesChartPanel'; +import { TimeSeriesChartPanel } from './TimeSeriesChartPanel'; // These tests exercise legend rendering, not annotations. The panel calls usePanelAnnotationsWithData, // which pulls in the full dashboard runtime (plugin registry, datasource store, query client). Mock it to // return no annotations so the panel can render without wiring those providers here. vi.mock('@perses-dev/dashboards', async (importOriginal) => ({ - ...(await importOriginal()), + ...(await importOriginal()), usePanelAnnotationsWithData: (): AnnotationSpecWithData[] => [], })); diff --git a/timeserieschart/src/TimeSeriesChartPanel.tsx b/timeserieschart/src/TimeSeriesChartPanel.tsx index 195ec8c40..e0145d9c4 100644 --- a/timeserieschart/src/TimeSeriesChartPanel.tsx +++ b/timeserieschart/src/TimeSeriesChartPanel.tsx @@ -12,50 +12,48 @@ // limitations under the License. import { Box, useTheme } from '@mui/material'; -import { +import type { ChartInstance, - YAxisLabel, ZoomEventData, - useChartsTheme, SelectedLegendItemState, - ContentWithLegend, TableColumnConfig, LegendItem, LegendProps, - useId, TooltipConfig, - DEFAULT_TOOLTIP_CONFIG, TimeChartSeriesMapping, + StepOptions, +} from '@perses-dev/components'; +import { + YAxisLabel, + useChartsTheme, + ContentWithLegend, + useId, + DEFAULT_TOOLTIP_CONFIG, getFormattedMultipleYAxes, DEFAULT_LEGEND, - StepOptions, formatValue, getTimeSeriesValues, } from '@perses-dev/components'; import { usePanelAnnotationsWithData } from '@perses-dev/dashboards'; +import type { PanelProps, CalculationType } from '@perses-dev/plugin-system'; import { LEGEND_VALUE_CONFIG, - PanelProps, useTimeRange, validateLegendSpec, legendValues, getCalculations, - CalculationType, } from '@perses-dev/plugin-system'; -import { TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec'; +import type { TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec'; import type { GridComponentOption } from 'echarts'; import merge from 'lodash/merge'; -import { ReactElement, useMemo, useRef, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo, useRef, useState } from 'react'; -import { - TimeSeriesChartOptions, - DEFAULT_FORMAT, - DEFAULT_VISUAL, - THRESHOLD_PLOT_INTERVAL, - QuerySettingsOptions, -} from './time-series-chart-model'; +import type { TimeSeriesChartOptions, QuerySettingsOptions } from './time-series-chart-model'; +import { DEFAULT_FORMAT, DEFAULT_VISUAL, THRESHOLD_PLOT_INTERVAL } from './time-series-chart-model'; import { TimeSeriesChartBase } from './TimeSeriesChartBase'; -import { convertAnnotationToTimeSeriesAnnotation, TimeSeriesAnnotation } from './utils/annotation'; +import type { TimeSeriesAnnotation } from './utils/annotation'; +import { convertAnnotationToTimeSeriesAnnotation } from './utils/annotation'; import { getTimeSeries, getCommonTimeScaleForQueries, diff --git a/timeserieschart/src/TimeSeriesExportAction.tsx b/timeserieschart/src/TimeSeriesExportAction.tsx index d79015b27..1fa7b3e58 100644 --- a/timeserieschart/src/TimeSeriesExportAction.tsx +++ b/timeserieschart/src/TimeSeriesExportAction.tsx @@ -17,7 +17,7 @@ import { exportDataAsCSV, extractExportableData, isExportableData, sanitizeFilen import DownloadIcon from 'mdi-material-ui/Download'; import React, { useCallback, useMemo } from 'react'; -import { TimeSeriesChartProps } from './TimeSeriesChartPanel'; +import type { TimeSeriesChartProps } from './TimeSeriesChartPanel'; export const TimeSeriesExportAction: React.FC = ({ queryResults, definition }) => { const exportableData = useMemo(() => { diff --git a/timeserieschart/src/VisualOptionsEditor.test.tsx b/timeserieschart/src/VisualOptionsEditor.test.tsx index 52add1137..f765e6db8 100644 --- a/timeserieschart/src/VisualOptionsEditor.test.tsx +++ b/timeserieschart/src/VisualOptionsEditor.test.tsx @@ -13,7 +13,8 @@ import { render, screen, fireEvent } from '@testing-library/react'; -import { TimeSeriesChartVisualOptions, VISUAL_CONFIG } from './time-series-chart-model'; +import type { TimeSeriesChartVisualOptions } from './time-series-chart-model'; +import { VISUAL_CONFIG } from './time-series-chart-model'; import { VisualOptionsEditor } from './VisualOptionsEditor'; describe('VisualOptionsEditor', () => { diff --git a/timeserieschart/src/VisualOptionsEditor.tsx b/timeserieschart/src/VisualOptionsEditor.tsx index efed36a34..dee965fd5 100644 --- a/timeserieschart/src/VisualOptionsEditor.tsx +++ b/timeserieschart/src/VisualOptionsEditor.tsx @@ -14,8 +14,9 @@ import { Slider, Switch, ToggleButton, ToggleButtonGroup } from '@mui/material'; import { OptionsEditorControl, OptionsEditorGroup, SettingsAutocomplete } from '@perses-dev/components'; import { produce } from 'immer'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; +import type { StackOptions, TimeSeriesChartVisualOptions } from './time-series-chart-model'; import { DEFAULT_AREA_OPACITY, DEFAULT_CONNECT_NULLS, @@ -24,11 +25,9 @@ import { DEFAULT_POINT_RADIUS, POINT_SIZE_OFFSET, STACK_CONFIG, - StackOptions, STACK_OPTIONS, LINE_STYLE_CONFIG, VISUAL_CONFIG, - TimeSeriesChartVisualOptions, DEFAULT_DISPLAY, } from './time-series-chart-model'; diff --git a/timeserieschart/src/YAxisOptionsEditor.tsx b/timeserieschart/src/YAxisOptionsEditor.tsx index 7e77b3d36..dabfe2e32 100644 --- a/timeserieschart/src/YAxisOptionsEditor.tsx +++ b/timeserieschart/src/YAxisOptionsEditor.tsx @@ -13,12 +13,12 @@ import { Switch, TextField } from '@mui/material'; import { OptionsEditorControl, OptionsEditorGroup, FormatControls, SettingsAutocomplete } from '@perses-dev/components'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; +import type { TimeSeriesChartYAxisOptions } from './time-series-chart-model'; import { DEFAULT_FORMAT, DEFAULT_Y_AXIS, - TimeSeriesChartYAxisOptions, Y_AXIS_CONFIG, LOG_BASE_CONFIG, LOG_BASE_OPTIONS, diff --git a/timeserieschart/src/annotations/AnnotationTooltip.tsx b/timeserieschart/src/annotations/AnnotationTooltip.tsx index cd9a43d8f..6574cca9b 100644 --- a/timeserieschart/src/annotations/AnnotationTooltip.tsx +++ b/timeserieschart/src/annotations/AnnotationTooltip.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { Box, Divider, Portal, Stack, Typography } from '@mui/material'; +import type { CursorCoordinates } from '@perses-dev/components'; import { assembleTransform, - CursorCoordinates, getDateAndTime, getTooltipStyles, PIN_TOOLTIP_HELP_TEXT, @@ -29,7 +29,7 @@ import Pin from 'mdi-material-ui/Pin'; import PinOutline from 'mdi-material-ui/PinOutline'; import useResizeObserver from 'use-resize-observer'; -import { TimeSeriesAnnotation } from '../utils/annotation'; +import type { TimeSeriesAnnotation } from '../utils/annotation'; export interface AnnotationTooltipProps { annotation: TimeSeriesAnnotation; diff --git a/timeserieschart/src/getPluginModule.ts b/timeserieschart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/timeserieschart/src/getPluginModule.ts +++ b/timeserieschart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/timeserieschart/src/test/mock-query-results.ts b/timeserieschart/src/test/mock-query-results.ts index 6324cb06b..a946dfbc5 100644 --- a/timeserieschart/src/test/mock-query-results.ts +++ b/timeserieschart/src/test/mock-query-results.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesData } from '@perses-dev/spec'; +import type { TimeSeriesData } from '@perses-dev/spec'; export const MOCK_TIME_SERIES_QUERY_RESULT_MULTIVALUE = [ { diff --git a/timeserieschart/src/time-series-chart-model.ts b/timeserieschart/src/time-series-chart-model.ts index 603af48fe..c983e5a60 100644 --- a/timeserieschart/src/time-series-chart-model.ts +++ b/timeserieschart/src/time-series-chart-model.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { FormatOptions, ThresholdOptions } from '@perses-dev/components'; -import { OptionsEditorProps, LegendSpecOptions } from '@perses-dev/plugin-system'; -import { Definition } from '@perses-dev/spec'; +import type { FormatOptions, ThresholdOptions } from '@perses-dev/components'; +import type { OptionsEditorProps, LegendSpecOptions } from '@perses-dev/plugin-system'; +import type { Definition } from '@perses-dev/spec'; /** * Line style options for time series charts. diff --git a/timeserieschart/src/utils/annotation.ts b/timeserieschart/src/utils/annotation.ts index 6259af079..de901fc16 100644 --- a/timeserieschart/src/utils/annotation.ts +++ b/timeserieschart/src/utils/annotation.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { AnnotationSpecWithData } from '@perses-dev/dashboards'; -import { AnnotationData, AnnotationDisplay } from '@perses-dev/spec'; +import type { AnnotationSpecWithData } from '@perses-dev/dashboards'; +import type { AnnotationData, AnnotationDisplay } from '@perses-dev/spec'; export type TimeSeriesAnnotation = AnnotationData & AnnotationDisplay; diff --git a/timeserieschart/src/utils/data-transform.test.ts b/timeserieschart/src/utils/data-transform.test.ts index e6a159bd4..a0e0f79c4 100644 --- a/timeserieschart/src/utils/data-transform.test.ts +++ b/timeserieschart/src/utils/data-transform.test.ts @@ -11,10 +11,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LegacyTimeSeries } from '@perses-dev/components'; -import { TimeScale } from '@perses-dev/spec'; +import type { LegacyTimeSeries } from '@perses-dev/components'; +import type { TimeScale } from '@perses-dev/spec'; -import { TimeSeriesChartVisualOptions, TimeSeriesChartYAxisOptions } from '../time-series-chart-model'; +import type { TimeSeriesChartVisualOptions, TimeSeriesChartYAxisOptions } from '../time-series-chart-model'; import { convertPercentThreshold, convertPanelYAxis, getTimeSeries, roundDown } from './data-transform'; const MAX_VALUE = 120; diff --git a/timeserieschart/src/utils/data-transform.ts b/timeserieschart/src/utils/data-transform.ts index d576e68b0..a7244f29a 100644 --- a/timeserieschart/src/utils/data-transform.ts +++ b/timeserieschart/src/utils/data-transform.ts @@ -11,20 +11,24 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - OPTIMIZED_MODE_SERIES_LIMIT, +import type { LegacyTimeSeries, EChartsDataFormat, EChartsValues, TimeSeriesOption, StepOptions, - getCommonTimeScale, } from '@perses-dev/components'; -import { useTimeSeriesQueries, PanelData } from '@perses-dev/plugin-system'; -import { TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec'; +import { OPTIMIZED_MODE_SERIES_LIMIT, getCommonTimeScale } from '@perses-dev/components'; +import type { useTimeSeriesQueries, PanelData } from '@perses-dev/plugin-system'; +import type { TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '@perses-dev/spec'; import type { YAXisComponentOption } from 'echarts'; -import { LineSeriesOption, BarSeriesOption } from 'echarts/charts'; +import type { LineSeriesOption, BarSeriesOption } from 'echarts/charts'; +import type { + TimeSeriesChartVisualOptions, + TimeSeriesChartYAxisOptions, + LineStyleType, +} from '../time-series-chart-model'; import { DEFAULT_AREA_OPACITY, DEFAULT_CONNECT_NULLS, @@ -33,9 +37,6 @@ import { DEFAULT_Y_AXIS, POSITIVE_MIN_VALUE_MULTIPLIER, NEGATIVE_MIN_VALUE_MULTIPLIER, - TimeSeriesChartVisualOptions, - TimeSeriesChartYAxisOptions, - LineStyleType, } from '../time-series-chart-model'; export type RunningQueriesState = ReturnType; @@ -287,5 +288,5 @@ export function convertPanelYAxis(inputAxis: TimeSeriesChartYAxisOptions = {}): export function roundDown(num: number): number { const magnitude = Math.floor(Math.log10(Math.abs(num))); const firstDigit = Math.floor(num / Math.pow(10, magnitude)); - return firstDigit * Math.pow(10, magnitude); + return Number((firstDigit * Math.pow(10, magnitude)).toPrecision(1)); } diff --git a/timeserieschart/src/utils/palette-gen.test.ts b/timeserieschart/src/utils/palette-gen.test.ts index f6650c76f..e22947f69 100644 --- a/timeserieschart/src/utils/palette-gen.test.ts +++ b/timeserieschart/src/utils/palette-gen.test.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesChartVisualOptions } from '../time-series-chart-model'; -import { getSeriesColor, getAutoPaletteColor, getCategoricalPaletteColor, SeriesColorProps } from './palette-gen'; +import type { TimeSeriesChartVisualOptions } from '../time-series-chart-model'; +import type { SeriesColorProps } from './palette-gen'; +import { getSeriesColor, getAutoPaletteColor, getCategoricalPaletteColor } from './palette-gen'; describe('getSeriesColor', () => { const fallbackColor = '#000'; diff --git a/timeserieschart/src/utils/palette-gen.ts b/timeserieschart/src/utils/palette-gen.ts index 01725f08c..04cfc5fc5 100644 --- a/timeserieschart/src/utils/palette-gen.ts +++ b/timeserieschart/src/utils/palette-gen.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { QuerySettingsOptions, TimeSeriesChartVisualOptions } from '../time-series-chart-model'; +import type { QuerySettingsOptions, TimeSeriesChartVisualOptions } from '../time-series-chart-model'; import { getConsistentColor } from './palette'; export interface SeriesColorProps { diff --git a/timeserieschart/tsconfig.build.json b/timeserieschart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/timeserieschart/tsconfig.build.json +++ b/timeserieschart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/timeserieschart/tsconfig.json b/timeserieschart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/timeserieschart/tsconfig.json +++ b/timeserieschart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/timeserieschart/vitest.config.ts b/timeserieschart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/timeserieschart/vitest.config.ts +++ b/timeserieschart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/timeseriestable/package.json b/timeseriestable/package.json index 80ec8ad7c..29f87a74f 100644 --- a/timeseriestable/package.json +++ b/timeseriestable/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "peerDependencies": { @@ -29,9 +29,9 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/dashboards": "^0.55.0-beta.6", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/timeseriestable/src/TimeSeriesTable.ts b/timeseriestable/src/TimeSeriesTable.ts index 5036bc683..5a39c07da 100644 --- a/timeseriestable/src/TimeSeriesTable.ts +++ b/timeseriestable/src/TimeSeriesTable.ts @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; import { TimeSeriesTableItemSelectionActionsEditor } from './components'; -import { TimeSeriesTableOptions } from './model'; -import { TimeSeriesTablePanel, TimeSeriesTableProps } from './TimeSeriesTablePanel'; +import type { TimeSeriesTableOptions } from './model'; +import type { TimeSeriesTableProps } from './TimeSeriesTablePanel'; +import { TimeSeriesTablePanel } from './TimeSeriesTablePanel'; /** * The core TimeSeriesTable panel plugin for Perses. diff --git a/timeseriestable/src/TimeSeriesTablePanel.test.tsx b/timeseriestable/src/TimeSeriesTablePanel.test.tsx index 199ceee6a..46b4b72e0 100644 --- a/timeseriestable/src/TimeSeriesTablePanel.test.tsx +++ b/timeseriestable/src/TimeSeriesTablePanel.test.tsx @@ -19,19 +19,21 @@ import { testChartsTheme, } from '@perses-dev/components'; import { VariableProvider } from '@perses-dev/dashboards'; -import { TimeRangeProviderBasic, WebhookAction } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; +import type { WebhookAction } from '@perses-dev/plugin-system'; +import { TimeRangeProviderBasic } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import { TimeSeriesTableOptions } from './model'; +import type { TimeSeriesTableOptions } from './model'; import { MOCK_TIME_SERIES_DATA_MULTIVALUE, MOCK_TIME_SERIES_DATA_SINGLEVALUE, MOCK_TIME_SERIES_QUERY_DEFINITION, } from './test/mock-query-results'; -import { TimeSeriesTablePanel, TimeSeriesTableProps } from './TimeSeriesTablePanel'; +import type { TimeSeriesTableProps } from './TimeSeriesTablePanel'; +import { TimeSeriesTablePanel } from './TimeSeriesTablePanel'; const TEST_PROPS: Omit = { contentDimensions: { width: 500, height: 500 }, diff --git a/timeseriestable/src/TimeSeriesTablePanel.tsx b/timeseriestable/src/TimeSeriesTablePanel.tsx index 6123e1e10..2e4b87164 100644 --- a/timeseriestable/src/TimeSeriesTablePanel.tsx +++ b/timeseriestable/src/TimeSeriesTablePanel.tsx @@ -13,12 +13,12 @@ import { Box } from '@mui/material'; import { useChartsTheme } from '@perses-dev/components'; -import { PanelProps } from '@perses-dev/plugin-system'; -import { TimeSeriesData } from '@perses-dev/spec'; -import { ReactElement } from 'react'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import type { TimeSeriesData } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; import { DataTable } from './components'; -import { TimeSeriesTableOptions } from './model'; +import type { TimeSeriesTableOptions } from './model'; export type TimeSeriesTableProps = PanelProps; diff --git a/timeseriestable/src/components/DataTable.tsx b/timeseriestable/src/components/DataTable.tsx index c860add7d..841f17f3e 100644 --- a/timeseriestable/src/components/DataTable.tsx +++ b/timeseriestable/src/components/DataTable.tsx @@ -25,11 +25,19 @@ import { } from '@mui/material'; import { useSelection } from '@perses-dev/components'; import { useSelectionItemActions } from '@perses-dev/dashboards'; -import { ActionOptions, PanelData, useAllVariableValues } from '@perses-dev/plugin-system'; -import { BucketTuple, HistogramValue, TimeSeries, TimeSeriesData, TimeSeriesHistogramTuple } from '@perses-dev/spec'; -import { ReactElement, ReactNode, useCallback, useMemo } from 'react'; +import type { ActionOptions, PanelData } from '@perses-dev/plugin-system'; +import { useAllVariableValues } from '@perses-dev/plugin-system'; +import type { + BucketTuple, + HistogramValue, + TimeSeries, + TimeSeriesData, + TimeSeriesHistogramTuple, +} from '@perses-dev/spec'; +import type { ReactElement, ReactNode } from 'react'; +import { useCallback, useMemo } from 'react'; -import { TimeSeriesTableOptions } from '../model'; +import type { TimeSeriesTableOptions } from '../model'; import { EmbeddedPanel } from './EmbeddedPanel'; import { SeriesName } from './SeriesName'; diff --git a/timeseriestable/src/components/EmbeddedPanel.tsx b/timeseriestable/src/components/EmbeddedPanel.tsx index d0ffbe262..0f1f4d90b 100644 --- a/timeseriestable/src/components/EmbeddedPanel.tsx +++ b/timeseriestable/src/components/EmbeddedPanel.tsx @@ -13,9 +13,9 @@ import { ErrorAlert, ErrorBoundary } from '@perses-dev/components'; import { PanelPluginLoader } from '@perses-dev/dashboards'; -import { PanelData } from '@perses-dev/plugin-system'; -import { QueryDataType, UnknownSpec } from '@perses-dev/spec'; -import { ReactElement } from 'react'; +import type { PanelData } from '@perses-dev/plugin-system'; +import type { QueryDataType, UnknownSpec } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; import useResizeObserver from 'use-resize-observer'; interface EmbeddedPanelProps { diff --git a/timeseriestable/src/components/SeriesName.tsx b/timeseriestable/src/components/SeriesName.tsx index 62de8ecd2..537965edf 100644 --- a/timeseriestable/src/components/SeriesName.tsx +++ b/timeseriestable/src/components/SeriesName.tsx @@ -13,8 +13,8 @@ import { Typography } from '@mui/material'; import { useSnackbar } from '@perses-dev/components'; -import { Labels } from '@perses-dev/spec'; -import { ReactElement, MouseEvent } from 'react'; +import type { Labels } from '@perses-dev/spec'; +import type { ReactElement, MouseEvent } from 'react'; interface SeriesNameProps { name: string; diff --git a/timeseriestable/src/components/TimeSeriesTableItemSelectionActionsEditor.tsx b/timeseriestable/src/components/TimeSeriesTableItemSelectionActionsEditor.tsx index 2d5948d71..6af12b695 100644 --- a/timeseriestable/src/components/TimeSeriesTableItemSelectionActionsEditor.tsx +++ b/timeseriestable/src/components/TimeSeriesTableItemSelectionActionsEditor.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ActionOptions, ItemSelectionActionsEditor, SelectionOptions } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ActionOptions, SelectionOptions } from '@perses-dev/plugin-system'; +import { ItemSelectionActionsEditor } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; -import { TimeSeriesTableSettingsEditorProps } from '../model'; +import type { TimeSeriesTableSettingsEditorProps } from '../model'; export function TimeSeriesTableItemSelectionActionsEditor({ value, diff --git a/timeseriestable/src/getPluginModule.ts b/timeseriestable/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/timeseriestable/src/getPluginModule.ts +++ b/timeseriestable/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/timeseriestable/src/model.ts b/timeseriestable/src/model.ts index d102c1890..f8e293549 100644 --- a/timeseriestable/src/model.ts +++ b/timeseriestable/src/model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ActionOptions, OptionsEditorProps, SelectionOptions } from '@perses-dev/plugin-system'; +import type { ActionOptions, OptionsEditorProps, SelectionOptions } from '@perses-dev/plugin-system'; export interface TimeSeriesTableOptions { /** diff --git a/timeseriestable/src/test/mock-query-results.ts b/timeseriestable/src/test/mock-query-results.ts index 479031aa2..d496b55d5 100644 --- a/timeseriestable/src/test/mock-query-results.ts +++ b/timeseriestable/src/test/mock-query-results.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesData } from '@perses-dev/spec'; +import type { TimeSeriesData } from '@perses-dev/spec'; export const MOCK_TIME_SERIES_QUERY_RESULT_MULTIVALUE = [ { diff --git a/timeseriestable/tsconfig.build.json b/timeseriestable/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/timeseriestable/tsconfig.build.json +++ b/timeseriestable/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/timeseriestable/tsconfig.json b/timeseriestable/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/timeseriestable/tsconfig.json +++ b/timeseriestable/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/timeseriestable/vitest.config.ts b/timeseriestable/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/timeseriestable/vitest.config.ts +++ b/timeseriestable/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/tracetable/package.json b/tracetable/package.json index 6accd3987..39d5d7553 100644 --- a/tracetable/package.json +++ b/tracetable/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -32,8 +32,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", + "@perses-dev/plugin-system": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/tracetable/src/DataTable.tsx b/tracetable/src/DataTable.tsx index cf2bcf571..2600e7e1a 100644 --- a/tracetable/src/DataTable.tsx +++ b/tracetable/src/DataTable.tsx @@ -12,22 +12,19 @@ // limitations under the License. import { Avatar, Box, Chip, Link, Tooltip, Typography, useTheme } from '@mui/material'; -import { DataGrid, GridColDef, GridRowSelectionModel } from '@mui/x-data-grid'; +import type { GridColDef, GridRowSelectionModel } from '@mui/x-data-grid'; +import { DataGrid } from '@mui/x-data-grid'; import { useChartsTheme, useSelection, useTimeZone } from '@perses-dev/components'; import { useSelectionItemActions } from '@perses-dev/dashboards'; -import { PanelData, replaceVariablesInString, useAllVariableValues, useRouterContext } from '@perses-dev/plugin-system'; -import { - convertTimeToDuration, - formatDuration, - QueryDefinition, - ServiceStats, - TraceData, - TraceSearchResult, -} from '@perses-dev/spec'; +import type { PanelData } from '@perses-dev/plugin-system'; +import { replaceVariablesInString, useAllVariableValues, useRouterContext } from '@perses-dev/plugin-system'; +import type { QueryDefinition, ServiceStats, TraceData, TraceSearchResult } from '@perses-dev/spec'; +import { convertTimeToDuration, formatDuration } from '@perses-dev/spec'; import InformationIcon from 'mdi-material-ui/Information'; -import { ReactElement, ReactNode, useCallback, useMemo } from 'react'; +import type { ReactElement, ReactNode } from 'react'; +import { useCallback, useMemo } from 'react'; -import { TraceTableOptions } from './trace-table-model'; +import type { TraceTableOptions } from './trace-table-model'; import { getServiceColor } from './utils/utils'; const DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = { diff --git a/tracetable/src/TraceTable.ts b/tracetable/src/TraceTable.ts index c4e6fdf72..9034d937e 100644 --- a/tracetable/src/TraceTable.ts +++ b/tracetable/src/TraceTable.ts @@ -11,11 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { TraceTableOptions, createInitialTraceTableOptions } from './trace-table-model'; +import type { TraceTableOptions } from './trace-table-model'; +import { createInitialTraceTableOptions } from './trace-table-model'; import { TraceTableItemSelectionActionsEditor } from './TraceTableItemSelectionActionsEditor'; -import { TraceTablePanel, TraceTablePanelProps } from './TraceTablePanel'; +import type { TraceTablePanelProps } from './TraceTablePanel'; +import { TraceTablePanel } from './TraceTablePanel'; /** * The core TraceTable panel plugin for Perses. diff --git a/tracetable/src/TraceTableItemSelectionActionsEditor.tsx b/tracetable/src/TraceTableItemSelectionActionsEditor.tsx index f9c4e87ed..2b1cd2375 100644 --- a/tracetable/src/TraceTableItemSelectionActionsEditor.tsx +++ b/tracetable/src/TraceTableItemSelectionActionsEditor.tsx @@ -11,15 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { - ActionOptions, - ItemSelectionActionsEditor, - OptionsEditorProps, - SelectionOptions, -} from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ActionOptions, OptionsEditorProps, SelectionOptions } from '@perses-dev/plugin-system'; +import { ItemSelectionActionsEditor } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; -import { TraceTableOptions } from './trace-table-model'; +import type { TraceTableOptions } from './trace-table-model'; type TraceTableItemSelectionActionsEditorProps = OptionsEditorProps; diff --git a/tracetable/src/TraceTablePanel.test.tsx b/tracetable/src/TraceTablePanel.test.tsx index 3e366c7a7..96e2f54ea 100644 --- a/tracetable/src/TraceTablePanel.test.tsx +++ b/tracetable/src/TraceTablePanel.test.tsx @@ -13,14 +13,16 @@ import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; import { VariableProvider } from '@perses-dev/dashboards'; -import { PanelData, ReactRouterProvider, TimeRangeProviderBasic } from '@perses-dev/plugin-system'; -import { TraceData } from '@perses-dev/spec'; +import type { PanelData } from '@perses-dev/plugin-system'; +import { ReactRouterProvider, TimeRangeProviderBasic } from '@perses-dev/plugin-system'; +import type { TraceData } from '@perses-dev/spec'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { render, screen } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import { MOCK_TRACE_SEARCH_RESULT_QUERY_RESULT } from './test/mock-trace-data'; -import { TraceTablePanel, TraceTablePanelProps } from './TraceTablePanel'; +import type { TraceTablePanelProps } from './TraceTablePanel'; +import { TraceTablePanel } from './TraceTablePanel'; const TEST_TRACE_TABLE_PROPS: Omit = { contentDimensions: { diff --git a/tracetable/src/TraceTablePanel.tsx b/tracetable/src/TraceTablePanel.tsx index 893f4cb9f..f4fb89932 100644 --- a/tracetable/src/TraceTablePanel.tsx +++ b/tracetable/src/TraceTablePanel.tsx @@ -13,12 +13,12 @@ import { Box } from '@mui/material'; import { NoDataOverlay, useChartsTheme } from '@perses-dev/components'; -import { PanelProps } from '@perses-dev/plugin-system'; -import { TraceData } from '@perses-dev/spec'; -import { ReactElement } from 'react'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import type { TraceData } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; import { DataTable } from './DataTable'; -import { TraceTableOptions } from './trace-table-model'; +import type { TraceTableOptions } from './trace-table-model'; export type TraceTablePanelProps = PanelProps; diff --git a/tracetable/src/getPluginModule.ts b/tracetable/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/tracetable/src/getPluginModule.ts +++ b/tracetable/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/tracetable/src/test/mock-trace-data.ts b/tracetable/src/test/mock-trace-data.ts index e57bce4ac..069e0e9e5 100644 --- a/tracetable/src/test/mock-trace-data.ts +++ b/tracetable/src/test/mock-trace-data.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TraceData } from '@perses-dev/spec'; +import type { TraceData } from '@perses-dev/spec'; /** * Mock data we get from getTraceData() in @perses/tempo-plugin. diff --git a/tracetable/src/trace-table-model.ts b/tracetable/src/trace-table-model.ts index 36b5a49a6..b3c2f0af3 100644 --- a/tracetable/src/trace-table-model.ts +++ b/tracetable/src/trace-table-model.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { ActionOptions, SelectionOptions } from '@perses-dev/plugin-system'; +import type { ActionOptions, SelectionOptions } from '@perses-dev/plugin-system'; /** * The Options object type supported by the TraceTable panel plugin. diff --git a/tracetable/src/utils/utils.ts b/tracetable/src/utils/utils.ts index 7d3f8e427..93c22eafe 100644 --- a/tracetable/src/utils/utils.ts +++ b/tracetable/src/utils/utils.ts @@ -11,8 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Theme } from '@mui/material'; -import { PersesChartsTheme } from '@perses-dev/components'; +import type { Theme } from '@mui/material'; +import type { PersesChartsTheme } from '@perses-dev/components'; import { getConsistentCategoricalColor, getConsistentColor } from './palette'; diff --git a/tracetable/tsconfig.build.json b/tracetable/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/tracetable/tsconfig.build.json +++ b/tracetable/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/tracetable/tsconfig.json b/tracetable/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/tracetable/tsconfig.json +++ b/tracetable/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/tracetable/vitest.config.ts b/tracetable/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/tracetable/vitest.config.ts +++ b/tracetable/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/tracingganttchart/package.json b/tracingganttchart/package.json index 76471bf67..cd2719f18 100644 --- a/tracingganttchart/package.json +++ b/tracingganttchart/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -33,8 +33,8 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/plugin-system": "^0.55.0-beta.3", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/plugin-system": "^0.55.0-beta.6", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", "echarts": "5.5.0", diff --git a/tracingganttchart/src/PanelActions.test.ts b/tracingganttchart/src/PanelActions.test.ts index e49aa3b6a..0559f251d 100644 --- a/tracingganttchart/src/PanelActions.test.ts +++ b/tracingganttchart/src/PanelActions.test.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { getFilename } from './PanelActions'; import * as otlpTrace from './test/traces/example_otlp.json'; diff --git a/tracingganttchart/src/PanelActions.tsx b/tracingganttchart/src/PanelActions.tsx index 8c35380ce..ecedbdd7c 100644 --- a/tracingganttchart/src/PanelActions.tsx +++ b/tracingganttchart/src/PanelActions.tsx @@ -13,11 +13,12 @@ import { InfoTooltip } from '@perses-dev/components'; import { HeaderIconButton } from '@perses-dev/dashboards'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import DownloadIcon from 'mdi-material-ui/DownloadOutline'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; -import { TracingGanttChartPanelProps } from './TracingGanttChartPanel'; +import type { TracingGanttChartPanelProps } from './TracingGanttChartPanel'; export function DownloadTraceAction(props: TracingGanttChartPanelProps): ReactElement | null { const { queryResults } = props; diff --git a/tracingganttchart/src/TracingGanttChart.ts b/tracingganttchart/src/TracingGanttChart.ts index 7e862dbb1..c86e0c911 100644 --- a/tracingganttchart/src/TracingGanttChart.ts +++ b/tracingganttchart/src/TracingGanttChart.ts @@ -11,11 +11,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PanelPlugin } from '@perses-dev/plugin-system'; +import type { PanelPlugin } from '@perses-dev/plugin-system'; -import { createInitialTracingGanttChartOptions, TracingGanttChartOptions } from './gantt-chart-model'; +import type { TracingGanttChartOptions } from './gantt-chart-model'; +import { createInitialTracingGanttChartOptions } from './gantt-chart-model'; import { DownloadTraceAction } from './PanelActions'; -import { TracingGanttChartPanel, TracingGanttChartPanelProps } from './TracingGanttChartPanel'; +import type { TracingGanttChartPanelProps } from './TracingGanttChartPanel'; +import { TracingGanttChartPanel } from './TracingGanttChartPanel'; export const TracingGanttChart: PanelPlugin = { PanelComponent: TracingGanttChartPanel, diff --git a/tracingganttchart/src/TracingGanttChart/DetailPane/Attributes.test.tsx b/tracingganttchart/src/TracingGanttChart/DetailPane/Attributes.test.tsx index ca8c694de..99ab85a03 100644 --- a/tracingganttchart/src/TracingGanttChart/DetailPane/Attributes.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/DetailPane/Attributes.test.tsx @@ -13,16 +13,18 @@ import { VariableProvider } from '@perses-dev/dashboards'; import { ReactRouterProvider, TimeRangeProviderBasic } from '@perses-dev/plugin-system'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { screen } from '@testing-library/dom'; -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; -import { CustomLinks } from '../../gantt-chart-model'; +import type { CustomLinks } from '../../gantt-chart-model'; import * as exampleTrace from '../../test/traces/example_otlp.json'; import { getTraceModel } from '../trace'; -import { AttributeList, AttributeListProps, TraceAttributes, TraceAttributesProps } from './Attributes'; +import type { AttributeListProps, TraceAttributesProps } from './Attributes'; +import { AttributeList, TraceAttributes } from './Attributes'; describe('Attributes', () => { const trace = getTraceModel(exampleTrace as otlptracev1.TracesData); diff --git a/tracingganttchart/src/TracingGanttChart/DetailPane/Attributes.tsx b/tracingganttchart/src/TracingGanttChart/DetailPane/Attributes.tsx index 0f3636394..2f5021eb1 100644 --- a/tracingganttchart/src/TracingGanttChart/DetailPane/Attributes.tsx +++ b/tracingganttchart/src/TracingGanttChart/DetailPane/Attributes.tsx @@ -13,11 +13,12 @@ import { Divider, Link, List, ListItem, ListItemText } from '@mui/material'; import { replaceVariablesInString, useAllVariableValues, useRouterContext } from '@perses-dev/plugin-system'; -import * as oltpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; -import { ReactElement, useMemo } from 'react'; +import type * as oltpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; -import { CustomLinks } from '../../gantt-chart-model'; -import { Span, Trace } from '../trace'; +import type { CustomLinks } from '../../gantt-chart-model'; +import type { Span, Trace } from '../trace'; import { formatDuration } from '../utils'; export interface TraceAttributesProps { diff --git a/tracingganttchart/src/TracingGanttChart/DetailPane/DetailPane.tsx b/tracingganttchart/src/TracingGanttChart/DetailPane/DetailPane.tsx index b60ba1a7c..4a372948c 100644 --- a/tracingganttchart/src/TracingGanttChart/DetailPane/DetailPane.tsx +++ b/tracingganttchart/src/TracingGanttChart/DetailPane/DetailPane.tsx @@ -13,10 +13,11 @@ import { Box, Chip, IconButton, Tab, Tabs, Typography } from '@mui/material'; import CloseIcon from 'mdi-material-ui/Close'; -import { ReactElement, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useState } from 'react'; -import { CustomLinks } from '../../gantt-chart-model'; -import { Span, Trace } from '../trace'; +import type { CustomLinks } from '../../gantt-chart-model'; +import type { Span, Trace } from '../trace'; import { TraceAttributes } from './Attributes'; import { SpanEventList } from './SpanEvents'; import { SpanLinkList } from './SpanLinks'; diff --git a/tracingganttchart/src/TracingGanttChart/DetailPane/SpanEvents.test.tsx b/tracingganttchart/src/TracingGanttChart/DetailPane/SpanEvents.test.tsx index f929a28c0..f75353419 100644 --- a/tracingganttchart/src/TracingGanttChart/DetailPane/SpanEvents.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/DetailPane/SpanEvents.test.tsx @@ -13,15 +13,17 @@ import { VariableProvider } from '@perses-dev/dashboards'; import { ReactRouterProvider, TimeRangeProviderBasic } from '@perses-dev/plugin-system'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { fireEvent, screen } from '@testing-library/dom'; -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import * as exampleTrace from '../../test/traces/example_otlp.json'; import { getTraceModel } from '../trace'; -import { SpanEventList, SpanEventListProps } from './SpanEvents'; +import type { SpanEventListProps } from './SpanEvents'; +import { SpanEventList } from './SpanEvents'; describe('SpanEvents', () => { const trace = getTraceModel(exampleTrace as otlptracev1.TracesData); diff --git a/tracingganttchart/src/TracingGanttChart/DetailPane/SpanEvents.tsx b/tracingganttchart/src/TracingGanttChart/DetailPane/SpanEvents.tsx index 4f7e390bb..bf11c4f44 100644 --- a/tracingganttchart/src/TracingGanttChart/DetailPane/SpanEvents.tsx +++ b/tracingganttchart/src/TracingGanttChart/DetailPane/SpanEvents.tsx @@ -14,10 +14,11 @@ import { Collapse, Divider, List, ListItemButton, ListItemText } from '@mui/material'; import ChevronDown from 'mdi-material-ui/ChevronDown'; import ChevronUp from 'mdi-material-ui/ChevronUp'; -import { Fragment, ReactElement, useState } from 'react'; +import type { ReactElement } from 'react'; +import { Fragment, useState } from 'react'; -import { CustomLinks } from '../../gantt-chart-model'; -import { Trace, Span, Event } from '../trace'; +import type { CustomLinks } from '../../gantt-chart-model'; +import type { Trace, Span, Event } from '../trace'; import { formatDuration } from '../utils'; import { AttributeItems, AttributeItem } from './Attributes'; diff --git a/tracingganttchart/src/TracingGanttChart/DetailPane/SpanLinks.test.tsx b/tracingganttchart/src/TracingGanttChart/DetailPane/SpanLinks.test.tsx index 07f99e451..95967e1aa 100644 --- a/tracingganttchart/src/TracingGanttChart/DetailPane/SpanLinks.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/DetailPane/SpanLinks.test.tsx @@ -13,16 +13,18 @@ import { VariableProvider } from '@perses-dev/dashboards'; import { ReactRouterProvider, TimeRangeProviderBasic } from '@perses-dev/plugin-system'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { screen } from '@testing-library/dom'; -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; -import { CustomLinks } from '../../gantt-chart-model'; +import type { CustomLinks } from '../../gantt-chart-model'; import * as exampleTrace from '../../test/traces/example_otlp.json'; import { getTraceModel } from '../trace'; -import { SpanLinkList, SpanLinkListProps } from './SpanLinks'; +import type { SpanLinkListProps } from './SpanLinks'; +import { SpanLinkList } from './SpanLinks'; describe('SpanLinks', () => { const trace = getTraceModel(exampleTrace as otlptracev1.TracesData); diff --git a/tracingganttchart/src/TracingGanttChart/DetailPane/SpanLinks.tsx b/tracingganttchart/src/TracingGanttChart/DetailPane/SpanLinks.tsx index dcd343390..2f54485b2 100644 --- a/tracingganttchart/src/TracingGanttChart/DetailPane/SpanLinks.tsx +++ b/tracingganttchart/src/TracingGanttChart/DetailPane/SpanLinks.tsx @@ -13,10 +13,11 @@ import { Divider, List } from '@mui/material'; import { replaceVariablesInString, useAllVariableValues } from '@perses-dev/plugin-system'; -import { Fragment, ReactElement } from 'react'; +import type { ReactElement } from 'react'; +import { Fragment } from 'react'; -import { CustomLinks } from '../../gantt-chart-model'; -import { Span, Link } from '../trace'; +import type { CustomLinks } from '../../gantt-chart-model'; +import type { Span, Link } from '../trace'; import { AttributeItem, AttributeItems } from './Attributes'; export interface SpanLinkListProps { diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTable.test.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTable.test.tsx index cad63efe8..1dac49271 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTable.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTable.test.tsx @@ -12,14 +12,16 @@ // limitations under the License. import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { fireEvent, screen } from '@testing-library/dom'; -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { VirtuosoMockContext } from 'react-virtuoso'; import * as exampleTrace from '../../test/traces/example_otlp.json'; import { getTraceModel } from '../trace'; -import { GanttTable, GanttTableProps } from './GanttTable'; +import type { GanttTableProps } from './GanttTable'; +import { GanttTable } from './GanttTable'; import { GanttTableProvider } from './GanttTableProvider'; describe('GanttTable', () => { diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTable.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTable.tsx index d8b8e150f..acfeae9eb 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTable.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTable.tsx @@ -12,12 +12,15 @@ // limitations under the License. import { Box, useTheme } from '@mui/material'; -import { ReactElement, useEffect, useMemo, useRef, useState } from 'react'; -import { Virtuoso, VirtuosoHandle, ListRange } from 'react-virtuoso'; +import type { ReactElement } from 'react'; +import { useEffect, useMemo, useRef, useState } from 'react'; +import type { VirtuosoHandle, ListRange } from 'react-virtuoso'; +import { Virtuoso } from 'react-virtuoso'; -import { CustomLinks, TracingGanttChartOptions } from '../../gantt-chart-model'; -import { Span, Trace, forEachSpan } from '../trace'; -import { Viewport } from '../utils'; +import type { CustomLinks, TracingGanttChartOptions } from '../../gantt-chart-model'; +import type { Span, Trace } from '../trace'; +import { forEachSpan } from '../trace'; +import type { Viewport } from '../utils'; import { GanttTableHeader } from './GanttTableHeader'; import { useGanttTableContext } from './GanttTableProvider'; import { GanttTableRow } from './GanttTableRow'; diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableHeader.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableHeader.tsx index b4c9fae60..23c819468 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableHeader.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableHeader.tsx @@ -12,11 +12,12 @@ // limitations under the License. import { Box, Stack, useTheme } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; import { TicksHeader } from '../Ticks'; -import { Trace } from '../trace'; -import { Viewport, rowHeight } from '../utils'; +import type { Trace } from '../trace'; +import type { Viewport } from '../utils'; +import { rowHeight } from '../utils'; interface GanttTableHeaderProps { trace: Trace; diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableProvider.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableProvider.tsx index 7c18a55a5..fbc356e04 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableProvider.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableProvider.tsx @@ -11,7 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { createContext, ReactElement, useContext, useState } from 'react'; +import type { ReactElement } from 'react'; +import { createContext, useContext, useState } from 'react'; interface GanttTableContextType { collapsedSpans: Set; diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableRow.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableRow.tsx index d3d52f99a..97649d1c3 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableRow.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/GanttTableRow.tsx @@ -14,9 +14,10 @@ import { Stack, styled, useTheme } from '@mui/material'; import { memo } from 'react'; -import { CustomLinks, TracingGanttChartOptions } from '../../gantt-chart-model'; -import { Span } from '../trace'; -import { Viewport, rowHeight } from '../utils'; +import type { CustomLinks, TracingGanttChartOptions } from '../../gantt-chart-model'; +import type { Span } from '../trace'; +import type { Viewport } from '../utils'; +import { rowHeight } from '../utils'; import { SpanDuration } from './SpanDuration'; import { SpanName } from './SpanName'; diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/ResizableDivider.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/ResizableDivider.tsx index 8cdc134c5..edcfbd8f4 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/ResizableDivider.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/ResizableDivider.tsx @@ -13,7 +13,8 @@ import { Box, styled } from '@mui/material'; import { useEvent } from '@perses-dev/plugin-system'; -import { MouseEvent as ReactMouseEvent, ReactElement, useEffect, useState } from 'react'; +import type { MouseEvent as ReactMouseEvent, ReactElement } from 'react'; +import { useEffect, useState } from 'react'; interface ResizableDividerProps { parentRef: React.RefObject; diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanDuration.test.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanDuration.test.tsx index 2c8b9702f..06822baaa 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanDuration.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanDuration.test.tsx @@ -12,14 +12,16 @@ // limitations under the License. import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { screen } from '@testing-library/dom'; -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import * as exampleTrace from '../../test/traces/example_otlp.json'; import { getTraceModel } from '../trace'; import { GanttTableProvider } from './GanttTableProvider'; -import { SpanDuration, SpanDurationProps } from './SpanDuration'; +import type { SpanDurationProps } from './SpanDuration'; +import { SpanDuration } from './SpanDuration'; describe('SpanDuration', () => { const trace = getTraceModel(exampleTrace as otlptracev1.TracesData); diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanDuration.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanDuration.tsx index 6924753ad..4ab9d1595 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanDuration.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanDuration.tsx @@ -13,12 +13,13 @@ import { Box, useTheme } from '@mui/material'; import { useChartsTheme } from '@perses-dev/components'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { TracingGanttChartOptions } from '../../gantt-chart-model'; +import type { TracingGanttChartOptions } from '../../gantt-chart-model'; import { Ticks } from '../Ticks'; -import { Span } from '../trace'; -import { Viewport, formatDuration, getSpanColor, minSpanWidthPx } from '../utils'; +import type { Span } from '../trace'; +import type { Viewport } from '../utils'; +import { formatDuration, getSpanColor, minSpanWidthPx } from '../utils'; export interface SpanDurationProps { options: TracingGanttChartOptions; diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanIndents.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanIndents.tsx index 9ab11b1f3..89cfdadb5 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanIndents.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanIndents.tsx @@ -14,9 +14,10 @@ import { styled, useTheme } from '@mui/material'; import ChevronDownIcon from 'mdi-material-ui/ChevronDown'; import ChevronRightIcon from 'mdi-material-ui/ChevronRight'; -import { MouseEvent, ReactElement, useCallback } from 'react'; +import type { MouseEvent, ReactElement } from 'react'; +import { useCallback } from 'react'; -import { Span } from '../trace'; +import type { Span } from '../trace'; import { useGanttTableContext } from './GanttTableProvider'; const MIN_INDENT_WIDTH = 8; diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanLinksButton.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanLinksButton.tsx index 3b658c98a..325091609 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanLinksButton.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanLinksButton.tsx @@ -15,10 +15,11 @@ import { IconButton, Menu, MenuItem } from '@mui/material'; import { InfoTooltip } from '@perses-dev/components'; import { replaceVariablesInString, useAllVariableValues, useRouterContext } from '@perses-dev/plugin-system'; import LaunchIcon from 'mdi-material-ui/Launch'; -import { MouseEvent, ReactElement, useState } from 'react'; +import type { MouseEvent, ReactElement } from 'react'; +import { useState } from 'react'; -import { CustomLinks } from '../../gantt-chart-model'; -import { Span } from '../trace'; +import type { CustomLinks } from '../../gantt-chart-model'; +import type { Span } from '../trace'; export interface SpanLinksButtonProps { customLinks: CustomLinks; diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanName.test.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanName.test.tsx index c6c98f514..32361e18d 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanName.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanName.test.tsx @@ -11,14 +11,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { screen } from '@testing-library/dom'; -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import * as exampleTrace from '../../test/traces/example_otlp.json'; import { getTraceModel } from '../trace'; import { GanttTableProvider } from './GanttTableProvider'; -import { SpanName, SpanNameProps } from './SpanName'; +import type { SpanNameProps } from './SpanName'; +import { SpanName } from './SpanName'; describe('SpanName', () => { const trace = getTraceModel(exampleTrace as otlptracev1.TracesData); diff --git a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanName.tsx b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanName.tsx index 6209511d4..30c2c5e85 100644 --- a/tracingganttchart/src/TracingGanttChart/GanttTable/SpanName.tsx +++ b/tracingganttchart/src/TracingGanttChart/GanttTable/SpanName.tsx @@ -13,10 +13,10 @@ import { Box, Stack } from '@mui/material'; import AlertIcon from 'mdi-material-ui/AlertCircleOutline'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { CustomLinks } from '../../gantt-chart-model'; -import { Span } from '../trace'; +import type { CustomLinks } from '../../gantt-chart-model'; +import type { Span } from '../trace'; import { spanHasError } from '../utils'; import { SpanIndents } from './SpanIndents'; import { SpanLinksButton } from './SpanLinksButton'; diff --git a/tracingganttchart/src/TracingGanttChart/MiniGanttChart/Canvas.tsx b/tracingganttchart/src/TracingGanttChart/MiniGanttChart/Canvas.tsx index 85a2ee895..91c38cdc5 100644 --- a/tracingganttchart/src/TracingGanttChart/MiniGanttChart/Canvas.tsx +++ b/tracingganttchart/src/TracingGanttChart/MiniGanttChart/Canvas.tsx @@ -14,13 +14,15 @@ import { Box, styled, useTheme } from '@mui/material'; import { useChartsTheme } from '@perses-dev/components'; import { useEvent } from '@perses-dev/plugin-system'; -import { useEffect, useRef, MouseEvent as ReactMouseEvent, useState, useCallback, ReactElement } from 'react'; +import type { MouseEvent as ReactMouseEvent, ReactElement } from 'react'; +import { useEffect, useRef, useState, useCallback } from 'react'; import useResizeObserver from 'use-resize-observer'; -import { TracingGanttChartOptions } from '../../gantt-chart-model'; +import type { TracingGanttChartOptions } from '../../gantt-chart-model'; import { Ticks } from '../Ticks'; -import { Span, Trace } from '../trace'; -import { getSpanColor, Viewport } from '../utils'; +import type { Span, Trace } from '../trace'; +import type { Viewport } from '../utils'; +import { getSpanColor } from '../utils'; import { drawSpans } from './draw'; const CANVAS_HEIGHT = 60; diff --git a/tracingganttchart/src/TracingGanttChart/MiniGanttChart/MiniGanttChart.tsx b/tracingganttchart/src/TracingGanttChart/MiniGanttChart/MiniGanttChart.tsx index 03c49c8a6..89aa473f4 100644 --- a/tracingganttchart/src/TracingGanttChart/MiniGanttChart/MiniGanttChart.tsx +++ b/tracingganttchart/src/TracingGanttChart/MiniGanttChart/MiniGanttChart.tsx @@ -12,12 +12,13 @@ // limitations under the License. import { Box, useTheme } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { TracingGanttChartOptions } from '../../gantt-chart-model'; +import type { TracingGanttChartOptions } from '../../gantt-chart-model'; import { TicksHeader } from '../Ticks'; -import { Trace } from '../trace'; -import { Viewport, rowHeight } from '../utils'; +import type { Trace } from '../trace'; +import type { Viewport } from '../utils'; +import { rowHeight } from '../utils'; import { Canvas } from './Canvas'; interface MiniGanttChartProps { diff --git a/tracingganttchart/src/TracingGanttChart/MiniGanttChart/draw.ts b/tracingganttchart/src/TracingGanttChart/MiniGanttChart/draw.ts index 851bdddaa..4f3187087 100644 --- a/tracingganttchart/src/TracingGanttChart/MiniGanttChart/draw.ts +++ b/tracingganttchart/src/TracingGanttChart/MiniGanttChart/draw.ts @@ -11,7 +11,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Span, Trace, forEachSpan } from '../trace'; +import type { Span, Trace } from '../trace'; +import { forEachSpan } from '../trace'; import { minSpanWidthPx } from '../utils'; const MIN_BAR_HEIGHT = 1; diff --git a/tracingganttchart/src/TracingGanttChart/Search.test.tsx b/tracingganttchart/src/TracingGanttChart/Search.test.tsx index 7684d4b1c..4055c321d 100644 --- a/tracingganttchart/src/TracingGanttChart/Search.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/Search.test.tsx @@ -12,10 +12,11 @@ // limitations under the License. import { ChartsProvider, testChartsTheme } from '@perses-dev/components'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { fireEvent, screen } from '@testing-library/dom'; -import { render, renderHook, act, RenderResult } from '@testing-library/react'; -import { ReactElement } from 'react'; +import type { RenderResult } from '@testing-library/react'; +import { render, renderHook, act } from '@testing-library/react'; +import type { ReactElement } from 'react'; import * as exampleTrace from '../test/traces/example_otlp.json'; import { SearchBar, useSpanSearch } from './Search'; diff --git a/tracingganttchart/src/TracingGanttChart/Search.tsx b/tracingganttchart/src/TracingGanttChart/Search.tsx index ded8dfb15..42665f2a0 100644 --- a/tracingganttchart/src/TracingGanttChart/Search.tsx +++ b/tracingganttchart/src/TracingGanttChart/Search.tsx @@ -12,14 +12,16 @@ // limitations under the License. import { IconButton, InputAdornment, Stack, TextField } from '@mui/material'; -import * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; +import type * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; import ChevronDown from 'mdi-material-ui/ChevronDown'; import ChevronUp from 'mdi-material-ui/ChevronUp'; import Close from 'mdi-material-ui/Close'; -import { ReactElement, useCallback, useMemo, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback, useMemo, useState } from 'react'; import { renderAttributeValue } from './DetailPane/Attributes'; -import { Span, Trace, forEachSpan } from './trace'; +import type { Span, Trace } from './trace'; +import { forEachSpan } from './trace'; export interface SearchBarProps { search: SpanSearch; diff --git a/tracingganttchart/src/TracingGanttChart/Ticks.test.tsx b/tracingganttchart/src/TracingGanttChart/Ticks.test.tsx index a68f17d98..8c5bd01c3 100644 --- a/tracingganttchart/src/TracingGanttChart/Ticks.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/Ticks.test.tsx @@ -11,12 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { screen } from '@testing-library/dom'; -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import * as otlpTrace from '../test/traces/example_otlp.json'; -import { TicksHeader, TicksHeaderProps } from './Ticks'; +import type { TicksHeaderProps } from './Ticks'; +import { TicksHeader } from './Ticks'; import { getTraceModel } from './trace'; describe('Ticks', () => { diff --git a/tracingganttchart/src/TracingGanttChart/Ticks.tsx b/tracingganttchart/src/TracingGanttChart/Ticks.tsx index 9cd893fe6..b4cd5a274 100644 --- a/tracingganttchart/src/TracingGanttChart/Ticks.tsx +++ b/tracingganttchart/src/TracingGanttChart/Ticks.tsx @@ -12,10 +12,11 @@ // limitations under the License. import { Box, styled } from '@mui/material'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { Trace } from './trace'; -import { Viewport, formatDuration } from './utils'; +import type { Trace } from './trace'; +import type { Viewport } from './utils'; +import { formatDuration } from './utils'; export interface TicksHeaderProps { trace: Trace; diff --git a/tracingganttchart/src/TracingGanttChart/TraceHeaderBar.test.tsx b/tracingganttchart/src/TracingGanttChart/TraceHeaderBar.test.tsx index 9fbc6899b..79ae4a1fb 100644 --- a/tracingganttchart/src/TracingGanttChart/TraceHeaderBar.test.tsx +++ b/tracingganttchart/src/TracingGanttChart/TraceHeaderBar.test.tsx @@ -11,15 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { screen } from '@testing-library/dom'; -import { render, RenderResult } from '@testing-library/react'; +import type { RenderResult } from '@testing-library/react'; +import { render } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; import * as exampleTrace from '../test/traces/example_otlp.json'; -import { SpanSearch } from './Search'; +import type { SpanSearch } from './Search'; import { getTraceModel } from './trace'; -import { TraceHeaderBar, TraceHeaderBarProps } from './TraceHeaderBar'; +import type { TraceHeaderBarProps } from './TraceHeaderBar'; +import { TraceHeaderBar } from './TraceHeaderBar'; describe('TraceHeaderBar', () => { const trace = getTraceModel(exampleTrace as otlptracev1.TracesData); diff --git a/tracingganttchart/src/TracingGanttChart/TraceHeaderBar.tsx b/tracingganttchart/src/TracingGanttChart/TraceHeaderBar.tsx index 911133f4e..e71d0918e 100644 --- a/tracingganttchart/src/TracingGanttChart/TraceHeaderBar.tsx +++ b/tracingganttchart/src/TracingGanttChart/TraceHeaderBar.tsx @@ -14,10 +14,12 @@ import { IconButton, Stack, Tooltip, Typography } from '@mui/material'; import { useTimeZone } from '@perses-dev/components'; import MagnifyIcon from 'mdi-material-ui/Magnify'; -import { ReactElement, useMemo, useState } from 'react'; +import type { ReactElement } from 'react'; +import { useMemo, useState } from 'react'; -import { SearchBar, SpanSearch } from './Search'; -import { Trace } from './trace'; +import type { SpanSearch } from './Search'; +import { SearchBar } from './Search'; +import type { Trace } from './trace'; import { formatDuration } from './utils'; const DATE_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = { diff --git a/tracingganttchart/src/TracingGanttChart/TracingGanttChart.tsx b/tracingganttchart/src/TracingGanttChart/TracingGanttChart.tsx index 9fee5041c..f85a2b89b 100644 --- a/tracingganttchart/src/TracingGanttChart/TracingGanttChart.tsx +++ b/tracingganttchart/src/TracingGanttChart/TracingGanttChart.tsx @@ -12,19 +12,21 @@ // limitations under the License. import { Box, Stack } from '@mui/material'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; -import { ReactElement, useMemo, useRef, useState } from 'react'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type { ReactElement } from 'react'; +import { useMemo, useRef, useState } from 'react'; -import { CustomLinks, TracingGanttChartOptions } from '../gantt-chart-model'; +import type { CustomLinks, TracingGanttChartOptions } from '../gantt-chart-model'; import { DetailPane } from './DetailPane/DetailPane'; import { GanttTable } from './GanttTable/GanttTable'; import { GanttTableProvider } from './GanttTable/GanttTableProvider'; import { ResizableDivider } from './GanttTable/ResizableDivider'; import { MiniGanttChart } from './MiniGanttChart/MiniGanttChart'; import { useSpanSearch } from './Search'; -import { getTraceModel, Span } from './trace'; +import type { Span } from './trace'; +import { getTraceModel } from './trace'; import { TraceHeaderBar } from './TraceHeaderBar'; -import { Viewport } from './utils'; +import type { Viewport } from './utils'; export interface TracingGanttChartProps { options: TracingGanttChartOptions; diff --git a/tracingganttchart/src/TracingGanttChart/trace.test.ts b/tracingganttchart/src/TracingGanttChart/trace.test.ts index 930d26208..a0d0d857d 100644 --- a/tracingganttchart/src/TracingGanttChart/trace.test.ts +++ b/tracingganttchart/src/TracingGanttChart/trace.test.ts @@ -11,14 +11,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; -import { JaegerTrace, jaegerTraceToOTLP } from '../test/convert/jaeger'; +import type { JaegerTrace } from '../test/convert/jaeger'; +import { jaegerTraceToOTLP } from '../test/convert/jaeger'; import * as asyncTrace from '../test/traces/async_jaeger.json'; import * as exampleTrace from '../test/traces/example_otlp.json'; import * as incompleteTrace from '../test/traces/pushbytes_incomplete_otlp.json'; import * as missingRootSpanTrace from '../test/traces/pushbytes_no_root_span_otlp.json'; -import { forEachSpan, getTraceModel, Span } from './trace'; +import type { Span } from './trace'; +import { forEachSpan, getTraceModel } from './trace'; describe('trace', () => { it('computes a GanttTrace model from a trace', (): void => { diff --git a/tracingganttchart/src/TracingGanttChart/trace.ts b/tracingganttchart/src/TracingGanttChart/trace.ts index 146d368dc..36b95cd2f 100644 --- a/tracingganttchart/src/TracingGanttChart/trace.ts +++ b/tracingganttchart/src/TracingGanttChart/trace.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; -import * as otlpresourcev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/resource/v1/resource'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; +import type * as otlpresourcev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/resource/v1/resource'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { sortedIndexBy } from 'lodash'; /** holds the trace and computed properties required for the Gantt chart */ diff --git a/tracingganttchart/src/TracingGanttChart/utils.ts b/tracingganttchart/src/TracingGanttChart/utils.ts index 7e21cb9a1..fd0b9ab0f 100644 --- a/tracingganttchart/src/TracingGanttChart/utils.ts +++ b/tracingganttchart/src/TracingGanttChart/utils.ts @@ -11,12 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Theme } from '@mui/material'; -import { PersesChartsTheme } from '@perses-dev/components'; +import type { Theme } from '@mui/material'; +import type { PersesChartsTheme } from '@perses-dev/components'; import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; import { getConsistentCategoricalColor, getConsistentColor } from './palette'; -import { Span } from './trace'; +import type { Span } from './trace'; /** * Viewport contains the current zoom, i.e. which timeframe of the trace should be visible diff --git a/tracingganttchart/src/TracingGanttChartPanel.tsx b/tracingganttchart/src/TracingGanttChartPanel.tsx index 68a744b3e..3aee51ec6 100644 --- a/tracingganttchart/src/TracingGanttChartPanel.tsx +++ b/tracingganttchart/src/TracingGanttChartPanel.tsx @@ -13,11 +13,11 @@ import { Box } from '@mui/material'; import { NoDataOverlay, TextOverlay, useChartsTheme } from '@perses-dev/components'; -import { PanelProps } from '@perses-dev/plugin-system'; -import { TraceData } from '@perses-dev/spec'; -import { ReactElement } from 'react'; +import type { PanelProps } from '@perses-dev/plugin-system'; +import type { TraceData } from '@perses-dev/spec'; +import type { ReactElement } from 'react'; -import { CustomLinks, TracingGanttChartOptions } from './gantt-chart-model'; +import type { CustomLinks, TracingGanttChartOptions } from './gantt-chart-model'; import { TracingGanttChart } from './TracingGanttChart/TracingGanttChart'; export type TracingGanttChartPanelProps = PanelProps; diff --git a/tracingganttchart/src/getPluginModule.ts b/tracingganttchart/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/tracingganttchart/src/getPluginModule.ts +++ b/tracingganttchart/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/tracingganttchart/src/test/convert/jaeger.ts b/tracingganttchart/src/test/convert/jaeger.ts index e4383a32b..673c9faf3 100644 --- a/tracingganttchart/src/test/convert/jaeger.ts +++ b/tracingganttchart/src/test/convert/jaeger.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; -import * as otlpresourcev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/resource/v1/resource'; -import * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; +import type * as otlpcommonv1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/common/v1/common'; +import type * as otlpresourcev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/resource/v1/resource'; +import type * as otlptracev1 from '@perses-dev/spec/dist/dashboard/query-type/otlp/trace/v1/trace'; // the following Jaeger data types and parsing function should eventually be moved to a Jaeger data source plugin diff --git a/tracingganttchart/tsconfig.build.json b/tracingganttchart/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/tracingganttchart/tsconfig.build.json +++ b/tracingganttchart/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/tracingganttchart/tsconfig.json b/tracingganttchart/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/tracingganttchart/tsconfig.json +++ b/tracingganttchart/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/tracingganttchart/vitest.config.ts b/tracingganttchart/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/tracingganttchart/vitest.config.ts +++ b/tracingganttchart/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/tsconfig.base.json b/tsconfig.base.json index c53929126..95731eb08 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,21 +1,20 @@ { "compilerOptions": { "target": "es2023", - "lib": ["dom", "dom.iterable", "esnext"], + "lib": ["dom", "dom.iterable", "es2023"], "module": "esnext", "jsx": "react-jsx", - "skipLibCheck": true, - "esModuleInterop": true, - "allowSyntheticDefaultImports": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "moduleResolution": "node10", + "moduleResolution": "bundler", "types": ["node", "vitest/globals"], "resolveJsonModule": true, + "esModuleInterop": true, + "verbatimModuleSyntax": true, "isolatedModules": true, + "strict": true, "noUncheckedIndexedAccess": true, - "declaration": true, - "declarationMap": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "noEmit": true, "pretty": true } } diff --git a/victorialogs/package.json b/victorialogs/package.json index 5cb9de00b..fee24e50b 100644 --- a/victorialogs/package.json +++ b/victorialogs/package.json @@ -14,14 +14,14 @@ "dev": "rsbuild dev", "build": "npm run build-mf && concurrently \"npm:build:*\"", "build-mf": "rsbuild build", - "build:cjs": "swc ./src -d dist/lib/cjs --strip-leading-paths --config-file ../.cjs.swcrc", "build:esm": "swc ./src -d dist/lib --strip-leading-paths --config-file ../.swcrc", "build:types": "tsc --project tsconfig.build.json", "lint": "oxlint src", "test": "cross-env LC_ALL=C TZ=UTC vitest run", "type-check": "tsc --noEmit" }, - "main": "lib/cjs/index.js", + "type": "module", + "main": "lib/index.js", "module": "lib/index.js", "types": "lib/index.d.ts", "dependencies": { @@ -32,10 +32,10 @@ "@emotion/styled": "^11.6.0", "@hookform/resolvers": "^3.2.0", "@perses-dev/components": "^0.55.0-beta.3", - "@perses-dev/dashboards": "^0.55.0-beta.3", - "@perses-dev/spec": "^0.3.0-beta.4", - "@perses-dev/explore": "^0.55.0-beta.3", - "@perses-dev/plugin-system": "^0.55.0-beta.3", + "@perses-dev/dashboards": "^0.55.0-beta.6", + "@perses-dev/spec": "^0.3.0-beta.5", + "@perses-dev/explore": "^0.55.0-beta.6", + "@perses-dev/plugin-system": "^0.55.0-beta.6", "@tanstack/react-query": "^4.39.1", "date-fns": "^4.1.0", "date-fns-tz": "^3.2.0", diff --git a/victorialogs/src/components/logsql-editor.tsx b/victorialogs/src/components/logsql-editor.tsx index 65a018183..41bc9c309 100644 --- a/victorialogs/src/components/logsql-editor.tsx +++ b/victorialogs/src/components/logsql-editor.tsx @@ -12,8 +12,10 @@ // limitations under the License. import { useTheme } from '@mui/material'; -import CodeMirror, { EditorView, ReactCodeMirrorProps } from '@uiw/react-codemirror'; -import { ReactElement, useMemo } from 'react'; +import type { ReactCodeMirrorProps } from '@uiw/react-codemirror'; +import CodeMirror, { EditorView } from '@uiw/react-codemirror'; +import type { ReactElement } from 'react'; +import { useMemo } from 'react'; import { LogsQLExtension } from './logsql-extension'; diff --git a/victorialogs/src/components/logsql-extension.ts b/victorialogs/src/components/logsql-extension.ts index 89ec87308..c2809fc1a 100644 --- a/victorialogs/src/components/logsql-extension.ts +++ b/victorialogs/src/components/logsql-extension.ts @@ -13,7 +13,7 @@ import { LRLanguage } from '@codemirror/language'; import { parser } from '@grafana/lezer-logql'; -import { Extension } from '@uiw/react-codemirror'; +import type { Extension } from '@uiw/react-codemirror'; import { logsqlHighlight } from './logsql-highlight'; diff --git a/victorialogs/src/datasources/victorialogs-datasource/VictoriaLogsDatasource.tsx b/victorialogs/src/datasources/victorialogs-datasource/VictoriaLogsDatasource.tsx index 67caa4cc0..e4c2f8473 100644 --- a/victorialogs/src/datasources/victorialogs-datasource/VictoriaLogsDatasource.tsx +++ b/victorialogs/src/datasources/victorialogs-datasource/VictoriaLogsDatasource.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourcePlugin } from '@perses-dev/plugin-system'; +import type { DatasourcePlugin } from '@perses-dev/plugin-system'; -import { VictoriaLogsClient, streamQueryRange, statsQueryRange, fieldNames, fieldValues } from '../../model/client'; -import { VictoriaLogsDatasourceSpec } from './types'; +import type { VictoriaLogsClient } from '../../model/client'; +import { streamQueryRange, statsQueryRange, fieldNames, fieldValues } from '../../model/client'; +import type { VictoriaLogsDatasourceSpec } from './types'; import { VictoriaLogsDatasourceEditor } from './VictoriaLogsDatasourceEditor'; const createClient: DatasourcePlugin['createClient'] = ( diff --git a/victorialogs/src/datasources/victorialogs-datasource/VictoriaLogsDatasourceEditor.tsx b/victorialogs/src/datasources/victorialogs-datasource/VictoriaLogsDatasourceEditor.tsx index c29b6a198..c0a372f16 100644 --- a/victorialogs/src/datasources/victorialogs-datasource/VictoriaLogsDatasourceEditor.tsx +++ b/victorialogs/src/datasources/victorialogs-datasource/VictoriaLogsDatasourceEditor.tsx @@ -12,9 +12,9 @@ // limitations under the License. import { HTTPSettingsEditor } from '@perses-dev/plugin-system'; -import { ReactElement } from 'react'; +import type { ReactElement } from 'react'; -import { VictoriaLogsDatasourceSpec } from './types'; +import type { VictoriaLogsDatasourceSpec } from './types'; export interface VictoriaLogsDatasourceEditorProps { value: VictoriaLogsDatasourceSpec; diff --git a/victorialogs/src/datasources/victorialogs-datasource/types.ts b/victorialogs/src/datasources/victorialogs-datasource/types.ts index b27e21b85..617fcfb03 100644 --- a/victorialogs/src/datasources/victorialogs-datasource/types.ts +++ b/victorialogs/src/datasources/victorialogs-datasource/types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { HTTPProxy } from '@perses-dev/spec'; +import type { HTTPProxy } from '@perses-dev/spec'; export interface VictoriaLogsDatasourceSpec { directUrl?: string; diff --git a/victorialogs/src/getPluginModule.ts b/victorialogs/src/getPluginModule.ts index 5e96075ae..126c97418 100644 --- a/victorialogs/src/getPluginModule.ts +++ b/victorialogs/src/getPluginModule.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; +import type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system'; -import packageJson from '../package.json'; +import packageJson from '../package.json' with { type: 'json' }; /** * Returns the plugin module information from package.json diff --git a/victorialogs/src/model/client.ts b/victorialogs/src/model/client.ts index 8134d2d1c..cfec44c35 100644 --- a/victorialogs/src/model/client.ts +++ b/victorialogs/src/model/client.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { +import type { VictoriaLogsStreamQueryRangeResponse, VictoriaLogsStatsQueryRangeResponse, VictoriaLogsFieldNamesResponse, diff --git a/victorialogs/src/model/selectors.ts b/victorialogs/src/model/selectors.ts index c72237b68..ddfe9fea4 100644 --- a/victorialogs/src/model/selectors.ts +++ b/victorialogs/src/model/selectors.ts @@ -11,8 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue, isVariableDatasource } from '@perses-dev/plugin-system'; -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import { isVariableDatasource } from '@perses-dev/plugin-system'; +import type { DatasourceSelector } from '@perses-dev/spec'; export const VICTORIALOGS_DATASOURCE_KIND = 'VictoriaLogsDatasource' as const; diff --git a/victorialogs/src/queries/victorialogs-log-query/VictoriaLogsLogQuery.tsx b/victorialogs/src/queries/victorialogs-log-query/VictoriaLogsLogQuery.tsx index 973ecf757..9f586b874 100644 --- a/victorialogs/src/queries/victorialogs-log-query/VictoriaLogsLogQuery.tsx +++ b/victorialogs/src/queries/victorialogs-log-query/VictoriaLogsLogQuery.tsx @@ -11,11 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogQueryPlugin, LogQueryContext, calculateVolumeInterval, parseVariables } from '@perses-dev/plugin-system'; -import { QueryDefinition } from '@perses-dev/spec'; +import type { LogQueryPlugin, LogQueryContext } from '@perses-dev/plugin-system'; +import { calculateVolumeInterval, parseVariables } from '@perses-dev/plugin-system'; +import type { QueryDefinition } from '@perses-dev/spec'; import { getVictoriaLogsLogData } from './query'; -import { VictoriaLogsLogQuerySpec } from './types'; +import type { VictoriaLogsLogQuerySpec } from './types'; import { VictoriaLogsLogQueryEditor } from './VictoriaLogsLogQueryEditor'; export const VictoriaLogsLogQuery: LogQueryPlugin = { diff --git a/victorialogs/src/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.tsx b/victorialogs/src/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.tsx index 56ad347ec..2c2451cfd 100644 --- a/victorialogs/src/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.tsx +++ b/victorialogs/src/queries/victorialogs-log-query/VictoriaLogsLogQueryEditor.tsx @@ -13,19 +13,16 @@ import { InputLabel, Stack } from '@mui/material'; import { createModEnterHandler } from '@perses-dev/dashboards'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; -import { ReactElement, useCallback, useState, useEffect } from 'react'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; +import { useCallback, useState, useEffect } from 'react'; import { LogsQLEditor } from '../../components/logsql-editor'; -import { VICTORIALOGS_DATASOURCE_KIND, VictoriaLogsDatasourceSelector } from '../../model'; +import type { VictoriaLogsDatasourceSelector } from '../../model'; +import { VICTORIALOGS_DATASOURCE_KIND } from '../../model'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; -import { VictoriaLogsLogQuerySpec } from './types'; +import type { VictoriaLogsLogQuerySpec } from './types'; type VictoriaLogsQueryEditorProps = OptionsEditorProps; diff --git a/victorialogs/src/queries/victorialogs-log-query/query.ts b/victorialogs/src/queries/victorialogs-log-query/query.ts index 2d802bb36..1629bb1fb 100644 --- a/victorialogs/src/queries/victorialogs-log-query/query.ts +++ b/victorialogs/src/queries/victorialogs-log-query/query.ts @@ -11,13 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { replaceVariables, LogQueryPlugin, LogQueryContext } from '@perses-dev/plugin-system'; -import { LogData, LogEntry } from '@perses-dev/spec'; +import type { LogQueryPlugin, LogQueryContext } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { LogData, LogEntry } from '@perses-dev/spec'; -import { VictoriaLogsClient } from '../../model/client'; -import { VictoriaLogsStreamQueryRangeResponse } from '../../model/types'; +import type { VictoriaLogsClient } from '../../model/client'; +import type { VictoriaLogsStreamQueryRangeResponse } from '../../model/types'; import { DEFAULT_DATASOURCE } from '../constants'; -import { VictoriaLogsLogQuerySpec } from './types'; +import type { VictoriaLogsLogQuerySpec } from './types'; function convertStreamToLogs(data: VictoriaLogsStreamQueryRangeResponse, defaultTime: string): LogData { const entries: LogEntry[] = []; diff --git a/victorialogs/src/queries/victorialogs-log-query/types.test.ts b/victorialogs/src/queries/victorialogs-log-query/types.test.ts index 54d2ca8da..615588bc1 100644 --- a/victorialogs/src/queries/victorialogs-log-query/types.test.ts +++ b/victorialogs/src/queries/victorialogs-log-query/types.test.ts @@ -11,12 +11,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { LogQueryContext } from '@perses-dev/plugin-system'; +import type { LogQueryContext } from '@perses-dev/plugin-system'; import type { Mock } from 'vitest'; import { VictoriaLogsDatasource } from '../../datasources/victorialogs-datasource'; -import { VictoriaLogsDatasourceSpec } from '../../datasources/victorialogs-datasource/types'; -import { VictoriaLogsStreamQueryRangeResponse } from '../../model/types'; +import type { VictoriaLogsDatasourceSpec } from '../../datasources/victorialogs-datasource/types'; +import type { VictoriaLogsStreamQueryRangeResponse } from '../../model/types'; import { VictoriaLogsLogQuery } from './VictoriaLogsLogQuery'; const datasource: VictoriaLogsDatasourceSpec = { diff --git a/victorialogs/src/queries/victorialogs-log-query/types.ts b/victorialogs/src/queries/victorialogs-log-query/types.ts index fdefaec85..1424e62ef 100644 --- a/victorialogs/src/queries/victorialogs-log-query/types.ts +++ b/victorialogs/src/queries/victorialogs-log-query/types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export interface VictoriaLogsLogQuerySpec { query: string; diff --git a/victorialogs/src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQuery.tsx b/victorialogs/src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQuery.tsx index 8b0ae86d8..6a8d8918c 100644 --- a/victorialogs/src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQuery.tsx +++ b/victorialogs/src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQuery.tsx @@ -11,10 +11,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, parseVariables } from '@perses-dev/plugin-system'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { parseVariables } from '@perses-dev/plugin-system'; import { getVictoriaLogsTimeSeriesData } from './query'; -import { VictoriaLogsTimeSeriesQuerySpec } from './types'; +import type { VictoriaLogsTimeSeriesQuerySpec } from './types'; import { VictoriaLogsQueryEditor } from './VictoriaLogsTimeSeriesQueryEditor'; export const VictoriaLogsTimeSeriesQuery: TimeSeriesQueryPlugin = { diff --git a/victorialogs/src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.tsx b/victorialogs/src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.tsx index 87dbfbf81..b64c4a53a 100644 --- a/victorialogs/src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.tsx +++ b/victorialogs/src/queries/victorialogs-time-series-query/VictoriaLogsTimeSeriesQueryEditor.tsx @@ -13,19 +13,16 @@ import { InputLabel, Stack } from '@mui/material'; import { createModEnterHandler } from '@perses-dev/dashboards'; -import { - DatasourceSelect, - DatasourceSelectProps, - isVariableDatasource, - OptionsEditorProps, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; -import { ReactElement, useCallback, useState, useEffect } from 'react'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; +import type { ReactElement } from 'react'; +import { useCallback, useState, useEffect } from 'react'; import { LogsQLEditor } from '../../components/logsql-editor'; -import { VICTORIALOGS_DATASOURCE_KIND, VictoriaLogsDatasourceSelector } from '../../model'; +import type { VictoriaLogsDatasourceSelector } from '../../model'; +import { VICTORIALOGS_DATASOURCE_KIND } from '../../model'; import { DATASOURCE_KIND, DEFAULT_DATASOURCE } from '../constants'; -import { VictoriaLogsTimeSeriesQuerySpec } from './types'; +import type { VictoriaLogsTimeSeriesQuerySpec } from './types'; type VictoriaLogsQueryEditorProps = OptionsEditorProps; diff --git a/victorialogs/src/queries/victorialogs-time-series-query/query.ts b/victorialogs/src/queries/victorialogs-time-series-query/query.ts index 741555e10..fd42deee4 100644 --- a/victorialogs/src/queries/victorialogs-time-series-query/query.ts +++ b/victorialogs/src/queries/victorialogs-time-series-query/query.ts @@ -11,14 +11,16 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { TimeSeriesQueryPlugin, replaceVariables } from '@perses-dev/plugin-system'; -import { DurationString, parseDurationString, TimeSeries } from '@perses-dev/spec'; +import type { TimeSeriesQueryPlugin } from '@perses-dev/plugin-system'; +import { replaceVariables } from '@perses-dev/plugin-system'; +import type { DurationString, TimeSeries } from '@perses-dev/spec'; +import { parseDurationString } from '@perses-dev/spec'; import { milliseconds } from 'date-fns'; -import { VictoriaLogsClient } from '../../model/client'; -import { VictoriaLogsStatsQueryRangeResponse } from '../../model/types'; +import type { VictoriaLogsClient } from '../../model/client'; +import type { VictoriaLogsStatsQueryRangeResponse } from '../../model/types'; import { DEFAULT_DATASOURCE } from '../constants'; -import { VictoriaLogsTimeSeriesQuerySpec } from './types'; +import type { VictoriaLogsTimeSeriesQuerySpec } from './types'; export type VictoriaLogsMatrixResult = { metric: Record; diff --git a/victorialogs/src/queries/victorialogs-time-series-query/types.test.ts b/victorialogs/src/queries/victorialogs-time-series-query/types.test.ts index b494cb419..1ad187958 100644 --- a/victorialogs/src/queries/victorialogs-time-series-query/types.test.ts +++ b/victorialogs/src/queries/victorialogs-time-series-query/types.test.ts @@ -13,13 +13,13 @@ vi.mock('echarts/core'); -import { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; -import { DatasourceSpec } from '@perses-dev/spec'; +import type { TimeSeriesQueryContext } from '@perses-dev/plugin-system'; +import type { DatasourceSpec } from '@perses-dev/spec'; import type { Mock } from 'vitest'; import { VictoriaLogsDatasource } from '../../datasources/victorialogs-datasource'; -import { VictoriaLogsDatasourceSpec } from '../../datasources/victorialogs-datasource/types'; -import { VictoriaLogsStatsQueryRangeResponse } from '../../model/types'; +import type { VictoriaLogsDatasourceSpec } from '../../datasources/victorialogs-datasource/types'; +import type { VictoriaLogsStatsQueryRangeResponse } from '../../model/types'; import { VictoriaLogsTimeSeriesQuery } from './VictoriaLogsTimeSeriesQuery'; const datasource: VictoriaLogsDatasourceSpec = { diff --git a/victorialogs/src/queries/victorialogs-time-series-query/types.ts b/victorialogs/src/queries/victorialogs-time-series-query/types.ts index 9a6e72cd6..ce625416a 100644 --- a/victorialogs/src/queries/victorialogs-time-series-query/types.ts +++ b/victorialogs/src/queries/victorialogs-time-series-query/types.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelector } from '@perses-dev/spec'; +import type { DatasourceSelector } from '@perses-dev/spec'; export interface VictoriaLogsTimeSeriesQuerySpec { query: string; diff --git a/victorialogs/src/variables/types.ts b/victorialogs/src/variables/types.ts index 13c815a17..104670bda 100644 --- a/victorialogs/src/variables/types.ts +++ b/victorialogs/src/variables/types.ts @@ -11,9 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { DatasourceSelectValue } from '@perses-dev/plugin-system'; +import type { DatasourceSelectValue } from '@perses-dev/plugin-system'; -import { VictoriaLogsDatasourceSelector } from '../model'; +import type { VictoriaLogsDatasourceSelector } from '../model'; export interface VictoriaLogsVariableOptionsBase { datasource?: DatasourceSelectValue; diff --git a/victorialogs/src/variables/utils.ts b/victorialogs/src/variables/utils.ts index 74ed926d0..3c236b1e5 100644 --- a/victorialogs/src/variables/utils.ts +++ b/victorialogs/src/variables/utils.ts @@ -11,12 +11,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { StatusError } from '@perses-dev/client'; -import { VariableOption, useDatasourceClient, useTimeRange } from '@perses-dev/plugin-system'; -import { AbsoluteTimeRange, DatasourceSelector } from '@perses-dev/spec'; -import { useQuery, UseQueryResult } from '@tanstack/react-query'; +import type { StatusError } from '@perses-dev/client'; +import type { VariableOption } from '@perses-dev/plugin-system'; +import { useDatasourceClient, useTimeRange } from '@perses-dev/plugin-system'; +import type { AbsoluteTimeRange, DatasourceSelector } from '@perses-dev/spec'; +import type { UseQueryResult } from '@tanstack/react-query'; +import { useQuery } from '@tanstack/react-query'; -import { +import type { VictoriaLogsClient, VictoriaLogsFieldItem, VictoriaLogsFieldNamesResponse, diff --git a/victorialogs/src/variables/victorialogs-field-names/VictoriaLogsFieldNamesVariable.tsx b/victorialogs/src/variables/victorialogs-field-names/VictoriaLogsFieldNamesVariable.tsx index 8753a921a..581d1f305 100644 --- a/victorialogs/src/variables/victorialogs-field-names/VictoriaLogsFieldNamesVariable.tsx +++ b/victorialogs/src/variables/victorialogs-field-names/VictoriaLogsFieldNamesVariable.tsx @@ -11,17 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { VariablePlugin, GetVariableOptionsContext } from '@perses-dev/plugin-system'; import { - VariablePlugin, - GetVariableOptionsContext, replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource, } from '@perses-dev/plugin-system'; -import { VictoriaLogsClient, DEFAULT_VICTORIALOGS, VICTORIALOGS_DATASOURCE_KIND } from '../../model'; -import { VictoriaLogsFieldNamesVariableOptions } from '../types'; +import type { VictoriaLogsClient } from '../../model'; +import { DEFAULT_VICTORIALOGS, VICTORIALOGS_DATASOURCE_KIND } from '../../model'; +import type { VictoriaLogsFieldNamesVariableOptions } from '../types'; import { fieldItemsToVariableOptions, getVictoriaLogsTimeRange } from '../utils'; import { VictoriaLogsFieldNamesVariableEditor } from './VictoriaLogsFieldNamesVariableEditor'; diff --git a/victorialogs/src/variables/victorialogs-field-names/VictoriaLogsFieldNamesVariableEditor.tsx b/victorialogs/src/variables/victorialogs-field-names/VictoriaLogsFieldNamesVariableEditor.tsx index f4e4afb0e..f4f71bc25 100644 --- a/victorialogs/src/variables/victorialogs-field-names/VictoriaLogsFieldNamesVariableEditor.tsx +++ b/victorialogs/src/variables/victorialogs-field-names/VictoriaLogsFieldNamesVariableEditor.tsx @@ -11,24 +11,20 @@ // See the License for the specific language governing permissions and // limitations under the License. import { FormControl, Stack, TextField } from '@mui/material'; -import { - DatasourceSelect, - DatasourceSelectProps, - OptionsEditorProps, - isVariableDatasource, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback } from 'react'; +import type { ReactElement } from 'react'; +import { useCallback } from 'react'; +import type { VictoriaLogsDatasourceSelector } from '../../model'; import { DEFAULT_VICTORIALOGS, isDefaultVictoriaLogsSelector, isVictoriaLogsDatasourceSelector, VICTORIALOGS_DATASOURCE_KIND, - VictoriaLogsDatasourceSelector, } from '../../model'; -import { VictoriaLogsFieldNamesVariableOptions } from '../types'; +import type { VictoriaLogsFieldNamesVariableOptions } from '../types'; export function VictoriaLogsFieldNamesVariableEditor( props: OptionsEditorProps, diff --git a/victorialogs/src/variables/victorialogs-field-values/VictoriaLogsFieldValuesVariable.tsx b/victorialogs/src/variables/victorialogs-field-values/VictoriaLogsFieldValuesVariable.tsx index d4763c2a7..cc6da2dbd 100644 --- a/victorialogs/src/variables/victorialogs-field-values/VictoriaLogsFieldValuesVariable.tsx +++ b/victorialogs/src/variables/victorialogs-field-values/VictoriaLogsFieldValuesVariable.tsx @@ -11,17 +11,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +import type { VariablePlugin, GetVariableOptionsContext } from '@perses-dev/plugin-system'; import { - VariablePlugin, - GetVariableOptionsContext, replaceVariables, parseVariables, datasourceSelectValueToSelector, isVariableDatasource, } from '@perses-dev/plugin-system'; -import { VictoriaLogsClient, DEFAULT_VICTORIALOGS, VICTORIALOGS_DATASOURCE_KIND } from '../../model'; -import { VictoriaLogsFieldValuesVariableOptions } from '../types'; +import type { VictoriaLogsClient } from '../../model'; +import { DEFAULT_VICTORIALOGS, VICTORIALOGS_DATASOURCE_KIND } from '../../model'; +import type { VictoriaLogsFieldValuesVariableOptions } from '../types'; import { fieldItemsToVariableOptions, getVictoriaLogsTimeRange } from '../utils'; import { VictoriaLogsFieldValuesVariableEditor } from './VictoriaLogsFieldValuesVariableEditor'; diff --git a/victorialogs/src/variables/victorialogs-field-values/VictoriaLogsFieldValuesVariableEditor.tsx b/victorialogs/src/variables/victorialogs-field-values/VictoriaLogsFieldValuesVariableEditor.tsx index 38eb863a9..35655a444 100644 --- a/victorialogs/src/variables/victorialogs-field-values/VictoriaLogsFieldValuesVariableEditor.tsx +++ b/victorialogs/src/variables/victorialogs-field-values/VictoriaLogsFieldValuesVariableEditor.tsx @@ -11,24 +11,20 @@ // See the License for the specific language governing permissions and // limitations under the License. import { FormControl, Stack, TextField, Autocomplete } from '@mui/material'; -import { - DatasourceSelect, - DatasourceSelectProps, - OptionsEditorProps, - isVariableDatasource, - useDatasourceSelectValueToSelector, -} from '@perses-dev/plugin-system'; +import type { DatasourceSelectProps, OptionsEditorProps } from '@perses-dev/plugin-system'; +import { DatasourceSelect, isVariableDatasource, useDatasourceSelectValueToSelector } from '@perses-dev/plugin-system'; import { produce } from 'immer'; -import { ReactElement, useCallback, useMemo, SyntheticEvent } from 'react'; +import type { ReactElement, SyntheticEvent } from 'react'; +import { useCallback, useMemo } from 'react'; +import type { VictoriaLogsDatasourceSelector } from '../../model'; import { DEFAULT_VICTORIALOGS, isDefaultVictoriaLogsSelector, isVictoriaLogsDatasourceSelector, VICTORIALOGS_DATASOURCE_KIND, - VictoriaLogsDatasourceSelector, } from '../../model'; -import { VictoriaLogsFieldValuesVariableOptions } from '../types'; +import type { VictoriaLogsFieldValuesVariableOptions } from '../types'; import { useFieldNames } from '../utils'; export function VictoriaLogsFieldValuesVariableEditor( diff --git a/victorialogs/tsconfig.build.json b/victorialogs/tsconfig.build.json index fc0aafe27..53608cda3 100644 --- a/victorialogs/tsconfig.build.json +++ b/victorialogs/tsconfig.build.json @@ -2,8 +2,12 @@ "extends": "./tsconfig.json", "exclude": ["**/*.stories.*", "**/*.test.*", "**/*.map"], "compilerOptions": { + "noEmit": false, + "outDir": "./dist/lib", + "rootDir": "./src", "emitDeclarationOnly": true, "declaration": true, + "declarationMap": true, "preserveWatchOutput": true } } diff --git a/victorialogs/tsconfig.json b/victorialogs/tsconfig.json index 98221344c..4bd6962d4 100644 --- a/victorialogs/tsconfig.json +++ b/victorialogs/tsconfig.json @@ -1,8 +1,4 @@ { "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "./dist/lib", - "rootDir": "./src" - }, "include": ["src"] } diff --git a/victorialogs/vitest.config.ts b/victorialogs/vitest.config.ts index 59830b049..19928bdd5 100644 --- a/victorialogs/vitest.config.ts +++ b/victorialogs/vitest.config.ts @@ -11,11 +11,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { resolve } from 'node:path'; - -import { definePackageVitestConfig } from '../vitest.shared'; +import { definePackageVitestConfig } from '../vitest.shared.ts'; export default definePackageVitestConfig({ - packageDir: resolve(__dirname), + packageDir: import.meta.dirname, setupFiles: ['src/setup-tests.ts'], }); diff --git a/vitest.shared.ts b/vitest.shared.ts index d378bdcd1..fd58ce49a 100644 --- a/vitest.shared.ts +++ b/vitest.shared.ts @@ -21,7 +21,7 @@ type VitestPackageOptions = { passWithNoTests?: boolean; }; -const repoRoot = resolve(__dirname); +const repoRoot = import.meta.dirname; // Common Vitest configuration shared across packages const sharedConfig = defineConfig({ @@ -38,6 +38,11 @@ const sharedConfig = defineConfig({ environment: 'jsdom', globals: true, include: ['src/**/*.test.{ts,tsx,js,jsx}', 'src/**/*.spec.{ts,tsx,js,jsx}'], + server: { + deps: { + inline: [/@perses-dev\/(components|dashboards|plugin-system)/], + }, + }, setupFiles: [resolve(repoRoot, 'vitest.setup.ts')], testTimeout: 15_000, },