@magemetrics/ai 0.0.40 → 0.0.42

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,34 +1,255 @@
1
- import { ComponentPropsWithoutRef } from 'react';
2
- import { JSX } from 'react/jsx-runtime';
1
+ import { default as default_2 } from 'react';
2
+ import { z } from '@hono/zod-openapi';
3
+
4
+ export declare class ApiService {
5
+ private client;
6
+ constructor(baseUrl: string);
7
+ getRecentFlows: (params: {
8
+ limit?: number;
9
+ }) => Promise<{
10
+ created_at: string;
11
+ id: string;
12
+ request: string;
13
+ user_id: string | null;
14
+ }[]>;
15
+ startFlow: (request: string) => Promise<string>;
16
+ }
17
+
18
+ export declare type CellContentProps = {
19
+ formattedValue: FormattedData | undefined;
20
+ isOpened: boolean;
21
+ unit?: string;
22
+ renderType?: string;
23
+ };
24
+
25
+ export declare interface Components {
26
+ dataTableCells?: {
27
+ [key: string]: (props: CellContentProps) => default_2.ReactNode;
28
+ };
29
+ dataReportTable?: (props: DataReportMessageProps) => default_2.ReactNode;
30
+ }
3
31
 
4
32
  declare type ControlledModalProps = {
5
33
  visible: boolean;
6
34
  onClose: () => void;
7
35
  };
8
36
 
37
+ export declare interface DataReportMessageProps {
38
+ report: FrontendFlowData;
39
+ isOpened: boolean;
40
+ setIsOpened: (opened: boolean) => void;
41
+ infiniteData: {
42
+ data?: {
43
+ pages: unknown[][];
44
+ };
45
+ isPending: boolean;
46
+ fetchNextPage: () => Promise<unknown>;
47
+ isFetching: boolean;
48
+ isFetchingNextPage: boolean;
49
+ hasNextPage: boolean | undefined;
50
+ };
51
+ columns: FrontendFlowColumns;
52
+ totalRows: number;
53
+ }
54
+
9
55
  declare type DisplayControlProps = {
10
56
  showRecommendations?: boolean;
11
57
  showRecentChats?: boolean;
12
58
  showBackdrop?: boolean;
13
59
  };
14
60
 
