react-semaphor 0.1.601 → 0.1.603

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 (123) hide show
  1. package/dist/analytics-protocol/index.js +415 -375
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +5 -5
  4. package/dist/brand-studio/index.js +8 -8
  5. package/dist/briefings/index.js +5 -5
  6. package/dist/chunks/{add-to-dashboard-ClhEIFst.js → add-to-dashboard-CFF-wFU-.js} +1 -1
  7. package/dist/chunks/{analytics-base-schemas-DevrgqQb.js → analytics-base-schemas-DsUh5Q3C.js} +14 -12
  8. package/dist/chunks/{assistant-chat-BE0XXzZP.js → assistant-chat-B6hNQI1t.js} +146 -146
  9. package/dist/chunks/{bookmark-impact-DXDAN5AY.js → bookmark-impact-Ba2PLcGp.js} +3 -3
  10. package/dist/chunks/{bookmark-state-BMyB3Tb6.js → bookmark-state-n7AaNzR_.js} +517 -516
  11. package/dist/chunks/{card-filter-builder-CE0-YVN5.js → card-filter-builder-Y22HizVx.js} +474 -474
  12. package/dist/chunks/{comparison-window-caption-Dxj2CHOa.js → comparison-window-caption-Ck2TIbnR.js} +69 -69
  13. package/dist/chunks/{context-BJoEFgNl.js → context-UCQ7sere.js} +1 -1
  14. package/dist/chunks/{dashboard-mJKPFRbb.js → dashboard-BghI99oY.js} +1 -1
  15. package/dist/chunks/{dashboard-briefing-launcher-CntwKyiZ.js → dashboard-briefing-launcher-DtBAnGiH.js} +725 -716
  16. package/dist/chunks/{dashboard-controls-XO089DMg.js → dashboard-controls-CtFXlyjV.js} +53 -53
  17. package/dist/chunks/{dashboard-json-CQRiydUv.js → dashboard-json-DfGBUtCd.js} +5 -5
  18. package/dist/chunks/dates-BnrXF4bb.js +185 -0
  19. package/dist/chunks/{edit-dashboard-visual-f-Dm-BLR.js → edit-dashboard-visual-oxt3x1wb.js} +8081 -8268
  20. package/dist/chunks/{filter-line-CKNMyNTQ.js → filter-line-Cy5YYqRL.js} +27 -27
  21. package/dist/chunks/{filter-reach-copy-B8GGyVuR.js → filter-reach-copy-CE_ZX147.js} +1786 -2214
  22. package/dist/chunks/{filter-value-text-CRtKecI5.js → filter-value-text-fWvSDwkl.js} +11 -11
  23. package/dist/chunks/{index-DoPApnxg.js → index-D5rxbtS4.js} +24 -24
  24. package/dist/chunks/{layout-grid-CiSCZdIr.js → layout-grid-9LndRoLa.js} +1 -1
  25. package/dist/chunks/{matrix-analytical-definition-myf3D3Qx.js → matrix-analytical-definition-CCp48UCw.js} +496 -425
  26. package/dist/chunks/matrix-member-presentation-zNehruXR.js +391 -0
  27. package/dist/chunks/{matrix-operation-contract-C1SuOHLZ.js → matrix-operation-contract-DPBj69D8.js} +518 -514
  28. package/dist/chunks/{metric-comparison-Cm0G893W.js → metric-comparison-B0FR-Q8I.js} +184 -125
  29. package/dist/chunks/{paintbrush-DQIwqlck.js → paintbrush-58FQYY-y.js} +1 -1
  30. package/dist/chunks/{palette-Cun747Rg.js → palette-Be62Tkoa.js} +1 -1
  31. package/dist/chunks/{pivot-result-contract-expectations-C1Dyx8du.js → pivot-result-contract-expectations-BYqAmG9n.js} +1236 -1190
  32. package/dist/chunks/{pivot-result-identity-CBS-ssEp.js → pivot-result-identity-CAP4--iq.js} +1 -1
  33. package/dist/chunks/raw-temporal-value-Dg_MTFF7.js +3778 -0
  34. package/dist/chunks/{report-preferences-dialog-SDZEcG2x.js → report-preferences-dialog-uJp9GBTM.js} +219 -205
  35. package/dist/chunks/{report-runtime-context-BbedQdtc.js → report-runtime-context-c77_KF9v.js} +2 -2
  36. package/dist/chunks/{resolve-dashboard-input-context-DRBS0eRa.js → resolve-dashboard-input-context-Rtl1ffmE.js} +8808 -7291
  37. package/dist/chunks/{save-Dj5bjm7P.js → save-C5A0JnEV.js} +1 -1
  38. package/dist/chunks/{saved-dashboard-context-DWVlJcsa.js → saved-dashboard-context-tcyTU8jm.js} +199 -213
  39. package/dist/chunks/selection-filter-compiler-DNijjI5y.js +150 -0
  40. package/dist/chunks/{semaphor-ready-indicator-OFOoAY-A.js → semaphor-ready-indicator-FBvunj6S.js} +37894 -35726
  41. package/dist/chunks/{shelf-drop-preview-context-2swWypXu.js → shelf-drop-preview-context-QKStrcK9.js} +54 -54
  42. package/dist/chunks/{stored-dashboard-NtOuEX6a.js → stored-dashboard-CHozcAY9.js} +770 -743
  43. package/dist/chunks/{style-sheet-parts-Qv4UcLAo.js → style-sheet-parts-CDCG-8Ej.js} +258 -251
  44. package/dist/chunks/{table-export-sheet-Do7ZB0_F.js → table-export-sheet-ZFIvs6Sj.js} +1 -1
  45. package/dist/chunks/{token-types-Dy_aXO-U.js → token-types-XbM6QByy.js} +1 -1
  46. package/dist/chunks/{upload-Bq-puSVy.js → upload-H15d7uHK.js} +1 -1
  47. package/dist/chunks/{validators-C7DFk3QK.js → validators-Baf3VIf5.js} +5 -5
  48. package/dist/chunks/{variable-draft-Cy03qnEi.js → variable-draft-C2y8Jp6Z.js} +27 -28
  49. package/dist/dashboard/index.js +2 -2
  50. package/dist/dashboard-authoring/index.js +3392 -2761
  51. package/dist/format-utils/index.js +205 -204
  52. package/dist/index.js +73 -75
  53. package/dist/report-runtime-context/index.js +2 -2
  54. package/dist/style.css +1 -1
  55. package/dist/surfboard/index.js +2 -2
  56. package/dist/types/components/dashboard/dashboard-web-component.d.ts +7 -0
  57. package/dist/types/components/ui-custom/date-range-presets.d.ts +8 -0
  58. package/dist/types/index.js +5 -5
  59. package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +1 -1
  60. package/dist/types/lib/document/document-edits.d.ts +0 -4
  61. package/dist/types/lib/query-context/assemble-card-query.d.ts +6 -1
  62. package/dist/types/lib/stores/dashboard-store.d.ts +30 -1
  63. package/dist/types/lib/types/common-types.d.ts +0 -2
  64. package/dist/types/lib/types/explorer-types.d.ts +1 -1
  65. package/dist/types/shared/analytics-protocol/aggregate-expression.d.ts +15 -0
  66. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +18 -0
  67. package/dist/types/shared/analytics-protocol/analyze-result-types.d.ts +3 -0
  68. package/dist/types/shared/analytics-protocol/comparison-choices.d.ts +92 -0
  69. package/dist/types/shared/analytics-protocol/comparison-placement.d.ts +30 -0
  70. package/dist/types/shared/analytics-protocol/contracts.d.ts +11 -5
  71. package/dist/types/shared/analytics-protocol/date-window.d.ts +105 -0
  72. package/dist/types/shared/analytics-protocol/filter-field-ownership.d.ts +27 -0
  73. package/dist/types/shared/analytics-protocol/fixtures.d.ts +4 -2
  74. package/dist/types/shared/analytics-protocol/index.d.ts +3 -0
  75. package/dist/types/shared/analytics-protocol/metric-comparison.d.ts +93 -11
  76. package/dist/types/shared/assistant-protocol/context.d.ts +16 -16
  77. package/dist/types/shared/dashboard-authoring/calculations/calculated-column.d.ts +52 -0
  78. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +129 -0
  79. package/dist/types/shared/dashboard-authoring/calculations/resolve-dashboard-field-copies.d.ts +46 -0
  80. package/dist/types/shared/dashboard-authoring/calculations/tokens.d.ts +36 -0
  81. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +8 -0
  82. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  83. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +2 -1
  84. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +0 -3
  85. package/dist/types/shared/dashboard-authoring/changes/calculation-change.d.ts +399 -0
  86. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +165 -360
  87. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +23 -2
  88. package/dist/types/shared/dashboard-authoring/changes/domain-change.d.ts +143 -266
  89. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +2 -0
  90. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +46 -0
  91. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
  92. package/dist/types/shared/dashboard-authoring/dashboard-variable-card.d.ts +2 -4
  93. package/dist/types/shared/dashboard-authoring/index.d.ts +7 -1
  94. package/dist/types/shared/dashboard-authoring/kpi-date-context.d.ts +2 -0
  95. package/dist/types/shared/dashboard-authoring/kpi-figure.d.ts +18 -0
  96. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +8 -7
  97. package/dist/types/shared/dashboard-authoring/measure-calculations/dates.d.ts +11 -1
  98. package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +2 -2
  99. package/dist/types/shared/dashboard-authoring/measure-calculations/options.d.ts +4 -0
  100. package/dist/types/shared/dashboard-authoring/measure-calculations/read.d.ts +18 -1
  101. package/dist/types/shared/dashboard-authoring/measure-calculations/resolve.d.ts +2 -0
  102. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +46 -88
  103. package/dist/types/shared/dashboard-authoring/operations/calculated-field-operations.d.ts +158 -0
  104. package/dist/types/shared/dashboard-authoring/operations/card-operations.d.ts +71 -0
  105. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +17 -6
  106. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +21 -0
  107. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +3 -0
  108. package/dist/types/shared/format-utils/comparison-detail.d.ts +34 -0
  109. package/dist/types/shared/format-utils/index.d.ts +1 -0
  110. package/dist/types/shared/format-utils/partial-period.d.ts +4 -2
  111. package/dist/types/shared/temporal/calendar-periods.d.ts +11 -0
  112. package/dist/types/shared/temporal/index.d.ts +2 -0
  113. package/dist/types/shared/temporal/temporal-text.d.ts +33 -0
  114. package/dist/types/shared/temporal/temporal.d.ts +27 -0
  115. package/dist/types/shared/temporal/zoned-wall-clock.d.ts +4 -3
  116. package/dist/types/shared/usage-events/details.d.ts +2 -2
  117. package/dist/types/shared/usage-events/envelope.d.ts +2 -2
  118. package/dist/usage-events/index.js +1 -1
  119. package/package.json +3 -2
  120. package/dist/chunks/dates-B-Urp5OD.js +0 -164
  121. package/dist/chunks/matrix-member-presentation-g0c_NpDW.js +0 -258
  122. package/dist/chunks/raw-temporal-value-DN_l-Tss.js +0 -454
  123. package/dist/chunks/selection-filter-compiler-DmAr7yqC.js +0 -131
