@accurix/centrinfo-widget 5.0.0 → 5.1.0

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.
@@ -1,7 +1,570 @@
1
- import * as preact0 from "preact";
1
+ import * as preact1 from "preact";
2
+ import { JSX } from "preact";
2
3
 
4
+ //#region ../centrinfo-results/src/analytics-chart-catalog.d.ts
5
+ type AnalyticsChartCatalogType = 'kpi' | 'table' | 'line' | 'bar' | 'pie' | 'scatter' | 'effectScatter' | 'map' | 'candlestick' | 'boxplot' | 'graph' | 'lines' | 'tree' | 'treemap' | 'sunburst' | 'parallel' | 'sankey' | 'funnel' | 'heatmap' | 'radar' | 'gauge' | 'pictorialBar' | 'themeRiver' | 'matrix' | 'chord' | 'custom' | 'dataset' | 'dataZoom' | 'graphic' | 'richText' | 'globe' | 'bar3D' | 'scatter3D' | 'surface' | 'map3D' | 'lines3D' | 'line3D' | 'scatterGL' | 'linesGL' | 'flowGL' | 'graphGL' | 'polygons3D';
6
+ //#endregion
7
+ //#region ../centrinfo-results/src/analytics-explanation.d.ts
8
+ /**
9
+ * Framework-agnostic analytics explanation core.
10
+ *
11
+ * Every surface (Liveboard SDK vanilla DOM, the Preact widget and full-page
12
+ * chat app, and the React dashboard) renders an explanation from the SAME
13
+ * display model built here, so wording, order and value-status rules never
14
+ * drift between surfaces. Renderers only map this model onto their own markup
15
+ * and theme tokens.
16
+ *
17
+ * Step-by-step order (fixed):
18
+ * 1. lead plain business answer (headline + summary)
19
+ * 2. comparison each compared period with its value + status chip
20
+ * 3. conclusions what the data supports
21
+ * 4. limits in-progress / unconfirmed zero / missing period / caveats
22
+ * 5. checked "Times in <tz> · Checked <time>"
23
+ * 6. investigate causes, recommendations, outlook, follow-ups (optional
24
+ * disclosure, collapsed by default)
25
+ *
26
+ * Zero is only "confirmed" when the source says so. An empty bucket or an
27
+ * unconfirmed zero reads as "no records yet" and never produces a % change.
28
+ *
29
+ * Pure TypeScript, no DOM or framework imports: safe for every SDK bundle.
30
+ */
31
+ type AnalyticsExplanationValueStatus = 'observed' | 'confirmed_zero' | 'empty_bucket' | 'unconfirmed_zero' | 'missing';
32
+ interface AnalyticsExplanationPeriodRangeInput {
33
+ label: string;
34
+ start?: string;
35
+ end?: string;
36
+ timezone?: string;
37
+ }
38
+ interface AnalyticsExplanationEvidenceItemInput {
39
+ id: string;
40
+ text: string;
41
+ kind?: string;
42
+ metric?: string;
43
+ period?: AnalyticsExplanationPeriodRangeInput;
44
+ filters?: string[];
45
+ value?: number;
46
+ valueStatus?: AnalyticsExplanationValueStatus | string;
47
+ statusReason?: string;
48
+ source?: {
49
+ kind?: 'card' | 'supporting_query' | string;
50
+ insightId?: string;
51
+ queryRunId?: string;
52
+ liveboardTileId?: string;
53
+ };
54
+ checkedAt?: string;
55
+ }
56
+ interface AnalyticsExplanationPeriodInput {
57
+ evidenceId?: string;
58
+ label: string;
59
+ start?: string;
60
+ end?: string;
61
+ timezone?: string;
62
+ current?: boolean;
63
+ inProgress?: boolean;
64
+ value?: number;
65
+ valueText?: string;
66
+ valueStatus?: AnalyticsExplanationValueStatus | string;
67
+ statusReason?: string;
68
+ source?: string;
69
+ }
70
+ interface AnalyticsExplanationMissingInput {
71
+ evidenceId?: string;
72
+ label: string;
73
+ period?: AnalyticsExplanationPeriodRangeInput;
74
+ reason: string;
75
+ }
76
+ interface AnalyticsExplanationFreshnessInput {
77
+ status?: string;
78
+ dataAsOf?: string;
79
+ expectedThrough?: string;
80
+ lagDays?: number;
81
+ checkedAt?: string;
82
+ timezone?: string;
83
+ }
84
+ /** Structural explanation shape every surface's DTO satisfies. */
85
+ interface AnalyticsExplanationInput {
86
+ explanationId?: string;
87
+ conversationalPreface?: string;
88
+ headline?: string;
89
+ summary?: string;
90
+ evidence?: string[];
91
+ headlineEvidenceIds?: string[];
92
+ summaryEvidenceIds?: string[];
93
+ businessMeaningEvidenceIds?: string[];
94
+ evidenceStatements?: Array<{
95
+ text: string;
96
+ evidenceIds?: string[];
97
+ }>;
98
+ evidenceItems?: AnalyticsExplanationEvidenceItemInput[];
99
+ periods?: AnalyticsExplanationPeriodInput[];
100
+ missing?: AnalyticsExplanationMissingInput[];
101
+ timezone?: string;
102
+ checkedAt?: string;
103
+ currentPeriodInProgress?: boolean;
104
+ cached?: boolean;
105
+ dataFreshness?: AnalyticsExplanationFreshnessInput;
106
+ businessMeaning?: string;
107
+ possibleDrivers?: Array<{
108
+ hypothesis: string;
109
+ howToCheck: string;
110
+ evidenceIds?: string[];
111
+ }>;
112
+ recommendations?: Array<{
113
+ action: string;
114
+ why: string;
115
+ successMetric?: string;
116
+ evidenceIds?: string[];
117
+ }>;
118
+ forecast?: {
119
+ text: string;
120
+ qualityStatus?: string;
121
+ limitations?: string;
122
+ horizon?: string;
123
+ };
124
+ limitations?: string[];
125
+ followUps?: string[];
126
+ source?: string;
127
+ /** "basic" = the free explanation built from the facts; "detailed" = checked AI wording. */
128
+ level?: 'basic' | 'detailed' | string;
129
+ /** The detailed AI explanation that loads separately (poll by explanationId). */
130
+ aiExplanation?: AnalyticsAIExplanationInput | null;
131
+ }
132
+ /** State of the detailed AI explanation, as returned by every surface. */
133
+ type AnalyticsAIExplanationStatus = 'pending' | 'ready' | 'failed' | 'not_requested';
134
+ interface AnalyticsAIExplanationInput {
135
+ status: AnalyticsAIExplanationStatus | string;
136
+ explanationId?: string;
137
+ retryAvailable?: boolean;
138
+ }
139
+ declare const ANALYTICS_EXPLANATION_COPY: {
140
+ readonly eyebrow: "Answer from your data";
141
+ readonly provenanceAI: "AI-assisted · evidence checked";
142
+ readonly provenanceGoverned: "Based on current values";
143
+ readonly comparison: "Comparison";
144
+ readonly conclusions: "What we can conclude";
145
+ readonly whyItMatters: "Why it matters";
146
+ readonly limits: "Important limits";
147
+ readonly investigate: "Investigate further";
148
+ readonly evidenceList: "Evidence checked";
149
+ readonly causes: "Possible causes";
150
+ readonly causesHint: "Not proven causes";
151
+ readonly howToCheck: "How to check:";
152
+ readonly recommendations: "Recommended next steps";
153
+ readonly watch: "Watch:";
154
+ readonly outlook: "Outlook";
155
+ readonly followUps: "Ask a follow-up";
156
+ readonly sourceNoteAI: "AI-assisted wording, checked against the live values shown here.";
157
+ readonly sourceNoteGoverned: "Based only on the live values shown here.";
158
+ readonly evidence: "Evidence";
159
+ readonly evidenceMetric: "Metric";
160
+ readonly evidencePeriod: "Period";
161
+ readonly evidenceTimezone: "Timezone";
162
+ readonly evidenceFilters: "Filters";
163
+ readonly evidenceValue: "Value";
164
+ readonly evidenceStatus: "Status";
165
+ readonly evidenceSource: "Source";
166
+ readonly evidenceChecked: "Checked";
167
+ readonly openSource: "Open source";
168
+ readonly closeEvidence: "Close evidence details";
169
+ readonly citationLabel: "Show evidence";
170
+ readonly sourceCard: "This card";
171
+ readonly sourceSupportingQuery: "Supporting query";
172
+ readonly feedbackPrompt: "Was this explanation helpful?";
173
+ readonly feedbackHelpful: "Helpful explanation";
174
+ readonly feedbackNotHelpful: "Unhelpful explanation";
175
+ readonly feedbackReasonsPrompt: "What went wrong? (optional)";
176
+ readonly feedbackCommentPlaceholder: "Anything else? (optional)";
177
+ readonly feedbackSubmit: "Send feedback";
178
+ readonly feedbackThanks: "Thanks for the feedback.";
179
+ readonly feedbackUndo: "Undo";
180
+ readonly feedbackError: "Feedback could not be saved. Try again.";
181
+ readonly notComparable: "Not comparable yet";
182
+ readonly basicExplanation: "Basic explanation";
183
+ readonly preparingDetailed: "Preparing a detailed explanation…";
184
+ readonly detailedReady: "Detailed explanation ready.";
185
+ readonly detailedUnavailable: "A detailed explanation is not available right now.";
186
+ readonly detailedRetry: "Try again";
187
+ readonly region: "Explanation";
188
+ readonly inProgress: "in progress";
189
+ readonly expand: "Expand explanation";
190
+ readonly collapse: "Collapse explanation";
191
+ readonly reasonWrongNumbers: "Wrong numbers";
192
+ readonly reasonMissingComparison: "Missing comparison";
193
+ readonly reasonUnclear: "Unclear";
194
+ readonly reasonTooLong: "Too long";
195
+ };
196
+ /** The explanation panel's copy with a host's overrides on top. */
197
+ type AnalyticsExplanationCopyOverrides = Partial<{ -readonly [K in keyof typeof ANALYTICS_EXPLANATION_COPY]: string }>;
198
+ type AnalyticsComparisonBasis = 'complete' | 'like_for_like' | 'current_in_progress_no_time' | 'not_comparable';
199
+ interface AnalyticsComparisonPeriod {
200
+ label: string;
201
+ start?: string;
202
+ end?: string;
203
+ fullEnd?: string;
204
+ inProgress?: boolean;
205
+ toDate?: boolean;
206
+ }
207
+ /** Backend `periodComparison` (reader-safe projection). */
208
+ interface AnalyticsPeriodComparison {
209
+ comparisonBasis: AnalyticsComparisonBasis | string;
210
+ reason?: string;
211
+ grain?: string;
212
+ measureField?: string;
213
+ seriesField?: string;
214
+ currentPeriod?: AnalyticsComparisonPeriod;
215
+ previousPeriod?: AnalyticsComparisonPeriod;
216
+ currentValue?: number;
217
+ previousToDateValue?: number;
218
+ previousFullValue?: number;
219
+ cutoffAt?: string;
220
+ cutoffSource?: 'now' | 'data_as_of' | string;
221
+ timezone?: string;
222
+ series?: Array<{
223
+ key: string;
224
+ currentValue?: number;
225
+ previousToDateValue?: number;
226
+ previousFullValue?: number;
227
+ }>;
228
+ }
229
+ interface AnalyticsComparisonDisplay {
230
+ basis: AnalyticsComparisonBasis | string;
231
+ kind: 'change' | 'neutral';
232
+ /** Set only for like-for-like (or complete) changes: red/green allowed. */
233
+ percent?: number;
234
+ tone: 'positive' | 'negative' | 'neutral';
235
+ /** Badge text: "↑ 50.0%", "Up from 0", "Today so far: 6 · Yesterday: 26 (full day)". */
236
+ label: string;
237
+ /** "vs yesterday at this time" / "vs same point last week". */
238
+ copy: string;
239
+ /** "Yesterday full day: 26". */
240
+ secondary?: string;
241
+ /** Compact one-line form for KPI cards: "Full day: 26". */
242
+ compactSecondary?: string;
243
+ /** Hover text with the cutoff time. */
244
+ title?: string;
245
+ reason?: string;
246
+ }
247
+ interface AnalyticsGroupComparisonPoint {
248
+ side: 'current' | 'previous';
249
+ basis: string;
250
+ /** Value to plot: previous-to-date on a like-for-like previous bucket. */
251
+ plotValue?: number;
252
+ /** Previous bucket: the full previous value (tooltip). */
253
+ fullValue?: number;
254
+ /** Previous bucket plotted at the same point (label "Yesterday at this time"). */
255
+ toDate: boolean;
256
+ /** Current bucket: this group's change, following the KPI basis rules. */
257
+ display?: AnalyticsComparisonDisplay;
258
+ }
259
+ /**
260
+ * Poll response for a detailed AI explanation. `explanation` is set only when
261
+ * `status` is "ready" and is the CHECKED explanation (never raw model text).
262
+ */
263
+ interface AnalyticsAIExplanationJob<E extends AnalyticsExplanationInput> {
264
+ status: AnalyticsAIExplanationStatus | string;
265
+ explanationId?: string;
266
+ retryAvailable?: boolean;
267
+ explanation?: E | null;
268
+ /**
269
+ * The free basic explanation as updated by the background job (it gains the
270
+ * baseline sentence, e.g. "within the recent range of 22–28"). Present while
271
+ * the AI explanation is pending or after it failed.
272
+ */
273
+ basic?: E | null;
274
+ }
275
+ interface AnalyticsAIExplanationTransport<E extends AnalyticsExplanationInput> {
276
+ /** GET the job by id with the surface's own credentials. */
277
+ poll: (explanationId: string, signal?: AbortSignal) => Promise<AnalyticsAIExplanationJob<E>>;
278
+ /** "Try again": re-request with the retry flag. Omit when retry is impossible. */
279
+ retry?: (explanationId: string, signal?: AbortSignal) => Promise<AnalyticsAIExplanationJob<E>>;
280
+ /** The job reached a final status: let the surface remember it (status only, not the payload). */
281
+ settled?: (explanationId: string, status: 'ready' | 'failed' | 'not_requested') => void;
282
+ }
283
+ //#endregion
284
+ //#region ../centrinfo-results/src/labels.d.ts
285
+ type AnalyticsExplanationCopy = Required<AnalyticsExplanationCopyOverrides>;
286
+ /** Every string the shared result renderer shows. Hosts override any subset. */
287
+ interface ResultLabels {
288
+ resultDetails: string;
289
+ liveMetric: string;
290
+ currentValue: string;
291
+ noMatchTitle: string;
292
+ noMatchBody: string;
293
+ chartType: string;
294
+ chooseChartType: string;
295
+ aggregate: string;
296
+ aggregateTitle: string;
297
+ aggregateCharge: string;
298
+ chartFallback: string;
299
+ chartLine: string;
300
+ chartBar: string;
301
+ chartStackedBar: string;
302
+ chartLineHint: string;
303
+ chartBarHint: string;
304
+ chartStackedBarHint: string;
305
+ aggregationSum: string;
306
+ aggregationAvg: string;
307
+ aggregationMin: string;
308
+ aggregationMax: string;
309
+ aggregationCount: string;
310
+ aggregationCountDistinct: string;
311
+ download: string;
312
+ downloadData: string;
313
+ expandTable: string;
314
+ expandChart: string;
315
+ restoreView: string;
316
+ aboutResult: string;
317
+ aboutPeriod: string;
318
+ aboutResults: string;
319
+ aboutChecked: string;
320
+ aboutTimezone: string;
321
+ aboutSourceData: string;
322
+ aboutFilters: string;
323
+ /** `{count}` placeholder. */
324
+ rowOne: string;
325
+ rowMany: string;
326
+ filtersOne: string;
327
+ filtersMany: string;
328
+ filtersApplied: string;
329
+ notSet: string;
330
+ noValue: string;
331
+ yes: string;
332
+ no: string;
333
+ chartValues: string;
334
+ /** `{measure}`, `{dimension}`. */
335
+ chartTitle: string;
336
+ seriesLimited: string;
337
+ summaryLatest: string;
338
+ summaryNoTrend: string;
339
+ summaryHighest: string;
340
+ summaryNoComparison: string;
341
+ zoomControls: string;
342
+ zoomIn: string;
343
+ zoomOut: string;
344
+ zoomReset: string;
345
+ zoomResetShort: string;
346
+ zoomNone: string;
347
+ zoomAllOne: string;
348
+ zoomAllMany: string;
349
+ zoomRange: string;
350
+ inProgress: string;
351
+ newContent: string;
352
+ updatedAt: string;
353
+ liveData: string;
354
+ viewData: string;
355
+ hideData: string;
356
+ inProgressLegend: string;
357
+ /** Overrides for the explanation panel copy. */
358
+ explanation?: Partial<AnalyticsExplanationCopy>;
359
+ governedResult: string;
360
+ }
361
+ //#endregion
362
+ //#region ../centrinfo-results/src/format.d.ts
363
+ /**
364
+ * The one place numbers, currency, percentages and dates are formatted, so the
365
+ * chart axis, tooltip, table and KPI show the same value the same way.
366
+ *
367
+ * Rules:
368
+ * - Currency comes from column metadata (`currencyCode`) or the result's fixed
369
+ * currency. With no known code the amount is shown as a plain number.
370
+ * - A `percent` column is read as percentage points (0.5 is "0.5%") unless its
371
+ * `formatPattern` contains `%` (Excel style), which marks a fraction (0.5 is
372
+ * "50%"). Magnitude is never used to guess.
373
+ * - Date-only values (`2024-03-05`) are calendar dates: they are formatted in
374
+ * UTC so they never shift a day. Instants are formatted in the result
375
+ * timezone. Granularity follows column metadata, the result's comparison
376
+ * grain, or the shape of the values — a daily series is never "Mar 2024".
377
+ */
378
+ type ResultGrain = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
379
+ interface ResultFormatContext {
380
+ locale?: string;
381
+ /** IANA zone of the result; used for instants, never for date-only values. */
382
+ timezone?: string;
383
+ grain?: ResultGrain;
384
+ /** Result-level fixed currency, used when the column has none. */
385
+ currencyCode?: string;
386
+ yes?: string;
387
+ no?: string;
388
+ }
389
+ //#endregion
390
+ //#region ../centrinfo-results/src/types.d.ts
391
+ interface AnalyticsVisualizationColumn$1 {
392
+ key: string;
393
+ label: string;
394
+ dataType: 'text' | 'number' | 'currency' | 'percent' | 'boolean' | 'date' | 'datetime';
395
+ semanticRole: 'identifier' | 'dimension' | 'measure' | 'date' | 'geography' | 'boolean';
396
+ aggregation?: 'none' | 'sum' | 'avg' | 'count' | 'count_distinct' | 'min' | 'max';
397
+ allowedAggregations?: Array<'none' | 'sum' | 'avg' | 'count' | 'count_distinct' | 'min' | 'max'>;
398
+ formatPattern?: string;
399
+ currencyCode?: string;
400
+ /** Time granularity of a date column; drives how its values are labelled. */
401
+ grain?: ResultGrain;
402
+ description?: string;
403
+ priority?: 'primary' | 'secondary' | 'detail';
404
+ sortable?: boolean;
405
+ filterable?: boolean;
406
+ groupable?: boolean;
407
+ }
408
+ interface AnalyticsVisualizationRecommendation$1 {
409
+ type: AnalyticsChartCatalogType | 'area' | 'stacked_bar';
410
+ mode: string;
411
+ categoryField?: string;
412
+ latitudeField?: string;
413
+ longitudeField?: string;
414
+ geometryField?: string;
415
+ valueFields?: string[];
416
+ seriesField?: string;
417
+ reason?: string;
418
+ confidence?: number;
419
+ }
420
+ interface AnalyticsVisualization$1 {
421
+ /** The latest time bucket is still in progress (drawn dashed). */
422
+ lastPeriodInProgress?: boolean;
423
+ /** Like-for-like comparison basis (reader-safe). */
424
+ periodComparison?: AnalyticsPeriodComparison;
425
+ version?: number;
426
+ presentation?: 'kpi' | 'chart' | 'table';
427
+ type: AnalyticsChartCatalogType | 'area' | 'stacked_bar';
428
+ title?: string;
429
+ label?: string;
430
+ value?: string;
431
+ latitudeField?: string;
432
+ longitudeField?: string;
433
+ geometryField?: string;
434
+ valueFields?: string[];
435
+ series?: string;
436
+ seriesField?: string;
437
+ columns?: string[];
438
+ rows?: Array<Record<string, unknown>>;
439
+ rowCount?: number;
440
+ timezone?: string;
441
+ freshness?: {
442
+ status?: string;
443
+ answeredAt?: string;
444
+ };
445
+ reportingPeriod?: {
446
+ label?: string;
447
+ start?: string;
448
+ end?: string;
449
+ timezone?: string;
450
+ };
451
+ appliedFilters?: Array<{
452
+ field: string;
453
+ operator: string;
454
+ value: unknown;
455
+ }>;
456
+ explanation?: {
457
+ checkedAt?: string;
458
+ timezone?: string;
459
+ dataFreshness?: {
460
+ status?: string;
461
+ };
462
+ };
463
+ expandable?: boolean;
464
+ tableAvailable?: boolean;
465
+ downloadAvailable?: boolean;
466
+ columnMetadata?: AnalyticsVisualizationColumn$1[];
467
+ currency?: {
468
+ code?: string;
469
+ field?: string;
470
+ source?: 'fixed_metadata' | 'source_field';
471
+ isMixed: boolean;
472
+ };
473
+ chartRecommendation?: AnalyticsVisualizationRecommendation$1;
474
+ }
475
+ interface ResultColumn {
476
+ key: string;
477
+ label?: string;
478
+ dataType?: AnalyticsVisualizationColumn$1['dataType'];
479
+ currencyCode?: string;
480
+ formatPattern?: string;
481
+ grain?: ResultGrain;
482
+ }
483
+ interface ResultTableClassNames {
484
+ wrap?: string;
485
+ table?: string;
486
+ note?: string;
487
+ }
488
+ //#endregion
489
+ //#region ../centrinfo-results/src/chart.d.ts
490
+ type WidgetAnalyticsSeries = {
491
+ field: string;
492
+ name: string;
493
+ values: Array<number | null>;
494
+ valueColumn?: AnalyticsVisualizationColumn$1;
495
+ /** Like-for-like breakdown: per-point comparison (tooltip detail). */
496
+ points?: Array<AnalyticsGroupComparisonPoint | undefined>;
497
+ };
498
+ type WidgetAnalyticsChartType = 'line' | 'bar' | 'stacked_bar';
499
+ type WidgetAnalyticsChartModel = {
500
+ type: WidgetAnalyticsChartType;
501
+ title: string;
502
+ xAxisTitle: string;
503
+ yAxisTitle: string;
504
+ categories: string[];
505
+ series: WidgetAnalyticsSeries[];
506
+ summary: string;
507
+ omittedSeriesCount: number;
508
+ /** Index of the in-progress (latest) time bucket, drawn dashed / faded. */
509
+ inProgressIndex?: number;
510
+ /** Like-for-like breakdown: the comparison drawn (previous-to-date bars). */
511
+ comparison?: AnalyticsPeriodComparison;
512
+ /** "Today so far, compared with yesterday at this time". */
513
+ comparisonNote?: string;
514
+ locale?: string;
515
+ /** Resolved copy used by the chart's tooltips, summary and zoom controls. */
516
+ labels: ResultLabels;
517
+ };
518
+ type WidgetAnalyticsChartOptions = {
519
+ locale?: string;
520
+ labels?: Partial<ResultLabels>;
521
+ };
522
+ declare const buildWidgetAnalyticsChartModel: (visualization: AnalyticsVisualization$1, overrideType?: WidgetAnalyticsChartType, options?: WidgetAnalyticsChartOptions) => WidgetAnalyticsChartModel | null;
523
+ declare const WidgetAnalyticsChart: ({
524
+ model,
525
+ expanded,
526
+ classPrefix: p
527
+ }: {
528
+ model: WidgetAnalyticsChartModel;
529
+ expanded?: boolean;
530
+ /** Class prefix of the surface (`cf` widget, `ca` chat app). */
531
+ classPrefix?: string;
532
+ }) => preact1.JSX.Element;
533
+ //#endregion
534
+ //#region ../centrinfo-results/src/result.d.ts
535
+ declare const formatResultCell: (value: unknown, locale?: string, column?: ResultColumn, context?: ResultFormatContext) => string;
536
+ declare const serializeResultCsv: (rows: Array<Record<string, unknown>>, columns?: Array<string | ResultColumn>) => string;
537
+ //#endregion
538
+ //#region ../centrinfo-results/src/table.d.ts
539
+ interface ResultTableProps {
540
+ rows: Array<Record<string, unknown>>;
541
+ columns?: Array<string | ResultColumn>;
542
+ maxRows?: number;
543
+ locale?: string;
544
+ /** Timezone / grain / currency context so cells format like the chart. */
545
+ format?: ResultFormatContext;
546
+ expanded?: boolean;
547
+ classNames?: ResultTableClassNames;
548
+ emptyLabel?: string;
549
+ }
550
+ declare const ResultTable: ({
551
+ rows,
552
+ columns,
553
+ maxRows,
554
+ locale,
555
+ format,
556
+ expanded,
557
+ classNames,
558
+ emptyLabel
559
+ }: ResultTableProps) => preact1.JSX.Element;
560
+ //#endregion
561
+ //#region ../centrinfo-results/src/result-details.d.ts
562
+ interface AnalyticsResultDetail {
563
+ label: string;
564
+ value: string;
565
+ }
566
+ //#endregion
3
567
  //#region src/i18n.d.ts
