semaphor 0.0.99 → 0.0.101

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,11 @@ 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
+
8
+ declare type AIContext = {
9
+ selectedEntities: SelectedEntities;
10
+ };
7
11
 
8
12
  export declare type AIScopeTable = {
9
13
  connectionId: string;
@@ -50,6 +54,16 @@ export declare type CacheConfig = {
50
54
  status: 'on' | 'on-refresh' | 'off';
51
55
  };
52
56
 
57
+ declare interface CardConfig {
58
+ groupByColumns?: GroupByField[];
59
+ metricColumns?: MetricField[];
60
+ pivotByColumns?: PivotByField[];
61
+ sortByColumns?: SortByField[];
62
+ filters?: FilterGroup;
63
+ joinPlan?: JoinPlan;
64
+ rowLimit?: number;
65
+ }
66
+
53
67
  declare type CardWithContent = BaseCustomCard & {
54
68
  content: React.FC<{
55
69
  card: TCard;
@@ -116,6 +130,8 @@ export declare type ConnectionPolicy = {
116
130
  params: Params;
117
131
  };
118
132
 
133
+ declare type ConnectionType = 'GoogleSheets' | 'MySQL' | 'MSSQL' | 'PostgreSQL' | 'BigQuery' | 'Redshift' | 'Snowflake' | 'S3' | 'clickhouse' | 'S3Tables' | 'API' | 'none';
134
+
119
135
  export declare type CustomCard = CardWithContent | CardWithFooter;
120
136
 
121
137
  export declare function Dashboard(props: DashboardProps): JSX_2.Element;
@@ -159,12 +175,50 @@ export declare type DashboardProps = {
159
175
  selectedSheetId?: string;
160
176
  };
161
177
 
178
+ declare interface DatabaseEntityReference {
179
+ connectionId: string;
180
+ connectionType: ConnectionType;
181
+ type: EntityType;
182
+ dialect?: Dialect;
183
+ database?: string;
184
+ schema?: string;
185
+ name: string;
186
+ }
187
+
188
+ declare type DatabaseEntityType = 'table' | 'view';
189
+
190
+ declare interface DataModelEntityReference extends DatabaseEntityReference {
191
+ type: 'model';
192
+ id: string;
193
+ label: string;
194
+ description: string;
195
+ }
196
+
197
+ declare interface DataSource {
198
+ connectionId: string;
199
+ semanticDomainId?: string;
200
+ connectionType: string;
201
+ mode: 'database' | 'upload' | 'url' | 'semanticDomain';
202
+ dbSelection?: {
203
+ database: string;
204
+ schema: string;
205
+ entityType: DatabaseEntityType;
206
+ };
207
+ selectedEntities: SelectedEntities;
208
+ }
209
+
210
+ 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"];
211
+
212
+ declare type DateFormatValue = (typeof DATE_FORMAT_VALUES)[number];
213
+
162
214
  export declare type DateOptions = {
163
215
  locale: string;
164
216
  format: string;
165
217
  options: Intl.DateTimeFormatOptions;
166
218
  };
167
219
 
220
+ declare type Dialect = 'mysql' | 'postgresql' | 'bigquery' | 'redshift' | 'snowflake' | 'clickhouse' | 'duckdb';
221
+
168
222
  export declare type DisplayDataType = 'string' | 'date' | 'number' | 'html' | 'none';
169
223
 
170
224
  export declare type DroppableId = 'droppable-group-by' | 'droppable-metric';
@@ -178,6 +232,8 @@ export declare type EmailSettings = {
178
232
 
179
233
  export declare const EMPTY_SELECTION: SelectionState;
180
234
 
235
+ declare type EntityType = 'table' | 'view' | 'model' | 'file' | 'dataset' | 'url' | 'upload';
236
+
181
237
  export declare type ErrorProps = {
182
238
  message?: string;
183
239
  };
@@ -189,6 +245,49 @@ export declare type ExportDataPayload = {
189
245
  sql: string;
190
246
  };
191
247
 
248
+ declare interface Field {
249
+ /**
250
+ * Unique identifier for this field instance (for joins, UI state, etc.).
251
+ * Should be unique within the context of the query or data model.
252
+ * Example: 'orders.customer_id', 'expr_12345', etc.
253
+ */
254
+ id: string;
255
+ /**
256
+ * The physical/source column name in the database or data source.
257
+ * Used for mapping to the underlying data model and SQL generation (unless overridden by expression).
258
+ */
259
+ name: string;
260
+ /**
261
+ * Human-friendly, localizable display name for the UI (table headers, chart axes, etc.).
262
+ */
263
+ label: string;
264
+ /**
265
+ * Unique, stable, machine-friendly reference name for SQL (AS alias), exports, and scripting.
266
+ * If not provided, should be auto-generated from label or name.
267
+ */
268
+ alias?: string;
269
+ dataType: string;
270
+ description?: string;
271
+ qualifiedEntityName?: string;
272
+ dateFormat?: DateFormatValue;
273
+ customFormat?: string;
274
+ granularity?: TimeGranularity;
275
+ entityId: string;
276
+ entityName: string;
277
+ entityType: EntityType;
278
+ role?: 'groupby' | 'metric' | 'sortby' | 'pivotby';
279
+ }
280
+
281
+ declare interface FileEntityReference extends DatabaseEntityReference {
282
+ id: string;
283
+ type: 'file' | 'url' | 'upload';
284
+ label: string;
285
+ description: string;
286
+ originalName: string;
287
+ file?: File;
288
+ url?: string;
289
+ }
290
+
192
291
  declare interface FilterByColumn extends BaseColumn {
193
292
  role: 'filter';
194
293
  operators?: string[];
@@ -200,6 +299,13 @@ declare interface FilterByColumn extends BaseColumn {
200
299
  staticValues?: string[];
201
300
  }
202
301
 
302
+ declare interface FilterCondition {
303
+ id: string;
304
+ field: Field;
305
+ operator: Operator;
306
+ value: FilterValue;
307
+ }
308
+
203
309
  declare type FilterForBetween = BaseFilter & {
204
310
  operation: 'between' | 'not between';
205
311
  values: [number, number];
@@ -230,6 +336,14 @@ declare type FilterForString = BaseFilter & {
230
336
  values: [string];
231
337
  };
232
338
 
339
+ declare interface FilterGroup {
340
+ id: string;
341
+ logicalOperator: LogicalOperator;
342
+ negate: boolean;
343
+ conditions: FilterCondition[];
344
+ groups: FilterGroup[];
345
+ }
346
+
233
347
  declare type FilterLocation = 'dashboard' | 'frame' | undefined;
234
348
 
235
349
  declare type FilterOnClick = {
@@ -237,7 +351,7 @@ declare type FilterOnClick = {
237
351
  columnIndex: number;
238
352
  };
239
353
 
240
- declare type FilterValue = string | number | null | (string | number)[] | RangeValue;
354
+ declare type FilterValue = string | number | boolean | Date | [number, number] | [string, string] | string[] | number[];
241
355
 
242
356
  export declare type GetDashboardResponse = {
243
357
  dashboard: TDashboard;
@@ -261,10 +375,47 @@ declare interface GroupByColumn extends BaseColumn {
261
375
  format?: string;
262
376
  }
263
377
 
378
+ declare interface GroupByField extends Field {
379
+ role: 'groupby';
380
+ granularity?: 'day' | 'week' | 'month' | 'quarter' | 'year';
381
+ /**
382
+ * Optional SQL expression for grouping (e.g., DATE_TRUNC('month', order_date)).
383
+ * If present, used in SELECT and GROUP BY instead of just the column name.
384
+ */
385
+ expression?: string;
386
+ }
387
+
264
388
  export declare type HtmlOptions = {
265
389
  html: string;
266
390
  };
267
391
 
392
+ declare interface Join {
393
+ id: string;
394
+ source: DatabaseEntityReference;
395
+ target: DatabaseEntityReference;
396
+ joinType: 'INNER' | 'LEFT' | 'RIGHT' | 'FULL';
397
+ joinKeyGroups: JoinKeyGroup[];
398
+ sequence: number;
399
+ }
400
+
401
+ declare interface JoinKey {
402
+ id?: string;
403
+ source: Field;
404
+ target: Field;
405
+ operator: string;
406
+ }
407
+
408
+ declare interface JoinKeyGroup {
409
+ id: string;
410
+ operator: string;
411
+ keys: JoinKey[];
412
+ }
413
+
414
+ declare interface JoinPlan {
415
+ baseEntity: DatabaseEntityReference;
416
+ joins: Join[];
417
+ }
418
+
268
419
  export declare type KPICardProps = {
269
420
  card: TCard;
270
421
  isLoading?: boolean;
@@ -277,12 +428,46 @@ export declare type LoadingProps = {
277
428
  message?: string;
278
429
  };
279
430
 
431
+ declare type LogicalOperator = 'AND' | 'OR';
432
+
280
433
  declare interface MetricColumn extends BaseColumn {
281
434
  role: 'metric';
282
435
  aggregate: AggregateFunction;
283
436
  aliasTemplate?: string;
284
437
  }
285
438
 
439
+ declare interface MetricField extends Field {
440
+ role: 'metric';
441
+ aggregate: AggregateFunction;
442
+ /**
443
+ * Optional SQL expression for the metric (e.g., ship_date - order_date).
444
+ * If present, used as aggregate(expression) instead of aggregate(name).
445
+ */
446
+ expression?: string;
447
+ /**
448
+ * Optional parameters for future extensibility (e.g., window functions).
449
+ * * Example:
450
+ * {
451
+ aggregate: "SUM",
452
+ name: "sales",
453
+ parameters: {
454
+ window: "PARTITION BY region ORDER BY date ROWS BETWEEN 1 PRECEDING AND CURRENT ROW"
455
+ }
456
+ }
457
+
458
+ {
459
+ aggregate: "COUNT",
460
+ name: "order_id",
461
+ parameters: {
462
+ filter: "status = 'Active'"
463
+ }
464
+ }
465
+ */
466
+ parameters?: Record<string, any>;
467
+ aliasTemplate?: string;
468
+ valueAliases?: Record<string, string>;
469
+ }
470
+
286
471
  declare type NoneOptions = {};
287
472
 
288
473
  export declare type NumberAxisFormat = {
@@ -299,8 +484,12 @@ export declare type NumberOptions = {
299
484
  colorRanges?: ColorRange[];
300
485
  };
301
486
 
487
+ declare type OldFilterValue = string | number | null | (string | number)[] | RangeValue;
488
+
302
489
  declare type Operation = '=' | '>' | '<' | '>=' | '<=' | '!=' | 'in' | 'not in' | 'like' | 'not like' | 'between' | 'not between' | 'is null' | 'is not null';
303
490
 
491
+ declare type Operator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'contains' | 'startsWith' | 'endsWith' | 'in' | 'not in';
492
+
304
493
  declare type OptionsMap = {
305
494
  number: NumberOptions;
306
495
  string: StringOptions;
@@ -318,6 +507,10 @@ declare type Params = {
318
507
  [key: string]: string | number | string[] | number[];
319
508
  };
320
509
 
510
+ declare interface PivotByField extends Field {
511
+ role: 'pivotby';
512
+ }
513
+
321
514
  export declare type Placeholders = {
322
515
  /**
323
516
  * Placeholder for the card when there are no records to display.
@@ -341,7 +534,7 @@ declare interface QueryConfig {
341
534
 
342
535
  declare type QueryFilter = {
343
536
  filterColumnName: string;
344
- filterValue: FilterValue;
537
+ filterValue: OldFilterValue;
345
538
  };
346
539
 
347
540
  declare type RangeValue = {
@@ -351,8 +544,15 @@ declare type RangeValue = {
351
544
  gt?: string | number;
352
545
  };
353
546
 
547
+ declare type SelectedEntities = DatabaseEntityReference[] | DataModelEntityReference[] | FileEntityReference[];
548
+
354
549
  export declare type SelectionState = Record<Level, string | null>;
355
550
 
551
+ declare interface SortByField extends Field {
552
+ role: 'sortby';
553
+ direction: 'asc' | 'desc';
554
+ }
555
+
356
556
  export declare type SqlGen = {
357
557
  measures?: {
358
558
  name: string;
@@ -434,6 +634,8 @@ export declare type TCard = {
434
634
  type: TChartType;
435
635
  sql?: string;
436
636
  python?: string;
637
+ dataSource?: DataSource;
638
+ config?: CardConfig;
437
639
  queryConfig?: QueryConfig;
438
640
  customCfg?: any;
439
641
  preferences?: TCardPreferences;
@@ -558,6 +760,7 @@ export declare type TCustomCardPreferences = {
558
760
  export declare type TDashboard = {
559
761
  id: string;
560
762
  title?: string;
763
+ aiContext?: AIContext;
561
764
  description?: string;
562
765
  sheets?: TSheet[];
563
766
  style?: TStyle;
@@ -575,6 +778,8 @@ export declare type TDataColumn = {
575
778
  column_name: string;
576
779
  data_type: string;
577
780
  is_nullable?: string;
781
+ label?: string;
782
+ description?: string;
578
783
  };
579
784
 
580
785
  export declare type TDatasetOptions = {
@@ -628,6 +833,8 @@ export declare type TFrame = {
628
833
 
629
834
  export declare type Theme = 'dark' | 'light' | 'system';
630
835
 
836
+ declare type TimeGranularity = 'day' | 'week' | 'month' | 'quarter' | 'year';
837
+
631
838
  export declare type TLegendOptions = {
632
839
  display?: boolean;
633
840
  position?: 'top' | 'left' | 'bottom' | 'right';