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,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 { }
@@ -0,0 +1,311 @@
1
+ import { FontSpec } from 'chart.js';
2
+
3
+ export declare type AggregateCalc = 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'COUNT' | 'COUNT_DISTINCT';
4
+
5
+ export declare type AuthToken = {
6
+ accessToken: string;
7
+ refreshToken: string;
8
+ };
9
+
10
+ declare type BaseCustomCard = {
11
+ cardId: string;
12
+ replaceDefault?: boolean;
13
+ };
14
+
15
+ declare type BaseFilter = {
16
+ filterId: TFilter['id'];
17
+ expression?: string;
18
+ name: string;
19
+ valueType: 'string' | 'number' | 'date' | 'boolean';
20
+ connectionType?: 'database' | 'api';
21
+ };
22
+
23
+ export declare type Bookmark = {
24
+ name: string;
25
+ default: boolean;
26
+ template: TDashboard;
27
+ filterValues?: TFilterValue[];
28
+ };
29
+
30
+ export declare type Breakpoint = 'lg' | 'md' | 'sm' | 'xs' | 'xxs';
31
+
32
+ declare type CardWithContent = BaseCustomCard & {
33
+ content: React.FC<{
34
+ card: TCard;
35
+ }>;
36
+ footer?: React.FC<{
37
+ card: TCard;
38
+ }>;
39
+ };
40
+
41
+ declare type CardWithFooter = BaseCustomCard & {
42
+ content?: React.FC<{
43
+ card: TCard;
44
+ }>;
45
+ footer: React.FC<{
46
+ card: TCard;
47
+ }>;
48
+ };
49
+
50
+ export declare type ConnectionPolicy = {
51
+ connectionId?: string;
52
+ name: string;
53
+ params: Params;
54
+ };
55
+
56
+ export declare type CustomCard = CardWithContent | CardWithFooter;
57
+
58
+ export declare type DashboardProps = {
59
+ id: string;
60
+ authToken: AuthToken | undefined;
61
+ style?: TStyle;
62
+ currentTheme?: Theme;
63
+ version?: string;
64
+ customCards?: CustomCard[];
65
+ onChartElementClicked?: (card: TCard, fieldValues: any) => void;
66
+ onEvent?: (event: TEvent) => void;
67
+ onSave?: (dashboard: TDashboard) => void;
68
+ LoadingComponent?: (props: LoadingProps) => React.ReactNode;
69
+ ErrorComponent?: (props: ErrorProps) => React.ReactNode;
70
+ };
71
+
72
+ export declare type ErrorProps = {
73
+ message?: string;
74
+ };
75
+
76
+ declare type FilterForBetween = BaseFilter & {
77
+ operation: 'between' | 'not between';
78
+ values: [number, number];
79
+ };
80
+
81
+ declare type FilterForCompare = BaseFilter & {
82
+ operation: '>' | '<' | '>=' | '<=';
83
+ values: [number];
84
+ };
85
+
86
+ declare type FilterForDate = BaseFilter & {
87
+ operation: 'between' | 'not between';
88
+ values: [Date, Date];
89
+ };
90
+
91
+ declare type FilterForEqual = BaseFilter & {
92
+ operation: '=' | '!=' | 'is null' | 'is not null';
93
+ values: [string | number];
94
+ };
95
+
96
+ declare type FilterForIn = BaseFilter & {
97
+ operation: 'in' | 'not in';
98
+ values: (string | number)[];
99
+ };
100
+
101
+ declare type FilterForString = BaseFilter & {
102
+ operation: 'like' | 'not like';
103
+ values: [string];
104
+ };
105
+
106
+ declare type FilterOnClick = {
107
+ expression?: string;
108
+ columnIndex: number;
109
+ };
110
+
111
+ export declare type KPICardProps = {
112
+ card: TCard;
113
+ isLoading: boolean;
114
+ };
115
+
116
+ export declare type LoadingProps = {
117
+ message?: string;
118
+ };
119
+
120
+ declare type Operation = '=' | '>' | '<' | '>=' | '<=' | '!=' | 'in' | 'not in' | 'like' | 'not like' | 'between' | 'not between' | 'is null' | 'is not null';
121
+
122
+ declare type Params = {
123
+ [key: string]: string | number | string[] | number[];
124
+ };
125
+
126
+ export declare type SqlGen = {
127
+ measures?: {
128
+ name: string;
129
+ calc: AggregateCalc;
130
+ }[];
131
+ dimensions?: string[];
132
+ };
133
+
134
+ /**
135
+ * Style propeerites for the dashboard
136
+ */
137
+ export declare type StyleProps = {
138
+ /** css class for `dashboard-panel` */
139
+ dashboardPanel?: string;
140
+ /** css class for `dashboard-tabs-container` */
141
+ dashboardTabsContainer?: string;
142
+ /** css class for `dashboard-card` */
143
+ /** css class for `dashboard-card-container` */
144
+ dashboardCardContainer?: string;
145
+ dashboardCard?: string;
146
+ /** grid-layout config */
147
+ gridLayout?: {
148
+ /** css class for `react-grid-layout` */
149
+ className?: string;
150
+ margin?: [number, number];
151
+ };
152
+ /** chart config */
153
+ chart?: {
154
+ /** chart font config */
155
+ font?: Partial<FontSpec>;
156
+ dataset?: any;
157
+ /** chart options */
158
+ options?: any;
159
+ };
160
+ };
161
+
162
+ export declare type TBaseQuery = {
163
+ id: string;
164
+ name: string;
165
+ sql: string;
166
+ description?: string;
167
+ };
168
+
169
+ export declare type TCard = {
170
+ id: string;
171
+ title: string;
172
+ description?: string;
173
+ info?: string;
174
+ connectionId?: string;
175
+ type: TChartType;
176
+ sql?: string;
177
+ python?: string;
178
+ data?: any[];
179
+ cfg?: any;
180
+ customCfg?: any;
181
+ preferences?: TCardPreferences;
182
+ lastSelectedDatabase?: string;
183
+ lastSelectedSchema?: string;
184
+ lastSelectedTable?: string;
185
+ refreshInterval?: string;
186
+ };
187
+
188
+ export declare type TCardContext = {
189
+ id: string;
190
+ name: string;
191
+ description: string;
192
+ sql: string;
193
+ };
194
+
195
+ export declare type TCardPreferences = {
196
+ onClickFilter?: FilterOnClick[];
197
+ filterOnClick?: boolean;
198
+ filterOnClickField?: string;
199
+ filterOnClickColumnIndex?: number;
200
+ formatNumber?: {
201
+ format?: string;
202
+ currency?: string;
203
+ locale?: string;
204
+ suffix?: string;
205
+ enabled?: boolean | string;
206
+ };
207
+ datasetOptions?: TDatasetOptions[];
208
+ chartOptions?: TChartOptions;
209
+ };
210
+
211
+ export declare type TChartOptions = {
212
+ type?: TChartType;
213
+ scales?: {
214
+ y?: {
215
+ type: 'linear' | 'logarithmic';
216
+ min: number;
217
+ max: number;
218
+ ticks: {
219
+ stepSize: number;
220
+ };
221
+ };
222
+ x?: {
223
+ type: 'linear' | 'logarithmic';
224
+ min: number;
225
+ max: number;
226
+ ticks: {
227
+ stepSize: number;
228
+ };
229
+ };
230
+ };
231
+ indexAxis?: 'x' | 'y' | undefined;
232
+ };
233
+
234
+ declare type TChartType = 'bar' | 'horizontalBar' | 'line' | 'pie' | 'doughnut' | 'radar' | 'polarArea' | 'bubble' | 'scatter' | 'stackedBar' | 'table' | 'kpi' | 'custom';
235
+
236
+ export declare type TDashboard = {
237
+ id: string;
238
+ title?: string;
239
+ description?: string;
240
+ sheets?: TSheet[];
241
+ style?: TStyle;
242
+ filters?: TFilter[];
243
+ customCards?: CustomCard[];
244
+ baseQueries?: TBaseQuery[];
245
+ };
246
+
247
+ export declare type TDataColumn = {
248
+ column_name: string;
249
+ data_type: string;
250
+ is_nullable?: string;
251
+ };
252
+
253
+ export declare type TDatasetOptions = {
254
+ idx: number;
255
+ type?: 'bar' | 'line';
256
+ fill?: string | number;
257
+ datalabels?: {
258
+ display?: boolean;
259
+ align?: string;
260
+ anchor?: string;
261
+ clamp?: boolean;
262
+ color?: string;
263
+ };
264
+ };
265
+
266
+ export declare type TEvent = {
267
+ type: 'success' | 'error' | 'info' | 'warning';
268
+ message: any;
269
+ };
270
+
271
+ declare type TFilter = {
272
+ id: string;
273
+ connectionId: string;
274
+ title: string;
275
+ column: string;
276
+ dataType: string;
277
+ table: string;
278
+ database: string;
279
+ sql: string;
280
+ operation: Operation;
281
+ };
282
+
283
+ declare type TFilterValue = FilterForString | FilterForEqual | FilterForCompare | FilterForBetween | FilterForIn | FilterForDate;
284
+
285
+ export declare type TFrame = {
286
+ id: string;
287
+ cards: TCard[];
288
+ activeCardId: string;
289
+ };
290
+
291
+ export declare type Theme = 'dark' | 'light' | 'system';
292
+
293
+ export declare type TSheet = {
294
+ id: string;
295
+ title?: string;
296
+ description?: string;
297
+ layout?: ReactGridLayout.Layout[];
298
+ layouts?: ReactGridLayout.Layouts;
299
+ cards?: TCard[];
300
+ frames?: TFrame[];
301
+ };
302
+
303
+ /**
304
+ * Style for the dashboard
305
+ */
306
+ export declare type TStyle = {
307
+ default: StyleProps;
308
+ dark?: StyleProps;
309
+ };
310
+
311
+ export { }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.43",
8
+ "version": "0.0.45",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -17,15 +17,26 @@
17
17
  "files": [
18
18
  "dist"
19
19
  ],
