@cobaltcore-dev/aurora 0.19.0 → 0.19.1

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 (36) hide show
  1. package/dist/client/App.d.ts +12 -0
  2. package/dist/client/analytics/setupRouterAnalytics.d.ts +20 -0
  3. package/dist/client/assets/__mocks__/svgMock.d.ts +3 -0
  4. package/dist/client/components/Auth/SessionExpirationTimer.d.ts +4 -0
  5. package/dist/client/components/ClipboardText.d.ts +10 -0
  6. package/dist/client/components/ContentHeader/ContentHeader.d.ts +10 -0
  7. package/dist/client/components/Error/RouteError.d.ts +9 -0
  8. package/dist/client/components/Error/StatusError.d.ts +11 -0
  9. package/dist/client/components/JsonEditor.d.ts +39 -0
  10. package/dist/client/components/ListToolbar/FiltersInput.d.ts +6 -0
  11. package/dist/client/components/ListToolbar/SelectedFilters.d.ts +24 -0
  12. package/dist/client/components/ListToolbar/SortInput.d.ts +11 -0
  13. package/dist/client/components/ListToolbar/index.d.ts +26 -0
  14. package/dist/client/components/ListToolbar/types.d.ts +116 -0
  15. package/dist/client/components/ProjectView/ProjectInfoBox.d.ts +12 -0
  16. package/dist/client/components/Slot.d.ts +7 -0
  17. package/dist/client/components/navigation/LanguageSelect.d.ts +3 -0
  18. package/dist/client/components/navigation/MainNavigation.d.ts +10 -0
  19. package/dist/client/components/navigation/UserMenu.d.ts +1 -0
  20. package/dist/client/components/navigation/types.d.ts +4 -0
  21. package/dist/client/hooks/index.d.ts +15 -0
  22. package/dist/client/hooks/useDomainId.d.ts +21 -0
  23. package/dist/client/hooks/useModalTracking.d.ts +33 -0
  24. package/dist/client/hooks/useProjectId.d.ts +22 -0
  25. package/dist/client/router.d.ts +7 -0
  26. package/dist/client/store/AuthProvider.d.ts +23 -0
  27. package/dist/client/utils/buildFilterParams.d.ts +5 -0
  28. package/dist/client/utils/cn.d.ts +27 -0
  29. package/dist/client/utils/formatBytes.d.ts +40 -0
  30. package/dist/client/utils/formatFloatingIpStatus.d.ts +6 -0
  31. package/dist/client/utils/languageDetection.d.ts +11 -0
  32. package/dist/client/utils/trpcErrors.d.ts +13 -0
  33. package/dist/client/utils/useErrorTranslation.d.ts +4 -0
  34. package/dist/client/utils/useListWithFiltering.d.ts +84 -0
  35. package/dist/client/utils/useModal.d.ts +3 -0
  36. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ import { Slots, OnTrackEventCallback } from './AuroraApp';
