@magemetrics/ai 0.11.4 → 0.11.6
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 +11921 -11226
- package/dist/react/index.d.ts +70 -1
- package/dist/styles.css +1 -1
- package/dist/web-component/index.d.ts +1 -0
- package/dist/web-component/web-component.es.js +35768 -35358
- package/package.json +5 -14
package/dist/react/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { DirectAuthProvider } from '@magemetrics/core';
|
|
|
6
6
|
import { ExternalAuthProvider } from '@magemetrics/core';
|
|
7
7
|
import { ExternalAuthProviderConfig } from '@magemetrics/core';
|
|
8
8
|
import { FetchNextPageOptions } from '@tanstack/react-query';
|
|
9
|
+
import { FileUIPart } from 'ai';
|
|
9
10
|
import { ForwardRefExoticComponent } from 'react';
|
|
10
11
|
import { InfiniteData } from '@tanstack/react-query';
|
|
11
12
|
import { InfiniteQueryObserverResult } from '@tanstack/react-query';
|
|
@@ -92,6 +93,7 @@ declare interface ChatComponent extends default_2.MemoExoticComponent<(props: Ch
|
|
|
92
93
|
export declare interface ChatContextValue {
|
|
93
94
|
flowId: string | undefined | null;
|
|
94
95
|
enableSpeechToText?: boolean;
|
|
96
|
+
enableFileUpload?: boolean;
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
/**
|
|
@@ -142,9 +144,10 @@ export declare interface ChatInputContextValue {
|
|
|
142
144
|
isAwaitingUserAnswer: boolean;
|
|
143
145
|
onRetry?: () => void;
|
|
144
146
|
onStop?: () => void;
|
|
145
|
-
sendMessage: (text: string, isEditing: boolean) => void;
|
|
147
|
+
sendMessage: (text: string, isEditing: boolean, files?: FileUIPart[]) => void;
|
|
146
148
|
lastUserMessage?: string;
|
|
147
149
|
enableSpeechToText?: boolean;
|
|
150
|
+
enableFileUpload?: boolean;
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
declare const ChatInputDefault: default_2.FC;
|
|
@@ -152,6 +155,7 @@ declare const ChatInputDefault: default_2.FC;
|
|
|
152
155
|
declare interface ChatProps {
|
|
153
156
|
flowId: string | undefined | null;
|
|
154
157
|
enableSpeechToText?: boolean;
|
|
158
|
+
enableFileUpload?: boolean;
|
|
155
159
|
children?: default_2.ReactNode;
|
|
156
160
|
}
|
|
157
161
|
|
|
@@ -205,6 +209,7 @@ declare interface ConfigurableChatComponent extends default_2.FC<ConfigurableCha
|
|
|
205
209
|
declare type ConfigurableChatComponentProps = {
|
|
206
210
|
flowId: string | undefined | null;
|
|
207
211
|
enableSpeechToText?: boolean;
|
|
212
|
+
enableFileUpload?: boolean;
|
|
208
213
|
disableCanvas?: boolean;
|
|
209
214
|
children?: default_2.ReactNode;
|
|
210
215
|
/**
|
|
@@ -236,6 +241,7 @@ declare interface ConversationContentProps {
|
|
|
236
241
|
topBar?: React.ReactNode;
|
|
237
242
|
disableCanvas?: boolean;
|
|
238
243
|
enableSpeechToText?: boolean;
|
|
244
|
+
enableFileUpload?: boolean;
|
|
239
245
|
children?: React.ReactNode;
|
|
240
246
|
}
|
|
241
247
|
|
|
@@ -280,6 +286,51 @@ export { ExternalAuthProvider }
|
|
|
280
286
|
|
|
281
287
|
export { ExternalAuthProviderConfig }
|
|
282
288
|
|
|
289
|
+
export declare interface FileAttachment {
|
|
290
|
+
/** Unique ID for this attachment (for React keys and removal) */
|
|
291
|
+
id: string;
|
|
292
|
+
/** Original file name */
|
|
293
|
+
filename: string;
|
|
294
|
+
/** File size in bytes */
|
|
295
|
+
size: number;
|
|
296
|
+
/** The FileUIPart ready to be sent via sendMessage */
|
|
297
|
+
filePart: FileUIPart;
|
|
298
|
+
/** Validation error, if any */
|
|
299
|
+
error?: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export declare interface FileUploadConfig {
|
|
303
|
+
/** Maximum file size per file in bytes. Default: 10 * 1024 * 1024 (10 MB) */
|
|
304
|
+
maxFileSize?: number;
|
|
305
|
+
/** Maximum combined file size in bytes. Default: 20 * 1024 * 1024 (20 MB) */
|
|
306
|
+
maxCombinedSize?: number;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
export declare interface FileUploadController {
|
|
310
|
+
/** Currently attached files (valid and invalid) */
|
|
311
|
+
attachments: FileAttachment[];
|
|
312
|
+
/** Whether all attachments are valid and ready to send */
|
|
313
|
+
isReady: boolean;
|
|
314
|
+
/** Whether any file is currently being read (FileReader in progress) */
|
|
315
|
+
isProcessing: boolean;
|
|
316
|
+
/** Total size of all valid attachments in bytes */
|
|
317
|
+
totalSize: number;
|
|
318
|
+
/** Combined size limit error, if total exceeds maxCombinedSize */
|
|
319
|
+
combinedSizeError?: string;
|
|
320
|
+
/** Add files from a FileList (e.g., from an input[type=file]) */
|
|
321
|
+
addFiles: (files: FileList) => void;
|
|
322
|
+
/** Remove a specific attachment by ID */
|
|
323
|
+
removeFile: (id: string) => void;
|
|
324
|
+
/** Clear all attachments */
|
|
325
|
+
clearFiles: () => void;
|
|
326
|
+
/** Get all valid FileUIParts for sendMessage */
|
|
327
|
+
getFileParts: () => FileUIPart[];
|
|
328
|
+
/** Open the native file picker (programmatic trigger) */
|
|
329
|
+
openFilePicker: () => void;
|
|
330
|
+
/** Ref to attach to a hidden file input element */
|
|
331
|
+
fileInputRef: React.RefObject<HTMLInputElement | null>;
|
|
332
|
+
}
|
|
333
|
+
|
|
283
334
|
/**
|
|
284
335
|
* This module handles the formatting and normalization of table cell values for display and sorting.
|
|
285
336
|
*
|
|
@@ -317,6 +368,12 @@ declare const FrontendCanvasSchema: z.ZodObject<{
|
|
|
317
368
|
is_public: z.ZodBoolean;
|
|
318
369
|
}, z.core.$strip>;
|
|
319
370
|
|
|
371
|
+
declare const FrontendRecommendationsSchema: z.ZodObject<{
|
|
372
|
+
starter: z.ZodString;
|
|
373
|
+
explanation: z.ZodString;
|
|
374
|
+
type: z.ZodString;
|
|
375
|
+
}, z.core.$strip>;
|
|
376
|
+
|
|
320
377
|
declare const FrontendReportSchema: z.ZodObject<{
|
|
321
378
|
status: z.ZodNullable<z.ZodString>;
|
|
322
379
|
title: z.ZodString;
|
|
@@ -549,6 +606,8 @@ export declare type PublicChatProps = Omit<ConversationContentProps, "children">
|
|
|
549
606
|
appearance?: AppearanceConfig;
|
|
550
607
|
};
|
|
551
608
|
|
|
609
|
+
export declare type Recommendation = z.infer<typeof FrontendRecommendationsSchema>;
|
|
610
|
+
|
|
552
611
|
declare type Report_2 = z.infer<typeof FrontendReportSchema>;
|
|
553
612
|
export { Report_2 as Report }
|
|
554
613
|
|
|
@@ -646,6 +705,8 @@ declare type StartOptions = DisplayControlProps & {
|
|
|
646
705
|
autoFocus?: boolean;
|
|
647
706
|
/** Whether speech-to-text controls should be shown */
|
|
648
707
|
enableSpeechToText?: boolean;
|
|
708
|
+
/** Whether file upload should be enabled in the chat input */
|
|
709
|
+
enableFileUpload?: boolean;
|
|
649
710
|
};
|
|
650
711
|
|
|
651
712
|
declare type TableFilters = Record<string, TableFilterValue>;
|
|
@@ -955,6 +1016,8 @@ export declare const useDownloadReportData: (options?: UseMutationOptions<Export
|
|
|
955
1016
|
mutateAsync: UseMutateAsyncFunction<ExportReportDataResult, Error, ExportReportDataParams, unknown>;
|
|
956
1017
|
};
|
|
957
1018
|
|
|
1019
|
+
export declare function useFileUpload(config?: FileUploadConfig): FileUploadController;
|
|
1020
|
+
|
|
958
1021
|
export declare const useMageMetricsApiUrl: () => string;
|
|
959
1022
|
|
|
960
1023
|
export declare const useMageMetricsClient: () => MageMetricsClient;
|
|
@@ -970,6 +1033,12 @@ user_id: string | null;
|
|
|
970
1033
|
application_id?: number | null | undefined;
|
|
971
1034
|
}[], Error>;
|
|
972
1035
|
|
|
1036
|
+
export declare const useRecommendations: (count: number) => UseQueryResult< {
|
|
1037
|
+
starter: string;
|
|
1038
|
+
explanation: string;
|
|
1039
|
+
type: string;
|
|
1040
|
+
}[], Error>;
|
|
1041
|
+
|
|
973
1042
|
export declare const useReport: (reportId: number) => {
|
|
974
1043
|
data: {
|
|
975
1044
|
created_at: string;
|