@magemetrics/ai 0.8.1 → 0.9.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.
@@ -8,7 +8,6 @@ import { ExternalAuthProvider } from '@magemetrics/core';
8
8
  import { ExternalAuthProviderConfig } from '@magemetrics/core';
9
9
  import { FetchNextPageOptions } from '@tanstack/react-query';
10
10
  import { ForwardRefExoticComponent } from 'react';
11
- import { GenerateInsightParam } from '@magemetrics/core';
12
11
  import { InfiniteData } from '@tanstack/react-query';
13
12
  import { InfiniteQueryObserverResult } from '@tanstack/react-query';
14
13
  import { MageMetricsClient } from '@magemetrics/core';
@@ -21,6 +20,7 @@ import { SortingState as SortingState_2 } from '@tanstack/react-table';
21
20
  import { UseMutateAsyncFunction } from '@tanstack/react-query';
22
21
  import { UseMutateFunction } from '@tanstack/react-query';
23
22
  import { UseMutationOptions } from '@tanstack/react-query';
23
+ import { UseQueryOptions } from '@tanstack/react-query';
24
24
  import { UseQueryResult } from '@tanstack/react-query';
25
25
  import { z } from 'zod';
26
26
 
@@ -53,6 +53,25 @@ export { AuthState }
53
53
  */
54
54
  export declare type BrandColors = PrimaryColorOption & SecondaryColorOption;
55
55
 
56
+ /**
57
+ * A standalone authenticated Canvas component that renders a canvas by its ID.
58
+ * This is useful for displaying saved canvases without the chat interface.
59
+ * @param root0 props for the component
60
+ * @param root0.canvasId The UUID of the canvas to display
61
+ * @returns the canvas component
62
+ * @example
63
+ * ```tsx
64
+ * import { Canvas } from "@magemetrics/ai";
65
+ *
66
+ * const SavedCanvasView = ({ canvasId }: { canvasId: string }) => {
67
+ * return <Canvas canvasId={canvasId} />;
68
+ * };
69
+ * ```
70
+ */
71
+ export declare const Canvas: React.FC<{
72
+ canvasId: string;
73
+ }>;
74
+
56
75
  export declare type CellContentProps = {
57
76
  formattedValue: FormattedData | undefined;
58
77
  unit?: string;
@@ -128,6 +147,10 @@ export declare interface Components {
128
147
  }) => default_2.ReactNode;
129
148
  avatar?: default_2.ReactNode;
130
149
  getCanvasShareableLink?: (canvasId: string) => string;
150
+ canvasPanelActions?: (props: {
151
+ canvas: FrontendCanvas;
152
+ flowId: string;
153
+ }) => default_2.ReactNode;
131
154
  }
132
155
 
133
156
  export declare const ConfigurableChat: ConfigurableChatComponent;
@@ -243,15 +266,6 @@ export { ExternalAuthProvider }
243
266
 
244
267
  export { ExternalAuthProviderConfig }
245
268
 
