@qodalis/console-kit 0.0.0-stage → 1.0.0-beta.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +251 -2
  2. package/dist/components/Badge.d.ts +14 -0
  3. package/dist/components/ButtonGroup.d.ts +35 -0
  4. package/dist/components/ChipList.d.ts +53 -0
  5. package/dist/components/ConfirmDialog.d.ts +28 -0
  6. package/dist/components/DataTable.d.ts +29 -0
  7. package/dist/components/DropdownMenu.d.ts +32 -0
  8. package/dist/components/ErrorBoundary.d.ts +29 -0
  9. package/dist/components/Modal.d.ts +30 -0
  10. package/dist/components/MonoPanel.d.ts +9 -0
  11. package/dist/components/PageHeader.d.ts +7 -0
  12. package/dist/components/Pagination.d.ts +11 -0
  13. package/dist/components/Select.d.ts +54 -0
  14. package/dist/components/Skeleton.d.ts +66 -0
  15. package/dist/components/Spinner.d.ts +9 -0
  16. package/dist/components/StatCard.d.ts +9 -0
  17. package/dist/components/States.d.ts +33 -0
  18. package/dist/components/Tooltip.d.ts +24 -0
  19. package/dist/components/actionIcons.d.ts +6 -0
  20. package/dist/components/charts/ColumnChart.d.ts +37 -0
  21. package/dist/components/charts/LineChart.d.ts +28 -0
  22. package/dist/components/charts/chartParts.d.ts +31 -0
  23. package/dist/components/charts/chartUtils.d.ts +14 -0
  24. package/dist/components/componentText.d.ts +3 -0
  25. package/dist/components/drawerGestures.d.ts +15 -0
  26. package/dist/components/errorText.d.ts +31 -0
  27. package/dist/components/overlay.d.ts +51 -0
  28. package/dist/components/paging.d.ts +16 -0
  29. package/dist/components/sortRows.d.ts +10 -0
  30. package/dist/components/useConfirm.d.ts +18 -0
  31. package/dist/extension/ExtensionLink.d.ts +10 -0
  32. package/dist/extension/defineExtension.d.ts +96 -0
  33. package/dist/extension/serverPlugin.d.ts +18 -0
  34. package/dist/extension/serverPluginApi.d.ts +42 -0
  35. package/dist/extension/types.d.ts +247 -0
  36. package/dist/extension/useQueryParams.d.ts +5 -0
  37. package/dist/format.d.ts +4 -0
  38. package/dist/hooks/liveReload.d.ts +28 -0
  39. package/dist/hooks/useAsync.d.ts +10 -0
  40. package/dist/hooks/usePaging.d.ts +10 -0
  41. package/dist/hooks/useStoredState.d.ts +9 -0
  42. package/dist/i18n/locales.d.ts +60 -0
  43. package/dist/i18n/messages.d.ts +3 -0
  44. package/dist/i18n/text.d.ts +21 -0
  45. package/dist/i18n/translations.d.ts +32 -0
  46. package/dist/index.d.ts +64 -0
  47. package/dist/index.js +2735 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/styles.css +1 -0
  50. package/dist/tailwind-preset.js +35 -0
  51. package/dist/tailwind-preset.js.map +1 -0
  52. package/dist/testing.d.ts +35 -0
  53. package/dist/testing.js +70 -0
  54. package/dist/testing.js.map +1 -0
  55. package/dist/theme/tagColors.d.ts +27 -0
  56. package/dist/theme/tailwind-preset.d.ts +46 -0
  57. package/dist/theme/tokens.d.ts +33 -0
  58. package/dist/tokens-3WNFc3gU.js +82 -0
  59. package/dist/tokens-3WNFc3gU.js.map +1 -0
  60. package/package.json +59 -4
