react-semaphor 0.0.146 → 0.0.147

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
+
@@ -184,8 +184,6 @@ declare type DashboardCardProps = {
184
184
  fetchCardData?: boolean;
185
185
  } & React_2.HTMLAttributes<HTMLDivElement>;
186
186
 
187
- export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
188
-
189
187
  declare type DashboardPlusProps = {
190
188
  showControls?: boolean;
191
189
  showFooter?: boolean;
@@ -231,8 +229,6 @@ export declare type DashboardStore = {
231
229
  actions: Actions;
232
230
  };
233
231
 
234
- export declare const DashboardWC: CustomElementConstructor;
235
-
236
232
  export declare const DATE_DATA_TYPES: string[];
237
233
 
238
234
  declare type EditorStore = {
@@ -414,6 +410,8 @@ export declare type StyleProps = {
414
410
  };
415
411
  };
416
412
 
413
+ export declare function Surfboard({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
414
+
417
415
  export declare type TBaseQuery = {
418
416
  id: string;
419
417
  name: string;
@@ -578,24 +576,8 @@ export declare function useCard(cardId: string): {
578
576
  cfg: TChartConfiguration | undefined;
579
577
  };
580
578
 
581
- export declare function useDashboard({ id, version, authToken, customStyle, currentTheme, onSave, onEvent, }: UseDashboardProps): {
582
- isLoading: boolean;
583
- isError: boolean;
584
- };
585
-
586
579
  export declare const useDashboardActions: () => Actions;
587
580
 
588
- declare type UseDashboardProps = {
589
- id: string;
590
- version?: string;
591
- authToken: AuthToken | undefined;
592
- customStyle?: TStyle;
593
- currentTheme?: 'light' | 'dark' | 'system';
594
- onSave?: (dashboard: TDashboard) => void;
595
- onEvent?: (event: TEvent) => void;
596
- customCards?: CustomCard[];
597
- };
598
-
599
581
  export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardStore>, "setState"> & {
600
582
  setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: {
601
583
  authToken?: {
@@ -0,0 +1,319 @@
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
+ declare type DashboardPlusProps = {
60
+ showControls?: boolean;
61
+ showFooter?: boolean;
62
+ } & DashboardProps;
63
+
64
+ export declare type DashboardProps = {
65
+ id: string;
66
+ authToken: AuthToken | undefined;
67
+ style?: TStyle;
68
+ currentTheme?: Theme;
69
+ version?: string;
70
+ customCards?: CustomCard[];
71
+ onChartElementClicked?: (card: TCard, fieldValues: any) => void;
72
+ onEvent?: (event: TEvent) => void;
73
+ onSave?: (dashboard: TDashboard) => void;
74
+ LoadingComponent?: (props: LoadingProps) => React.ReactNode;
75
+ ErrorComponent?: (props: ErrorProps) => React.ReactNode;
76
+ };
77
+
78
+ export declare type ErrorProps = {
79
+ message?: string;
80
+ };
81
+
82
+ declare type FilterForBetween = BaseFilter & {
83
+ operation: 'between' | 'not between';
84
+ values: [number, number];
85
+ };
86
+
87
+ declare type FilterForCompare = BaseFilter & {
88
+ operation: '>' | '<' | '>=' | '<=';
89
+ values: [number];
90
+ };
91
+
92
+ declare type FilterForDate = BaseFilter & {
93
+ operation: 'between' | 'not between';
94
+ values: [Date, Date];
95
+ };
96
+
97
+ declare type FilterForEqual = BaseFilter & {
98
+ operation: '=' | '!=' | 'is null' | 'is not null';
99
+ values: [string | number];
100
+ };
101
+
102
+ declare type FilterForIn = BaseFilter & {
103
+ operation: 'in' | 'not in';
104
+ values: (string | number)[];
105
+ };
106
+
107
+ declare type FilterForString = BaseFilter & {
108
+ operation: 'like' | 'not like';
109
+ values: [string];
110
+ };
111
+
112
+ declare type FilterOnClick = {
113
+ expression?: string;
114
+ columnIndex: number;
115
+ };
116
+
117
+ export declare type KPICardProps = {
118
+ card: TCard;
119
+ isLoading: boolean;
120
+ };
121
+
122
+ export declare type LoadingProps = {
123
+ message?: string;
124
+ };
125
+
126
+ declare type Operation = '=' | '>' | '<' | '>=' | '<=' | '!=' | 'in' | 'not in' | 'like' | 'not like' | 'between' | 'not between' | 'is null' | 'is not null';
127
+
128
+ declare type Params = {
129
+ [key: string]: string | number | string[] | number[];
130
+ };
131
+
132
+ export declare type SqlGen = {
133
+ measures?: {
134
+ name: string;
135
+ calc: AggregateCalc;
136
+ }[];
137
+ dimensions?: string[];
138
+ };
139
+
140
+ /**
141
+ * Style propeerites for the dashboard
142
+ */
143
+ export declare type StyleProps = {
144
+ /** css class for `dashboard-panel` */
145
+ dashboardPanel?: string;
146
+ /** css class for `dashboard-tabs-container` */
147
+ dashboardTabsContainer?: string;
148
+ /** css class for `dashboard-card` */
149
+ /** css class for `dashboard-card-container` */
150
+ dashboardCardContainer?: string;
151
+ dashboardCard?: string;
152
+ /** grid-layout config */
153
+ gridLayout?: {
154
+ /** css class for `react-grid-layout` */
155
+ className?: string;
156
+ margin?: [number, number];
157
+ };
158
+ /** chart config */
159
+ chart?: {
160
+ /** chart font config */
161
+ font?: Partial<FontSpec>;
162
+ dataset?: any;
163
+ /** chart options */
164
+ options?: any;
165
+ };
166
+ };
167
+
168
+ export declare function Surfboard({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
169
+
170
+ export declare type TBaseQuery = {
171
+ id: string;
172
+ name: string;
173
+ sql: string;
174
+ description?: string;
175
+ };
176
+
177
+ export declare type TCard = {
178
+ id: string;
179
+ title: string;
180
+ description?: string;
181
+ info?: string;
182
+ connectionId?: string;
183
+ type: TChartType;
184
+ sql?: string;
185
+ python?: string;
186
+ data?: any[];
187
+ cfg?: any;
188
+ customCfg?: any;
189
+ preferences?: TCardPreferences;
190
+ lastSelectedDatabase?: string;
191
+ lastSelectedSchema?: string;
192
+ lastSelectedTable?: string;
193
+ refreshInterval?: string;
194
+ };
195
+
196
+ export declare type TCardContext = {
197
+ id: string;
198
+ name: string;
199
+ description: string;
200
+ sql: string;
201
+ };
202
+
203
+ export declare type TCardPreferences = {
204
+ onClickFilter?: FilterOnClick[];
205
+ filterOnClick?: boolean;
206
+ filterOnClickField?: string;
207
+ filterOnClickColumnIndex?: number;
208
+ formatNumber?: {
209
+ format?: string;
210
+ currency?: string;
211
+ locale?: string;
212
+ suffix?: string;
213
+ enabled?: boolean | string;
214
+ };
215
+ datasetOptions?: TDatasetOptions[];
216
+ chartOptions?: TChartOptions;
217
+ };
218
+
219
+ export declare type TChartOptions = {
220
+ type?: TChartType;
221
+ scales?: {
222
+ y?: {
223
+ type: 'linear' | 'logarithmic';
224
+ min: number;
225
+ max: number;
226
+ ticks: {
227
+ stepSize: number;
228
+ };
229
+ };
230
+ x?: {
231
+ type: 'linear' | 'logarithmic';
232
+ min: number;
233
+ max: number;
234
+ ticks: {
235
+ stepSize: number;
236
+ };
237
+ };
238
+ };
239
+ indexAxis?: 'x' | 'y' | undefined;
240
+ };
241
+
242
+ declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi' | 'custom';
243
+
244
+ export declare type TDashboard = {
245
+ id: string;
246
+ title?: string;
247
+ description?: string;
248
+ sheets?: TSheet[];
249
+ style?: TStyle;
250
+ filters?: TFilter[];
251
+ customCards?: CustomCard[];
252
+ baseQueries?: TBaseQuery[];
253
+ };
254
+
255
+ export declare type TDataColumn = {
256
+ column_name: string;
257
+ data_type: string;
258
+ is_nullable?: string;
259
+ };
260
+
261
+ export declare type TDatasetOptions = {
262
+ idx: number;
263
+ type?: 'bar' | 'line';
264
+ fill?: string | number;
265
+ datalabels?: {
266
+ display?: boolean;
267
+ align?: string;
268
+ anchor?: string;
269
+ clamp?: boolean;
270
+ color?: string;
271
+ };
272
+ };
273
+
274
+ export declare type TEvent = {
275
+ type: 'success' | 'error' | 'info' | 'warning';
276
+ message: any;
277
+ };
278
+
279
+ declare type TFilter = {
280
+ id: string;
281
+ connectionId: string;
282
+ title: string;
283
+ column: string;
284
+ dataType: string;
285
+ table: string;
286
+ database: string;
287
+ sql: string;
288
+ operation: Operation;
289
+ };
290
+
291
+ declare type TFilterValue = FilterForString | FilterForEqual | FilterForCompare | FilterForBetween | FilterForIn | FilterForDate;
292
+
293
+ export declare type TFrame = {
294
+ id: string;
295
+ cards: TCard[];
296
+ activeCardId: string;
297
+ };
298
+
299
+ export declare type Theme = 'dark' | 'light' | 'system';
300
+
301
+ export declare type TSheet = {
302
+ id: string;
303
+ title?: string;
304
+ description?: string;
305
+ layout?: ReactGridLayout.Layout[];
306
+ layouts?: ReactGridLayout.Layouts;
307
+ cards?: TCard[];
308
+ frames?: TFrame[];
309
+ };
310
+
311
+ /**
312
+ * Style for the dashboard
313
+ */
314
+ export declare type TStyle = {
315
+ default: StyleProps;
316
+ dark?: StyleProps;
317
+ };
318
+
319
+ export { }