react-semaphor 0.1.370 → 0.1.371

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.
Files changed (52) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +40 -38
  3. package/dist/chunks/{calendar-preferences-dialog-6q51A6XC.js → calendar-preferences-dialog-ClBAkMmF.js} +1 -1
  4. package/dist/chunks/{calendar-preferences-dialog-CUGzkNcE.js → calendar-preferences-dialog-Dn6o2r2Y.js} +1 -1
  5. package/dist/chunks/{dashboard-briefing-launcher-BEZnvIla.js → dashboard-briefing-launcher-BO-kXtEd.js} +1 -1
  6. package/dist/chunks/{dashboard-briefing-launcher-ptERmNJr.js → dashboard-briefing-launcher-D3Xfc_26.js} +3 -3
  7. package/dist/chunks/{dashboard-controls-CqKC5oEk.js → dashboard-controls-B3sdy_Zx.js} +3 -3
  8. package/dist/chunks/{dashboard-controls-CGt6_hMf.js → dashboard-controls-DcXMFgGR.js} +1 -1
  9. package/dist/chunks/{dashboard-json-6SgPm_QW.js → dashboard-json-BWfkEy48.js} +1 -1
  10. package/dist/chunks/{dashboard-json-CYSbOdmE.js → dashboard-json-CFURS_OR.js} +1 -1
  11. package/dist/chunks/{edit-dashboard-visual-w6hKbjlw.js → edit-dashboard-visual-BD2AJLiT.js} +1 -1
  12. package/dist/chunks/{edit-dashboard-visual-ByQx_M2i.js → edit-dashboard-visual-DjdhKiP2.js} +3 -3
  13. package/dist/chunks/{index-CPyEi9gS.js → index-C0Qnfr_7.js} +5 -4
  14. package/dist/chunks/{index-BtqYNH_S.js → index-DlLvzmJF.js} +2 -2
  15. package/dist/chunks/{resource-management-panel-Bf8-3eUf.js → resource-management-panel-DytUMSGA.js} +1 -1
  16. package/dist/chunks/{resource-management-panel-mJ84NxzC.js → resource-management-panel-YvIfaphX.js} +2 -2
  17. package/dist/chunks/{use-create-flow-overlay-state-BfoXDDrd.js → use-create-flow-overlay-state-BETXykC9.js} +2 -2
  18. package/dist/chunks/{use-create-flow-overlay-state-c6rCm36x.js → use-create-flow-overlay-state-CwIG1Ekp.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-NN0e3fBP.js → use-visual-utils-Bk135OgA.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-C_c-aiqi.js → use-visual-utils-BzFjIykb.js} +1 -1
  21. package/dist/chunks/{validation-PPSpYtVf.js → validation-CQFpcSSP.js} +295 -192
  22. package/dist/chunks/validation-D4Zz6WPD.js +1 -0
  23. package/dist/chunks/{validators-DBNa-eb1.js → validators-CuKnUZFO.js} +717 -345
  24. package/dist/chunks/validators-DHee9kM2.js +1 -0
  25. package/dist/dashboard/index.cjs +1 -1
  26. package/dist/dashboard/index.js +1 -1
  27. package/dist/dashboard-authoring/index.cjs +1 -1
  28. package/dist/dashboard-authoring/index.js +1 -1
  29. package/dist/data-app-builder/index.cjs +1 -1
  30. package/dist/data-app-builder/index.js +1 -1
  31. package/dist/data-app-sdk/index.cjs +1 -1
  32. package/dist/data-app-sdk/index.js +56 -49
  33. package/dist/data-app-sdk-validation/index.cjs +1 -1
  34. package/dist/data-app-sdk-validation/index.js +5 -4
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.js +5 -5
  37. package/dist/surfboard/index.cjs +1 -1
  38. package/dist/surfboard/index.js +2 -2
  39. package/dist/types/analytics-protocol.d.ts +91 -0
  40. package/dist/types/dashboard-assistant.d.ts +60 -2
  41. package/dist/types/dashboard-authoring.d.ts +58 -2
  42. package/dist/types/dashboard.d.ts +67 -2
  43. package/dist/types/data-app-builder.d.ts +41 -0
  44. package/dist/types/data-app-sdk-validation.d.ts +50 -3
  45. package/dist/types/data-app-sdk.d.ts +53 -3
  46. package/dist/types/main.d.ts +59 -2
  47. package/dist/types/shared.d.ts +66 -2
  48. package/dist/types/surfboard.d.ts +67 -2
  49. package/dist/types/types.d.ts +67 -2
  50. package/package.json +1 -1
  51. package/dist/chunks/validation-DYL3ArlL.js +0 -1
  52. package/dist/chunks/validators-CgxWT8UX.js +0 -1
@@ -2,8 +2,14 @@ declare type AggregateFunction = 'COUNT' | 'SUM' | 'AVG' | 'MIN' | 'MAX' | 'MEDI
2
2
 
