semaphor 0.0.44 → 0.0.46

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.
@@ -0,0 +1,314 @@
1
+ import { FontSpec } from 'chart.js';
2
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
3
+
4
+ export declare type AggregateCalc = 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'COUNT' | 'COUNT_DISTINCT';
5
+
6
+ export declare type AuthToken = {
7
+ accessToken: string;
8
+ refreshToken?: string;
9
+ };
10
+
11
+ declare type BaseCustomCard = {
12
+ cardId: string;
13
+ replaceDefault?: boolean;
14
+ };
15
+
16
+ declare type BaseFilter = {
17
+ filterId: TFilter['id'];
18
+ expression?: string;
19
+ name: string;
20
+ valueType: 'string' | 'number' | 'date' | 'boolean';
21
+ connectionType?: 'database' | 'api';
22
+ };
23
+
24
+ export declare type Bookmark = {
25
+ name: string;
26
+ default: boolean;
27
+ template: TDashboard;
28
+ filterValues?: TFilterValue[];
29
+ };
30
+
31
+ export declare type Breakpoint = 'lg' | 'md' | 'sm' | 'xs' | 'xxs';
32
+
33
+ declare type CardWithContent = BaseCustomCard & {
34
+ content: React.FC<{
35
+ card: TCard;
36
+ }>;
37
+ footer?: React.FC<{
38
+ card: TCard;
39
+ }>;
40
+ };
41
+
42
+ declare type CardWithFooter = BaseCustomCard & {
43
+ content?: React.FC<{
44
+ card: TCard;
45
+ }>;
46
+ footer: React.FC<{
47
+ card: TCard;
48
+ }>;
49
+ };
50
+
51
+ export declare type ConnectionPolicy = {
52
+ connectionId?: string;
53
+ name: string;
54
+ params: Params;
55
+ };
56
+
57
+ export declare type CustomCard = CardWithContent | CardWithFooter;
58
+
59
+ export declare function Dashboard(props: DashboardProps): JSX_2.Element;
60
+
61
+ export declare type DashboardProps = {
62
+ id?: string;
63
+ authToken: AuthToken | undefined;
64
+ style?: TStyle;
65
+ currentTheme?: Theme;
66
+ version?: string;
67
+ customCards?: CustomCard[];
68
+ onChartElementClicked?: (card: TCard, fieldValues: any) => void;
69
+ onEvent?: (event: TEvent) => void;
70
+ onSave?: (dashboard: TDashboard) => void;
71
+ LoadingComponent?: (props: LoadingProps) => React.ReactNode;
72
+ ErrorComponent?: (props: ErrorProps) => React.ReactNode;
73
+ };
74
+
75
+ export declare type ErrorProps = {
76
+ message?: string;
77
+ };
78
+
79
+ declare type FilterForBetween = BaseFilter & {
80
+ operation: 'between' | 'not between';
81
+ values: [number, number];
82
+ };
83
+
84
+ declare type FilterForCompare = BaseFilter & {
85
+ operation: '>' | '<' | '>=' | '<=';
86
+ values: [number];
87
+ };
88
+
89
+ declare type FilterForDate = BaseFilter & {
90
+ operation: 'between' | 'not between';
91
+ values: [Date, Date];
92
+ };
93
+
94
+ declare type FilterForEqual = BaseFilter & {
95
+ operation: '=' | '!=' | 'is null' | 'is not null';
96
+ values: [string | number];
97
+ };
98
+
99
+ declare type FilterForIn = BaseFilter & {
100
+ operation: 'in' | 'not in';
101
+ values: (string | number)[];
102
+ };
103
+
104
+ declare type FilterForString = BaseFilter & {
105
+ operation: 'like' | 'not like';
106
+ values: [string];
107
+ };
108
+
109
+ declare type FilterOnClick = {
110
+ expression?: string;
111
+ columnIndex: number;
112
+ };
113
+
114
+ export declare type KPICardProps = {
115
+ card: TCard;
116
+ isLoading: boolean;
117
+ };
118
+
119
+ export declare type LoadingProps = {
120
+ message?: string;
121
+ };
122
+
123
+ declare type Operation = '=' | '>' | '<' | '>=' | '<=' | '!=' | 'in' | 'not in' | 'like' | 'not like' | 'between' | 'not between' | 'is null' | 'is not null';
124
+
125
+ declare type Params = {
126
+ [key: string]: string | number | string[] | number[];
127
+ };
128
+
129
+ export declare type SqlGen = {
130
+ measures?: {
131
+ name: string;
132
+ calc: AggregateCalc;
133
+ }[];
134
+ dimensions?: string[];
135
+ };
136
+
137
+ /**
138
+ * Style propeerites for the dashboard
139
+ */
140
+ export declare type StyleProps = {
141
+ /** css class for `dashboard-panel` */
142
+ dashboardPanel?: string;
143
+ /** css class for `dashboard-tabs-container` */
144
+ dashboardTabsContainer?: string;
145
+ /** css class for `dashboard-card` */
146
+ /** css class for `dashboard-card-container` */
147
+ dashboardCardContainer?: string;
148
+ dashboardCard?: string;
149
+ /** grid-layout config */
150
+ gridLayout?: {
151
+ /** css class for `react-grid-layout` */
152
+ className?: string;
153
+ margin?: [number, number];
154
+ };
155
+ /** chart config */
156
+ chart?: {
157
+ /** chart font config */
158
+ font?: Partial<FontSpec>;
159
+ dataset?: any;
160
+ /** chart options */
161
+ options?: any;
162
+ };
163
+ };
164
+
165
+ export declare type TBaseQuery = {
166
+ id: string;
167
+ name: string;
168
+ sql: string;
169
+ description?: string;
170
+ };
171
+
172
+ export declare type TCard = {
173
+ id: string;
174
+ title: string;
175
+ description?: string;
176
+ info?: string;
177
+ connectionId?: string;
178
+ type: TChartType;
179
+ sql?: string;
180
+ python?: string;
181
+ data?: any[];
182
+ cfg?: any;
183
+ customCfg?: any;
184
+ preferences?: TCardPreferences;
185
+ lastSelectedDatabase?: string;
186
+ lastSelectedSchema?: string;
187
+ lastSelectedTable?: string;
188
+ refreshInterval?: string;
189
+ };
190
+
191
+ export declare type TCardContext = {
192
+ id: string;
193
+ name: string;
194
+ description: string;
195
+ sql: string;
196
+ };
197
+
198
+ export declare type TCardPreferences = {
199
+ onClickFilter?: FilterOnClick[];
200
+ filterOnClick?: boolean;
201
+ filterOnClickField?: string;
202
+ filterOnClickColumnIndex?: number;
203
+ formatNumber?: {
204
+ format?: string;
205
+ currency?: string;
206
+ locale?: string;
207
+ suffix?: string;
208
+ enabled?: boolean | string;
209
+ };
210
+ datasetOptions?: TDatasetOptions[];
211
+ chartOptions?: TChartOptions;
212
+ };
213
+
214
+ export declare type TChartOptions = {
215
+ type?: TChartType;
216
+ scales?: {
217
+ y?: {
218
+ type: 'linear' | 'logarithmic';
219
+ min: number;
220
+ max: number;
221
+ ticks: {
222
+ stepSize: number;
223
+ };
224
+ };
225
+ x?: {
226
+ type: 'linear' | 'logarithmic';
227
+ min: number;
228
+ max: number;
229
+ ticks: {
230
+ stepSize: number;
231
+ };
232
+ };
233
+ };
234
+ indexAxis?: 'x' | 'y' | undefined;
235
+ };
236
+
237
+ declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi' | 'custom';
238
+
239
+ export declare type TDashboard = {
240
+ id: string;
241
+ title?: string;
242
+ description?: string;
243
+ sheets?: TSheet[];
244
+ style?: TStyle;
245
+ filters?: TFilter[];
246
+ customCards?: CustomCard[];
247
+ baseQueries?: TBaseQuery[];
248
+ };
249
+
250
+ export declare type TDataColumn = {
251
+ column_name: string;
252
+ data_type: string;
253
+ is_nullable?: string;
254
+ };
255
+
256
+ export declare type TDatasetOptions = {
257
+ idx: number;
258
+ type?: 'bar' | 'line';
259
+ fill?: string | number;
260
+ datalabels?: {
261
+ display?: boolean;
262
+ align?: string;
263
+ anchor?: string;
264
+ clamp?: boolean;
265
+ color?: string;
266
+ };
267
+ };
268
+
269
+ export declare type TEvent = {
270
+ type: 'success' | 'error' | 'info' | 'warning';
271
+ message: any;
272
+ };
273
+
274
+ declare type TFilter = {
275
+ id: string;
276
+ connectionId: string;
277
+ title: string;
278
+ column: string;
279
+ dataType: string;
280
+ table: string;
281
+ database: string;
282
+ sql: string;
283
+ operation: Operation;
284
+ };
285
+
286
+ declare type TFilterValue = FilterForString | FilterForEqual | FilterForCompare | FilterForBetween | FilterForIn | FilterForDate;
287
+
288
+ export declare type TFrame = {
289
+ id: string;
290
+ cards: TCard[];
291
+ activeCardId: string;
292
+ };
293
+
294
+ export declare type Theme = 'dark' | 'light' | 'system';
295
+
296
+ export declare type TSheet = {
297
+ id: string;
298
+ title?: string;
299
+ description?: string;
300
+ layout?: ReactGridLayout.Layout[];
301
+ layouts?: ReactGridLayout.Layouts;
302
+ cards?: TCard[];
303
+ frames?: TFrame[];
304
+ };
305
+
306
+ /**
307
+ * Style for the dashboard
308
+ */
309
+ export declare type TStyle = {
310
+ default: StyleProps;
311
+ dark?: StyleProps;
312
+ };
313
+
314
+ export { }
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1 @@
1
+
@@ -2,7 +2,6 @@ import { BubbleDataPoint } from 'chart.js';
2
2
  import { Chart } from 'chart.js';