@@ -0,0 +1,66 @@
1
+ import type { CSSProperties, ReactNode } from 'react';
2
+ /**
3
+ * Placeholders shaped like the content that is loading, so the reader sees that something will
4
+ * appear (and where) instead of a blank area or a line of text. Every helper is one loading status
5
+ * for assistive technology (role="status", announced politely with a translated label); the bars
6
+ * themselves are hidden from it. The pulse stops under reduced motion.
7
+ */
8
+ /** One placeholder bar or block; size it with classes (`h-4 w-1/2`) or `style`. */
9
+ export declare function Skeleton({ className, style }: {
10
+ className?: string;
11
+ style?: CSSProperties;
12
+ }): import("react/jsx-runtime").JSX.Element;
13
+ /** The loading status around placeholders: announced once, pulsing unless reduced motion is on. */
14
+ export declare function SkeletonGroup({ label, className, children }: {
15
+ label?: string;
16
+ className?: string;
17
+ children: ReactNode;
18
+ }): import("react/jsx-runtime").JSX.Element;
19
+ /** Lines of text; the last one shorter, as a paragraph ends. */
20
+ export declare function SkeletonText({ lines, label, className }: {
21
+ lines?: number;
22
+ label?: string;
23
+ className?: string;
24
+ }): import("react/jsx-runtime").JSX.Element;
25
+ /**
26
+ * Cards shaped like `StatCard` (label, value), in their own wrapping row, or with `inRow` as items of the
27
+ * enclosing row (next to real cards).
28
+ */
29
+ export declare function SkeletonStatCards({ count, label, inRow, className }: {
30
+ count?: number;
31
+ label?: string;
32
+ inRow?: boolean;
33
+ className?: string;
34
+ }): import("react/jsx-runtime").JSX.Element;
35
+ /** One card shaped like `StatCard`, to sit in a row of real cards. */
36
+ export declare function SkeletonStatCard({ label, className }: {
37
+ label?: string;
38
+ className?: string;
39
+ }): import("react/jsx-runtime").JSX.Element;
40
+ /** A table shaped like `DataTable`: a header and `rows` rows of `columns` cells. */
41
+ export declare function SkeletonTable({ rows, columns, label, plain, className }: {
42
+ rows?: number;
43
+ columns?: number;
44
+ label?: string;
45
+ /** Without the card (border, background), inside a panel that has them (as `DataTable`'s `plain`). */
46
+ plain?: boolean;
47
+ className?: string;
48
+ }): import("react/jsx-runtime").JSX.Element;
49
+ /** A card shaped like `ChartCard` with a plot area of `height` pixels, so the chart replaces it without a jump. */
50
+ export declare function SkeletonChartCard({ height, label, className }: {
51
+ height?: number;
52
+ label?: string;
53
+ className?: string;
54
+ }): import("react/jsx-runtime").JSX.Element;
55
+ /** A list of `items` rows: a title line and a shorter detail line each. */
56
+ export declare function SkeletonList({ items, label, className }: {
57
+ items?: number;
58
+ label?: string;
59
+ className?: string;
60
+ }): import("react/jsx-runtime").JSX.Element;
61
+ /** A whole page: a header (title, subtitle) and a table, while the page itself is loading. */
62
+ export declare function SkeletonPage({ label, columns, rows }: {
63
+ label?: string;
64
+ columns?: number;
65
+ rows?: number;
66
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A small spinning ring in the current text color. Decorative by default (inside a busy button,
3
+ * next to a label); pass `label` to announce it as a loading status on its own.
4
+ */
5
+ export default function Spinner({ size, label, className }: {
6
+ size?: number;
7
+ label?: string;
8
+ className?: string;
9
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ interface Props {
2
+ label: string;
3
+ value: string | number;
4
+ sub?: string;
5
+ subColor?: string;
6
+ }
7
+ /** A failing card shows an inline error instead of breaking the page */
8
+ export default function StatCard(props: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,33 @@
1
+ import type { ReactNode } from 'react';
2
+ /** Nothing to show (no rows, nothing matches a filter): a quiet centered message, with an optional action. */
3
+ export declare function EmptyState({ message, detail, action, className }: {
4
+ message?: ReactNode;
5
+ detail?: ReactNode;
6
+ action?: ReactNode;
7
+ className?: string;
8
+ }): import("react/jsx-runtime").JSX.Element;
9
+ /**
10
+ * The signed-in user may not open this (the server answered 403): a calm notice, not a failure, naming the missing
11
+ * permission when it is known. ErrorState shows it for refusals by itself.
12
+ */
13
+ export declare function NoAccessState({ permission, title, className }: {
14
+ /** The permission the page needs (`config:read`), when known. */
15
+ permission?: string | null;
16
+ /** Default: "You don't have access to this page". */
17
+ title?: ReactNode;
18
+ className?: string;
19
+ }): import("react/jsx-runtime").JSX.Element;
20
+ /**
21
+ * Something failed to load: what failed (`title`), the reason (`error`) and a Retry button when
22
+ * `onRetry` is given. Announced as an alert. A refusal for lack of permission (403, `forbidden: missing permission
23
+ * …`, `permission denied: …`) is not a failure: a full-size state shows NoAccessState instead, a compact one keeps its
24
+ * title with the missing permission as the reason.
25
+ */
26
+ export declare function ErrorState({ title, error, onRetry, compact, className }: {
27
+ title?: ReactNode;
28
+ error?: unknown;
29
+ onRetry?: () => void;
30
+ /** One line, for a failure inside a card or a panel. */
31
+ compact?: boolean;
32
+ className?: string;
33
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ interface Props {
3
+ /** Rendered only while the tooltip is open, so it can load what it shows on demand. */
4
+ content: () => ReactNode;
5
+ /**
6
+ * The trigger: a focusable element (a link or button), given the tooltip's id for its `aria-describedby` while the
7
+ * tooltip is open. It is wrapped in an inline element that listens for hover, focus and touch.
8
+ */
9
+ children: (describedBy: string | undefined) => ReactElement;
10
+ /** Classes of the wrapping element (e.g. its hit area). */
11
+ className?: string;
12
+ /** Milliseconds the pointer rests on the trigger before the tooltip opens (keyboard focus opens it at once). */
13
+ openDelay?: number;
14
+ /** Milliseconds a finger rests on the trigger to open it on touch screens (the tap that follows is not a click). */
15
+ longPress?: number;
16
+ }
17
+ /**
18
+ * A styled tooltip for a trigger: opens on hover (after `openDelay`), keyboard focus or a long press; closes when the
19
+ * pointer leaves, focus moves on, on Escape or a tap elsewhere. Placed above the trigger (below when there is no
20
+ * room), kept inside the window and following it when the page scrolls, rendered at the end of the page so tables
21
+ * do not clip it.
22
+ */
23
+ export default function Tooltip({ content, children, className, openDelay, longPress }: Props): import("react/jsx-runtime").JSX.Element;
24
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const DetailsIcon: () => import("react/jsx-runtime").JSX.Element;
2
+ export declare const LogsIcon: () => import("react/jsx-runtime").JSX.Element;
3
+ export declare const RunAgainIcon: () => import("react/jsx-runtime").JSX.Element;
4
+ export declare const DeleteIcon: () => import("react/jsx-runtime").JSX.Element;
5
+ export declare const DownloadIcon: () => import("react/jsx-runtime").JSX.Element;
6
+ export declare const RevokeIcon: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,37 @@
1
+ import { type TooltipRow } from './chartParts';
2
+ export interface ColumnSegment {
3
+ key: string;
4
+ value: number;
5
+ color: string;
6
+ }
7
+ export interface Column {
8
+ key: string;
9
+ /** Stacked bottom to top. */
10
+ segments: ColumnSegment[];
11
+ /** Tooltip heading, e.g. the time range. */
12
+ title: string;
13
+ rows: TooltipRow[];
14
+ /** What a screen reader hears for the column. */
15
+ ariaLabel: string;
16
+ }
17
+ interface Props {
18
+ columns: Column[];
19
+ /** Labels under some columns (by index). */
20
+ xTicks: {
21
+ index: number;
22
+ label: string;
23
+ }[];
24
+ formatValue: (value: number) => string;
25
+ /** Whole-number ticks (counts). */
26
+ integer?: boolean;
27
+ height?: number;
28
+ /** Column picked by click or Enter; the same one again clears it. */
29
+ selectedKey?: string | null;
30
+ onSelect?: (key: string | null) => void;
31
+ /** Data is reloading: the previous render stays, dimmed. */
32
+ stale?: boolean;
33
+ ariaLabel: string;
34
+ }
35
+ /** Columns from one baseline, stacked when a column has several segments; hover or focus shows a tooltip. */
36
+ export default function ColumnChart({ columns, xTicks, formatValue, integer, height, selectedKey, onSelect, stale, ariaLabel, }: Props): import("react/jsx-runtime").JSX.Element;
37
+ export {};
@@ -0,0 +1,28 @@
1
+ export interface LineSeries {
2
+ key: string;
3
+ label: string;
4
+ color: string;
5
+ /** One value per point of `times`; null leaves a gap. */
6
+ values: (number | null)[];
7
+ }
8
+ interface Props {
9
+ /** Point times (ms since the epoch), oldest first. */
10
+ times: number[];
11
+ series: LineSeries[];
12
+ formatValue: (value: number) => string;
13
+ formatTime: (time: number) => string;
14
+ /** Time axis labels. */
15
+ formatTick: (time: number) => string;
16
+ height?: number;
17
+ /** Axis maximum at least this (e.g. 10 for a percentage that stays low). */
18
+ minMax?: number;
19
+ /** Whole-number ticks (counts). */
20
+ integer?: boolean;
21
+ ariaLabel: string;
22
+ }
23
+ /**
24
+ * Lines over time on one axis: 2px lines, a light wash under a single series, a dot at the latest value, and a
25
+ * crosshair that snaps to the nearest point and lists every series there.
26
+ */
27
+ export default function LineChart({ times, series, formatValue, formatTime, formatTick, height, minMax, integer, ariaLabel }: Props): import("react/jsx-runtime").JSX.Element;
28
+ export {};
@@ -0,0 +1,31 @@
1
+ import type { ReactNode } from 'react';
2
+ export interface LegendItem {
3
+ label: string;
4
+ color: string;
5
+ value?: string;
6
+ }
7
+ /** Swatch keys in the mark's shape (a small rounded square for columns), text in text colors. */
8
+ export declare function ChartLegend({ items }: {
9
+ items: LegendItem[];
10
+ }): import("react/jsx-runtime").JSX.Element;
11
+ export interface TooltipRow {
12
+ label: string;
13
+ value: string;
14
+ color?: string;
15
+ }
16
+ /** The hover/focus readout: values lead, labels follow, each row keyed by a short line of the series color. */
17
+ export declare function ChartTooltip({ x, y, width, title, rows }: {
18
+ x: number;
19
+ y: number;
20
+ width: number;
21
+ title: string;
22
+ rows: TooltipRow[];
23
+ }): import("react/jsx-runtime").JSX.Element;
24
+ /** The card a chart sits in: title, optional note and legend, then the plot. */
25
+ export declare function ChartCard({ title, note, legend, actions, children }: {
26
+ title: string;
27
+ note?: ReactNode;
28
+ legend?: ReactNode;
29
+ actions?: ReactNode;
30
+ children: ReactNode;
31
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ /** Width of an element, following resizes (0 until it is laid out). */
2
+ export declare function useElementWidth<T extends HTMLElement>(): readonly [import("react").RefObject<T>, number];
3
+ /**
4
+ * A column from the baseline up: 4px rounded at the data end, square at the baseline. `rounded` false gives a square
5
+ * top (a segment under another one of a stack).
6
+ */
7
+ export declare function columnPath(x: number, y: number, width: number, height: number, rounded?: boolean): string;
8
+ /** A round axis maximum at or above `value`, with its ticks (0 and 1-4 more); `integer` keeps whole steps (counts). */
9
+ export declare function niceScale(value: number, integer?: boolean): {
10
+ max: number;
11
+ ticks: number[];
12
+ };
13
+ /** About `count` evenly spread tick positions over `length` columns, always including the last. */
14
+ export declare function spreadTicks(length: number, count: number): number[];
@@ -0,0 +1,3 @@
1
+ import { type KitTextKey, type KitTextParams } from '../i18n/text';
2
+ /** Built-in texts of the shared components, in the language of the enclosing `KitProvider` (English without one). */
3
+ export declare function useComponentText(): (key: KitTextKey, params?: KitTextParams) => string;
@@ -0,0 +1,15 @@
1
+ export declare function focusableIn(container: HTMLElement | null): HTMLElement[];
2
+ /**
3
+ * Where Tab (or Shift+Tab) should move focus to keep it inside the drawer: from the last element to the first and
4
+ * back, or into the drawer when focus is outside it. Null: let the browser move it.
5
+ */
6
+ export declare function trapFocusTarget(items: readonly HTMLElement[], active: Element | null, backwards: boolean): HTMLElement | null;
7
+ /** Pixels a finger must travel left (and more left than up or down) to close the drawer. */
8
+ export declare const SWIPE_CLOSE_DISTANCE = 60;
9
+ export declare function isSwipeLeft(start: {
10
+ x: number;
11
+ y: number;
12
+ }, end: {
13
+ x: number;
14
+ y: number;
15
+ }): boolean;
@@ -0,0 +1,31 @@
1
+ /** Reason phrases of the error statuses servers and proxies answer without a readable body. */
2
+ export declare const HTTP_REASON_PHRASES: Readonly<Record<number, string>>;
3
+ /** `HTTP 404 Not Found`: a status with its text (the standard phrase when the server sent none, as over HTTP/2). */
4
+ export declare function httpStatusText(status: number, statusText?: string): string;
5
+ /** True for an HTML document or fragment (an Express or proxy error page), never shown raw. */
6
+ export declare function isHtml(text: string): boolean;
7
+ /**
8
+ * The text of an HTML error page: its `<pre>` (Express: "Cannot GET /api/..."), else its `<h1>` or `<title>` (a
9
+ * proxy's "502 Bad Gateway"; a bare "Error" title says nothing); null when it has none.
10
+ */
11
+ export declare function htmlErrorText(html: string): string | null;
12
+ /**
13
+ * The readable message of a failure, never a raw JSON or HTML body: an Error's message or a string is read as the
14
+ * server's JSON error body when it is one (`{"error":"forbidden"}` → `forbidden`), an HTML page as its `<pre>`,
15
+ * `<h1>` or `<title>` text, else `HTTP 404 Not Found` (with the error's `status` and `statusText` when it has them,
16
+ * else `HTTP error`); a plain text as is (a network error's "Failed to fetch"), anything else as text.
17
+ */
18
+ export declare function errorText(error: unknown): string;
19
+ /**
20
+ * The message of a failed response's body, for an `Error`: the JSON body's `error` (or `message`, `detail`, `title`),
21
+ * an HTML page's text, a plain-text body as is; `HTTP 404 Not Found` when the body says nothing.
22
+ */
23
+ export declare function responseErrorText(status: number, statusText: string, body: string): string;
24
+ /**
25
+ * A refusal for lack of permission (HTTP 403), or null for any other failure: an error with `status` 403, or one whose
26
+ * message is a server's refusal (`forbidden…`, `permission denied: …`, `HTTP 403`). `permission` is the permission it
27
+ * names, when it names one (`config:read`, or several separated by commas).
28
+ */
29
+ export declare function accessDenied(error: unknown): {
30
+ permission: string | null;
31
+ } | null;
@@ -0,0 +1,51 @@
1
+ import { type RefObject } from 'react';
2
+ /**
3
+ * The class that scopes an extension's styles: its Tailwind config sets `important: '.qcli-extension'`, so its utility
4
+ * classes apply only inside elements carrying this class and never restyle the Console's own pages. The Console puts
5
+ * it on every element it mounts an extension (or an Overview card) into.
6
+ */
7
+ export declare const EXTENSION_SCOPE = "qcli-extension";
8
+ /** Overlays (modals, menus, selects, tooltips) of this copy of the kit go into a body-level element with this class. */
9
+ export declare function scopeOverlays(className: string | null): void;
10
+ /**
11
+ * Where overlays are rendered: `document.body`, or inside an extension (`defineExtension`) a body-level element carrying
12
+ * the scope class, so the extension's scoped styles apply to its modals and menus too.
13
+ */
14
+ export declare function overlayRoot(): HTMLElement;
15
+ export interface PopoverPosition {
16
+ left: number;
17
+ top: number;
18
+ /** The trigger's width; the popover is at least as wide. */
19
+ minWidth: number;
20
+ /** Room on the chosen side, so a long list scrolls instead of leaving the window. */
21
+ maxHeight: number;
22
+ placement: 'bottom' | 'top';
23
+ }
24
+ /**
25
+ * Where a popover goes: under its trigger, or above it when there is not enough room below and more above; aligned to
26
+ * the trigger's start (or end) and kept inside the window. Measured before paint and again on scroll and resize.
27
+ */
28
+ export declare function usePopoverPosition(open: boolean, trigger: HTMLElement | null, panel: RefObject<HTMLElement | null>, align?: 'start' | 'end'): PopoverPosition | null;
29
+ /**
30
+ * Closes a popover on a press outside its trigger and panel, and (when `onScroll` is given) when the page scrolls
31
+ * under it; a scroll inside the panel itself is its own list scrolling and is ignored.
32
+ */
33
+ export declare function useDismiss(open: boolean, inside: () => (Element | null)[], onOutside: () => void, onScroll?: () => void): void;
34
+ /** Stops the page behind an open dialog from scrolling; nested dialogs share one lock. */
35
+ export declare function useBodyScrollLock(active: boolean): void;
36
+ /** Index of the next enabled item from `from` in direction `step` (wrapping off); `from` itself when none. */
37
+ export declare function nextEnabled(disabled: readonly boolean[], from: number, step: 1 | -1): number;
38
+ export declare function firstEnabled(disabled: readonly boolean[]): number;
39
+ export declare function lastEnabled(disabled: readonly boolean[]): number;
40
+ /**
41
+ * Type-ahead: the typed letters (kept for half a second) jump to the next enabled item whose label starts with them,
42
+ * after the current one; repeating one letter cycles through the items starting with it.
43
+ */
44
+ export declare function useTypeahead(): (key: string, labels: readonly string[], disabled: readonly boolean[], current: number) => number;
45
+ /** A printable key without modifiers (type-ahead), not Space. */
46
+ export declare function isTypeaheadKey(e: {
47
+ key: string;
48
+ ctrlKey: boolean;
49
+ metaKey: boolean;
50
+ altKey: boolean;
51
+ }): boolean;
@@ -0,0 +1,16 @@
1
+ /** Rows per page a reader can pick. */
2
+ export declare const PAGE_SIZES: readonly [20, 50, 100, 200];
3
+ export declare const DEFAULT_PAGE_SIZE: 20;
4
+ /** A stored page size, or null when it is not one of `PAGE_SIZES`. */
5
+ export declare function parsePageSize(value: string): number | null;
6
+ /** Pages needed for `total` rows (at least one, so an empty list still has page 1). */
7
+ export declare function pageCount(total: number, size: number): number;
8
+ /** The page, moved back onto the last one when the rows shrank under it (0-based). */
9
+ export declare function clampPage(page: number, total: number, size: number): number;
10
+ /** The rows a page shows, 1-based for display: `from`–`to` of `total` (0–0 when there are none). */
11
+ export declare function pageRange(page: number, size: number, total: number): {
12
+ from: number;
13
+ to: number;
14
+ };
15
+ /** The rows of a page. */
16
+ export declare function pageSlice<T>(rows: readonly T[], page: number, size: number): T[];
@@ -0,0 +1,10 @@
1
+ export type SortValue = string | number | null | undefined;
2
+ export interface SortState {
3
+ key: string;
4
+ direction: 'asc' | 'desc';
5
+ }
6
+ /**
7
+ * The rows sorted by a value: numbers by size, text by locale (numeric-aware, ignoring case); empty values stay last
8
+ * in either direction, and equal rows keep their order.
9
+ */
10
+ export declare function sortRows<T>(rows: T[], value: (row: T) => SortValue, direction: 'asc' | 'desc'): T[];
@@ -0,0 +1,18 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface ConfirmOptions {
3
+ title: ReactNode;
4
+ message: ReactNode;
5
+ confirmLabel?: string;
6
+ cancelLabel?: string;
7
+ tone?: 'default' | 'danger';
8
+ /** The action, run while the dialog shows its loading state; the dialog closes when it settles without throwing. */
9
+ onConfirm?: () => void | Promise<void>;
10
+ }
11
+ /**
12
+ * `window.confirm` as a dialog: `if (!(await confirm({ title, message }))) return;`, or pass `onConfirm` to run the
13
+ * action inside the dialog. Render `dialog` once in the component.
14
+ */
15
+ export declare function useConfirm(): {
16
+ confirm: (options: ConfirmOptions) => Promise<boolean>;
17
+ dialog: ReactNode;
18
+ };
@@ -0,0 +1,10 @@
1
+ import type { AnchorHTMLAttributes } from 'react';
2
+ /**
3
+ * The Console URL of a path below the extension's page, for an `href` (open in a new tab, copy the link): the
4
+ * current page's URL up to `/x/<id>`, then the path.
5
+ */
6
+ export declare function useExtensionHref(to: string): string;
7
+ /** A link inside the extension: a real `href`, and a plain click navigates (`context.navigate`) without reloading. */
8
+ export declare function ExtensionLink({ to, onClick, ...props }: {
9
+ to: string;
10
+ } & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'href'>): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,96 @@
1
+ import { type ComponentType } from 'react';
2
+ import { type LiveReloadOptions } from '../hooks/liveReload';
3
+ import type { ServerPluginRequirement } from './serverPluginApi';
4
+ import type { ConfigEditorMount, ConfigEditorProps, ConsoleExtension, ConsoleExtensionConfig, ConsoleExtensionContext, ConsoleOverview, OverviewCardSize } from './types';
5
+ /** An Overview card as a React component (rendered with `useConsole()` available). */
6
+ export interface OverviewCardComponent {
7
+ id: string;
8
+ size: OverviewCardSize;
9
+ component: ComponentType;
10
+ }
11
+ export interface ExtensionOptions {
12
+ /** Cards and attention items for the Console's Overview (register the module with `widgets: ["overview"]`). */
13
+ overview?: {
14
+ cards?: OverviewCardComponent[];
15
+ attention?: ConsoleOverview['attention'];
16
+ };
17
+ /** Entries for the command palette (register the module with `widgets: ["palette"]`). */
18
+ palette?: ConsoleExtension['palette'];
19
+ /**
20
+ * Inputs for the Console's Config page by `editor` hint, as React components (register the module with
21
+ * `widgets: ["config"]`). They render with `useConsole()` available and again on every change of their props.
22
+ */
23
+ configEditors?: Record<string, ComponentType<ConfigEditorProps>>;
24
+ /**
25
+ * The server plugin serving the page's API. When the page's first route (`api`) is answered as missing (404
26
+ * without a JSON `{ error }`), the page says the plugin is not installed on this server, with a button opening it
27
+ * in the marketplace's server plugins and the packages to add in code, instead of a failed request.
28
+ */
29
+ serverPlugin?: ServerPluginRequirement;
30
+ }
31
+ /** A React config editor as a {@link ConfigEditorMount}: one root per entry, rendered again on every update. */
32
+ export declare function mountConfigEditor(Editor: ComponentType<ConfigEditorProps>): ConfigEditorMount;
33
+ /**
34
+ * The extension for a React component: mounts a React root holding `App` with the Console's
35
+ * context (`useConsole()`) and the kit's language, and renders again when the theme, the
36
+ * language or the extension's path changes. `options.overview` adds cards to the Console's Overview.
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * export default defineExtension(() => {
41
+ * const { user } = useConsole();
42
+ * return <PageHeader title={`Hello ${user.name}`} />;
43
+ * }, {
44
+ * overview: { cards: [{ id: 'count', size: 'stat', component: CountCard }] },
45
+ * });
46
+ * ```
47
+ */
48
+ export declare function defineExtension(App: ComponentType, options?: ExtensionOptions): ConsoleExtension;
49
+ /** The Console's context inside an extension made with {@link defineExtension}. */
50
+ export declare function useConsole(): ConsoleExtensionContext;
51
+ /** @deprecated Use {@link useConsole} (the same hook, from before the rename to Qodalis Console). */
52
+ export declare const useDashboard: typeof useConsole;
53
+ /**
54
+ * A marketplace plugin's settings (`qodalis.config` of its package.json): the stored values over the defaults, the
55
+ * component rendering again when they change (Config page, `config set`). `undefined` for built-in extensions; `{}`
56
+ * when the Console could not read them, so fall back to your defaults:
57
+ *
58
+ * ```tsx
59
+ * const config = useExtensionConfig<{ refreshSeconds?: number }>();
60
+ * const seconds = config?.refreshSeconds ?? 30;
61
+ * ```
62
+ */
63
+ export declare function useExtensionConfig<T extends object = ConsoleExtensionConfig>(): Partial<T> | undefined;
64
+ /** A failed request: the HTTP status and the server's `error` text (or the status text). */
65
+ export declare class ApiError extends Error {
66
+ readonly status: number;
67
+ readonly error: string;
68
+ readonly body?: unknown;
69
+ constructor(status: number, error: string, body?: unknown);
70
+ }
71
+ /** Options of an {@link ExtensionApi} call. */
72
+ export interface ApiCallOptions {
73
+ /** An optional request: its 401 does not sign the user out. */
74
+ quiet?: boolean;
75
+ }
76
+ export interface ExtensionApi {
77
+ get<T = unknown>(path: string, options?: ApiCallOptions): Promise<T>;
78
+ post<T = unknown>(path: string, body?: unknown): Promise<T>;
79
+ put<T = unknown>(path: string, body?: unknown): Promise<T>;
80
+ patch<T = unknown>(path: string, body?: unknown): Promise<T>;
81
+ del<T = unknown>(path: string): Promise<T>;
82
+ }
83
+ /** JSON helpers over the context's `fetch`: parsed bodies, {@link ApiError} for non-2xx answers. */
84
+ export declare function createApi(fetcher: ConsoleExtensionContext['fetch']): ExtensionApi;
85
+ /** {@link createApi} for the Console's `fetch`, inside an extension. */
86
+ export declare function useApi(): ExtensionApi;
87
+ /**
88
+ * Calls `reload` shortly after the Console's server events of the given types (`job:*`, `fs:changed`, …): a burst
89
+ * of events causes one reload, `delay` ms after the last; `paused` keeps them for later, `filter` picks events.
90
+ */
91
+ export declare function useLiveReload(patterns: string | readonly string[], reload: () => void, options?: LiveReloadOptions): void;
92
+ /**
93
+ * Calls `reload` shortly after server events matching `patterns` (`databases:migration-run`, `job:*`): a burst of events
94
+ * causes one call, `delay` ms after the last. `reload` may change on every render.
95
+ */
96
+ export declare function useServerEvents(patterns: string | readonly string[], reload: () => void, delay?: number): void;
@@ -0,0 +1,18 @@
1
+ import { type ReactNode } from 'react';
2
+ import { type Fetcher, type ServerPluginRequirement } from './serverPluginApi';
3
+ /**
4
+ * The page of a Console plugin whose server plugin is not installed: which one, a button opening it in the
5
+ * marketplace's server plugins (unless it is added in code only), and the packages to add in code.
6
+ */
7
+ export declare function MissingServerPlugin({ requirement }: {
8
+ requirement: ServerPluginRequirement;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ /**
11
+ * Renders `children` with an extension `fetch` that watches the plugin's route ({@link watchMissingApi}); when the
12
+ * route is missing, {@link MissingServerPlugin} replaces the page. `provide` gives `children` the watched fetch.
13
+ */
14
+ export declare function RequireServerPlugin({ requirement, fetcher, provide }: {
15
+ requirement: ServerPluginRequirement;
16
+ fetcher: Fetcher;
17
+ provide: (fetcher: Fetcher) => ReactNode;
18
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,42 @@
1
+ /** The server plugin a Console page needs: its declaration, and how its absence is told from an answer. */
2
+ /** The server plugins a platform installs a Console page's API with. */
3
+ export interface ServerPluginPackages {
4
+ node?: string;
5
+ python?: string;
6
+ dotnet?: string;
7
+ }
8
+ /**
9
+ * The server plugin a Console page needs: the one serving its API. Official modules declare it in
10
+ * `defineExtension(App, { serverPlugin })` and their package.json (`qodalis.serverPackages`, read by the marketplace);
11
+ * the marketplace's `requires.serverPackage` of the Console plugin is the same relation.
12
+ */
13
+ export interface ServerPluginRequirement {
14
+ /** Its id in the marketplace (`data-explorer`): the server plugins tab opens on it. */
15
+ id: string;
16
+ /** Its name as the page says it (`Data explorer`). */
17
+ title: string;
18
+ /** Its package on each platform. */
19
+ packages: ServerPluginPackages;
20
+ /**
21
+ * The route the page loads first (`/api/qcli/data-explorer/sources`, no query): when the server answers it 404
22
+ * without a JSON `{ error }` (Express's "Cannot GET", an empty .NET 404, FastAPI's `detail`), the plugin is missing.
23
+ */
24
+ api: string;
25
+ /** It is added in the server's code only (not installable from the marketplace). */
26
+ codeOnly?: boolean;
27
+ }
28
+ /**
29
+ * True when a response says the route does not exist (the server plugin serving it is not installed): 404 whose body
30
+ * is not a JSON object with an `error` (a 404 of the plugin itself, `{ "error": "unknown data source" }`, carries one).
31
+ */
32
+ export declare function isMissingApi(status: number, body: string): boolean;
33
+ export type Fetcher = (path: string, init?: RequestInit & {
34
+ quiet?: boolean;
35
+ }) => Promise<Response>;
36
+ /**
37
+ * The extension's `fetch`, watching its answers: `onMissing` runs when the plugin's {@link ServerPluginRequirement.api}
38
+ * route is answered as missing ({@link isMissingApi}). No request of its own; the answer is passed on unchanged.
39
+ */
40
+ export declare function watchMissingApi(fetcher: Fetcher, api: string, onMissing: () => void): Fetcher;
41
+ /** The Console's Plugins → Marketplace → Server plugins tab searching `id`, below the Console's base path. */
42
+ export declare function serverPluginMarketplaceHref(id: string, here?: string): string;