@magemetrics/ai 0.4.1-RC1 → 0.4.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.
@@ -1,14 +1,18 @@
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';
6
+ import { ForwardRefExoticComponent } from 'react';
5
7
  import { GenerateInsightParam } from '@magemetrics/core';
6
8
  import { InfiniteData } from '@tanstack/react-query';
7
9
  import { InfiniteQueryObserverResult } from '@tanstack/react-query';
8
- import { JSX } from 'react/jsx-runtime';
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';
14
+ import { RefAttributes } from 'react';
15
+ import { SetStateAction } from 'react';
12
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';
@@ -41,9 +45,7 @@ export declare interface Components {
41
45
  [key: string]: (props: CellContentProps) => default_2.ReactNode;
42
46
  };
43
47
  };
44
- dataReportTable?: (props: {
45
- report: FrontendReport;
46
- }) => default_2.ReactNode;
48
+ dataReportTable?: (props: DataReportMessageProps) => default_2.ReactNode;
47
49
  dataReportMessageActions?: (props: {
48
50
  report: FrontendReport;
49
51
  isSelected: boolean;
@@ -67,6 +69,8 @@ declare type ControlledModalProps = {
67
69
  onClose: () => void;
68
70
  };
69
71
 
72
+ export declare const ConversationContent: React.FC<ConversationContentProps>;
73
+
70
74
  declare interface ConversationContentProps {
71
75
  flowId?: string;
72
76
  className?: string;
@@ -77,7 +81,45 @@ declare interface ConversationContentProps {
77
81
 
78
82
  export { CreateFlowParam }
79
83
 
80
- export declare const DataTable: () => JSX.Element;
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
+ */
92
+ export declare const DataReport: React.FC<{
93
+ reportId: number;
94
+ initialState?: DataTableState;
95
+ onStateChange?: (state: DataTableState) => void;
96
+ }>;
97
+
98
+ export declare interface DataReportMessageProps {
99
+ report: FrontendReport;
100
+ explainability: FrontendReportExplainability | null | undefined;
101
+ infiniteData: {
102
+ data?: {
103
+ pages: Record<string, unknown>[][];
104
+ };
105
+ isPending: boolean;
106
+ fetchNextPage: () => Promise<unknown>;
107
+ isFetching: boolean;
108
+ isFetchingNextPage: boolean;
109
+ hasNextPage: boolean | undefined;
110
+ };
111
+ columns: FrontendReportColumns;
112
+ totalRows: number;
113
+ }
114
+
115
+ export declare const DataTable: React.FC<DataReportMessageProps>;
116
+
117
+ declare type DataTableState = {
118
+ pageIndex: number;
119
+ pageSize: number;
120
+ sorting: SortingState;
121
+ filters: TableFilters;
122
+ };
81
123
 
82
124
  declare type DisplayControlProps = {
83
125
  /** Whether to display the recommendations section when the input is active */
@@ -94,6 +136,10 @@ declare type DomWrapperProps = {
94
136
  display?: string;
95
137
  };
96
138
 
139
+ export declare const DownloadDataReportButton: React.FC<{
140
+ reportId: number;
141
+ }>;
142
+
97
143
  declare type ExportReportDataParams = {
98
144
  reportId: number;
99
145
  filename?: string;
@@ -143,6 +189,69 @@ declare type FormattedData = {
143
189
 
144
190
  declare type FrontendReport = z.infer<typeof FrontendReportSchema>;
145
191
 
192
+ declare type FrontendReportColumns = z.infer<typeof FrontendReportColumnsSchema>;
193
+
194
+ declare const FrontendReportColumnsSchema: z.ZodArray<z.ZodObject<{
195
+ dataType: z.ZodString;
196
+ renderType: z.ZodOptional<z.ZodString>;
197
+ unit: z.ZodOptional<z.ZodString>;
198
+ name: z.ZodString;
199
+ data_type: z.ZodString;
200
+ }, z.core.$strip>>;
201
+
202
+ declare type FrontendReportExplainability = z.infer<typeof FrontendReportExplainabilitySchema>;
203
+
204
+ declare const FrontendReportExplainabilitySchema: z.ZodObject<{
205
+ flow_data_id: z.ZodNumber;
206
+ sql_explanation: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
207
+ chunk_title: z.ZodString;
208
+ chunk_explanation: z.ZodString;
209
+ lines: z.ZodArray<z.ZodObject<{
210
+ sql: z.ZodString;
211
+ explanation: z.ZodString;
212
+ }, z.core.$strip>>;
213
+ }, z.core.$strip>>>>;
214
+ business_explanation: z.ZodOptional<z.ZodNullable<z.ZodObject<{
215
+ summary: z.ZodString;
216
+ implementation: z.ZodArray<z.ZodString>;
217
+ assumptions: z.ZodArray<z.ZodObject<{
218
+ type: z.ZodEnum<{
219
+ grain: "grain";
220
+ completeness: "completeness";
221
+ transformation: "transformation";
222
+ relationship: "relationship";
223
+ other: "other";
224
+ }>;
225
+ details: z.ZodString;
226
+ explanation: z.ZodString;
227
+ }, z.core.$strip>>;
228
+ }, z.core.$strip>>>;
229
+ columns_lineage: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
230
+ nodes: z.ZodArray<z.ZodObject<{
231
+ id: z.ZodString;
232
+ type: z.ZodEnum<{
233
+ result: "result";
234
+ filter: "filter";
235
+ entity: "entity";
236
+ attribute: "attribute";
237
+ process: "process";
238
+ combine: "combine";
239
+ }>;
240
+ explanation: z.ZodString;
241
+ }, z.core.$strip>>;
242
+ edges: z.ZodArray<z.ZodObject<{
243
+ source: z.ZodString;
244
+ target: z.ZodString;
245
+ }, z.core.$strip>>;
246
+ }, z.core.$strip>>>>;
247
+ confidence_score: z.ZodNumber;
248
+ confidence_score_reason: z.ZodString;
249
+ assumptions_score: z.ZodOptional<z.ZodNumber>;
250
+ assumptions_score_reason: z.ZodOptional<z.ZodString>;
251
+ friendliness_score: z.ZodOptional<z.ZodNumber>;
252
+ friendliness_score_reason: z.ZodOptional<z.ZodString>;
253
+ }, z.core.$strip>;
254
+
146
255
  declare const FrontendReportSchema: z.ZodObject<{
147
256
  status: z.ZodNullable<z.ZodString>;
148
257
  title: z.ZodString;
@@ -214,6 +323,20 @@ declare const FrontendVisualizationSchema: z.ZodObject<{
214
323
 
215
324
  export { GenerateInsightParam }
216
325
 
326
+ export declare const InfiniteDataTableUI: React.FC<InfiniteDataTableUIProps>;
327
+
328
+ declare type InfiniteDataTableUIProps = {
329
+ flowDataId: number;
330
+ data: Record<string, unknown>[];
331
+ columns: FrontendReportColumns;
332
+ explainability: FrontendReportExplainability | null | undefined;
333
+ hasNextPage: boolean | undefined;
334
+ fetchNextPage: () => Promise<unknown>;
335
+ isFetchingNextPage: boolean;
336
+ isFetching: boolean;
337
+ totalRows: number;
338
+ };
339
+
217
340
  export declare const logout: () => void;
218
341
 
219
342
  export { MageMetricsClient }
@@ -271,6 +394,37 @@ declare interface ModalProps {
271
394
  startOptions?: StartOptions;
272
395
  }
273
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
+
274
428
  declare type PersistenceOptions = "queryParam" | "none";
275
429
 
276
430
  export declare const PublicCanvas: React.FC<React.ComponentProps<typeof PublicCanvasPanel>>;
@@ -279,6 +433,22 @@ declare const PublicCanvasPanel: default_2.FC<{
279
433
  canvasId: string;
280
434
  }>;
281
435
 
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<{
446
+ canvasId: string;
447
+ reportId: number;
448
+ initialState?: DataTableState;
449
+ onStateChange?: (state: DataTableState) => void;
450
+ }>;
451
+
282
452
  declare type ReportDataFilters = {
283
453
  columns?: string[];
284
454
  limit: number;
@@ -428,34 +598,7 @@ export declare const useCreateFlow: (options?: UseMutationOptions<{
428
598
  }, Error, CreateFlowParam, unknown>;
429
599
  };
430
600
 
431
- export declare const useCustomReportData: () => {
432
- report: {
433
- status: string | null;
434
- title: string;
435
- id: number;
436
- request: string | null;
437
- created_at: string;
438
- is_removed: boolean;
439
- flow_id: string;
440
- bookmarked: boolean;
441
- data_summary: {
442
- [x: string]: unknown;
443
- columns: Record<string, {
444
- [x: string]: unknown;
445
- data_type: string;
446
- null_count: number | null;
447
- unique_count: number | null;
448
- unique_percentage: number | null;
449
- position?: number | undefined;
450
- }>;
451
- };
452
- };
453
- fetchNextPage: (options?: FetchNextPageOptions) => Promise<InfiniteQueryObserverResult<InfiniteData< {
454
- [key: string]: unknown;
455
- }[], unknown>, Error>>;
456
- pages: {
457
- [key: string]: unknown;
458
- }[][] | undefined;
601
+ export declare const useDataReport: (reportId: FrontendReport["id"]) => {
459
602
  columns: {
460
603
  name: string;
461
604
  data_type: string;
@@ -464,13 +607,59 @@ export declare const useCustomReportData: () => {
464
607
  unit?: string;
465
608
  }[] | undefined;
466
609
  isPendingColumns: boolean;
467
- hasMoreData: boolean;
468
- isFetching: boolean;
469
610
  isPendingData: boolean;
470
- totalRows: number | undefined;
471
- totalPages: number | undefined;
472
- sorting: SortingState_2;
473
- filters: TableFilters;
611
+ fetchNextPage: (options?: FetchNextPageOptions) => Promise<InfiniteQueryObserverResult<InfiniteData< {
612
+ [key: string]: unknown;
613
+ }[], unknown>, Error>>;
614
+ isFetching: boolean;
615
+ isFetchingNextPage: boolean;
616
+ hasNextPage: boolean;
617
+ allData: {
618
+ [key: string]: unknown;
619
+ }[];
620
+ explainability: {
621
+ sql_explanation?: {
622
+ chunk_title: string;
623
+ chunk_explanation: string;
624
+ lines: {
625
+ sql: string;
626
+ explanation: string;
627
+ }[];
628
+ }[] | null;
629
+ business_explanation?: {
630
+ summary: string;
631
+ implementation: string[];
632
+ assumptions: {
633
+ type: "grain" | "completeness" | "transformation" | "relationship" | "other";
634
+ details: string;
635
+ explanation: string;
636
+ }[];
637
+ } | null;
638
+ columns_lineage?: {
639
+ [key: string]: {
640
+ nodes: {
641
+ id: string;
642
+ type: "entity" | "attribute" | "filter" | "process" | "combine" | "result";
643
+ explanation: string;
644
+ }[];
645
+ edges: {
646
+ source: string;
647
+ target: string;
648
+ }[];
649
+ };
650
+ } | null;
651
+ confidence_score: number;
652
+ confidence_score_reason: string;
653
+ assumptions_score?: number;
654
+ assumptions_score_reason?: string;
655
+ friendliness_score?: number;
656
+ friendliness_score_reason?: string;
657
+ flow_data_id: number;
658
+ } | null | undefined;
659
+ totalRows: number;
660
+ infiniteData: InfiniteData< {
661
+ [key: string]: unknown;
662
+ }[], unknown> | undefined;
474
663
  };
475
664
 
476
665
  export declare const useDataReportColumnValue: (reportId: number, filters: ReportDataFilters) => UseQueryResult< {
@@ -720,6 +909,79 @@ export declare const useMageMetricsClient: () => MageMetricsClient;
720
909
 
721
910
  export declare const useMageMetricsReady: () => false | MageMetricsClient;
722
911
 
912
+ export declare const usePaginatedDataReport: (reportId: FrontendReport["id"], options?: {
913
+ pageSize?: number;
914
+ initialPageIndex?: number;
915
+ initialSorting?: SortingState_2;
916
+ initialFilters?: TableFilters;
917
+ }) => {
918
+ columns: {
919
+ name: string;
920
+ data_type: string;
921
+ dataType: string;
922
+ renderType?: string;
923
+ unit?: string;
924
+ }[] | undefined;
925
+ isPendingColumns: boolean;
926
+ isPendingData: boolean;
927
+ isFetching: boolean;
928
+ data: {
929
+ [key: string]: unknown;
930
+ }[];
931
+ explainability: {
932
+ sql_explanation?: {
933
+ chunk_title: string;
934
+ chunk_explanation: string;
935
+ lines: {
936
+ sql: string;
937
+ explanation: string;
938
+ }[];
939
+ }[] | null;
940
+ business_explanation?: {
941
+ summary: string;
942
+ implementation: string[];
943
+ assumptions: {
944
+ type: "grain" | "completeness" | "transformation" | "relationship" | "other";
945
+ details: string;
946
+ explanation: string;
947
+ }[];
948
+ } | null;
949
+ columns_lineage?: {
950
+ [key: string]: {
951
+ nodes: {
952
+ id: string;
953
+ type: "entity" | "attribute" | "filter" | "process" | "combine" | "result";
954
+ explanation: string;
955
+ }[];
956
+ edges: {
957
+ source: string;
958
+ target: string;
959
+ }[];
960
+ };
961
+ } | null;
962
+ confidence_score: number;
963
+ confidence_score_reason: string;
964
+ assumptions_score?: number;
965
+ assumptions_score_reason?: string;
966
+ friendliness_score?: number;
967
+ friendliness_score_reason?: string;
968
+ flow_data_id: number;
969
+ } | null | undefined;
970
+ totalRows: number | undefined;
971
+ pageIndex: number;
972
+ pageSize: number;
973
+ totalPages: number | undefined;
974
+ nextPage: () => void;
975
+ previousPage: () => void;
976
+ goToPage: (page: number) => void;
977
+ hasNextPage: boolean;
978
+ hasPreviousPage: boolean;
979
+ sorting: SortingState_2;
980
+ setSorting: Dispatch<SetStateAction<SortingState_2>>;
981
+ filters: TableFilters;
982
+ setFilters: (newFilters: TableFilters) => void;
983
+ };
984
+
723
985
  export declare const useRecentFlows: (limit?: number) => UseQueryResult< {
724
986
  id: string;
725
987
  request: string;
@@ -769,6 +1031,12 @@ declare const V1FrontendVisualizationSchema: z.ZodObject<{
769
1031
  }, z.core.$strip>], "type">;
770
1032
  }, z.core.$strip>;
771
1033
 
1034
+ export declare const Visualization: ForwardRefExoticComponent< {
1035
+ visualizationId: number;
1036
+ withTitle: boolean;
1037
+ exportingEnabled?: boolean;
1038
+ } & RefAttributes<HTMLDivElement>>;
1039
+
772
1040
  export { }
773
1041
 
774
1042