@@ -0,0 +1,158 @@
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), and for
74
+ * every dashboard copy inside those formulas (a field another field reads), so
75
+ * an edit to a dependency reaches what reads it. A copy keeps its identity: a
76
+ * copy whose name the dashboard already gives another field (a card pasted
77
+ * from another dashboard) comes in under the next free name (`<name>_2`), its
78
+ * copies renamed with their label and result column kept. Identities are
79
+ * never merged by name or formula: two fields alike in words may read
80
+ * different domains (ledger P6-06). From release 2 a copy without a
81
+ * definition can't be saved (MC-D12). A copied formula without a scope (a
82
+ * frozen copy) is never adopted: converting those is the backfill planner's
83
+ * job. Library visuals store no definitions list.
84
+ */
85
+ export declare function adoptCalculatedFields(dashboard: TDashboard, cards: readonly TCard[]): TDashboard;
86
+ /**
87
+ * The operations that turn one dashboard field list into another, by
88
+ * identity key, in order: removals, changes, then additions. The editor's
89
+ * field list computes the list it wants; the store writes it through these
90
+ * (MC-D10, MC-D11), so the write merges with the dashboard as it is.
91
+ */
92
+ export declare function calculatedFieldListOperations(before: readonly Field[], after: readonly Field[]): CalculatedFieldOperation[];
93
+ /** One problem a dashboard field list has, in words safe to show (release 1's save checks, MC-D12). */
94
+ export type CalculatedFieldListIssue = {
95
+ name: string;
96
+ message: string;
97
+ };
98
+ /**
99
+ * Release 1's save checks of `dashboard.calculatedFields` (MC-D12): identity
100
+ * keys and names unique, every `{field_N}` has its input, every input is
101
+ * used, a role and a data type on each. Reads only the list.
102
+ */
103
+ export declare function checkCalculatedFieldList(fields: readonly Field[] | undefined): CalculatedFieldListIssue[];
104
+ /** A card's calculated column a save refuses (release 2, MC-D12), in words safe to show. */
105
+ export type CalculatedColumnIssue = {
106
+ cardId: string;
107
+ cardTitle: string;
108
+ name: string;
109
+ message: string;
110
+ };
111
+ /**
112
+ * Release 2's save refusal (MC-D12): a card's placed calculated column with no
113
+ * definition (`classifyCalculatedColumn` says `no_definition`: a copied
114
+ * formula, a card or sheet field's copy, a dashboard copy whose field is
115
+ * gone), and a card that keeps its own `calculatedFields`. It reads a card's
116
+ * placements only (the walk the backfill used: shelves, their conditions, card
117
+ * filters, inline filters), never its preferences (ledger P5-03). A Matrix card
118
+ * is left alone: its own fields and bindings are its definitions (MC-D15). A
119
+ * typed derived column carries its own definition (`derivedField`) and is
120
+ * accepted (ledger P5-05). Reads only the payload.
121
+ */
122
+ export declare function checkCalculatedColumnDefinitions(dashboard: TDashboard,
123
+ /** The cards to read; the shared traversal's by default. A caller reading a stored shape it doesn't cover passes those cards too. */
124
+ cards?: readonly TCard[]): CalculatedColumnIssue[];
125
+ /**
126
+ * Whether operations the open card's edit makes would apply: they are tried
127
+ * on the dashboard with that card's copies left out (the editor holds its
128
+ * draft), so a refusal shows when the author makes the change, never at the
129
+ * commit (MC-D11). The message of the first refusal, or undefined.
130
+ */
131
+ export declare function refusalOfCalculatedFieldOperations(dashboard: TDashboard, operations: readonly CalculatedFieldOperation[], openCardId?: string | null): string | undefined;
132
+ /**
133
+ * The operations tried as the commit will apply them, with the open card's
134
+ * copies left out (the editor holds its draft): the dashboard they leave,
135
+ * whose fields list carries every change they propagate (a field another
136
+ * reads, ledger P4-23), so an edit made later in the same session starts
137
+ * from it; or the first refusal's message.
138
+ */
139
+ export declare function simulateCalculatedFieldOperations(dashboard: TDashboard, operations: readonly CalculatedFieldOperation[], openCardId?: string | null): {
140
+ ok: true;
141
+ dashboard: TDashboard;
142
+ } | {
143
+ ok: false;
144
+ message: string;
145
+ };
146
+ /** 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. */
147
+ export declare function withoutRemovedFieldCopies(dashboard: TDashboard, cardId: string, key: string): TDashboard;
148
+ /**
149
+ * A compiled card's dashboard-field columns written as the editor's drop
150
+ * writes them (`getNewField`), each keeping the compiled column's id and
151
+ * alias (calculated fields one core MC-D9, ledger P4-02). The compiler
152
+ * resolves a card query's names against the dashboard's fields
153
+ * (`compileCardQuery`'s `dashboardFields`) and marks each column it placed
154
+ * with the field's identity; this finds the field by that identity, never by
155
+ * name. An aggregate the author stated is kept, marked as the compiler marks
156
+ * one; a sort on a placed column follows it to the copy.
157
+ */
158
+ export declare function placeDashboardFieldCopies(config: NonNullable<TCard['config']>, dashboardFields: readonly Field[]): NonNullable<TCard['config']>;
@@ -0,0 +1,71 @@
1
+ import { Immer } from 'immer';
2
+ import { TCard, TDashboard, TFrame, TSheet } from '../../../lib/types/common-types.js';
3
+ import { SheetLayoutChange } from '../../layouts/index.js';
4
+ import { SentenceClause } from './operation-sentences.js';
5
+ import { CardUpdate, CreatedEntity, DashboardOperation, DashboardRuntimeEffect, OperationFailureCode } from './operation-types.js';
6
+ /**
7
+ * The card operations of the dashboard reducer (MCP dashboard editing SPEC
8
+ * 3.3): add, remove, rename and retype. Pure: each returns a new dashboard
9
+ * that shares everything it did not touch, and never mints ids or reads the
10
+ * clock.
11
+ */
12
+ /** Drafts are finalized unfrozen, so callers own a plain document. */
13
+ export declare const reducerImmer: Immer;
14
+ export declare class OperationFailure extends Error {
15
+ readonly code: OperationFailureCode;
16
+ readonly fix?: string | undefined;
17
+ readonly details?: Record<string, unknown> | undefined;
18
+ constructor(code: OperationFailureCode, message: string, fix?: string | undefined, details?: Record<string, unknown> | undefined);
19
+ }
20
+ export type OperationOutcome = {
21
+ dashboard: TDashboard;
22
+ created?: CreatedEntity[];
23
+ /** Frames to load metadata for, beyond the frames of created and touched cards: a variable's, from the one writer (P2-28). */
24
+ queryFrames?: TFrame[];
25
+ /** Existing cards this operation changed in place (`DashboardOperationResult.touched`). */
26
+ touched?: string[];
27
+ runtimeEffects?: DashboardRuntimeEffect[];
28
+ clauses: SentenceClause[];
29
+ /**
30
+ * The operation made a frame that showed a library visual the dashboard's
31
+ * own (DE-D50). The confirmation reads this, never the sentence that says so.
32
+ */
33
+ detached?: boolean;
34
+ };
35
+ export type FrameCardLocation = {
36
+ sheetIndex: number;
37
+ frameIndex: number;
38
+ cardIndex: number;
39
+ sheet: TSheet;
40
+ frame: TFrame;
41
+ card: TCard;
42
+ };
43
+ /** A card in a frame on a grid sheet. Document-section cards are not frame cards. */
44
+ export declare function locateFrameCard(dashboard: TDashboard, cardId: string): FrameCardLocation | undefined;
45
+ export declare const sheetName: (sheet: TSheet | undefined) => string;
46
+ export declare function requireCard(dashboard: TDashboard, cardId: string): FrameCardLocation;
47
+ export declare function addCard(dashboard: TDashboard, operation: Extract<DashboardOperation, {
48
+ op: 'card.add';
49
+ }>): OperationOutcome;
50
+ /**
51
+ * The sheet after a layout change: the layout engine's frames, and its layouts
52
+ * and customized breakpoints when they changed (responsive layouts SPEC §3.1,
53
+ * §6.1). `sheet` is the sheet before the change.
54
+ */
55
+ export declare function withSheetLayoutChange(sheet: TSheet, change: SheetLayoutChange): TSheet;
56
+ /**
57
+ * Removes one card (DE-D42). With other tabs left, the frame stays and its
58
+ * first card becomes active, through the editor's own tab close rule
59
+ * (`withoutFrameCard`); a linked frame
60
+ * becomes local. The last card takes the frame and its layout entries on
61
+ * every breakpoint. Every input reference to the card goes with it.
62
+ */
63
+ export declare function removeCard(dashboard: TDashboard, cardId: string): OperationOutcome;
64
+ export declare function updateCard(dashboard: TDashboard, cardId: string, update: CardUpdate): OperationOutcome;
65
+ /** Replaces one card of a frame (and clears a link to a library visual, DE-D50); optionally resizes the frame's layouts. */
66
+ export declare function replaceFrameCard(dashboard: TDashboard, at: FrameCardLocation, card: TCard, options: {
67
+ resize: boolean;
68
+ }): {
69
+ dashboard: TDashboard;
70
+ detached: boolean;
71
+ };
@@ -1,4 +1,5 @@
1
1
  import { DataVariable, EmbeddedFilterDashboardInput, TDashboard, TFrame, TInlineFilter, TextCardRichContent } from '../../../lib/types/common-types.js';
