react-semaphor 0.1.601 → 0.1.602

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 (75) hide show
  1. package/dist/analytics-protocol/index.js +9 -9
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/brand-studio/index.js +7 -7
  4. package/dist/briefings/index.js +4 -4
  5. package/dist/chunks/{assistant-chat-BE0XXzZP.js → assistant-chat-BWF3GYip.js} +12 -12
  6. package/dist/chunks/{bookmark-impact-DXDAN5AY.js → bookmark-impact-BF3iRx5a.js} +3 -3
  7. package/dist/chunks/{bookmark-state-BMyB3Tb6.js → bookmark-state-CBSTdW6q.js} +4 -4
  8. package/dist/chunks/{card-filter-builder-CE0-YVN5.js → card-filter-builder-B8XHwMY6.js} +394 -394
  9. package/dist/chunks/{comparison-window-caption-Dxj2CHOa.js → comparison-window-caption-W83qB4V5.js} +4 -4
  10. package/dist/chunks/{dashboard-mJKPFRbb.js → dashboard-DG5EIYYB.js} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-CntwKyiZ.js → dashboard-briefing-launcher-CBSrhyWZ.js} +727 -718
  12. package/dist/chunks/{dashboard-controls-XO089DMg.js → dashboard-controls-D6ECO4N1.js} +15 -15
  13. package/dist/chunks/{dashboard-json-CQRiydUv.js → dashboard-json-DrJftBSL.js} +4 -4
  14. package/dist/chunks/{dates-B-Urp5OD.js → dates-Bz-qM5px.js} +10 -10
  15. package/dist/chunks/{edit-dashboard-visual-f-Dm-BLR.js → edit-dashboard-visual-BDYAJIbb.js} +1565 -1544
  16. package/dist/chunks/{filter-line-CKNMyNTQ.js → filter-line-BXT6y303.js} +6 -6
  17. package/dist/chunks/{filter-reach-copy-B8GGyVuR.js → filter-reach-copy-BukhZmzm.js} +1661 -1950
  18. package/dist/chunks/{filter-value-text-CRtKecI5.js → filter-value-text-D3-bf3_b.js} +4 -4
  19. package/dist/chunks/{index-DoPApnxg.js → index-BW0yozjs.js} +5 -5
  20. package/dist/chunks/{layout-grid-CiSCZdIr.js → layout-grid-Ds0diMeY.js} +1 -1
  21. package/dist/chunks/{matrix-analytical-definition-myf3D3Qx.js → matrix-analytical-definition-CgQgVeeI.js} +4 -4
  22. package/dist/chunks/{matrix-member-presentation-g0c_NpDW.js → matrix-member-presentation-DSBIIudt.js} +1 -1
  23. package/dist/chunks/{matrix-operation-contract-C1SuOHLZ.js → matrix-operation-contract--DkNCOzd.js} +517 -514
  24. package/dist/chunks/{metric-comparison-Cm0G893W.js → metric-comparison-zMylnIkc.js} +1 -1
  25. package/dist/chunks/{paintbrush-DQIwqlck.js → paintbrush-CX8pao1j.js} +1 -1
  26. package/dist/chunks/{palette-Cun747Rg.js → palette-CuA0HlzF.js} +1 -1
  27. package/dist/chunks/{pivot-result-contract-expectations-C1Dyx8du.js → pivot-result-contract-expectations-C8KL7hPx.js} +8 -8
  28. package/dist/chunks/{pivot-result-identity-CBS-ssEp.js → pivot-result-identity-C1AOH1PS.js} +1 -1
  29. package/dist/chunks/{raw-temporal-value-DN_l-Tss.js → raw-temporal-value-E416F-0L.js} +1 -1
  30. package/dist/chunks/{report-preferences-dialog-SDZEcG2x.js → report-preferences-dialog-CbuVNDGi.js} +13 -13
  31. package/dist/chunks/{report-runtime-context-BbedQdtc.js → report-runtime-context-E7USjN7E.js} +1 -1
  32. package/dist/chunks/{resolve-dashboard-input-context-DRBS0eRa.js → resolve-dashboard-input-context-CULCE_hM.js} +8417 -7052
  33. package/dist/chunks/{save-Dj5bjm7P.js → save-BKHlDONy.js} +1 -1
  34. package/dist/chunks/{saved-dashboard-context-DWVlJcsa.js → saved-dashboard-context-C1WlOx5z.js} +32 -32
  35. package/dist/chunks/{selection-filter-compiler-DmAr7yqC.js → selection-filter-compiler-ifT8JCXS.js} +1 -1
  36. package/dist/chunks/{semaphor-ready-indicator-OFOoAY-A.js → semaphor-ready-indicator-CBIRcDWs.js} +33414 -31523
  37. package/dist/chunks/{shelf-drop-preview-context-2swWypXu.js → shelf-drop-preview-context-xR69SMA8.js} +53 -53
  38. package/dist/chunks/{stored-dashboard-NtOuEX6a.js → stored-dashboard-BuM8vnWf.js} +739 -717
  39. package/dist/chunks/{style-sheet-parts-Qv4UcLAo.js → style-sheet-parts-Bt9ZNre8.js} +2 -2
  40. package/dist/chunks/{table-export-sheet-Do7ZB0_F.js → table-export-sheet-DVljtHkG.js} +1 -1
  41. package/dist/chunks/{token-types-Dy_aXO-U.js → token-types-D_xKgyVS.js} +1 -1
  42. package/dist/chunks/{upload-Bq-puSVy.js → upload-Dll_M7XQ.js} +1 -1
  43. package/dist/chunks/{validators-C7DFk3QK.js → validators-ClWHpYql.js} +2 -2
  44. package/dist/chunks/{variable-draft-Cy03qnEi.js → variable-draft-CDGGl53R.js} +27 -28
  45. package/dist/dashboard/index.js +2 -2
  46. package/dist/dashboard-authoring/index.js +3086 -2578
  47. package/dist/format-utils/index.js +14 -14
  48. package/dist/index.js +71 -73
  49. package/dist/report-runtime-context/index.js +1 -1
  50. package/dist/style.css +1 -1
  51. package/dist/surfboard/index.js +2 -2
  52. package/dist/types/components/dashboard/dashboard-web-component.d.ts +7 -0
  53. package/dist/types/index.js +5 -5
  54. package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +1 -1
  55. package/dist/types/lib/query-context/assemble-card-query.d.ts +6 -1
  56. package/dist/types/lib/stores/dashboard-store.d.ts +30 -0
  57. package/dist/types/shared/analytics-protocol/aggregate-expression.d.ts +15 -0
  58. package/dist/types/shared/dashboard-authoring/calculations/calculated-column.d.ts +52 -0
  59. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +129 -0
  60. package/dist/types/shared/dashboard-authoring/calculations/resolve-dashboard-field-copies.d.ts +46 -0
  61. package/dist/types/shared/dashboard-authoring/calculations/tokens.d.ts +36 -0
  62. package/dist/types/shared/dashboard-authoring/changes/calculation-change.d.ts +399 -0
  63. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +144 -2
  64. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +21 -2
  65. package/dist/types/shared/dashboard-authoring/changes/domain-change.d.ts +143 -266
  66. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +2 -0
  67. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +46 -0
  68. package/dist/types/shared/dashboard-authoring/index.d.ts +7 -1
  69. package/dist/types/shared/dashboard-authoring/operations/calculated-field-operations.d.ts +133 -0
  70. package/dist/types/shared/dashboard-authoring/operations/card-operations.d.ts +71 -0
  71. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +18 -5
  72. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +21 -0
  73. package/dist/types/shared/usage-events/details.d.ts +2 -2
  74. package/dist/types/shared/usage-events/envelope.d.ts +2 -2
  75. package/package.json +1 -1
