semaphor 0.0.43 → 0.0.45

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';
@@ -185,8 +184,6 @@ declare type DashboardCardProps = {
185
184
  fetchCardData?: boolean;
186
185
  } & React_2.HTMLAttributes<HTMLDivElement>;
187
186
 
188
- export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
189
-
190
187
  declare type DashboardPlusProps = {
191
188
  showControls?: boolean;
192
189
  showFooter?: boolean;
@@ -196,7 +193,7 @@ export declare type DashboardProps = {
196
193
  id: string;
197
194
  authToken: AuthToken | undefined;
198
195
  style?: TStyle;
199
- currentTheme?: 'light' | 'dark' | 'system';
196
+ currentTheme?: Theme;
200
197
  version?: string;
201
198
  customCards?: CustomCard[];
202
199
  onChartElementClicked?: (card: TCard, fieldValues: any) => void;
@@ -206,10 +203,6 @@ export declare type DashboardProps = {
206
203
  ErrorComponent?: (props: ErrorProps) => React.ReactNode;
207
204
  };
208
205
 
209
- export declare function DashboardProvider({ children }: {
210
- children: React_2.ReactNode;
211
- }): JSX_2.Element;
212
-
213
206
  export declare type DashboardStore = {
214
207
  authToken?: AuthToken;
215
208
  currentBreakpoint: Breakpoint;
@@ -343,6 +336,11 @@ export declare function getSql(config: SqlGen, schemaName: string, tableName: st
343
336
 
344
337
  export declare function isColumnInSqlGen(column: TDataColumn, sqlGen: SqlGen): boolean | undefined;
345
338
 
339
+ export declare type KPICardProps = {
340
+ card: TCard;
341
+ isLoading: boolean;
342
+ };
343
+
346
344
  export declare type LoadingProps = {
347
345
  message?: string;
348
346
  };
@@ -355,8 +353,6 @@ declare type Params = {
355
353
  [key: string]: string | number | string[] | number[];
356
354
  };
357
355
 
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
356
  export declare const resolveDataType: (value: any) => string;
361
357
 
362
358
  export declare function SelectComponent({ title, items, value, isLoading, isError, connectionTooltip, onChange, className, showIcon, }: SelectProps): JSX_2.Element;
@@ -416,6 +412,8 @@ export declare type StyleProps = {
416
412
  };
417
413
  };
418
414
 
415
+ export declare function Surfboard({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
416
+
419
417
  export declare type TBaseQuery = {
420
418
  id: string;
421
419
  name: string;
@@ -549,6 +547,8 @@ export declare type TFrame = {
549
547
  activeCardId: string;
550
548
  };
551
549
 
550
+ export declare type Theme = 'dark' | 'light' | 'system';
551
+
552
552
  export declare type TSheet = {
553
553
  id: string;
554
554
  title?: string;
@@ -567,15 +567,6 @@ export declare type TStyle = {
567
567
  dark?: StyleProps;
568
568
  };
569
569
 
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
570
  export declare function useCard(cardId: string): {
580
571
  data: any;
581
572
  card: TCard;
@@ -587,24 +578,8 @@ export declare function useCard(cardId: string): {
587
578
  cfg: TChartConfiguration | undefined;
588
579
  };
589
580
 
590
- export declare function useDashboard({ id, version, authToken, customStyle, currentTheme, onSave, onEvent, }: UseDashboardProps): {
591
- isLoading: boolean;
592
- isError: boolean;
593
- };
594
-
595
581
  export declare const useDashboardActions: () => Actions;
596
582
 
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
583
  export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardStore>, "setState"> & {
609
584
  setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: {
610
585
  authToken?: {
@@ -612,7 +587,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
612
587
  refreshToken: string;
613
588
  } | undefined;
614
589
  currentBreakpoint: Breakpoint;
615
- theme?: "light" | "dark" | "system" | undefined;
590
+ theme?: "dark" | "light" | "system" | undefined;
616
591
  themeStyle?: {
617
592
  dashboardPanel?: string | undefined;
618
593
  dashboardTabsContainer?: string | undefined;
@@ -724,7 +699,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
724
699
  static?: boolean | undefined;
725
700
  isDraggable?: boolean | undefined;
726
701
  isResizable?: boolean | undefined;
727
- resizeHandles?: ("s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
702
+ resizeHandles?: ("w" | "s" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
728
703
  isBounded?: boolean | undefined;
729
704
  }[] | undefined;
730
705
  layouts?: {
@@ -742,7 +717,7 @@ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardSto
742
717
  static?: boolean | undefined;
743
718
  isDraggable?: boolean | undefined;
744
719
  isResizable?: boolean | undefined;
745
- resizeHandles?: ("s" | "w" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
720
+ resizeHandles?: ("w" | "s" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
746
721
  isBounded?: boolean | undefined;
747
722
  }[];
748
723
  } | undefined;
@@ -1175,7 +1150,8 @@ export declare function useEditorAside(token?: AuthToken, _connectionQueryKey?:
1175
1150
  columns: TDataColumn[];
1176
1151
  isColumnsLoadingOrFetching: boolean;
1177
1152
  isColumnsError: boolean;
1178
- isAPIConnection: boolean;
1153
+ isNonDbConnection: boolean;
1154
+ connectionType: any;
1179
1155
  tableName: any;
1180
1156
  schemaName: string;
1181
1157
  handleConnectionChange: (value: string) => void;
@@ -1443,8 +1419,4 @@ export declare const useEditorStore: UseBoundStore<Omit<StoreApi<EditorStore>, "
1443
1419
  }) => void), shouldReplace?: boolean | undefined): void;
1444
1420
  }>;
1445
1421
 
1446
- export declare type WritableDraft<T> = {
1447
- -readonly [K in keyof T]: Draft<T[K]>;
1448
- };
1449
-
1450
1422
  export { }