246
- declare type ExtractInsightResponse = z.infer<typeof ExtractInsightResponseSchema>;
247
-
248
- declare const ExtractInsightResponseSchema: z.ZodUnion<[z.ZodObject<{
249
- type: z.ZodLiteral<"text">;
250
- insight: z.ZodString;
251
- }, z.core.$strip>, z.ZodObject<{
252
- type: z.ZodLiteral<"missing">;
253
- }, z.core.$strip>]>;
254
-
255
269
  /**
256
270
  * This module handles the formatting and normalization of table cell values for display and sorting.
257
271
  *
@@ -279,6 +293,16 @@ declare type FormattedData = {
279
293
  sortValue: string | number | Date | null;
280
294
  };
281
295
 
296
+ declare type FrontendCanvas = z.infer<typeof FrontendCanvasSchema>;
297
+
298
+ declare const FrontendCanvasSchema: z.ZodObject<{
299
+ title: z.ZodNullable<z.ZodString>;
300
+ id: z.ZodUUID;
301
+ nodes: z.ZodArray<z.ZodAny>;
302
+ edges: z.ZodArray<z.ZodAny>;
303
+ is_public: z.ZodBoolean;
304
+ }, z.core.$strip>;
305
+
282
306
  declare type FrontendReport = z.infer<typeof FrontendReportSchema>;
283
307
 
284
308
  declare type FrontendReportColumns = z.infer<typeof FrontendReportColumnsSchema>;
@@ -443,8 +467,6 @@ declare const FrontendVisualizationSchema: z.ZodObject<{
443
467
  }, z.core.$strip>>;
444
468
  }, z.core.$strip>;
445
469
 
446
- export { GenerateInsightParam }
447
-
448
470
  export declare const InfiniteDataTableUI: React.FC<InfiniteDataTableUIProps>;
449
471
 
450
472
  declare type InfiniteDataTableUIProps = {
@@ -709,6 +731,27 @@ declare type StartOptions = DisplayControlProps & {
709
731
 
710
732
  declare type TableFilters = Record<string, string | number>;
711
733
 
734
+ /**
735
+ * Hook to fetch a canvas by its ID.
736
+ * @param canvasId - The UUID of the canvas to fetch
737
+ * @param options - Optional react-query options
738
+ * @returns Query result with the canvas data
739
+ * @example
740
+ * ```tsx
741
+ * const { data: canvas, isLoading } = useCanvas(canvasId);
742
+ * if (canvas) {
743
+ * console.log(canvas.title, canvas.is_public);
744
+ * }
745
+ * ```
746
+ */
747
+ export declare const useCanvas: (canvasId: string | undefined | null, options?: Omit<UseQueryOptions<FrontendCanvas, unknown>, "queryKey" | "queryFn">) => UseQueryResult< {
748
+ title: string | null;
749
+ id: string;
750
+ nodes: any[];
751
+ edges: any[];
752
+ is_public: boolean;
753
+ }, unknown>;
754
+
712
755
  export declare const useChatContext: () => ChatContextValue;
713
756
 
714
757
  export declare const useChatInputContext: () => ChatInputContextValue;
@@ -975,169 +1018,6 @@ export declare const useDownloadReportData: (options?: UseMutationOptions<Export
975
1018
  mutateAsync: UseMutateAsyncFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
976
1019
  };
977
1020
 
