react-semaphor 0.1.586 → 0.1.588

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 (98) hide show
  1. package/dist/analytics-protocol/index.js +341 -338
  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-DhP8wVtM.js → add-to-dashboard-C86FsM8D.js} +1 -1
  7. package/dist/chunks/{aggregate-measure-field-DsFXETpI.js → aggregate-measure-field-BrkXsSJp.js} +2 -2
  8. package/dist/chunks/{analytics-base-schemas-BaIQrEzX.js → analytics-base-schemas-8wz9vqn_.js} +173 -165
  9. package/dist/chunks/{assistant-chat-BU5gchFy.js → assistant-chat-BeM6joPc.js} +19 -18
  10. package/dist/chunks/{bookmark-impact-ZPSGncK6.js → bookmark-impact-B7pbMx2e.js} +2 -2
  11. package/dist/chunks/{bookmark-state-CL4WEpgB.js → bookmark-state-Bn7k3ttp.js} +5 -5
  12. package/dist/chunks/{card-filter-builder-HELJWA4D.js → card-filter-builder-DmodrhyI.js} +81 -81
  13. package/dist/chunks/{comparison-window-caption-CoART8BC.js → comparison-window-caption-fqijZdVd.js} +451 -395
  14. package/dist/chunks/{context-BTLBjQNh.js → context-CVXTFljo.js} +1 -1
  15. package/dist/chunks/{dashboard-BXP-ZxSY.js → dashboard-Tu5wT0Cw.js} +1 -1
  16. package/dist/chunks/{dashboard-briefing-launcher-BGj42whr.js → dashboard-briefing-launcher-D8jMxIJo.js} +249 -265
  17. package/dist/chunks/{dashboard-controls-zvbRp6D2.js → dashboard-controls-uzeAIEkM.js} +65 -65
  18. package/dist/chunks/{dashboard-json-CykexgqL.js → dashboard-json-i5rpFNCg.js} +5 -5
  19. package/dist/chunks/dates-BunbHJH0.js +115 -0
  20. package/dist/chunks/{edit-dashboard-visual-C82JNxbt.js → edit-dashboard-visual-BpEK_Sls.js} +2882 -2843
  21. package/dist/chunks/{filter-line-Cu2u1K36.js → filter-line-Dza3ee4w.js} +5 -5
  22. package/dist/chunks/{filter-reach-copy-ZERaFKsN.js → filter-reach-copy-D5AmDHda.js} +939 -937
  23. package/dist/chunks/{filter-value-text-xefXzZlf.js → filter-value-text-DQw4v3nC.js} +6 -6
  24. package/dist/chunks/{index-otMIColV.js → index-dGxJTaP1.js} +39 -39
  25. package/dist/chunks/{layout-grid-9nSS2SL-.js → layout-grid-XCYphks2.js} +1 -1
  26. package/dist/chunks/{list-filter-CfMPI6v4.js → list-filter-DGV3fqqv.js} +1 -1
  27. package/dist/chunks/{matrix-analytical-definition-DOVSFFuf.js → matrix-analytical-definition-SN0JUJVk.js} +3 -3
  28. package/dist/chunks/{matrix-member-presentation-BKDyxJho.js → matrix-member-presentation-DVBJR0MA.js} +1 -1
  29. package/dist/chunks/{matrix-operation-contract-BM5TveR3.js → matrix-operation-contract-JSmproo9.js} +15 -15
  30. package/dist/chunks/{metric-comparison-ZmurmEIs.js → metric-comparison-xE_J6hkg.js} +2 -2
  31. package/dist/chunks/{paintbrush-LzAje2ff.js → paintbrush-DEEZXhDj.js} +1 -1
  32. package/dist/chunks/{palette-DicJG0TC.js → palette-Bgy0H-Nt.js} +1 -1
  33. package/dist/chunks/{pivot-header-presentation-CdeTU96P.js → pivot-header-presentation-D-DfPAjb.js} +1 -1
  34. package/dist/chunks/{pivot-result-contract-expectations-Bx_BCu-7.js → pivot-result-contract-expectations-DbBahmgc.js} +545 -536
  35. package/dist/chunks/{pivot-result-identity-Bvs6Uq3v.js → pivot-result-identity-CUsMt_4r.js} +1 -1
  36. package/dist/chunks/{raw-temporal-value-DH-feMc2.js → raw-temporal-value-BnGCWJAL.js} +1 -1
  37. package/dist/chunks/{report-preferences-dialog-B-CoyS1x.js → report-preferences-dialog-CTM0xfd0.js} +14 -14
  38. package/dist/chunks/{report-runtime-context-NlOXwyRB.js → report-runtime-context-CrOgmuxO.js} +2 -2
  39. package/dist/chunks/{resolve-dashboard-input-context-BTTdKXH0.js → resolve-dashboard-input-context-DFBIngUZ.js} +5621 -5476
  40. package/dist/chunks/{save-0wu1Z1U7.js → save-xnRCvMeA.js} +1 -1
  41. package/dist/chunks/{saved-dashboard-context-B-rosN4W.js → saved-dashboard-context-DKMTP9ib.js} +17 -17
  42. package/dist/chunks/selection-filter-compiler-DkIjp1yH.js +131 -0
  43. package/dist/chunks/{semaphor-ready-indicator-Cy1n_04D.js → semaphor-ready-indicator-zU9reNmX.js} +47183 -46779
  44. package/dist/chunks/{shelf-drop-preview-context-Bmz54WYm.js → shelf-drop-preview-context-R9sf4oDX.js} +6 -6
  45. package/dist/chunks/{stored-dashboard-rDJ8sw6J.js → stored-dashboard-CksluF2S.js} +1539 -1404
  46. package/dist/chunks/{style-sheet-parts-_dGSFzDi.js → style-sheet-parts-D7NbsFL0.js} +3 -3
  47. package/dist/chunks/{table-export-sheet-Dmtqi5NV.js → table-export-sheet-ClSgERQC.js} +1 -1
  48. package/dist/chunks/{token-types-DEe_FP4l.js → token-types-DTocOcwt.js} +1 -1
  49. package/dist/chunks/{upload-CtyOkU_B.js → upload-BXGgYS4g.js} +1 -1
  50. package/dist/chunks/{validators-CJ8Jh0E8.js → validators-CrYXNnNE.js} +51 -49
  51. package/dist/chunks/{variable-draft-DvngkRMl.js → variable-draft-rbtGPvmX.js} +16 -14
  52. package/dist/chunks/visual-choice-DDfHfHvY.js +172 -0
  53. package/dist/dashboard/index.js +2 -2
  54. package/dist/dashboard-authoring/index.js +1501 -1460
  55. package/dist/format-utils/index.js +162 -158
  56. package/dist/index.js +21 -21
  57. package/dist/report-runtime-context/index.js +2 -2
  58. package/dist/style.css +1 -1
  59. package/dist/surfboard/index.js +2 -2
  60. package/dist/types/index.js +5 -5
  61. package/dist/types/lib/dashboard-view-state/card-view-state.d.ts +39 -2
  62. package/dist/types/lib/dashboard-view-state/date-zoom.d.ts +65 -0
  63. package/dist/types/lib/dashboard-view-state/grain-pick.d.ts +38 -0
  64. package/dist/types/lib/dashboard-view-state/index.d.ts +2 -0
  65. package/dist/types/lib/formatters/grouped-temporal-presentation.d.ts +6 -2
  66. package/dist/types/lib/hooks/interactions/use-drill-actions.d.ts +1 -1
  67. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +2 -2
  68. package/dist/types/lib/query-context/assemble-card-query.d.ts +2 -1
  69. package/dist/types/lib/query-context/build-card-query-context.d.ts +15 -1
  70. package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +3 -0
  71. package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +14 -1
  72. package/dist/types/lib/stores/dashboard-store.d.ts +7 -1
  73. package/dist/types/lib/types/explorer-types.d.ts +24 -4
  74. package/dist/types/lib/utils/card-config-utils.d.ts +1 -1
  75. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +32 -0
  76. package/dist/types/shared/analytics-protocol/contracts.d.ts +30 -0
  77. package/dist/types/shared/analytics-protocol/filter-field-ownership.d.ts +13 -0
  78. package/dist/types/shared/dashboard-authoring/automatic-grain.d.ts +77 -0
  79. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +10 -3
  80. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  81. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +5 -2
  82. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +5 -2
  83. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +2 -0
  84. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +13 -8
  85. package/dist/types/shared/dashboard-authoring/control-value-resolution.d.ts +24 -0
  86. package/dist/types/shared/dashboard-authoring/index.d.ts +2 -0
  87. package/dist/types/shared/dashboard-authoring/kpi-figure.d.ts +12 -12
  88. package/dist/types/shared/dashboard-authoring/kpi-trend-rule.d.ts +51 -0
  89. package/dist/types/shared/dashboard-authoring/variable-draft.d.ts +1 -0
  90. package/dist/types/shared/format-utils/index.d.ts +1 -0
  91. package/dist/types/shared/format-utils/partial-period.d.ts +40 -0
  92. package/dist/types/shared/format-utils/temporal-bucket.d.ts +11 -0
  93. package/dist/types/shared/usage-events/details.d.ts +2 -2
  94. package/dist/usage-events/index.js +1 -1
  95. package/package.json +1 -1
  96. package/dist/chunks/dates-CaqZtq01.js +0 -92
  97. package/dist/chunks/selection-filter-compiler-BReJy-uv.js +0 -92
  98. package/dist/chunks/visual-choice-BBPizkRo.js +0 -206
