react-semaphor 0.1.369 → 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 (53) 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-nOPr0mTk.js → validation-CQFpcSSP.js} +446 -246
  22. package/dist/chunks/validation-D4Zz6WPD.js +1 -0
  23. package/dist/chunks/validators-CuKnUZFO.js +2171 -0
  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 +261 -183
  33. package/dist/data-app-sdk-validation/index.cjs +1 -1
  34. package/dist/data-app-sdk-validation/index.js +4 -3
  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 +542 -2
  40. package/dist/types/dashboard-assistant.d.ts +508 -4
  41. package/dist/types/dashboard-authoring.d.ts +217 -3
  42. package/dist/types/dashboard.d.ts +67 -2
  43. package/dist/types/data-app-builder.d.ts +197 -1
  44. package/dist/types/data-app-sdk-validation.d.ts +520 -6
  45. package/dist/types/data-app-sdk.d.ts +543 -8
  46. package/dist/types/main.d.ts +215 -3
  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-Dsf7PydY.js +0 -1
  52. package/dist/chunks/validators-CVuWOHYv.js +0 -1032
  53. package/dist/chunks/validators-oc8qtP4q.js +0 -1
@@ -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;
@@ -1828,7 +1843,7 @@ declare type SemaphorAnalyticsFilterBase = {
1828
1843
 
1829
1844
  declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
1830
1845
 
1831
- declare type SemaphorAnalyticsIntent = SemaphorMetricIntent | SemaphorRecordsIntent | SemaphorInputOptionsIntent | SemaphorSqlIntent;
1846
+ declare type SemaphorAnalyticsIntent = SemaphorMetricIntent | SemaphorRecordsIntent | SemaphorInputOptionsIntent | SemaphorSqlIntent | SemaphorMatrixIntent;
1832
1847
 
1833
1848
  declare type SemaphorAnalyticsNullFilter = SemaphorAnalyticsFilterBase & {
1834
1849
  operator: SemaphorAnalyticsNullFilterOperator;
@@ -1869,8 +1884,54 @@ 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
 
1927
+ /**
1928
+ * Explorer-backed table source. This is intentionally distinct from raw SQL:
1929
+ * matrix planning needs stable source metadata, fields, and dialect context.
1930
+ */
1931
+ declare type SemaphorExplorerSourceRef = Extract<SemaphorSourceRef, {
1932
+ kind: 'physical';
1933
+ }>;
1934
+
1874
1935
  declare type SemaphorFieldRef = {
1875
1936
  name: string;
1876
1937
  label?: string;
@@ -1903,6 +1964,7 @@ declare type SemaphorInputOptionsIntent = {
1903
1964
  field: SemaphorFieldRef;
1904
1965
  search?: string;
1905
1966
  limit?: number;
1967
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1906
1968
  };
1907
1969
 
1908
1970
  declare type SemaphorInputScope = {
@@ -1928,6 +1990,149 @@ declare type SemaphorInputSpec = {
1928
1990
  scope?: SemaphorInputScope;
1929
1991
  };
1930
1992
 
1993
+ declare type SemaphorMatrixAxisExpansionOptions = {
1994
+ defaultDepth?: number;
1995
+ lazy?: boolean;
1996
+ expandedPaths?: SemaphorMatrixMemberPathSegment[][];
1997
+ };
1998
+
1999
+ declare type SemaphorMatrixAxisLevel = {
2000
+ id?: string;
2001
+ field: SemaphorFieldRef;
2002
+ grain?: SemaphorTimeGrain;
2003
+ label?: string;
2004
+ subtotal?: boolean | SemaphorMatrixSubtotalOptions;
2005
+ sortBy?: SemaphorMatrixAxisSortRule;
2006
+ };
2007
+
2008
+ declare type SemaphorMatrixAxisSortRule = {
2009
+ direction: 'asc' | 'desc';
2010
+ by: {
2011
+ kind: 'label';
2012
+ } | {
2013
+ kind: 'field';
2014
+ field: SemaphorFieldRef;
2015
+ aggregate?: SemaphorAggregateFunction;
2016
+ };
2017
+ nulls?: 'warehouseDefault' | 'first' | 'last';
2018
+ scope?: 'global' | 'withinParent';
2019
+ };
2020
+
2021
+ declare type SemaphorMatrixDisplayLimitOptions = {
2022
+ rows?: SemaphorMatrixDisplayLimitRule;
2023
+ columns?: SemaphorMatrixDisplayLimitRule;
2024
+ };
2025
+
2026
+ declare type SemaphorMatrixDisplayLimitRule = {
2027
+ limit: number;
2028
+ by?: 'label' | 'value';
2029
+ direction?: 'top' | 'bottom';
2030
+ others?: boolean | {
2031
+ label?: string;
2032
+ };
2033
+ };
2034
+
2035
+ declare type SemaphorMatrixExpansionOptions = {
2036
+ rows?: SemaphorMatrixAxisExpansionOptions;
2037
+ columns?: SemaphorMatrixAxisExpansionOptions;
2038
+ };
2039
+
2040
+ declare type SemaphorMatrixIntent = {
2041
+ kind: 'matrix';
2042
+ version?: SemaphorProtocolVersion;
2043
+ id?: string;
2044
+ label?: string;
2045
+ source: SemaphorMatrixSourceRef;
2046
+ rows: SemaphorMatrixAxisLevel[];
2047
+ columns?: SemaphorMatrixAxisLevel[];
2048
+ values: SemaphorMatrixValueField[];
2049
+ filters?: SemaphorAnalyticsFilter[];
2050
+ inputs?: SemaphorInputBinding[];
2051
+ totals?: SemaphorMatrixTotalOptions;
2052
+ sort?: SemaphorMatrixSortRule[];
2053
+ expansion?: SemaphorMatrixExpansionOptions;
2054
+ layout?: SemaphorMatrixLayoutOptions;
2055
+ displayLimits?: SemaphorMatrixDisplayLimitOptions;
2056
+ };
2057
+
2058
+ declare type SemaphorMatrixLayoutOptions = {
2059
+ hierarchy?: 'compact' | 'tabular' | 'outline';
2060
+ valuesPlacement?: 'columns' | 'rows';
2061
+ stickyRowHeaders?: boolean;
2062
+ stickyColumnHeaders?: boolean;
2063
+ };
2064
+
2065
+ declare type SemaphorMatrixMemberPathSegment = {
2066
+ levelId: string;
2067
+ value: unknown;
2068
+ };
2069
+
2070
+ declare type SemaphorMatrixSortRule = {
2071
+ axis: 'row' | 'column';
2072
+ targetId?: string;
2073
+ direction: 'asc' | 'desc';
2074
+ by: {
2075
+ kind: 'label';
2076
+ } | {
2077
+ kind: 'field';
2078
+ field: SemaphorFieldRef;
2079
+ aggregate?: SemaphorAggregateFunction;
2080
+ } | {
2081
+ kind: 'value';
2082
+ valueId: string;
2083
+ rowPath?: SemaphorMatrixMemberPathSegment[];
2084
+ columnPath?: SemaphorMatrixMemberPathSegment[];
2085
+ };
2086
+ nulls?: 'warehouseDefault' | 'first' | 'last';
2087
+ scope?: 'global' | 'withinParent';
2088
+ };
2089
+
2090
+ declare type SemaphorMatrixSourceRef = SemaphorSemanticSourceRef | SemaphorExplorerSourceRef;
2091
+
2092
+ declare type SemaphorMatrixSubtotalOptions = {
2093
+ enabled?: boolean;
2094
+ position?: 'before' | 'after';
2095
+ label?: string;
2096
+ };
2097
+
2098
+ declare type SemaphorMatrixTotalCalculation = {
2099
+ kind: 'defaultAggregate';
2100
+ } | {
2101
+ kind: 'blank';
2102
+ } | {
2103
+ kind: 'labelOnly';
2104
+ label?: string;
2105
+ } | {
2106
+ kind: 'customAggregate';
2107
+ aggregate: SemaphorAggregateFunction;
2108
+ } | {
2109
+ kind: 'percentOfParent';
2110
+ } | {
2111
+ kind: 'percentOfGrandTotal';
2112
+ } | {
2113
+ kind: 'customExpression';
2114
+ expressionId: string;
2115
+ };
2116
+
2117
+ declare type SemaphorMatrixTotalOptions = {
2118
+ rows?: boolean | 'perLevel';
2119
+ columns?: boolean | 'perLevel';
2120
+ grandTotal?: boolean | {
2121
+ rows?: boolean;
2122
+ columns?: boolean;
2123
+ };
2124
+ rowPosition?: 'top' | 'bottom';
2125
+ columnPosition?: 'left' | 'right';
2126
+ };
2127
+
2128
+ declare type SemaphorMatrixValueField = {
2129
+ id?: string;
2130
+ field: SemaphorFieldRef;
2131
+ aggregate?: SemaphorAggregateFunction;
2132
+ label?: string;
2133
+ totalBehavior?: SemaphorMatrixTotalCalculation;
2134
+ };
2135
+
1931
2136
  declare type SemaphorMetricAnalysis = {
1932
2137
  kind: 'period_change';
1933
2138
  orderBy?: 'absolute_change' | 'positive_change' | 'negative_change' | 'period';
@@ -1959,6 +2164,7 @@ declare type SemaphorMetricIntent = {
1959
2164
  };
1960
2165
  inputs?: SemaphorInputBinding[];
1961
2166
  limit?: number;
2167
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1962
2168
  };
1963
2169
 
1964
2170
  declare type SemaphorPaginationRequest = {
@@ -1986,6 +2192,7 @@ declare type SemaphorRecordsIntent = {
1986
2192
  direction: 'asc' | 'desc';
1987
2193
  };
1988
2194
  inputs?: SemaphorInputBinding[];
2195
+ derivedFields?: SemaphorDerivedFieldDefinition[];
1989
2196
  };
1990
2197
 
1991
2198
  declare type SemaphorRelativeTimeWindow = {
@@ -1996,6 +2203,10 @@ declare type SemaphorRelativeTimeWindow = {
1996
2203
  completeness?: 'include_partial' | 'complete_periods';
1997
2204
  };
1998
2205
 
2206
+ declare type SemaphorSemanticSourceRef = Extract<SemaphorSourceRef, {
2207
+ kind: 'semantic';
2208
+ }>;
2209
+
1999
2210
  declare type SemaphorSourceRef = {
2000
2211
  kind: 'semantic';
2001
2212
  domainId: string;
@@ -2051,6 +2262,9 @@ declare type SemaphorViewPresentation = {
2051
2262
  } | {
2052
2263
  kind: 'table';
2053
2264
  columns?: string[];
2265
+ } | {
2266
+ kind: 'matrixTable';
2267
+ mode?: 'auto' | 'pivot' | 'hierarchical';
2054
2268
  } | {
2055
2269
  kind: 'text';
2056
2270
  };
@@ -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;
@@ -564,7 +564,7 @@ declare type SemaphorAnalyticsFilterBase = {
564
564
 
565
565
  declare type SemaphorAnalyticsFilterOperator = SemaphorInputOperator | 'not_contains' | 'is_null' | 'is_not_null';
566
566
 
567
- declare type SemaphorAnalyticsIntent = SemaphorMetricIntent | SemaphorRecordsIntent | SemaphorInputOptionsIntent | SemaphorSqlIntent;
567
+ declare type SemaphorAnalyticsIntent = SemaphorMetricIntent | SemaphorRecordsIntent | SemaphorInputOptionsIntent | SemaphorSqlIntent | SemaphorMatrixIntent;
568
568
 
569
569
  declare type SemaphorAnalyticsNullFilter = SemaphorAnalyticsFilterBase & {
570
570
  operator: SemaphorAnalyticsNullFilterOperator;
@@ -580,8 +580,54 @@ 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
 
623
+ /**
624
+ * Explorer-backed table source. This is intentionally distinct from raw SQL:
625
+ * matrix planning needs stable source metadata, fields, and dialect context.
626
+ */
627
+ declare type SemaphorExplorerSourceRef = Extract<SemaphorSourceRef, {
628
+ kind: 'physical';
629
+ }>;
630
+
585
631
  declare type SemaphorFieldRef = {
586
632
  name: string;
587
633
  label?: string;
@@ -610,6 +656,150 @@ declare type SemaphorInputOptionsIntent = {
610
656
  field: SemaphorFieldRef;
611
657
  search?: string;
612
658
  limit?: number;
659
+ derivedFields?: SemaphorDerivedFieldDefinition[];
660
+ };
661
+
662
+ declare type SemaphorMatrixAxisExpansionOptions = {
663
+ defaultDepth?: number;
664
+ lazy?: boolean;
665
+ expandedPaths?: SemaphorMatrixMemberPathSegment[][];
666
+ };
667
+
668
+ declare type SemaphorMatrixAxisLevel = {
669
+ id?: string;
670
+ field: SemaphorFieldRef;
671
+ grain?: SemaphorTimeGrain;
672
+ label?: string;
673
+ subtotal?: boolean | SemaphorMatrixSubtotalOptions;
674
+ sortBy?: SemaphorMatrixAxisSortRule;
675
+ };
676
+
677
+ declare type SemaphorMatrixAxisSortRule = {
678
+ direction: 'asc' | 'desc';
679
+ by: {
680
+ kind: 'label';
681
+ } | {
682
+ kind: 'field';
683
+ field: SemaphorFieldRef;
684
+ aggregate?: SemaphorAggregateFunction;
685
+ };
686
+ nulls?: 'warehouseDefault' | 'first' | 'last';
687
+ scope?: 'global' | 'withinParent';
688
+ };
689
+
690
+ declare type SemaphorMatrixDisplayLimitOptions = {
691
+ rows?: SemaphorMatrixDisplayLimitRule;
692
+ columns?: SemaphorMatrixDisplayLimitRule;
693
+ };
694
+
695
+ declare type SemaphorMatrixDisplayLimitRule = {
696
+ limit: number;
697
+ by?: 'label' | 'value';
698
+ direction?: 'top' | 'bottom';
699
+ others?: boolean | {
700
+ label?: string;
701
+ };
702
+ };
703
+
704
+ declare type SemaphorMatrixExpansionOptions = {
705
+ rows?: SemaphorMatrixAxisExpansionOptions;
706
+ columns?: SemaphorMatrixAxisExpansionOptions;
707
+ };
708
+
709
+ declare type SemaphorMatrixIntent = {
710
+ kind: 'matrix';
711
+ version?: SemaphorProtocolVersion;
712
+ id?: string;
713
+ label?: string;
714
+ source: SemaphorMatrixSourceRef;
715
+ rows: SemaphorMatrixAxisLevel[];
716
+ columns?: SemaphorMatrixAxisLevel[];
717
+ values: SemaphorMatrixValueField[];
718
+ filters?: SemaphorAnalyticsFilter[];
719
+ inputs?: SemaphorInputBinding[];
720
+ totals?: SemaphorMatrixTotalOptions;
721
+ sort?: SemaphorMatrixSortRule[];
722
+ expansion?: SemaphorMatrixExpansionOptions;
723
+ layout?: SemaphorMatrixLayoutOptions;
724
+ displayLimits?: SemaphorMatrixDisplayLimitOptions;
725
+ };
726
+
727
+ declare type SemaphorMatrixLayoutOptions = {
728
+ hierarchy?: 'compact' | 'tabular' | 'outline';
729
+ valuesPlacement?: 'columns' | 'rows';
730
+ stickyRowHeaders?: boolean;
731
+ stickyColumnHeaders?: boolean;
732
+ };
733
+
734
+ declare type SemaphorMatrixMemberPathSegment = {
735
+ levelId: string;
736
+ value: unknown;
737
+ };
738
+
739
+ declare type SemaphorMatrixSortRule = {
740
+ axis: 'row' | 'column';
741
+ targetId?: string;
742
+ direction: 'asc' | 'desc';
743
+ by: {
744
+ kind: 'label';
745
+ } | {
746
+ kind: 'field';
747
+ field: SemaphorFieldRef;
748
+ aggregate?: SemaphorAggregateFunction;
749
+ } | {
750
+ kind: 'value';
751
+ valueId: string;
752
+ rowPath?: SemaphorMatrixMemberPathSegment[];
753
+ columnPath?: SemaphorMatrixMemberPathSegment[];
754
+ };
755
+ nulls?: 'warehouseDefault' | 'first' | 'last';
756
+ scope?: 'global' | 'withinParent';
757
+ };
758
+
759
+ declare type SemaphorMatrixSourceRef = SemaphorSemanticSourceRef | SemaphorExplorerSourceRef;
760
+
761
+ declare type SemaphorMatrixSubtotalOptions = {
762
+ enabled?: boolean;
763
+ position?: 'before' | 'after';
764
+ label?: string;
765
+ };
766
+
767
+ declare type SemaphorMatrixTotalCalculation = {
768
+ kind: 'defaultAggregate';
769
+ } | {
770
+ kind: 'blank';
771
+ } | {
772
+ kind: 'labelOnly';
773
+ label?: string;
774
+ } | {
775
+ kind: 'customAggregate';
776
+ aggregate: SemaphorAggregateFunction;
777
+ } | {
778
+ kind: 'percentOfParent';
779
+ } | {
780
+ kind: 'percentOfGrandTotal';
781
+ } | {
782
+ kind: 'customExpression';
783
+ expressionId: string;
784
+ };
785
+
786
+ declare type SemaphorMatrixTotalOptions = {
787
+ rows?: boolean | 'perLevel';
788
+ columns?: boolean | 'perLevel';
789
+ grandTotal?: boolean | {
790
+ rows?: boolean;
791
+ columns?: boolean;
792
+ };
793
+ rowPosition?: 'top' | 'bottom';
794
+ columnPosition?: 'left' | 'right';
795
+ };
796
+
797
+ declare type SemaphorMatrixValueField = {
798
+ id?: string;
799
+ field: SemaphorFieldRef;
800
+ aggregate?: SemaphorAggregateFunction;
801
+ label?: string;
802
+ totalBehavior?: SemaphorMatrixTotalCalculation;
613
803
  };
614
804
 
615
805
  declare type SemaphorMetricAnalysis = {
@@ -643,6 +833,7 @@ declare type SemaphorMetricIntent = {
643
833
  };
644
834
  inputs?: SemaphorInputBinding[];
645
835
  limit?: number;
836
+ derivedFields?: SemaphorDerivedFieldDefinition[];
646
837
  };
647
838
 
648
839
  declare type SemaphorPaginationRequest = {
@@ -670,6 +861,7 @@ declare type SemaphorRecordsIntent = {
670
861
  direction: 'asc' | 'desc';
671
862
  };
672
863
  inputs?: SemaphorInputBinding[];
864
+ derivedFields?: SemaphorDerivedFieldDefinition[];
673
865
  };
674
866
 
675
867
  declare type SemaphorRelativeTimeWindow = {
@@ -680,6 +872,10 @@ declare type SemaphorRelativeTimeWindow = {
680
872
  completeness?: 'include_partial' | 'complete_periods';
681
873
  };
682
874
 
875
+ declare type SemaphorSemanticSourceRef = Extract<SemaphorSourceRef, {
876
+ kind: 'semantic';
877
+ }>;
878
+
683
879
  declare type SemaphorSourceRef = {
684
880
  kind: 'semantic';
685
881
  domainId: string;