@@ -97,77 +97,6 @@ export declare const contextChangeSchema: z.ZodObject<{
97
97
  } | undefined;
98
98
  }>;
99
99
  export declare const COMPARISON_POLARITIES: readonly ["higher_is_better", "lower_is_better", "neutral"];
100
- /**
101
- * A new calculation, by intent: the domain decides whether it is a fact, a
102
- * dimension or a metric from its formula (SE-D2). One dataset's formula names
103
- * the dataset; one across datasets names its `inputs` as {token}s.
104
- */
105
- export declare const calculationAddSchema: z.ZodObject<{
106
- op: z.ZodLiteral<"calculation.add">;
107
- dataset: z.ZodOptional<z.ZodString>;
108
- name: z.ZodString;
109
- label: z.ZodOptional<z.ZodString>;
110
- description: z.ZodOptional<z.ZodString>;
111
- expression: z.ZodString;
112
- inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
113
- dataset: z.ZodString;
114
- field: z.ZodString;
115
- aggregate: z.ZodOptional<z.ZodEnum<["SUM", "COUNT", "AVG", "MIN", "MAX", "MEDIAN", "DISTINCT"]>>;
116
- }, "strict", z.ZodTypeAny, {
117
- field: string;
118
- dataset: string;
119
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
120
- }, {
121
- field: string;
122
- dataset: string;
123
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
124
- }>, z.ZodObject<{
125
- metric: z.ZodString;
126
- dataset: z.ZodOptional<z.ZodString>;
127
- }, "strict", z.ZodTypeAny, {
128
- metric: string;
129
- dataset?: string | undefined;
130
- }, {
131
- metric: string;
132
- dataset?: string | undefined;
133
- }>]>>>;
134
- use: z.ZodOptional<z.ZodEnum<["aggregate", "group_or_filter"]>>;
135
- dataType: z.ZodOptional<z.ZodEnum<["string", "number", "boolean", "date", "datetime"]>>;
136
- }, "strict", z.ZodTypeAny, {
137
- name: string;
138
- expression: string;
139
- op: "calculation.add";
140
- label?: string | undefined;
141
- dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
142
- description?: string | undefined;
143
- inputs?: Record<string, {
144
- field: string;
145
- dataset: string;
146
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
147
- } | {
148
- metric: string;
149
- dataset?: string | undefined;
150
- }> | undefined;
151
- dataset?: string | undefined;
152
- use?: "aggregate" | "group_or_filter" | undefined;
153
- }, {
154
- name: string;
155
- expression: string;
156
- op: "calculation.add";
157
- label?: string | undefined;
158
- dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
159
- description?: string | undefined;
160
- inputs?: Record<string, {
161
- field: string;
162
- dataset: string;
163
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
164
- } | {
165
- metric: string;
166
- dataset?: string | undefined;
167
- }> | undefined;
168
- dataset?: string | undefined;
169
- use?: "aggregate" | "group_or_filter" | undefined;
170
- }>;
171
100
  /** The changes that edit a domain's metadata, in full (the parsing shape). */