@@ -1,3 +1,4 @@
1
+ import { KpiTrendGrain } from '../kpi-trend-rule.js';
1
2
  import { TChartType } from '../../../lib/charts/types.js';
2
3
  import { AxisConfig, TCard, TCardPreferences, TLegendOptions } from '../../../lib/types/common-types.js';
3
4
  import { SemaphorValueFormat } from '../../analytics-protocol/contracts.js';
@@ -30,10 +31,16 @@ export declare function writeChartOrientation<T extends Pick<TCard, 'type' | 'pr
30
31
  */
31
32
  export declare function writeCardVariant<T extends Pick<TCard, 'type' | 'preferences'>>(card: T, variant: CardVariant): T;
32
33
  /**
33
- * A KPI's band (KPI tile layout KL-D29), as the KPI settings' band control
34
- * writes it: `trend` or `none`, or null for Automatic, which stores nothing.
34
+ * A KPI's Trend switch (KPI trend window KT-D16), as the editor's switch and
35
+ * the MCP's `trend` write it: on stores `kpiBand: 'trend'`, off stores nothing.
35
36
  */
36
- export declare function writeKpiBand<T extends Pick<TCard, 'config'>>(card: T, band: 'trend' | 'none' | null): T;
37
+ export declare function writeKpiTrend<T extends Pick<TCard, 'config'>>(card: T, on: boolean): T;
38
+ /**
39
+ * A KPI trend's grain when it has no Trend By (KPI trend window KT-D2,
40
+ * KT-D12), as the editor's Grain control and the MCP's `trendGrain` write it:
41
+ * a grain, or null for Automatic, which stores nothing.
42
+ */
43
+ export declare function writeKpiTrendGrain<T extends Pick<TCard, 'config'>>(card: T, grain: KpiTrendGrain | null): T;
37
44
  /**
38
45
  * A config table's totals (table overall totals OT-D16): the row on or off,
39
46
  * and each named measure's total, keyed by its result alias. Overall is the
@@ -1,6 +1,6 @@
1
1
  import { TCard } from '../../../lib/types/common-types.js';
2
2
  import { CardType } from '../changes/card-types.js';
3
- export type SettingName = 'columns.label' | 'columns.format' | 'columns.hidden' | 'columns.width' | 'orientation' | 'stack' | 'donut' | 'totals' | 'dataLabels' | 'legend' | 'axes' | 'highlights' | 'columns.polarity' | 'comparisonDisplay' | 'inheritComparison' | 'band' | 'seeRecords';
3
+ export type SettingName = 'columns.label' | 'columns.format' | 'columns.hidden' | 'columns.width' | 'orientation' | 'stack' | 'donut' | 'totals' | 'dataLabels' | 'legend' | 'axes' | 'highlights' | 'columns.polarity' | 'comparisonDisplay' | 'inheritComparison' | 'trend' | 'trendGrain' | 'seeRecords';
4
4
  export declare const SETTINGS_BY_KIND: Readonly<Record<CardType, readonly SettingName[]>>;
5
5
  export type CardSettingsKind = {
6
6
  type: CardType;
@@ -1,3 +1,4 @@
1
+ import { KpiTrendGrain } from '../kpi-trend-rule.js';
1
2
  import { MetricComparisonPolarity } from '../../analytics-protocol/metric-comparison.js';
2
3
  import { TableColumnTotal } from '../measure-calculations/table-column-total.js';
3
4
  import { SemaphorDateValueFormat, SemaphorDurationValueFormat, SemaphorNumericValueFormat, SemaphorValueFormat, TemporalBucketFormat } from '../../analytics-protocol/contracts.js';
@@ -74,8 +75,10 @@ export type CardSettingsInput = {
74
75
  comparisonDisplay?: ComparisonDisplayInput;
75
76
  /** false: measures without a comparison of their own ignore the dashboard's; true removes the stored opt-out (RC-D16). */
