@magemetrics/ai 0.11.3 → 0.11.4

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,1090 +1,121 @@
1
- import { AuthProvider } from '@magemetrics/core';
2
- import { AuthState } from '@magemetrics/core';
3
- import { CreateFlowParam } from '@magemetrics/core';
4
- import { default as default_2 } from 'react';
5
- import { DirectAuthProvider } from '@magemetrics/core';
6
- import { ExternalAuthProvider } from '@magemetrics/core';
7
- import { ExternalAuthProviderConfig } from '@magemetrics/core';
8
- import { FetchNextPageOptions } from '@tanstack/react-query';
9
- import { ForwardRefExoticComponent } from 'react';
10
- import { InfiniteData } from '@tanstack/react-query';
11
- import { InfiniteQueryObserverResult } from '@tanstack/react-query';
12
- import { JSX } from 'react/jsx-runtime';
13
- import { MageMetricsClient } from '@magemetrics/core';
14
- import { MageMetricsClientConfig } from '@magemetrics/core';
15
- import { PropsWithChildren } from 'react';
16
- import { QueryObserverResult } from '@tanstack/react-query';
17
- import { RefAttributes } from 'react';
18
- import { RefetchOptions } from '@tanstack/react-query';
19
- import { SortingState as SortingState_2 } from '@tanstack/react-table';
20
- import { UseMutateAsyncFunction } from '@tanstack/react-query';
21
- import { UseMutateFunction } from '@tanstack/react-query';
22
- import { UseMutationOptions } from '@tanstack/react-query';
23
- import { UseQueryOptions } from '@tanstack/react-query';
24
- import { UseQueryResult } from '@tanstack/react-query';
25
- import { z } from 'zod';
26
-
27
- /**
28
- * Appearance configuration for visual customization of the `@magemetrics/ai` package.
29
- */
30
- export declare type AppearanceConfig = {
31
- /**
32
- * Brand colors used throughout the UI (buttons, accents, interactive elements).
33
- */
34
- colors?: BrandColors;
35
- /**
36
- * Modal-specific appearance settings.
37
- */
38
- modal?: ModalAppearance;
39
- };
40
-
41
- declare type AssemblyAIMicrophoneController = {
42
- status: "idle" | "starting" | "recording";
43
- startRecording: (onTranscript: (text: string) => void) => Promise<void>;
44
- stopRecording: () => Promise<void>;
45
- };
46
-
47
- export { AuthProvider }
48
-
49
- export { AuthState }
50
-
51
- /**
52
- * Brand colors configuration for the appearance prop.
53
- */
54
- export declare type BrandColors = PrimaryColorOption & SecondaryColorOption;
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
-
75
- export declare type CellContentProps = {
76
- formattedValue: FormattedData | undefined;
77
- unit?: string;
78
- renderType?: string;
79
- };
80
-
81
- export declare const Chat: React.FC<PublicChatProps>;
82
-
83
- declare const Chat_2: ChatComponent;
84
-
85
- declare interface ChatComponent extends default_2.MemoExoticComponent<(props: ChatProps) => default_2.JSX.Element> {
86
- Messages: typeof MessagesContainer;
87
- Input: typeof InputContainer & {
88
- Default: typeof ChatInputDefault;
89
- };
90
- }
91
-
92
- export declare interface ChatContextValue {
93
- flowId: string | undefined | null;
94
- enableSpeechToText?: boolean;
95
- }
96
-
97
- /**
98
- * Optional provider that allows the host application to pass dynamic runtime hints
99
- * to the chat. The hints are sent with every message and injected ephemerally into
100
- * the LLM prompt — they are not persisted or shown in the UI.
101
- * Place this anywhere inside `MageMetricsContextProvider` and around the `Chat` component.
102
- * When the `value` prop changes, the next message sent will carry the updated hints.
103
- * If this provider is not used, no hints are sent — everything works as before.
104
- * @param props - The provider props
105
- * @param props.value - The chat hints value to provide
106
- * @param props.children - The child components
107
- * @returns The provider component wrapping children
108
- */
109
- export declare const ChatHintsProvider: default_2.FC<ChatHintsProviderProps>;
110
-
111
- declare interface ChatHintsProviderProps {
112
- /**
113
- * Arbitrary key-value hints from the host application.
114
- * These are sent alongside every chat message and injected into the LLM prompt.
115
- * @example
116
- * ```tsx
117
- * <ChatHintsProvider value={{
118
- * selectedLocation: { lat: 48.8566, lng: 2.3522, name: "Paris" },
119
- * activeFilters: ["revenue > 1M"],
120
- * }}>
121
- * <Chat flowId="..." />
122
- * </ChatHintsProvider>
123
- * ```
124
- */
125
- value: ChatHintsValue;
126
- children: default_2.ReactNode;
127
- }
128
-
129
- /**
130
- * The value type for chat hints — a free-form key-value object
131
- * that the host application can use to pass runtime information to the LLM.
132
- * These hints are injected ephemerally into each chat message (not persisted)
133
- * so the LLM is aware of the host application's current state.
134
- */
135
- export declare type ChatHintsValue = Record<string, unknown>;
136
-
137
- export declare interface ChatInputContextValue {
138
- flowId: string | undefined;
139
- isLoading: boolean;
140
- isStreaming: boolean;
141
- isError: boolean;
142
- isAwaitingUserAnswer: boolean;
143
- onRetry?: () => void;
144
- onStop?: () => void;
145
- sendMessage: (text: string, isEditing: boolean) => void;
146
- lastUserMessage?: string;
147
- enableSpeechToText?: boolean;
148
- }
149
-
150
- declare const ChatInputDefault: default_2.FC;
151
-
152
- declare interface ChatProps {
153
- flowId: string | undefined | null;
154
- enableSpeechToText?: boolean;
155
- children?: default_2.ReactNode;
156
- }
157
-
158
- declare interface ColumnSort {
159
- desc: boolean;
160
- id: string;
161
- }
162
-
163
- export declare interface Components {
164
- dataTableCells?: {
165
- empty?: (props: CellContentProps) => default_2.ReactNode;
166
- units?: {
167
- [key: string]: (props: CellContentProps) => default_2.ReactNode;
168
- };
169
- renderTypes?: {
170
- [key: string]: (props: CellContentProps) => default_2.ReactNode;
171
- };
172
- };
173
- dataReportTable?: (props: {
174
- report: Report_2;
175
- }) => default_2.ReactNode;
176
- dataReportMessageActions?: (props: {
177
- report: Report_2;
178
- isSelected: boolean;
179
- }) => default_2.ReactNode;
180
- visualizationMessageActions?: (props: {
181
- visualization: FrontendVisualization | V1FrontendVisualization;
182
- isSelected: boolean;
183
- }) => default_2.ReactNode;
184
- dataReportPanelActions?: (props: {
185
- report: Report_2;
186
- }) => default_2.ReactNode;
187
- visualizationPanelActions?: (props: {
188
- visualization: FrontendVisualization | V1FrontendVisualization;
189
- }) => default_2.ReactNode;
190
- avatar?: default_2.ReactNode;
191
- getCanvasShareableLink?: (canvasId: string) => string;
192
- canvasPanelActions?: (props: {
193
- canvas: FrontendCanvas;
194
- flowId: string;
195
- }) => default_2.ReactNode;
196
- }
197
-
198
- export declare const ConfigurableChat: ConfigurableChatComponent;
199
-
200
- declare interface ConfigurableChatComponent extends default_2.FC<ConfigurableChatComponentProps> {
201
- Messages: typeof Chat_2.Messages;
202
- Input: typeof Chat_2.Input;
203
- }
204
-
205
- declare type ConfigurableChatComponentProps = {
206
- flowId: string | undefined | null;
207
- enableSpeechToText?: boolean;
208
- disableCanvas?: boolean;
209
- children?: default_2.ReactNode;
210
- /**
211
- * Appearance configuration for customizing the visual style.
212
- * Includes brand colors and modal-specific styling options.
213
- */
214
- appearance?: AppearanceConfig;
215
- };
216
-
217
- /** @deprecated This type is no longer used and will be removed in a future version. */
218
- declare type ControlledModalProps = {
219
- visible: boolean;
220
- onClose: () => void;
221
- };
222
-
223
- declare interface ConversationContentProps {
224
- flowId?: string;
225
- className?: string;
226
- style?: React.CSSProperties;
227
- topBar?: React.ReactNode;
228
- disableCanvas?: boolean;
229
- enableSpeechToText?: boolean;
230
- children?: React.ReactNode;
231
- }
232
-
233
- export { CreateFlowParam }
234
-
235
- export declare const DataTable: () => JSX.Element;
236
-
237
- declare type DataTableState = {
238
- pageIndex?: number;
239
- sorting?: SortingState;
240
- filters?: TableFilters;
241
- pageSize?: number;
242
- };
243
-
244
- export { DirectAuthProvider }
245
-
246
- declare type DisplayControlProps = {
247
- /** Whether to display the recommendations section when the input is active */
248
- showRecommendations?: boolean;
249
- /** Whether to display recent chats when the input is active */
250
- showRecentChats?: boolean;
251
- /** Whether to display a backdrop overlay when the input is active */
252
- showBackdrop?: boolean;
253
- };
254
-
255
- export declare const DomWrapper: React.FC<PropsWithChildren<DomWrapperProps>>;
256
-
257
- declare type DomWrapperProps = InternalColorSwatchProps;
258
-
259
- declare type ExportReportDataParams = {
260
- reportId: number;
261
- filename?: string;
262
- format?: "text" | "blob";
263
- };
264
-
265
- declare type ExportReportDataResult = {
266
- filename: string;
267
- data: Blob | string;
268
- };
269
-
270
- export { ExternalAuthProvider }
271
-
272
- export { ExternalAuthProviderConfig }
273
-
274
- /**
275
- * This module handles the formatting and normalization of table cell values for display and sorting.
276
- *
277
- * Problem:
278
- * When displaying data in tables, we often receive values in various formats (strings, dates,
279
- * JSON objects, etc.). We need to:
280
- * 1. Display these values in a consistent, human-readable format
281
- * 2. Enable proper sorting of these values regardless of their original format
282
- *
283
- * Solution:
284
- * The FormattedData type and formatCellValue function transform any input value into a
285
- * standardized format with two properties:
286
- * - display: A string representation suitable for rendering
287
- * - sortValue: A normalized value (string/number/date) suitable for consistent sorting
288
- *
289
- * The module handles various special cases:
290
- * - JSON strings (parsing them to extract actual values)
291
- * - Date/time values (converting to consistent format)
292
- * - BigQuery-style objects with 'value' property
293
- * - Nested objects (pretty-printing them)
294
- * - Null/undefined values
295
- */
296
- declare type FormattedData = {
297
- display: (string & {}) | "empty" | null;
298
- sortValue: string | number | Date | null;
299
- };
300
-
301
- declare type FrontendCanvas = z.infer<typeof FrontendCanvasSchema>;
302
-
303
- declare const FrontendCanvasSchema: z.ZodObject<{
304
- title: z.ZodNullable<z.ZodString>;
305
- id: z.ZodUUID;
306
- nodes: z.ZodArray<z.ZodAny>;
307
- edges: z.ZodArray<z.ZodAny>;
308
- is_public: z.ZodBoolean;
309
- }, z.core.$strip>;
310
-
311
- declare const FrontendReportSchema: z.ZodObject<{
312
- status: z.ZodNullable<z.ZodString>;
313
- title: z.ZodString;
314
- id: z.ZodNumber;
315
- request: z.ZodNullable<z.ZodString>;
316
- created_at: z.ZodString;
317
- data_summary: z.ZodObject<{
318
- columns: z.ZodRecord<z.ZodString, z.ZodObject<{
319
- position: z.ZodOptional<z.ZodNumber>;
320
- data_type: z.ZodString;
321
- null_count: z.ZodNullable<z.ZodNumber>;
322
- unique_count: z.ZodNullable<z.ZodNumber>;
323
- unique_percentage: z.ZodNullable<z.ZodNumber>;
324
- min_value: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
325
- max_value: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
326
- avg_value: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
327
- median_value: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
328
- std_value: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
329
- min_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
330
- max_date: z.ZodOptional<z.ZodNullable<z.ZodString>>;
331
- min_length: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
332
- max_length: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
333
- avg_length: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
334
- }, z.core.$loose>>;
335
- }, z.core.$loose>;
336
- flow_id: z.ZodString;
337
- is_removed: z.ZodBoolean;
338
- is_materialized: z.ZodNullable<z.ZodBoolean>;
339
- last_materialized_at: z.ZodNullable<z.ZodString>;
340
- materialized_error_message: z.ZodNullable<z.ZodString>;
341
- materialized_status: z.ZodNullable<z.ZodEnum<{
342
- completed: "completed";
343
- failed: "failed";
344
- running: "running";
345
- }>>;
346
- }, z.core.$strip>;
347
-
348
- declare type FrontendVisualization = z.output<typeof FrontendVisualizationSchema>;
349
-
350
- declare const FrontendVisualizationSchema: z.ZodObject<{
351
- id: z.ZodNumber;
352
- configuration: z.ZodDiscriminatedUnion<[z.ZodObject<{
353
- config_version: z.ZodLiteral<2>;
354
- xAxisLabel: z.ZodString;
355
- yAxisLabel: z.ZodString;
356
- categoryColumn: z.ZodString;
357
- secondaryCategoryColumn: z.ZodOptional<z.ZodString>;
358
- valueColumn: z.ZodString;
359
- title: z.ZodString;
360
- type: z.ZodLiteral<"bar">;
361
- }, z.core.$strip>, z.ZodObject<{
362
- xAxisColumn: z.ZodString;
363
- valueColumns: z.ZodArray<z.ZodString>;
364
- yAxisLabels: z.ZodArray<z.ZodString>;
365
- title: z.ZodString;
366
- type: z.ZodLiteral<"line/area">;
367
- config_version: z.ZodLiteral<2>;
368
- }, z.core.$strip>, z.ZodObject<{
369
- config_version: z.ZodLiteral<2>;
370
- valueColumn: z.ZodString;
371
- xAxisColumn: z.ZodString;
372
- xAxisLabel: z.ZodString;
373
- yAxisLabel: z.ZodString;
374
- categoryColumn: z.ZodString;
375
- title: z.ZodString;
376
- type: z.ZodLiteral<"line/area-categorical">;
377
- }, z.core.$strip>, z.ZodObject<{
378
- config_version: z.ZodLiteral<2>;
379
- xAxisLabel: z.ZodString;
380
- yAxisLabel: z.ZodString;
381
- xAxisValueColumn: z.ZodString;
382
- yAxisValueColumn: z.ZodString;
383
- title: z.ZodString;
384
- type: z.ZodLiteral<"scatter">;
385
- }, z.core.$strip>, z.ZodObject<{
386
- config_version: z.ZodLiteral<2>;
387
- categoryColumn: z.ZodString;
388
- valueColumn: z.ZodString;
389
- title: z.ZodString;
390
- type: z.ZodLiteral<"pie">;
391
- }, z.core.$strip>], "type">;
392
- created_at: z.ZodString;
393
- flow_data: z.ZodOptional<z.ZodObject<{
394
- is_materialized: z.ZodNullable<z.ZodBoolean>;
395
- last_materialized_at: z.ZodNullable<z.ZodString>;
396
- materialized_error_message: z.ZodNullable<z.ZodString>;
397
- materialized_status: z.ZodNullable<z.ZodEnum<{
398
- completed: "completed";
399
- failed: "failed";
400
- running: "running";
401
- }>>;
402
- }, z.core.$strip>>;
403
- flow_data_id: z.ZodNumber;
404
- }, z.core.$strip>;
405
-
406
- declare const InputContainer: default_2.FC<{
407
- children?: default_2.ReactNode | ((context: ChatInputContextValue) => default_2.ReactNode);
408
- }>;
409
-
410
- /**
411
- * Internal/relaxed type for passing color props through component trees.
412
- * Use this for internal components; use ColorSwatchOptions for external APIs.
413
- */
414
- declare type InternalColorSwatchProps = {
415
- primaryColor?: string;
416
- primarySwatch?: PrimaryColorSwatch;
417
- secondaryColor?: string;
418
- secondarySwatch?: SecondaryColorSwatch;
419
- };
420
-
421
- export declare const logout: () => void;
422
-
423
- export { MageMetricsClient }
424
-
425
- export { MageMetricsClientConfig }
426
-
427
- export declare const MageMetricsContextProvider: default_2.FC<MageMetricsContextProviderProps>;
428
-
429
- export declare type MageMetricsContextProviderProps = {
430
- children: default_2.ReactNode;
431
- components?: Components;
432
- } & ({
433
- /** Provide an external MageMetricsClient instance. */
434
- client: MageMetricsClient;
435
- apiKey?: never;
436
- apiUrl?: never;
437
- externalJwt?: never;
438
- additionalHeaders?: never;
439
- applicationName?: never;
440
- } | ({
441
- /** Configuration to create a new MageMetricsClient. */
442
- client?: never;
443
- } & MageMetricsClientConfig));
444
-
445
- export declare const MageMetricsPublicContextProvider: React.FC<MageMetricsPublicContextProviderProps>;
446
-
447
- declare type MageMetricsPublicContextProviderProps = PropsWithChildren<Pick<MageMetricsClientConfig, "apiUrl" | "apiKey"> & {
448
- components?: Components;
449
- }>;
450
-
451
- export declare const ManagedModal: React.FC<ManagedModalProps>;
452
-
453
- declare type ManagedModalBaseProps = ModalProps & {
454
- /** API key for authenticating with the MageMetrics service */
455
- apiKey: string;
456
- /** External JWT token for user authentication */
457
- externalJwt: string;
458
- /** Base URL for the MageMetrics API */
459
- apiUrl: string;
460
- /** Whether to disable canvas functionality in conversations */
461
- disableCanvas?: boolean;
462
- /** Whether to render data freshness info in the conversation header */
463
- showDataFreshness?: boolean;
464
- /** Where to persist modal state (localStorage, queryParam, or none) */
465
- persist?: PersistenceOptions;
466
- /** Custom component overrides for extending functionality */
467
- components?: Components;
468
- /** Application name to associate with flows created through this modal */
469
- applicationName?: string;
470
- /**
471
- * Appearance configuration for customizing the visual style.
472
- * Includes brand colors and modal-specific styling options.
473
- */
474
- appearance?: AppearanceConfig;
475
- /** Callbacks for various events */
476
- callbacks?: {
477
- /** Callback fired when the conversation modal is opened */
478
- onConversationOpen?: () => void;
479
- };
480
- };
481
-
482
- /**
483
- * Props for ManagedModal component.
484
- */
485
- declare type ManagedModalProps = ManagedModalBaseProps;
486
-
487
- declare const MessagesContainer: default_2.FC;
488
-
489
- /**
490
- * Modal-specific appearance configuration.
491
- */
492
- export declare type ModalAppearance = {
493
- /**
494
- * Primary color for modal background gradient.
495
- * Used to customize the mesh gradient background in conversation modals.
496
- * Can be any CSS color (hex, rgb, hsl, oklch, etc.).
497
- */
498
- backgroundPrimary?: string;
499
- };
500
-
501
- declare interface ModalProps {
502
- /**
503
- * @deprecated This prop is no longer used and will be removed in a future version.
504
- * Control modal visibility and close behavior externally
505
- */
506
- modal?: ControlledModalProps;
507
- /** Configuration options for the start modal (chat launcher, recommendations, etc.) */
508
- startOptions?: StartOptions;
509
- }
510
-
511
- declare type PersistenceOptions = "queryParam" | "none";
512
-
513
- /**
514
- * Primary color shade stops used in the UI.
515
- */
516
- declare const PRIMARY_SHADE_STOPS: readonly ["50", "400", "500", "600", "650", "750", "900"];
517
-
518
- /**
519
- * Primary color options - mutually exclusive: use either primaryColor OR primarySwatch, not both.
520
- */
521
- declare type PrimaryColorOption = {
522
- primaryColor: string;
523
- primarySwatch?: never;
524
- } | {
525
- primaryColor?: never;
526
- primarySwatch: PrimaryColorSwatch;
527
- } | {
528
- primaryColor?: never;
529
- primarySwatch?: never;
530
- };
531
-
532
- declare type PrimaryColorShade = (typeof PRIMARY_SHADE_STOPS)[number];
533
-
534
- /** Complete primary swatch (7 shades required) */
535
- export declare type PrimaryColorSwatch = Record<PrimaryColorShade, string>;
536
-
537
- export declare const PublicCanvas: React.FC<React.ComponentProps<typeof PublicCanvasPanel>>;
538
-
539
- declare const PublicCanvasPanel: default_2.FC<{
540
- canvasId: string;
541
- }>;
542
-
543
- export declare type PublicChatProps = Omit<ConversationContentProps, "children"> & {
544
- /**
545
- * Appearance configuration for customizing the visual style.
546
- * Includes brand colors and modal-specific styling options.
547
- */
548
- appearance?: AppearanceConfig;
549
- };
550
-
551
- declare type Report_2 = z.infer<typeof FrontendReportSchema>;
552
- export { Report_2 as Report }
553
-
554
- declare type ReportDataFilters = {
555
- columns?: string[];
556
- limit: number;
557
- sorting: SortingState;
558
- filters: TableFilters;
559
- cursor?: number;
560
- };
561
-
562
- /**
563
- * Secondary color shade stops used in the UI.
564
- */
565
- declare const SECONDARY_SHADE_STOPS: readonly ["500", "600", "700"];
566
-
567
- /**
568
- * Secondary color options - mutually exclusive: use either secondaryColor OR secondarySwatch, not both.
569
- */
570
- declare type SecondaryColorOption = {
571
- secondaryColor: string;
572
- secondarySwatch?: never;
573
- } | {
574
- secondaryColor?: never;
575
- secondarySwatch: SecondaryColorSwatch;
576
- } | {
577
- secondaryColor?: never;
578
- secondarySwatch?: never;
579
- };
580
-
581
- declare type SecondaryColorShade = (typeof SECONDARY_SHADE_STOPS)[number];
582
-
583
- /** Complete secondary swatch (3 shades required) */
584
- export declare type SecondaryColorSwatch = Record<SecondaryColorShade, string>;
585
-
586
- declare type SortingState = ColumnSort[];
587
-
588
- export declare const StandaloneConversationModal: default_2.FC<StandaloneConversationModalProps>;
589
-
590
- declare type StandaloneConversationModalProps = {
591
- opened: boolean;
592
- flowId: string;
593
- disableCanvas?: boolean;
594
- showDataFreshness?: boolean;
595
- onOpenChange?: (open: boolean) => void;
596
- appearance?: AppearanceConfig;
597
- };
598
-
599
- /**
600
- * This component is not bounded in height and must be wrapped in a container to properly work
601
- * @param props - props
602
- * @param props.report - The report to display
603
- * @param props.initialState - Initial state for the report
604
- * @param props.onStateChange - Callback function to handle state changes
605
- * @returns JSX.Element
606
- */
607
- export declare const StandaloneDataTable: React.FC<{
608
- report: Report_2;
609
- initialState?: DataTableState;
610
- onStateChange?: (state: DataTableState) => void;
611
- }>;
612
-
613
- declare type StartOptions = DisplayControlProps & {
614
- /** Label text displayed above the chat launcher input */
615
- label?: string;
616
- /** Label text displayed above the recommendations section */
617
- recommendationsLabel?: string;
618
- /** Whether the chat launcher input should auto-focus on mount */
619
- autoFocus?: boolean;
620
- /** Whether speech-to-text controls should be shown */
621
- enableSpeechToText?: boolean;
622
- };
623
-
624
- declare type TableFilters = Record<string, TableFilterValue>;
625
-
626
- declare type TableFilterValue = z.infer<typeof TableFilterValueSchema>;
627
-
628
- declare const TableFilterValueSchema: z.ZodObject<{
629
- operator: z.ZodEnum<{
630
- contains: "contains";
631
- eq: "eq";
632
- gt: "gt";
633
- gte: "gte";
634
- lt: "lt";
635
- lte: "lte";
636
- endsWith: "endsWith";
637
- startsWith: "startsWith";
638
- neq: "neq";
639
- regex: "regex";
640
- between: "between";
641
- }>;
642
- value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
643
- }, z.core.$strip>;
644
-
645
- /**
646
- * Hook to fetch a canvas by its ID.
647
- * @param canvasId - The UUID of the canvas to fetch
648
- * @param options - Optional react-query options
649
- * @returns Query result with the canvas data
650
- * @example
651
- * ```tsx
652
- * const { data: canvas, isLoading } = useCanvas(canvasId);
653
- * if (canvas) {
654
- * console.log(canvas.title, canvas.is_public);
655
- * }
656
- * ```
657
- */
658
- export declare const useCanvas: (canvasId: string | undefined | null, options?: Omit<UseQueryOptions<FrontendCanvas, unknown>, "queryKey" | "queryFn">) => UseQueryResult< {
659
- title: string | null;
660
- id: string;
661
- nodes: any[];
662
- edges: any[];
663
- is_public: boolean;
664
- }, unknown>;
665
-
666
- export declare const useChatContext: () => ChatContextValue;
667
-
668
- /**
669
- * Returns the current chat hints value, or `null` if no `ChatHintsProvider` is present.
670
- * @returns The current chat hints value or null
671
- */
672
- export declare const useChatHints: () => ChatHintsValue | null;
673
-
674
- export declare const useChatInputContext: () => ChatInputContextValue;
675
-
676
- export declare const useCreateFlow: (options?: UseMutationOptions<{
677
- flowId: string;
678
- }, Error, CreateFlowParam>) => {
679
- createFlow: UseMutateFunction< {
680
- flowId: string;
681
- }, Error, CreateFlowParam, unknown>;
682
- createFlowAsync: UseMutateAsyncFunction< {
683
- flowId: string;
684
- }, Error, CreateFlowParam, unknown>;
685
- isCreatingFlow: boolean;
686
- data: undefined;
687
- variables: undefined;
688
- error: null;
689
- isError: false;
690
- isIdle: true;
691
- isPending: false;
692
- isSuccess: false;
693
- status: "idle";
694
- mutate: UseMutateFunction< {
695
- flowId: string;
696
- }, Error, CreateFlowParam, unknown>;
697
- reset: () => void;
698
- context: unknown;
699
- failureCount: number;
700
- failureReason: Error | null;
701
- isPaused: boolean;
702
- submittedAt: number;
703
- mutateAsync: UseMutateAsyncFunction< {
704
- flowId: string;
705
- }, Error, CreateFlowParam, unknown>;
706
- } | {
707
- createFlow: UseMutateFunction< {
708
- flowId: string;
709
- }, Error, CreateFlowParam, unknown>;
710
- createFlowAsync: UseMutateAsyncFunction< {
711
- flowId: string;
712
- }, Error, CreateFlowParam, unknown>;
713
- isCreatingFlow: boolean;
714
- data: undefined;
715
- variables: CreateFlowParam;
716
- error: null;
717
- isError: false;
718
- isIdle: false;
719
- isPending: true;
720
- isSuccess: false;
721
- status: "pending";
722
- mutate: UseMutateFunction< {
723
- flowId: string;
724
- }, Error, CreateFlowParam, unknown>;
725
- reset: () => void;
726
- context: unknown;
727
- failureCount: number;
728
- failureReason: Error | null;
729
- isPaused: boolean;
730
- submittedAt: number;
731
- mutateAsync: UseMutateAsyncFunction< {
732
- flowId: string;
733
- }, Error, CreateFlowParam, unknown>;
734
- } | {
735
- createFlow: UseMutateFunction< {
736
- flowId: string;
737
- }, Error, CreateFlowParam, unknown>;
738
- createFlowAsync: UseMutateAsyncFunction< {
739
- flowId: string;
740
- }, Error, CreateFlowParam, unknown>;
741
- isCreatingFlow: boolean;
742
- data: undefined;
743
- error: Error;
744
- variables: CreateFlowParam;
745
- isError: true;
746
- isIdle: false;
747
- isPending: false;
748
- isSuccess: false;
749
- status: "error";
750
- mutate: UseMutateFunction< {
751
- flowId: string;
752
- }, Error, CreateFlowParam, unknown>;
753
- reset: () => void;
754
- context: unknown;
755
- failureCount: number;
756
- failureReason: Error | null;
757
- isPaused: boolean;
758
- submittedAt: number;
759
- mutateAsync: UseMutateAsyncFunction< {
760
- flowId: string;
761
- }, Error, CreateFlowParam, unknown>;
762
- } | {
763
- createFlow: UseMutateFunction< {
764
- flowId: string;
765
- }, Error, CreateFlowParam, unknown>;
766
- createFlowAsync: UseMutateAsyncFunction< {
767
- flowId: string;
768
- }, Error, CreateFlowParam, unknown>;
769
- isCreatingFlow: boolean;
770
- data: {
771
- flowId: string;
772
- };
773
- error: null;
774
- variables: CreateFlowParam;
775
- isError: false;
776
- isIdle: false;
777
- isPending: false;
778
- isSuccess: true;
779
- status: "success";
780
- mutate: UseMutateFunction< {
781
- flowId: string;
782
- }, Error, CreateFlowParam, unknown>;
783
- reset: () => void;
784
- context: unknown;
785
- failureCount: number;
786
- failureReason: Error | null;
787
- isPaused: boolean;
788
- submittedAt: number;
789
- mutateAsync: UseMutateAsyncFunction< {
790
- flowId: string;
791
- }, Error, CreateFlowParam, unknown>;
792
- };
793
-
794
- export declare const useDataReportColumnValue: (reportId: number, filters: ReportDataFilters) => UseQueryResult< {
795
- [x: string]: unknown;
796
- }[], Error>;
797
-
798
- export declare const useDataTableContext: () => {
799
- report: {
800
- status: string | null;
801
- title: string;
802
- id: number;
803
- request: string | null;
804
- created_at: string;
805
- data_summary: {
806
- [x: string]: unknown;
807
- columns: Record<string, {
808
- [x: string]: unknown;
809
- data_type: string;
810
- null_count: number | null;
811
- unique_count: number | null;
812
- unique_percentage: number | null;
813
- position?: number | undefined;
814
- min_value?: number | null | undefined;
815
- max_value?: number | null | undefined;
816
- avg_value?: number | null | undefined;
817
- median_value?: number | null | undefined;
818
- std_value?: number | null | undefined;
819
- min_date?: string | null | undefined;
820
- max_date?: string | null | undefined;
821
- min_length?: number | null | undefined;
822
- max_length?: number | null | undefined;
823
- avg_length?: number | null | undefined;
824
- }>;
825
- };
826
- flow_id: string;
827
- is_removed: boolean;
828
- is_materialized: boolean | null;
829
- last_materialized_at: string | null;
830
- materialized_error_message: string | null;
831
- materialized_status: "completed" | "running" | "failed" | null;
832
- };
833
- fetchNextPage: (options?: FetchNextPageOptions) => Promise<InfiniteQueryObserverResult<InfiniteData< {
834
- [x: string]: unknown;
835
- }[], unknown>, Error>>;
836
- pages: {
837
- [x: string]: unknown;
838
- }[][] | undefined;
839
- columns: {
840
- name: string;
841
- data_type: string;
842
- dataType: string;
843
- renderType?: string | undefined;
844
- unit?: string | undefined;
845
- canonicalDataType?: "numeric" | "boolean" | "datetime" | "text" | "array" | "json" | "other" | undefined;
846
- }[] | undefined;
847
- isPendingColumns: boolean;
848
- hasMoreData: boolean;
849
- isFetching: boolean;
850
- isPendingData: boolean;
851
- totalRows: number | undefined;
852
- totalPages: number | undefined;
853
- sorting: SortingState_2;
854
- filters: TableFilters;
855
- };
856
-
857
- export declare const useDownloadReportData: (options?: UseMutationOptions<ExportReportDataResult, Error, ExportReportDataParams>) => {
858
- download: UseMutateFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
859
- data: undefined;
860
- variables: undefined;
861
- error: null;
862
- isError: false;
863
- isIdle: true;
864
- isPending: false;
865
- isSuccess: false;
866
- status: "idle";
867
- mutate: UseMutateFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
868
- reset: () => void;
869
- context: unknown;
870
- failureCount: number;
871
- failureReason: Error | null;
872
- isPaused: boolean;
873
- submittedAt: number;
874
- mutateAsync: UseMutateAsyncFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
875
- } | {
876
- download: UseMutateFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
877
- data: undefined;
878
- variables: ExportReportDataParams;
879
- error: null;
880
- isError: false;
881
- isIdle: false;
882
- isPending: true;
883
- isSuccess: false;
884
- status: "pending";
885
- mutate: UseMutateFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
886
- reset: () => void;
887
- context: unknown;
888
- failureCount: number;
889
- failureReason: Error | null;
890
- isPaused: boolean;
891
- submittedAt: number;
892
- mutateAsync: UseMutateAsyncFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
893
- } | {
894
- download: UseMutateFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
895
- data: undefined;
896
- error: Error;
897
- variables: ExportReportDataParams;
898
- isError: true;
899
- isIdle: false;
900
- isPending: false;
901
- isSuccess: false;
902
- status: "error";
903
- mutate: UseMutateFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
904
- reset: () => void;
905
- context: unknown;
906
- failureCount: number;
907
- failureReason: Error | null;
908
- isPaused: boolean;
909
- submittedAt: number;
910
- mutateAsync: UseMutateAsyncFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
911
- } | {
912
- download: UseMutateFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
913
- data: ExportReportDataResult;
914
- error: null;
915
- variables: ExportReportDataParams;
916
- isError: false;
917
- isIdle: false;
918
- isPending: false;
919
- isSuccess: true;
920
- status: "success";
921
- mutate: UseMutateFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
922
- reset: () => void;
923
- context: unknown;
924
- failureCount: number;
925
- failureReason: Error | null;
926
- isPaused: boolean;
927
- submittedAt: number;
928
- mutateAsync: UseMutateAsyncFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
929
- };
930
-
931
- export declare const useMageMetricsApiUrl: () => string;
932
-
933
- export declare const useMageMetricsClient: () => MageMetricsClient;
934
-
935
- export declare const useMageMetricsReady: () => false | MageMetricsClient;
936
-
937
- export declare const useRecentFlows: (limit?: number) => UseQueryResult< {
938
- title: string | null;
939
- id: string;
940
- request: string;
941
- created_at: string;
942
- user_id: string | null;
943
- application_id?: number | null | undefined;
944
- }[], Error>;
945
-
946
- export declare const useReport: (reportId: number) => {
947
- data: {
948
- created_at: string;
949
- flow_id: string;
950
- id: number;
951
- title: string;
952
- request: string | null;
953
- data_summary: {
954
- [x: string]: unknown;
955
- columns: {
956
- [x: string]: {
957
- [x: string]: unknown;
958
- position?: number | undefined;
959
- data_type: string;
960
- null_count: number | null;
961
- unique_count: number | null;
962
- unique_percentage: number | null;
963
- min_value?: number | null | undefined;
964
- max_value?: number | null | undefined;
965
- avg_value?: number | null | undefined;
966
- median_value?: number | null | undefined;
967
- std_value?: number | null | undefined;
968
- min_date?: string | null | undefined;
969
- max_date?: string | null | undefined;
970
- min_length?: number | null | undefined;
971
- max_length?: number | null | undefined;
972
- avg_length?: number | null | undefined;
973
- };
974
- };
975
- };
976
- status: string | null;
977
- is_removed: boolean;
978
- is_materialized: boolean | null;
979
- last_materialized_at: string | null;
980
- materialized_error_message: string | null;
981
- materialized_status: "completed" | "running" | "failed" | null;
982
- } | null | undefined;
983
- isLoading: boolean;
984
- error: Error | null;
985
- isError: boolean;
986
- isSuccess: boolean;
987
- refetch: (options?: RefetchOptions) => Promise<QueryObserverResult< {
988
- created_at: string;
989
- flow_id: string;
990
- id: number;
991
- title: string;
992
- request: string | null;
993
- data_summary: {
994
- [x: string]: unknown;
995
- columns: {
996
- [x: string]: {
997
- [x: string]: unknown;
998
- position?: number | undefined;
999
- data_type: string;
1000
- null_count: number | null;
1001
- unique_count: number | null;
1002
- unique_percentage: number | null;
1003
- min_value?: number | null | undefined;
1004
- max_value?: number | null | undefined;
1005
- avg_value?: number | null | undefined;
1006
- median_value?: number | null | undefined;
1007
- std_value?: number | null | undefined;
1008
- min_date?: string | null | undefined;
1009
- max_date?: string | null | undefined;
1010
- min_length?: number | null | undefined;
1011
- max_length?: number | null | undefined;
1012
- avg_length?: number | null | undefined;
1013
- };
1014
- };
1015
- };
1016
- status: string | null;
1017
- is_removed: boolean;
1018
- is_materialized: boolean | null;
1019
- last_materialized_at: string | null;
1020
- materialized_error_message: string | null;
1021
- materialized_status: "completed" | "running" | "failed" | null;
1022
- } | null, Error>>;
1023
- isRefetching: boolean;
1024
- isFetching: boolean;
1025
- };
1026
-
1027
- export declare const useSpeechToText: () => AssemblyAIMicrophoneController;
1028
-
1029
- declare type V1FrontendVisualization = z.output<typeof V1FrontendVisualizationSchema>;
1030
-
1031
- declare const V1FrontendVisualizationSchema: z.ZodObject<{
1032
- id: z.ZodNumber;
1033
- configuration: z.ZodDiscriminatedUnion<[z.ZodObject<{
1034
- xAxisLabel: z.ZodString;
1035
- yAxisLabel: z.ZodString;
1036
- xAxisDataKey: z.ZodOptional<z.ZodString>;
1037
- yAxisDataKey: z.ZodOptional<z.ZodString>;
1038
- dimensionDataKey: z.ZodOptional<z.ZodString>;
1039
- valueColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
1040
- title: z.ZodString;
1041
- type: z.ZodLiteral<"bar">;
1042
- }, z.core.$strip>, z.ZodObject<{
1043
- xAxisLabel: z.ZodString;
1044
- yAxisLabel: z.ZodString;
1045
- xAxisDataKey: z.ZodOptional<z.ZodString>;
1046
- yAxisDataKey: z.ZodOptional<z.ZodString>;
1047
- dimensionDataKey: z.ZodOptional<z.ZodString>;
1048
- valueColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
1049
- title: z.ZodString;
1050
- type: z.ZodLiteral<"line/area">;
1051
- }, z.core.$strip>, z.ZodObject<{
1052
- xAxisLabel: z.ZodString;
1053
- yAxisLabel: z.ZodString;
1054
- xAxisDataKey: z.ZodOptional<z.ZodString>;
1055
- yAxisDataKey: z.ZodOptional<z.ZodString>;
1056
- dimensionDataKey: z.ZodOptional<z.ZodString>;
1057
- valueColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
1058
- title: z.ZodString;
1059
- type: z.ZodLiteral<"scatter">;
1060
- }, z.core.$strip>, z.ZodObject<{
1061
- nameKey: z.ZodString;
1062
- dataKey: z.ZodString;
1063
- title: z.ZodString;
1064
- type: z.ZodLiteral<"pie">;
1065
- }, z.core.$strip>], "type">;
1066
- created_at: z.ZodString;
1067
- flow_data: z.ZodOptional<z.ZodObject<{
1068
- is_materialized: z.ZodNullable<z.ZodBoolean>;
1069
- last_materialized_at: z.ZodNullable<z.ZodString>;
1070
- materialized_error_message: z.ZodNullable<z.ZodString>;
1071
- materialized_status: z.ZodNullable<z.ZodEnum<{
1072
- completed: "completed";
1073
- failed: "failed";
1074
- running: "running";
1075
- }>>;
1076
- }, z.core.$strip>>;
1077
- flow_data_id: z.ZodNumber;
1078
- }, z.core.$strip>;
1079
-
1080
- export declare const Visualization: ForwardRefExoticComponent< {
1081
- visualizationId: number;
1082
- withTitle: boolean;
1083
- exportingEnabled?: boolean;
1084
- } & RefAttributes<HTMLDivElement>>;
1085
-
1086
- export declare type WebComponentManagedModalProps = ManagedModalProps & {
1087
- enableCsvDownload: boolean;
1088
- };
1089
-
1090
- export { }
1
+ /**
2
+ * Hand-written type declarations for the `@magemetrics/ai/web-component` entry point.
3
+ *
4
+ * WHY THIS FILE EXISTS:
5
+ * `vite-plugin-dts` with `rollupTypes: true` determines the api-extractor entry
6
+ * from `package.json` `exports["."].types`, which always resolves to the React
7
+ * entry's `.d.ts`. When the web-component build runs, it rolls up the React types
8
+ * instead of the web-component types. This is a known limitation when a single
9
+ * package.json serves multiple build entry points.
10
+ *
11
+ * MAINTENANCE:
12
+ * This file must be kept in sync with `src/web-component.tsx` exports.
13
+ * If you add, remove, or change exports in `web-component.tsx`, update this file.
14
+ */
15
+
16
+ /** Registers the `<magemetrics-ai>` custom element. Safe to call multiple times. */
17
+ export declare const createMagemetrics: () => void;
18
+
19
+ /** Clears stored authentication tokens from localStorage. */
20
+ export declare const logout: () => void;
21
+
22
+ // ---------------------------------------------------------------------------
23
+ // Props & element types
24
+ // ---------------------------------------------------------------------------
25
+
26
+ /**
27
+ * Appearance configuration for visual customization.
28
+ */
29
+ export interface AppearanceConfig {
30
+ colors?: BrandColors;
31
+ modal?: ModalAppearance;
32
+ }
33
+
34
+ export interface ModalAppearance {
35
+ backgroundPrimary?: string;
36
+ }
37
+
38
+ export type BrandColors = PrimaryColorOption & SecondaryColorOption;
39
+
40
+ type PrimaryColorOption =
41
+ | { primaryColor: string; primarySwatch?: never }
42
+ | { primaryColor?: never; primarySwatch: PrimaryColorSwatch }
43
+ | { primaryColor?: never; primarySwatch?: never };
44
+
45
+ type SecondaryColorOption =
46
+ | { secondaryColor: string; secondarySwatch?: never }
47
+ | { secondaryColor?: never; secondarySwatch: SecondaryColorSwatch }
48
+ | { secondaryColor?: never; secondarySwatch?: never };
49
+
50
+ type PrimaryColorSwatch = Record<
51
+ "50" | "400" | "500" | "600" | "650" | "750" | "900",
52
+ string
53
+ >;
54
+ type SecondaryColorSwatch = Record<"500" | "600" | "700", string>;
55
+
56
+ /**
57
+ * Configuration options for the start modal (chat launcher, recommendations, etc.).
58
+ */
59
+ export interface StartOptions {
60
+ showRecommendations?: boolean;
61
+ showRecentChats?: boolean;
62
+ showBackdrop?: boolean;
63
+ label?: string;
64
+ recommendationsLabel?: string;
65
+ autoFocus?: boolean;
66
+ enableSpeechToText?: boolean;
67
+ }
68
+
69
+ type PersistenceOptions = "queryParam" | "none";
70
+
71
+ /**
72
+ * Props accepted by the `<magemetrics-ai>` web component.
73
+ *
74
+ * Extends the standalone managed-modal props with `enableCsvDownload`.
75
+ * Only the props listed in the `r2wc` definition are settable as HTML attributes.
76
+ */
77
+ export interface WebComponentManagedModalProps {
78
+ /** API key for authenticating with the MageMetrics service. */
79
+ apiKey: string;
80
+ /** External JWT token for user authentication. */
81
+ externalJwt: string;
82
+ /** Base URL for the MageMetrics API. */
83
+ apiUrl: string;
84
+ /** Where to persist modal state. */
85
+ persist?: PersistenceOptions;
86
+ /** Configuration options for the start modal. */
87
+ startOptions?: StartOptions;
88
+ /** Whether to enable CSV download for data reports. */
89
+ enableCsvDownload: boolean;
90
+ /** Whether to render data freshness info in the conversation header. */
91
+ showDataFreshness?: boolean;
92
+ /** Application name to associate with flows created through this modal. */
93
+ applicationName?: string;
94
+ /**
95
+ * Appearance configuration for customizing the visual style.
96
+ */
97
+ appearance?: AppearanceConfig;
98
+ }
99
+
100
+ /**
101
+ * The `<magemetrics-ai>` custom element, typed for `querySelector` usage.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * const el = document.querySelector("magemetrics-ai") as SearchElement;
106
+ * el.apiKey = "...";
107
+ * ```
108
+ */
109
+ export type SearchElement = HTMLElement & WebComponentManagedModalProps;
110
+
111
+ // ---------------------------------------------------------------------------
112
+ // JSX augmentation — enables `<magemetrics-ai .../>` in TSX files
113
+ // ---------------------------------------------------------------------------
114
+
115
+ declare module "react" {
116
+ namespace JSX {
117
+ interface IntrinsicElements {
118
+ "magemetrics-ai": WebComponentManagedModalProps;
119
+ }
120
+ }
121
+ }