2
+ import { CalculatedFieldOperation } from './calculated-field-operations.js';
2
3
  import { DocumentEdit } from '../../../lib/document/document-edits.js';
3
4
  import { ResolvedCardSettings } from '../card-settings/resolved.js';
4
5
  import { MeasureCalculationsUpdate } from '../measure-calculations/resolve.js';
@@ -73,10 +74,12 @@ export type FrameCommit = {
73
74
  frame: TFrame;
74
75
  /** Other frames on the sheet rewritten during the edit (calculated-field renames), applied with it. */
75
76
  rewrittenFrames?: TFrame[];
76
- /** Sheet calculated fields from the edited frame, persisted on the sheet. */
77
- sheetCalculatedFields?: Field[];
78
- /** Dashboard calculated fields rewritten during the edit. */
79
- dashboardCalculatedFields?: Field[];
77
+ /**
78
+ * The editor's dashboard-field adds, changes and removals during the edit,
79
+ * in order, applied through the `calculatedField.*` operations after the
80
+ * frame (MC-D11): the commit never replaces the dashboard's list.
81
+ */
82
+ calculatedFieldOps?: CalculatedFieldOperation[];
80
83
  /** True when committed from the visual editor: resize the frame's layouts if its type changed. */
81
84
  resizeLayouts: boolean;
82
85
  };