3
3
  /**
4
4
  * Formula metadata for calculated fields (UI-only metadata)
5
- * This is supplementary data to help the UI display and edit calculated fields.
6
- * The `expression` field remains the source of truth for the backend.
5
+ * This is supplementary runtime/compiler data to help dashboard UI display,
6
+ * edit, and execute calculated fields.
7
+ *
8
+ * Public source-level calculation metadata belongs in `Field.derivedField`
9
+ * (`SemaphorDerivedFieldDefinition`). `calculatedFormula` deliberately uses
10
+ * indexed `{field_N}` tokens and full runtime Field objects so current dashboard
11
+ * query execution can resolve aliases, joins, filters, and aggregates without
12
+ * doing catalog lookups.
7
13
  *
8
14
  * IMPORTANT: This metadata is ALWAYS updated atomically with the expression field.
9
15
  * Both are generated together from the same dialog inputs, preventing drift.
@@ -389,6 +395,15 @@ declare interface Field {
389
395
  role?: 'groupby' | 'metric' | 'sortby' | 'pivotby' | 'detail';
390
396
  expression?: string;
391
397
  calculatedFormula?: CalculatedFieldFormula;
398
+ /**
399
+ * Public, source-level derived-field metadata for semantic/domain-authored
400
+ * calculations. This is the AI/MCP/Data App-facing contract: named-token
401
+ * expression, typed inputs, result role, and compute stage.
402
+ *
403
+ * Dashboard-local calculated fields may omit this because they are local
404
+ * runtime artifacts rather than semantic-domain definitions.
405
+ */
406
+ derivedField?: SemaphorDerivedFieldDefinition;
392
407
  format?: FormatSpec;
393
408
  aggregate?: AggregateFunction;
394
409
  fieldScope?: FieldScope;
@@ -1017,12 +1032,51 @@ declare type SemaphorCompiledQuery = {
1017
1032
  analyticsIntent?: SemaphorAnalyticsIntent;
1018
1033
  };
1019
1034
 
1035
+ declare type SemaphorDerivedFieldAggregationBehavior = 'additive' | 'non_additive' | 'ratio_of_sums' | 'weighted' | 'pre_aggregated' | 'snapshot';
1036
+
1037
+ declare type SemaphorDerivedFieldAggregationStrategy = 'default' | 'symmetric_aggregate' | 'aggregate_then_join' | 'weighted';
1038
+
1039
+ declare type SemaphorDerivedFieldComputeStage = 'row' | 'aggregate';
1040
+
1041
+ declare type SemaphorDerivedFieldDefinition = {
1042
+ kind: 'derived_field';
1043
+ name: string;
1044
+ label: string;
1045
+ description?: string;
1046
+ resultRole: SemaphorDerivedFieldResultRole;
1047
+ dataType: NonNullable<SemaphorFieldRef['dataType']>;
1048
+ computeStage: SemaphorDerivedFieldComputeStage;
1049
+ expression: string;
1050
+ expressionLanguage?: 'semaphor_sql_template';
1051
+ inputs: Record<string, SemaphorDerivedFieldInput>;
1052
+ defaultAggregate?: SemaphorAggregateFunction;
1053
+ aggregationBehavior?: SemaphorDerivedFieldAggregationBehavior;
1054
+ aggregationStrategy?: SemaphorDerivedFieldAggregationStrategy;
1055
+ format?: unknown;
1056
+ tags?: string[];
1057
+ };
1058
+
1059
+ declare type SemaphorDerivedFieldInput = {
1060
+ kind: 'field';
1061
+ field: SemaphorFieldRef;
1062
+ aggregate?: SemaphorAggregateFunction;
1063
+ } | {
1064
+ kind: 'metric';
1065
+ metric: SemaphorFieldRef;
1066
+ } | {
1067
+ kind: 'dimension';
1068
+ dimension: SemaphorFieldRef;
1069
+ };
1070
+
1071
+ declare type SemaphorDerivedFieldResultRole = 'measure' | 'group' | 'date' | 'id' | 'filter';
1072
+
1020
1073
  declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
1021
1074
 
1022
1075
  declare type SemaphorExecutionFieldRef = SemaphorFieldRef & {
1023
1076
  semanticAggregate?: SemaphorAggregateFunction;
1024
1077
  effectiveAggregate?: SemaphorAggregateFunction;
1025
1078
  aggregateSource?: SemaphorMetricAggregateSource;
1079
+ derivedField?: SemaphorDerivedFieldDefinition;
1026
1080
  };
1027
1081
 
