@magemetrics/ai 0.10.0 → 0.11.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.
- package/dist/react/ai.js +19995 -14904
- package/dist/react/index.d.ts +218 -26
- package/dist/styles.css +1 -1
- package/dist/web-component/index.d.ts +218 -26
- package/dist/web-component/web-component.es.js +28635 -27940
- package/package.json +11 -11
package/dist/react/index.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { AuthProvider } from '@magemetrics/core';
|
|
2
2
|
import { AuthState } from '@magemetrics/core';
|
|
3
|
-
import { Components } from './shared/context/MageMetricsContext';
|
|
4
|
-
import { Components as Components_2 } from '../shared/context/MageMetricsContext';
|
|
5
|
-
import { Components as Components_3 } from './MageMetricsContext';
|
|
6
3
|
import { CreateFlowParam } from '@magemetrics/core';
|
|
7
4
|
import { default as default_2 } from 'react';
|
|
8
5
|
import { DirectAuthProvider } from '@magemetrics/core';
|
|
@@ -15,16 +12,11 @@ import { InfiniteQueryObserverResult } from '@tanstack/react-query';
|
|
|
15
12
|
import { JSX } from 'react/jsx-runtime';
|
|
16
13
|
import { MageMetricsClient } from '@magemetrics/core';
|
|
17
14
|
import { MageMetricsClientConfig } from '@magemetrics/core';
|
|
18
|
-
import { MageMetricsContextProvider } from './shared/context/MageMetricsContext';
|
|
19
|
-
import { MageMetricsContextProviderProps } from './shared/context/MageMetricsContext';
|
|
20
|
-
import { PersistenceOptions } from '../shared/context/MageMetricsContext';
|
|
21
15
|
import { PropsWithChildren } from 'react';
|
|
22
16
|
import { QueryObserverResult } from '@tanstack/react-query';
|
|
23
17
|
import { RefAttributes } from 'react';
|
|
24
18
|
import { RefetchOptions } from '@tanstack/react-query';
|
|
25
19
|
import { SortingState as SortingState_2 } from '@tanstack/react-table';
|
|
26
|
-
import { useMageMetricsClient } from './shared/context/MageMetricsContext';
|
|
27
|
-
import { useMageMetricsReady } from './shared/context/MageMetricsContext';
|
|
28
20
|
import { UseMutateAsyncFunction } from '@tanstack/react-query';
|
|
29
21
|
import { UseMutateFunction } from '@tanstack/react-query';
|
|
30
22
|
import { UseMutationOptions } from '@tanstack/react-query';
|
|
@@ -102,6 +94,46 @@ export declare interface ChatContextValue {
|
|
|
102
94
|
enableSpeechToText?: boolean;
|
|
103
95
|
}
|
|
104
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
|
+
|
|
105
137
|
export declare interface ChatInputContextValue {
|
|
106
138
|
flowId: string | undefined;
|
|
107
139
|
isLoading: boolean;
|
|
@@ -128,7 +160,40 @@ declare interface ColumnSort {
|
|
|
128
160
|
id: string;
|
|
129
161
|
}
|
|
130
162
|
|
|
131
|
-
export
|
|
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
|
+
}
|
|
132
197
|
|
|
133
198
|
export declare const ConfigurableChat: ConfigurableChatComponent;
|
|
134
199
|
|
|
@@ -236,8 +301,8 @@ declare type FormattedData = {
|
|
|
236
301
|
declare type FrontendCanvas = z.infer<typeof FrontendCanvasSchema>;
|
|
237
302
|
|
|
238
303
|
declare const FrontendCanvasSchema: z.ZodObject<{
|
|
239
|
-
id: z.ZodUUID;
|
|
240
304
|
title: z.ZodNullable<z.ZodString>;
|
|
305
|
+
id: z.ZodUUID;
|
|
241
306
|
nodes: z.ZodArray<z.ZodAny>;
|
|
242
307
|
edges: z.ZodArray<z.ZodAny>;
|
|
243
308
|
is_public: z.ZodBoolean;
|
|
@@ -245,8 +310,8 @@ declare const FrontendCanvasSchema: z.ZodObject<{
|
|
|
245
310
|
|
|
246
311
|
declare const FrontendReportSchema: z.ZodObject<{
|
|
247
312
|
status: z.ZodNullable<z.ZodString>;
|
|
248
|
-
id: z.ZodNumber;
|
|
249
313
|
title: z.ZodString;
|
|
314
|
+
id: z.ZodNumber;
|
|
250
315
|
request: z.ZodNullable<z.ZodString>;
|
|
251
316
|
created_at: z.ZodString;
|
|
252
317
|
data_summary: z.ZodObject<{
|
|
@@ -274,11 +339,68 @@ declare const FrontendReportSchema: z.ZodObject<{
|
|
|
274
339
|
last_materialized_at: z.ZodNullable<z.ZodString>;
|
|
275
340
|
materialized_error_message: z.ZodNullable<z.ZodString>;
|
|
276
341
|
materialized_status: z.ZodNullable<z.ZodEnum<{
|
|
277
|
-
running: "running";
|
|
278
342
|
completed: "completed";
|
|
279
343
|
failed: "failed";
|
|
344
|
+
running: "running";
|
|
280
345
|
}>>;
|
|
281
|
-
|
|
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_id: z.ZodNumber;
|
|
394
|
+
flow_data: z.ZodOptional<z.ZodObject<{
|
|
395
|
+
is_materialized: z.ZodNullable<z.ZodBoolean>;
|
|
396
|
+
last_materialized_at: z.ZodNullable<z.ZodString>;
|
|
397
|
+
materialized_error_message: z.ZodNullable<z.ZodString>;
|
|
398
|
+
materialized_status: z.ZodNullable<z.ZodEnum<{
|
|
399
|
+
completed: "completed";
|
|
400
|
+
failed: "failed";
|
|
401
|
+
running: "running";
|
|
402
|
+
}>>;
|
|
403
|
+
}, z.core.$strip>>;
|
|
282
404
|
}, z.core.$strip>;
|
|
283
405
|
|
|
284
406
|
declare const InputContainer: default_2.FC<{
|
|
@@ -302,14 +424,28 @@ export { MageMetricsClient }
|
|
|
302
424
|
|
|
303
425
|
export { MageMetricsClientConfig }
|
|
304
426
|
|
|
305
|
-
export
|
|
306
|
-
|
|
307
|
-
export
|
|
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));
|
|
308
444
|
|
|
309
445
|
export declare const MageMetricsPublicContextProvider: React.FC<MageMetricsPublicContextProviderProps>;
|
|
310
446
|
|
|
311
447
|
declare type MageMetricsPublicContextProviderProps = PropsWithChildren<Pick<MageMetricsClientConfig, "apiUrl" | "apiKey"> & {
|
|
312
|
-
components?:
|
|
448
|
+
components?: Components;
|
|
313
449
|
}>;
|
|
314
450
|
|
|
315
451
|
export declare const ManagedModal: React.FC<ManagedModalProps>;
|
|
@@ -328,7 +464,7 @@ declare type ManagedModalBaseProps = ModalProps & {
|
|
|
328
464
|
/** Where to persist modal state (localStorage, queryParam, or none) */
|
|
329
465
|
persist?: PersistenceOptions;
|
|
330
466
|
/** Custom component overrides for extending functionality */
|
|
331
|
-
components?:
|
|
467
|
+
components?: Components;
|
|
332
468
|
/** Application name to associate with flows created through this modal */
|
|
333
469
|
applicationName?: string;
|
|
334
470
|
/**
|
|
@@ -372,6 +508,8 @@ declare interface ModalProps {
|
|
|
372
508
|
startOptions?: StartOptions;
|
|
373
509
|
}
|
|
374
510
|
|
|
511
|
+
declare type PersistenceOptions = "queryParam" | "none";
|
|
512
|
+
|
|
375
513
|
/**
|
|
376
514
|
* Primary color shade stops used in the UI.
|
|
377
515
|
*/
|
|
@@ -518,8 +656,8 @@ declare const TableFilterValueSchema: z.ZodObject<{
|
|
|
518
656
|
* ```
|
|
519
657
|
*/
|
|
520
658
|
export declare const useCanvas: (canvasId: string | undefined | null, options?: Omit<UseQueryOptions<FrontendCanvas, unknown>, "queryKey" | "queryFn">) => UseQueryResult< {
|
|
521
|
-
id: string;
|
|
522
659
|
title: string | null;
|
|
660
|
+
id: string;
|
|
523
661
|
nodes: any[];
|
|
524
662
|
edges: any[];
|
|
525
663
|
is_public: boolean;
|
|
@@ -527,6 +665,12 @@ is_public: boolean;
|
|
|
527
665
|
|
|
528
666
|
export declare const useChatContext: () => ChatContextValue;
|
|
529
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
|
+
|
|
530
674
|
export declare const useChatInputContext: () => ChatInputContextValue;
|
|
531
675
|
|
|
532
676
|
export declare const useCreateFlow: (options?: UseMutationOptions<{
|
|
@@ -654,8 +798,8 @@ export declare const useDataReportColumnValue: (reportId: number, filters: Repor
|
|
|
654
798
|
export declare const useDataTableContext: () => {
|
|
655
799
|
report: {
|
|
656
800
|
status: string | null;
|
|
657
|
-
id: number;
|
|
658
801
|
title: string;
|
|
802
|
+
id: number;
|
|
659
803
|
request: string | null;
|
|
660
804
|
created_at: string;
|
|
661
805
|
data_summary: {
|
|
@@ -685,7 +829,6 @@ export declare const useDataTableContext: () => {
|
|
|
685
829
|
last_materialized_at: string | null;
|
|
686
830
|
materialized_error_message: string | null;
|
|
687
831
|
materialized_status: "completed" | "running" | "failed" | null;
|
|
688
|
-
bookmarked: boolean;
|
|
689
832
|
};
|
|
690
833
|
fetchNextPage: (options?: FetchNextPageOptions) => Promise<InfiniteQueryObserverResult<InfiniteData< {
|
|
691
834
|
[key: string]: unknown;
|
|
@@ -787,13 +930,13 @@ export declare const useDownloadReportData: (options?: UseMutationOptions<Export
|
|
|
787
930
|
|
|
788
931
|
export declare const useMageMetricsApiUrl: () => string;
|
|
789
932
|
|
|
790
|
-
export
|
|
933
|
+
export declare const useMageMetricsClient: () => MageMetricsClient;
|
|
791
934
|
|
|
792
|
-
export
|
|
935
|
+
export declare const useMageMetricsReady: () => false | MageMetricsClient;
|
|
793
936
|
|
|
794
937
|
export declare const useRecentFlows: (limit?: number) => UseQueryResult< {
|
|
795
|
-
id: string;
|
|
796
938
|
title: string | null;
|
|
939
|
+
id: string;
|
|
797
940
|
request: string;
|
|
798
941
|
created_at: string;
|
|
799
942
|
user_id: string | null;
|
|
@@ -832,7 +975,6 @@ export declare const useReport: (reportId: number) => {
|
|
|
832
975
|
} & {
|
|
833
976
|
[key: string]: unknown;
|
|
834
977
|
};
|
|
835
|
-
bookmarked: boolean;
|
|
836
978
|
status: string | null;
|
|
837
979
|
is_removed: boolean;
|
|
838
980
|
is_materialized: boolean | null;
|
|
@@ -875,7 +1017,6 @@ export declare const useReport: (reportId: number) => {
|
|
|
875
1017
|
} & {
|
|
876
1018
|
[key: string]: unknown;
|
|
877
1019
|
};
|
|
878
|
-
bookmarked: boolean;
|
|
879
1020
|
status: string | null;
|
|
880
1021
|
is_removed: boolean;
|
|
881
1022
|
is_materialized: boolean | null;
|
|
@@ -889,6 +1030,57 @@ export declare const useReport: (reportId: number) => {
|
|
|
889
1030
|
|
|
890
1031
|
export declare const useSpeechToText: () => AssemblyAIMicrophoneController;
|
|
891
1032
|
|
|
1033
|
+
declare type V1FrontendVisualization = z.output<typeof V1FrontendVisualizationSchema>;
|
|
1034
|
+
|
|
1035
|
+
declare const V1FrontendVisualizationSchema: z.ZodObject<{
|
|
1036
|
+
id: z.ZodNumber;
|
|
1037
|
+
configuration: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1038
|
+
xAxisLabel: z.ZodString;
|
|
1039
|
+
yAxisLabel: z.ZodString;
|
|
1040
|
+
xAxisDataKey: z.ZodOptional<z.ZodString>;
|
|
1041
|
+
yAxisDataKey: z.ZodOptional<z.ZodString>;
|
|
1042
|
+
dimensionDataKey: z.ZodOptional<z.ZodString>;
|
|
1043
|
+
valueColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1044
|
+
title: z.ZodString;
|
|
1045
|
+
type: z.ZodLiteral<"bar">;
|
|
1046
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1047
|
+
xAxisLabel: z.ZodString;
|
|
1048
|
+
yAxisLabel: z.ZodString;
|
|
1049
|
+
xAxisDataKey: z.ZodOptional<z.ZodString>;
|
|
1050
|
+
yAxisDataKey: z.ZodOptional<z.ZodString>;
|
|
1051
|
+
dimensionDataKey: z.ZodOptional<z.ZodString>;
|
|
1052
|
+
valueColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1053
|
+
title: z.ZodString;
|
|
1054
|
+
type: z.ZodLiteral<"line/area">;
|
|
1055
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1056
|
+
xAxisLabel: z.ZodString;
|
|
1057
|
+
yAxisLabel: z.ZodString;
|
|
1058
|
+
xAxisDataKey: z.ZodOptional<z.ZodString>;
|
|
1059
|
+
yAxisDataKey: z.ZodOptional<z.ZodString>;
|
|
1060
|
+
dimensionDataKey: z.ZodOptional<z.ZodString>;
|
|
1061
|
+
valueColumns: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1062
|
+
title: z.ZodString;
|
|
1063
|
+
type: z.ZodLiteral<"scatter">;
|
|
1064
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
1065
|
+
nameKey: z.ZodString;
|
|
1066
|
+
dataKey: z.ZodString;
|
|
1067
|
+
title: z.ZodString;
|
|
1068
|
+
type: z.ZodLiteral<"pie">;
|
|
1069
|
+
}, z.core.$strip>], "type">;
|
|
1070
|
+
created_at: z.ZodString;
|
|
1071
|
+
flow_data_id: z.ZodNumber;
|
|
1072
|
+
flow_data: z.ZodOptional<z.ZodObject<{
|
|
1073
|
+
is_materialized: z.ZodNullable<z.ZodBoolean>;
|
|
1074
|
+
last_materialized_at: z.ZodNullable<z.ZodString>;
|
|
1075
|
+
materialized_error_message: z.ZodNullable<z.ZodString>;
|
|
1076
|
+
materialized_status: z.ZodNullable<z.ZodEnum<{
|
|
1077
|
+
completed: "completed";
|
|
1078
|
+
failed: "failed";
|
|
1079
|
+
running: "running";
|
|
1080
|
+
}>>;
|
|
1081
|
+
}, z.core.$strip>>;
|
|
1082
|
+
}, z.core.$strip>;
|
|
1083
|
+
|
|
892
1084
|
export declare const Visualization: ForwardRefExoticComponent< {
|
|
893
1085
|
visualizationId: number;
|
|
894
1086
|
withTitle: boolean;
|