76
77
  inheritComparison?: boolean;
77
- /** A KPI's band (KPI tile layout KL-D29): `trend` needs a Trend By; `automatic` follows the summary and target. */
78
- band?: 'automatic' | 'trend' | 'none';
78
+ /** A KPI's Trend switch (KPI trend window KT-D16): on draws its trend on the date it counts (KT-D1); off follows the summary and target. */
79
+ trend?: boolean;
80
+ /** A KPI trend's grain when it has no Trend By (KT-D2, KT-D12): `automatic` fits it to the period the KPI counts. */
81
+ trendGrain?: 'automatic' | KpiTrendGrain;
79
82
  /** false: viewers can't open the records behind the card's numbers; true removes the stored opt-out (see-records SR-D4). */
80
83
  seeRecords?: boolean;
81
84
  };
@@ -1,3 +1,4 @@
1
+ import { KpiTrendGrain } from '../kpi-trend-rule.js';
1
2
  import { SemaphorValueFormat } from '../../analytics-protocol/contracts.js';
2
3
  import { CardColumnRef, ConditionalRule } from '../conditional-formatting/types.js';
3
4
  import { AxisConfigKey, CardVariant } from './card-display-write.js';
@@ -51,8 +52,10 @@ export type ResolvedCardSettings = {
51
52
  comparisonDisplay?: ResolvedComparisonDisplay;
52
53
  /** Whether measures without a comparison of their own follow the dashboard's (RC-D16). */
53
54
  inheritComparison?: boolean;
54
- /** A KPI's band (KL-D29); null returns it to Automatic. */
55
- band?: 'trend' | 'none' | null;
55
+ /** A KPI's Trend switch (KT-D16). */
56
+ trend?: boolean;
57
+ /** A KPI trend's grain (KT-D12); null returns it to Automatic. */
58
+ trendGrain?: KpiTrendGrain | null;
56
59
  /** Whether viewers can open the records behind the card's numbers (see-records SR-D4). */
57
60
  seeRecords?: boolean;
58
61
  };
@@ -153,6 +153,7 @@ export declare const CARD_CONFIG_KEY_CLASSES: {
153
153
  readonly detailTableBackup: "presentation";
154
154
  readonly summary: "presentation";
155
155
  readonly kpiBand: "presentation";
156
+ readonly kpiTrendGrain: "presentation";
156
157
  readonly rowAggregates: "presentation";
157
158
  readonly columnAggregates: "presentation";
158
159
  };
@@ -202,6 +203,7 @@ export declare const COLUMN_KEY_CLASSES: {
202
203
  };