978
- export declare const useGenerateContextualInsight: (options?: UseMutationOptions<ExtractInsightResponse, Error, GenerateInsightParam>) => {
979
- generateInsight: UseMutateFunction< {
980
- type: "text";
981
- insight: string;
982
- } | {
983
- type: "missing";
984
- }, Error, GenerateInsightParam, unknown>;
985
- generateInsightAsync: UseMutateAsyncFunction< {
986
- type: "text";
987
- insight: string;
988
- } | {
989
- type: "missing";
990
- }, Error, GenerateInsightParam, unknown>;
991
- data: undefined;
992
- variables: undefined;
993
- error: null;
994
- isError: false;
995
- isIdle: true;
996
- isPending: false;
997
- isSuccess: false;
998
- status: "idle";
999
- mutate: UseMutateFunction< {
1000
- type: "text";
1001
- insight: string;
1002
- } | {
1003
- type: "missing";
1004
- }, Error, GenerateInsightParam, unknown>;
1005
- reset: () => void;
1006
- context: unknown;
1007
- failureCount: number;
1008
- failureReason: Error | null;
1009
- isPaused: boolean;
1010
- submittedAt: number;
1011
- mutateAsync: UseMutateAsyncFunction< {
1012
- type: "text";
1013
- insight: string;
1014
- } | {
1015
- type: "missing";
1016
- }, Error, GenerateInsightParam, unknown>;
1017
- } | {
1018
- generateInsight: UseMutateFunction< {
1019
- type: "text";
1020
- insight: string;
1021
- } | {
1022
- type: "missing";
1023
- }, Error, GenerateInsightParam, unknown>;
1024
- generateInsightAsync: UseMutateAsyncFunction< {
1025
- type: "text";
1026
- insight: string;
1027
- } | {
1028
- type: "missing";
1029
- }, Error, GenerateInsightParam, unknown>;
1030
- data: undefined;
1031
- variables: GenerateInsightParam;
1032
- error: null;
1033
- isError: false;
1034
- isIdle: false;
1035
- isPending: true;
1036
- isSuccess: false;
1037
- status: "pending";
1038
- mutate: UseMutateFunction< {
1039
- type: "text";
1040
- insight: string;
1041
- } | {
1042
- type: "missing";
1043
- }, Error, GenerateInsightParam, unknown>;
1044
- reset: () => void;
1045
- context: unknown;
1046
- failureCount: number;
1047
- failureReason: Error | null;
1048
- isPaused: boolean;
1049
- submittedAt: number;
1050
- mutateAsync: UseMutateAsyncFunction< {
1051
- type: "text";
1052
- insight: string;
1053
- } | {
1054
- type: "missing";
1055
- }, Error, GenerateInsightParam, unknown>;
1056
- } | {
1057
- generateInsight: UseMutateFunction< {
1058
- type: "text";
1059
- insight: string;
1060
- } | {
1061
- type: "missing";
1062
- }, Error, GenerateInsightParam, unknown>;
1063
- generateInsightAsync: UseMutateAsyncFunction< {
1064
- type: "text";
1065
- insight: string;
1066
- } | {
1067
- type: "missing";
1068
- }, Error, GenerateInsightParam, unknown>;
1069
- data: undefined;
1070
- error: Error;
1071
- variables: GenerateInsightParam;
1072
- isError: true;
1073
- isIdle: false;
1074
- isPending: false;
1075
- isSuccess: false;
1076
- status: "error";
1077
- mutate: UseMutateFunction< {
1078
- type: "text";
1079
- insight: string;
1080
- } | {
1081
- type: "missing";
1082
- }, Error, GenerateInsightParam, unknown>;
1083
- reset: () => void;
1084
- context: unknown;
1085
- failureCount: number;
1086
- failureReason: Error | null;
1087
- isPaused: boolean;
1088
- submittedAt: number;
1089
- mutateAsync: UseMutateAsyncFunction< {
1090
- type: "text";
1091
- insight: string;
1092
- } | {
1093
- type: "missing";
1094
- }, Error, GenerateInsightParam, unknown>;
1095
- } | {
1096
- generateInsight: UseMutateFunction< {
1097
- type: "text";
1098
- insight: string;
1099
- } | {
1100
- type: "missing";
1101
- }, Error, GenerateInsightParam, unknown>;
1102
- generateInsightAsync: UseMutateAsyncFunction< {
1103
- type: "text";
1104
- insight: string;
1105
- } | {
1106
- type: "missing";
1107
- }, Error, GenerateInsightParam, unknown>;
1108
- data: {
1109
- type: "text";
1110
- insight: string;
1111
- } | {
1112
- type: "missing";
1113
- };
1114
- error: null;
1115
- variables: GenerateInsightParam;
1116
- isError: false;
1117
- isIdle: false;
1118
- isPending: false;
1119
- isSuccess: true;
1120
- status: "success";
1121
- mutate: UseMutateFunction< {
1122
- type: "text";
1123
- insight: string;
1124
- } | {
1125
- type: "missing";
1126
- }, Error, GenerateInsightParam, unknown>;
1127
- reset: () => void;
1128
- context: unknown;
1129
- failureCount: number;
1130
- failureReason: Error | null;
1131
- isPaused: boolean;
1132
- submittedAt: number;
1133
- mutateAsync: UseMutateAsyncFunction< {
1134
- type: "text";
1135
- insight: string;
1136
- } | {
1137
- type: "missing";
1138
- }, Error, GenerateInsightParam, unknown>;
1139
- };
1140
-
1141
1021
  export declare const useMageMetricsApiUrl: () => string;
1142
1022
 
1143
1023
  export declare const useMageMetricsClient: () => MageMetricsClient;
