semaphor 0.0.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 ADDED
File without changes
@@ -0,0 +1,519 @@
1
+ /// <reference types="react-grid-layout" />
2
+
3
+ import { FontSpec } from 'chart.js';
4
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
5
+ import { Layout } from 'react-grid-layout';
6
+ import { StoreApi } from 'zustand';
7
+ import { UseBoundStore } from 'zustand';
8
+
9
+ declare type Actions = {
10
+ setAuthToken: (authToken: AuthToken) => void;
11
+ setThemeStyle: (themeStyle: StyleProps) => void;
12
+ setIsEditorSaveEvent: (isEditorSaveEvent: boolean) => void;
13
+ setDashboard: (dashboard: TDashboard) => void;
14
+ setDashboardTheme: (theme: 'light' | 'dark' | 'system') => void;
15
+ setDashboardTitle: (title: string) => void;
16
+ setDashboardDescription: (description: string) => void;
17
+ setSheets: (sheets: TSheet[]) => void;
18
+ setSheetTitle: (sheetId: string, title: string) => void;
19
+ setSheetDescription: (sheetId: string, description: string) => void;
20
+ setSelectedSheetId: (sheetId: string | null) => void;
21
+ setSheetLayout: (sheetId: string, layout: ReactGridLayout.Layout[]) => void;
22
+ setCards: (sheetId: string, cards: TCard[]) => void;
23
+ setSelectedCardId: (sheetId: string, cardId: string | null) => void;
24
+ setSelectedCard: (card: TCard | null) => void;
25
+ setCardTitle: (sheetId: string, cardId: string, title: string) => void;
26
+ setCardSql: (sheetId: string, cardId: string, sql: string) => void;
27
+ setCardDescription: (sheetId: string, cardId: string, description: string) => void;
28
+ setCardData: (sheetId: string, cardId: string, data: any[]) => void;
29
+ addCard: (sheetId: string, card: TCard) => void;
30
+ updateCard: (sheetId: string, card: TCard) => void;
31
+ removeCard: (sheetId: string, card: TCard) => void;
32
+ setIsDashboardEditing: (editing: boolean) => void;
33
+ setShowDashboardJSON: (show: boolean) => void;
34
+ setIsVisualEditing: (editing: boolean) => void;
35
+ setShowFilters: (show: boolean) => void;
36
+ addFilter: (filter: TFilter) => void;
37
+ removeFilter: (filterId: string) => void;
38
+ updateFilter: (filter: TFilter) => void;
39
+ addOrUpdateFilterValue: (filterValue: TFilterValue) => void;
40
+ removeFilterValue: (filterId: string) => void;
41
+ setStyle: (style: TStyle) => void;
42
+ getStyle: () => TStyle | undefined;
43
+ setOnSaveFunction: (onSaveFunction: (dashboard: TDashboard) => void) => void;
44
+ setOnAddCard: (onAddCard: (card: TCard, sheetId: string) => void) => void;
45
+ setOnUpdateCard: (onUpdateCard: (card: TCard, sheetId: string) => void) => void;
46
+ setOnRemoveCard: (onRemoveCard: (card: TCard, sheetId: string) => void) => void;
47
+ setOnEvent: (onEvent: (event: TEvent) => void) => void;
48
+ getDashboard: () => TDashboard | undefined;
49
+ getSelectedSheet: () => TSheet | undefined;
50
+ getSelectedSheetCards: () => TCard[] | undefined;
51
+ getSelectedCard: () => TCard | undefined;
52
+ getSelectedSheetLayout: () => ReactGridLayout.Layout[] | undefined;
53
+ };
54
+
55
+ export declare type AuthToken = {
56
+ accessToken: string;
57
+ refreshToken: string;
58
+ };
59
+
60
+ declare type BaseFilter = {
61
+ filterId: TFilter['id'];
62
+ expression?: string;
63
+ name: string;
64
+ valueType: 'string' | 'number' | 'date' | 'boolean';
65
+ connectionType?: 'database' | 'api';
66
+ };
67
+
68
+ export declare function cleanCard(card: TCard): TCard;
69
+
70
+ export declare function Dashboard(props: DashboardProps): JSX_2.Element;
71
+
72
+ export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): JSX_2.Element;
73
+
74
+ declare type DashboardPlusProps = {
75
+ showControls?: boolean;
76
+ showFooter?: boolean;
77
+ } & DashboardProps;
78
+
79
+ export declare type DashboardProps = {
80
+ id: string;
81
+ authToken: AuthToken | undefined;
82
+ style?: TStyle;
83
+ currentTheme?: 'light' | 'dark' | 'system';
84
+ onEvent?: (event: TEvent) => void;
85
+ onSave?: (dashboard: TDashboard) => void;
86
+ LoadingComponent?: (props: LoadingProps) => React.ReactNode;
87
+ ErrorComponent?: (props: ErrorProps) => React.ReactNode;
88
+ };
89
+
90
+ declare type DashboardStore = {
91
+ authToken?: AuthToken;
92
+ theme?: 'light' | 'dark' | 'system';
93
+ themeStyle?: StyleProps;
94
+ dashboard: TDashboard;
95
+ selectedSheetId?: string | null | undefined;
96
+ selectedCardId?: string | null;
97
+ selectedCard?: TCard | null;
98
+ isDashboardEditing: boolean;
99
+ isVisualEditing: boolean;
100
+ showDashboardJSON: boolean;
101
+ showFilters: boolean;
102
+ filterValues?: TFilterValue[];
103
+ isEditorSaveEvent: boolean;
104
+ onEvent?: (event: TEvent) => void;
105
+ onSaveFunction?: (dashboard: TDashboard) => void;
106
+ onAddCard?: (card: TCard, sheetId: string) => void;
107
+ onUpdateCard?: (card: TCard, sheetId: string) => void;
108
+ onRemoveCard?: (card: TCard, sheetId: string) => void;
109
+ actions: Actions;
110
+ };
111
+
112
+ export declare type ErrorProps = {
113
+ message?: string;
114
+ };
115
+
116
+ declare type FilterForBetween = BaseFilter & {
117
+ operation: 'between' | 'not between';
118
+ values: [number, number];
119
+ };
120
+
121
+ declare type FilterForCompare = BaseFilter & {
122
+ operation: '>' | '<' | '>=' | '<=';
123
+ values: [number];
124
+ };
125
+
126
+ declare type FilterForDate = BaseFilter & {
127
+ operation: 'between' | 'not between';
128
+ values: [Date, Date];
129
+ };
130
+
131
+ declare type FilterForEqual = BaseFilter & {
132
+ operation: '=' | '!=' | 'is null' | 'is not null';
133
+ values: [string | number];
134
+ };
135
+
136
+ declare type FilterForIn = BaseFilter & {
137
+ operation: 'in' | 'not in';
138
+ values: (string | number)[];
139
+ };
140
+
141
+ declare type FilterForString = BaseFilter & {
142
+ operation: 'like' | 'not like';
143
+ values: [string];
144
+ };
145
+
146
+ export declare function getDashbaordStateWithoutData(dashboardState: TDashboard): {
147
+ sheets: {
148
+ cards: TCard[] | undefined;
149
+ id: string;
150
+ title?: string | undefined;
151
+ description?: string | undefined;
152
+ layout?: Layout[] | undefined;
153
+ }[] | undefined;
154
+ id: string;
155
+ title?: string | undefined;
156
+ description?: string | undefined;
157
+ style?: TStyle | undefined;
158
+ filters?: TFilter[] | undefined;
159
+ };
160
+
161
+ export declare type LoadingProps = {
162
+ message?: string;
163
+ };
164
+
165
+ export declare type StyleProps = {
166
+ dashboardPanel?: string;
167
+ dashboardTabsContainer?: string;
168
+ dashboardCard?: string;
169
+ dashboardHeader?: string;
170
+ dashboardTitle?: string;
171
+ dashboardDescription?: string;
172
+ gridLayout?: {
173
+ className?: string;
174
+ margin?: [number, number];
175
+ };
176
+ chart?: {
177
+ font?: Partial<FontSpec>;
178
+ dataset?: any;
179
+ options?: any;
180
+ };
181
+ };
182
+
183
+ export declare type TCard = {
184
+ id: string;
185
+ title: string;
186
+ description?: string;
187
+ connectionId?: string;
188
+ type: TChartType;
189
+ sql?: string;
190
+ data?: any[];
191
+ cfg?: any;
192
+ customCfg?: any;
193
+ preferences?: TCardPreferences;
194
+ lastSelectedDatabase?: string;
195
+ lastSelectedSchema?: string;
196
+ lastSelectedTable?: string;
197
+ refreshInterval?: string;
198
+ };
199
+
200
+ export declare type TCardPreferences = {
201
+ filterOnClick?: boolean;
202
+ filterOnClickField?: string;
203
+ };
204
+
205
+ declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table';
206
+
207
+ export declare type TDashboard = {
208
+ id: string;
209
+ title?: string;
210
+ description?: string;
211
+ sheets?: TSheet[];
212
+ style?: TStyle;
213
+ filters?: TFilter[];
214
+ };
215
+
216
+ export declare type TEvent = {
217
+ type: 'success' | 'error' | 'info' | 'warning';
218
+ message: any;
219
+ };
220
+
221
+ declare type TFilter = {
222
+ id: string;
223
+ connectionId: string;
224
+ title: string;
225
+ column: string;
226
+ dataType: string;
227
+ table: string;
228
+ database: string;
229
+ sql: string;
230
+ };
231
+
232
+ declare type TFilterValue = FilterForString | FilterForEqual | FilterForCompare | FilterForBetween | FilterForIn | FilterForDate;
233
+
234
+ export declare type TSheet = {
235
+ id: string;
236
+ title?: string;
237
+ description?: string;
238
+ layout?: ReactGridLayout.Layout[];
239
+ cards?: TCard[];
240
+ };
241
+
242
+ export declare type TStyle = {
243
+ default: StyleProps;
244
+ dark?: StyleProps;
245
+ };
246
+
247
+ export declare function useActions(): {
248
+ setDashboardTitle: (title: string) => void;
249
+ getStyle: () => TStyle | undefined;
250
+ getDashboard: () => TDashboard | undefined;
251
+ setOnSaveFunction: (onSaveFunction: (dashboard: TDashboard) => void) => void;
252
+ setOnAddCard: (onAddCard: (card: TCard, sheetId: string) => void) => void;
253
+ setOnUpateCard: (onUpdateCard: (card: TCard, sheetId: string) => void) => void;
254
+ setOnRemoveCard: (onRemoveCard: (card: TCard, sheetId: string) => void) => void;
255
+ };
256
+
257
+ export declare const useDashboardStore: UseBoundStore<Omit<StoreApi<DashboardStore>, "setState"> & {
258
+ setState(nextStateOrUpdater: DashboardStore | Partial<DashboardStore> | ((state: {
259
+ authToken?: {
260
+ accessToken: string;
261
+ refreshToken: string;
262
+ } | undefined;
263
+ theme?: "light" | "dark" | "system" | undefined;
264
+ themeStyle?: {
265
+ dashboardPanel?: string | undefined;
266
+ dashboardTabsContainer?: string | undefined;
267
+ dashboardCard?: string | undefined;
268
+ dashboardHeader?: string | undefined;
269
+ dashboardTitle?: string | undefined;
270
+ dashboardDescription?: string | undefined;
271
+ gridLayout?: {
272
+ className?: string | undefined;
273
+ margin?: [number, number] | undefined;
274
+ } | undefined;
275
+ chart?: {
276
+ font?: {
277
+ family?: string | undefined;
278
+ size?: number | undefined;
279
+ style?: "normal" | "italic" | "oblique" | "initial" | "inherit" | undefined;
280
+ weight?: number | "bold" | "normal" | "lighter" | "bolder" | null | undefined;
281
+ lineHeight?: string | number | undefined;
282
+ } | undefined;
283
+ dataset?: any;
284
+ options?: any;
285
+ } | undefined;
286
+ } | undefined;
287
+ dashboard: {
288
+ id: string;
289
+ title?: string | undefined;
290
+ description?: string | undefined;
291
+ sheets?: {
292
+ id: string;
293
+ title?: string | undefined;
294
+ description?: string | undefined;
295
+ layout?: {
296
+ i: string;
297
+ x: number;
298
+ y: number;
299
+ w: number;
300
+ h: number;
301
+ minW?: number | undefined;
302
+ maxW?: number | undefined;
303
+ minH?: number | undefined;
304
+ maxH?: number | undefined;
305
+ moved?: boolean | undefined;
306
+ static?: boolean | undefined;
307
+ isDraggable?: boolean | undefined;
308
+ isResizable?: boolean | undefined;
309
+ resizeHandles?: ("w" | "s" | "e" | "n" | "sw" | "nw" | "se" | "ne")[] | undefined;
310
+ isBounded?: boolean | undefined;
311
+ }[] | undefined;
312
+ cards?: {
313
+ id: string;
314
+ title: string;
315
+ description?: string | undefined;
316
+ connectionId?: string | undefined;
317
+ type: TChartType;
318
+ sql?: string | undefined;
319
+ data?: any[] | undefined;
320
+ cfg?: any;
321
+ customCfg?: any;
322
+ preferences?: {
323
+ filterOnClick?: boolean | undefined;
324
+ filterOnClickField?: string | undefined;
325
+ } | undefined;
326
+ lastSelectedDatabase?: string | undefined;
327
+ lastSelectedSchema?: string | undefined;
328
+ lastSelectedTable?: string | undefined;
329
+ refreshInterval?: string | undefined;
330
+ }[] | undefined;
331
+ }[] | undefined;
332
+ style?: {
333
+ default: {
334
+ dashboardPanel?: string | undefined;
335
+ dashboardTabsContainer?: string | undefined;
336
+ dashboardCard?: string | undefined;
337
+ dashboardHeader?: string | undefined;
338
+ dashboardTitle?: string | undefined;
339
+ dashboardDescription?: string | undefined;
340
+ gridLayout?: {
341
+ className?: string | undefined;
342
+ margin?: [number, number] | undefined;
343
+ } | undefined;
344
+ chart?: {
345
+ font?: {
346
+ family?: string | undefined;
347
+ size?: number | undefined;
348
+ style?: "normal" | "italic" | "oblique" | "initial" | "inherit" | undefined;
349
+ weight?: number | "bold" | "normal" | "lighter" | "bolder" | null | undefined;
350
+ lineHeight?: string | number | undefined;
351
+ } | undefined;
352
+ dataset?: any;
353
+ options?: any;
354
+ } | undefined;
355
+ };
356
+ dark?: {
357
+ dashboardPanel?: string | undefined;
358
+ dashboardTabsContainer?: string | undefined;
359
+ dashboardCard?: string | undefined;
360
+ dashboardHeader?: string | undefined;
361
+ dashboardTitle?: string | undefined;
362
+ dashboardDescription?: string | undefined;
363
+ gridLayout?: {
364
+ className?: string | undefined;
365
+ margin?: [number, number] | undefined;
366
+ } | undefined;
367
+ chart?: {
368
+ font?: {
369
+ family?: string | undefined;
370
+ size?: number | undefined;
371
+ style?: "normal" | "italic" | "oblique" | "initial" | "inherit" | undefined;
372
+ weight?: number | "bold" | "normal" | "lighter" | "bolder" | null | undefined;
373
+ lineHeight?: string | number | undefined;
374
+ } | undefined;
375
+ dataset?: any;
376
+ options?: any;
377
+ } | undefined;
378
+ } | undefined;
379
+ } | undefined;
380
+ filters?: {
381
+ id: string;
382
+ connectionId: string;
383
+ title: string;
384
+ column: string;
385
+ dataType: string;
386
+ table: string;
387
+ database: string;
388
+ sql: string;
389
+ }[] | undefined;
390
+ };
391
+ selectedSheetId?: string | null | undefined;
392
+ selectedCardId?: string | null | undefined;
393
+ selectedCard?: {
394
+ id: string;
395
+ title: string;
396
+ description?: string | undefined;
397
+ connectionId?: string | undefined;
398
+ type: TChartType;
399
+ sql?: string | undefined;
400
+ data?: any[] | undefined;
401
+ cfg?: any;
402
+ customCfg?: any;
403
+ preferences?: {
404
+ filterOnClick?: boolean | undefined;
405
+ filterOnClickField?: string | undefined;
406
+ } | undefined;
407
+ lastSelectedDatabase?: string | undefined;
408
+ lastSelectedSchema?: string | undefined;
409
+ lastSelectedTable?: string | undefined;
410
+ refreshInterval?: string | undefined;
411
+ } | null | undefined;
412
+ isDashboardEditing: boolean;
413
+ isVisualEditing: boolean;
414
+ showDashboardJSON: boolean;
415
+ showFilters: boolean;
416
+ filterValues?: ({
417
+ filterId: string;
418
+ expression?: string | undefined;
419
+ name: string;
420
+ valueType: "string" | "number" | "boolean" | "date";
421
+ connectionType?: "database" | "api" | undefined;
422
+ operation: "like" | "not like";
423
+ values: [string];
424
+ } | {
425
+ filterId: string;
426
+ expression?: string | undefined;
427
+ name: string;
428
+ valueType: "string" | "number" | "boolean" | "date";
429
+ connectionType?: "database" | "api" | undefined;
430
+ operation: "=" | "!=" | "is null" | "is not null";
431
+ values: [string | number];
432
+ } | {
433
+ filterId: string;
434
+ expression?: string | undefined;
435
+ name: string;
436
+ valueType: "string" | "number" | "boolean" | "date";
437
+ connectionType?: "database" | "api" | undefined;
438
+ operation: ">" | "<" | ">=" | "<=";
439
+ values: [number];
440
+ } | {
441
+ filterId: string;
442
+ expression?: string | undefined;
443
+ name: string;
444
+ valueType: "string" | "number" | "boolean" | "date";
445
+ connectionType?: "database" | "api" | undefined;
446
+ operation: "between" | "not between";
447
+ values: [number, number];
448
+ } | {
449
+ filterId: string;
450
+ expression?: string | undefined;
451
+ name: string;
452
+ valueType: "string" | "number" | "boolean" | "date";
453
+ connectionType?: "database" | "api" | undefined;
454
+ operation: "between" | "not between";
455
+ values: [Date, Date];
456
+ } | {
457
+ filterId: string;
458
+ expression?: string | undefined;
459
+ name: string;
460
+ valueType: "string" | "number" | "boolean" | "date";
461
+ connectionType?: "database" | "api" | undefined;
462
+ operation: "in" | "not in";
463
+ values: (string | number)[];
464
+ })[] | undefined;
465
+ isEditorSaveEvent: boolean;
466
+ onEvent?: ((event: TEvent) => void) | undefined;
467
+ onSaveFunction?: ((dashboard: TDashboard) => void) | undefined;
468
+ onAddCard?: ((card: TCard, sheetId: string) => void) | undefined;
469
+ onUpdateCard?: ((card: TCard, sheetId: string) => void) | undefined;
470
+ onRemoveCard?: ((card: TCard, sheetId: string) => void) | undefined;
471
+ actions: {
472
+ setAuthToken: (authToken: AuthToken) => void;
473
+ setThemeStyle: (themeStyle: StyleProps) => void;
474
+ setIsEditorSaveEvent: (isEditorSaveEvent: boolean) => void;
475
+ setDashboard: (dashboard: TDashboard) => void;
476
+ setDashboardTheme: (theme: 'light' | 'dark' | 'system') => void;
477
+ setDashboardTitle: (title: string) => void;
478
+ setDashboardDescription: (description: string) => void;
479
+ setSheets: (sheets: TSheet[]) => void;
480
+ setSheetTitle: (sheetId: string, title: string) => void;
481
+ setSheetDescription: (sheetId: string, description: string) => void;
482
+ setSelectedSheetId: (sheetId: string | null) => void;
483
+ setSheetLayout: (sheetId: string, layout: ReactGridLayout.Layout[]) => void;
484
+ setCards: (sheetId: string, cards: TCard[]) => void;
485
+ setSelectedCardId: (sheetId: string, cardId: string | null) => void;
486
+ setSelectedCard: (card: TCard | null) => void;
487
+ setCardTitle: (sheetId: string, cardId: string, title: string) => void;
488
+ setCardSql: (sheetId: string, cardId: string, sql: string) => void;
489
+ setCardDescription: (sheetId: string, cardId: string, description: string) => void;
490
+ setCardData: (sheetId: string, cardId: string, data: any[]) => void;
491
+ addCard: (sheetId: string, card: TCard) => void;
492
+ updateCard: (sheetId: string, card: TCard) => void;
493
+ removeCard: (sheetId: string, card: TCard) => void;
494
+ setIsDashboardEditing: (editing: boolean) => void;
495
+ setShowDashboardJSON: (show: boolean) => void;
496
+ setIsVisualEditing: (editing: boolean) => void;
497
+ setShowFilters: (show: boolean) => void;
498
+ addFilter: (filter: TFilter) => void;
499
+ removeFilter: (filterId: string) => void;
500
+ updateFilter: (filter: TFilter) => void;
501
+ addOrUpdateFilterValue: (filterValue: TFilterValue) => void;
502
+ removeFilterValue: (filterId: string) => void;
503
+ setStyle: (style: TStyle) => void;
504
+ getStyle: () => TStyle | undefined;
505
+ setOnSaveFunction: (onSaveFunction: (dashboard: TDashboard) => void) => void;
506
+ setOnAddCard: (onAddCard: (card: TCard, sheetId: string) => void) => void;
507
+ setOnUpdateCard: (onUpdateCard: (card: TCard, sheetId: string) => void) => void;
508
+ setOnRemoveCard: (onRemoveCard: (card: TCard, sheetId: string) => void) => void;
509
+ setOnEvent: (onEvent: (event: TEvent) => void) => void;
510
+ getDashboard: () => TDashboard | undefined;
511
+ getSelectedSheet: () => TSheet | undefined;
512
+ getSelectedSheetCards: () => TCard[] | undefined;
513
+ getSelectedCard: () => TCard | undefined;
514
+ getSelectedSheetLayout: () => ReactGridLayout.Layout[] | undefined;
515
+ };
516
+ }) => void), shouldReplace?: boolean | undefined): void;
517
+ }>;
518
+
519
+ export { }