@magemetrics/ai 0.3.3 → 0.4.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,6 +1,7 @@
1
1
  import { AuthState } from '@magemetrics/core';
2
2
  import { CreateFlowParam } from '@magemetrics/core';
3
3
  import { default as default_2 } from 'react';
4
+ import { Dispatch } from 'react';
4
5
  import { FetchNextPageOptions } from '@tanstack/react-query';
5
6
  import { ForwardRefExoticComponent } from 'react';
6
7
  import { GenerateInsightParam } from '@magemetrics/core';
@@ -8,8 +9,11 @@ import { InfiniteData } from '@tanstack/react-query';
8
9
  import { InfiniteQueryObserverResult } from '@tanstack/react-query';
9
10
  import { MageMetricsClient } from '@magemetrics/core';
10
11
  import { MageMetricsClientConfig } from '@magemetrics/core';
12
+ import { OnChangeFn } from '@tanstack/react-table';
11
13
  import { PropsWithChildren } from 'react';
12
14
  import { RefAttributes } from 'react';
15
+ import { SetStateAction } from 'react';
16
+ import { SortingState as SortingState_2 } from '@tanstack/react-table';
13
17
  import { UseMutateAsyncFunction } from '@tanstack/react-query';
14
18
  import { UseMutateFunction } from '@tanstack/react-query';
15
19
  import { UseMutationOptions } from '@tanstack/react-query';