61
+ /**
62
+ * This module handles the formatting and normalization of table cell values for display and sorting.
63
+ *
64
+ * Problem:
65
+ * When displaying data in tables, we often receive values in various formats (strings, dates,
66
+ * JSON objects, etc.). We need to:
67
+ * 1. Display these values in a consistent, human-readable format
68
+ * 2. Enable proper sorting of these values regardless of their original format
69
+ *
70
+ * Solution:
71
+ * The FormattedData type and formatCellValue function transform any input value into a
72
+ * standardized format with two properties:
73
+ * - display: A string representation suitable for rendering
74
+ * - sortValue: A normalized value (string/number/date) suitable for consistent sorting
75
+ *
76
+ * The module handles various special cases:
77
+ * - JSON strings (parsing them to extract actual values)
78
+ * - Date/time values (converting to consistent format)
79
+ * - BigQuery-style objects with 'value' property
80
+ * - Nested objects (pretty-printing them)
81
+ * - Null/undefined values
82
+ */
83
+ declare type FormattedData = {
84
+ display: (string & {}) | "empty" | null;
85
+ sortValue: string | number | Date | null;
86
+ };
87
+
88
+ declare type FrontendFlowColumns = z.infer<typeof FrontendFlowColumnsSchema>;
89
+
90
+ declare const FrontendFlowColumnsSchema: z.ZodArray<z.ZodObject<{
91
+ name: z.ZodString;
92
+ data_type: z.ZodString;
93
+ } & {
94
+ dataType: z.ZodString;
95
+ renderType: z.ZodOptional<z.ZodString>;
96
+ unit: z.ZodOptional<z.ZodString>;
97
+ }, "strip", z.ZodTypeAny, {
98
+ name: string;
99
+ data_type: string;
100
+ dataType: string;
101
+ unit?: string | undefined;
102
+ renderType?: string | undefined;
103
+ }, {
104
+ name: string;
105
+ data_type: string;
106
+ dataType: string;
107
+ unit?: string | undefined;
108
+ renderType?: string | undefined;
109
+ }>, "many">;
110
+
111
+ declare type FrontendFlowData = z.infer<typeof FrontendFlowDataSchema>;
112
+
113
+ declare const FrontendFlowDataSchema: z.ZodObject<Omit<{
114
+ created_at: z.ZodString;
115
+ flow_id: z.ZodString;
116
+ id: z.ZodNumber;
117
+ is_sample: z.ZodBoolean;
118
+ schema: z.ZodString;
119
+ sql: z.ZodString;
120
+ table: z.ZodString;
121
+ title: z.ZodString;
122
+ data_sample: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
123
+ data_summary: z.ZodObject<{
124
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
125
+ position: z.ZodOptional<z.ZodNumber>;
126
+ data_type: z.ZodString;
127
+ null_count: z.ZodNullable<z.ZodNumber>;
128
+ unique_count: z.ZodNullable<z.ZodNumber>;
129
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
130
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
131
+ position: z.ZodOptional<z.ZodNumber>;
132
+ data_type: z.ZodString;
133
+ null_count: z.ZodNullable<z.ZodNumber>;
134
+ unique_count: z.ZodNullable<z.ZodNumber>;
135
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
136
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
137
+ position: z.ZodOptional<z.ZodNumber>;
138
+ data_type: z.ZodString;
139
+ null_count: z.ZodNullable<z.ZodNumber>;
140
+ unique_count: z.ZodNullable<z.ZodNumber>;
141
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
142
+ }, z.ZodTypeAny, "passthrough">>>;
143
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
144
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
145
+ position: z.ZodOptional<z.ZodNumber>;
146
+ data_type: z.ZodString;
147
+ null_count: z.ZodNullable<z.ZodNumber>;
148
+ unique_count: z.ZodNullable<z.ZodNumber>;
149
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
150
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
151
+ position: z.ZodOptional<z.ZodNumber>;
152
+ data_type: z.ZodString;
153
+ null_count: z.ZodNullable<z.ZodNumber>;
154
+ unique_count: z.ZodNullable<z.ZodNumber>;
155
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
156
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
157
+ position: z.ZodOptional<z.ZodNumber>;
158
+ data_type: z.ZodString;
159
+ null_count: z.ZodNullable<z.ZodNumber>;
160
+ unique_count: z.ZodNullable<z.ZodNumber>;
161
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
162
+ }, z.ZodTypeAny, "passthrough">>>;
163
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
164
+ columns: z.ZodRecord<z.ZodString, z.ZodObject<{
165
+ position: z.ZodOptional<z.ZodNumber>;
166
+ data_type: z.ZodString;
167
+ null_count: z.ZodNullable<z.ZodNumber>;
168
+ unique_count: z.ZodNullable<z.ZodNumber>;
169
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
170
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
171
+ position: z.ZodOptional<z.ZodNumber>;
172
+ data_type: z.ZodString;
173
+ null_count: z.ZodNullable<z.ZodNumber>;
174
+ unique_count: z.ZodNullable<z.ZodNumber>;
175
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
176
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
177
+ position: z.ZodOptional<z.ZodNumber>;
178
+ data_type: z.ZodString;
179
+ null_count: z.ZodNullable<z.ZodNumber>;
180
+ unique_count: z.ZodNullable<z.ZodNumber>;
181
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
182
+ }, z.ZodTypeAny, "passthrough">>>;
183
+ }, z.ZodTypeAny, "passthrough">>;
184
+ }, "schema" | "sql" | "table" | "created_at" | "is_sample" | "data_sample">, "strip", z.ZodTypeAny, {
185
+ title: string;
186
+ id: number;
187
+ flow_id: string;
188
+ data_summary: {
189
+ columns: Record<string, z.objectOutputType<{
190
+ position: z.ZodOptional<z.ZodNumber>;
191
+ data_type: z.ZodString;
192
+ null_count: z.ZodNullable<z.ZodNumber>;
193
+ unique_count: z.ZodNullable<z.ZodNumber>;
194
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
195
+ }, z.ZodTypeAny, "passthrough">>;
196
+ } & {
197
+ [k: string]: unknown;
198
+ };
199
+ }, {
200
+ title: string;
201
+ id: number;
202
+ flow_id: string;
203
+ data_summary: {
204
+ columns: Record<string, z.objectInputType<{
205
+ position: z.ZodOptional<z.ZodNumber>;
206
+ data_type: z.ZodString;
207
+ null_count: z.ZodNullable<z.ZodNumber>;
208
+ unique_count: z.ZodNullable<z.ZodNumber>;
209
+ unique_percentage: z.ZodNullable<z.ZodNumber>;
210
+ }, z.ZodTypeAny, "passthrough">>;
211
+ } & {
212
+ [k: string]: unknown;
213
+ };
214
+ }>;
215
+
15
216
  export declare const logout: () => Promise<void>;
16
217
 
17
- export declare const MageMetricsModal: (props: MageMetricsModalProps) => JSX.Element;
218
+ export declare const MageMetricsContextProvider: default_2.FC<MageMetricsContextProviderProps>;
219
+
220
+ export declare interface MageMetricsContextProviderProps {
221
+ children: default_2.ReactNode;
222
+ apiKey?: string;
223
+ externalJwt?: string;
224
+ apiUrl: string;
225
+ experimental_components?: Components;
226
+ }
18
227
 
19
- declare type MageMetricsModalProps = ComponentPropsWithoutRef<typeof MainModal>;
228
+ export declare const ManagedModal: React.FC<ManagedModalProps>;
20
229
 
21
- declare const MainModal: React.FC<{
230
+ declare interface ManagedModalProps extends ModalProps {
22
231
  apiKey: string;
23
232
  externalJwt: string;
24
233
  apiUrl: string;
25
- display?: string;
26
234
  persist?: PersistenceOptions;
235
+ experimental_components?: Components;
236
+ }
237
+
238
+ declare interface ModalProps {
239
+ display?: string;
27
240
  modal?: ControlledModalProps;
28
241
  startOptions?: StartOptions;
29
- }>;
242
+ }
243
+
244
+ declare type PersistenceOptions = "queryParam" | "none";
30
245
 
31
- declare type PersistenceOptions = "localStorage" | "queryParam" | "none";
246
+ export declare const StandaloneConversationModal: React.FC<StandaloneConversationModalProps>;
247
+
248
+ declare type StandaloneConversationModalProps = {
249
+ opened: boolean;
250
+ flowId: string;
251
+ onOpenChange?: (open: boolean) => void;
252
+ };
32
253
 
33
254
  declare type StartOptions = DisplayControlProps & {
34
255
  label?: string;
@@ -41,7 +262,7 @@ export { }
41
262
  declare module "react" {
42
263
  namespace JSX {
43
264
  interface IntrinsicElements {
44
- "magemetrics-ai": SearchElementAttributes;
265
+ "magemetrics-ai": ManagedModalProps;
45
266
  }
46
267
  }
47
268
  }