@@ -8,7 +8,6 @@ import { ExternalAuthProvider } from '@magemetrics/core';
8
8
  import { ExternalAuthProviderConfig } from '@magemetrics/core';
9
9
  import { FetchNextPageOptions } from '@tanstack/react-query';
10
10
  import { ForwardRefExoticComponent } from 'react';
11
- import { GenerateInsightParam } from '@magemetrics/core';
12
11
  import { InfiniteData } from '@tanstack/react-query';
13
12
  import { InfiniteQueryObserverResult } from '@tanstack/react-query';
14
13
  import { MageMetricsClient } from '@magemetrics/core';
@@ -21,6 +20,7 @@ import { SortingState as SortingState_2 } from '@tanstack/react-table';
21
20
  import { UseMutateAsyncFunction } from '@tanstack/react-query';
22
21
  import { UseMutateFunction } from '@tanstack/react-query';
23
22
  import { UseMutationOptions } from '@tanstack/react-query';
23
+ import { UseQueryOptions } from '@tanstack/react-query';
24
24
  import { UseQueryResult } from '@tanstack/react-query';
25
25
  import { z } from 'zod';
26
26
 
@@ -53,6 +53,25 @@ export { AuthState }
53
53
  */
54
54
  export declare type BrandColors = PrimaryColorOption & SecondaryColorOption;
55
55
 
56
+ /**
57
+ * A standalone authenticated Canvas component that renders a canvas by its ID.
58
+ * This is useful for displaying saved canvases without the chat interface.
59
+ * @param root0 props for the component
60
+ * @param root0.canvasId The UUID of the canvas to display
61
+ * @returns the canvas component
62
+ * @example
63
+ * ```tsx
64
+ * import { Canvas } from "@magemetrics/ai";
65
+ *
66
+ * const SavedCanvasView = ({ canvasId }: { canvasId: string }) => {
67
+ * return <Canvas canvasId={canvasId} />;
68
+ * };
69
+ * ```
70
+ */
71
+ export declare const Canvas: React.FC<{
72
+ canvasId: string;
73
+ }>;
74
+
56
75
  export declare type CellContentProps = {
57
76
  formattedValue: FormattedData | undefined;
58
77
  unit?: string;
@@ -128,6 +147,10 @@ export declare interface Components {
128
147
  }) => default_2.ReactNode;
129
148
  avatar?: default_2.ReactNode;
130
149
  getCanvasShareableLink?: (canvasId: string) => string;
150
+ canvasPanelActions?: (props: {
151
+ canvas: FrontendCanvas;
152
+ flowId: string;
153
+ }) => default_2.ReactNode;
131
154
  }
132
155
 
133
156
  export declare const ConfigurableChat: ConfigurableChatComponent;
@@ -243,15 +266,6 @@ export { ExternalAuthProvider }
243
266
 
244
267
  export { ExternalAuthProviderConfig }
245
268
 