1028
1082
  /**
@@ -1061,6 +1115,7 @@ declare type SemaphorInputOptionsIntent = {
1061
1115
  field: SemaphorFieldRef;
1062
1116
  search?: string;
1063
1117
  limit?: number;
1118
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1064
1119
  };
1065
1120
 
1066
1121
  declare type SemaphorInputOptionsResult = SemaphorAnalyticsResultBase & {
@@ -1256,6 +1311,7 @@ declare type SemaphorMetricIntent = {
1256
1311
  };
1257
1312
  inputs?: SemaphorInputBinding[];
1258
1313
  limit?: number;
1314
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1259
1315
  };
1260
1316
 
1261
1317
  declare type SemaphorMetricResult = SemaphorAnalyticsResultBase & {
@@ -1311,6 +1367,7 @@ declare type SemaphorRecordsIntent = {
1311
1367
  direction: 'asc' | 'desc';
1312
1368
  };
1313
1369
  inputs?: SemaphorInputBinding[];
1370
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1314
1371
  };
1315
1372
 
1316
1373
  declare type SemaphorRecordsResult = SemaphorAnalyticsResultBase & {
@@ -1366,6 +1423,7 @@ declare type SemaphorResultColumn = {
1366
1423
  dataType?: SemaphorFieldRef['dataType'];
1367
1424
  aggregate?: SemaphorFieldRef['aggregate'];
1368
1425
  source?: SemaphorFieldRef['source'];
1426
+ derivedField?: SemaphorDerivedFieldDefinition;
1369
1427
  };
1370
1428
 
1371
1429
  declare type SemaphorSemanticSourceRef = Extract<SemaphorSourceRef, {
@@ -81,8 +81,14 @@ declare type CacheConfig = {
81
81
 
82
82
  /**
83
83
  * Formula metadata for calculated fields (UI-only metadata)
84
- * This is supplementary data to help the UI display and edit calculated fields.
85
- * The `expression` field remains the source of truth for the backend.
84
+ * This is supplementary runtime/compiler data to help dashboard UI display,
85
+ * edit, and execute calculated fields.
86
+ *
87
+ * Public source-level calculation metadata belongs in `Field.derivedField`
88
+ * (`SemaphorDerivedFieldDefinition`). `calculatedFormula` deliberately uses
89
+ * indexed `{field_N}` tokens and full runtime Field objects so current dashboard
90
+ * query execution can resolve aliases, joins, filters, and aggregates without
91
+ * doing catalog lookups.
86
92
  *
87
93
  * IMPORTANT: This metadata is ALWAYS updated atomically with the expression field.
88
94
  * Both are generated together from the same dialog inputs, preventing drift.
@@ -1251,6 +1257,15 @@ declare interface Field {
1251
1257
  role?: 'groupby' | 'metric' | 'sortby' | 'pivotby' | 'detail';
1252
1258
  expression?: string;
1253
1259
  calculatedFormula?: CalculatedFieldFormula;
1260
+ /**
1261
+ * Public, source-level derived-field metadata for semantic/domain-authored
1262
+ * calculations. This is the AI/MCP/Data App-facing contract: named-token
1263
+ * expression, typed inputs, result role, and compute stage.
1264
+ *
1265
+ * Dashboard-local calculated fields may omit this because they are local
1266
+ * runtime artifacts rather than semantic-domain definitions.
1267
+ */
1268
+ derivedField?: SemaphorDerivedFieldDefinition;
1254
1269
  format?: FormatSpec;
1255
1270
  aggregate?: AggregateFunction;
1256
1271
  fieldScope?: FieldScope;
@@ -1869,6 +1884,44 @@ declare type SemaphorDashboardViewIntent = {
1869
1884
  text?: string;
1870
1885
  };
1871
1886
 
1887
+ declare type SemaphorDerivedFieldAggregationBehavior = 'additive' | 'non_additive' | 'ratio_of_sums' | 'weighted' | 'pre_aggregated' | 'snapshot';
1888
+
1889
+ declare type SemaphorDerivedFieldAggregationStrategy = 'default' | 'symmetric_aggregate' | 'aggregate_then_join' | 'weighted';
1890
+
1891
+ declare type SemaphorDerivedFieldComputeStage = 'row' | 'aggregate';
1892
+
1893
+ declare type SemaphorDerivedFieldDefinition = {
1894
+ kind: 'derived_field';
1895
+ name: string;
1896
+ label: string;
1897
+ description?: string;
1898
+ resultRole: SemaphorDerivedFieldResultRole;
1899
+ dataType: NonNullable<SemaphorFieldRef['dataType']>;
1900
+ computeStage: SemaphorDerivedFieldComputeStage;
1901
+ expression: string;
1902
+ expressionLanguage?: 'semaphor_sql_template';
1903
+ inputs: Record<string, SemaphorDerivedFieldInput>;
1904
+ defaultAggregate?: SemaphorAggregateFunction;
1905
+ aggregationBehavior?: SemaphorDerivedFieldAggregationBehavior;
1906
+ aggregationStrategy?: SemaphorDerivedFieldAggregationStrategy;
1907
+ format?: unknown;
1908
+ tags?: string[];
1909
+ };
1910
+
1911
+ declare type SemaphorDerivedFieldInput = {
1912
+ kind: 'field';
1913
+ field: SemaphorFieldRef;
1914
+ aggregate?: SemaphorAggregateFunction;
1915
+ } | {
1916
+ kind: 'metric';
1917
+ metric: SemaphorFieldRef;
1918
+ } | {
1919
+ kind: 'dimension';
1920
+ dimension: SemaphorFieldRef;
1921
+ };
1922
+
1923
+ declare type SemaphorDerivedFieldResultRole = 'measure' | 'group' | 'date' | 'id' | 'filter';
1924
+
1872
1925
  declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