20
- "main": "dist/react-semaphor-umd.cjs",
21
- "module": "dist/react-semaphor.js",
20
+ "main": "dist/index.cjs",
21
+ "module": "dist/index.js",
22
+ "types": "dist/types/main.d.ts",
22
23
  "exports": {
23
24
  ".": {
24
- "import": "./dist/react-semaphor.js",
25
- "require": "./dist/react-semaphor-umd.cjs",
26
- "types": "./dist/index.d.ts"
25
+ "import": "./dist/index.js",
26
+ "require": "./dist/index.cjs",
27
+ "types": "./dist/types/main.d.ts"
27
28
  },
28
- "./dist/style.css": "./dist/style.css"
29
+ "./dashboard": {
30
+ "import": "./dist/dashboard/index.js",
31
+ "require": "./dist/dashboard/index.cjs",
32
+ "types": "./dist/types/dashboard.d.ts"
33
+ },
34
+ "./surfboard": {
35
+ "import": "./dist/surfboard/index.js",
36
+ "require": "./dist/surfboard/index.cjs",
37
+ "types": "./dist/types/surfboard.d.ts"
38
+ },
39
+ "./style.css": "./dist/style.css"
29
40
  },
30
41
  "scripts": {
31
42
  "dev": "vite",
@@ -85,6 +96,7 @@
85
96
  "zustand": "^4.4.7"
86
97
  },
87
98
  "devDependencies": {
99
+ "@microsoft/api-extractor": "^7.47.0",
88
100
  "@tanstack/react-query-devtools": "^5.17.21",
89
101
  "@types/chart.js": "^2.9.41",
90
102
  "@types/jsoneditor": "^9.9.5",
@@ -108,7 +120,7 @@
108
120
  "prettier-plugin-tailwindcss": "^0.6.1",
109
121
  "simple-zustand-devtools": "^1.1.0",
110
122
  "tailwindcss": "^3.4.1",
111
- "typescript": "^5.2.2",
123
+ "typescript": "^5.4.5",
112
124
  "vite": "^5.0.8",
113
125
  "vite-plugin-css-injected-by-js": "^3.5.1",
114
126
  "vite-plugin-dts": "^3.6.4"