246
- declare type ExtractInsightResponse = z.infer<typeof ExtractInsightResponseSchema>;
247
-
248
- declare const ExtractInsightResponseSchema: z.ZodUnion<[z.ZodObject<{
249
- type: z.ZodLiteral<"text">;
250
- insight: z.ZodString;
251
- }, z.core.$strip>, z.ZodObject<{
252
- type: z.ZodLiteral<"missing">;
253
- }, z.core.$strip>]>;
254
-
255
269
  /**
256
270
  * This module handles the formatting and normalization of table cell values for display and sorting.
257
271
  *
@@ -279,6 +293,16 @@ declare type FormattedData = {
279
293
  sortValue: string | number | Date | null;
280
294
  };
281
295
 
296
+ declare type FrontendCanvas = z.infer<typeof FrontendCanvasSchema>;
297
+
298
+ declare const FrontendCanvasSchema: z.ZodObject<{
299
+ title: z.ZodNullable<z.ZodString>;
300
+ id: z.ZodUUID;
301
+ nodes: z.ZodArray<z.ZodAny>;
302
+ edges: z.ZodArray<z.ZodAny>;
303
+ is_public: z.ZodBoolean;
304
+ }, z.core.$strip>;
305
+
282
306
  declare type FrontendReport = z.infer<typeof FrontendReportSchema>;
283
307
 
284
308
  declare type FrontendReportColumns = z.infer<typeof FrontendReportColumnsSchema>;
@@ -443,8 +467,6 @@ declare const FrontendVisualizationSchema: z.ZodObject<{
443
467
  }, z.core.$strip>>;
444
468
  }, z.core.$strip>;
445
469
 
446
- export { GenerateInsightParam }
447
-
448
470
  export declare const InfiniteDataTableUI: React.FC<InfiniteDataTableUIProps>;
449
471
 
450
472
  declare type InfiniteDataTableUIProps = {
@@ -709,6 +731,27 @@ declare type StartOptions = DisplayControlProps & {
709
731
 
710
732
  declare type TableFilters = Record<string, string | number>;
711
733
 
734
+ /**
735
+ * Hook to fetch a canvas by its ID.
736
+ * @param canvasId - The UUID of the canvas to fetch
737
+ * @param options - Optional react-query options
738
+ * @returns Query result with the canvas data
739
+ * @example
740
+ * ```tsx
741
+ * const { data: canvas, isLoading } = useCanvas(canvasId);
742
+ * if (canvas) {
743
+ * console.log(canvas.title, canvas.is_public);
744
+ * }
745
+ * ```
746
+ */
747
+ export declare const useCanvas: (canvasId: string | undefined | null, options?: Omit<UseQueryOptions<FrontendCanvas, unknown>, "queryKey" | "queryFn">) => UseQueryResult< {
748
+ title: string | null;
749
+ id: string;
750
+ nodes: any[];
751
+ edges: any[];
752
+ is_public: boolean;
753
+ }, unknown>;
754
+
712
755
  export declare const useChatContext: () => ChatContextValue;
713
756
 
714
757
  export declare const useChatInputContext: () => ChatInputContextValue;
@@ -975,169 +1018,6 @@ export declare const useDownloadReportData: (options?: UseMutationOptions<Export
975
1018
  mutateAsync: UseMutateAsyncFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
976
1019
  };
977
1020
 
