@prismiq/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/dist/CustomSQLEditor-BXB4rf1q.d.cts +1297 -0
- package/dist/CustomSQLEditor-DYeId0Gp.d.ts +1297 -0
- package/dist/DashboardDialog-B3vYC5Gs.d.ts +1106 -0
- package/dist/DashboardDialog-LHmrtNQU.d.cts +1106 -0
- package/dist/accessibility-2yy5yqRR.d.cts +145 -0
- package/dist/accessibility-2yy5yqRR.d.ts +145 -0
- package/dist/charts/index.cjs +110 -0
- package/dist/charts/index.cjs.map +1 -0
- package/dist/charts/index.d.cts +2 -0
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +5 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/chunk-2H5WTH4K.js +2409 -0
- package/dist/chunk-2H5WTH4K.js.map +1 -0
- package/dist/chunk-4AVL6GQK.cjs +470 -0
- package/dist/chunk-4AVL6GQK.cjs.map +1 -0
- package/dist/chunk-EX74SI67.js +455 -0
- package/dist/chunk-EX74SI67.js.map +1 -0
- package/dist/chunk-FEABEF3J.cjs +7543 -0
- package/dist/chunk-FEABEF3J.cjs.map +1 -0
- package/dist/chunk-JTCBZDHY.js +126 -0
- package/dist/chunk-JTCBZDHY.js.map +1 -0
- package/dist/chunk-LMTG3LRC.cjs +326 -0
- package/dist/chunk-LMTG3LRC.cjs.map +1 -0
- package/dist/chunk-MDXGGZSW.cjs +273 -0
- package/dist/chunk-MDXGGZSW.cjs.map +1 -0
- package/dist/chunk-MOAEEF5P.js +7510 -0
- package/dist/chunk-MOAEEF5P.js.map +1 -0
- package/dist/chunk-NK7HKX2J.cjs +2459 -0
- package/dist/chunk-NK7HKX2J.cjs.map +1 -0
- package/dist/chunk-NY6TZLST.cjs +8781 -0
- package/dist/chunk-NY6TZLST.cjs.map +1 -0
- package/dist/chunk-T6STUE7E.js +321 -0
- package/dist/chunk-T6STUE7E.js.map +1 -0
- package/dist/chunk-TRW7DKLP.cjs +141 -0
- package/dist/chunk-TRW7DKLP.cjs.map +1 -0
- package/dist/chunk-UPYINBZU.js +8706 -0
- package/dist/chunk-UPYINBZU.js.map +1 -0
- package/dist/chunk-WWTT2OJ5.js +246 -0
- package/dist/chunk-WWTT2OJ5.js.map +1 -0
- package/dist/components/index.cjs +222 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +207 -0
- package/dist/components/index.d.ts +207 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/dashboard/index.cjs +140 -0
- package/dist/dashboard/index.cjs.map +1 -0
- package/dist/dashboard/index.d.cts +302 -0
- package/dist/dashboard/index.d.ts +302 -0
- package/dist/dashboard/index.js +7 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/export/index.cjs +32 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +197 -0
- package/dist/export/index.d.ts +197 -0
- package/dist/export/index.js +3 -0
- package/dist/export/index.js.map +1 -0
- package/dist/index-C-Qcuu4Y.d.cts +821 -0
- package/dist/index-rPc7ijt8.d.ts +821 -0
- package/dist/index.cjs +1486 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1435 -0
- package/dist/index.d.ts +1435 -0
- package/dist/index.js +926 -0
- package/dist/index.js.map +1 -0
- package/dist/ssr/index.cjs +64 -0
- package/dist/ssr/index.cjs.map +1 -0
- package/dist/ssr/index.d.cts +213 -0
- package/dist/ssr/index.d.ts +213 -0
- package/dist/ssr/index.js +3 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/types-WrCbOeAV.d.cts +569 -0
- package/dist/types-WrCbOeAV.d.ts +569 -0
- package/dist/utils/index.cjs +64 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +112 -0
- package/dist/utils/index.d.ts +112 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +110 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1435 @@
|
|
|
1
|
+
import { D as DatabaseSchema, c as TableSchema, a as QueryDefinition, V as ValidationResult, Q as QueryResult, S as SQLValidationResult, d as Dashboard, e as DashboardCreate, f as DashboardUpdate, W as WidgetCreate, g as Widget, h as WidgetUpdate, i as WidgetPositionUpdate, j as SavedQuery, k as SavedQueryCreate, l as SavedQueryUpdate, P as PinnedDashboard, m as PinnedDashboardsResponse, R as Relationship, n as WidgetPosition } from './types-WrCbOeAV.js';
|
|
2
|
+
export { A as AggregationType, o as ColumnSchema, q as ColumnSelection, u as DashboardPinContextsResponse, E as ExecuteSQLRequest, r as FilterDefinition, F as FilterOperator, G as GroupByDefinition, J as JoinDefinition, p as JoinType, b as QueryTable, t as SortDefinition, s as SortDirection } from './types-WrCbOeAV.js';
|
|
3
|
+
import { P as PrismiqTheme, T as ThemeMode, D as DeepPartial, a as ThemeContextValue, C as ChartDataOptions, b as ChartDataResult } from './index-rPc7ijt8.js';
|
|
4
|
+
export { A as AreaChart, F as AreaChartProps, v as AxisFormat, B as BarChart, y as BarChartProps, r as BaseChartProps, u as ChartClickParams, o as ChartDataPoint, p as ChartSeries, Q as ChartSuggestion, O as ChartType, E as EChartWrapper, x as EChartWrapperProps, w as LegendPosition, L as LineChart, z as LineChartProps, M as MetricCard, J as MetricCardProps, d as PieChart, G as PieChartProps, R as ReferenceLineConfig, e as ScatterChart, H as ScatterChartProps, S as Sparkline, N as SparklineProps, I as TrendConfig, c as TrendIndicator, K as TrendIndicatorProps, h as applyThemeToOption, g as createChartTheme, m as createGradientColor, f as dataPointsToChartData, i as formatAxisLabel, j as formatCompact, k as formatMetricValue, l as getChartColors, n as isChartDataEmpty, q as queryResultToChartData, s as suggestChartType, t as toChartData } from './index-rPc7ijt8.js';
|
|
5
|
+
import { ReactNode, CSSProperties } from 'react';
|
|
6
|
+
export { ai as AggregationPicker, aj as AggregationPickerProps, a as Badge, m as BadgeProps, B as Button, h as ButtonProps, C as Checkbox, l as CheckboxProps, a0 as ColumnNode, a3 as ColumnNodeProps, a4 as ColumnSelector, a6 as ColumnSelectorProps, aD as CustomSQLEditor, aE as CustomSQLEditorProps, e as Dialog, g as DialogFooter, v as DialogFooterProps, f as DialogHeader, u as DialogHeaderProps, t as DialogProps, D as Dropdown, b as DropdownItem, p as DropdownItemProps, o as DropdownProps, c as DropdownSeparator, q as DropdownSeparatorProps, U as EmptyDashboard, Z as EmptyDashboardProps, P as EmptyState, V as EmptyStateProps, K as ErrorBoundary, M as ErrorBoundaryProps, L as ErrorFallback, N as ErrorFallbackProps, a8 as FilterBuilder, ab as FilterBuilderProps, a9 as FilterRow, ac as FilterRowProps, aa as FilterValueInput, ad as FilterValueInputProps, d as Icon, s as IconName, r as IconProps, I as Input, i as InputProps, Q as NoData, X as NoDataProps, R as NoResults, Y as NoResultsProps, ao as Pagination, at as PaginationProps, au as QueryBuilder, ax as QueryBuilderProps, ay as QueryBuilderState, av as QueryBuilderToolbar, az as QueryBuilderToolbarProps, aw as QueryPreview, aA as QueryPreviewProps, ak as ResultsTable, ap as ResultsTableProps, aB as SavedQueryPicker, aC as SavedQueryPickerProps, _ as SchemaExplorer, a1 as SchemaExplorerProps, S as Select, k as SelectOption, j as SelectProps, a5 as SelectedColumn, a7 as SelectedColumnProps, w as Skeleton, y as SkeletonChart, G as SkeletonChartProps, A as SkeletonMetricCard, J as SkeletonMetricCardProps, E as SkeletonProps, z as SkeletonTable, H as SkeletonTableProps, x as SkeletonText, F as SkeletonTextProps, ae as SortBuilder, ag as SortBuilderProps, af as SortRow, ah as SortRowProps, an as TableCell, as as TableCellProps, al as TableHeader, aq as TableHeaderProps, $ as TableNode, a2 as TableNodeProps, am as TableRow, ar as TableRowProps, T as Tooltip, n as TooltipProps, W as WidgetErrorBoundary, O as WidgetErrorBoundaryProps } from './CustomSQLEditor-DYeId0Gp.js';
|
|
7
|
+
export { ExcelCellStyle, ExcelExportOptions, ExportData, ExportOptions, UseExportOptions, UseExportResult, downloadFile, exportMultipleSheets, exportToCSV, exportToExcel, generateCSV, useExport } from './export/index.js';
|
|
8
|
+
export { J as Dashboard, a6 as DashboardCard, a9 as DashboardCardProps, x as DashboardContext, k as DashboardContextValue, j as DashboardDefinition, a7 as DashboardDialog, aa as DashboardDialogProps, a0 as DashboardEditor, l as DashboardEditorContextValue, o as DashboardEditorProps, g as DashboardFilter, f as DashboardFilterType, D as DashboardLayout, K as DashboardLayoutComponent, p as DashboardLayoutProps, a5 as DashboardList, a8 as DashboardListProps, n as DashboardProps, w as DashboardProvider, m as DashboardProviderProps, Y as DateRangeFilter, t as DateRangeFilterProps, i as DateRangeValue, a1 as EditorToolbar, a4 as EditorToolbarProps, X as FilterBar, s as FilterBarProps, F as FilterOption, h as FilterValue, _ as MultiSelectFilter, M as MultiSelectFilterProps, N as NumberRangeValue, Z as SelectFilter, S as SelectFilterProps, $ as TextFilter, T as TextFilterProps, E as UseAutoRefreshOptions, G as UseAutoRefreshResult, U as UseDashboardFiltersResult, I as UseFullscreenResult, B as UseWidgetResult, O as Widget, c as WidgetConfig, Q as WidgetContent, V as WidgetContentProps, W as WidgetDefinition, a3 as WidgetEditor, v as WidgetEditorProps, P as WidgetHeader, r as WidgetHeaderProps, a2 as WidgetPalette, u as WidgetPaletteProps, a as WidgetPosition, q as WidgetProps, b as WidgetType, C as useAutoRefresh, y as useDashboard, z as useDashboardFilters, H as useFullscreen, A as useWidget } from './DashboardDialog-B3vYC5Gs.js';
|
|
9
|
+
export { A as ArrowNavigationOptions, F as FocusTrapOptions, S as SkipLinkProps, g as UseArrowNavigationResult, U as UseFocusTrapResult, d as announceToScreenReader, f as focusVisibleStyles, e as skipLinkFocusStyles, s as skipLinkStyles, a as useArrowNavigation, u as useFocusTrap, c as useFocusVisible, b as useRovingTabIndex } from './accessibility-2yy5yqRR.js';
|
|
10
|
+
export { BREAKPOINTS, Breakpoint, ClientOnly, ClientOnlyProps, WindowSize, getLocalStorage, getWindowHeight, getWindowWidth, isBrowser, isServer, removeLocalStorage, setLocalStorage, useBreakpoint, useIsBreakpoint, useIsClient, useMediaQuery, useWindowSize } from './ssr/index.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Prismiq API Client.
|
|
14
|
+
*
|
|
15
|
+
* Typed HTTP client for communicating with the Prismiq backend.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Configuration for the Prismiq client.
|
|
20
|
+
*/
|
|
21
|
+
interface ClientConfig {
|
|
22
|
+
/** Base URL of the Prismiq API endpoint. */
|
|
23
|
+
endpoint: string;
|
|
24
|
+
/**
|
|
25
|
+
* Tenant ID for multi-tenant isolation.
|
|
26
|
+
* All API calls will include this in the X-Tenant-ID header.
|
|
27
|
+
* Required for production use.
|
|
28
|
+
*/
|
|
29
|
+
tenantId: string;
|
|
30
|
+
/**
|
|
31
|
+
* User ID for ownership and permissions.
|
|
32
|
+
* Included in X-User-ID header when provided.
|
|
33
|
+
* Used for dashboard ownership and access control.
|
|
34
|
+
*/
|
|
35
|
+
userId?: string;
|
|
36
|
+
/**
|
|
37
|
+
* PostgreSQL schema name for per-tenant schema isolation.
|
|
38
|
+
* Included in X-Schema-Name header when provided.
|
|
39
|
+
* Used when each tenant has their own PostgreSQL schema (e.g., "org_123").
|
|
40
|
+
*/
|
|
41
|
+
schemaName?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Custom headers to include with every request.
|
|
44
|
+
* Useful for application-specific headers like row-level security filters.
|
|
45
|
+
* Keys are header names, values are header values.
|
|
46
|
+
*/
|
|
47
|
+
customHeaders?: Record<string, string>;
|
|
48
|
+
/** Optional function to get an authentication token. */
|
|
49
|
+
getToken?: () => Promise<string> | string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Base error class for Prismiq API errors.
|
|
53
|
+
*/
|
|
54
|
+
declare class PrismiqError extends Error {
|
|
55
|
+
readonly statusCode?: number | undefined;
|
|
56
|
+
constructor(message: string, statusCode?: number | undefined);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* HTTP client for the Prismiq backend API.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const client = new PrismiqClient({
|
|
64
|
+
* endpoint: 'https://api.example.com/analytics',
|
|
65
|
+
* getToken: () => authService.getToken(),
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* const schema = await client.getSchema();
|
|
69
|
+
* const result = await client.executeQuery(query);
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
declare class PrismiqClient {
|
|
73
|
+
private readonly endpoint;
|
|
74
|
+
private readonly tenantId;
|
|
75
|
+
private readonly userId?;
|
|
76
|
+
private readonly schemaName?;
|
|
77
|
+
private readonly customHeaders?;
|
|
78
|
+
private readonly getToken?;
|
|
79
|
+
constructor(config: ClientConfig);
|
|
80
|
+
/**
|
|
81
|
+
* Make an authenticated request to the API.
|
|
82
|
+
*/
|
|
83
|
+
private request;
|
|
84
|
+
/**
|
|
85
|
+
* Make a GET request to the API.
|
|
86
|
+
*
|
|
87
|
+
* @param path - API path (starting with /)
|
|
88
|
+
* @returns Response data
|
|
89
|
+
*/
|
|
90
|
+
get<T>(path: string): Promise<T>;
|
|
91
|
+
/**
|
|
92
|
+
* Make a POST request to the API.
|
|
93
|
+
*
|
|
94
|
+
* @param path - API path (starting with /)
|
|
95
|
+
* @param body - Request body (will be JSON stringified)
|
|
96
|
+
* @returns Response data
|
|
97
|
+
*/
|
|
98
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
99
|
+
/**
|
|
100
|
+
* Make a PUT request to the API.
|
|
101
|
+
*
|
|
102
|
+
* @param path - API path (starting with /)
|
|
103
|
+
* @param body - Request body (will be JSON stringified)
|
|
104
|
+
* @returns Response data
|
|
105
|
+
*/
|
|
106
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
107
|
+
/**
|
|
108
|
+
* Make a PATCH request to the API.
|
|
109
|
+
*
|
|
110
|
+
* @param path - API path (starting with /)
|
|
111
|
+
* @param body - Request body (will be JSON stringified)
|
|
112
|
+
* @returns Response data
|
|
113
|
+
*/
|
|
114
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
115
|
+
/**
|
|
116
|
+
* Make a DELETE request to the API.
|
|
117
|
+
*
|
|
118
|
+
* @param path - API path (starting with /)
|
|
119
|
+
* @returns Response data
|
|
120
|
+
*/
|
|
121
|
+
delete<T>(path: string): Promise<T>;
|
|
122
|
+
/**
|
|
123
|
+
* Get the complete database schema.
|
|
124
|
+
*
|
|
125
|
+
* @returns The database schema including all tables and relationships.
|
|
126
|
+
*/
|
|
127
|
+
getSchema(): Promise<DatabaseSchema>;
|
|
128
|
+
/**
|
|
129
|
+
* Get a list of available table names.
|
|
130
|
+
*
|
|
131
|
+
* @returns Array of table names.
|
|
132
|
+
*/
|
|
133
|
+
getTables(): Promise<string[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Get schema information for a specific table.
|
|
136
|
+
*
|
|
137
|
+
* @param tableName - The name of the table.
|
|
138
|
+
* @returns The table schema including columns.
|
|
139
|
+
*/
|
|
140
|
+
getTable(tableName: string): Promise<TableSchema>;
|
|
141
|
+
/**
|
|
142
|
+
* Get sample values from a column for data preview.
|
|
143
|
+
*
|
|
144
|
+
* @param tableName - The name of the table.
|
|
145
|
+
* @param columnName - The name of the column.
|
|
146
|
+
* @param limit - Maximum number of distinct values to return (default: 5).
|
|
147
|
+
* @returns Array of sample values.
|
|
148
|
+
*/
|
|
149
|
+
getColumnSample(tableName: string, columnName: string, limit?: number): Promise<unknown[]>;
|
|
150
|
+
/**
|
|
151
|
+
* Validate a query without executing it.
|
|
152
|
+
*
|
|
153
|
+
* @param query - The query definition to validate.
|
|
154
|
+
* @returns Validation result with any errors.
|
|
155
|
+
*/
|
|
156
|
+
validateQuery(query: QueryDefinition): Promise<ValidationResult>;
|
|
157
|
+
/**
|
|
158
|
+
* Generate SQL from a query definition without executing.
|
|
159
|
+
*
|
|
160
|
+
* @param query - The query definition.
|
|
161
|
+
* @returns The generated SQL string.
|
|
162
|
+
*/
|
|
163
|
+
generateSql(query: QueryDefinition): Promise<string>;
|
|
164
|
+
/**
|
|
165
|
+
* Execute a query and return the full result.
|
|
166
|
+
*
|
|
167
|
+
* @param query - The query definition to execute.
|
|
168
|
+
* @param bypassCache - If true, bypass cache and re-execute query.
|
|
169
|
+
* @returns The query result with all rows and cache metadata.
|
|
170
|
+
*/
|
|
171
|
+
executeQuery(query: QueryDefinition, bypassCache?: boolean): Promise<QueryResult>;
|
|
172
|
+
/**
|
|
173
|
+
* Execute a query with a limited result set for previewing.
|
|
174
|
+
*
|
|
175
|
+
* @param query - The query definition to execute.
|
|
176
|
+
* @param limit - Maximum number of rows to return (default: 100).
|
|
177
|
+
* @returns The query result with limited rows.
|
|
178
|
+
*/
|
|
179
|
+
previewQuery(query: QueryDefinition, limit?: number): Promise<QueryResult>;
|
|
180
|
+
/**
|
|
181
|
+
* Validate a raw SQL query without executing it.
|
|
182
|
+
*
|
|
183
|
+
* Checks that the SQL is a valid SELECT statement and only
|
|
184
|
+
* references tables visible in the schema.
|
|
185
|
+
*
|
|
186
|
+
* @param sql - Raw SQL query to validate.
|
|
187
|
+
* @returns Validation result with any errors and referenced tables.
|
|
188
|
+
*/
|
|
189
|
+
validateSQL(sql: string): Promise<SQLValidationResult>;
|
|
190
|
+
/**
|
|
191
|
+
* Execute a raw SQL query.
|
|
192
|
+
*
|
|
193
|
+
* Only SELECT statements are allowed. Queries are restricted
|
|
194
|
+
* to tables visible in the schema.
|
|
195
|
+
*
|
|
196
|
+
* @param sql - Raw SQL query (SELECT only).
|
|
197
|
+
* @param params - Optional named parameters for the query.
|
|
198
|
+
* @returns The query result with all rows.
|
|
199
|
+
*/
|
|
200
|
+
executeSQL(sql: string, params?: Record<string, unknown>): Promise<QueryResult>;
|
|
201
|
+
/**
|
|
202
|
+
* List all dashboards accessible to the current user.
|
|
203
|
+
*
|
|
204
|
+
* @returns Array of dashboards.
|
|
205
|
+
*/
|
|
206
|
+
listDashboards(): Promise<Dashboard[]>;
|
|
207
|
+
/**
|
|
208
|
+
* Get a specific dashboard by ID.
|
|
209
|
+
*
|
|
210
|
+
* @param id - The dashboard ID.
|
|
211
|
+
* @returns The dashboard with all widgets.
|
|
212
|
+
*/
|
|
213
|
+
getDashboard(id: string): Promise<Dashboard>;
|
|
214
|
+
/**
|
|
215
|
+
* Create a new dashboard.
|
|
216
|
+
*
|
|
217
|
+
* @param data - Dashboard creation data.
|
|
218
|
+
* @returns The created dashboard.
|
|
219
|
+
*/
|
|
220
|
+
createDashboard(data: DashboardCreate): Promise<Dashboard>;
|
|
221
|
+
/**
|
|
222
|
+
* Update an existing dashboard.
|
|
223
|
+
*
|
|
224
|
+
* @param id - The dashboard ID.
|
|
225
|
+
* @param data - Dashboard update data.
|
|
226
|
+
* @returns The updated dashboard.
|
|
227
|
+
*/
|
|
228
|
+
updateDashboard(id: string, data: DashboardUpdate): Promise<Dashboard>;
|
|
229
|
+
/**
|
|
230
|
+
* Delete a dashboard.
|
|
231
|
+
*
|
|
232
|
+
* @param id - The dashboard ID.
|
|
233
|
+
*/
|
|
234
|
+
deleteDashboard(id: string): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* Add a widget to a dashboard.
|
|
237
|
+
*
|
|
238
|
+
* @param dashboardId - The dashboard ID.
|
|
239
|
+
* @param data - Widget creation data.
|
|
240
|
+
* @returns The created widget.
|
|
241
|
+
*/
|
|
242
|
+
addWidget(dashboardId: string, data: WidgetCreate): Promise<Widget>;
|
|
243
|
+
/**
|
|
244
|
+
* Update a widget.
|
|
245
|
+
*
|
|
246
|
+
* @param dashboardId - The dashboard ID.
|
|
247
|
+
* @param widgetId - The widget ID.
|
|
248
|
+
* @param data - Widget update data.
|
|
249
|
+
* @returns The updated widget.
|
|
250
|
+
*/
|
|
251
|
+
updateWidget(dashboardId: string, widgetId: string, data: WidgetUpdate): Promise<Widget>;
|
|
252
|
+
/**
|
|
253
|
+
* Delete a widget from a dashboard.
|
|
254
|
+
*
|
|
255
|
+
* @param dashboardId - The dashboard ID.
|
|
256
|
+
* @param widgetId - The widget ID.
|
|
257
|
+
*/
|
|
258
|
+
deleteWidget(dashboardId: string, widgetId: string): Promise<void>;
|
|
259
|
+
/**
|
|
260
|
+
* Update the layout (positions) of multiple widgets.
|
|
261
|
+
*
|
|
262
|
+
* @param dashboardId - The dashboard ID.
|
|
263
|
+
* @param positions - Array of widget position updates.
|
|
264
|
+
* @returns The updated dashboard.
|
|
265
|
+
*/
|
|
266
|
+
updateLayout(dashboardId: string, positions: WidgetPositionUpdate[]): Promise<Dashboard>;
|
|
267
|
+
/**
|
|
268
|
+
* List all saved queries accessible to the current user.
|
|
269
|
+
*
|
|
270
|
+
* @returns Array of saved queries.
|
|
271
|
+
*/
|
|
272
|
+
listSavedQueries(): Promise<SavedQuery[]>;
|
|
273
|
+
/**
|
|
274
|
+
* Get a specific saved query by ID.
|
|
275
|
+
*
|
|
276
|
+
* @param id - The saved query ID.
|
|
277
|
+
* @returns The saved query.
|
|
278
|
+
*/
|
|
279
|
+
getSavedQuery(id: string): Promise<SavedQuery>;
|
|
280
|
+
/**
|
|
281
|
+
* Create a new saved query.
|
|
282
|
+
*
|
|
283
|
+
* @param data - Saved query creation data.
|
|
284
|
+
* @returns The created saved query.
|
|
285
|
+
*/
|
|
286
|
+
createSavedQuery(data: SavedQueryCreate): Promise<SavedQuery>;
|
|
287
|
+
/**
|
|
288
|
+
* Update an existing saved query.
|
|
289
|
+
*
|
|
290
|
+
* @param id - The saved query ID.
|
|
291
|
+
* @param data - Saved query update data.
|
|
292
|
+
* @returns The updated saved query.
|
|
293
|
+
*/
|
|
294
|
+
updateSavedQuery(id: string, data: SavedQueryUpdate): Promise<SavedQuery>;
|
|
295
|
+
/**
|
|
296
|
+
* Delete a saved query.
|
|
297
|
+
*
|
|
298
|
+
* @param id - The saved query ID.
|
|
299
|
+
*/
|
|
300
|
+
deleteSavedQuery(id: string): Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* Pin a dashboard to a context.
|
|
303
|
+
*
|
|
304
|
+
* @param dashboardId - The dashboard ID to pin.
|
|
305
|
+
* @param context - The context to pin to (e.g., "accounts", "dashboard").
|
|
306
|
+
* @param position - Optional position in the list (appends at end if not provided).
|
|
307
|
+
* @returns The created pin entry.
|
|
308
|
+
*/
|
|
309
|
+
pinDashboard(dashboardId: string, context: string, position?: number): Promise<PinnedDashboard>;
|
|
310
|
+
/**
|
|
311
|
+
* Unpin a dashboard from a context.
|
|
312
|
+
*
|
|
313
|
+
* @param dashboardId - The dashboard ID to unpin.
|
|
314
|
+
* @param context - The context to unpin from.
|
|
315
|
+
*/
|
|
316
|
+
unpinDashboard(dashboardId: string, context: string): Promise<void>;
|
|
317
|
+
/**
|
|
318
|
+
* Get all dashboards pinned to a context.
|
|
319
|
+
*
|
|
320
|
+
* @param context - The context to get pins for (e.g., "accounts", "dashboard").
|
|
321
|
+
* @returns Response with dashboards and pin metadata.
|
|
322
|
+
*/
|
|
323
|
+
getPinnedDashboards(context: string): Promise<PinnedDashboardsResponse>;
|
|
324
|
+
/**
|
|
325
|
+
* Get all contexts where a dashboard is pinned.
|
|
326
|
+
*
|
|
327
|
+
* @param dashboardId - The dashboard ID.
|
|
328
|
+
* @returns List of context names.
|
|
329
|
+
*/
|
|
330
|
+
getDashboardPinContexts(dashboardId: string): Promise<string[]>;
|
|
331
|
+
/**
|
|
332
|
+
* Reorder pinned dashboards within a context.
|
|
333
|
+
*
|
|
334
|
+
* @param context - The context to reorder pins in.
|
|
335
|
+
* @param dashboardIds - Ordered list of dashboard IDs (new order).
|
|
336
|
+
*/
|
|
337
|
+
reorderPins(context: string, dashboardIds: string[]): Promise<void>;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Default theme definitions for Prismiq.
|
|
342
|
+
*/
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Light theme - the default Prismiq theme.
|
|
346
|
+
*/
|
|
347
|
+
declare const lightTheme: PrismiqTheme;
|
|
348
|
+
/**
|
|
349
|
+
* Dark theme for Prismiq.
|
|
350
|
+
*/
|
|
351
|
+
declare const darkTheme: PrismiqTheme;
|
|
352
|
+
|
|
353
|
+
interface ThemeProviderProps {
|
|
354
|
+
/** Child components. */
|
|
355
|
+
children: ReactNode;
|
|
356
|
+
/** Initial theme mode. If not set, uses stored mode or system preference. */
|
|
357
|
+
defaultMode?: ThemeMode;
|
|
358
|
+
/** Custom theme overrides for light mode. */
|
|
359
|
+
lightTheme?: DeepPartial<PrismiqTheme>;
|
|
360
|
+
/** Custom theme overrides for dark mode. */
|
|
361
|
+
darkTheme?: DeepPartial<PrismiqTheme>;
|
|
362
|
+
/** Custom class name for the wrapper element. */
|
|
363
|
+
className?: string;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Theme provider that manages theme mode and injects CSS variables.
|
|
367
|
+
*
|
|
368
|
+
* @example
|
|
369
|
+
* ```tsx
|
|
370
|
+
* function App() {
|
|
371
|
+
* return (
|
|
372
|
+
* <ThemeProvider defaultMode="system">
|
|
373
|
+
* <Dashboard />
|
|
374
|
+
* </ThemeProvider>
|
|
375
|
+
* );
|
|
376
|
+
* }
|
|
377
|
+
* ```
|
|
378
|
+
*/
|
|
379
|
+
declare function ThemeProvider({ children, defaultMode, lightTheme: customLightTheme, darkTheme: customDarkTheme, className, }: ThemeProviderProps): JSX.Element;
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* useTheme hook.
|
|
383
|
+
*
|
|
384
|
+
* Provides access to the current theme and mode.
|
|
385
|
+
*/
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Hook to access the theme context.
|
|
389
|
+
*
|
|
390
|
+
* Must be used within a ThemeProvider.
|
|
391
|
+
*
|
|
392
|
+
* @throws Error if used outside of ThemeProvider.
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```tsx
|
|
396
|
+
* function ThemeToggle() {
|
|
397
|
+
* const { mode, setMode, resolvedMode } = useTheme();
|
|
398
|
+
*
|
|
399
|
+
* return (
|
|
400
|
+
* <button onClick={() => setMode(mode === 'dark' ? 'light' : 'dark')}>
|
|
401
|
+
* Current: {resolvedMode}
|
|
402
|
+
* </button>
|
|
403
|
+
* );
|
|
404
|
+
* }
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
declare function useTheme(): ThemeContextValue;
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Analytics Provider and Context.
|
|
411
|
+
*
|
|
412
|
+
* Provides the Prismiq client and schema to React components.
|
|
413
|
+
*/
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Value provided by the AnalyticsContext.
|
|
417
|
+
*/
|
|
418
|
+
interface AnalyticsContextValue {
|
|
419
|
+
/** The Prismiq API client instance. */
|
|
420
|
+
client: PrismiqClient;
|
|
421
|
+
/** The database schema, or null if not yet loaded. */
|
|
422
|
+
schema: DatabaseSchema | null;
|
|
423
|
+
/** Whether the schema is currently loading. */
|
|
424
|
+
isLoading: boolean;
|
|
425
|
+
/** Error that occurred during schema loading, if any. */
|
|
426
|
+
error: Error | null;
|
|
427
|
+
/** Function to manually refresh the schema. */
|
|
428
|
+
refetchSchema: () => Promise<void>;
|
|
429
|
+
/** Current tenant ID for multi-tenant isolation. */
|
|
430
|
+
tenantId: string;
|
|
431
|
+
/** Current user ID for ownership and permissions. */
|
|
432
|
+
userId?: string;
|
|
433
|
+
/** PostgreSQL schema name for per-tenant schema isolation. */
|
|
434
|
+
schemaName?: string;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Props for the AnalyticsProvider component.
|
|
438
|
+
*/
|
|
439
|
+
interface AnalyticsProviderProps {
|
|
440
|
+
/** Configuration for the Prismiq client. tenantId, userId, schemaName are provided via separate props. */
|
|
441
|
+
config: Omit<ClientConfig, 'tenantId' | 'userId' | 'schemaName'>;
|
|
442
|
+
/**
|
|
443
|
+
* Tenant ID for multi-tenant isolation.
|
|
444
|
+
* All API calls will include this in the X-Tenant-ID header.
|
|
445
|
+
* Required for production use.
|
|
446
|
+
*/
|
|
447
|
+
tenantId: string;
|
|
448
|
+
/**
|
|
449
|
+
* User ID for ownership and permissions.
|
|
450
|
+
* Included in X-User-ID header when provided.
|
|
451
|
+
* Used for dashboard ownership and access control.
|
|
452
|
+
*/
|
|
453
|
+
userId?: string;
|
|
454
|
+
/**
|
|
455
|
+
* PostgreSQL schema name for per-tenant schema isolation.
|
|
456
|
+
* Included in X-Schema-Name header when provided.
|
|
457
|
+
* Used when each tenant has their own PostgreSQL schema (e.g., "org_123").
|
|
458
|
+
*/
|
|
459
|
+
schemaName?: string;
|
|
460
|
+
/** Callback when a query is executed successfully. */
|
|
461
|
+
onQueryExecute?: (query: QueryDefinition, result: QueryResult) => void;
|
|
462
|
+
/** Callback when a query execution fails. */
|
|
463
|
+
onQueryError?: (query: QueryDefinition, error: Error) => void;
|
|
464
|
+
/** Callback when schema is loaded successfully. */
|
|
465
|
+
onSchemaLoad?: (schema: DatabaseSchema) => void;
|
|
466
|
+
/** Callback when schema loading fails. */
|
|
467
|
+
onSchemaError?: (error: Error) => void;
|
|
468
|
+
/** Child components that will have access to the analytics context. */
|
|
469
|
+
children: ReactNode;
|
|
470
|
+
}
|
|
471
|
+
interface AnalyticsCallbacks {
|
|
472
|
+
onQueryExecute?: (query: QueryDefinition, result: QueryResult) => void;
|
|
473
|
+
onQueryError?: (query: QueryDefinition, error: Error) => void;
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Hook to access analytics callbacks.
|
|
477
|
+
* For internal use by components that need to fire callbacks.
|
|
478
|
+
*/
|
|
479
|
+
declare function useAnalyticsCallbacks(): AnalyticsCallbacks;
|
|
480
|
+
declare function AnalyticsProvider({ config, tenantId, userId, schemaName, onQueryExecute, onQueryError, onSchemaLoad, onSchemaError, children, }: AnalyticsProviderProps): JSX.Element;
|
|
481
|
+
/**
|
|
482
|
+
* Hook to access the analytics context.
|
|
483
|
+
*
|
|
484
|
+
* Must be used within an AnalyticsProvider.
|
|
485
|
+
*
|
|
486
|
+
* @throws Error if used outside of AnalyticsProvider.
|
|
487
|
+
*
|
|
488
|
+
* @example
|
|
489
|
+
* ```tsx
|
|
490
|
+
* function Dashboard() {
|
|
491
|
+
* const { client, schema, isLoading, error } = useAnalytics();
|
|
492
|
+
*
|
|
493
|
+
* if (isLoading) return <Loading />;
|
|
494
|
+
* if (error) return <Error message={error.message} />;
|
|
495
|
+
*
|
|
496
|
+
* return <TableList tables={schema?.tables ?? []} />;
|
|
497
|
+
* }
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
500
|
+
declare function useAnalytics(): AnalyticsContextValue;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* useSchema hook.
|
|
504
|
+
*
|
|
505
|
+
* Provides convenient access to database schema with helper methods.
|
|
506
|
+
*/
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Result of the useSchema hook.
|
|
510
|
+
*/
|
|
511
|
+
interface UseSchemaResult {
|
|
512
|
+
/** The complete database schema, or null if not yet loaded. */
|
|
513
|
+
schema: DatabaseSchema | null;
|
|
514
|
+
/** List of tables in the schema. */
|
|
515
|
+
tables: TableSchema[];
|
|
516
|
+
/** List of relationships between tables. */
|
|
517
|
+
relationships: Relationship[];
|
|
518
|
+
/** Whether the schema is currently loading. */
|
|
519
|
+
isLoading: boolean;
|
|
520
|
+
/** Error that occurred during schema loading, if any. */
|
|
521
|
+
error: Error | null;
|
|
522
|
+
/** Get a table by name. */
|
|
523
|
+
getTable: (name: string) => TableSchema | undefined;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Hook for accessing the database schema.
|
|
527
|
+
*
|
|
528
|
+
* Provides the schema from the AnalyticsProvider context with
|
|
529
|
+
* convenient helper methods for working with tables.
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* ```tsx
|
|
533
|
+
* function TableExplorer() {
|
|
534
|
+
* const { tables, isLoading, getTable } = useSchema();
|
|
535
|
+
*
|
|
536
|
+
* if (isLoading) return <Loading />;
|
|
537
|
+
*
|
|
538
|
+
* const usersTable = getTable('users');
|
|
539
|
+
*
|
|
540
|
+
* return (
|
|
541
|
+
* <ul>
|
|
542
|
+
* {tables.map(table => (
|
|
543
|
+
* <li key={table.name}>{table.name}</li>
|
|
544
|
+
* ))}
|
|
545
|
+
* </ul>
|
|
546
|
+
* );
|
|
547
|
+
* }
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
declare function useSchema(): UseSchemaResult;
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* useQuery hook.
|
|
554
|
+
*
|
|
555
|
+
* Executes queries against the Prismiq backend with caching and cancellation.
|
|
556
|
+
*/
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Options for the useQuery hook.
|
|
560
|
+
*/
|
|
561
|
+
interface UseQueryOptions {
|
|
562
|
+
/**
|
|
563
|
+
* Whether the query should be executed.
|
|
564
|
+
* Set to false to disable automatic execution.
|
|
565
|
+
* @default true
|
|
566
|
+
*/
|
|
567
|
+
enabled?: boolean;
|
|
568
|
+
/**
|
|
569
|
+
* Whether to use the preview endpoint (limited results).
|
|
570
|
+
* @default false
|
|
571
|
+
*/
|
|
572
|
+
preview?: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Maximum number of rows to return when using preview.
|
|
575
|
+
* @default 100
|
|
576
|
+
*/
|
|
577
|
+
previewLimit?: number;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Result of the useQuery hook.
|
|
581
|
+
*/
|
|
582
|
+
interface UseQueryResult {
|
|
583
|
+
/** The query result data, or null if not yet loaded. */
|
|
584
|
+
data: QueryResult | null;
|
|
585
|
+
/** Whether the query is currently loading. */
|
|
586
|
+
isLoading: boolean;
|
|
587
|
+
/** Error that occurred during query execution, if any. */
|
|
588
|
+
error: Error | null;
|
|
589
|
+
/** Function to manually re-execute the query. */
|
|
590
|
+
refetch: () => Promise<void>;
|
|
591
|
+
}
|
|
592
|
+
/**
|
|
593
|
+
* Hook for executing queries against the Prismiq backend.
|
|
594
|
+
*
|
|
595
|
+
* The query is automatically executed when:
|
|
596
|
+
* - The query definition changes
|
|
597
|
+
* - enabled is true
|
|
598
|
+
* - The query is not null
|
|
599
|
+
*
|
|
600
|
+
* Supports cancellation when the component unmounts or the query changes.
|
|
601
|
+
*
|
|
602
|
+
* @param query - The query definition to execute, or null to skip.
|
|
603
|
+
* @param options - Configuration options.
|
|
604
|
+
*
|
|
605
|
+
* @example
|
|
606
|
+
* ```tsx
|
|
607
|
+
* function QueryResults() {
|
|
608
|
+
* const query: QueryDefinition = {
|
|
609
|
+
* tables: [{ id: 't1', name: 'users' }],
|
|
610
|
+
* columns: [
|
|
611
|
+
* { table_id: 't1', column: 'name', aggregation: 'none' },
|
|
612
|
+
* ],
|
|
613
|
+
* };
|
|
614
|
+
*
|
|
615
|
+
* const { data, isLoading, error } = useQuery(query, { preview: true });
|
|
616
|
+
*
|
|
617
|
+
* if (isLoading) return <Loading />;
|
|
618
|
+
* if (error) return <Error message={error.message} />;
|
|
619
|
+
*
|
|
620
|
+
* return (
|
|
621
|
+
* <table>
|
|
622
|
+
* <thead>
|
|
623
|
+
* <tr>
|
|
624
|
+
* {data?.columns.map(col => <th key={col}>{col}</th>)}
|
|
625
|
+
* </tr>
|
|
626
|
+
* </thead>
|
|
627
|
+
* <tbody>
|
|
628
|
+
* {data?.rows.map((row, i) => (
|
|
629
|
+
* <tr key={i}>
|
|
630
|
+
* {row.map((cell, j) => <td key={j}>{String(cell)}</td>)}
|
|
631
|
+
* </tr>
|
|
632
|
+
* ))}
|
|
633
|
+
* </tbody>
|
|
634
|
+
* </table>
|
|
635
|
+
* );
|
|
636
|
+
* }
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
declare function useQuery(query: QueryDefinition | null, options?: UseQueryOptions): UseQueryResult;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Hook for transforming QueryResult to chart-ready format.
|
|
643
|
+
*/
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Transforms a QueryResult into chart-ready data format.
|
|
647
|
+
*
|
|
648
|
+
* Features:
|
|
649
|
+
* - Extracts categories and series from query result
|
|
650
|
+
* - Supports grouping by column for multi-series
|
|
651
|
+
* - Sorting by X or Y values
|
|
652
|
+
* - Limiting number of data points
|
|
653
|
+
* - Memoized for performance
|
|
654
|
+
*
|
|
655
|
+
* @example
|
|
656
|
+
* ```tsx
|
|
657
|
+
* const { categories, series, isEmpty } = useChartData(queryResult, {
|
|
658
|
+
* xColumn: 'month',
|
|
659
|
+
* yColumns: ['revenue', 'cost'],
|
|
660
|
+
* sortBy: 'y',
|
|
661
|
+
* sortDirection: 'desc',
|
|
662
|
+
* limit: 10,
|
|
663
|
+
* });
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
declare function useChartData(result: QueryResult | null, options: ChartDataOptions): ChartDataResult;
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* useDashboards hook.
|
|
670
|
+
*
|
|
671
|
+
* Fetches and manages the list of dashboards from the Prismiq backend.
|
|
672
|
+
*/
|
|
673
|
+
|
|
674
|
+
/**
|
|
675
|
+
* Options for the useDashboards hook.
|
|
676
|
+
*/
|
|
677
|
+
interface UseDashboardsOptions {
|
|
678
|
+
/**
|
|
679
|
+
* Whether to automatically fetch dashboards on mount.
|
|
680
|
+
* @default true
|
|
681
|
+
*/
|
|
682
|
+
enabled?: boolean;
|
|
683
|
+
}
|
|
684
|
+
/**
|
|
685
|
+
* Result of the useDashboards hook.
|
|
686
|
+
*/
|
|
687
|
+
interface UseDashboardsResult {
|
|
688
|
+
/** The list of dashboards, or null if not yet loaded. */
|
|
689
|
+
data: Dashboard[] | null;
|
|
690
|
+
/** Whether the dashboards are currently loading. */
|
|
691
|
+
isLoading: boolean;
|
|
692
|
+
/** Error that occurred during fetch, if any. */
|
|
693
|
+
error: Error | null;
|
|
694
|
+
/** Function to manually refresh the dashboard list. */
|
|
695
|
+
refetch: () => Promise<void>;
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* Hook for fetching the list of dashboards.
|
|
699
|
+
*
|
|
700
|
+
* @param options - Configuration options.
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```tsx
|
|
704
|
+
* function DashboardList() {
|
|
705
|
+
* const { data, isLoading, error } = useDashboards();
|
|
706
|
+
*
|
|
707
|
+
* if (isLoading) return <Loading />;
|
|
708
|
+
* if (error) return <Error message={error.message} />;
|
|
709
|
+
*
|
|
710
|
+
* return (
|
|
711
|
+
* <ul>
|
|
712
|
+
* {data?.map(dashboard => (
|
|
713
|
+
* <li key={dashboard.id}>{dashboard.name}</li>
|
|
714
|
+
* ))}
|
|
715
|
+
* </ul>
|
|
716
|
+
* );
|
|
717
|
+
* }
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
720
|
+
declare function useDashboards(options?: UseDashboardsOptions): UseDashboardsResult;
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* useDashboard hook.
|
|
724
|
+
*
|
|
725
|
+
* Fetches a single dashboard by ID from the Prismiq backend.
|
|
726
|
+
*/
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Options for the useDashboard hook.
|
|
730
|
+
*/
|
|
731
|
+
interface UseDashboardOptions {
|
|
732
|
+
/**
|
|
733
|
+
* Whether to automatically fetch the dashboard on mount.
|
|
734
|
+
* @default true
|
|
735
|
+
*/
|
|
736
|
+
enabled?: boolean;
|
|
737
|
+
}
|
|
738
|
+
/**
|
|
739
|
+
* Result of the useDashboard hook.
|
|
740
|
+
*/
|
|
741
|
+
interface UseDashboardResult {
|
|
742
|
+
/** The dashboard data, or null if not yet loaded. */
|
|
743
|
+
data: Dashboard | null;
|
|
744
|
+
/** Whether the dashboard is currently loading. */
|
|
745
|
+
isLoading: boolean;
|
|
746
|
+
/** Error that occurred during fetch, if any. */
|
|
747
|
+
error: Error | null;
|
|
748
|
+
/** Function to manually refresh the dashboard. */
|
|
749
|
+
refetch: () => Promise<void>;
|
|
750
|
+
/**
|
|
751
|
+
* Optimistically update widget positions.
|
|
752
|
+
* Updates local state immediately without waiting for API.
|
|
753
|
+
*/
|
|
754
|
+
optimisticUpdatePositions: (positions: Record<string, WidgetPosition> | WidgetPositionUpdate[]) => void;
|
|
755
|
+
}
|
|
756
|
+
/**
|
|
757
|
+
* Hook for fetching a single dashboard by ID.
|
|
758
|
+
*
|
|
759
|
+
* @param dashboardId - The ID of the dashboard to fetch, or null to skip.
|
|
760
|
+
* @param options - Configuration options.
|
|
761
|
+
*
|
|
762
|
+
* @example
|
|
763
|
+
* ```tsx
|
|
764
|
+
* function DashboardView({ id }: { id: string }) {
|
|
765
|
+
* const { data, isLoading, error } = useDashboard(id);
|
|
766
|
+
*
|
|
767
|
+
* if (isLoading) return <Loading />;
|
|
768
|
+
* if (error) return <Error message={error.message} />;
|
|
769
|
+
* if (!data) return null;
|
|
770
|
+
*
|
|
771
|
+
* return (
|
|
772
|
+
* <div>
|
|
773
|
+
* <h1>{data.name}</h1>
|
|
774
|
+
* <p>{data.description}</p>
|
|
775
|
+
* {data.widgets.map(widget => (
|
|
776
|
+
* <Widget key={widget.id} widget={widget} />
|
|
777
|
+
* ))}
|
|
778
|
+
* </div>
|
|
779
|
+
* );
|
|
780
|
+
* }
|
|
781
|
+
* ```
|
|
782
|
+
*/
|
|
783
|
+
declare function useDashboard(dashboardId: string | null, options?: UseDashboardOptions): UseDashboardResult;
|
|
784
|
+
|
|
785
|
+
/**
|
|
786
|
+
* useDashboardMutations hook.
|
|
787
|
+
*
|
|
788
|
+
* Provides mutation functions for creating, updating, and deleting dashboards and widgets.
|
|
789
|
+
*/
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* State for a mutation operation.
|
|
793
|
+
*/
|
|
794
|
+
interface MutationState {
|
|
795
|
+
/** Whether a mutation is in progress. */
|
|
796
|
+
isLoading: boolean;
|
|
797
|
+
/** Error from the last mutation, if any. */
|
|
798
|
+
error: Error | null;
|
|
799
|
+
}
|
|
800
|
+
/**
|
|
801
|
+
* Result of the useDashboardMutations hook.
|
|
802
|
+
*/
|
|
803
|
+
interface UseDashboardMutationsResult {
|
|
804
|
+
/** Current mutation state. */
|
|
805
|
+
state: MutationState;
|
|
806
|
+
/** Create a new dashboard. */
|
|
807
|
+
createDashboard: (data: DashboardCreate) => Promise<Dashboard>;
|
|
808
|
+
/** Update an existing dashboard. */
|
|
809
|
+
updateDashboard: (id: string, data: DashboardUpdate) => Promise<Dashboard>;
|
|
810
|
+
/** Delete a dashboard. */
|
|
811
|
+
deleteDashboard: (id: string) => Promise<void>;
|
|
812
|
+
/** Add a widget to a dashboard. */
|
|
813
|
+
addWidget: (dashboardId: string, data: WidgetCreate) => Promise<Widget>;
|
|
814
|
+
/** Update a widget. */
|
|
815
|
+
updateWidget: (dashboardId: string, widgetId: string, data: WidgetUpdate) => Promise<Widget>;
|
|
816
|
+
/** Delete a widget. */
|
|
817
|
+
deleteWidget: (dashboardId: string, widgetId: string) => Promise<void>;
|
|
818
|
+
/** Update widget positions in a dashboard. */
|
|
819
|
+
updateLayout: (dashboardId: string, positions: WidgetPositionUpdate[]) => Promise<Dashboard>;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Hook for dashboard and widget mutations.
|
|
823
|
+
*
|
|
824
|
+
* All mutation functions return promises and update the shared loading/error state.
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* ```tsx
|
|
828
|
+
* function DashboardActions() {
|
|
829
|
+
* const { state, createDashboard, deleteDashboard } = useDashboardMutations();
|
|
830
|
+
* const { refetch } = useDashboards();
|
|
831
|
+
*
|
|
832
|
+
* const handleCreate = async () => {
|
|
833
|
+
* try {
|
|
834
|
+
* await createDashboard({ name: 'New Dashboard' });
|
|
835
|
+
* await refetch();
|
|
836
|
+
* } catch (error) {
|
|
837
|
+
* // Error is also available in state.error
|
|
838
|
+
* console.error('Failed to create dashboard:', error);
|
|
839
|
+
* }
|
|
840
|
+
* };
|
|
841
|
+
*
|
|
842
|
+
* return (
|
|
843
|
+
* <button onClick={handleCreate} disabled={state.isLoading}>
|
|
844
|
+
* {state.isLoading ? 'Creating...' : 'Create Dashboard'}
|
|
845
|
+
* </button>
|
|
846
|
+
* );
|
|
847
|
+
* }
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
declare function useDashboardMutations(): UseDashboardMutationsResult;
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* useSavedQueries hook.
|
|
854
|
+
*
|
|
855
|
+
* Fetches and manages saved queries from the Prismiq backend.
|
|
856
|
+
*/
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Options for the useSavedQueries hook.
|
|
860
|
+
*/
|
|
861
|
+
interface UseSavedQueriesOptions {
|
|
862
|
+
/**
|
|
863
|
+
* Whether to automatically fetch saved queries on mount.
|
|
864
|
+
* @default true
|
|
865
|
+
*/
|
|
866
|
+
enabled?: boolean;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Result of the useSavedQueries hook.
|
|
870
|
+
*/
|
|
871
|
+
interface UseSavedQueriesResult {
|
|
872
|
+
/** The list of saved queries, or null if not yet loaded. */
|
|
873
|
+
data: SavedQuery[] | null;
|
|
874
|
+
/** Whether the saved queries are currently loading. */
|
|
875
|
+
isLoading: boolean;
|
|
876
|
+
/** Error that occurred during fetch, if any. */
|
|
877
|
+
error: Error | null;
|
|
878
|
+
/** Function to manually refresh the saved query list. */
|
|
879
|
+
refetch: () => Promise<void>;
|
|
880
|
+
/** Function to create a new saved query. */
|
|
881
|
+
createQuery: (data: SavedQueryCreate) => Promise<SavedQuery>;
|
|
882
|
+
/** Function to update an existing saved query. */
|
|
883
|
+
updateQuery: (id: string, data: SavedQueryUpdate) => Promise<SavedQuery>;
|
|
884
|
+
/** Function to delete a saved query. */
|
|
885
|
+
deleteQuery: (id: string) => Promise<void>;
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Hook for fetching and managing saved queries.
|
|
889
|
+
*
|
|
890
|
+
* @param options - Configuration options.
|
|
891
|
+
*
|
|
892
|
+
* @example
|
|
893
|
+
* ```tsx
|
|
894
|
+
* function SavedQueryList() {
|
|
895
|
+
* const { data, isLoading, error, createQuery } = useSavedQueries();
|
|
896
|
+
*
|
|
897
|
+
* if (isLoading) return <Loading />;
|
|
898
|
+
* if (error) return <Error message={error.message} />;
|
|
899
|
+
*
|
|
900
|
+
* return (
|
|
901
|
+
* <ul>
|
|
902
|
+
* {data?.map(query => (
|
|
903
|
+
* <li key={query.id}>{query.name}</li>
|
|
904
|
+
* ))}
|
|
905
|
+
* </ul>
|
|
906
|
+
* );
|
|
907
|
+
* }
|
|
908
|
+
* ```
|
|
909
|
+
*/
|
|
910
|
+
declare function useSavedQueries(options?: UseSavedQueriesOptions): UseSavedQueriesResult;
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* useCustomSQL hook.
|
|
914
|
+
*
|
|
915
|
+
* Executes raw SQL queries against the Prismiq backend with validation.
|
|
916
|
+
*/
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* Options for the useCustomSQL hook.
|
|
920
|
+
*/
|
|
921
|
+
interface UseCustomSQLOptions {
|
|
922
|
+
/**
|
|
923
|
+
* Whether the query should be executed.
|
|
924
|
+
* Set to false to disable automatic execution.
|
|
925
|
+
* @default true
|
|
926
|
+
*/
|
|
927
|
+
enabled?: boolean;
|
|
928
|
+
/**
|
|
929
|
+
* Named parameters for the query.
|
|
930
|
+
*/
|
|
931
|
+
params?: Record<string, unknown>;
|
|
932
|
+
/**
|
|
933
|
+
* Whether to validate before executing.
|
|
934
|
+
* When true, validates first and only executes if valid.
|
|
935
|
+
* @default true
|
|
936
|
+
*/
|
|
937
|
+
validateFirst?: boolean;
|
|
938
|
+
}
|
|
939
|
+
/**
|
|
940
|
+
* Result of the useCustomSQL hook.
|
|
941
|
+
*/
|
|
942
|
+
interface UseCustomSQLResult {
|
|
943
|
+
/** The query result data, or null if not yet loaded. */
|
|
944
|
+
data: QueryResult | null;
|
|
945
|
+
/** Whether the query is currently loading. */
|
|
946
|
+
isLoading: boolean;
|
|
947
|
+
/** Error that occurred during query execution, if any. */
|
|
948
|
+
error: Error | null;
|
|
949
|
+
/** Validation result from the last validation check. */
|
|
950
|
+
validation: SQLValidationResult | null;
|
|
951
|
+
/** Whether the SQL is currently being validated. */
|
|
952
|
+
isValidating: boolean;
|
|
953
|
+
/** Function to manually re-execute the query. */
|
|
954
|
+
refetch: () => Promise<void>;
|
|
955
|
+
/** Function to manually validate the SQL without executing. */
|
|
956
|
+
validate: () => Promise<SQLValidationResult>;
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* Hook for executing raw SQL queries against the Prismiq backend.
|
|
960
|
+
*
|
|
961
|
+
* Only SELECT statements are allowed. Queries are restricted
|
|
962
|
+
* to tables visible in the schema.
|
|
963
|
+
*
|
|
964
|
+
* @param sql - The SQL query to execute, or null to skip.
|
|
965
|
+
* @param options - Configuration options.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```tsx
|
|
969
|
+
* function SQLResults() {
|
|
970
|
+
* const sql = "SELECT name, email FROM users WHERE status = 'active'";
|
|
971
|
+
* const { data, isLoading, error, validation } = useCustomSQL(sql);
|
|
972
|
+
*
|
|
973
|
+
* if (isLoading) return <Loading />;
|
|
974
|
+
* if (error) return <Error message={error.message} />;
|
|
975
|
+
* if (validation && !validation.valid) {
|
|
976
|
+
* return <ValidationErrors errors={validation.errors} />;
|
|
977
|
+
* }
|
|
978
|
+
*
|
|
979
|
+
* return (
|
|
980
|
+
* <table>
|
|
981
|
+
* <thead>
|
|
982
|
+
* <tr>
|
|
983
|
+
* {data?.columns.map(col => <th key={col}>{col}</th>)}
|
|
984
|
+
* </tr>
|
|
985
|
+
* </thead>
|
|
986
|
+
* <tbody>
|
|
987
|
+
* {data?.rows.map((row, i) => (
|
|
988
|
+
* <tr key={i}>
|
|
989
|
+
* {row.map((cell, j) => <td key={j}>{String(cell)}</td>)}
|
|
990
|
+
* </tr>
|
|
991
|
+
* ))}
|
|
992
|
+
* </tbody>
|
|
993
|
+
* </table>
|
|
994
|
+
* );
|
|
995
|
+
* }
|
|
996
|
+
* ```
|
|
997
|
+
*/
|
|
998
|
+
declare function useCustomSQL(sql: string | null, options?: UseCustomSQLOptions): UseCustomSQLResult;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* usePinnedDashboards hook.
|
|
1002
|
+
*
|
|
1003
|
+
* Fetches dashboards pinned to a specific context.
|
|
1004
|
+
*/
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* Options for the usePinnedDashboards hook.
|
|
1008
|
+
*/
|
|
1009
|
+
interface UsePinnedDashboardsOptions {
|
|
1010
|
+
/**
|
|
1011
|
+
* Context to get pinned dashboards for (e.g., "accounts", "dashboard").
|
|
1012
|
+
*/
|
|
1013
|
+
context: string;
|
|
1014
|
+
/**
|
|
1015
|
+
* Whether to automatically fetch on mount.
|
|
1016
|
+
* @default true
|
|
1017
|
+
*/
|
|
1018
|
+
enabled?: boolean;
|
|
1019
|
+
}
|
|
1020
|
+
/**
|
|
1021
|
+
* Result of the usePinnedDashboards hook.
|
|
1022
|
+
*/
|
|
1023
|
+
interface UsePinnedDashboardsResult {
|
|
1024
|
+
/** The list of pinned dashboards, or null if not yet loaded. */
|
|
1025
|
+
dashboards: Dashboard[] | null;
|
|
1026
|
+
/** Pin metadata for each dashboard. */
|
|
1027
|
+
pins: PinnedDashboard[] | null;
|
|
1028
|
+
/** Whether the data is currently loading. */
|
|
1029
|
+
isLoading: boolean;
|
|
1030
|
+
/** Error that occurred during fetch, if any. */
|
|
1031
|
+
error: Error | null;
|
|
1032
|
+
/** Function to manually refresh the pinned dashboards. */
|
|
1033
|
+
refetch: () => Promise<void>;
|
|
1034
|
+
}
|
|
1035
|
+
/**
|
|
1036
|
+
* Hook for fetching dashboards pinned to a context.
|
|
1037
|
+
*
|
|
1038
|
+
* @param options - Configuration options including the context.
|
|
1039
|
+
*
|
|
1040
|
+
* @example
|
|
1041
|
+
* ```tsx
|
|
1042
|
+
* function AccountsPinnedDashboards() {
|
|
1043
|
+
* const { dashboards, isLoading, error } = usePinnedDashboards({
|
|
1044
|
+
* context: 'accounts',
|
|
1045
|
+
* });
|
|
1046
|
+
*
|
|
1047
|
+
* if (isLoading) return <Loading />;
|
|
1048
|
+
* if (error) return <Error message={error.message} />;
|
|
1049
|
+
*
|
|
1050
|
+
* return (
|
|
1051
|
+
* <ul>
|
|
1052
|
+
* {dashboards?.map(d => (
|
|
1053
|
+
* <li key={d.id}>{d.name}</li>
|
|
1054
|
+
* ))}
|
|
1055
|
+
* </ul>
|
|
1056
|
+
* );
|
|
1057
|
+
* }
|
|
1058
|
+
* ```
|
|
1059
|
+
*/
|
|
1060
|
+
declare function usePinnedDashboards(options: UsePinnedDashboardsOptions): UsePinnedDashboardsResult;
|
|
1061
|
+
|
|
1062
|
+
/**
|
|
1063
|
+
* usePinMutations hook.
|
|
1064
|
+
*
|
|
1065
|
+
* Provides functions for pin/unpin/reorder operations.
|
|
1066
|
+
*/
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Mutation state for pin operations.
|
|
1070
|
+
*/
|
|
1071
|
+
interface PinMutationState {
|
|
1072
|
+
/** Whether a mutation is in progress. */
|
|
1073
|
+
isLoading: boolean;
|
|
1074
|
+
/** Error that occurred during the last mutation, if any. */
|
|
1075
|
+
error: Error | null;
|
|
1076
|
+
}
|
|
1077
|
+
/**
|
|
1078
|
+
* Result of the usePinMutations hook.
|
|
1079
|
+
*/
|
|
1080
|
+
interface UsePinMutationsResult {
|
|
1081
|
+
/** Current mutation state. */
|
|
1082
|
+
state: PinMutationState;
|
|
1083
|
+
/**
|
|
1084
|
+
* Pin a dashboard to a context.
|
|
1085
|
+
* @param dashboardId - Dashboard ID to pin.
|
|
1086
|
+
* @param context - Context to pin to (e.g., "accounts").
|
|
1087
|
+
* @param position - Optional position in the list.
|
|
1088
|
+
* @returns The created pin entry.
|
|
1089
|
+
*/
|
|
1090
|
+
pin: (dashboardId: string, context: string, position?: number) => Promise<PinnedDashboard>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Unpin a dashboard from a context.
|
|
1093
|
+
* @param dashboardId - Dashboard ID to unpin.
|
|
1094
|
+
* @param context - Context to unpin from.
|
|
1095
|
+
*/
|
|
1096
|
+
unpin: (dashboardId: string, context: string) => Promise<void>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Reorder pinned dashboards in a context.
|
|
1099
|
+
* @param context - Context to reorder pins in.
|
|
1100
|
+
* @param dashboardIds - Ordered list of dashboard IDs.
|
|
1101
|
+
*/
|
|
1102
|
+
reorder: (context: string, dashboardIds: string[]) => Promise<void>;
|
|
1103
|
+
/** Clear the error state. */
|
|
1104
|
+
clearError: () => void;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Hook for pin/unpin/reorder operations.
|
|
1108
|
+
*
|
|
1109
|
+
* @example
|
|
1110
|
+
* ```tsx
|
|
1111
|
+
* function PinButton({ dashboardId }: { dashboardId: string }) {
|
|
1112
|
+
* const { pin, unpin, state } = usePinMutations();
|
|
1113
|
+
* const [isPinned, setIsPinned] = useState(false);
|
|
1114
|
+
*
|
|
1115
|
+
* const handleClick = async () => {
|
|
1116
|
+
* if (isPinned) {
|
|
1117
|
+
* await unpin(dashboardId, 'accounts');
|
|
1118
|
+
* setIsPinned(false);
|
|
1119
|
+
* } else {
|
|
1120
|
+
* await pin(dashboardId, 'accounts');
|
|
1121
|
+
* setIsPinned(true);
|
|
1122
|
+
* }
|
|
1123
|
+
* };
|
|
1124
|
+
*
|
|
1125
|
+
* return (
|
|
1126
|
+
* <button onClick={handleClick} disabled={state.isLoading}>
|
|
1127
|
+
* {isPinned ? 'Unpin' : 'Pin'}
|
|
1128
|
+
* </button>
|
|
1129
|
+
* );
|
|
1130
|
+
* }
|
|
1131
|
+
* ```
|
|
1132
|
+
*/
|
|
1133
|
+
declare function usePinMutations(): UsePinMutationsResult;
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* useDashboardPinStatus hook.
|
|
1137
|
+
*
|
|
1138
|
+
* Fetches the pin status of a dashboard across contexts.
|
|
1139
|
+
*/
|
|
1140
|
+
/**
|
|
1141
|
+
* Options for the useDashboardPinStatus hook.
|
|
1142
|
+
*/
|
|
1143
|
+
interface UseDashboardPinStatusOptions {
|
|
1144
|
+
/**
|
|
1145
|
+
* Dashboard ID to check pin status for.
|
|
1146
|
+
*/
|
|
1147
|
+
dashboardId: string;
|
|
1148
|
+
/**
|
|
1149
|
+
* Optional list of contexts to filter results by.
|
|
1150
|
+
* When provided, pinnedContexts will only include contexts from this list.
|
|
1151
|
+
* This is useful when you only care about specific contexts.
|
|
1152
|
+
*/
|
|
1153
|
+
contexts?: string[];
|
|
1154
|
+
/**
|
|
1155
|
+
* Whether to automatically fetch on mount.
|
|
1156
|
+
* @default true
|
|
1157
|
+
*/
|
|
1158
|
+
enabled?: boolean;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Result of the useDashboardPinStatus hook.
|
|
1162
|
+
*/
|
|
1163
|
+
interface UseDashboardPinStatusResult {
|
|
1164
|
+
/** List of contexts where the dashboard is pinned, or null if not yet loaded. */
|
|
1165
|
+
pinnedContexts: string[] | null;
|
|
1166
|
+
/**
|
|
1167
|
+
* Check if the dashboard is pinned to a specific context.
|
|
1168
|
+
* @param context - Context to check.
|
|
1169
|
+
* @returns true if pinned to the context, false otherwise.
|
|
1170
|
+
*/
|
|
1171
|
+
isPinned: (context: string) => boolean;
|
|
1172
|
+
/** Whether the data is currently loading. */
|
|
1173
|
+
isLoading: boolean;
|
|
1174
|
+
/** Error that occurred during fetch, if any. */
|
|
1175
|
+
error: Error | null;
|
|
1176
|
+
/** Function to manually refresh the pin status. */
|
|
1177
|
+
refetch: () => Promise<void>;
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Hook for checking the pin status of a dashboard.
|
|
1181
|
+
*
|
|
1182
|
+
* @param options - Configuration options including the dashboard ID.
|
|
1183
|
+
*
|
|
1184
|
+
* @example
|
|
1185
|
+
* ```tsx
|
|
1186
|
+
* function DashboardPinMenu({ dashboardId }: { dashboardId: string }) {
|
|
1187
|
+
* const { pinnedContexts, isPinned, isLoading } = useDashboardPinStatus({
|
|
1188
|
+
* dashboardId,
|
|
1189
|
+
* });
|
|
1190
|
+
*
|
|
1191
|
+
* if (isLoading) return <Loading />;
|
|
1192
|
+
*
|
|
1193
|
+
* return (
|
|
1194
|
+
* <ul>
|
|
1195
|
+
* <li>
|
|
1196
|
+
* <Checkbox checked={isPinned('accounts')} />
|
|
1197
|
+
* Accounts
|
|
1198
|
+
* </li>
|
|
1199
|
+
* <li>
|
|
1200
|
+
* <Checkbox checked={isPinned('dashboard')} />
|
|
1201
|
+
* Dashboard
|
|
1202
|
+
* </li>
|
|
1203
|
+
* </ul>
|
|
1204
|
+
* );
|
|
1205
|
+
* }
|
|
1206
|
+
* ```
|
|
1207
|
+
*/
|
|
1208
|
+
declare function useDashboardPinStatus(options: UseDashboardPinStatusOptions): UseDashboardPinStatusResult;
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* PinButton component.
|
|
1212
|
+
*
|
|
1213
|
+
* A button to pin/unpin a dashboard to a specific context.
|
|
1214
|
+
*/
|
|
1215
|
+
|
|
1216
|
+
interface PinButtonProps {
|
|
1217
|
+
/** Dashboard ID to pin/unpin. */
|
|
1218
|
+
dashboardId: string;
|
|
1219
|
+
/** Context to pin to (e.g., "accounts", "dashboard"). */
|
|
1220
|
+
context: string;
|
|
1221
|
+
/** Label text (default: "Pin"). */
|
|
1222
|
+
label?: string;
|
|
1223
|
+
/** Label when pinned (default: "Unpin"). */
|
|
1224
|
+
unpinLabel?: string;
|
|
1225
|
+
/** Show as icon only (no label). */
|
|
1226
|
+
iconOnly?: boolean;
|
|
1227
|
+
/** Size variant. */
|
|
1228
|
+
size?: 'sm' | 'md' | 'lg';
|
|
1229
|
+
/** Called after pin/unpin completes. */
|
|
1230
|
+
onPinChange?: (isPinned: boolean) => void;
|
|
1231
|
+
/** Custom class name. */
|
|
1232
|
+
className?: string;
|
|
1233
|
+
/** Custom styles. */
|
|
1234
|
+
style?: CSSProperties;
|
|
1235
|
+
}
|
|
1236
|
+
/**
|
|
1237
|
+
* Button to pin/unpin a dashboard to a context.
|
|
1238
|
+
*
|
|
1239
|
+
* @example
|
|
1240
|
+
* ```tsx
|
|
1241
|
+
* // Basic usage
|
|
1242
|
+
* <PinButton dashboardId={dashboard.id} context="accounts" />
|
|
1243
|
+
*
|
|
1244
|
+
* // Icon only with custom label
|
|
1245
|
+
* <PinButton
|
|
1246
|
+
* dashboardId={dashboard.id}
|
|
1247
|
+
* context="dashboard"
|
|
1248
|
+
* iconOnly
|
|
1249
|
+
* onPinChange={(isPinned) => console.log('Pinned:', isPinned)}
|
|
1250
|
+
* />
|
|
1251
|
+
* ```
|
|
1252
|
+
*/
|
|
1253
|
+
declare function PinButton({ dashboardId, context, label, unpinLabel, iconOnly, size, onPinChange, className, style, }: PinButtonProps): ReactNode;
|
|
1254
|
+
|
|
1255
|
+
/**
|
|
1256
|
+
* PinMenu component.
|
|
1257
|
+
*
|
|
1258
|
+
* A dropdown menu showing multiple pin contexts with checkboxes.
|
|
1259
|
+
*/
|
|
1260
|
+
|
|
1261
|
+
/** Configuration for a pin context option. */
|
|
1262
|
+
interface PinContextOption {
|
|
1263
|
+
/** Unique context identifier (e.g., "accounts", "dashboard"). */
|
|
1264
|
+
id: string;
|
|
1265
|
+
/** Display label for the context. */
|
|
1266
|
+
label: string;
|
|
1267
|
+
/** Optional icon to display. */
|
|
1268
|
+
icon?: ReactNode;
|
|
1269
|
+
}
|
|
1270
|
+
interface PinMenuProps {
|
|
1271
|
+
/** Dashboard ID to pin/unpin. */
|
|
1272
|
+
dashboardId: string;
|
|
1273
|
+
/** Available contexts to pin to. */
|
|
1274
|
+
contexts: PinContextOption[];
|
|
1275
|
+
/** Called after pin state changes. */
|
|
1276
|
+
onPinChange?: (context: string, isPinned: boolean) => void;
|
|
1277
|
+
/** Custom class name. */
|
|
1278
|
+
className?: string;
|
|
1279
|
+
/** Custom styles. */
|
|
1280
|
+
style?: CSSProperties;
|
|
1281
|
+
}
|
|
1282
|
+
/**
|
|
1283
|
+
* Dropdown menu showing multiple pin contexts with checkboxes.
|
|
1284
|
+
*
|
|
1285
|
+
* @example
|
|
1286
|
+
* ```tsx
|
|
1287
|
+
* const PIN_CONTEXTS = [
|
|
1288
|
+
* { id: 'dashboard', label: 'Dashboard' },
|
|
1289
|
+
* { id: 'accounts', label: 'Accounts' },
|
|
1290
|
+
* ];
|
|
1291
|
+
*
|
|
1292
|
+
* <PinMenu
|
|
1293
|
+
* dashboardId={dashboard.id}
|
|
1294
|
+
* contexts={PIN_CONTEXTS}
|
|
1295
|
+
* onPinChange={(ctx, pinned) => console.log(ctx, pinned)}
|
|
1296
|
+
* />
|
|
1297
|
+
* ```
|
|
1298
|
+
*/
|
|
1299
|
+
declare function PinMenu({ dashboardId, contexts, onPinChange, className, style, }: PinMenuProps): ReactNode;
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* PinnedDashboardList component.
|
|
1303
|
+
*
|
|
1304
|
+
* Displays a list of dashboards pinned to a context.
|
|
1305
|
+
*/
|
|
1306
|
+
|
|
1307
|
+
/** Props for custom rendering of a list item. */
|
|
1308
|
+
interface PinnedDashboardItemActions {
|
|
1309
|
+
/** Unpin this dashboard from the context. Returns a promise. */
|
|
1310
|
+
unpin: () => Promise<void>;
|
|
1311
|
+
}
|
|
1312
|
+
interface PinnedDashboardListProps {
|
|
1313
|
+
/** Context to show pins for (e.g., "accounts", "dashboard"). */
|
|
1314
|
+
context: string;
|
|
1315
|
+
/** Called when user selects a dashboard. */
|
|
1316
|
+
onSelect: (dashboard: Dashboard) => void;
|
|
1317
|
+
/** Custom empty state element. */
|
|
1318
|
+
emptyState?: ReactNode;
|
|
1319
|
+
/** Custom render function for each item. */
|
|
1320
|
+
renderItem?: (dashboard: Dashboard, actions: PinnedDashboardItemActions) => ReactNode;
|
|
1321
|
+
/** Custom class name. */
|
|
1322
|
+
className?: string;
|
|
1323
|
+
/** Custom styles. */
|
|
1324
|
+
style?: CSSProperties;
|
|
1325
|
+
}
|
|
1326
|
+
/**
|
|
1327
|
+
* List of dashboards pinned to a context.
|
|
1328
|
+
*
|
|
1329
|
+
* @example
|
|
1330
|
+
* ```tsx
|
|
1331
|
+
* function AccountsDashboards() {
|
|
1332
|
+
* const [selected, setSelected] = useState<Dashboard | null>(null);
|
|
1333
|
+
*
|
|
1334
|
+
* return (
|
|
1335
|
+
* <PinnedDashboardList
|
|
1336
|
+
* context="accounts"
|
|
1337
|
+
* onSelect={setSelected}
|
|
1338
|
+
* emptyState={<p>No pinned dashboards</p>}
|
|
1339
|
+
* />
|
|
1340
|
+
* );
|
|
1341
|
+
* }
|
|
1342
|
+
* ```
|
|
1343
|
+
*/
|
|
1344
|
+
declare function PinnedDashboardList({ context, onSelect, emptyState, renderItem, className, style, }: PinnedDashboardListProps): ReactNode;
|
|
1345
|
+
|
|
1346
|
+
/**
|
|
1347
|
+
* PinnedDashboardView component.
|
|
1348
|
+
*
|
|
1349
|
+
* Full view with pinned dashboard list and selected dashboard display.
|
|
1350
|
+
*/
|
|
1351
|
+
|
|
1352
|
+
interface PinnedDashboardViewProps {
|
|
1353
|
+
/** Context this view is for (for unpin action). */
|
|
1354
|
+
context: string;
|
|
1355
|
+
/** Dashboard to display (null = show list). */
|
|
1356
|
+
selectedDashboard: Dashboard | null;
|
|
1357
|
+
/** Called when user clicks back or closes. */
|
|
1358
|
+
onBack: () => void;
|
|
1359
|
+
/** Called when user selects from list. */
|
|
1360
|
+
onSelect: (dashboard: Dashboard) => void;
|
|
1361
|
+
/** Show unpin button in header. */
|
|
1362
|
+
showUnpin?: boolean;
|
|
1363
|
+
/** Custom back button label. */
|
|
1364
|
+
backLabel?: string;
|
|
1365
|
+
/** Custom empty state for list. */
|
|
1366
|
+
emptyState?: ReactNode;
|
|
1367
|
+
/** Custom class name. */
|
|
1368
|
+
className?: string;
|
|
1369
|
+
/** Custom styles. */
|
|
1370
|
+
style?: CSSProperties;
|
|
1371
|
+
}
|
|
1372
|
+
/**
|
|
1373
|
+
* Full view with pinned dashboard list and dashboard display.
|
|
1374
|
+
*
|
|
1375
|
+
* When no dashboard is selected, shows the list. When a dashboard
|
|
1376
|
+
* is selected, shows the dashboard with a back button.
|
|
1377
|
+
*
|
|
1378
|
+
* @example
|
|
1379
|
+
* ```tsx
|
|
1380
|
+
* function AccountsDashboardSection() {
|
|
1381
|
+
* const [selected, setSelected] = useState<Dashboard | null>(null);
|
|
1382
|
+
*
|
|
1383
|
+
* return (
|
|
1384
|
+
* <PinnedDashboardView
|
|
1385
|
+
* context="accounts"
|
|
1386
|
+
* selectedDashboard={selected}
|
|
1387
|
+
* onSelect={setSelected}
|
|
1388
|
+
* onBack={() => setSelected(null)}
|
|
1389
|
+
* backLabel="Back to Accounts"
|
|
1390
|
+
* emptyState={<p>Pin dashboards from Analytics.</p>}
|
|
1391
|
+
* />
|
|
1392
|
+
* );
|
|
1393
|
+
* }
|
|
1394
|
+
* ```
|
|
1395
|
+
*/
|
|
1396
|
+
declare function PinnedDashboardView({ context, selectedDashboard, onBack, onSelect, showUnpin, backLabel, emptyState, className, style, }: PinnedDashboardViewProps): ReactNode;
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* @prismiq/react - React SDK for Prismiq embedded analytics
|
|
1400
|
+
*
|
|
1401
|
+
* @example
|
|
1402
|
+
* ```tsx
|
|
1403
|
+
* import {
|
|
1404
|
+
* AnalyticsProvider,
|
|
1405
|
+
* ThemeProvider,
|
|
1406
|
+
* QueryBuilder,
|
|
1407
|
+
* BarChart,
|
|
1408
|
+
* Dashboard,
|
|
1409
|
+
* useQuery
|
|
1410
|
+
* } from '@prismiq/react';
|
|
1411
|
+
*
|
|
1412
|
+
* function App() {
|
|
1413
|
+
* return (
|
|
1414
|
+
* <ThemeProvider>
|
|
1415
|
+
* <AnalyticsProvider config={{ endpoint: 'https://api.example.com' }}>
|
|
1416
|
+
* <Dashboard id="my-dashboard" />
|
|
1417
|
+
* </AnalyticsProvider>
|
|
1418
|
+
* </ThemeProvider>
|
|
1419
|
+
* );
|
|
1420
|
+
* }
|
|
1421
|
+
* ```
|
|
1422
|
+
*
|
|
1423
|
+
* For modular imports (smaller bundle size):
|
|
1424
|
+
* ```tsx
|
|
1425
|
+
* import { BarChart } from '@prismiq/react/charts';
|
|
1426
|
+
* import { Dashboard } from '@prismiq/react/dashboard';
|
|
1427
|
+
* import { useIsClient } from '@prismiq/react/ssr';
|
|
1428
|
+
* import { useFocusTrap } from '@prismiq/react/utils';
|
|
1429
|
+
* import { exportToCSV } from '@prismiq/react/export';
|
|
1430
|
+
* ```
|
|
1431
|
+
*/
|
|
1432
|
+
|
|
1433
|
+
declare const VERSION = "0.1.0";
|
|
1434
|
+
|
|
1435
|
+
export { type AnalyticsCallbacks, type AnalyticsContextValue, AnalyticsProvider, type AnalyticsProviderProps, ChartDataOptions, ChartDataResult, type ClientConfig, DashboardCreate, DashboardUpdate, DatabaseSchema, DeepPartial, type MutationState, PinButton, type PinButtonProps, type PinContextOption, PinMenu, type PinMenuProps, type PinMutationState, PinnedDashboard, type PinnedDashboardItemActions, PinnedDashboardList, type PinnedDashboardListProps, PinnedDashboardView, type PinnedDashboardViewProps, PinnedDashboardsResponse, PrismiqClient, PrismiqError, PrismiqTheme, QueryDefinition, QueryResult, Relationship, SQLValidationResult, SavedQuery, SavedQueryCreate, SavedQueryUpdate, TableSchema, ThemeContextValue, ThemeMode, ThemeProvider, type ThemeProviderProps, type UseCustomSQLOptions, type UseCustomSQLResult, type UseDashboardMutationsResult, type UseDashboardOptions, type UseDashboardPinStatusOptions, type UseDashboardPinStatusResult, type UseDashboardResult, type UseDashboardsOptions, type UseDashboardsResult, type UsePinMutationsResult, type UsePinnedDashboardsOptions, type UsePinnedDashboardsResult, type UseQueryOptions, type UseQueryResult, type UseSavedQueriesOptions, type UseSavedQueriesResult, type UseSchemaResult, VERSION, ValidationResult, darkTheme, lightTheme, useAnalytics, useAnalyticsCallbacks, useChartData, useCustomSQL, useDashboard as useDashboardData, useDashboardMutations, useDashboardPinStatus, useDashboards, usePinMutations, usePinnedDashboards, useQuery, useSavedQueries, useSchema, useTheme };
|