172
101
  export declare const domainEditChangeSchemas: readonly [z.ZodObject<{
173
102
  label: z.ZodOptional<z.ZodString>;
@@ -540,71 +469,6 @@ export declare const domainEditChangeSchemas: readonly [z.ZodObject<{
540
469
  remove?: string[] | undefined;
541
470
  } | undefined;
542
471
  } | undefined;
543
- }>, z.ZodObject<{
544
- op: z.ZodLiteral<"calculation.add">;
545
- dataset: z.ZodOptional<z.ZodString>;
546
- name: z.ZodString;
547
- label: z.ZodOptional<z.ZodString>;
548
- description: z.ZodOptional<z.ZodString>;
549
- expression: z.ZodString;
550
- inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
551
- dataset: z.ZodString;
552
- field: z.ZodString;
553
- aggregate: z.ZodOptional<z.ZodEnum<["SUM", "COUNT", "AVG", "MIN", "MAX", "MEDIAN", "DISTINCT"]>>;
554
- }, "strict", z.ZodTypeAny, {
555
- field: string;
556
- dataset: string;
557
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
558
- }, {
559
- field: string;
560
- dataset: string;
561
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
562
- }>, z.ZodObject<{
563
- metric: z.ZodString;
564
- dataset: z.ZodOptional<z.ZodString>;
565
- }, "strict", z.ZodTypeAny, {
566
- metric: string;
567
- dataset?: string | undefined;
568
- }, {
569
- metric: string;
570
- dataset?: string | undefined;
571
- }>]>>>;
572
- use: z.ZodOptional<z.ZodEnum<["aggregate", "group_or_filter"]>>;
573
- dataType: z.ZodOptional<z.ZodEnum<["string", "number", "boolean", "date", "datetime"]>>;
574
- }, "strict", z.ZodTypeAny, {
575
- name: string;
576
- expression: string;
577
- op: "calculation.add";
578
- label?: string | undefined;
579
- dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
580
- description?: string | undefined;
581
- inputs?: Record<string, {
582
- field: string;
583
- dataset: string;
584
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
585
- } | {
586
- metric: string;
587
- dataset?: string | undefined;
588
- }> | undefined;
589
- dataset?: string | undefined;
590
- use?: "aggregate" | "group_or_filter" | undefined;
591
- }, {
592
- name: string;
593
- expression: string;
594
- op: "calculation.add";
595
- label?: string | undefined;
596
- dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
597
- description?: string | undefined;
598
- inputs?: Record<string, {
599
- field: string;
600
- dataset: string;
601
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
602
- } | {
603
- metric: string;
604
- dataset?: string | undefined;
605
- }> | undefined;
606
- dataset?: string | undefined;
607
- use?: "aggregate" | "group_or_filter" | undefined;
608
472
  }>, z.ZodObject<{
609
473
  op: z.ZodLiteral<"relationship.update">;
610
474
  relationship: z.ZodString;
@@ -1061,71 +925,6 @@ export declare const registeredDomainEditChangeSchemas: readonly [z.ZodObject<{
1061
925
  remove?: string[] | undefined;
1062
926
  } | undefined;
1063
927
  } | undefined;
1064
- }>, z.ZodObject<{
1065
- op: z.ZodLiteral<"calculation.add">;
1066
- dataset: z.ZodOptional<z.ZodString>;
1067
- name: z.ZodString;
1068
- label: z.ZodOptional<z.ZodString>;
1069
- description: z.ZodOptional<z.ZodString>;
1070
- expression: z.ZodString;
1071
- inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
1072
- dataset: z.ZodString;
1073
- field: z.ZodString;
1074
- aggregate: z.ZodOptional<z.ZodEnum<["SUM", "COUNT", "AVG", "MIN", "MAX", "MEDIAN", "DISTINCT"]>>;
1075
- }, "strict", z.ZodTypeAny, {
1076
- field: string;
1077
- dataset: string;
1078
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1079
- }, {
1080
- field: string;
1081
- dataset: string;
1082
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1083
- }>, z.ZodObject<{
1084
- metric: z.ZodString;
1085
- dataset: z.ZodOptional<z.ZodString>;
1086
- }, "strict", z.ZodTypeAny, {
1087
- metric: string;
1088
- dataset?: string | undefined;
1089
- }, {
1090
- metric: string;
1091
- dataset?: string | undefined;
1092
- }>]>>>;
1093
- use: z.ZodOptional<z.ZodEnum<["aggregate", "group_or_filter"]>>;
1094
- dataType: z.ZodOptional<z.ZodEnum<["string", "number", "boolean", "date", "datetime"]>>;
1095
- }, "strict", z.ZodTypeAny, {
1096
- name: string;
1097
- expression: string;
1098
- op: "calculation.add";
1099
- label?: string | undefined;
1100
- dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
1101
- description?: string | undefined;
1102
- inputs?: Record<string, {
1103
- field: string;
1104
- dataset: string;
1105
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1106
- } | {
1107
- metric: string;
1108
- dataset?: string | undefined;
1109
- }> | undefined;
1110
- dataset?: string | undefined;
1111
- use?: "aggregate" | "group_or_filter" | undefined;
1112
- }, {
1113
- name: string;
1114
- expression: string;
1115
- op: "calculation.add";
1116
- label?: string | undefined;
1117
- dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
1118
- description?: string | undefined;
1119
- inputs?: Record<string, {
1120
- field: string;
1121
- dataset: string;
1122
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1123
- } | {
1124
- metric: string;
1125
- dataset?: string | undefined;
1126
- }> | undefined;
1127
- dataset?: string | undefined;
1128
- use?: "aggregate" | "group_or_filter" | undefined;
1129
928
  }>, z.ZodObject<{
1130
929
  op: z.ZodLiteral<"relationship.update">;
1131
930
  relationship: z.ZodString;
@@ -1210,6 +1009,7 @@ export declare const registeredDomainEditChangeSchemas: readonly [z.ZodObject<{
1210
1009
  } | undefined;
1211
1010
  isActive?: false | undefined;
1212
1011
  }>];