1873
1926
 
1874
1927
  /**
@@ -1911,6 +1964,7 @@ declare type SemaphorInputOptionsIntent = {
1911
1964
  field: SemaphorFieldRef;
1912
1965
  search?: string;
1913
1966
  limit?: number;
1967
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1914
1968
  };
1915
1969
 
1916
1970
  declare type SemaphorInputScope = {
@@ -2110,6 +2164,7 @@ declare type SemaphorMetricIntent = {
2110
2164
  };
2111
2165
  inputs?: SemaphorInputBinding[];
2112
2166
  limit?: number;
2167
+ derivedFields?: SemaphorDerivedFieldDefinition[];
2113
2168
  };
2114
2169
 
2115
2170
  declare type SemaphorPaginationRequest = {
@@ -2137,6 +2192,7 @@ declare type SemaphorRecordsIntent = {
2137
2192
  direction: 'asc' | 'desc';
2138
2193
  };
2139
2194
  inputs?: SemaphorInputBinding[];
2195
+ derivedFields?: SemaphorDerivedFieldDefinition[];
2140
2196
  };
2141
2197
 
2142
2198
  declare type SemaphorRelativeTimeWindow = {
@@ -158,8 +158,14 @@ export declare type CacheConfig = {
158
158
 
159
159
  /**
160
160
  * Formula metadata for calculated fields (UI-only metadata)
161
- * This is supplementary data to help the UI display and edit calculated fields.
162
- * The `expression` field remains the source of truth for the backend.
161
+ * This is supplementary runtime/compiler data to help dashboard UI display,
162
+ * edit, and execute calculated fields.
163
+ *
164
+ * Public source-level calculation metadata belongs in `Field.derivedField`
165
+ * (`SemaphorDerivedFieldDefinition`). `calculatedFormula` deliberately uses
166
+ * indexed `{field_N}` tokens and full runtime Field objects so current dashboard
167
+ * query execution can resolve aliases, joins, filters, and aggregates without
168
+ * doing catalog lookups.
163
169
  *
164
170
  * IMPORTANT: This metadata is ALWAYS updated atomically with the expression field.
165
171
  * Both are generated together from the same dialog inputs, preventing drift.
@@ -1288,6 +1294,15 @@ declare interface Field {
1288
1294
  role?: 'groupby' | 'metric' | 'sortby' | 'pivotby' | 'detail';
1289
1295
  expression?: string;
1290
1296
  calculatedFormula?: CalculatedFieldFormula;
1297
+ /**
1298
+ * Public, source-level derived-field metadata for semantic/domain-authored
1299
+ * calculations. This is the AI/MCP/Data App-facing contract: named-token
1300
+ * expression, typed inputs, result role, and compute stage.
1301
+ *
1302
+ * Dashboard-local calculated fields may omit this because they are local
1303
+ * runtime artifacts rather than semantic-domain definitions.
1304
+ */
1305
+ derivedField?: SemaphorDerivedFieldDefinition;
1291
1306
  format?: FormatSpec;
1292
1307
  aggregate?: AggregateFunction;
1293
1308
  fieldScope?: FieldScope;
@@ -1907,8 +1922,57 @@ declare type SemanticExecutionPayload = {
1907
1922
  }>;
1908
1923
  };
1909
1924
 
1925
+ declare type SemaphorAggregateFunction = 'SUM' | 'COUNT' | 'AVG' | 'MIN' | 'MAX' | 'MEDIAN' | 'DISTINCT';
1926
+
1927
+ declare type SemaphorDerivedFieldAggregationBehavior = 'additive' | 'non_additive' | 'ratio_of_sums' | 'weighted' | 'pre_aggregated' | 'snapshot';
1928
+
1929
+ declare type SemaphorDerivedFieldAggregationStrategy = 'default' | 'symmetric_aggregate' | 'aggregate_then_join' | 'weighted';
1930
+
1931
+ declare type SemaphorDerivedFieldComputeStage = 'row' | 'aggregate';
1932
+
1933
+ declare type SemaphorDerivedFieldDefinition = {
1934
+ kind: 'derived_field';
1935
+ name: string;
1936
+ label: string;
1937
+ description?: string;
1938
+ resultRole: SemaphorDerivedFieldResultRole;
1939
+ dataType: NonNullable<SemaphorFieldRef['dataType']>;
1940
+ computeStage: SemaphorDerivedFieldComputeStage;
1941
+ expression: string;
1942
+ expressionLanguage?: 'semaphor_sql_template';
1943
+ inputs: Record<string, SemaphorDerivedFieldInput>;
1944
+ defaultAggregate?: SemaphorAggregateFunction;
1945
+ aggregationBehavior?: SemaphorDerivedFieldAggregationBehavior;
1946
+ aggregationStrategy?: SemaphorDerivedFieldAggregationStrategy;
1947
+ format?: unknown;
1948
+ tags?: string[];
1949
+ };
1950
+
1951
+ declare type SemaphorDerivedFieldInput = {
1952
+ kind: 'field';
1953
+ field: SemaphorFieldRef;
1954
+ aggregate?: SemaphorAggregateFunction;
1955
+ } | {
1956
+ kind: 'metric';
1957
+ metric: SemaphorFieldRef;
1958
+ } | {
1959
+ kind: 'dimension';
1960
+ dimension: SemaphorFieldRef;
1961
+ };
1962
+
1963
+ declare type SemaphorDerivedFieldResultRole = 'measure' | 'group' | 'date' | 'id' | 'filter';
1964
+
1910
1965
  declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