@@ -77,9 +81,18 @@ declare interface ConversationContentProps {
77
81
 
78
82
  export { CreateFlowParam }
79
83
 
80
- /** This component is not bounded in height and must be wrapped in a container to properly work */
84
+ /**
85
+ * This component is not bounded in height and must be wrapped in a container to properly work
86
+ * @param props - props
87
+ * @param props.reportId - The ID of the report to display
88
+ * @param props.initialState - The initial state of data table
89
+ * @param props.onStateChange - Callback function to handle state changes
90
+ * @returns JSX.Element
91
+ */
81
92
  export declare const DataReport: React.FC<{
82
93
  reportId: number;
94
+ initialState?: DataTableState;
95
+ onStateChange?: (state: DataTableState) => void;
83
96
  }>;
84
97
 
85
98
  export declare interface DataReportMessageProps {
@@ -101,6 +114,13 @@ export declare interface DataReportMessageProps {
101
114
 
102
115
  export declare const DataTable: React.FC<DataReportMessageProps>;
103
116
 
117
+ declare type DataTableState = {
118
+ pageIndex: number;
119
+ pageSize: number;
120
+ sorting: SortingState;
121
+ filters: TableFilters;
122
+ };
123
+
104
124
  declare type DisplayControlProps = {
105
125
  /** Whether to display the recommendations section when the input is active */
106
126
  showRecommendations?: boolean;
@@ -357,6 +377,8 @@ declare interface ManagedModalProps extends ModalProps {
357
377
  apiUrl: string;
358
378
  /** Whether to disable canvas functionality in conversations */
359
379
  disableCanvas?: boolean;
380
+ /** Whether to render data freshness info in the conversation header */
381
+ showDataFreshness?: boolean;
360
382
  /** Where to persist modal state (localStorage, queryParam, or none) */
361
383
  persist?: PersistenceOptions;
362
384
  /** Custom component overrides for extending functionality */
@@ -372,18 +394,59 @@ declare interface ModalProps {
372
394
  startOptions?: StartOptions;
373
395
  }
374
396
 
397
+ export declare const PaginatedDataTableUI: React.FC<PaginatedDataTableUIProps>;
398
+
399
+ declare type PaginatedDataTableUIProps = {
400
+ reportId: number;
401
+ data: Record<string, unknown>[];
402
+ columns: FrontendReportColumns;
403
+ explainability: FrontendReportExplainability | null | undefined;
404
+ isFetching: boolean;
405
+ totalRows?: number;
406
+ pageIndex: number;
407
+ pageSize: number;
408
+ totalPages?: number;
409
+ hasNextPage: boolean;
410
+ hasPreviousPage: boolean;
411
+ onNextPage: () => void;
412
+ onPreviousPage: () => void;
413
+ goToPage: (page: number) => void;
414
+ sorting: SortingState;
415
+ onSortingChange: OnChangeFn<SortingState>;
416
+ filters: TableFilters;
417
+ onFiltersChange: (filters: TableFilters) => void;
418
+ onCalculatedPageSize?: (pageSize: number) => void;
419
+ onStateChange?: (state: {
420
+ pageIndex: number;
421
+ pageSize: number;
422
+ sorting: SortingState;
423
+ filters: TableFilters;
424
+ }) => void;
425
+ emptyState?: React.ReactNode;
426
+ };
427
+
375
428
  declare type PersistenceOptions = "queryParam" | "none";
376
429
 
377
430
  export declare const PublicCanvas: React.FC<React.ComponentProps<typeof PublicCanvasPanel>>;
378
431
 
379
- /** This component is not bounded in height and must be wrapped in a container to properly work */
380
- export declare const PublicCanvasDataReport: React.FC<{
432
+ declare const PublicCanvasPanel: default_2.FC<{
381
433
  canvasId: string;
382
- reportId: number;
383
434
  }>;
384
435
 
385
- declare const PublicCanvasPanel: default_2.FC<{
436
+ /**
437
+ * This component is not bounded in height and must be wrapped in a container to properly work
438
+ * @param props - props
439
+ * @param props.canvasId - The ID of the canvas to display
440
+ * @param props.reportId - The ID of the report to display
441
+ * @param props.initialState - The initial state of data table
442
+ * @param props.onStateChange - Callback function to handle state changes
443
+ * @returns JSX.Element
444
+ */
445
+ export declare const PublicDataReport: React.FC<{
386
446
  canvasId: string;
447
+ reportId: number;
448
+ initialState?: DataTableState;
449
+ onStateChange?: (state: DataTableState) => void;
387
450
  }>;
388
451
 
389
452
  declare type ReportDataFilters = {
@@ -402,6 +465,7 @@ declare type StandaloneConversationModalProps = {
402
465
  opened: boolean;
403
466
  flowId: string;
404
467
  disableCanvas?: boolean;
468
+ showDataFreshness?: boolean;
405
469
  onOpenChange?: (open: boolean) => void;
406
470
  };
407
471
 
@@ -847,6 +911,79 @@ export declare const useMageMetricsClient: () => MageMetricsClient;
847
911
 
848
912
  export declare const useMageMetricsReady: () => false | MageMetricsClient;
849
913
 
914
+ export declare const usePaginatedDataReport: (reportId: FrontendReport["id"], options?: {
915
+ pageSize?: number;
916
+ initialPageIndex?: number;
917
+ initialSorting?: SortingState_2;
918
+ initialFilters?: TableFilters;
919
+ }) => {
920
+ columns: {
921
+ name: string;
922
+ data_type: string;
923
+ dataType: string;
924
+ renderType?: string;
925
+ unit?: string;
926
+ }[] | undefined;
927
+ isPendingColumns: boolean;
928
+ isPendingData: boolean;
929
+ isFetching: boolean;
930
+ data: {
931
+ [key: string]: unknown;
932
+ }[];
933
+ explainability: {
934
+ sql_explanation?: {
935
+ chunk_title: string;
936
+ chunk_explanation: string;
937
+ lines: {
938
+ sql: string;
939
+ explanation: string;
940
+ }[];
941
+ }[] | null;
942
+ business_explanation?: {
943
+ summary: string;
944
+ implementation: string[];
945
+ assumptions: {
946
+ type: "grain" | "completeness" | "transformation" | "relationship" | "other";
947
+ details: string;
948
+ explanation: string;
949
+ }[];
950
+ } | null;
951
+ columns_lineage?: {
952
+ [key: string]: {
953
+ nodes: {
954
+ id: string;
955
+ type: "entity" | "attribute" | "filter" | "process" | "combine" | "result";
956
+ explanation: string;
957
+ }[];
958
+ edges: {
959
+ source: string;
960
+ target: string;
961
+ }[];
962
+ };
963
+ } | null;
964
+ confidence_score: number;
965
+ confidence_score_reason: string;
966
+ assumptions_score?: number;
967
+ assumptions_score_reason?: string;
968
+ friendliness_score?: number;
969
+ friendliness_score_reason?: string;
970
+ flow_data_id: number;
971
+ } | null | undefined;
972
+ totalRows: number | undefined;
973
+ pageIndex: number;
974
+ pageSize: number;
975
+ totalPages: number | undefined;
976
+ nextPage: () => void;
977
+ previousPage: () => void;
978
+ goToPage: (page: number) => void;
979
+ hasNextPage: boolean;
980
+ hasPreviousPage: boolean;
981
+ sorting: SortingState_2;
982
+ setSorting: Dispatch<SetStateAction<SortingState_2>>;
983
+ filters: TableFilters;
984
+ setFilters: (newFilters: TableFilters) => void;
985
+ };
986
+
850
987
  export declare const useRecentFlows: (limit?: number) => UseQueryResult< {
851
988
  id: string;
852
989
  request: string;