203
204
  group_by: {
204
205
  readonly timeDrillPath: "presentation";
206
+ readonly grainMode: "query";
205
207
  readonly id: "presentation";
206
208
  readonly name: "query";
207
209
  readonly label: "presentation";
@@ -165,6 +165,11 @@ export declare const analyticsFilterSchema: z.ZodObject<{
165
165
  scope?: "aggregate" | "row" | undefined;
166
166
  }>;
167
167
  export declare const TIME_GRAINS: readonly ["minute", "hour", "day", "week", "month", "quarter", "year"];
168
+ /**
169
+ * Chart date grain DG-D8: a chart's date grouped by a grain that follows the
170
+ * dashboard date, the word the KPI trend's `trendGrain` already uses.
171
+ */
172
+ export declare const AUTOMATIC_TIME_GRAIN: "automatic";
168
173
  /** The largest row limit a query states. */
169
174
  export declare const MAX_QUERY_LIMIT = 1000;
170
175
  declare const queryMeasureUnion: z.ZodUnion<[z.ZodString, z.ZodObject<{
@@ -1191,7 +1196,7 @@ export declare const metricCardQuerySchema: z.ZodObject<{
1191
1196
  connectionId?: string | undefined;
1192
1197
  } | undefined;
1193
1198
  }>]>>;
1194
- timeGrain: z.ZodOptional<z.ZodEnum<["minute", "hour", "day", "week", "month", "quarter", "year"]>>;
1199
+ timeGrain: z.ZodOptional<z.ZodEnum<["minute", "hour", "day", "week", "month", "quarter", "year", "automatic"]>>;
1195
1200
  filters: z.ZodOptional<z.ZodArray<z.ZodObject<{
1196
1201
  id: z.ZodOptional<z.ZodString>;
1197
1202
  field: z.ZodUnion<[z.ZodString, z.ZodObject<{
@@ -1600,7 +1605,7 @@ export declare const metricCardQuerySchema: z.ZodObject<{
1600
1605
  connectionId?: string | undefined;
1601
1606
  } | undefined;
1602
1607
  } | undefined;
1603
- timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | undefined;
1608
+ timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | "automatic" | undefined;
1604
1609
  dimensions?: (string | {
1605
1610
  name: string;
1606
1611
  datasetName?: string | undefined;
@@ -1827,7 +1832,7 @@ export declare const metricCardQuerySchema: z.ZodObject<{
1827
1832
  connectionId?: string | undefined;
1828
1833
  } | undefined;
1829
1834
  } | undefined;
1830
- timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | undefined;
1835
+ timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | "automatic" | undefined;
1831
1836
  dimensions?: (string | {
1832
1837
  name: string;
1833
1838
  datasetName?: string | undefined;
@@ -2760,7 +2765,7 @@ declare const cardQueryPatchObject: z.ZodObject<{
2760
2765
  connectionId?: string | undefined;
2761
2766
  } | undefined;
2762
2767
  }>]>>>;
2763
- timeGrain: z.ZodOptional<z.ZodNullable<z.ZodEnum<["minute", "hour", "day", "week", "month", "quarter", "year"]>>>;
2768
+ timeGrain: z.ZodOptional<z.ZodNullable<z.ZodEnum<["minute", "hour", "day", "week", "month", "quarter", "year", "automatic"]>>>;
2764
2769
  filters: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
2765
2770
  id: z.ZodOptional<z.ZodString>;
2766
2771
  field: z.ZodUnion<[z.ZodString, z.ZodObject<{
@@ -3187,7 +3192,7 @@ declare const cardQueryPatchObject: z.ZodObject<{
3187
3192
  connectionId?: string | undefined;
3188
3193
  } | undefined;
3189
3194
  } | null | undefined;
3190
- timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | null | undefined;
3195
+ timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | "automatic" | null | undefined;
3191
3196
  dimensions?: (string | {
3192
3197
  name: string;
3193
3198
  datasetName?: string | undefined;
@@ -3430,7 +3435,7 @@ declare const cardQueryPatchObject: z.ZodObject<{
3430
3435
  connectionId?: string | undefined;
3431
3436
  } | undefined;
3432
3437
  } | null | undefined;
3433
- timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | null | undefined;
3438
+ timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | "automatic" | null | undefined;
3434
3439
  dimensions?: (string | {
3435
3440
  name: string;
3436
3441
  datasetName?: string | undefined;
@@ -4910,7 +4915,7 @@ export declare const dashboardChangeSchema: z.ZodDiscriminatedUnion<"op", [z.Zod
4910
4915
  connectionId?: string | undefined;
4911
4916
  } | undefined;
4912
4917
  } | null | undefined;
4913
- timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | null | undefined;
4918
+ timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | "automatic" | null | undefined;
4914
4919
  dimensions?: (string | {
4915
4920
  name: string;
4916
4921
  datasetName?: string | undefined;
@@ -5264,7 +5269,7 @@ export declare const dashboardChangeSchema: z.ZodDiscriminatedUnion<"op", [z.Zod
5264
5269
  connectionId?: string | undefined;
5265
5270
  } | undefined;
5266
5271
  } | null | undefined;
5267
- timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | null | undefined;
5272
+ timeGrain?: "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year" | "automatic" | null | undefined;
5268
5273
  dimensions?: (string | {
5269
5274
  name: string;
5270
5275
  datasetName?: string | undefined;
@@ -30,6 +30,30 @@ export declare function resolveBindingControlValue(params: {
30
30
  definitions: Map<string, ControlDefinition>;
31
31
  controlValues?: Record<string, unknown>;
32
32
  }): string | undefined;
33
+ /**
34
+ * The value a binding applies to a card, or `undefined` when it applies
35
+ * nothing: an optional control with no value, or one set to the card's own
36
+ * default. The one rule the server's control resolution and the grain chip
37
+ * read (chart date grain review P4R-06).
38
+ */
39
+ export declare function appliedBindingControlValue(params: {
40
+ binding: ControlBinding;
41
+ definitions: Map<string, ControlDefinition>;
42
+ controlValues?: Record<string, unknown>;
43
+ }): string | undefined;
44
+ /**
45
+ * Whether a Grain control sets the card's date grain now. A Grain control
46
+ * wins over a viewer's grain pick, as it wins over the card's saved grain:
47
+ * the server applies it after the pick (chart date grain review P4R-06). A
48
+ * control that can't resolve leaves the card unrunnable, so it counts as
49
+ * setting the grain.
50
+ */
51
+ export declare function grainControlApplies(context: {
52
+ controlBindings: readonly ControlBinding[];
53
+ controlDefinitions: ControlDefinition[];
54
+ cardControlDefinitions: ControlDefinition[];
55
+ controlValues: Record<string, unknown>;
56
+ }): boolean;
33
57
  export declare function resolveScalarMappedValue(params: {
34
58
  binding: Extract<ControlBinding, {
35
59
  mapping: unknown;
@@ -1,5 +1,6 @@
1
1
  export * from './comparison-document-migration.js';
2
2
  export * from './temporal-result-owner.js';
3
+ export * from './automatic-grain.js';
3
4
  export * from './detail-date-presentation.js';
4
5
  export * from './temporal-bucket-authoring.js';
5
6
  export * from './canonical-result-keys.js';
@@ -57,6 +58,7 @@ export * from './card-formats/sql-date-pattern.js';
57
58
  export * from './retired-presentation-fields.js';
58
59
  export * from './conditional-formatting/index.js';
59
60
  export * from './kpi-figure.js';
61
+ export * from './kpi-trend-rule.js';
60
62
  export * from './kpi-date-context.js';
61
63
  export * from './see-records/index.js';
62
64
  export * from './card-settings/index.js';
@@ -2,8 +2,8 @@ import { TCard } from '../../lib/types/common-types.js';
2
2
  import { CardConfig, MetricField } from '../../lib/types/explorer-types.js';
3
3
  import { ComparisonMetadataMap } from '../../lib/types/query-types.js';
4
4
  import { MetricComparisonEvaluation, MetricComparisonPolarity } from '../analytics-protocol/index.js';
5
- import { TemporalBucketMetadata } from '../analytics-protocol/contracts.js';
6
5
  import { KpiDateContext } from './kpi-date-context.js';
6
+ import { KpiTrendMetadata, KpiTrendPartial } from './kpi-trend-rule.js';
7
7
  type KpiCard = Pick<TCard, 'sql' | 'config' | 'preferences'>;
8
8
  /**
9
9
  * Which column is the value, by source. The shape reads ids, never formats, so
@@ -74,35 +74,35 @@ export type KpiResultSegment = {
74
74
  metricId: string;
75
75
  /** The period's start as a canonical bucket value: `2026-10-01`, or `2026-10-01T14:00:00` below a day. */
76
76
  bucket: string;
77
- /** The point covers less than its whole period: cut by the value's window, or still running. */
78
- partial?: boolean;
77
+ /** The point covers less than its whole period, and how (KPI trend window KT-D9); absent for a whole period. */
78
+ partial?: KpiTrendPartial;
79
79
  };
80
- /** How many periods a trend shows (KL-D28). */
81
- export declare const KPI_TREND_PERIODS = 12;
82
80
  /** A config KPI's Trend By: its date grouping, the field its comparison and trend run over. */
83
81
  export declare function kpiTrendBy(config: Pick<CardConfig, 'groupByColumns'> | undefined): import('../../components/index.js').GroupByField | undefined;
84
82
  /**
85
83
  * Whether a config KPI shows a trend under its value (KL-D29): the author
86
- * chose Trend and it has a Trend By. The server runs the trend query and the
87
- * tile draws the band on the same answer.
84
+ * chose Trend. It runs on the date the KPI counts on, a Trend By or not (KPI
85
+ * trend window KT-D1): the server runs the trend when that date resolves and
86
+ * the tile draws the band on the same answer.
88
87
  */
89
88
  export declare function kpiShowsTrend(card: Pick<TCard, 'sql' | 'config'>): boolean;
90
89
  export type KpiTrendPoint = {
91
90
  bucket: string;
92
91
  value: number | null;
93
- partial: boolean;
92
+ /** Absent for a whole period (KT-D9). */
93
+ partial?: KpiTrendPartial;
94
94
  };
95
- /** The trend's points, oldest first, and the grain and calendar they are counted in. */
95
+ /** The trend's points, oldest first, and the grain, calendar, grain source and span they are counted in. */
96
96
  export type KpiTrend = {
97
- metadata: TemporalBucketMetadata;
97
+ metadata: KpiTrendMetadata;
98
98
  points: KpiTrendPoint[];
99
99
  };
100
100
  /** The metadata a config KPI response carries beside its rows. */
101
101
  export type KpiResultMetadata = {
102
102
  kpiLayout: KpiLayout;
103
103
  comparisonMetadata?: ComparisonMetadataMap;
104
- /** The trend's grain and calendar, when the response has trend rows (KL-D28). */
105
- trend?: TemporalBucketMetadata;
104
+ /** The trend's grain, calendar, grain source and span, when the card shows a trend (KL-D28, KT-D9). */
105
+ trend?: KpiTrendMetadata;
106
106
  /** Which date it counts, its windows and its compared period (KPI date context KD-D1). */
107
107
  dateContext?: KpiDateContext;
108
108
  };
@@ -0,0 +1,51 @@
1
+ import { CardConfig } from '../../lib/types/explorer-types.js';
2
+ import { DateGrainSource, DateWindow, TemporalBucketMetadata } from '../analytics-protocol/contracts.js';
3
+ import { DatePeriodPartial } from '../format-utils/partial-period.js';
4
+ /** A grain a KPI's trend draws in (KT-D2): the Trend By's, the card's or Automatic's. */
5
+ export type KpiTrendGrain = NonNullable<CardConfig['kpiTrendGrain']>;
6
+ export declare const KPI_TREND_GRAINS: readonly KpiTrendGrain[];
7
+ /** How many periods a history or recent span shows (KT-D4, as KL-D28). */
8
+ export declare const KPI_TREND_PERIODS = 12;
9
+ /** Where the trend's grain came from (KT-D2): a chart's sources, or the Trend By. */
10
+ export type KpiTrendGrainSource = DateGrainSource | 'trend_by';
11
+ /**
12
+ * What the trend's periods cover (KT-D4): the period the KPI counts, cut into
13
+ * periods (`window`); the 12 periods ending with it when it is one period of
14
+ * the grain (`history`); the 12 ending now when it counts all time (`recent`).
15
+ */
16
+ export type KpiTrendSpan = 'window' | 'history' | 'recent';
17
+ /**
18
+ * A point that covers less than its whole period (KT-D9): still running at the
19
+ * reference time, cut by the counted period's start, or cut by its end.
20
+ */
21
+ export type KpiTrendPartial = DatePeriodPartial;
22
+ /**
23
+ * The trend's grain and calendar, as every grouped date names its buckets
24
+ * (KPI tile layout ledger H-4), with where the grain came from and what the
25
+ * periods cover. `skipped` says why a trend the card shows has no rows.
26
+ */
27
+ export type KpiTrendMetadata = TemporalBucketMetadata & {
28
+ grainSource: KpiTrendGrainSource;
29
+ span: KpiTrendSpan;
30
+ skipped?: 'too_many_points';
31
+ /**
32
+ * The counted period the periods were cut to (window and history spans):
33
+ * a point cut at its start or end names that date from here (ledger ED-02).
34
+ * Absent for a recent span, which has no counted period.
35
+ */
36
+ window?: DateWindow;
37
+ };
38
+ /** The editor's Trend row under the Date section (KT-D11): what the line draws and where its grain came from. */
39
+ export type KpiTrendRowWords = {
40
+ head: string;
41
+ detail: string;
42
+ };
43
+ /**
44
+ * The Trend row's words, from the response's trend metadata and its point
45
+ * count: "By week · 14 points" over "Aug 6 – Nov 3 · Automatic"; the history
46
+ * and recent spans in words; a skipped trend with its fix. Undefined when the
47
+ * response has no trend metadata (no date: the Date section says why).
48
+ */
49
+ export declare function describeKpiTrendRow(metadata: KpiTrendMetadata | undefined, points: number, options?: {
50
+ now?: Date;
51
+ }): KpiTrendRowWords | undefined;
@@ -110,6 +110,7 @@ export declare const SHELF_FIELD_KEYS: {
110
110
  readonly semanticComparisonPolarity: "shelf";
111
111
  readonly parameters: "shelf";
112
112
  readonly direction: "shelf";
113
+ readonly grainMode: "shelf";
113
114
  };
114
115
  /** The dialog's draft for a saved variable. */
115
116
  export declare function draftFromVariable(variable: DataVariable): VariableDraft;
@@ -31,6 +31,7 @@ export { pickColumnFormat, resolveColumnFormat, withLiveModelFormats, type Colum
31
31
  export * from './presentation-execution.js';
32
32
  export * from './temporal-bucket-format-policy.js';
33
33
  export * from './temporal-bucket.js';
34
+ export * from './partial-period.js';
34
35
  export * from './raw-temporal.js';
35
36
  export * from './temporal-input-presentation.js';
36
37
  export * from './flat-table-export-totals.js';
@@ -0,0 +1,40 @@
1
+ import { DateWindow, TemporalBucketMetadata } from '../analytics-protocol/contracts.js';
2
+ import { ResolvedTemporalValueFormatPreferences } from '../value-format-preferences/value-format-preferences.js';
3
+ /** How a period covers less than its whole span: still running, cut at its start, or cut at its end. */
4
+ export type DatePeriodPartial = 'running' | 'start' | 'end';
5
+ /**
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.
9
+ */
10
+ export declare function cutDatePeriod(period: {
11
+ start: Date;
12
+ end: Date;
13
+ }, counted: {
14
+ from: Date;
15
+ to?: Date;
16
+ }, now: Date): {
17
+ start: Date;
18
+ end: Date;
19
+ partial?: DatePeriodPartial;
20
+ };
21
+ /**
22
+ * A period's name with how it is partial (KT-D10): "Nov 2026 (so far)",
23
+ * "Week of Aug 3 (from Aug 6)", "(to Nov 3)", or "(partial)" when the cut
24
+ * date can't be named. A whole period keeps its name.
25
+ */
26
+ export declare function partialPeriodLabel(name: string, partial: DatePeriodPartial | undefined, edges?: {
27
+ start: string;
28
+ end: string;
29
+ }): string;
30
+ /**
31
+ * Names where a counted window cuts a period (ledger ED-02), in the calendar
32
+ * the server counted in: for day and coarser grains, the day holding its
33
+ * start or the last day before its end ("8/6/26"); below a day, the time of
34
+ * the cut, in the viewer's time style. Undefined when the window's dates
35
+ * can't be read.
36
+ */
37
+ export declare function partialPeriodEdgeNames(window: DateWindow, metadata: TemporalBucketMetadata, preferences: ResolvedTemporalValueFormatPreferences | undefined): {
38
+ start: string;
39
+ end: string;
40
+ } | undefined;
@@ -89,6 +89,17 @@ export declare function temporalBucketPeriod(value: TemporalBucketValue, metadat
89
89
  endExclusive: string;
90
90
  timezone: string;
91
91
  } | undefined;
92
+ /**
93
+ * The calendar days a bucket covers, first and last inclusive, as
94
+ * `YYYY-MM-DD` on its own calendar (a week from its week start, a fiscal
95
+ * quarter): the whole-day form a date-only range means (chart date zoom
96
+ * DZ-D4). Undefined for a value that isn't canonical, a blank, or a grain
97
+ * finer than a day, which a whole-day range can't follow.
98
+ */
99
+ export declare function temporalBucketDays(value: TemporalBucketValue, metadata: TemporalBucketMetadata): {
100
+ first: string;
101
+ last: string;
102
+ } | undefined;
92
103
  /**
93
104
  * A bucket's grain and governed calendar in words, for a reader that restates
94
105
  * a bucketed condition ("by hour in the America/Chicago calendar; each value
@@ -165,13 +165,13 @@ export declare const queryExecutedDetailsSchema: z.ZodObject<{
165
165
  page?: number | undefined;
166
166
  rows?: number | undefined;
167
167
  dataset?: string | undefined;
168
+ card_type?: string | undefined;
168
169
  trigger?: "sort" | "page" | "refresh" | "drill" | "initial_load" | "input_change" | "click_filter" | undefined;
169
170
  dashboard_title?: string | undefined;
170
171
  project_name?: string | undefined;
171
172
  parent_query_run_id?: string | undefined;
172
173
  query_kind?: "card" | "sql" | "export" | "matrix_window" | "filter_options" | "control_options" | undefined;
173
174
  card_title?: string | undefined;
174
- card_type?: string | undefined;
175
175
  sheet_title?: string | undefined;
176
176
  connection_name?: string | undefined;
177
177
  connection_type?: string | undefined;
@@ -194,13 +194,13 @@ export declare const queryExecutedDetailsSchema: z.ZodObject<{
194
194
  page?: number | undefined;
195
195
  rows?: number | undefined;
196
196
  dataset?: string | undefined;
197
+ card_type?: string | undefined;
197
198
  trigger?: "sort" | "page" | "refresh" | "drill" | "initial_load" | "input_change" | "click_filter" | undefined;
198
199
  dashboard_title?: string | undefined;
199
200
  project_name?: string | undefined;
200
201
  parent_query_run_id?: string | undefined;
201
202
  query_kind?: "card" | "sql" | "export" | "matrix_window" | "filter_options" | "control_options" | undefined;
202
203
  card_title?: string | undefined;
203
- card_type?: string | undefined;
204
204
  sheet_title?: string | undefined;
205
205
  connection_name?: string | undefined;
206
206
  connection_type?: string | undefined;
@@ -1,5 +1,5 @@
1
1
  import { z as e } from "zod";
2
- import { g as h, l as S } from "../chunks/context-BTLBjQNh.js";
2
+ import { g as h, l as S } from "../chunks/context-CVXTFljo.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.586",
8
+ "version": "0.1.588",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,92 +0,0 @@
1
- import { h as D, d as F, r as b, a as f, e as g } from "./resolve-dashboard-input-context-BTTdKXH0.js";
2
- import { d as h } from "./filter-reach-copy-ZERaFKsN.js";
3
- import "./validators-CJ8Jh0E8.js";
4
- import "./matrix-operation-contract-BM5TveR3.js";
5
- import "./analytics-base-schemas-BaIQrEzX.js";
6
- import "zod";
7
- import "./pivot-result-contract-expectations-Bx_BCu-7.js";
8
- import "../value-format-preferences/index.js";
9
- import { A as y } from "./bookmark-state-CL4WEpgB.js";
10
- import "./schema-C9NPiIru.js";
11
- import "./index-CV_Kzou0.js";
12
- import "./context-BTLBjQNh.js";
13
- import { p as C, r as N } from "./stored-dashboard-rDJ8sw6J.js";
14
- import { g as q } from "./saved-dashboard-context-B-rosN4W.js";
15
- function T(n, e) {
16
- var s;
17
- if (e.status === "blocked" || (s = n.sql) != null && s.trim()) return !1;
18
- const i = new Set(
19
- e.mappingDispositions.flatMap(
20
- (t) => t.status === "apply" ? [t.filterValue.filterId] : []
21
- )
22
- );
23
- return e.cardFilterValues.some((t) => {
24
- const a = e.queryFilterDefinitions.find(
25
- (o) => o.id === t.filterId
26
- );
27
- if (!D(t)) return !1;
28
- if (!(i.has(t.filterId) || (a == null ? void 0 : a.kind) === "global-date"))
29
- return !!(a && w(
30
- [a],
31
- e.resolvedPrimaryDateField,
32
- [t]
33
- ));
34
- const l = F(t);
35
- return !!(l && b({
36
- card: n,
37
- filter: l,
38
- filterValue: t,
39
- effectiveFilterValue: t,
40
- temporalBinding: e.resolvedPrimaryDateField
41
- }).status === "eligible");
42
- });
43
- }
44
- function w(n, e, i) {
45
- if (!e) return !1;
46
- const s = e.qualifiedFieldName, t = e.qualifiedEntityName, a = t && e.name ? `${t}.${e.name}` : s;
47
- return n.some((r) => {
48
- if (!(f(r.dataType || "") === "date")) return !1;
49
- const o = h(r, i), d = o.split("."), u = d[d.length - 1] || o, p = d.length > 1 ? d.slice(0, -1).join(".") : void 0, c = r.qualifiedTableName || p, m = c ? `${c}.${u}` : void 0;
50
- return s ? m ? m === a || m.endsWith(`.${s}`) : u === e.name : m ? m === a : u === e.name;
51
- });
52
- }
53
- function P(n, e) {
54
- const i = (a) => {
55
- const r = a.field;
56
- return r ? e.id && r.id === e.id ? !0 : e.qualifiedFieldName && r.qualifiedFieldName ? r.qualifiedFieldName === e.qualifiedFieldName : r.name === e.name : !1;
57
- }, s = (a) => a.conditions.some((r) => {
58
- var l;
59
- return f(((l = r.field) == null ? void 0 : l.dataType) || "") === "date" && i(r);
60
- }) || a.groups.some(s), t = g(n);
61
- return t ? s(t) : !1;
62
- }
63
- function v(n, e) {
64
- var l, o;
65
- const i = (o = (l = n.config) == null ? void 0 : l.groupByColumns) == null ? void 0 : o.find((d) => f(d.dataType || "") === "date"), s = e.resolvedPrimaryDateField, t = i ? { id: i.id, name: i.name, label: i.label || i.name, qualifiedFieldName: i.qualifiedFieldName } : s ? { name: s.name, label: s.name, qualifiedFieldName: s.qualifiedFieldName } : void 0;
66
- if (!t) return { comparisonDate: null, dateWindow: e.status === "ready" ? "none" : "unknown" };
67
- const a = { name: t.name, label: t.label };
68
- if (P(n, t)) return { comparisonDate: a, dateWindow: "applies" };
69
- if (e.status !== "ready") return { comparisonDate: a, dateWindow: "unknown" };
70
- const r = T(n, { status: "ready", ...e.compiledFilters });
71
- return { comparisonDate: a, dateWindow: r ? "applies" : "none" };
72
- }
73
- function z(n) {
74
- const e = C(n.dashboard), i = y(e).find((r) => r.cardId === n.cardId);
75
- if (!i || i.kind === "documentSectionCard") return { comparisonDate: null, dateWindow: "unknown" };
76
- const { runtimeValues: s, transientContexts: t } = N({ dashboard: e, capture: {}, calendar: n.calendar }), a = q({
77
- dashboard: e,
78
- location: i,
79
- runtimeValues: s,
80
- semanticExecutionPayload: n.semanticExecutionPayload,
81
- calendar: n.calendar,
82
- transientContexts: t
83
- });
84
- return v(
85
- i.card,
86
- (a == null ? void 0 : a.status) === "ready" ? { status: "ready", compiledFilters: a.compiledFilters, resolvedPrimaryDateField: a.resolvedPrimaryDateField } : { status: "blocked", resolvedPrimaryDateField: a == null ? void 0 : a.resolvedPrimaryDateField }
87
- );
88
- }
89
- export {
90
- z as a,
91
- v as r
92
- };
@@ -1,92 +0,0 @@
1
- function f(e, r) {
2
- return {
3
- id: r,
4
- field: e.field,
5
- operator: e.operator,
6
- value: e.value,
7
- label: e.label,
8
- temporalBucket: e.temporalBucket,
9
- ...e.rawTemporal ? { rawTemporal: e.rawTemporal } : {}
10
- };
11
- }
12
- function p(e) {
13
- var r;
14
- return JSON.stringify([
15
- ((r = e.field) == null ? void 0 : r.id) ?? "",
16
- e.operator,
17
- e.value ?? null,
18
- e.temporalBucket ?? null,
19
- e.rawTemporal ?? null
20
- ]);
21
- }
22
- function c(e) {
23
- return JSON.stringify(e.map(p).sort());
24
- }
25
- function i(e) {
26
- const r = /* @__PURE__ */ new Map();
27
- for (const t of e)
28
- for (const o of t.tuples) {
29
- const l = o.conditions.filter(
30
- (u) => {
31
- var n;
32
- return (n = u.field) == null ? void 0 : n.id;
33
- }
34
- );
35
- if (l.length === 0) continue;
36
- let a = r.get(t.sourceCardId);
37
- a || (a = /* @__PURE__ */ new Map(), r.set(t.sourceCardId, a));
38
- const s = [...l].sort(
39
- (u, n) => p(u).localeCompare(p(n))
40
- );
41
- a.set(c(s), s);
42
- }
43
- return [...r.entries()].sort(([t], [o]) => t.localeCompare(o)).map(([t, o]) => ({
44
- sourceCardId: t,
45
- tuples: [...o.entries()].sort(([l], [a]) => l.localeCompare(a)).map(([, l]) => ({ conditions: l }))
46
- }));
47
- }
48
- function d(e) {
49
- const r = i(e);
50
- if (r.length !== 0)
51
- return {
52
- id: "selection",
53
- logicalOperator: "AND",
54
- negate: !1,
55
- conditions: [],
56
- groups: r.map((t) => {
57
- const o = `selection:${t.sourceCardId}`;
58
- return {
59
- id: o,
60
- logicalOperator: "OR",
61
- negate: !1,
62
- conditions: [],
63
- groups: t.tuples.map((l, a) => {
64
- const s = `${o}:${a}`;
65
- return {
66
- id: s,
67
- logicalOperator: "AND",
68
- negate: !1,
69
- conditions: l.conditions.map((u, n) => ({
70
- ...u,
71
- id: `${s}:${n}`
72
- })),
73
- groups: []
74
- };
75
- })
76
- };
77
- })
78
- };
79
- }
80
- function m(e) {
81
- return JSON.stringify(
82
- i(e).map((r) => [
83
- r.sourceCardId,
84
- r.tuples.map((t) => t.conditions.map(p))
85
- ])
86
- );
87
- }
88
- export {
89
- d as c,
90
- m as s,
91
- f as t
92
- };