@@ -206,7 +209,9 @@ export type DashboardOperation = ({
206
209
  edit: Extract<DocumentEdit, {
207
210
  type: 'updateText' | 'updateRegionText';
208
211
  }>;
209
- }) & {
212
+ }
213
+ /** A dashboard field added, changed (every copy follows) or removed (calculated fields one core MC-D10). */
214
+ | CalculatedFieldOperation) & {
210
215
  /** Set by the resolver: the public change this operation came from. Descriptions group by it. */
211
216
  changeIndex?: number;
212
217
  };
@@ -287,7 +292,13 @@ export type OperationFailureCode = 'sheet_not_found'
287
292
  /** A data variable the one writer refuses (data variables spec 2.11); `details.issues` has its issues. */
288
293
  | 'variable_invalid' | 'variable_not_found'
289
294
  /** A Document edit its writer refuses (`DocumentEditError`), or a sheet that is no Document. */
290
- | 'document_invalid';
295
+ | 'document_invalid'
296
+ /** A dashboard field with that identity key or name exists already (calculated fields one core). */
297
+ | 'calculated_field_taken' | 'calculated_field_not_found'
298
+ /** `calculatedField.remove` while a copy remains; `details.usedBy` names the cards and filters. */
299
+ | 'calculated_field_in_use'
300
+ /** A measure's formula moving between per row and over aggregates while something uses it (ledger P4-08). */
301
+ | 'calculated_field_stage_change';
291
302
  export type DashboardOperationResult = {
292
303
  ok: true;
293
304
  dashboard: TDashboard;
@@ -164,6 +164,25 @@ export type OutlineLayoutRow = {
164
164
  width: FrameWidth;
165
165
  }>;
166
166
  };