3
3
  import { ChartConfiguration } from 'chart.js';
4
4
  import { ChartTypeRegistry } from 'chart.js';
5
- import { Draft } from 'immer';
6
5
  import { FC } from 'react';
7
6
  import { FontSpec } from 'chart.js';
8
7
  import { JSX as JSX_2 } from 'react/jsx-runtime';
@@ -15,6 +14,7 @@ import { StoreApi } from 'zustand';
15
14
  import { UseBoundStore } from 'zustand';
16
15
 
17
16
  declare type Actions = {
17
+ setIsSessionExpired: (isSessionExpired: boolean) => void;
18
18
  setCurrentBreakpoint: (breakpoint: Breakpoint) => void;
19
19
  addFilteringCard: (card: TCard) => void;
20
20
  removeFilteringCard: (card: TCard) => void;
@@ -117,7 +117,7 @@ export declare type AggregateCalc = 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'COUNT' | 'C
117
117
 
118
118
  export declare type AuthToken = {
119
119
  accessToken: string;
120
- refreshToken: string;
120
+ refreshToken?: string;
121
121
  };
122
122
 
123
123
  declare type BaseCustomCard = {
@@ -185,18 +185,16 @@ declare type DashboardCardProps = {
185
185
  fetchCardData?: boolean;
186
186
  } & React_2.HTMLAttributes<HTMLDivElement>;
187
187
 
188
- export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
189
-
190
188
  declare type DashboardPlusProps = {
191
189
  showControls?: boolean;
192
190
  showFooter?: boolean;
193
191
  } & DashboardProps;
194
192
 
195
193
  export declare type DashboardProps = {
196
- id: string;
194
+ id?: string;
197
195
  authToken: AuthToken | undefined;
198
196
  style?: TStyle;
199
- currentTheme?: 'light' | 'dark' | 'system';
197
+ currentTheme?: Theme;
200
198
  version?: string;
201
199
  customCards?: CustomCard[];
202
200
  onChartElementClicked?: (card: TCard, fieldValues: any) => void;
@@ -206,11 +204,8 @@ export declare type DashboardProps = {
206
204
  ErrorComponent?: (props: ErrorProps) => React.ReactNode;
207
205
  };
208
206
 
209
- export declare function DashboardProvider({ children }: {
210
- children: React_2.ReactNode;
211
- }): JSX_2.Element;
212
-
213
207
  export declare type DashboardStore = {
208
+ isSessionExpired: boolean;
214
209
  authToken?: AuthToken;
215
210
  currentBreakpoint: Breakpoint;
216
211
  theme?: 'light' | 'dark' | 'system';
@@ -343,6 +338,11 @@ export declare function getSql(config: SqlGen, schemaName: string, tableName: st
343
338
 
344
339
  export declare function isColumnInSqlGen(column: TDataColumn, sqlGen: SqlGen): boolean | undefined;
345
340
 
341
+ export declare type KPICardProps = {
342
+ card: TCard;
343
+ isLoading: boolean;
344
+ };
345
+
346
346
  export declare type LoadingProps = {
347
347
  message?: string;
348
348
  };
@@ -355,8 +355,6 @@ declare type Params = {
355
355
  [key: string]: string | number | string[] | number[];
356
356
  };
357
357
 
358
- export declare const PYTHON_DEFAULT_CODE = "import pandas as pd\ndf = pd.DataFrame(data) # 'data' contains the query result\nresult = df.to_dict('records') # must return 'result' as [dict] type\n";
359
-
360
358
  export declare const resolveDataType: (value: any) => string;
361
359
 
362
360
  export declare function SelectComponent({ title, items, value, isLoading, isError, connectionTooltip, onChange, className, showIcon, }: SelectProps): JSX_2.Element;
@@ -416,6 +414,8 @@ export declare type StyleProps = {
416
414
  };
417
415
  };
418
416
 
417
+ export declare function Surfboard({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
418
+
419
419
  export declare type TBaseQuery = {
420
420
  id: string;
421
421
  name: string;
@@ -549,6 +549,8 @@ export declare type TFrame = {
549
549
  activeCardId: string;
550
550
  };
551
551
 
552
+ export declare type Theme = 'dark' | 'light' | 'system';
553
+
552
554
  export declare type TSheet = {
553
555
  id: string;
554
556
  title?: string;
@@ -567,15 +569,6 @@ export declare type TStyle = {
567
569
  dark?: StyleProps;
568
570
  };
569
571
 
570
- export declare function useActions(): {
571
- getStyle: () => TStyle | undefined;
572
- getDashboard: () => TDashboard | undefined;
573
- setOnSaveFunction: (onSaveFunction: (dashboard: TDashboard) => void) => void;
574
- setOnAddCard: (onAddCard: (card: TCard, sheetId: string) => void) => void;
575
- setOnUpateCard: (onUpdateCard: (card: TCard, sheetId: string) => void) => void;
576
- setOnRemoveCard: (onRemoveCard: (card: TCard, sheetId: string) => void) => void;
577
- };
578
-
579
572
  export declare function useCard(cardId: string): {
580
573
  data: any;
581
574
  card: TCard;
@@ -587,32 +580,17 @@ export declare function useCard(cardId: string): {
587
580
  cfg: TChartConfiguration | undefined;
588
581
  };
589
582
 
590
- export declare function useDashboard({ id, version, authToken, customStyle, currentTheme, onSave, onEvent, }: UseDashboardProps): {
591
- isLoading: boolean;
592
- isError: boolean;
593
- };
594
-
595
583
  export declare const useDashboardActions: () => Actions;
596
584
 
597
- declare type UseDashboardProps = {
598
- id: string;
599
- version?: string;
600
- authToken: AuthToken | undefined;
601
- customStyle?: TStyle;
602
- currentTheme?: 'light' | 'dark' | 'system';
603
- onSave?: (dashboard: TDashboard) => void;
604
- onEvent?: (event: TEvent) => void;
605
- customCards?: CustomCard[];
606
- };
607
-
608
585
  export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardStore>, "setState"> & {
609
586
  setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: {
587
+ isSessionExpired: boolean;
610
588
  authToken?: {
611
589
  accessToken: string;
612
- refreshToken: string;
590
+ refreshToken?: string | undefined;
613
591
  } | undefined;
614
592
  currentBreakpoint: Breakpoint;
615
- theme?: "light" | "dark" | "system" | undefined;
593
+ theme?: "dark" | "light" | "system" | undefined;
616
594
  themeStyle?: {
617
595
  dashboardPanel?: string | undefined;
618
596
  dashboardTabsContainer?: string | undefined;
@@ -724,7 +702,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
724
702
  static?: boolean | undefined;
725
703
  isDraggable?: boolean | undefined;
726
704
  isResizable?: boolean | undefined;
727
- resizeHandles?: ("s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
705
+ resizeHandles?: ("w" | "s" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
728
706
  isBounded?: boolean | undefined;
729
707
  }[] | undefined;
730
708
  layouts?: {
@@ -742,7 +720,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
742
720
  static?: boolean | undefined;
743
721
  isDraggable?: boolean | undefined;
744
722
  isResizable?: boolean | undefined;
745
- resizeHandles?: ("s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
723
+ resizeHandles?: ("w" | "s" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
746
724
  isBounded?: boolean | undefined;
747
725
  }[];
748
726
  } | undefined;
@@ -1096,6 +1074,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
1096
1074
  onUpdateCard?: ((card: TCard, sheetId: string) => void) | undefined;
1097
1075
  onRemoveCard?: ((card: TCard, sheetId: string) => void) | undefined;
1098
1076
  actions: {
1077
+ setIsSessionExpired: (isSessionExpired: boolean) => void;
1099
1078
  setCurrentBreakpoint: (breakpoint: Breakpoint) => void;
1100
1079
  addFilteringCard: (card: TCard) => void;
1101
1080
  removeFilteringCard: (card: TCard) => void;
@@ -1175,7 +1154,8 @@ export declare function useEditorAside(token?: AuthToken, _connectionQueryKey?:
1175
1154
  columns: TDataColumn[];
1176
1155
  isColumnsLoadingOrFetching: boolean;
1177
1156
  isColumnsError: boolean;
1178
- isAPIConnection: boolean;
1157
+ isNonDbConnection: boolean;
1158
+ connectionType: any;
1179
1159
  tableName: any;
1180
1160
  schemaName: string;
1181
1161
  handleConnectionChange: (value: string) => void;
@@ -1443,8 +1423,4 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
1443
1423
  }) => void), shouldReplace?: boolean | undefined): void;
1444
1424
  }>;
1445
1425
 
1446
- export declare type WritableDraft<T> = {
1447
- -readonly [K in keyof T]: Draft<T[K]>;
1448
- };
1449
-
1450
1426
  export { }