1012
+ /** A domain proposal's changes as parsed: its own edits and the calculation changes (MC-D3, MC-D7). */
1213
1013
  export declare const domainEditChangeSchema: z.ZodDiscriminatedUnion<"op", [z.ZodObject<{
1214
1014
  label: z.ZodOptional<z.ZodString>;
1215
1015
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
@@ -1581,71 +1381,6 @@ export declare const domainEditChangeSchema: z.ZodDiscriminatedUnion<"op", [z.Zo
1581
1381
  remove?: string[] | undefined;
1582
1382
  } | undefined;
1583
1383
  } | undefined;
1584
- }>, z.ZodObject<{
1585
- op: z.ZodLiteral<"calculation.add">;
1586
- dataset: z.ZodOptional<z.ZodString>;
1587
- name: z.ZodString;
1588
- label: z.ZodOptional<z.ZodString>;
1589
- description: z.ZodOptional<z.ZodString>;
1590
- expression: z.ZodString;
1591
- inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
1592
- dataset: z.ZodString;
1593
- field: z.ZodString;
1594
- aggregate: z.ZodOptional<z.ZodEnum<["SUM", "COUNT", "AVG", "MIN", "MAX", "MEDIAN", "DISTINCT"]>>;
1595
- }, "strict", z.ZodTypeAny, {
1596
- field: string;
1597
- dataset: string;
1598
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1599
- }, {
1600
- field: string;
1601
- dataset: string;
1602
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1603
- }>, z.ZodObject<{
1604
- metric: z.ZodString;
1605
- dataset: z.ZodOptional<z.ZodString>;
1606
- }, "strict", z.ZodTypeAny, {
1607
- metric: string;
1608
- dataset?: string | undefined;
1609
- }, {
1610
- metric: string;
1611
- dataset?: string | undefined;
1612
- }>]>>>;
1613
- use: z.ZodOptional<z.ZodEnum<["aggregate", "group_or_filter"]>>;
1614
- dataType: z.ZodOptional<z.ZodEnum<["string", "number", "boolean", "date", "datetime"]>>;
1615
- }, "strict", z.ZodTypeAny, {
1616
- name: string;
1617
- expression: string;
1618
- op: "calculation.add";
1619
- label?: string | undefined;
1620
- dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
1621
- description?: string | undefined;
1622
- inputs?: Record<string, {
1623
- field: string;
1624
- dataset: string;
1625
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1626
- } | {
1627
- metric: string;
1628
- dataset?: string | undefined;
1629
- }> | undefined;
1630
- dataset?: string | undefined;
1631
- use?: "aggregate" | "group_or_filter" | undefined;
1632
- }, {
1633
- name: string;
1634
- expression: string;
1635
- op: "calculation.add";
1636
- label?: string | undefined;
1637
- dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
1638
- description?: string | undefined;
1639
- inputs?: Record<string, {
1640
- field: string;
1641
- dataset: string;
1642
- aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1643
- } | {
1644
- metric: string;
1645
- dataset?: string | undefined;
1646
- }> | undefined;
1647
- dataset?: string | undefined;
1648
- use?: "aggregate" | "group_or_filter" | undefined;
1649
1384
  }>, z.ZodObject<{
1650
1385
  op: z.ZodLiteral<"relationship.update">;
1651
1386
  relationship: z.ZodString;
@@ -1729,6 +1464,148 @@ export declare const domainEditChangeSchema: z.ZodDiscriminatedUnion<"op", [z.Zo
1729
1464
  } | undefined;
1730
1465
  } | undefined;