167
+ /** A dashboard field read back so an agent can send it again (MC-INV-3). */
168
+ export type OutlineCalculatedField = {
169
+ domainId: string;
170
+ dataset: string;
171
+ name: string;
172
+ label?: string;
173
+ description?: string;
174
+ /** Named {token}s over `inputs`, as `toNamedTokens` writes them. */
175
+ expression: string;
176
+ inputs: Record<string, {
177
+ dataset: string;
178
+ field: string;
179
+ aggregate?: string;
180
+ }>;
181
+ use: 'aggregate' | 'group_or_filter';
182
+ dataType: string;
183
+ /** Card ids and dashboard filter ids whose columns copy it. */
184
+ usedBy: string[];
185
+ };
167
186
  export type DashboardOutline = {
168
187
  dashboardId: string;
169
188
  title: string;
@@ -185,6 +204,8 @@ export type DashboardOutline = {
185
204
  variables: OutlineVariable[];
186
205
  /** What `dashboard.style` sets, read back in its words, and what the dashboard shows. */
187
206
  style: OutlineStyle;
207
+ /** The dashboard's own calculated fields, in the words `calculation.add` takes (calculated fields one core MC-INV-3). */
208
+ calculatedFields?: OutlineCalculatedField[];
188
209
  /** In the editor's words: what the dashboard holds that no change can state (the parity backlog, DV-D13). */
189
210
  editorOnly?: string[];
190
211
  /** Queries left out because the dashboard has more than `maxQueryCards` cards (DE-D34). */
@@ -4,6 +4,7 @@ import { DashboardFilterNotReachedReason, DashboardRelationshipReachResolver } f
4
4
  import { AgentNumberConditionDefault, FilterInputEntry, NumberFilterShowAs } from '../filter-model/index.js';
5
5
  import { AgentTimeWindowRefusal } from '../../analytics-protocol/agent-time-window.js';
6
6
  import { RelativeDateWindow } from '../../analytics-protocol/relative-date/index.js';
7
+ import { ComparisonShiftSpec } from '../../analytics-protocol/metric-comparison.js';
7
8
  import { CalendarContext } from '../../report-runtime-context/index.js';
8
9
  import { FilterValue } from '../changes/dashboard-change.js';
9
10
  /**
@@ -37,6 +38,8 @@ export type OutlineFilter = {
37
38
  * it. It stays while filter.update leaves defaultPeriod out.
38
39
  */
39
40
  defaultPeriodReadOnly?: AgentTimeWindowRefusal;
41
+ /** A date filter's default comparison, a step back, as filter.update takes it (compare-with IN-08). */
42
+ defaultComparison?: ComparisonShiftSpec;
40
43
  /** For a date filter, the picker a viewer gets: one day, one month, or a range. */
41
44
  datePicker?: 'day' | 'month' | 'range';
42
45
  /** "all": every grid sheet. */
@@ -0,0 +1,34 @@
1
+ import { DashboardDateComparisonOwner, ResolvedMetricComparisonRequest, StoredMetricComparisonSpec } from '../analytics-protocol/metric-comparison.js';
2
+ import { ComparisonWindowShape } from '../analytics-protocol/comparison-choices.js';
3
+ /**
4
+ * A comparison in words (compare-with CW-D12, CW-INV-3), the one owner of
5
+ * comparison wording: the menu, the toolbar chip, the editor, the tile's
6
+ * tooltip, the assistant's context and the MCP outline all read it. It words
7
+ * what is requested, named for the window when its shape is known ("Previous
8
+ * 7 days", "Same day last week"); the dates exist only once the server has
9
+ * placed them (they arrive on a result), so none are invented here. Pure,
10
+ * React-free.
11
+ */
12
+ export type ComparisonWords = {
13
+ /** For a menu, a chip or a control: "Previous 7 days", "Same days last year, matching weekdays". */
14
+ label: string;
15
+ /** Inside a sentence: "the previous 7 days", "the same days last year, matching weekdays", "a target of 500". */
16
+ sentence: string;
17
+ };
18
+ /** A window's size in words, for a note about it: "a day", "a month", "7 days", "3 months", "24 hours". */
19
+ export declare function describeWindowSize(shape: ComparisonWindowShape): string;
20
+ /**
21
+ * Why a step back cannot fit the window it compares, and the steps that do
22
+ * (compare-with CW-D16): the MCP's refusal of a Date filter's default and its
23
+ * warning on a measure or a variable read the same words.
24
+ */
25
+ export declare function describeComparisonOverlap(spec: StoredMetricComparisonSpec, shape: ComparisonWindowShape): {
26
+ message: string;
27
+ fix: string;
28
+ };
29
+ /** A comparison's words, named for the window when its shape is known (CW-D12). */
30
+ export declare function describeComparison(stored: StoredMetricComparisonSpec, shape?: ComparisonWindowShape): ComparisonWords;
31
+ /** Whose date the dashboard date comparison follows. */
32
+ export declare function describeDashboardDateComparisonOwner(owner: DashboardDateComparisonOwner | undefined): string;
33
+ /** One measure's requested comparison, with where it comes from. */
34
+ export declare function describeMeasureComparison(measure: string, request: ResolvedMetricComparisonRequest): string;
@@ -41,6 +41,7 @@ export * from './attachment-filter-line.js';
41
41
  export { describeFilterValueInFullDetail, type FullDetailFilterValue, } from './filter-value-text.js';
42
42
  export { describeConditionInFullDetail, type FilterClauseText } from './filter-detail.js';
43
43
  export { formatCanonicalComparisonRange } from '../../lib/utils/comparison-window-caption.js';
44
+ export { describeComparison } from './comparison-detail.js';
44
45
  export { PDF_GROUP_CONTINUATION_CLASS } from './grouped-table-presentation.js';
45
46
  export { toStoredValueFormat } from './stored-value-format.js';
46
47
  export { SEMAPHOR_GENERATED_COUNT_METRIC_ID } from '../analytics-protocol/contracts.js';
@@ -4,8 +4,10 @@ import { ResolvedTemporalValueFormatPreferences } from '../value-format-preferen
4
4
  export type DatePeriodPartial = 'running' | 'start' | 'end';
5
5
  /**
6
6
  * A whole period cut to the counted window (KT-D9): it starts no earlier than
7
- * the window and ends no later; `running` when it ends after `now`, else
8
- * `start` or `end` when the window cut it, else whole.
7
+ * the window and ends no later; `running` when `now` falls inside it (it has
8
+ * started and not ended: a period still to come, such as next month's
9
+ * forecast, is not running; ledger EXT-12), else `start` or `end` when the
10
+ * window cut it, else whole.
9
11
  */
10
12
  export declare function cutDatePeriod(period: {
11
13
  start: Date;
@@ -52,6 +52,17 @@ export declare function startOfPeriodWall(wall: WallClockTime, unit: Exclude<Tem
52
52
  * occurrence, so a repeated hour is two periods.
53
53
  */
54
54
  export declare function periodAt(instant: Date, unit: TemporalUnit, calendar: TemporalCalendar, offset?: number): TemporalPeriod;
55
+ /** The calendar units a whole window can be, largest first. */
56
+ export declare const WHOLE_PERIOD_UNITS: readonly ["year", "quarter", "month", "week", "day"];
57
+ export type WholePeriodUnit = (typeof WHOLE_PERIOD_UNITS)[number];
58
+ /**
59
+ * The calendar period a window is exactly, when it is one: a whole year,
60
+ * quarter, month, week or day in this calendar (the largest that fits), else
61
+ * null. The one detector placement steps a range by and the comparison menu
62
+ * names a range by, so a whole February is "Previous month" in the menu and
63
+ * January in the run (compare-with ledger EXT-04).
64
+ */
65
+ export declare function completeCalendarPeriod(start: Date, endExclusive: Date, calendar: TemporalCalendar): WholePeriodUnit | null;
55
66
  /** Where the period containing `instant` starts. */
56
67
  export declare function startOfPeriod(instant: Date, unit: TemporalUnit, calendar: TemporalCalendar): Date;
57
68
  /** The last millisecond of the period containing `instant`. */
@@ -1,4 +1,6 @@
1
+ export * from './temporal.js';
1
2
  export * from './zoned-wall-clock.js';
3
+ export * from './temporal-text.js';
2
4
  export * from './calendar-periods.js';
3
5
  export * from './calendar-day-equality.js';
4
6
  export * from './raw-temporal-equality.js';
@@ -0,0 +1,33 @@
1
+ /** Date and time text as written: the date, then the time and the offset when present. */
2
+ export type TemporalText = {
3
+ year: number;
4
+ /** Absent for a year on its own (`2026`). */
5
+ month?: number;
6
+ /** Absent for a year or a month on its own (`2026-06`). */
7
+ day?: number;
8
+ time?: {
9
+ hour: number;
10
+ /** 1 for `9`, 2 for `09`. */
11
+ hourDigits: 1 | 2;
12
+ minute?: number;
13
+ second?: number;
14
+ /** The digits after the second, as written. */
15
+ fraction: string;
16
+ };
17
+ /** As written: `Z`, `+05`, `+0530` or `+05:30`. */
18
+ offset?: string;
19
+ /** Whitespace stood between the time and the offset (`… 10:00 +05`). */
20
+ spacedOffset?: true;
21
+ /** What follows the date and time, when a reader accepts text after them. */
22
+ rest: string;
23
+ };
24
+ /** The text's date and time fields, or null when it does not start with a four-digit year. */
25
+ export declare function lexTemporalText(text: string): TemporalText | null;
26
+ /** The offset as Temporal reads it (`+05` to `+05:00`, `+0530` to `+05:30`), or `Z`. */
27
+ export declare function normalizedOffset(offset: string): string;
28
+ /** Whether the fields name a real calendar date and wall time (February 29 only in a leap year, hours below 24). */
29
+ export declare function isRealTemporalText(text: TemporalText): boolean;
30
+ /** The milliseconds of a fraction as written (`5` is 500, `123456` is 123). */
31
+ export declare function fractionMilliseconds(fraction: string): number;
32
+ /** Exactly `YYYY-MM-DD`, as written; whether it names a real day is the reader's check (`parseWallDate`). */
33
+ export declare function isCalendarDateText(text: string): boolean;
@@ -0,0 +1,27 @@
1
+ import { Temporal as Polyfill } from 'temporal-polyfill';
2
+ type TemporalNamespace = typeof Polyfill;
3
+ export declare const Temporal: TemporalNamespace;
4
+ export type PlainDate = Polyfill.PlainDate;
5
+ export type PlainDateTime = Polyfill.PlainDateTime;
6
+ export type ZonedDateTime = Polyfill.ZonedDateTime;
7
+ export type Instant = Polyfill.Instant;
8
+ export type Duration = Polyfill.Duration;
9
+ /**
10
+ * How a wall-clock time a clock change skips or repeats names an instant
11
+ * (analytics kernel K7): a repeated hour takes its first occurrence, a skipped
12
+ * hour moves forward by the gap.
13
+ */
14
+ export declare const WALL_CLOCK_DISAMBIGUATION: "compatible";
15
+ /** The instant of a `Date`, as Temporal reads it. */
16
+ export declare function instantOf(date: Date): Instant;
17
+ /** The `Date` of an instant or a zoned time, for the code that still speaks `Date`. */
18
+ export declare function dateOf(value: Instant | ZonedDateTime): Date;
19
+ /** The first instant after an inclusive end (its last millisecond): the end a half-open window takes. */
20
+ export declare function exclusiveEndOf(inclusiveEnd: Date): Date;
21
+ /** The last millisecond before an exclusive end: the inclusive end a resolver hands out. */
22
+ export declare function inclusiveEndOf(exclusiveEnd: Date): Date;
23
+ /** Elapsed time from one instant to another, in milliseconds. */
24
+ export declare function elapsedMilliseconds(from: Date, to: Date): number;
25
+ /** An instant moved by elapsed time (never the calendar: a day across a clock change is not 24 hours of it). */
26
+ export declare function afterElapsed(instant: Date, milliseconds: number): Date;
27
+ export {};
@@ -1,3 +1,4 @@
1
+ import { PlainDateTime } from './temporal.js';
1
2
  export type ZonedWallClock = {
2
3
  year: number;
3
4
  month: number;
@@ -11,14 +12,14 @@ export declare function zonedWallClock(instant: Date, tz: string): ZonedWallCloc
11
12
  export type ZonedWallClockTime = ZonedWallClock & {
12
13
  millisecond?: number;
13
14
  };
15
+ /** The wall clock as a Temporal plain date and time (the calendar's own, no timezone). */
16
+ export declare function plainWallClock(wall: ZonedWallClockTime): PlainDateTime;
14
17
  /** The wall clock as if it were UTC, in milliseconds. */
15
18
  export declare function wallClockMilliseconds(wall: ZonedWallClockTime): number;
16
19
  /**
17
20
  * The instant a wall-clock time names in a timezone (analytics kernel K7). A
18
21
  * repeated hour takes its first occurrence; a skipped hour moves forward by
19
- * the gap, as JavaScript's Temporal API and java.time do by default. The
20
- * offsets a day either side cover any one change, and no offset reaches a
21
- * day, so the answer never depends on the machine.
22
+ * the gap: Temporal's `compatible` rule, as java.time does by default.
22
23
  */
23
24
  export declare function zonedWallClockToInstant(wall: ZonedWallClockTime, tz: string): Date;
24
25
  /**
@@ -273,18 +273,18 @@ export declare const exportCompletedDetailsSchema: z.ZodObject<{
273
273
  mechanism: "rendered" | "job" | "matrix_direct";
274
274
  scope?: "dashboard" | "card" | "visual" | undefined;
275
275
  rows?: number | undefined;
276
+ stage?: "create" | "acquire" | "deadline" | "render" | undefined;
276
277
  chunks?: number | undefined;
277
278
  bytes?: number | undefined;
278
- stage?: "create" | "acquire" | "deadline" | "render" | undefined;
279
279
  export_id?: string | undefined;
280
280
  }, {
281
281
  format: "csv" | "xlsx" | "pdf" | "png";
282
282
  mechanism: "rendered" | "job" | "matrix_direct";
283
283
  scope?: "dashboard" | "card" | "visual" | undefined;
284
284
  rows?: number | undefined;
285
+ stage?: "create" | "acquire" | "deadline" | "render" | undefined;
285
286
  chunks?: number | undefined;
286
287
  bytes?: number | undefined;
287
- stage?: "create" | "acquire" | "deadline" | "render" | undefined;
288
288
  export_id?: string | undefined;
289
289
  }>;
290
290
  export type ExportCompletedDetails = z.infer<typeof exportCompletedDetailsSchema>;
@@ -108,7 +108,7 @@ export declare const usageEventEnvelopeSchema: z.ZodObject<{
108
108
  release: string;
109
109
  org_id: string | null;
110
110
  tenant_id: string | null;
111
- actor_type: "system" | "tenant" | "tenant_user" | "anonymous" | "org_user" | "api_key";
111
+ actor_type: "system" | "tenant" | "anonymous" | "tenant_user" | "org_user" | "api_key";
112
112
  org_user_id: string | null;
113
113
  tenant_user_id: string | null;
114
114
  session_id: string | null;
@@ -137,7 +137,7 @@ export declare const usageEventEnvelopeSchema: z.ZodObject<{
137
137
  release: string;
138
138
  org_id: string | null;
139
139
  tenant_id: string | null;
140
- actor_type: "system" | "tenant" | "tenant_user" | "anonymous" | "org_user" | "api_key";
140
+ actor_type: "system" | "tenant" | "anonymous" | "tenant_user" | "org_user" | "api_key";
141
141
  org_user_id: string | null;
142
142
  tenant_user_id: string | null;
143
143
  session_id: string | null;
@@ -1,5 +1,5 @@
1
1
  import { z as e } from "zod";
2
- import { g as h, l as S } from "../chunks/context-BJoEFgNl.js";
2
+ import { g as h, l as S } from "../chunks/context-UCQ7sere.js";
3
3
  import { Q as b, a as y, b as x } from "../chunks/attribution-BvoKvhcj.js";
4
4
  import { U as te, c as ne, u as ae } from "../chunks/attribution-BvoKvhcj.js";
5
5
  const r = e.string().min(1).max(128), t = e.string().max(500), m = e.array(e.string().max(500)).max(500), n = e.number().int().nonnegative(), p = e.string().refine((o) => new TextEncoder().encode(o).length <= 16 * 1024), f = e.object({
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.601",
8
+ "version": "0.1.603",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -117,7 +117,7 @@
117
117
  "build": "node scripts/build.mjs",
118
118
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
119
119
  "lint:regressions": "node scripts/lint-regressions.mjs",
120
- "check:guards": "node scripts/card-config-consumers.mjs && node scripts/components-entry-imports.mjs && node scripts/types-entry-imports.mjs && node scripts/card-query-assembly-imports.mjs && node scripts/matrix-conversion-imports.mjs && node scripts/legacy-table-type-references.mjs && node scripts/assistant-chat-imports.mjs && node scripts/filter-model-reads.mjs && node scripts/kpi-figure-reads.mjs && node scripts/layout-engine.mjs && node scripts/text-variable-refs.mjs && node scripts/data-variable-derivation.mjs && node scripts/variable-name-allocation.mjs && node scripts/unreached-modules.mjs && node scripts/dashboard-style-reads.mjs && node scripts/host-color-variables.mjs",
120
+ "check:guards": "node scripts/card-config-consumers.mjs && node scripts/components-entry-imports.mjs && node scripts/types-entry-imports.mjs && node scripts/card-query-assembly-imports.mjs && node scripts/matrix-conversion-imports.mjs && node scripts/legacy-table-type-references.mjs && node scripts/assistant-chat-imports.mjs && node scripts/filter-model-reads.mjs && node scripts/kpi-figure-reads.mjs && node scripts/layout-engine.mjs && node scripts/text-variable-refs.mjs && node scripts/data-variable-derivation.mjs && node scripts/variable-name-allocation.mjs && node scripts/unreached-modules.mjs && node scripts/dashboard-style-reads.mjs && node scripts/host-color-variables.mjs && node scripts/comparison-words.mjs",
121
121
  "preview": "vite preview",
122
122
  "test": "vitest run",
123
123
  "test:changed": "vitest run --changed",
@@ -222,6 +222,7 @@
222
222
  "sonner": "^1.5.0",
223
223
  "tailwind-merge": "^2.1.0",
224
224
  "tailwindcss-animate": "^1.0.7",
225
+ "temporal-polyfill": "1.0.8",
225
226
  "uuid": "^9.0.1",
226
227
  "zod": "^3.25.76",
227
228
  "zustand": "^5.0.9"