978
- export declare const useGenerateContextualInsight: (options?: UseMutationOptions<ExtractInsightResponse, Error, GenerateInsightParam>) => {
979
- generateInsight: UseMutateFunction< {
980
- type: "text";
981
- insight: string;
982
- } | {
983
- type: "missing";
984
- }, Error, GenerateInsightParam, unknown>;
985
- generateInsightAsync: UseMutateAsyncFunction< {
986
- type: "text";
987
- insight: string;
988
- } | {
989
- type: "missing";
990
- }, Error, GenerateInsightParam, unknown>;
991
- data: undefined;
992
- variables: undefined;
993
- error: null;
994
- isError: false;
995
- isIdle: true;
996
- isPending: false;
997
- isSuccess: false;
998
- status: "idle";
999
- mutate: UseMutateFunction< {
1000
- type: "text";
1001
- insight: string;
1002
- } | {
1003
- type: "missing";
1004
- }, Error, GenerateInsightParam, unknown>;
1005
- reset: () => void;
1006
- context: unknown;
1007
- failureCount: number;
1008
- failureReason: Error | null;
1009
- isPaused: boolean;
1010
- submittedAt: number;
1011
- mutateAsync: UseMutateAsyncFunction< {
1012
- type: "text";
1013
- insight: string;
1014
- } | {
1015
- type: "missing";
1016
- }, Error, GenerateInsightParam, unknown>;
1017
- } | {
1018
- generateInsight: UseMutateFunction< {
1019
- type: "text";
1020
- insight: string;
1021
- } | {
1022
- type: "missing";
1023
- }, Error, GenerateInsightParam, unknown>;
1024
- generateInsightAsync: UseMutateAsyncFunction< {
1025
- type: "text";
1026
- insight: string;
1027
- } | {
1028
- type: "missing";
1029
- }, Error, GenerateInsightParam, unknown>;
1030
- data: undefined;
1031
- variables: GenerateInsightParam;
1032
- error: null;
1033
- isError: false;
1034
- isIdle: false;
1035
- isPending: true;
1036
- isSuccess: false;
1037
- status: "pending";
1038
- mutate: UseMutateFunction< {
1039
- type: "text";
1040
- insight: string;
1041
- } | {
1042
- type: "missing";
1043
- }, Error, GenerateInsightParam, unknown>;
1044
- reset: () => void;
1045
- context: unknown;
1046
- failureCount: number;
1047
- failureReason: Error | null;
1048
- isPaused: boolean;
1049
- submittedAt: number;
1050
- mutateAsync: UseMutateAsyncFunction< {
1051
- type: "text";
1052
- insight: string;
1053
- } | {
1054
- type: "missing";
1055
- }, Error, GenerateInsightParam, unknown>;
1056
- } | {
1057
- generateInsight: UseMutateFunction< {
1058
- type: "text";
1059
- insight: string;
1060
- } | {
1061
- type: "missing";
1062
- }, Error, GenerateInsightParam, unknown>;
1063
- generateInsightAsync: UseMutateAsyncFunction< {
1064
- type: "text";
1065
- insight: string;
1066
- } | {
1067
- type: "missing";
1068
- }, Error, GenerateInsightParam, unknown>;
1069
- data: undefined;
1070
- error: Error;
1071
- variables: GenerateInsightParam;
1072
- isError: true;
1073
- isIdle: false;
1074
- isPending: false;
1075
- isSuccess: false;
1076
- status: "error";
1077
- mutate: UseMutateFunction< {
1078
- type: "text";
1079
- insight: string;
1080
- } | {
1081
- type: "missing";
1082
- }, Error, GenerateInsightParam, unknown>;
1083
- reset: () => void;
1084
- context: unknown;
1085
- failureCount: number;
1086
- failureReason: Error | null;
1087
- isPaused: boolean;
1088
- submittedAt: number;
1089
- mutateAsync: UseMutateAsyncFunction< {
1090
- type: "text";
1091
- insight: string;
1092
- } | {
1093
- type: "missing";
1094
- }, Error, GenerateInsightParam, unknown>;
1095
- } | {
1096
- generateInsight: UseMutateFunction< {
1097
- type: "text";
1098
- insight: string;
1099
- } | {
1100
- type: "missing";
1101
- }, Error, GenerateInsightParam, unknown>;
1102
- generateInsightAsync: UseMutateAsyncFunction< {
1103
- type: "text";
1104
- insight: string;
1105
- } | {
1106
- type: "missing";
1107
- }, Error, GenerateInsightParam, unknown>;
1108
- data: {
1109
- type: "text";
1110
- insight: string;
1111
- } | {
1112
- type: "missing";
1113
- };
1114
- error: null;
1115
- variables: GenerateInsightParam;
1116
- isError: false;
1117
- isIdle: false;
1118
- isPending: false;
1119
- isSuccess: true;
1120
- status: "success";
1121
- mutate: UseMutateFunction< {
1122
- type: "text";
1123
- insight: string;
1124
- } | {
1125
- type: "missing";
1126
- }, Error, GenerateInsightParam, unknown>;
1127
- reset: () => void;
1128
- context: unknown;
1129
- failureCount: number;
1130
- failureReason: Error | null;
1131
- isPaused: boolean;
1132
- submittedAt: number;
1133
- mutateAsync: UseMutateAsyncFunction< {
1134
- type: "text";
1135
- insight: string;
1136
- } | {
1137
- type: "missing";
1138
- }, Error, GenerateInsightParam, unknown>;
1139
- };
1140
-
1141
1021
  export declare const useMageMetricsApiUrl: () => string;
1142
1022
 
1143
1023
  export declare const useMageMetricsClient: () => MageMetricsClient;