1731
1466
  isActive?: false | undefined;
1467
+ }>, z.ZodObject<{
1468
+ op: z.ZodLiteral<"calculation.add">;
1469
+ domainId: z.ZodOptional<z.ZodString>;
1470
+ dataset: z.ZodOptional<z.ZodString>;
1471
+ name: z.ZodString;
1472
+ label: z.ZodOptional<z.ZodString>;
1473
+ description: z.ZodOptional<z.ZodString>;
1474
+ expression: z.ZodString;
1475
+ inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
1476
+ dataset: z.ZodString;
1477
+ field: z.ZodString;
1478
+ aggregate: z.ZodOptional<z.ZodEnum<["SUM", "COUNT", "AVG", "MIN", "MAX", "MEDIAN", "DISTINCT"]>>;
1479
+ }, "strict", z.ZodTypeAny, {
1480
+ field: string;
1481
+ dataset: string;
1482
+ aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1483
+ }, {
1484
+ field: string;
1485
+ dataset: string;
1486
+ aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1487
+ }>, z.ZodObject<{
1488
+ metric: z.ZodString;
1489
+ dataset: z.ZodOptional<z.ZodString>;
1490
+ }, "strict", z.ZodTypeAny, {
1491
+ metric: string;
1492
+ dataset?: string | undefined;
1493
+ }, {
1494
+ metric: string;
1495
+ dataset?: string | undefined;
1496
+ }>]>>>;
1497
+ use: z.ZodOptional<z.ZodEnum<["aggregate", "group_or_filter"]>>;
1498
+ dataType: z.ZodOptional<z.ZodEnum<["string", "number", "boolean", "date", "datetime"]>>;
1499
+ }, "strict", z.ZodTypeAny, {
1500
+ name: string;
1501
+ expression: string;
1502
+ op: "calculation.add";
1503
+ domainId?: string | undefined;
1504
+ label?: string | undefined;
1505
+ dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
1506
+ description?: string | undefined;
1507
+ inputs?: Record<string, {
1508
+ field: string;
1509
+ dataset: string;
1510
+ aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1511
+ } | {
1512
+ metric: string;
1513
+ dataset?: string | undefined;
1514
+ }> | undefined;
1515
+ dataset?: string | undefined;
1516
+ use?: "aggregate" | "group_or_filter" | undefined;
1517
+ }, {
1518
+ name: string;
1519
+ expression: string;
1520
+ op: "calculation.add";
1521
+ domainId?: string | undefined;
1522
+ label?: string | undefined;
1523
+ dataType?: "string" | "number" | "boolean" | "date" | "datetime" | undefined;
1524
+ description?: string | undefined;
1525
+ inputs?: Record<string, {
1526
+ field: string;
1527
+ dataset: string;
1528
+ aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1529
+ } | {
1530
+ metric: string;
1531
+ dataset?: string | undefined;
1532
+ }> | undefined;
1533
+ dataset?: string | undefined;
1534
+ use?: "aggregate" | "group_or_filter" | undefined;
1535
+ }>, z.ZodObject<{
1536
+ op: z.ZodLiteral<"calculation.update">;
1537
+ name: z.ZodString;
1538
+ domainId: z.ZodOptional<z.ZodString>;
1539
+ dataset: z.ZodOptional<z.ZodString>;
1540
+ label: z.ZodOptional<z.ZodString>;
1541
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1542
+ expression: z.ZodOptional<z.ZodString>;
1543
+ inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
1544
+ dataset: z.ZodString;
1545
+ field: z.ZodString;
1546
+ aggregate: z.ZodOptional<z.ZodEnum<["SUM", "COUNT", "AVG", "MIN", "MAX", "MEDIAN", "DISTINCT"]>>;
1547
+ }, "strict", z.ZodTypeAny, {
1548
+ field: string;
1549
+ dataset: string;
1550
+ aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1551
+ }, {
1552
+ field: string;
1553
+ dataset: string;
1554
+ aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1555
+ }>, z.ZodObject<{
1556
+ metric: z.ZodString;
1557
+ dataset: z.ZodOptional<z.ZodString>;
1558
+ }, "strict", z.ZodTypeAny, {
1559
+ metric: string;
1560
+ dataset?: string | undefined;
1561
+ }, {
1562
+ metric: string;
1563
+ dataset?: string | undefined;
1564
+ }>]>>>;
1565
+ }, "strict", z.ZodTypeAny, {
1566
+ name: string;
1567
+ op: "calculation.update";
1568
+ domainId?: string | undefined;
1569
+ label?: string | undefined;
1570
+ description?: string | null | undefined;
1571
+ expression?: string | undefined;
1572
+ inputs?: Record<string, {
1573
+ field: string;
1574
+ dataset: string;
1575
+ aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1576
+ } | {
1577
+ metric: string;
1578
+ dataset?: string | undefined;
1579
+ }> | undefined;
1580
+ dataset?: string | undefined;
1581
+ }, {
1582
+ name: string;
1583
+ op: "calculation.update";
1584
+ domainId?: string | undefined;
1585
+ label?: string | undefined;
1586
+ description?: string | null | undefined;
1587
+ expression?: string | undefined;
1588
+ inputs?: Record<string, {
1589
+ field: string;
1590
+ dataset: string;
1591
+ aggregate?: "SUM" | "COUNT" | "AVG" | "MIN" | "MAX" | "MEDIAN" | "DISTINCT" | undefined;
1592
+ } | {
1593
+ metric: string;
1594
+ dataset?: string | undefined;
1595
+ }> | undefined;
1596
+ dataset?: string | undefined;
1597
+ }>, z.ZodObject<{
1598
+ op: z.ZodLiteral<"calculation.remove">;
1599
+ name: z.ZodString;
1600
+ dataset: z.ZodOptional<z.ZodString>;
1601
+ }, "strict", z.ZodTypeAny, {
1602
+ name: string;
1603
+ op: "calculation.remove";
1604
+ dataset?: string | undefined;
1605
+ }, {
1606
+ name: string;
1607
+ op: "calculation.remove";
1608
+ dataset?: string | undefined;
1732
1609
  }>]>;