4
-
5
568
  /**
6
569
  * Every user-visible chrome string in one place. The widget ships English
7
570
  * defaults; a host localises by passing `labels` to `Centrinfo.init()` —
@@ -11,6 +574,12 @@ import * as preact0 from "preact";
11
574
  * never produces.
12
575
  */
13
576
  interface WidgetStrings {
577
+ /**
578
+ * Labels for analytics answers (KPI, chart, table, details, explanation).
579
+ * Any subset overrides the English defaults; `explanation` holds the
580
+ * explanation panel's wording.
581
+ */
582
+ analytics?: Partial<ResultLabels>;
14
583
  /** Optional full-page labels. Older integrations use the core labels as fallbacks. */
15
584
  fullPageNewConversation?: string;
16
585
  fullPageHistory?: string;
@@ -101,6 +670,7 @@ interface WidgetStrings {
101
670
  /** Per-message 👍/👎 feedback. */
102
671
  feedbackHelpful: string;
103
672
  feedbackNotHelpful: string;
673
+ feedbackAnswerPrompt: string;
104
674
  feedbackThanks: string;
105
675
  /** End-of-chat CSAT prompt. */
106
676
  csatPrompt: string;
@@ -116,6 +686,8 @@ interface WidgetStrings {
116
686
  emptyReply: string;
117
687
  errorGeneric: string;
118
688
  errorRateLimit: string;
689
+ /** Shown in place of an analytics result that is not kept in local storage. */
690
+ resultExpired: string;
119
691
  attaching: string;
120
692
  attachTooLarge: string;
121
693
  attachFailed: string;
@@ -206,7 +778,7 @@ interface WidgetStrings {
206
778
  previewActionNote: string;
207
779
  previewBanner: string;
208
780
  }
209
- declare const StringsProvider: preact0.Provider<WidgetStrings>;
781
+ declare const StringsProvider: preact1.Provider<WidgetStrings>;
210
782
  //#endregion
211
783
  //#region src/api/types.d.ts
212
784
  /** The result metadata that arrives with (or after) an answer. */
@@ -296,6 +868,7 @@ interface AnalyticsVisualizationColumn {
296
868
  dataType: 'text' | 'number' | 'currency' | 'percent' | 'boolean' | 'date' | 'datetime';
297
869
  semanticRole: 'identifier' | 'dimension' | 'measure' | 'date' | 'geography' | 'boolean';
298
870
  aggregation?: 'none' | 'sum' | 'avg' | 'count' | 'count_distinct' | 'min' | 'max';
871
+ allowedAggregations?: Array<'none' | 'sum' | 'avg' | 'count' | 'count_distinct' | 'min' | 'max'>;
299
872
  formatPattern?: string;
300
873
  currencyCode?: string;
301
874
  description?: string;
@@ -313,21 +886,101 @@ interface AnalyticsVisualizationRecommendation {
313
886
  reason?: string;
314
887
  confidence?: number;
315
888
  }
889
+ type AnalyticsValueStatus = 'observed' | 'confirmed_zero' | 'empty_bucket' | 'unconfirmed_zero' | 'missing';
890
+ interface AnalyticsEvidencePeriod {
891
+ label: string;
892
+ start?: string;
893
+ end?: string;
894
+ timezone?: string;
895
+ }
896
+ interface AnalyticsExplanationEvidenceItem {
897
+ id: string;
898
+ text: string;
899
+ kind?: string;
900
+ metric?: string;
901
+ period?: AnalyticsEvidencePeriod;
902
+ filters?: string[];
903
+ value?: number;
904
+ valueStatus: AnalyticsValueStatus | string;
905
+ statusReason?: string;
906
+ source: {
907
+ kind: 'card' | 'supporting_query' | string;
908
+ insightId?: string;
909
+ queryRunId?: string;
910
+ liveboardTileId?: string;
911
+ };
912
+ checkedAt?: string;
913
+ }
914
+ interface AnalyticsExplanationPeriod {
915
+ evidenceId?: string;
916
+ label: string;
917
+ start?: string;
918
+ end?: string;
919
+ timezone?: string;
920
+ current?: boolean;
921
+ inProgress?: boolean;
922
+ value?: number;
923
+ valueText?: string;
924
+ valueStatus: AnalyticsValueStatus | string;
925
+ statusReason?: string;
926
+ source?: 'card' | 'supporting_query' | string;
927
+ }
928
+ interface AnalyticsExplanationMissing {
929
+ evidenceId?: string;
930
+ label: string;
931
+ period?: AnalyticsEvidencePeriod;
932
+ reason: string;
933
+ }
934
+ interface AnalyticsExplanationDataFreshness {
935
+ status: string;
936
+ dataAsOf?: string;
937
+ expectedThrough?: string;
938
+ lagDays?: number;
939
+ checkedAt?: string;
940
+ timezone?: string;
941
+ }
942
+ interface AnalyticsValueProvenance {
943
+ rowIndex: number;
944
+ field: string;
945
+ period?: string;
946
+ filled: 'empty_bucket' | string;
947
+ status: 'empty_bucket' | 'confirmed_zero' | 'unconfirmed_zero' | string;
948
+ reason?: string;
949
+ }
316
950
  interface AnalyticsVisualizationExplanation {
951
+ /** Stable opaque id; used only for "Was this helpful?" feedback. */
952
+ explanationId?: string;
317
953
  conversationalPreface?: string;
318
954
  metricReference?: string;
319
955
  headline: string;
320
956
  summary: string;
321
957
  evidence?: string[];
958
+ headlineEvidenceIds?: string[];
959
+ summaryEvidenceIds?: string[];
960
+ businessMeaningEvidenceIds?: string[];
961
+ evidenceStatements?: Array<{
962
+ text: string;
963
+ evidenceIds?: string[];
964
+ }>;
965
+ evidenceItems?: AnalyticsExplanationEvidenceItem[];
966
+ periods?: AnalyticsExplanationPeriod[];
967
+ missing?: AnalyticsExplanationMissing[];
968
+ timezone?: string;
969
+ checkedAt?: string;
970
+ currentPeriodInProgress?: boolean;
971
+ cached?: boolean;
972
+ dataFreshness?: AnalyticsExplanationDataFreshness;
322
973
  businessMeaning?: string;
323
974
  possibleDrivers?: Array<{
324
975
  hypothesis: string;
325
976
  howToCheck: string;
977
+ evidenceIds?: string[];
326
978
  }>;
327
979
  recommendations?: Array<{
328
980
  action: string;
329
981
  why: string;
330
982
  successMetric?: string;
983
+ evidenceIds?: string[];
331
984
  }>;
332
985
  forecast?: {
333
986
  text: string;
@@ -338,6 +991,12 @@ interface AnalyticsVisualizationExplanation {
338
991
  limitations?: string[];
339
992
  followUps?: string[];
340
993
  source: 'governed_result' | 'ai_grounded' | 'rag_deterministic_analysis' | 'analysis_contract' | string;
994
+ /** The detailed AI explanation that loads separately (poll by explanationId). */
995
+ aiExplanation?: {
996
+ status: string;
997
+ explanationId?: string;
998
+ retryAvailable?: boolean;
999
+ } | null;
341
1000
  }
342
1001
  interface AnalyticsVisualizationAnalysis {
343
1002
  summary: string;
@@ -467,6 +1126,7 @@ interface AnalyticsVisualization {
467
1126
  tableAvailable?: boolean;
468
1127
  downloadAvailable?: boolean;
469
1128
  explanation?: AnalyticsVisualizationExplanation;
1129
+ valueProvenance?: AnalyticsValueProvenance[];
470
1130
  }
471
1131
  interface SpeechResult {
472
1132
  providerReady: boolean;
@@ -587,6 +1247,31 @@ interface FeedbackInput {
587
1247
  question?: string;
588
1248
  answer?: string;
589
1249
  }
1250
+ /** "Was this helpful?" vote on one analytics explanation
1251
+ * (POST /public-chat/explanation-feedback). One vote per visitor session per
1252
+ * explanation; `clear` removes it. Never billed. */
1253
+ interface ExplanationFeedbackInput {
1254
+ sessionId: string;
1255
+ explanationId: string;
1256
+ rating: 'up' | 'down' | 'clear';
1257
+ reasons?: Array<'wrong_numbers' | 'missing_comparison' | 'unclear' | 'too_long'>;
1258
+ comment?: string;
1259
+ modelId?: string;
1260
+ modelVersion?: number;
1261
+ /** Which public surface showed the explanation. */
1262
+ surface?: 'widget' | 'chat_app';
1263
+ }
1264
+ /** Detailed AI explanation job for an analytics answer
1265
+ * (GET /public-chat/analytics-explanations/:id). `explanation` is set only
1266
+ * when ready and is the checked, public-safe explanation. */
1267
+ interface ExplanationJob {
1268
+ status: 'pending' | 'ready' | 'failed' | 'not_requested' | string;
1269
+ explanationId?: string;
1270
+ retryAvailable?: boolean;
1271
+ explanation?: Record<string, unknown> | null;
1272
+ /** The free basic explanation as updated by the job (gains the baseline sentence). */
1273
+ basic?: Record<string, unknown> | null;
1274
+ }
590
1275
  /** A [start, end) window the org's calendar is busy. */
591
1276
  interface BusyRange {
592
1277
  start: string;
@@ -664,6 +1349,13 @@ interface Transport {
664
1349
  /** Record a 👍/👎 on an assistant reply (`POST /public-chat/feedback`).
665
1350
  * Best-effort — a failed rating never disrupts the chat. */
666
1351
  sendFeedback(input: FeedbackInput): Promise<void>;
1352
+ /** Record a vote on an analytics explanation. Rejects on failure so the UI
1353
+ * can offer a retry (unlike `sendFeedback`). Optional for custom transports. */
1354
+ sendExplanationFeedback?(input: ExplanationFeedbackInput): Promise<void>;
1355
+ /** Poll the detailed AI explanation of an analytics answer. Optional. */
1356
+ fetchExplanation?(explanationId: string, sessionId: string, surface?: 'widget' | 'chat_app', signal?: AbortSignal): Promise<ExplanationJob>;
1357
+ /** "Try again" on a failed detailed AI explanation. Optional. */
1358
+ retryExplanation?(explanationId: string, sessionId: string, surface?: 'widget' | 'chat_app'): Promise<ExplanationJob>;
667
1359
  }
668
1360
  //#endregion
669
1361
  //#region src/types.d.ts
@@ -736,6 +1428,11 @@ interface WidgetConfig {
736
1428
  labels?: Partial<WidgetStrings>;
737
1429
  /** Locale used to select a translation bundle. Defaults to browser locale. */
738
1430
  locale?: string;
1431
+ /**
1432
+ * Text direction. `auto` (default) follows the locale: Arabic, Hebrew,
1433
+ * Persian, Urdu and similar scripts render right-to-left.
1434
+ */
1435
+ dir?: 'ltr' | 'rtl' | 'auto';
739
1436
  /**
740
1437
  * Translation data keyed by locale (`fr`, `fr-CA`, `yo`, ...). Exact locale
741
1438
  * wins, then its base language. Explicit `labels` still wins over the pack.
@@ -835,6 +1532,14 @@ interface WidgetConfig {
835
1532
  role: 'user' | 'assistant';
836
1533
  content: string;
837
1534
  }) => void;
1535
+ /** Called only for a server-cited source in a signed analytics answer.
1536
+ * The host should open it through its authorized analytics client. */
1537
+ onOpenAnalyticsSource?: (source: {
1538
+ kind: 'liveboard_tile' | 'insight';
1539
+ id: string;
1540
+ /** Result filters for a host to validate against the destination board. */
1541
+ appliedFilters?: AnalyticsVisualization['appliedFilters'];
1542
+ }) => void;
838
1543
  onAction?: (action: string) => void;
839
1544
  onHandoff?: () => void;
840
1545
  }
@@ -998,6 +1703,10 @@ interface ChatMessage {
998
1703
  feedback?: 'up' | 'down';
999
1704
  visualization?: AnalyticsVisualization;
1000
1705
  artifacts?: ChatArtifact[];
1706
+ /** Set on a restored message whose analytics result was not kept in local storage. */
1707
+ resultExpired?: {
1708
+ title?: string;
1709
+ };
1001
1710
  }
1002
1711
  interface Source {
1003
1712
  title?: string;
@@ -1086,4 +1795,4 @@ interface SchedulerInfo {
1086
1795
  };
1087
1796
  }
1088
1797
  //#endregion
1089
- export { WidgetStrings as C, StringsProvider as S, DemoSlotsResult as _, MessageAttachment as a, PublicChatActionField as b, Visitor as c, WidgetHandle as d, WidgetThemeTokens as f, DemoBooking as g, AnalyticsVisualization as h, FeaturedLink as i, WidgetActionTranslation as l, ActionResult as m, ChatArtifact as n, SchedulerInfo as o, WidgetUser as p, ChatMessage as r, Source as s, BootstrapInfo as t, WidgetConfig as u, GifResult as v, Transport as x, PublicChatAction as y };
1798
+ export { buildWidgetAnalyticsChartModel as A, StringsProvider as C, formatResultCell as D, ResultTable as E, AnalyticsAIExplanationTransport as M, AnalyticsExplanationInput as N, serializeResultCsv as O, Transport as S, AnalyticsResultDetail as T, DemoSlotsResult as _, MessageAttachment as a, PublicChatAction as b, Visitor as c, WidgetHandle as d, WidgetThemeTokens as f, DemoBooking as g, AnalyticsVisualization as h, FeaturedLink as i, ResultLabels as j, WidgetAnalyticsChart as k, WidgetActionTranslation as l, ActionResult as m, ChatArtifact as n, SchedulerInfo as o, WidgetUser as p, ChatMessage as r, Source as s, BootstrapInfo as t, WidgetConfig as u, ExplanationFeedbackInput as v, WidgetStrings as w, PublicChatActionField as x, GifResult as y };