react-semaphor 0.0.490 → 0.0.491

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.
@@ -3,7 +3,7 @@ import { JSX as JSX_2 } from 'react/jsx-runtime';
3
3
 
4
4
  export declare type AggregateCalc = 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'COUNT' | 'COUNT_DISTINCT';
5
5
 
6
- declare type AggregateFunction = 'SUM' | 'AVG' | 'COUNT' | 'MAX' | 'MIN' | 'DISTINCT';
6
+ declare type AggregateFunction = 'COUNT' | 'SUM' | 'AVG' | 'MIN' | 'MAX' | 'MEDIAN' | 'DISTINCT';
7
7
 
8
8
  export declare type AIScopeTable = {
9
9
  connectionId: string;
@@ -50,6 +50,15 @@ export declare type CacheConfig = {
50
50
  status: 'on' | 'on-refresh' | 'off';
51
51
  };
52
52
 
53
+ declare interface CardConfig {
54
+ groupByColumns?: GroupByField[];
55
+ metricColumns?: MetricField[];
56
+ pivotByColumns?: PivotByField[];
57
+ sortByColumns?: SortByField[];
58
+ filters?: FilterGroup;
59
+ joinPlan?: JoinPlan;
60
+ }
61
+
53
62
  declare type CardWithContent = BaseCustomCard & {
54
63
  content: React.FC<{
55
64
  card: TCard;
@@ -116,6 +125,8 @@ export declare type ConnectionPolicy = {
116
125
  params: Params;
117
126
  };
118
127
 
128
+ declare type ConnectionType = 'GoogleSheets' | 'MySQL' | 'MSSQL' | 'PostgreSQL' | 'BigQuery' | 'Redshift' | 'Snowflake' | 'S3' | 'clickhouse' | 'S3Tables' | 'API' | 'none';
129
+
119
130
  export declare type CustomCard = CardWithContent | CardWithFooter;
120
131
 
121
132
  export declare type DashboardEventHandlers = {
@@ -162,12 +173,50 @@ export declare type DashboardProps = {
162
173
  selectedSheetId?: string;
163
174
  };
164
175
 
176
+ declare interface DatabaseEntityReference {
177
+ connectionId: string;
178
+ connectionType: ConnectionType;
179
+ type: EntityType;
180
+ dialect?: Dialect;
181
+ database?: string;
182
+ schema?: string;
183
+ name: string;
184
+ }
185
+
186
+ declare type DatabaseEntityType = 'table' | 'view';
187
+
188
+ declare interface DataModelEntityReference extends DatabaseEntityReference {
189
+ type: 'model';
190
+ id: string;
191
+ label: string;
192
+ description: string;
193
+ }
194
+
195
+ declare interface DataSource {
196
+ connectionId: string;
197
+ semanticModelId?: string;
198
+ connectionType: string;
199
+ mode: 'database' | 'upload' | 'url' | 'semanticModel';
200
+ dbSelection?: {
201
+ database: string;
202
+ schema: string;
203
+ entityType: DatabaseEntityType;
204
+ };
205
+ selectedEntities?: SelectedEntities;
206
+ }
207
+
208
+ declare const DATE_FORMAT_VALUES: readonly ["YYYY-MM-DD", "MM/DD/YYYY", "DD/MM/YYYY", "MMMM DD, YYYY", "MMM DD, YYYY", "DD MMM YYYY", "YYYY-MM", "MMMM YYYY", "custom"];
209
+
210
+ declare type DateFormatValue = (typeof DATE_FORMAT_VALUES)[number];
211
+
165
212
  export declare type DateOptions = {
166
213
  locale: string;
167
214
  format: string;
168
215
  options: Intl.DateTimeFormatOptions;
169
216
  };
170
217
 
218
+ declare type Dialect = 'mysql' | 'postgresql' | 'bigquery' | 'redshift' | 'snowflake' | 'clickhouse' | 'duckdb';
219
+
171
220
  export declare type DisplayDataType = 'string' | 'date' | 'number' | 'html' | 'none';
172
221
 
173
222
  export declare type DroppableId = 'droppable-group-by' | 'droppable-metric';
@@ -181,6 +230,8 @@ export declare type EmailSettings = {
181
230
 
182
231
  export declare const EMPTY_SELECTION: SelectionState;
183
232
 
233
+ declare type EntityType = 'table' | 'view' | 'model' | 'file' | 'dataset' | 'url' | 'upload';
234
+
184
235
  export declare type ErrorProps = {
185
236
  message?: string;
186
237
  };
@@ -192,6 +243,32 @@ export declare type ExportDataPayload = {
192
243
  sql: string;
193
244
  };
194
245
 
246
+ declare interface Field {
247
+ id: string;
248
+ name: string;
249
+ dataType: string;
250
+ label: string;
251
+ description?: string;
252
+ qualifiedEntityName?: string;
253
+ dateFormat?: DateFormatValue;
254
+ customFormat?: string;
255
+ granularity?: TimeGranularity;
256
+ entityId: string;
257
+ entityName: string;
258
+ entityType: EntityType;
259
+ role?: 'groupby' | 'metric' | 'sortby' | 'pivotby';
260
+ }
261
+
262
+ declare interface FileEntityReference extends DatabaseEntityReference {
263
+ id: string;
264
+ type: 'file' | 'url' | 'upload';
265
+ label: string;
266
+ description: string;
267
+ originalName: string;
268
+ file?: File;
269
+ url?: string;
270
+ }
271
+
195
272
  declare interface FilterByColumn extends BaseColumn {
196
273
  role: 'filter';
197
274
  operators?: string[];
@@ -203,6 +280,13 @@ declare interface FilterByColumn extends BaseColumn {
203
280
  staticValues?: string[];
204
281
  }
205
282
 
283
+ declare interface FilterCondition {
284
+ id: string;
285
+ field: Field;
286
+ operator: Operator;
287
+ value: FilterValue;
288
+ }
289
+
206
290
  declare type FilterForBetween = BaseFilter & {
207
291
  operation: 'between' | 'not between';
208
292
  values: [number, number];
@@ -233,6 +317,14 @@ declare type FilterForString = BaseFilter & {
233
317
  values: [string];
234
318
  };
235
319
 
320
+ declare interface FilterGroup {
321
+ id: string;
322
+ logicalOperator: LogicalOperator;
323
+ negate: boolean;
324
+ conditions: FilterCondition[];
325
+ groups: FilterGroup[];
326
+ }
327
+
236
328
  declare type FilterLocation = 'dashboard' | 'frame' | undefined;
237
329
 
238
330
  declare type FilterOnClick = {
@@ -240,7 +332,7 @@ declare type FilterOnClick = {
240
332
  columnIndex: number;
241
333
  };
242
334
 
243
- declare type FilterValue = string | number | null | (string | number)[] | RangeValue;
335
+ declare type FilterValue = string | number | boolean | Date | [number, number] | [string, string] | string[] | number[];
244
336
 
245
337
  export declare type GetDashboardResponse = {
246
338
  dashboard: TDashboard;
@@ -264,10 +356,42 @@ declare interface GroupByColumn extends BaseColumn {
264
356
  format?: string;
265
357
  }
266
358
 
359
+ declare interface GroupByField extends Field {
360
+ role: 'groupby';
361
+ granularity?: 'day' | 'week' | 'month' | 'quarter' | 'year';
362
+ }
363
+
267
364
  export declare type HtmlOptions = {
268
365
  html: string;
269
366
  };
270
367
 
368
+ declare interface Join {
369
+ id: string;
370
+ source: DatabaseEntityReference;
371
+ target: DatabaseEntityReference;
372
+ joinType: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL';
373
+ joinKeyGroups: JoinKeyGroup[];
374
+ sequence: number;
375
+ }
376
+
377
+ declare interface JoinKey {
378
+ id?: string;
379
+ source: Field;
380
+ target: Field;
381
+ operator: string;
382
+ }
383
+
384
+ declare interface JoinKeyGroup {
385
+ id: string;
386
+ operator: string;
387
+ keys: JoinKey[];
388
+ }
389
+
390
+ declare interface JoinPlan {
391
+ baseEntity: DatabaseEntityReference;
392
+ joins: Join[];
393
+ }
394
+
271
395
  export declare type KPICardProps = {
272
396
  card: TCard;
273
397
  isLoading?: boolean;
@@ -280,12 +404,21 @@ export declare type LoadingProps = {
280
404
  message?: string;
281
405
  };
282
406
 
407
+ declare type LogicalOperator = 'AND' | 'OR';
408
+
283
409
  declare interface MetricColumn extends BaseColumn {
284
410
  role: 'metric';
285
411
  aggregate: AggregateFunction;
286
412
  aliasTemplate?: string;
287
413
  }
288
414
 
415
+ declare interface MetricField extends Field {
416
+ role: 'metric';
417
+ aggregate: AggregateFunction;
418
+ aliasTemplate?: string;
419
+ valueAliases?: Record<string, string>;
420
+ }
421
+
289
422
  declare type NoneOptions = {};
290
423
 
291
424
  export declare type NumberAxisFormat = {
@@ -302,8 +435,12 @@ export declare type NumberOptions = {
302
435
  colorRanges?: ColorRange[];
303
436
  };
304
437
 
438
+ declare type OldFilterValue = string | number | null | (string | number)[] | RangeValue;
439
+
305
440
  declare type Operation = '=' | '>' | '<' | '>=' | '<=' | '!=' | 'in' | 'not in' | 'like' | 'not like' | 'between' | 'not between' | 'is null' | 'is not null';
306
441
 
442
+ declare type Operator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'contains' | 'startsWith' | 'endsWith' | 'in' | 'not in';
443
+
307
444
  declare type OptionsMap = {
308
445
  number: NumberOptions;
309
446
  string: StringOptions;
@@ -321,6 +458,10 @@ declare type Params = {
321
458
  [key: string]: string | number | string[] | number[];
322
459
  };
323
460
 
461
+ declare interface PivotByField extends Field {
462
+ role: 'pivotby';
463
+ }
464
+
324
465
  export declare type Placeholders = {
325
466
  /**
326
467
  * Placeholder for the card when there are no records to display.
@@ -344,7 +485,7 @@ declare interface QueryConfig {
344
485
 
345
486
  declare type QueryFilter = {
346
487
  filterColumnName: string;
347
- filterValue: FilterValue;
488
+ filterValue: OldFilterValue;
348
489
  };
349
490
 
350
491
  declare type RangeValue = {
@@ -354,8 +495,15 @@ declare type RangeValue = {
354
495
  gt?: string | number;
355
496
  };
356
497
 
498
+ declare type SelectedEntities = DatabaseEntityReference[] | DataModelEntityReference[] | FileEntityReference[];
499
+
357
500
  export declare type SelectionState = Record<Level, string | null>;
358
501
 
502
+ declare interface SortByField extends Field {
503
+ role: 'sortby';
504
+ direction: 'asc' | 'desc';
505
+ }
506
+
359
507
  export declare type SqlGen = {
360
508
  measures?: {
361
509
  name: string;
@@ -439,6 +587,8 @@ export declare type TCard = {
439
587
  type: TChartType;
440
588
  sql?: string;
441
589
  python?: string;
590
+ dataSource?: DataSource;
591
+ config?: CardConfig;
442
592
  queryConfig?: QueryConfig;
443
593
  customCfg?: any;
444
594
  preferences?: TCardPreferences;
@@ -580,6 +730,8 @@ export declare type TDataColumn = {
580
730
  column_name: string;
581
731
  data_type: string;
582
732
  is_nullable?: string;
733
+ label?: string;
734
+ description?: string;
583
735
  };
584
736
 
585
737
  export declare type TDatasetOptions = {
@@ -633,6 +785,8 @@ export declare type TFrame = {
633
785
 
634
786
  export declare type Theme = 'dark' | 'light' | 'system';
635
787
 
788
+ declare type TimeGranularity = 'day' | 'week' | 'month' | 'quarter' | 'year';
789
+
636
790
  export declare type TLegendOptions = {
637
791
  display?: boolean;
638
792
  position?: 'top' | 'left' | 'bottom' | 'right';
@@ -2,7 +2,7 @@ import { FontSpec } from 'chart.js';
2
2
 
3
3
  export declare type AggregateCalc = 'AVG' | 'MIN' | 'MAX' | 'SUM' | 'COUNT' | 'COUNT_DISTINCT';
4
4
 
5
- declare type AggregateFunction = 'SUM' | 'AVG' | 'COUNT' | 'MAX' | 'MIN' | 'DISTINCT';
5
+ declare type AggregateFunction = 'COUNT' | 'SUM' | 'AVG' | 'MIN' | 'MAX' | 'MEDIAN' | 'DISTINCT';
6
6
 
7
7
  export declare type AIScopeTable = {
8
8
  connectionId: string;
@@ -49,6 +49,15 @@ export declare type CacheConfig = {
49
49
  status: 'on' | 'on-refresh' | 'off';
50
50
  };
51
51
 
52
+ declare interface CardConfig {
53
+ groupByColumns?: GroupByField[];
54
+ metricColumns?: MetricField[];
55
+ pivotByColumns?: PivotByField[];
56
+ sortByColumns?: SortByField[];
57
+ filters?: FilterGroup;
58
+ joinPlan?: JoinPlan;
59
+ }
60
+
52
61
  declare type CardWithContent = BaseCustomCard & {
53
62
  content: React.FC<{
54
63
  card: TCard;
@@ -115,6 +124,8 @@ export declare type ConnectionPolicy = {
115
124
  params: Params;
116
125
  };
117
126
 
127
+ declare type ConnectionType = 'GoogleSheets' | 'MySQL' | 'MSSQL' | 'PostgreSQL' | 'BigQuery' | 'Redshift' | 'Snowflake' | 'S3' | 'clickhouse' | 'S3Tables' | 'API' | 'none';
128
+
118
129
  export declare type CustomCard = CardWithContent | CardWithFooter;
119
130
 
120
131
  export declare type DashboardEventHandlers = {
@@ -156,12 +167,50 @@ export declare type DashboardProps = {
156
167
  selectedSheetId?: string;
157
168
  };
158
169
 
170
+ declare interface DatabaseEntityReference {
171
+ connectionId: string;
172
+ connectionType: ConnectionType;
173
+ type: EntityType;
174
+ dialect?: Dialect;
175
+ database?: string;
176
+ schema?: string;
177
+ name: string;
178
+ }
179
+
180
+ declare type DatabaseEntityType = 'table' | 'view';
181
+
182
+ declare interface DataModelEntityReference extends DatabaseEntityReference {
183
+ type: 'model';
184
+ id: string;
185
+ label: string;
186
+ description: string;
187
+ }
188
+
189
+ declare interface DataSource {
190
+ connectionId: string;
191
+ semanticModelId?: string;
192
+ connectionType: string;
193
+ mode: 'database' | 'upload' | 'url' | 'semanticModel';
194
+ dbSelection?: {
195
+ database: string;
196
+ schema: string;
197
+ entityType: DatabaseEntityType;
198
+ };
199
+ selectedEntities?: SelectedEntities;
200
+ }
201
+
202
+ declare const DATE_FORMAT_VALUES: readonly ["YYYY-MM-DD", "MM/DD/YYYY", "DD/MM/YYYY", "MMMM DD, YYYY", "MMM DD, YYYY", "DD MMM YYYY", "YYYY-MM", "MMMM YYYY", "custom"];
203
+
204
+ declare type DateFormatValue = (typeof DATE_FORMAT_VALUES)[number];
205
+
159
206
  export declare type DateOptions = {
160
207
  locale: string;
161
208
  format: string;
162
209
  options: Intl.DateTimeFormatOptions;
163
210
  };
164
211
 
212
+ declare type Dialect = 'mysql' | 'postgresql' | 'bigquery' | 'redshift' | 'snowflake' | 'clickhouse' | 'duckdb';
213
+
165
214
  export declare type DisplayDataType = 'string' | 'date' | 'number' | 'html' | 'none';
166
215
 
167
216
  export declare type DroppableId = 'droppable-group-by' | 'droppable-metric';
@@ -175,6 +224,8 @@ export declare type EmailSettings = {
175
224
 
176
225
  export declare const EMPTY_SELECTION: SelectionState;
177
226
 
227
+ declare type EntityType = 'table' | 'view' | 'model' | 'file' | 'dataset' | 'url' | 'upload';
228
+
178
229
  export declare type ErrorProps = {
179
230
  message?: string;
180
231
  };
@@ -186,6 +237,32 @@ export declare type ExportDataPayload = {
186
237
  sql: string;
187
238
  };
188
239
 
240
+ declare interface Field {
241
+ id: string;
242
+ name: string;
243
+ dataType: string;
244
+ label: string;
245
+ description?: string;
246
+ qualifiedEntityName?: string;
247
+ dateFormat?: DateFormatValue;
248
+ customFormat?: string;
249
+ granularity?: TimeGranularity;
250
+ entityId: string;
251
+ entityName: string;
252
+ entityType: EntityType;
253
+ role?: 'groupby' | 'metric' | 'sortby' | 'pivotby';
254
+ }
255
+
256
+ declare interface FileEntityReference extends DatabaseEntityReference {
257
+ id: string;
258
+ type: 'file' | 'url' | 'upload';
259
+ label: string;
260
+ description: string;
261
+ originalName: string;
262
+ file?: File;
263
+ url?: string;
264
+ }
265
+
189
266
  declare interface FilterByColumn extends BaseColumn {
190
267
  role: 'filter';
191
268
  operators?: string[];
@@ -197,6 +274,13 @@ declare interface FilterByColumn extends BaseColumn {
197
274
  staticValues?: string[];
198
275
  }
199
276
 
277
+ declare interface FilterCondition {
278
+ id: string;
279
+ field: Field;
280
+ operator: Operator;
281
+ value: FilterValue;
282
+ }
283
+
200
284
  declare type FilterForBetween = BaseFilter & {
201
285
  operation: 'between' | 'not between';
202
286
  values: [number, number];
@@ -227,6 +311,14 @@ declare type FilterForString = BaseFilter & {
227
311
  values: [string];
228
312
  };
229
313
 
314
+ declare interface FilterGroup {
315
+ id: string;
316
+ logicalOperator: LogicalOperator;
317
+ negate: boolean;
318
+ conditions: FilterCondition[];
319
+ groups: FilterGroup[];
320
+ }
321
+
230
322
  declare type FilterLocation = 'dashboard' | 'frame' | undefined;
231
323
 
232
324
  declare type FilterOnClick = {
@@ -234,7 +326,7 @@ declare type FilterOnClick = {
234
326
  columnIndex: number;
235
327
  };
236
328
 
237
- declare type FilterValue = string | number | null | (string | number)[] | RangeValue;
329
+ declare type FilterValue = string | number | boolean | Date | [number, number] | [string, string] | string[] | number[];
238
330
 
239
331
  export declare type GetDashboardResponse = {
240
332
  dashboard: TDashboard;
@@ -258,10 +350,42 @@ declare interface GroupByColumn extends BaseColumn {
258
350
  format?: string;
259
351
  }
260
352
 
353
+ declare interface GroupByField extends Field {
354
+ role: 'groupby';
355
+ granularity?: 'day' | 'week' | 'month' | 'quarter' | 'year';
356
+ }
357
+
261
358
  export declare type HtmlOptions = {
262
359
  html: string;
263
360
  };
264
361
 
362
+ declare interface Join {
363
+ id: string;
364
+ source: DatabaseEntityReference;
365
+ target: DatabaseEntityReference;
366
+ joinType: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL';
367
+ joinKeyGroups: JoinKeyGroup[];
368
+ sequence: number;
369
+ }
370
+
371
+ declare interface JoinKey {
372
+ id?: string;
373
+ source: Field;
374
+ target: Field;
375
+ operator: string;
376
+ }
377
+
378
+ declare interface JoinKeyGroup {
379
+ id: string;
380
+ operator: string;
381
+ keys: JoinKey[];
382
+ }
383
+
384
+ declare interface JoinPlan {
385
+ baseEntity: DatabaseEntityReference;
386
+ joins: Join[];
387
+ }
388
+
265
389
  export declare type KPICardProps = {
266
390
  card: TCard;
267
391
  isLoading?: boolean;
@@ -274,12 +398,21 @@ export declare type LoadingProps = {
274
398
  message?: string;
275
399
  };
276
400
 
401
+ declare type LogicalOperator = 'AND' | 'OR';
402
+
277
403
  declare interface MetricColumn extends BaseColumn {
278
404
  role: 'metric';
279
405
  aggregate: AggregateFunction;
280
406
  aliasTemplate?: string;
281
407
  }
282
408
 
409
+ declare interface MetricField extends Field {
410
+ role: 'metric';
411
+ aggregate: AggregateFunction;
412
+ aliasTemplate?: string;
413
+ valueAliases?: Record<string, string>;
414
+ }
415
+
283
416
  declare type NoneOptions = {};
284
417
 
285
418
  export declare type NumberAxisFormat = {
@@ -296,8 +429,12 @@ export declare type NumberOptions = {
296
429
  colorRanges?: ColorRange[];
297
430
  };
298
431
 
432
+ declare type OldFilterValue = string | number | null | (string | number)[] | RangeValue;
433
+
299
434
  declare type Operation = '=' | '>' | '<' | '>=' | '<=' | '!=' | 'in' | 'not in' | 'like' | 'not like' | 'between' | 'not between' | 'is null' | 'is not null';
300
435
 
436
+ declare type Operator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'contains' | 'startsWith' | 'endsWith' | 'in' | 'not in';
437
+
301
438
  declare type OptionsMap = {
302
439
  number: NumberOptions;
303
440
  string: StringOptions;
@@ -315,6 +452,10 @@ declare type Params = {
315
452
  [key: string]: string | number | string[] | number[];
316
453
  };
317
454
 
455
+ declare interface PivotByField extends Field {
456
+ role: 'pivotby';
457
+ }
458
+
318
459
  export declare type Placeholders = {
319
460
  /**
320
461
  * Placeholder for the card when there are no records to display.
@@ -338,7 +479,7 @@ declare interface QueryConfig {
338
479
 
339
480
  declare type QueryFilter = {
340
481
  filterColumnName: string;
341
- filterValue: FilterValue;
482
+ filterValue: OldFilterValue;
342
483
  };
343
484
 
344
485
  declare type RangeValue = {
@@ -348,8 +489,15 @@ declare type RangeValue = {
348
489
  gt?: string | number;
349
490
  };
350
491
 
492
+ declare type SelectedEntities = DatabaseEntityReference[] | DataModelEntityReference[] | FileEntityReference[];
493
+
351
494
  export declare type SelectionState = Record<Level, string | null>;
352
495
 
496
+ declare interface SortByField extends Field {
497
+ role: 'sortby';
498
+ direction: 'asc' | 'desc';
499
+ }
500
+
353
501
  export declare type SqlGen = {
354
502
  measures?: {
355
503
  name: string;
@@ -431,6 +579,8 @@ export declare type TCard = {
431
579
  type: TChartType;
432
580
  sql?: string;
433
581
  python?: string;
582
+ dataSource?: DataSource;
583
+ config?: CardConfig;
434
584
  queryConfig?: QueryConfig;
435
585
  customCfg?: any;
436
586
  preferences?: TCardPreferences;
@@ -572,6 +722,8 @@ export declare type TDataColumn = {
572
722
  column_name: string;
573
723
  data_type: string;
574
724
  is_nullable?: string;
725
+ label?: string;
726
+ description?: string;
575
727
  };
576
728
 
577
729
  export declare type TDatasetOptions = {
@@ -625,6 +777,8 @@ export declare type TFrame = {
625
777
 
626
778
  export declare type Theme = 'dark' | 'light' | 'system';
627
779
 
780
+ declare type TimeGranularity = 'day' | 'week' | 'month' | 'quarter' | 'year';
781
+
628
782
  export declare type TLegendOptions = {
629
783
  display?: boolean;
630
784
  position?: 'top' | 'left' | 'bottom' | 'right';
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.0.490",
8
+ "version": "0.0.491",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",