1733
1610
  /** The ops that edit a domain's metadata: the one list callers route by (semaphor-app's MCP change tools, SE-D6). */
1734
1611
  export declare const DOMAIN_EDIT_CHANGE_OPS: readonly DomainEditChange['op'][];
@@ -57,6 +57,8 @@ export type CardQueryRead = {
57
57
  export declare function readCardQuery(card: TCard, viewer: {
58
58
  sql: boolean;
59
59
  calculations?: boolean;
60
+ /** The dashboard's own calculated fields: a copy equal to one reads by the field's name (calculated fields one core MC-D9). */
61
+ calculatedFields?: readonly Field[];
60
62
  }): CardQueryRead;
61
63
  /**
62
64
  * Where a card's data comes from, as the outline names it. SQL owns the result
@@ -24,6 +24,38 @@ export type CardSource = {
24
24
  connectionId: string;
25
25
  connectionType?: string;
26
26
  };
27
+ /** A calculation to compile, in the words `calculation.add` takes (calculated fields one core). */
28
+ export type CalculationCompileRequest = {
29
+ domainId: string;
30
+ /** A one-dataset formula's dataset; its formula names that dataset's fields. */
31
+ dataset?: string;
32
+ name: string;
33
+ label?: string;
34
+ description?: string;
35
+ expression: string;
36
+ inputs?: Record<string, {
37
+ dataset: string;
38
+ field: string;
39
+ aggregate?: string;
40
+ } | {
41
+ metric: string;
42
+ dataset?: string;
43
+ }>;
44
+ use?: 'aggregate' | 'group_or_filter';
45
+ dataType?: 'string' | 'number' | 'boolean' | 'date' | 'datetime';
46
+ };
47
+ export type CalculationCompileResult = {
48
+ ok: true;
49
+ /** The compiled field in the stored shape (indexed tokens over full input fields), as the domain catalog builds it. */
50
+ field: Field;
51
+ /** A measure (fact or dataset metric) or a dimension, and its compute stage. */
52
+ kind: 'measure' | 'dimension';
53
+ stage: 'row' | 'aggregate';
54
+ dataset: string;
55
+ } | {
56
+ ok: false;
57
+ problems: ChangeDiagnostic[];
58
+ };
27
59
  export type ChangeServices = {
28
60
  /** The caller's capabilities; read only through `need`, which records each one relied on (DE-D60). */
29
61
  capabilities: {
@@ -39,6 +71,12 @@ export type ChangeServices = {
39
71
  compileCardQuery(request: {
40
72
  query: MetricCardQuery | RecordsCardQuery;
41
73
  chartType: TChartType;
74
+ /**
75
+ * The dashboard's own calculated fields, as the proposal has them so far:
76
+ * a name the query states resolves to one of them before the domain
77
+ * (MC-D9), on the card's dataset. Resolved in memory; nothing is fetched.
78
+ */
79
+ dashboardFields?: readonly Field[];
42
80
  }): Promise<{
43
81
  ok: true;
44
82
  part: CardQueryPart;
@@ -61,6 +99,14 @@ export type ChangeServices = {
61
99
  field: string;
62
100
  toDataset: string;
63
101
  }): Promise<FieldRef[]>;
102
+ /**
103
+ * A calculation compiled by the domain's own compiler, as the domain would
104
+ * place it (calculated fields one core MC-D5): the formula in a dataset's
105
+ * field names, or `{token}`s over `inputs`, placed by stage and use and
106
+ * built into the stored field shape. Compiles only; nothing is saved.
107
+ * Phase 4's dashboard-field changes call it at propose (MC-INV-4).
108
+ */
109
+ compileCalculation?(request: CalculationCompileRequest): Promise<CalculationCompileResult>;
64
110
  /** A new unique id (a UUID: Matrix ids must be UUIDs, ledger P1-04). */
65
111
  newId(): string;
66
112
  /**
@@ -50,7 +50,8 @@ export * from './changes/card-query-part.js';
50
50
  export * from './changes/read-card-query.js';
51
51
  export * from './changes/dashboard-change.js';
52
52
  export * from './changes/domain-change.js';
53
- export { resolveDashboardChanges, type CardSource, type ChangeServices, type ChangeRef, type ChangeResolution, } from './changes/resolve-dashboard-changes.js';
53
+ export * from './changes/calculation-change.js';
54
+ export { resolveDashboardChanges, type CalculationCompileRequest, type CalculationCompileResult, type CardSource, type ChangeServices, type ChangeRef, type ChangeResolution, } from './changes/resolve-dashboard-changes.js';
54
55
  export * from './changes/resolve-dashboard-create.js';
55
56
  export * from './text-card-words/index.js';
56
57
  export * from './outline/outline-filters.js';
@@ -88,3 +89,8 @@ export * from './filter-reach-copy.js';
88
89
  export * from './variable-draft.js';
89
90
  export * from './variable-editability.js';
90
91
  export * from './dashboard-style/index.js';
92
+ export * from './calculations/tokens.js';
93
+ export * from './calculations/calculated-column.js';
94
+ export * from './calculations/definition.js';
95
+ export * from './calculations/resolve-dashboard-field-copies.js';
96
+ export * from './operations/calculated-field-operations.js';
@@ -0,0 +1,133 @@
1
+ import { TCard, TDashboard } from '../../../lib/types/common-types.js';
2
+ import { Field } from '../../../lib/types/explorer-types.js';
3
+ import { OperationFailure, OperationOutcome } from './card-operations.js';
4
+ /**
5
+ * A dashboard field and every copy of it, the one owner (calculated fields one
6
+ * core MC-D10): `calculatedField.add` appends a definition to
7
+ * `dashboard.calculatedFields`; `calculatedField.update` replaces it and
8
+ * rewrites every copy with its identity key (on every card's shelves, card
9
+ * filters and inline filters, and in dashboard filters' and inputs'
10
+ * `fieldMeta`), keeping each copy's own place (id, alias, role, aggregate,
11
+ * sort, format, label overrides); `calculatedField.remove` is refused while a
12
+ * copy remains, naming the cards and filters. The editor's dialog, the MCP
13
+ * resolver and the watch page apply these; nothing else writes the list.
14
+ */
15
+ export type CalculatedFieldOperation = {
16
+ op: 'calculatedField.add';
17
+ field: Field;
18
+ } | {
19
+ op: 'calculatedField.update';
20
+ key: string;
21
+ field: Field;
22
+ } | {
23
+ op: 'calculatedField.remove';
24
+ key: string;
25
+ /** The card open in the editor when the author removed it: its remaining copies (a sort, a filter) leave with the field at the commit. */
26
+ cardId?: string;
27
+ };
28
+ /** Where a dashboard field is used: the cards whose columns or filters copy it, and the dashboard filters. */
29
+ export type DashboardFieldUsage = {
30
+ cards: Array<{
31
+ cardId: string;
32
+ title?: string;
33
+ }>;
34
+ filters: Array<{
35
+ filterId: string;
36
+ label?: string;
37
+ }>;
38
+ /** The dashboard's other calculated fields whose formulas read this one (an input, at any depth). */
39
+ fields: Array<{
40
+ name: string;
41
+ label?: string;
42
+ }>;
43
+ };
44
+ /** Whether anything on the dashboard uses the field: a card, a filter or another field's formula. */
45
+ export declare const isCalculatedFieldInUse: (usage: DashboardFieldUsage) => boolean;
46
+ /**
47
+ * The cards, dashboard filters and fields that copy the field with this
48
+ * identity key; with `holds`, only those whose copy it accepts (a stage or
49
+ * type change counts the copies still built for the old shape).
50
+ */
51
+ export declare function calculatedFieldUsage(dashboard: TDashboard, key: string, holds?: (copy: Field) => boolean): DashboardFieldUsage;
52
+ /** The one wording of a removal refused while the field is used (MC-INV-2). */
53
+ export declare function calculatedFieldInUseMessage(field: Field, usage: DashboardFieldUsage): string;
54
+ export declare function addCalculatedField(dashboard: TDashboard, field: Field): OperationOutcome;
55
+ /**
56
+ * The refusal an update gets when it changes what a use is built for: a
57
+ * dimension's output type (its filters and their selections are of that
58
+ * type), or a measure's formula moving between per row and over aggregates
59
+ * (ledger P4-08: a card aggregates a per-row formula and nothing over one
60
+ * with its own aggregates). A use counts while its copy holds the old type
61
+ * or stage it was placed with (one saved without it: the old formula); one
62
+ * placed from this change or a later queued one holds the new (ledger P4-37,
63
+ * P4-43, P4-46). The one rule, for the update, the commit and the editor's check
64
+ * before it (`simulateCalculatedFieldOperations`).
65
+ */
66
+ export declare function stageChangeRefusal(dashboard: TDashboard, key: string, previous: Field, definition: Field): OperationFailure | undefined;
67
+ export declare function updateCalculatedField(dashboard: TDashboard, key: string, field: Field): OperationOutcome;
68
+ export declare function removeCalculatedField(dashboard: TDashboard, key: string): OperationOutcome;
69
+ export declare function applyCalculatedFieldOperation(dashboard: TDashboard, operation: CalculatedFieldOperation): OperationOutcome;
70
+ /**
71
+ * The definitions a dashboard needs for the copies its cards bring (MC-D19):
72
+ * a dashboard field for every dashboard copy whose identity key the dashboard
73
+ * lacks, built from the copy itself (a copy holds its whole formula). In
74
+ * release 1 frozen copies are left alone (`frozen: false`); the backfill
75
+ * passes `frozen: true` for the frozen copies it doesn't turn into domain
76
+ * references. Library visuals store no definitions list.
77
+ */
78
+ export declare function adoptCalculatedFields(dashboard: TDashboard, cards: readonly TCard[], options: {
79
+ frozen: boolean;
80
+ newId?: () => string;
81
+ }): TDashboard;
82
+ /**
83
+ * The operations that turn one dashboard field list into another, by
84
+ * identity key, in order: removals, changes, then additions. The editor's
85
+ * field list computes the list it wants; the store writes it through these
86
+ * (MC-D10, MC-D11), so the write merges with the dashboard as it is.
87
+ */
88
+ export declare function calculatedFieldListOperations(before: readonly Field[], after: readonly Field[]): CalculatedFieldOperation[];
89
+ /** One problem a dashboard field list has, in words safe to show (release 1's save checks, MC-D12). */
90
+ export type CalculatedFieldListIssue = {
91
+ name: string;
92
+ message: string;
93
+ };
94
+ /**
95
+ * Release 1's save checks of `dashboard.calculatedFields` (MC-D12): identity
96
+ * keys and names unique, every `{field_N}` has its input, every input is
97
+ * used, a role and a data type on each. Reads only the list.
98
+ */
99
+ export declare function checkCalculatedFieldList(fields: readonly Field[] | undefined): CalculatedFieldListIssue[];
100
+ /**
101
+ * Whether operations the open card's edit makes would apply: they are tried
102
+ * on the dashboard with that card's copies left out (the editor holds its
103
+ * draft), so a refusal shows when the author makes the change, never at the
104
+ * commit (MC-D11). The message of the first refusal, or undefined.
105
+ */
106
+ export declare function refusalOfCalculatedFieldOperations(dashboard: TDashboard, operations: readonly CalculatedFieldOperation[], openCardId?: string | null): string | undefined;
107
+ /**
108
+ * The operations tried as the commit will apply them, with the open card's
109
+ * copies left out (the editor holds its draft): the dashboard they leave,
110
+ * whose fields list carries every change they propagate (a field another
111
+ * reads, ledger P4-23), so an edit made later in the same session starts
112
+ * from it; or the first refusal's message.
113
+ */
114
+ export declare function simulateCalculatedFieldOperations(dashboard: TDashboard, operations: readonly CalculatedFieldOperation[], openCardId?: string | null): {
115
+ ok: true;
116
+ dashboard: TDashboard;
117
+ } | {
118
+ ok: false;
119
+ message: string;
120
+ };
121
+ /** One card without its copies of a removed field, on every shelf and filter: what the author's delete of the field means for the card being edited. */
122
+ export declare function withoutRemovedFieldCopies(dashboard: TDashboard, cardId: string, key: string): TDashboard;
123
+ /**
124
+ * A compiled card's dashboard-field columns written as the editor's drop
125
+ * writes them (`getNewField`), each keeping the compiled column's id and
126
+ * alias (calculated fields one core MC-D9, ledger P4-02). The compiler
127
+ * resolves a card query's names against the dashboard's fields
128
+ * (`compileCardQuery`'s `dashboardFields`) and marks each column it placed
129
+ * with the field's identity; this finds the field by that identity, never by
130
+ * name. An aggregate the author stated is kept, marked as the compiler marks
131
+ * one; a sort on a placed column follows it to the copy.
132
+ */
133
+ export declare function placeDashboardFieldCopies(config: NonNullable<TCard['config']>, dashboardFields: readonly Field[]): NonNullable<TCard['config']>;