2
+ type AppProps = {
3
+ theme?: "theme-dark" | "theme-light";
4
+ bffEndpoint?: string;
5
+ onThemeChange?: (theme: "theme-dark" | "theme-light") => void;
6
+ slots?: Slots;
7
+ appName?: string;
8
+ onTrackEvent?: OnTrackEventCallback;
9
+ enabledServices?: string[];
10
+ };
11
+ declare const App: (props: AppProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default App;
@@ -0,0 +1,20 @@
1
+ import { createAuroraRouter } from '../router';
2
+ /**
3
+ * Sets up analytics tracking for router navigation events.
4
+ * Subscribes to the router's "onResolved" event and emits analytics events
5
+ * when users navigate between routes. Metadata always includes `pathname`,
6
+ * includes `search` when query params are present, and includes `section`/`service`
7
+ * when available via route `staticData`.
8
+ *
9
+ * @param router - The TanStack Router instance
10
+ * @returns Cleanup function to unsubscribe from router events
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * const router = createAuroraRouter(trpcReact, trpcClient)
15
+ * const cleanup = setupRouterAnalytics(router)
16
+ * // Later, when unmounting:
17
+ * cleanup()
18
+ * ```
19
+ */
20
+ export declare function setupRouterAnalytics(router: ReturnType<typeof createAuroraRouter>): () => void;
@@ -0,0 +1,3 @@
1
+ declare const SvgMock: () => null;
2
+ export default SvgMock;
3
+ export { SvgMock as ReactComponent };
@@ -0,0 +1,4 @@
1
+ export declare function SessionExpirationTimer(props: {
2
+ className?: string;
3
+ sessionExpired: Date;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ export interface ClipboardTextProps extends React.HTMLAttributes<HTMLDivElement> {
3
+ tooltipContent?: string;
4
+ text: string;
5
+ className?: string;
6
+ truncateAt?: number;
7
+ showTooltip?: boolean;
8
+ }
9
+ declare const ClipboardText: React.FC<ClipboardTextProps>;
10
+ export default ClipboardText;
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ interface ContentHeaderProps {
3
+ title: string;
4
+ projectId: string;
5
+ description?: string | null;
6
+ actions?: ReactNode;
7
+ badges?: ReactNode;
8
+ }
9
+ export declare function ContentHeader({ title, projectId, description, actions, badges }: ContentHeaderProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,9 @@
1
+ interface RouteErrorProps {
2
+ error: unknown;
3
+ title?: string;
4
+ helpText?: string;
5
+ /** Explicitly pass a safe error message to display. Use this when you want to show specific error details. */
6
+ safeErrorMessage?: string;
7
+ }
8
+ export declare function RouteError({ error, title, helpText, safeErrorMessage }: RouteErrorProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,11 @@
1
+ interface StatusErrorProps {
2
+ message: string;
3
+ statusCode?: number;
4
+ onHomeClick?: () => void;
5
+ onBackClick?: () => void;
6
+ title: string;
7
+ showHeader?: boolean;
8
+ reset?: () => void;
9
+ }
10
+ export declare function StatusError({ message, statusCode, onHomeClick, onBackClick, title, reset }: StatusErrorProps): import("react/jsx-runtime").JSX.Element;
11
+ export {};
@@ -0,0 +1,39 @@
1
+ export interface JsonEditorProps {
2
+ /** Current JSON string value */
3
+ value: string;
4
+ /** Callback when value changes */
5
+ onChange: (value: string) => void;
6
+ /** Callback when editor loses focus */
7
+ onBlur?: () => void;
8
+ /** Whether the editor is disabled */
9
+ disabled?: boolean;
10
+ /** Placeholder text when empty */
11
+ placeholder?: string;
12
+ /** Error message to display (also shows error border) */
13
+ error?: string | null;
14
+ /** Additional CSS class names (use height classes like h-96 to set fixed height) */
15
+ className?: string;
16
+ /** HTML id attribute */
17
+ id?: string;
18
+ /** HTML name attribute */
19
+ name?: string;
20
+ /** Number of spaces for indentation (default: 2) */
21
+ indentSize?: number;
22
+ /** Whether to show line numbers (default: true) */
23
+ showLineNumbers?: boolean;
24
+ /** Test ID for testing */
25
+ "data-testid"?: string;
26
+ }
27
+ /**
28
+ * A simple JSON editor component with line numbers and smart indentation.
29
+ *
30
+ * Features:
31
+ * - Line numbers
32
+ * - Tab key inserts spaces
33
+ * - Enter key auto-indents based on context
34
+ * - Closing braces/brackets auto-dedent
35
+ * - Error state styling
36
+ * - Accessible and keyboard-friendly
37
+ */
38
+ export declare const JsonEditor: ({ value, onChange, onBlur, disabled, placeholder, error, className, id, name, indentSize, showLineNumbers, "data-testid": testId, }: JsonEditorProps) => import("react/jsx-runtime").JSX.Element;
39
+ export default JsonEditor;
@@ -0,0 +1,6 @@
1
+ import { Filter, SelectedFilter } from './types';
2
+ export type FiltersInputProps = {
3
+ filters: Filter[];
4
+ onChange: (filter: SelectedFilter) => void;
5
+ };
6
+ export declare const FiltersInput: ({ filters, onChange }: FiltersInputProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { SelectedFilter } from './types';
2
+ export type SelectedFiltersProps = {
3
+ /**
4
+ * Array of currently active filters to be displayed as closeable pills.
5
+ */
6
+ selectedFilters: SelectedFilter[];
7
+ /**
8
+ * Callback function invoked when a user removes an individual filter pill.
9
+ */
10
+ onDelete: (filter: SelectedFilter) => void;
11
+ /**
12
+ * Callback function invoked when the "Clear all" button is clicked.
13
+ */
14
+ onClear: () => void;
15
+ };
16
+ /**
17
+ * SelectedFilters Component
18
+ *
19
+ * Displays currently active filters as closeable pill components with individual
20
+ * remove buttons and an optional "Clear all" button (shown when 2+ filters are active).
21
+ *
22
+ * The pills are arranged in a flexible, wrapping layout that adapts to available space.
23
+ */
24
+ export declare const SelectedFilters: ({ selectedFilters, onDelete, onClear }: SelectedFiltersProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { default as React } from 'react';
2
+ import { SortOption } from './types';
3
+ export interface SortInputProps {
4
+ sortBy?: string | number | string[];
5
+ onSortByChange: (param?: string | number | string[]) => void;
6
+ sortDirection: "asc" | "desc";
7
+ onSortDirectionChange: (direction: "asc" | "desc") => void;
8
+ options: SortOption[];
9
+ selectClassName?: string;
10
+ }
11
+ export declare const SortInput: React.FC<SortInputProps>;
@@ -0,0 +1,26 @@
1
+ import { ReactNode } from 'react';
2
+ import { SearchInputProps } from '@cloudoperators/juno-ui-components';
3
+ import { FilterSettings, SortSettings } from './types';
4
+ export type ListToolbarProps = {
5
+ filterSettings?: FilterSettings;
6
+ onFilter?: (filterSettings: FilterSettings) => void;
7
+ sortSettings?: SortSettings;
8
+ onSort?: (sortSettings: SortSettings) => void;
9
+ searchTerm?: string;
10
+ onSearch?: (searchTerm: string) => void;
11
+ searchInputProps?: Omit<SearchInputProps, "value" | "onSearch" | "onClear" | "onInput">;
12
+ actions?: ReactNode;
13
+ tabs?: {
14
+ items: Array<{
15
+ label: string;
16
+ value: string;
17
+ }>;
18
+ activeItem: string;
19
+ onActiveItemChange: (value: ReactNode) => void;
20
+ };
21
+ totalCount?: number;
22
+ itemName?: string;
23
+ filteredCount?: number;
24
+ lastUpdated?: Date | string;
25
+ };
26
+ export declare const ListToolbar: ({ filterSettings, onFilter, sortSettings, onSort, searchTerm, onSearch, searchInputProps, actions, tabs, totalCount, filteredCount, itemName, lastUpdated, }: ListToolbarProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Represents a single selected filter value in the active filter list
3
+ * Used to track which filters are currently applied to the data
4
+ */
5
+ export type SelectedFilter = {
6
+ /** The filter name/key this selection belongs to (e.g., "status", "visibility") */
7
+ name: string;
8
+ /** The selected value for this filter (e.g., "active", "public") */
9
+ value: string;
10
+ /**
11
+ * Whether this filter is temporarily disabled without removing it
12
+ * Useful for "show/hide" functionality in the UI
13
+ * @default false
14
+ */
15
+ inactive?: boolean;
16
+ };
17
+ /**
18
+ * Defines a filterable field and its available options
19
+ * Represents a single filter category that users can apply to narrow down results
20
+ */
21
+ export type Filter = {
22
+ /**
23
+ * Human-readable name shown in the UI
24
+ * @example "Status", "Visibility", "Disk Format"
25
+ */
26
+ displayName: string;
27
+ /**
28
+ * The actual parameter name used in API requests
29
+ * @example "status", "visibility", "disk_format"
30
+ */
31
+ filterName: string;
32
+ /**
33
+ * Array of available values users can select for this filter
34
+ * @example ["active", "queued", "saving"] for status filter
35
+ */
36
+ values: string[];
37
+ /**
38
+ * Whether this filter supports selecting multiple values using the 'in' operator
39
+ *
40
+ * For OpenStack Glance API:
41
+ * - Supports 'in': name, status, id, container_format, disk_format
42
+ * - Does NOT support 'in': visibility, protected, owner, tags, dates
43
+ *
44
+ * When true, multiple selections will be combined as: `filterName=in:value1,value2,value3`
45
+ * When false, only single value is allowed: `filterName=value`
46
+ *
47
+ * @default false
48
+ * @example
49
+ * // supportsMultiValue: true
50
+ * status=in:active,queued,saving
51
+ *
52
+ * // supportsMultiValue: false
53
+ * visibility=public
54
+ */
55
+ supportsMultiValue?: boolean;
56
+ };
57
+ /**
58
+ * Complete filter configuration including available filters and current selections
59
+ * Represents the entire filtering state for a list view
60
+ */
61
+ export type FilterSettings = {
62
+ /**
63
+ * Currently applied filters by the user
64
+ * If undefined or empty, no filters are active
65
+ */
66
+ selectedFilters?: SelectedFilter[];
67
+ /**
68
+ * Available filter definitions that users can choose from
69
+ * These define what filters are available in the UI
70
+ */
71
+ filters: Filter[];
72
+ };
73
+ /**
74
+ * Represents a single option in the sort dropdown
75
+ * Defines a field that data can be sorted by
76
+ */
77
+ export type SortOption = {
78
+ /**
79
+ * The actual field name to sort by (used in API requests)
80
+ * @example "created_at", "name", "size", "status"
81
+ */
82
+ value: string;
83
+ /**
84
+ * Human-readable label shown in the UI
85
+ * @example "Created At", "Name", "Size", "Status"
86
+ */
87
+ label: string;
88
+ };
89
+ /**
90
+ * Complete sorting configuration including available options and current sort state
91
+ * Represents the entire sorting state for a list view
92
+ */
93
+ export type SortSettings = {
94
+ /**
95
+ * Array of available fields that can be used for sorting
96
+ * These options are displayed in the sort dropdown
97
+ */
98
+ options: SortOption[];
99
+ /**
100
+ * Currently selected sort field
101
+ * Can be a string (single field), number (field index), or array (multiple fields)
102
+ *
103
+ * For OpenStack Glance API, typically a string representing the field name
104
+ * @example "created_at", "name", "size"
105
+ */
106
+ sortBy?: string | number | string[];
107
+ /**
108
+ * Current sort direction
109
+ *
110
+ * - "asc": Ascending order (A-Z, 0-9, oldest to newest)
111
+ * - "desc": Descending order (Z-A, 9-0, newest to oldest)
112
+ *
113
+ * @default "desc" (typically for created_at to show newest first)
114
+ */
115
+ sortDirection?: "asc" | "desc";
116
+ };
@@ -0,0 +1,12 @@
1
+ interface ProjectInfoBoxProps {
2
+ projectInfo: {
3
+ id: string;
4
+ name: string;
5
+ description?: string;
6
+ domain?: {
7
+ name?: string;
8
+ };
9
+ };
10
+ }
11
+ export declare function ProjectInfoBox({ projectInfo }: ProjectInfoBoxProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -0,0 +1,7 @@
1
+ import { FC } from 'react';
2
+ import { SlotProps } from '../AuroraApp';
3
+ export declare function Slot({ component: Component, useShadowDOM, currentService, }: {
4
+ component: FC<SlotProps>;
5
+ useShadowDOM?: boolean;
6
+ currentService?: string;
7
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,3 @@
1
+ export declare function LanguageSelect({ className }: {
2
+ className?: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { NavigationItem } from './types';
2
+ import { Slots } from '../../AuroraApp';
3
+ interface NavigationProps {
4
+ items: NavigationItem[];
5
+ handleThemeToggle?: (theme: string) => void;
6
+ appName?: string;
7
+ slots?: Slots;
8
+ }
9
+ export declare function MainNavigation({ items, handleThemeToggle, appName, slots }: NavigationProps): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1 @@
1
+ export declare function UserMenu(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ export interface NavigationItem {
2
+ route: string;
3
+ label: string;
4
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * URL-based context hooks
3
+ *
4
+ * These hooks extract scope information (projectId, domainId) directly from URL params.
5
+ * This follows the principle "URL is the source of truth".
6
+ *
7
+ * Benefits:
8
+ * - Centralized URL param extraction (single point of change during route refactoring)
9
+ * - Type-safe access to route params
10
+ * - Runtime validation with clear error messages
11
+ * - No prop drilling needed
12
+ * - Easy to test and mock
13
+ */
14
+ export { useProjectId } from './useProjectId';
15
+ export { useDomainId } from './useDomainId';
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Get the current user's domain ID from the authentication context.
3
+ *
4
+ * This hook provides access to the domain ID of the currently authenticated user.
5
+ * The domain ID is obtained from the user's session, not from URL parameters.
6
+ *
7
+ * @throws {Error} If user is not authenticated or domain ID is not available
8
+ * @returns {string} The current domain ID from the user's session
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * function UsersList() {
13
+ * const domainId = useDomainId()
14
+ *
15
+ * const { data } = trpc.identity.users.list.useQuery({
16
+ * domain_id: domainId
17
+ * })
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function useDomainId(): string;
@@ -0,0 +1,33 @@
1
+ interface UseModalTrackingOptions {
2
+ isOpen: boolean;
3
+ actionPrefix: string;
4
+ }
5
+ interface UseModalTrackingReturn {
6
+ trackClose: () => void;
7
+ markSubmitted: () => void;
8
+ resetTracking: () => void;
9
+ }
10
+ /**
11
+ * Custom hook to handle modal open/close analytics tracking.
12
+ *
13
+ * Tracks:
14
+ * - `.open` event when modal opens (once per modal open)
15
+ * - `.close` event when modal closes without submission (cancelled)
16
+ *
17
+ * @example
18
+ * const { trackClose, markSubmitted, resetTracking } = useModalTracking({
19
+ * isOpen,
20
+ * actionPrefix: "storage.ceph.bucket.create"
21
+ * })
22
+ *
23
+ * // In handleClose:
24
+ * trackClose()
25
+ *
26
+ * // In handleSubmit:
27
+ * markSubmitted()
28
+ *
29
+ * // In cleanup/reset:
30
+ * resetTracking()
31
+ */
32
+ export declare const useModalTracking: ({ isOpen, actionPrefix }: UseModalTrackingOptions) => UseModalTrackingReturn;
33
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Extract projectId from the current URL.
3
+ *
4
+ * This hook works with both old and new route structures:
5
+ * - Old: /accounts/:accountId/projects/:projectId/...
6
+ * - New: /projects/:projectId/...
7
+ *
8
+ * @throws {Error} If used outside of a project route context
9
+ * @returns {string} The current project ID from URL params
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * function SecurityGroupsList() {
14
+ * const projectId = useProjectId()
15
+ *
16
+ * const { data } = trpc.network.securityGroup.list.useQuery({
17
+ * project_id: projectId
18
+ * })
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function useProjectId(): string;
@@ -0,0 +1,7 @@
1
+ import { TrpcReact, TrpcClient } from './trpcClient';
2
+ export declare function createAuroraRouter(trpcReact: TrpcReact, trpcClient: TrpcClient): import('@tanstack/router-core').RouterCore<import('@tanstack/router-core').Route<import('@tanstack/react-router').Register, any, "/", "/", string, "__root__", undefined, {}, import('./routes/__root').RouterContext, import('@tanstack/router-core').AnyContext, import('@tanstack/router-core').AnyContext, {}, undefined, import('./routeTree.gen').RootRouteChildren, import('./routeTree.gen').FileRouteTypes, unknown, unknown, undefined>, "never", false, import('@tanstack/history').RouterHistory, Record<string, any>>;
3
+ declare module "@tanstack/react-router" {
4
+ interface Register {
5
+ router: ReturnType<typeof createAuroraRouter>;
6
+ }
7
+ }
@@ -0,0 +1,23 @@
1
+ import { default as React } from 'react';
2
+ import { TokenData } from '../../server/Authentication/types/models';
3
+ export type User = TokenData["user"] | null;
4
+ export interface AuthContext {
5
+ isAuthenticated: boolean;
6
+ login: (user: User, expires_at?: string) => Promise<void>;
7
+ logout: () => Promise<void>;
8
+ user?: User;
9
+ expiresAt?: Date;
10
+ }
11
+ interface RouterNavigation {
12
+ navigate: (options: {
13
+ to: string;
14
+ search?: Record<string, unknown>;
15
+ }) => void;
16
+ invalidate: () => void;
17
+ }
18
+ export declare function AuthProvider({ children, router }: {
19
+ children: React.ReactNode;
20
+ router: RouterNavigation;
21
+ }): import("react/jsx-runtime").JSX.Element;
22
+ export declare function useAuth(): AuthContext;
23
+ export {};
@@ -0,0 +1,5 @@
1
+ import { FilterSettings } from '../components/ListToolbar/types';
2
+ /**
3
+ * Builds filter parameters from current filter settings
4
+ */
5
+ export declare const buildFilterParams: (filterSettings: FilterSettings) => Record<string, string | boolean>;
@@ -0,0 +1,27 @@
1
+ import { ClassValue } from 'clsx';
2
+ /**
3
+ * A utility function that combines clsx and tailwind-merge
4
+ *
5
+ * This function takes multiple class values (strings, objects, arrays, etc.)
6
+ * and combines them into a single string of CSS classes.
7
+ * It then uses tailwind-merge to resolve any Tailwind CSS conflicts.
8
+ *
9
+ * @param inputs - Class values to be combined
10
+ * @returns A string of CSS classes with Tailwind conflicts resolved
11
+ *
12
+ * @example
13
+ * // Basic usage
14
+ * cn('text-red-500', 'bg-blue-500')
15
+ * // => 'text-red-500 bg-blue-500'
16
+ *
17
+ * @example
18
+ * // With conditionals
19
+ * cn('text-white', isError && 'bg-red-500', !isError && 'bg-blue-500')
20
+ * // => 'text-white bg-red-500' or 'text-white bg-blue-500'
21
+ *
22
+ * @example
23
+ * // Resolving conflicts
24
+ * cn('text-red-500', 'text-blue-500')
25
+ * // => 'text-blue-500' (the latter class wins)
26
+ */
27
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Supported unit systems for byte formatting.
3
+ *
4
+ * - `"binary"` (IEC): uses powers of 1024 → B, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB
5
+ * - `"decimal"` (SI): uses powers of 1000 → B, KB, MB, GB, TB, PB, EB, ZB, YB
6
+ *
7
+ * Default is `"binary"`.
8
+ */
9
+ export type ByteUnitSystem = "binary" | "decimal";
10
+ export interface FormatBytesOptions {
11
+ /** Number of decimal places to display. Defaults to `2`. */
12
+ decimals?: number;
13
+ /** Unit system to use. Defaults to `"binary"`. */
14
+ unitSystem?: ByteUnitSystem;
15
+ }
16
+ /**
17
+ * Formats a raw byte count into a human-readable string.
18
+ *
19
+ * @example
20
+ * formatBytes(1536) // "1.50 KiB" (binary, default)
21
+ * formatBytes(1500, { unitSystem: "decimal" }) // "1.50 KB"
22
+ * formatBytes(1073741824) // "1.00 GiB"
23
+ * formatBytes(0) // "0 B"
24
+ * formatBytes(null) // "0 B"
25
+ */
26
+ export declare function formatBytes(bytes: number | null | undefined, { decimals, unitSystem }?: FormatBytesOptions): string;
27
+ /**
28
+ * Convenience wrapper that always uses the decimal (SI) unit system.
29
+ *
30
+ * @example
31
+ * formatBytesDecimal(1500000) // "1.50 MB"
32
+ */
33
+ export declare const formatBytesDecimal: (bytes: number | null | undefined, decimals?: number) => string;
34
+ /**
35
+ * Convenience wrapper that always uses the binary (IEC) unit system.
36
+ *
37
+ * @example
38
+ * formatBytesBinary(1048576) // "1.00 MiB"
39
+ */
40
+ export declare const formatBytesBinary: (bytes: number | null | undefined, decimals?: number) => string;
@@ -0,0 +1,6 @@
1
+ import { FloatingIpStatus } from '../../server/Network/types/floatingIp';
2
+ /**
3
+ * Formats a floating IP status value from uppercase enum to title case.
4
+ * Example: "ACTIVE" → "Active", "DOWN" → "Down", "ERROR" → "Error"
5
+ */
6
+ export declare const formatFloatingIpStatus: (status: FloatingIpStatus) => string;
@@ -0,0 +1,11 @@
1
+ export declare const SUPPORTED_LOCALES: readonly ["en", "de"];
2
+ export type SupportedLocale = (typeof SUPPORTED_LOCALES)[number];
3
+ /**
4
+ * Detects the user's preferred language with fallback chain:
5
+ * 1. Saved preference (localStorage)
6
+ * 2. Browser language settings
7
+ * 3. Default locale
8
+ */
9
+ export declare function detectLanguage(): SupportedLocale;
10
+ export declare function saveLanguagePreference(locale: SupportedLocale): void;
11
+ export declare function getLanguagePreference(): SupportedLocale | null;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Type guard to check if an error is a tRPC error with UNAUTHORIZED code
3
+ */
4
+ export declare function isTRPCUnauthorized(error: unknown): boolean;
5
+ /**
6
+ * Type guard to check if an error is a tRPC error
7
+ */
8
+ export declare function isTRPCError(error: unknown): error is {
9
+ data: {
10
+ code: string;
11
+ };
12
+ message?: string;
13
+ };
@@ -0,0 +1,4 @@
1
+ export declare const useErrorTranslation: () => {
2
+ translateError: (errorCode: string) => string;
3
+ isRetryableError: (errorCode: string) => boolean;
4
+ };
@@ -0,0 +1,84 @@
1
+ import { FilterSettings, SortOption, SortSettings } from '../components/ListToolbar/types';
2
+ /**
3
+ * Sort direction enumeration
4
+ * Used across all sort-enabled list views
5
+ */
6
+ export type SortDirection = "asc" | "desc";
7
+ /**
8
+ * Generic required sort settings with guaranteed non-optional properties
9
+ * Used by components to maintain a fully-defined sort state
10
+ *
11
+ * Type parameter K is the sort key type (string literal union of allowed sort fields)
12
+ *
13
+ * @example
14
+ * // For floating IPs
15
+ * type FloatingIpListSortSettings = ListSortConfig<FloatingIpsSortKey>
16
+ *
17
+ * // For security groups
18
+ * type SecurityGroupListSortSettings = ListSortConfig<"name" | "project_id">
19
+ */
20
+ export type ListSortConfig<T extends string = string> = {
21
+ /**
22
+ * Array of available sort options to display in the UI
23
+ */
24
+ options: SortOption[];
25
+ /**
26
+ * The currently selected sort field (guaranteed to be one of the available options)
27
+ */
28
+ sortBy: T;
29
+ /**
30
+ * The currently active sort direction (guaranteed to be either "asc" or "desc")
31
+ */
32
+ sortDirection: SortDirection;
33
+ };
34
+ /**
35
+ * Configuration options for the useListWithFiltering hook
36
+ */
37
+ export interface UseListWithFilteringOptions<T extends string> {
38
+ /** Default sort key to use on initial render */
39
+ defaultSortKey: T;
40
+ /** Default sort direction to use on initial render */
41
+ defaultSortDir: SortDirection;
42
+ /** Available sort options to display in the sort dropdown */
43
+ sortOptions: Array<{
44
+ label: string;
45
+ value: string;
46
+ }>;
47
+ /** Initial filter settings configuration */
48
+ filterSettings: FilterSettings;
49
+ }
50
+ /**
51
+ * Return value from the useListWithFiltering hook
52
+ */
53
+ export interface UseListWithFilteringReturn<T extends string> {
54
+ searchTerm: string;
55
+ sortSettings: ListSortConfig<T>;
56
+ filterSettings: FilterSettings;
57
+ handleSearchChange: (term: string | number | string[] | undefined) => void;
58
+ handleSortChange: (newSortSettings: SortSettings) => void;
59
+ handleFilterChange: (newFilterSettings: FilterSettings) => void;
60
+ }
61
+ /**
62
+ * Custom hook to manage common list view state: search, sort, and filter
63
+ *
64
+ * Extracts shared logic from list components to ensure consistent behavior
65
+ * across all list pages and reduce code duplication.
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * const listState = useListWithFiltering({
70
+ * defaultSortKey: "name",
71
+ * defaultSortDir: "asc",
72
+ * sortOptions: [
73
+ * { label: t`Name`, value: "name" },
74
+ * { label: t`Created`, value: "created_at" },
75
+ * ],
76
+ * filterSettings: {
77
+ * filters: [
78
+ * { displayName: t`Status`, filterName: "status", values: ["active", "inactive"] }
79
+ * ]
80
+ * }
81
+ * })
82
+ * ```
83
+ */
84
+ export declare function useListWithFiltering<T extends string>({ defaultSortKey, defaultSortDir, sortOptions, filterSettings: initialFilterSettings, }: UseListWithFilteringOptions<T>): UseListWithFilteringReturn<T>;
@@ -0,0 +1,3 @@
1
+ type UseModalReturn = [boolean, () => void];
2
+ export declare const useModal: (initialState?: boolean) => UseModalReturn;
3
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cobaltcore-dev/aurora",
3
- "version": "0.19.0",
3
+ "version": "0.19.1",
4
4
  "private": false,
5
5
  "description": "Aurora OpenStack dashboard — server and client library",
6
6
  "license": "Apache-2.0",