react-autoql 8.36.2 → 8.37.1

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.
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react'
2
- import type { Authentication } from 'autoql-fe-utils'
2
+ import type { Authentication, PushMessageData } from 'autoql-fe-utils'
3
3
 
4
4
  export * from 'autoql-fe-utils'
5
5
 
@@ -204,6 +204,25 @@ export interface DashboardTile {
204
204
  [key: string]: any
205
205
  }
206
206
 
207
+ export interface ValueActionContext {
208
+ column: {
209
+ name: string
210
+ display_name?: string
211
+ type?: string
212
+ precision?: string
213
+ dow_style?: string
214
+ }
215
+ formattedValue: string
216
+ queryId?: string
217
+ queryText?: string
218
+ event: MouseEvent
219
+ }
220
+
221
+ export type ValueActionCallback = (value: any, row: Record<string, any>, context: ValueActionContext) => void
222
+
223
+ // A plain function, or an object that also sets the link's tooltip (default "Open")
224
+ export type ValueActionCallbackEntry = ValueActionCallback | { onClick: ValueActionCallback; tooltip?: string }
225
+
207
226
  export interface DashboardProps {
208
227
  authentication?: Authentication
209
228
  autoQLConfig?: AutoQLConfig
@@ -217,6 +236,9 @@ export interface DashboardProps {
217
236
  notExecutedText?: string | React.ReactElement
218
237
  onChange?: (tiles: DashboardTile[], slicers?: any[]) => void
219
238
  onErrorCallback?: (error: any) => void
239
+ // Called when the value is clicked in a cell of a column whose value_action is
240
+ // { type: 'callback', callback_name }. Keyed by callback_name; the row is keyed by column name.
241
+ valueActionCallbacks?: Record<string, ValueActionCallbackEntry>
220
242
  onSuccessCallback?: (response: any) => void
221
243
  autoChartAggregations?: boolean
222
244
  enableDynamicCharting?: boolean
@@ -256,7 +278,26 @@ export interface DashboardProps {
256
278
  [key: string]: any
257
279
  }
258
280
 
259
- export declare class Dashboard extends React.Component<DashboardProps> {}
281
+ export declare class Dashboard extends React.Component<DashboardProps> {
282
+ // What the chosen tiles show now, for a report: each tile captured as "Add to Report…" captures it
283
+ // (QueryOutput.captureForReport). Without tileKeys, every tile in reading order.
284
+ captureTilesForReport(options?: {
285
+ tileKeys?: Array<string | number>
286
+ maxTableRows?: number
287
+ maxChartRows?: number
288
+ }): DashboardTileCapture[]
289
+ }
290
+
291
+ // One tile's capture from Dashboard.captureTilesForReport. `result` is { ok: false, reason: 'loading' }
292
+ // while the tile has no finished answer on screen, and 'not-found' for a key the dashboard has no tile for.
293
+ export interface DashboardTileCapture {
294
+ tileKey: string | number
295
+ dashboardId?: string
296
+ title: string
297
+ query: string
298
+ displayType?: string
299
+ result: ReportCaptureResult | { ok: false; reason: 'loading' | 'not-found' }
300
+ }
260
301
 
261
302
  // ─── DataMessenger ───────────────────────────────────────────────────────────
262
303
 
@@ -308,6 +349,9 @@ export interface DataMessengerProps {
308
349
  onNotificationCount?: (count: number) => void
309
350
  onVisibleChange?: (visible: boolean) => void
310
351
  onErrorCallback?: (error: any) => void
352
+ // Called when the value is clicked in a cell of a column whose value_action is
353
+ // { type: 'callback', callback_name }. Keyed by callback_name; the row is keyed by column name.
354
+ valueActionCallbacks?: Record<string, ValueActionCallbackEntry>
311
355
  onSuccessAlert?: (message: string) => void
312
356
  onProjectSelectChange?: (projectId: string) => void
313
357
  source?: string | string[]
@@ -362,10 +406,15 @@ export interface QueryOutputProps {
362
406
  onDrilldownStart?: (params: any) => void
363
407
  onDrilldownEnd?: () => void
364
408
  onErrorCallback?: (error: any) => void
409
+ // Called when the value is clicked in a cell of a column whose value_action is
410
+ // { type: 'callback', callback_name }. Keyed by callback_name; the row is keyed by column name.
411
+ valueActionCallbacks?: Record<string, ValueActionCallbackEntry>
365
412
  [key: string]: any
366
413
  }
367
414
 
368
415
  export declare class QueryOutput extends React.Component<QueryOutputProps> {
416
+ // What the answer shows now, as plain JSON, for a report to keep (a report's Data block `capture`).
417
+ captureForReport(options?: { maxTableRows?: number; maxChartRows?: number }): ReportCaptureResult
369
418
  changeDisplayType(displayType: string): void
370
419
  getCurrentSupportedDisplayTypes(): string[]
371
420
  readonly state: { displayType: string; [key: string]: any }
@@ -411,6 +460,601 @@ export interface DataExplorerProps {
411
460
 
412
461
  export declare class DataExplorer extends React.Component<DataExplorerProps> {}
413
462
 
463
+ // ─── ReportBuilder ───────────────────────────────────────────────────────────
464
+
465
+ // A report is a template: plain, versioned JSON that says what to show, never the data itself. The
466
+ // builder keeps blocks and fields it doesn't know (from a newer version) through a save.
467
+ //
468
+ // ReportBuilder and Reports fetch their code (a file of its own beside the package's main one) the first time one
469
+ // is shown, saying they're loading meanwhile; a ref to either is null until then.
470
+
471
+ export type ReportBlockWidth = 'full' | 'half'
472
+ export type ReportHeadingLevel = 1 | 2 | 3
473
+ export type ReportTableRows = 10 | 25 | 50 | 100
474
+ export type ReportTypeface = 'theme' | 'archivo' | 'newsreader' | 'plex-mono'
475
+
476
+ export interface ReportTextStyle {
477
+ font?: Exclude<ReportTypeface, 'theme'>
478
+ size?: 'small' | 'normal' | 'large' | 'xlarge' | 'huge'
479
+ weight?: 'regular' | 'medium' | 'semibold' | 'bold'
480
+ color?: string
481
+ background?: string
482
+ align?: 'center' | 'right'
483
+ }
484
+
485
+ export interface ReportHeadingBlock {
486
+ id: string
487
+ type: 'heading'
488
+ text: string
489
+ level: ReportHeadingLevel
490
+ width?: ReportBlockWidth
491
+ style?: ReportTextStyle
492
+ }
493
+
494
+ export interface ReportTextBlock {
495
+ id: string
496
+ type: 'text'
497
+ // Markdown: **bold**, *italic*, ++underline++, ~~strikethrough~~, [links](https://…), lists and ### headings.
498
+ // A single line break is a line break, so plain text reads as typed.
499
+ text: string
500
+ width?: ReportBlockWidth
501
+ style?: ReportTextStyle
502
+ }
503
+
504
+ export interface ReportTileSource {
505
+ type: 'tile'
506
+ dashboardId: string
507
+ tileKey: string
508
+ // Labels for when the tile can't be found; never executed.
509
+ snapshot?: { dashboardName?: string; tileTitle?: string; query?: string; displayType?: string }
510
+ }
511
+
512
+ export interface ReportQuestionSource {
513
+ type: 'query'
514
+ query: string
515
+ }
516
+
517
+ // What an answer showed when it was added to a report ("Add to Report…"): its data and the settings that
518
+ // shaped it, shaped like a dashboard tile's saved view. Made by QueryOutput.captureForReport.
519
+ export interface ReportCapture {
520
+ version: number
521
+ capturedAt: string
522
+ displayType: string
523
+ data: {
524
+ columns: Array<Record<string, any>>
525
+ rows: any[][]
526
+ count_rows: number
527
+ text?: string
528
+ query_id?: string
529
+ interpretation?: string
530
+ parsed_interpretation?: any
531
+ }
532
+ // Tables only: the columns shown, in display order (indices into `columns`), the sort shown, and the
533
+ // header filters as typed (optional: older captures have none).
534
+ table?: {
535
+ columnIndices?: number[]
536
+ sort: Array<{ name: string; sort: string }>
537
+ filters?: Array<{ name: string; value: string }>
538
+ filtered: boolean
539
+ }
540
+ config: Record<string, any>
541
+ }
542
+
543
+ export type ReportCaptureResult =
544
+ | { ok: true; capture: ReportCapture }
545
+ | { ok: false; reason: 'no-data' | 'unsupported' | 'too-large'; rowCount?: number }
546
+
547
+ export interface ReportDataBlock {
548
+ id: string
549
+ type: 'data'
550
+ source: ReportTileSource | ReportQuestionSource | null
551
+ // Table rows to print; a chart shows its tile as the dashboard does.
552
+ rows: ReportTableRows
553
+ width?: ReportBlockWidth
554
+ // What the block shows until a run replaces it (always, while enableRunReport is off).
555
+ capture?: ReportCapture
556
+ // How it's shown, when not as captured: 'table' or a chart type its data supports ('bar', 'line', …).
557
+ // Chosen in the properties panel; a choice the data can't be drawn as is ignored.
558
+ displayType?: string
559
+ // A question asked in the builder (enableDataBlocks), which its Rerun button can ask again.
560
+ askedHere?: boolean
561
+ // Its chart's axes and aggregation, when chosen in the builder with the chart's own axis selectors: what
562
+ // QueryOutput reports (onTableConfigChange, onAggConfigChange). Kept across Rerun; set right when drawn if the
563
+ // data no longer fits.
564
+ dataConfig?: {
565
+ tableConfig?: Record<string, unknown>
566
+ pivotTableConfig?: Record<string, unknown>
567
+ columnOverrides?: Record<string, unknown>
568
+ }
569
+ aggConfig?: Record<string, string>
570
+ }
571
+
572
+ export interface ReportPageBreakBlock {
573
+ id: string
574
+ type: 'pagebreak'
575
+ }
576
+
577
+ // Auto Analyze's wording about one Data block (`target`), as written — Markdown — and edited since.
578
+ export interface ReportAnalysisBlock {
579
+ id: string
580
+ type: 'analysis'
581
+ target: string | null
582
+ // Asked for next time it's written (Analyze again).
583
+ focus?: string
584
+ text: string
585
+ width?: ReportBlockWidth
586
+ style?: ReportTextStyle
587
+ // What it was written from: when, the target's capturedAt then, its title, the focus used, the rows read.
588
+ writtenAt?: string
589
+ targetAsOf?: string
590
+ targetTitle?: string
591
+ focusUsed?: string
592
+ rowsAnalyzed?: number
593
+ }
594
+
595
+ export type ReportBlock =
596
+ | ReportHeadingBlock
597
+ | ReportTextBlock
598
+ | ReportDataBlock
599
+ | ReportAnalysisBlock
600
+ | ReportPageBreakBlock
601
+
602
+ // Paper is always US Letter.
603
+ export interface ReportPageSetup {
604
+ orientation: 'portrait' | 'landscape'
605
+ margins: 'narrow' | 'normal' | 'wide'
606
+ typeface: ReportTypeface
607
+ header: boolean
608
+ footer: boolean
609
+ pageNumbers: boolean
610
+ repeatTableHeaders: boolean
611
+ showInterpretation: boolean
612
+ coverPage: boolean
613
+ tableOfContents: boolean
614
+ }
615
+
616
+ export interface Report {
617
+ schemaVersion: number
618
+ title: string
619
+ page: ReportPageSetup
620
+ blocks: ReportBlock[]
621
+ }
622
+
623
+ export interface ReportDashboard {
624
+ id: string | number
625
+ name?: string
626
+ // 'PROJECT' for a dashboard the whole project shares, as AutoQL lists it.
627
+ type?: string
628
+ tiles?: DashboardTile[]
629
+ slicers?: Array<{ type?: string; data: any }>
630
+ }
631
+
632
+ // A font the organisation uploaded: its name as shown, and the file as a data: URL.
633
+ export interface ReportBrandFont {
634
+ name?: string
635
+ url: string
636
+ }
637
+
638
+ export interface ReportBranding {
639
+ name?: string
640
+ // The organisation's mark (shown before the name, which stands alone without one) and its name set as an image
641
+ // (it takes the place of the name); URLs, or data: URLs as uploaded.
642
+ logoUrl?: string
643
+ wordmarkUrl?: string
644
+ // Where the logo and wordmark sit, in each page's header and on the cover. Left by default.
645
+ position?: 'left' | 'center' | 'right'
646
+ // Brand colours, '#rrggbb', up to 6: offered in the colour pickers.
647
+ colors?: string[]
648
+ // Set in by reports on the theme's typeface, on screen and in print.
649
+ headingFont?: ReportBrandFont
650
+ bodyFont?: ReportBrandFont
651
+ }
652
+
653
+ export interface ReportRunSummary {
654
+ status: 'success' | 'partial' | 'error' | 'cancelled'
655
+ // One timestamp for the whole run (ISO 8601).
656
+ runAt: string
657
+ blocks: Array<{
658
+ blockId: string
659
+ status: 'success' | 'error' | 'cancelled' | 'skipped'
660
+ rowCount?: number
661
+ countRows?: number | null
662
+ error?: { message: string; referenceId?: string }
663
+ }>
664
+ }
665
+
666
+ export interface ReportBuilderProps {
667
+ authentication?: Authentication
668
+ autoQLConfig?: AutoQLConfig
669
+ dataFormatting?: DataFormatting
670
+ // Fetched by the host; data blocks read their tiles from these.
671
+ dashboards?: ReportDashboard[]
672
+ // Controlled: the builder stores nothing itself.
673
+ report?: Report
674
+ onChange?: (report: Report) => void
675
+ // The branding the pages are drawn with. With enableBranding, what the organisation set in AutoQL wins and this
676
+ // fills in the rest (the organisation's name, say).
677
+ branding?: ReportBranding
678
+ // The organisation's branding is kept by AutoQL (/autoql/api/v1/reports/branding): the builder loads it and
679
+ // draws it over `branding`. Off by default.
680
+ enableBranding?: boolean
681
+ // With enableBranding: adds "Branding…" to the report options menu (⋮) once AutoQL has answered, to change the
682
+ // organisation's branding. Saving takes AutoQL's organisation-admin grant, so say who may.
683
+ canEditBranding?: boolean
684
+ onRunComplete?: (summary: ReportRunSummary) => void
685
+ onErrorCallback?: (error: any) => void
686
+ getAuthenticationForProject?: (projectId: string | number) => Authentication | undefined
687
+ // A stylesheet that loads the typefaces the report can use. None is loaded by default.
688
+ fontStylesheetUrl?: string | null
689
+ // Run report: the builder fetches every data block itself. Off by default: blocks show what was
690
+ // captured when they were added, and runReport() resolves null.
691
+ enableRunReport?: boolean
692
+ // Data blocks can be made in the builder, not only arrive with "Add to Report…". Off by default.
693
+ enableDataBlocks?: boolean
694
+ // With enableDataBlocks: an empty Data block offers "Pick dashboard tiles…", which calls this. Show your own
695
+ // picker and resolve with the blocks to put in the empty block's place, in order, or null to leave it.
696
+ pickDashboardTiles?: () => Promise<ReportBlock[] | null | undefined> | ReportBlock[] | null | undefined
697
+ // Analysis blocks can be made and written: Auto Analyze's wording about one result, one Auto Analyze credit
698
+ // per run. Off by default; analyses already in a report always show and print.
699
+ enableAnalysis?: boolean
700
+ // Adds "New report · Get started…" to the palette, which calls this. The host starts the report.
701
+ onGetStarted?: () => void
702
+ // Your own element for the toolbar, shown just before Preview (and in the preview): whether the report is
703
+ // saved, say. None by default.
704
+ toolbarStatus?: React.ReactNode
705
+ className?: string
706
+ }
707
+
708
+ export declare class ReportBuilder extends React.Component<ReportBuilderProps> {
709
+ // Runs every data block as one run with one timestamp; null if superseded, or if enableRunReport is off.
710
+ runReport(): Promise<ReportRunSummary | null>
711
+ openPrintPreview(): Promise<void>
712
+ closePrintPreview(): Promise<void>
713
+ // Waits for the preview's pages and charts, then opens the browser's print dialog; true once it has.
714
+ print(): Promise<boolean>
715
+ }
716
+
717
+ export declare const REPORT_SCHEMA_VERSION: number
718
+ export declare function createEmptyReport(
719
+ overrides?: Partial<Omit<Report, 'page'>> & { page?: Partial<ReportPageSetup> },
720
+ ): Report
721
+
722
+ // A question asked once, its answer kept as a Data block's capture (shown the way AutoQL shows it by default),
723
+ // with the table rows the block should print. Never rejects.
724
+ export type CaptureQuestionResult =
725
+ | { ok: true; capture: ReportCapture; rows: ReportTableRows }
726
+ | {
727
+ ok: false
728
+ reason: 'cancelled' | 'error' | 'no-data' | 'unsupported'
729
+ // For 'error': why the question didn't run or didn't answer with data.
730
+ error?: { message: string; referenceId?: string }
731
+ }
732
+
733
+ export declare function captureQuestion(options: {
734
+ query: string
735
+ authentication?: Authentication
736
+ autoQLConfig?: AutoQLConfig
737
+ // Stops the request; the result is then { ok: false, reason: 'cancelled' }.
738
+ signal?: AbortSignal
739
+ cancelToken?: any
740
+ }): Promise<CaptureQuestionResult>
741
+
742
+ // How many table rows a new block for this capture prints: all of a table that 10, 25, 50 or 100 holds,
743
+ // else 25.
744
+ export declare function rowsForCapture(capture: ReportCapture | null | undefined): ReportTableRows
745
+
746
+ // ─── Reports, kept by AutoQL ─────────────────────────────────────────────────
747
+ // A user's own reports on the token's data source, through AutoQL's report service
748
+ // (/autoql/api/v1/reports), with their folders and tags.
749
+
750
+ // The service's message ids (the number its reference_id ends with) by name.
751
+ export declare const REPORT_ERROR_CODES: Record<number, string>
752
+
753
+ export declare class ReportsApiError extends Error {
754
+ // 0 when the service couldn't be reached.
755
+ status: number
756
+ // The message id's name, e.g. 'REPORT_VERSION_CONFLICT', when the service sent one.
757
+ code?: string
758
+ messageId?: number
759
+ referenceId?: string
760
+ // The answer's data in camelCase: { version, updatedAt } on a version conflict, { reason } on an invalid
761
+ // report or block, { id } of the folder or tag that holds a name.
762
+ details?: Record<string, any>
763
+ }
764
+
765
+ export interface StoredReportSummary {
766
+ id: string
767
+ title: string
768
+ sizeBytes: number
769
+ version: number
770
+ folderId: string | null
771
+ tagIds: string[]
772
+ createdAt: string
773
+ updatedAt: string
774
+ }
775
+
776
+ export interface StoredReport extends StoredReportSummary {
777
+ projectId: string
778
+ report: Report
779
+ }
780
+
781
+ export interface StoredReportStamp {
782
+ id: string
783
+ version: number
784
+ updatedAt: string
785
+ }
786
+
787
+ export interface ReportFolder {
788
+ id: string
789
+ name: string
790
+ reportCount: number
791
+ createdAt: string
792
+ updatedAt: string
793
+ }
794
+
795
+ export interface ReportTag extends ReportFolder {
796
+ color: string
797
+ }
798
+
799
+ export interface ReportPlacement {
800
+ id: string
801
+ folderId: string | null
802
+ tagIds: string[]
803
+ }
804
+
805
+ interface ReportsCall {
806
+ authentication: Authentication
807
+ }
808
+
809
+ export declare function fetchReports(
810
+ options: ReportsCall & {
811
+ page?: number
812
+ pageSize?: number
813
+ q?: string
814
+ folderId?: string
815
+ tagIds?: string[]
816
+ orderBy?: 'updated_at' | 'created_at' | 'title'
817
+ order?: 'asc' | 'desc'
818
+ signal?: AbortSignal
819
+ },
820
+ ): Promise<{ reports: StoredReportSummary[]; page: number; pageSize: number; totalPages: number; totalItems: number }>
821
+ export declare function fetchReport(options: ReportsCall & { id: string; signal?: AbortSignal }): Promise<StoredReport>
822
+ export declare function createReport(
823
+ options: ReportsCall & { id: string; report: Report; folderId?: string; tagIds?: string[]; keepalive?: boolean },
824
+ ): Promise<StoredReport & { created: boolean }>
825
+ export declare function saveReport(
826
+ options: ReportsCall & { id: string; report: Report; version: number; keepalive?: boolean },
827
+ ): Promise<StoredReportStamp>
828
+ export declare function deleteReport(options: ReportsCall & { id: string }): Promise<void>
829
+ export declare function deleteReports(
830
+ options: ReportsCall & { ids: string[] },
831
+ ): Promise<{ deleted: string[]; notFound: string[] }>
832
+ export declare function appendReportBlock(
833
+ options: ReportsCall & { id: string; block: ReportBlock },
834
+ ): Promise<StoredReportStamp & { appended: boolean }>
835
+ export declare function organizeReports(
836
+ options: ReportsCall & {
837
+ reportIds: string[]
838
+ // null unfiles; leaving it out leaves the reports' folders as they are.
839
+ folderId?: string | null
840
+ addTagIds?: string[]
841
+ removeTagIds?: string[]
842
+ },
843
+ ): Promise<ReportPlacement[]>
844
+
845
+ export declare function fetchReportFolders(options: ReportsCall & { signal?: AbortSignal }): Promise<ReportFolder[]>
846
+ export declare function createReportFolder(
847
+ options: ReportsCall & { id: string; name: string },
848
+ ): Promise<ReportFolder & { created: boolean }>
849
+ export declare function renameReportFolder(options: ReportsCall & { id: string; name: string }): Promise<ReportFolder>
850
+ export declare function deleteReportFolder(options: ReportsCall & { id: string }): Promise<void>
851
+
852
+ export declare function fetchReportTags(options: ReportsCall & { signal?: AbortSignal }): Promise<ReportTag[]>
853
+ export declare function createReportTag(
854
+ options: ReportsCall & { id: string; name: string; color: string },
855
+ ): Promise<ReportTag & { created: boolean }>
856
+ export declare function updateReportTag(
857
+ options: ReportsCall & { id: string; name?: string; color?: string },
858
+ ): Promise<ReportTag>
859
+ export declare function deleteReportTag(options: ReportsCall & { id: string }): Promise<void>
860
+
861
+ // ─── Reports workspace ───────────────────────────────────────────────────────
862
+ // A user's reports on the token's data source, each open in a tab with its own ReportBuilder and saved to AutoQL
863
+ // as it's edited: the tab strip, New report (from a question, a dashboard or a blank page), autosave with its
864
+ // save control, and the dashboard-tiles picker. The host draws the home page.
865
+
866
+ export interface ReportsNotice {
867
+ tone: 'error' | 'info'
868
+ text: string
869
+ }
870
+
871
+ // What renderHome draws the home page from.
872
+ export interface ReportsHomeProps {
873
+ // The user's reports on the data source, most recently saved first; null while they load.
874
+ reports: StoredReportSummary[] | null
875
+ // Why they couldn't be listed.
876
+ listError: string | null
877
+ retryList: () => void
878
+ // Shows the report in its tab (opening one if it isn't open).
879
+ openReport: (id: string) => void
880
+ // Deletes the report for good (ask first); its tab closes. Resolves with whether it was deleted — why not is in
881
+ // notices.
882
+ deleteReport: (id: string) => Promise<boolean>
883
+ // Deletes several, one after another as deleteReport does each. Resolves with whether every one was deleted.
884
+ deleteReports: (ids: string[]) => Promise<boolean>
885
+ deletingId: string | null
886
+ // What happened meanwhile: a report deleted in another tab, a delete that failed.
887
+ notices: ReportsNotice[]
888
+ // Opens New report.
889
+ newReport: () => void
890
+
891
+ // The user's folders and tags on the data source, A to Z; null while they load. Each report in `reports` says its
892
+ // folder (folderId, null for none) and its tags (tagIds).
893
+ folders: ReportFolder[] | null
894
+ tags: ReportTag[] | null
895
+ // Why they couldn't be loaded.
896
+ organizersError: string | null
897
+ retryOrganizers: () => void
898
+ // The changes below resolve once AutoQL has them, the lists following, and reject with an Error whose message is
899
+ // the line to show (`code` and `status` are the service's).
900
+ // A new folder or tag, or the one with that name already, whatever its case. Names are 1 to 80 characters.
901
+ createFolder: (name: string) => Promise<ReportFolder>
902
+ renameFolder: (id: string, name: string) => Promise<ReportFolder>
903
+ // Its reports become unfiled; none is deleted.
904
+ deleteFolder: (id: string) => Promise<void>
905
+ // `color` is a short key the host picks (`blue`, `amber`…), kept as it's sent.
906
+ createTag: (name: string, color: string) => Promise<ReportTag>
907
+ updateTag: (id: string, change: { name?: string; color?: string }) => Promise<ReportTag>
908
+ // Taken off every report that had it; none is deleted.
909
+ deleteTag: (id: string) => Promise<void>
910
+ // Files reports in a folder (null: none; left out: as they are) and adds or takes off tags, all at once or not at
911
+ // all. Resolves with where each report now is.
912
+ organizeReports: (change: {
913
+ reportIds: string[]
914
+ folderId?: string | null
915
+ addTagIds?: string[]
916
+ removeTagIds?: string[]
917
+ }) => Promise<ReportPlacement[]>
918
+ }
919
+
920
+ export interface ReportsProps {
921
+ authentication?: Authentication
922
+ autoQLConfig?: AutoQLConfig
923
+ dataFormatting?: DataFormatting
924
+ // Which data source the reports are on. The token's project by default.
925
+ dataSourceId?: string | number
926
+ // The dashboards a report can take tiles from (New report from a dashboard, an empty Data block's "Pick
927
+ // dashboard tiles…"). Null while they load; leave it out where there are none. Tiles may carry their answers.
928
+ dashboards?: ReportDashboard[] | null
929
+ // Why the dashboards couldn't be loaded, said over the open report.
930
+ dashboardsError?: string | null
931
+ // A dashboard's tiles as the tiles picker answered them, for a host that keeps answers between views.
932
+ onDashboardTilesChange?: (dashboardId: string, tiles: DashboardTile[]) => void
933
+ // The report shown (null: the home page), for a host that keeps it in its address: when it changes, that report
934
+ // shows (once the list is in, and if it's there). onShowReport hears every change made in the workspace.
935
+ shownReportId?: string | null
936
+ onShowReport?: (id: string | null) => void
937
+ // Draws the home page. A plain list of the reports by default.
938
+ renderHome?: (home: ReportsHomeProps) => React.ReactNode
939
+ // Where the open tabs are remembered in this browser (localStorage keys start with it); null remembers nothing.
940
+ // 'react-autoql.' by default.
941
+ storageKeyPrefix?: string | null
942
+ // AutoQL turned the token away (401): pass in a new authentication, and what failed is tried again with it.
943
+ onUnauthorized?: () => void
944
+ // How long a pause in editing is before a report saves (ms). 2000 by default.
945
+ saveDelay?: number
946
+ // The folder New report makes reports in, while it's one of the user's: the one the host's home page shows, say.
947
+ newReportFolderId?: string | null
948
+ // Passed on to each report's ReportBuilder.
949
+ branding?: ReportBranding
950
+ enableBranding?: boolean
951
+ canEditBranding?: boolean
952
+ enableDataBlocks?: boolean
953
+ enableAnalysis?: boolean
954
+ enableRunReport?: boolean
955
+ fontStylesheetUrl?: string | null
956
+ getAuthenticationForProject?: (projectId: string | number) => Authentication | undefined
957
+ onRunComplete?: (summary: ReportRunSummary) => void
958
+ onErrorCallback?: (error: any) => void
959
+ className?: string
960
+ }
961
+
962
+ export declare class Reports extends React.Component<ReportsProps> {
963
+ // Saves everything waiting, now (before signing out, say); keepalive when the page is going away. Resolves with
964
+ // whether each report reached the server.
965
+ flushAll(options?: { keepalive?: boolean }): Promise<boolean[]>
966
+ // Whether any report has edits AutoQL doesn't have yet.
967
+ hasUnsavedChanges(): boolean
968
+ // Saves the report shown, now.
969
+ saveNow(): void
970
+ // Lists the reports again.
971
+ reload(): void
972
+ }
973
+
974
+ // What a toolbar's custom option hands its callback: the answer's payload, and from react-autoql's toolbars a
975
+ // capture of what it shows now.
976
+ export interface ReportToolbarOptionData {
977
+ query?: string
978
+ tileKey?: string | number
979
+ dashboardId?: string | number
980
+ [key: string]: unknown
981
+ }
982
+
983
+ export interface ReportToolbarOptionExtra {
984
+ captureForReport?: (options?: { maxTableRows?: number; maxChartRows?: number }) => ReportCaptureResult
985
+ }
986
+
987
+ // The Data block "Add to Report…" adds: the answer or tile as it's shown now, and where it came from (the tile,
988
+ // when there is one, else the question). A message to show when it can't be kept.
989
+ export declare function captureReportBlock(options: {
990
+ data: ReportToolbarOptionData | null | undefined
991
+ extra: ReportToolbarOptionExtra | null | undefined
992
+ dashboard?: { id: string; name?: string; tiles?: DashboardTile[] } | null
993
+ }): { ok: true; block: ReportDataBlock } | { ok: false; message: string }
994
+
995
+ export interface AddToReportDialogProps {
996
+ authentication?: Authentication
997
+ // The block to add at the end of the chosen report (captureReportBlock).
998
+ block: ReportBlock
999
+ onClose: () => void
1000
+ // After it's added (before onClose): which report, and whether it was made for this.
1001
+ onAdded?: (added: { id: string; title: string; created: boolean }) => void
1002
+ }
1003
+
1004
+ // "Add to Report…": adds a block to the end of one of the user's reports, or to a new one.
1005
+ export declare class AddToReportDialog extends React.Component<AddToReportDialogProps> {}
1006
+
1007
+ // ─── Push notifications ───────────────────────────────────────────────────────
1008
+
1009
+ export type PushNotificationStatus = 'unsupported' | 'checking' | 'on' | 'off' | 'blocked'
1010
+
1011
+ export declare const PUSH_NOTIFICATION_STATUS: {
1012
+ UNSUPPORTED: 'unsupported'
1013
+ CHECKING: 'checking'
1014
+ ON: 'on'
1015
+ OFF: 'off'
1016
+ BLOCKED: 'blocked'
1017
+ }
1018
+
1019
+ export interface PushNotificationsProviderProps {
1020
+ authentication?: Authentication
1021
+ /** Where the app serves push-sw.js. Defaults to '/push-sw.js'. Pass null when the app's own service worker imports it. */
1022
+ serviceWorkerUrl?: string | null
1023
+ /** Service worker scope. Defaults to the scope of the current page. */
1024
+ scope?: string
1025
+ /** Called with the notification's URL when the user clicks a notification. Defaults to a full page load. */
1026
+ onNotificationClick?: (url: string, data: PushMessageData) => void
1027
+ /** Called when an alert arrives while the app is open. */
1028
+ onPushReceived?: (data: PushMessageData) => void
1029
+ children?: React.ReactNode
1030
+ }
1031
+
1032
+ export interface UsePushNotificationsResult {
1033
+ isSupported: boolean
1034
+ status: PushNotificationStatus
1035
+ isEnabled: boolean
1036
+ isBusy: boolean
1037
+ error: unknown
1038
+ /** Asks for permission if needed and subscribes. Call it from a click. Resolves true when push is on. */
1039
+ enable: () => Promise<boolean>
1040
+ /** Unsubscribes this browser. Call it on logout too. */
1041
+ disable: () => Promise<void>
1042
+ /** Saves this browser's subscription to the server again. */
1043
+ sync: () => Promise<void>
1044
+ }
1045
+
1046
+ export interface PushNotificationsToggleProps {
1047
+ label?: string
1048
+ description?: string
1049
+ blockedMessage?: string
1050
+ errorMessage?: string
1051
+ className?: string
1052
+ }
1053
+
1054
+ export declare const PushNotificationsProvider: React.FC<PushNotificationsProviderProps>
1055
+ export declare function usePushNotifications(): UsePushNotificationsResult
1056
+ export declare const PushNotificationsToggle: React.FC<PushNotificationsToggleProps>
1057
+
414
1058
  // ─── Miscellaneous components ─────────────────────────────────────────────────
415
1059
 
416
1060
  export declare const Icon: React.FC<{ type: string; className?: string; [key: string]: any }>