1911
1966
 
1967
+ declare type SemaphorFieldRef = {
1968
+ name: string;
1969
+ label?: string;
1970
+ role?: 'dimension' | 'measure' | 'date' | 'id' | 'unknown';
1971
+ dataType?: 'string' | 'number' | 'boolean' | 'date' | 'datetime' | 'unknown';
1972
+ source?: SemaphorSourceRef;
1973
+ aggregate?: SemaphorAggregateFunction;
1974
+ };
1975
+
1912
1976
  declare type SemaphorSourceRef = {
1913
1977
  kind: 'semantic';
1914
1978
  domainId: string;
@@ -2566,6 +2630,7 @@ export declare type TDataColumn = {
2566
2630
  role?: 'groupby' | 'metric' | 'sortby' | 'pivotby' | 'detail';
2567
2631
  expression?: string;
2568
2632
  calculatedFormula?: CalculatedFieldFormula;
2633
+ derivedField?: SemaphorDerivedFieldDefinition;
2569
2634
  format?: FormatSpec;
2570
2635
  sourceField?: string;
2571
2636
  aggregate?: AggregateFunction;
@@ -580,6 +580,44 @@ declare type SemaphorAnalyticsValueFilter = SemaphorAnalyticsFilterBase & {
580
580
 
581
581
  declare type SemaphorAnalyticsValueFilterOperator = Exclude<SemaphorAnalyticsFilterOperator, 'is_null' | 'is_not_null'>;
582
582
 
583
+ declare type SemaphorDerivedFieldAggregationBehavior = 'additive' | 'non_additive' | 'ratio_of_sums' | 'weighted' | 'pre_aggregated' | 'snapshot';
584
+
585
+ declare type SemaphorDerivedFieldAggregationStrategy = 'default' | 'symmetric_aggregate' | 'aggregate_then_join' | 'weighted';
586
+
587
+ declare type SemaphorDerivedFieldComputeStage = 'row' | 'aggregate';
588
+
589
+ declare type SemaphorDerivedFieldDefinition = {
590
+ kind: 'derived_field';
591
+ name: string;
592
+ label: string;
593
+ description?: string;
594
+ resultRole: SemaphorDerivedFieldResultRole;
595
+ dataType: NonNullable<SemaphorFieldRef['dataType']>;
596
+ computeStage: SemaphorDerivedFieldComputeStage;
597
+ expression: string;
598
+ expressionLanguage?: 'semaphor_sql_template';
599
+ inputs: Record<string, SemaphorDerivedFieldInput>;
600
+ defaultAggregate?: SemaphorAggregateFunction;
601
+ aggregationBehavior?: SemaphorDerivedFieldAggregationBehavior;
602
+ aggregationStrategy?: SemaphorDerivedFieldAggregationStrategy;
603
+ format?: unknown;
604
+ tags?: string[];
605
+ };
606
+
607
+ declare type SemaphorDerivedFieldInput = {
608
+ kind: 'field';
609
+ field: SemaphorFieldRef;
610
+ aggregate?: SemaphorAggregateFunction;
611
+ } | {
612
+ kind: 'metric';
613
+ metric: SemaphorFieldRef;
614
+ } | {
615
+ kind: 'dimension';
616
+ dimension: SemaphorFieldRef;
617
+ };
618
+
619
+ declare type SemaphorDerivedFieldResultRole = 'measure' | 'group' | 'date' | 'id' | 'filter';
620
+
583
621
  declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
584
622
 
585
623
  /**
@@ -618,6 +656,7 @@ declare type SemaphorInputOptionsIntent = {
618
656
  field: SemaphorFieldRef;
619
657
  search?: string;
620
658
  limit?: number;
659
+ derivedFields?: SemaphorDerivedFieldDefinition[];
621
660
  };
622
661
 
623
662
  declare type SemaphorMatrixAxisExpansionOptions = {
@@ -794,6 +833,7 @@ declare type SemaphorMetricIntent = {
794
833
  };
795
834
  inputs?: SemaphorInputBinding[];
796
835
  limit?: number;
836
+ derivedFields?: SemaphorDerivedFieldDefinition[];
797
837
  };
798
838
 
799
839
  declare type SemaphorPaginationRequest = {
@@ -821,6 +861,7 @@ declare type SemaphorRecordsIntent = {
821
861
  direction: 'asc' | 'desc';
822
862
  };
823
863
  inputs?: SemaphorInputBinding[];
864
+ derivedFields?: SemaphorDerivedFieldDefinition[];
824
865
  };
825
866
 
826
867
  declare type SemaphorRelativeTimeWindow = {
@@ -470,6 +470,10 @@ declare type SemaphorAnalyticsValueFilter = SemaphorAnalyticsFilterBase & {
470
470
 
471
471
  declare type SemaphorAnalyticsValueFilterOperator = Exclude<SemaphorAnalyticsFilterOperator, 'is_null' | 'is_not_null'>;
472
472
 
473
+ declare type SemaphorAppDerivedFieldsSpec = {
474
+ derivedFields?: SemaphorDerivedFieldDefinition[];
475
+ };
476
+
473
477
  declare type SemaphorCompiledQuery = {
474
478
  kind: 'config';
475
479
  queryId: string;
@@ -543,12 +547,51 @@ export declare type SemaphorDataAppValidationResult = {
543
547
  executionResults: SemaphorAnalyticsExecutionResult[];
544
548
  };
545
549
 
550
+ declare type SemaphorDerivedFieldAggregationBehavior = 'additive' | 'non_additive' | 'ratio_of_sums' | 'weighted' | 'pre_aggregated' | 'snapshot';
551
+
552
+ declare type SemaphorDerivedFieldAggregationStrategy = 'default' | 'symmetric_aggregate' | 'aggregate_then_join' | 'weighted';
553
+
554
+ declare type SemaphorDerivedFieldComputeStage = 'row' | 'aggregate';
555
+
556
+ declare type SemaphorDerivedFieldDefinition = {
557
+ kind: 'derived_field';
558
+ name: string;
559
+ label: string;
560
+ description?: string;
561
+ resultRole: SemaphorDerivedFieldResultRole;
562
+ dataType: NonNullable<SemaphorFieldRef['dataType']>;
563
+ computeStage: SemaphorDerivedFieldComputeStage;
564
+ expression: string;
565
+ expressionLanguage?: 'semaphor_sql_template';
566
+ inputs: Record<string, SemaphorDerivedFieldInput>;
567
+ defaultAggregate?: SemaphorAggregateFunction;
568
+ aggregationBehavior?: SemaphorDerivedFieldAggregationBehavior;
569
+ aggregationStrategy?: SemaphorDerivedFieldAggregationStrategy;
570
+ format?: unknown;
571
+ tags?: string[];
572
+ };
573
+
574
+ declare type SemaphorDerivedFieldInput = {
575
+ kind: 'field';
576
+ field: SemaphorFieldRef;
577
+ aggregate?: SemaphorAggregateFunction;
578
+ } | {
579
+ kind: 'metric';
580
+ metric: SemaphorFieldRef;
581
+ } | {
582
+ kind: 'dimension';
583
+ dimension: SemaphorFieldRef;
584
+ };
585
+
586
+ declare type SemaphorDerivedFieldResultRole = 'measure' | 'group' | 'date' | 'id' | 'filter';
587
+
546
588
  declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
547
589
 
548
590
  declare type SemaphorExecutionFieldRef = SemaphorFieldRef & {
549
591
  semanticAggregate?: SemaphorAggregateFunction;
550
592
  effectiveAggregate?: SemaphorAggregateFunction;
551
593
  aggregateSource?: SemaphorMetricAggregateSource;
594
+ derivedField?: SemaphorDerivedFieldDefinition;
552
595
  };
553
596
 
554
597
  /**
@@ -630,13 +673,14 @@ declare type SemaphorInputOptionsIntent = {
630
673
  field: SemaphorFieldRef;
631
674
  search?: string;
632
675
  limit?: number;
676
+ derivedFields?: SemaphorDerivedFieldDefinition[];
633
677
  };
634
678
 
635
679
  declare type SemaphorInputOptionsQueryDefinition = SemaphorInputOptionsQuerySpec & {
636
680
  queryKind: 'inputOptions';
637
681
  };
638
682
 
639
- declare type SemaphorInputOptionsQuerySpec = SemaphorQuerySourceSpec & {
683
+ declare type SemaphorInputOptionsQuerySpec = SemaphorQuerySourceSpec & SemaphorAppDerivedFieldsSpec & {
640
684
  id?: string;
641
685
  label?: string;
642
686
  field: SemaphorQueryField;
@@ -869,13 +913,14 @@ declare type SemaphorMetricIntent = {
869
913
  };
870
914
  inputs?: SemaphorInputBinding[];
871
915
  limit?: number;
916
+ derivedFields?: SemaphorDerivedFieldDefinition[];
872
917
  };
873
918
 
874
919
  declare type SemaphorMetricQueryDefinition = SemaphorMetricQuerySpec & {
875
920
  queryKind: 'metric';
876
921
  };
877
922
 
878
- declare type SemaphorMetricQuerySpec = SemaphorQuerySourceSpec & {
923
+ declare type SemaphorMetricQuerySpec = SemaphorQuerySourceSpec & SemaphorAppDerivedFieldsSpec & {
879
924
  id?: string;
880
925
  label?: string;
881
926
  metrics: SemaphorNonEmptyArray<SemaphorQueryField>;
@@ -941,7 +986,7 @@ declare type SemaphorQuerySourceSpec = {
941
986
  source: SemaphorSourceRef;
942
987
  };
943
988
 
944
- declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & {
989
+ declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & SemaphorAppDerivedFieldsSpec & {
945
990
  id?: string;
946
991
  label?: string;
947
992
  dateField?: SemaphorQueryField;
@@ -976,6 +1021,7 @@ declare type SemaphorRecordsIntent = {
976
1021
  direction: 'asc' | 'desc';
977
1022
  };
978
1023
  inputs?: SemaphorInputBinding[];
1024
+ derivedFields?: SemaphorDerivedFieldDefinition[];
979
1025
  };
980
1026
 
981
1027
  declare type SemaphorRecordsOrderBy = SemaphorQueryOrderBy;
@@ -1043,6 +1089,7 @@ declare type SemaphorResultColumn = {
1043
1089
  dataType?: SemaphorFieldRef['dataType'];
1044
1090
  aggregate?: SemaphorFieldRef['aggregate'];
1045
1091
  source?: SemaphorFieldRef['source'];
1092
+ derivedField?: SemaphorDerivedFieldDefinition;
1046
1093
  };
1047
1094
 
1048
1095
  declare type SemaphorScalar = string | number | boolean | null;
@@ -343,6 +343,9 @@ export declare const semaphor: {
343
343
  filter<TValue extends SemaphorInputValue = SemaphorInputValue>(spec: Omit<SemaphorFilterInputSpec<TValue>, "kind">): SemaphorFilterInputSpec<TValue>;
344
344
  control<TValue extends SemaphorInputValue = SemaphorInputValue>(spec: SemaphorControlBuilderSpec<TValue>): SemaphorControlInputSpec<TValue>;
345
345
  sqlParam<TValue extends SemaphorSqlParameterValue = SemaphorSqlParameterValue>(spec: SemaphorSqlParamInputSpec<TValue>): SemaphorControlInputSpec<TValue>;
346
+ derivedField(spec: Omit<SemaphorDerivedFieldDefinition, "kind"> & {
347
+ kind?: "derived_field";
348
+ }): SemaphorDerivedFieldDefinition;
346
349
  metric(spec: SemaphorMetricQuerySpec): SemaphorMetricQueryDefinition;
347
350
  analysis(spec: SemaphorAnalysisQuerySpec): SemaphorAnalysisQueryDefinition;
348
351
  records(spec: SemaphorRecordsQuerySpec): SemaphorRecordsQueryDefinition;
@@ -542,6 +545,10 @@ declare type SemaphorAnalyticsValueFilterOperator = Exclude<SemaphorAnalyticsFil
542
545
 
543
546
  export declare type SemaphorAnyQueryResult<TRecord extends Record<string, unknown> = Record<string, unknown>> = SemaphorQueryResult<TRecord>;
544
547
 
548
+ export declare type SemaphorAppDerivedFieldsSpec = {
549
+ derivedFields?: SemaphorDerivedFieldDefinition[];
550
+ };
551
+
545
552
  declare type SemaphorCompiledQuery = {
546
553
  kind: 'config';
547
554
  queryId: string;
@@ -657,12 +664,51 @@ declare type SemaphorDataAppWindowRuntime = {
657
664
  };
658
665
  };
659
666
 
667
+ declare type SemaphorDerivedFieldAggregationBehavior = 'additive' | 'non_additive' | 'ratio_of_sums' | 'weighted' | 'pre_aggregated' | 'snapshot';
668
+
669
+ declare type SemaphorDerivedFieldAggregationStrategy = 'default' | 'symmetric_aggregate' | 'aggregate_then_join' | 'weighted';
670
+
671
+ declare type SemaphorDerivedFieldComputeStage = 'row' | 'aggregate';
672
+
673
+ export declare type SemaphorDerivedFieldDefinition = {
674
+ kind: 'derived_field';
675
+ name: string;
676
+ label: string;
677
+ description?: string;
678
+ resultRole: SemaphorDerivedFieldResultRole;
679
+ dataType: NonNullable<SemaphorFieldRef['dataType']>;
680
+ computeStage: SemaphorDerivedFieldComputeStage;
681
+ expression: string;
682
+ expressionLanguage?: 'semaphor_sql_template';
683
+ inputs: Record<string, SemaphorDerivedFieldInput>;
684
+ defaultAggregate?: SemaphorAggregateFunction;
685
+ aggregationBehavior?: SemaphorDerivedFieldAggregationBehavior;
686
+ aggregationStrategy?: SemaphorDerivedFieldAggregationStrategy;
687
+ format?: unknown;
688
+ tags?: string[];
689
+ };
690
+
691
+ declare type SemaphorDerivedFieldInput = {
692
+ kind: 'field';
693
+ field: SemaphorFieldRef;
694
+ aggregate?: SemaphorAggregateFunction;
695
+ } | {
696
+ kind: 'metric';
697
+ metric: SemaphorFieldRef;
698
+ } | {
699
+ kind: 'dimension';
700
+ dimension: SemaphorFieldRef;
701
+ };
702
+
703
+ declare type SemaphorDerivedFieldResultRole = 'measure' | 'group' | 'date' | 'id' | 'filter';
704
+
660
705
  declare type SemaphorDialect = 'postgres' | 'mysql' | 'mssql' | 'snowflake' | 'clickhouse' | 'bigquery' | 'redshift' | 'duckdb' | 'sqlite' | 'unknown';
661
706
 
662
707
  declare type SemaphorExecutionFieldRef = SemaphorFieldRef & {
663
708
  semanticAggregate?: SemaphorAggregateFunction;
664
709
  effectiveAggregate?: SemaphorAggregateFunction;
665
710
  aggregateSource?: SemaphorMetricAggregateSource;
711
+ derivedField?: SemaphorDerivedFieldDefinition;
666
712
  };
667
713
 
668
714
  /**
@@ -744,6 +790,7 @@ declare type SemaphorInputOptionsIntent = {
744
790
  field: SemaphorFieldRef;
745
791
  search?: string;
746
792
  limit?: number;
793
+ derivedFields?: SemaphorDerivedFieldDefinition[];
747
794
  };
748
795
 
749
796
  export declare type SemaphorInputOptionsPayload = {
@@ -762,7 +809,7 @@ export declare type SemaphorInputOptionsQueryResult = SemaphorQueryState & Semap
762
809
  }>;
763
810
  };
764
811
 
765
- export declare type SemaphorInputOptionsQuerySpec = SemaphorQuerySourceSpec & {
812
+ export declare type SemaphorInputOptionsQuerySpec = SemaphorQuerySourceSpec & SemaphorAppDerivedFieldsSpec & {
766
813
  id?: string;
767
814
  label?: string;
768
815
  field: SemaphorQueryField;
@@ -1007,6 +1054,7 @@ declare type SemaphorMetricIntent = {
1007
1054
  };
1008
1055
  inputs?: SemaphorInputBinding[];
1009
1056
  limit?: number;
1057
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1010
1058
  };
1011
1059
 
1012
1060
  export declare type SemaphorMetricPayload = {
@@ -1028,7 +1076,7 @@ export declare type SemaphorMetricQueryResult = SemaphorQueryState & SemaphorMet
1028
1076
  intent?: SemaphorMetricIntent;
1029
1077
  };
1030
1078
 
1031
- export declare type SemaphorMetricQuerySpec = SemaphorQuerySourceSpec & {
1079
+ export declare type SemaphorMetricQuerySpec = SemaphorQuerySourceSpec & SemaphorAppDerivedFieldsSpec & {
1032
1080
  id?: string;
1033
1081
  label?: string;
1034
1082
  metrics: SemaphorNonEmptyArray<SemaphorQueryField>;
@@ -1127,7 +1175,7 @@ export declare type SemaphorQueryState = {
1127
1175
 
1128
1176
  export declare type SemaphorQueryStatus = 'idle' | 'loading' | 'success' | 'error';
1129
1177
 
1130
- declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & {
1178
+ declare type SemaphorRecordsBaseQuerySpec = SemaphorQuerySourceSpec & SemaphorAppDerivedFieldsSpec & {
1131
1179
  id?: string;
1132
1180
  label?: string;
1133
1181
  dateField?: SemaphorQueryField;
@@ -1162,6 +1210,7 @@ declare type SemaphorRecordsIntent = {
1162
1210
  direction: 'asc' | 'desc';
1163
1211
  };
1164
1212
  inputs?: SemaphorInputBinding[];
1213
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1165
1214
  };
1166
1215
 
1167
1216
  export declare type SemaphorRecordsOrderBy = SemaphorQueryOrderBy;
@@ -1242,6 +1291,7 @@ export declare type SemaphorResultColumn = {
1242
1291
  dataType?: SemaphorFieldRef['dataType'];
1243
1292
  aggregate?: SemaphorFieldRef['aggregate'];
1244
1293
  source?: SemaphorFieldRef['source'];
1294
+ derivedField?: SemaphorDerivedFieldDefinition;
1245
1295
  };
1246
1296
 
1247
1297
  export declare type SemaphorRowsQueryResult<TRecord extends Record<string, unknown> = Record<string, unknown>> = SemaphorRecordsQueryResult<TRecord> | SemaphorSqlQueryResult<TRecord>;