@fencyai/react 0.1.59 → 0.1.60

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,3 +1,3 @@
1
1
  import { UseFiles } from '../../types/UseFiles';
2
2
  import { UseFilesProps } from '../../types/UseFilesProps';
3
- export declare function useFiles(props: UseFilesProps): UseFiles;
3
+ export declare function useFiles(props?: UseFilesProps): UseFiles;
@@ -7,7 +7,7 @@ export function useFiles(props) {
7
7
  const context = useFencyContext();
8
8
  const { createStream } = useStream({
9
9
  onFileUploadCompleted: (streamData) => {
10
- props.onUploadCompleted?.(streamData);
10
+ props?.onUploadCompleted?.(streamData);
11
11
  setFiles((prev) => prev.map((fileUpload) => {
12
12
  return fileUpload.id === streamData.uploadId
13
13
  ? { ...fileUpload, status: 'upload_complete' }
@@ -15,13 +15,16 @@ export function useFiles(props) {
15
15
  }));
16
16
  },
17
17
  onFileTextContentReady: (streamData) => {
18
- props.onTextContentReady?.(streamData);
18
+ props?.onTextContentReady?.(streamData);
19
19
  setFiles((prev) => prev.map((fileUpload) => fileUpload.id === streamData.fileId
20
20
  ? { ...fileUpload, textContent: streamData.textContent }
21
21
  : fileUpload));
22
22
  },
23
23
  });
24
24
  const createFile = async (params) => {
25
+ const clientSecret = params.fetchClientSecret
26
+ ? await params.fetchClientSecret()
27
+ : undefined;
25
28
  const streamResponse = await createStream({
26
29
  type: 'FileStream',
27
30
  });
@@ -34,6 +37,7 @@ export function useFiles(props) {
34
37
  fileType: params.fileType,
35
38
  fileSize: params.fileSize,
36
39
  extractTextContent: params.extractTextContent || true,
40
+ clientSecret: clientSecret?.clientSecret,
37
41
  },
38
42
  baseUrl: context.fency.baseUrl,
39
43
  });
@@ -3,4 +3,7 @@ export interface CreateFileParams {
3
3
  fileType: string;
4
4
  fileSize: number;
5
5
  extractTextContent?: boolean;
6
+ fetchClientSecret?: () => Promise<{
7
+ clientSecret: string;
8
+ }>;
6
9
  }
@@ -2,7 +2,4 @@ import { FencyInstance } from '@fencyai/js';
2
2
  export interface FencyProviderProps {
3
3
  fency: Promise<FencyInstance>;
4
4
  children: React.ReactNode;
5
- options?: {
6
- fetchClientSecret: () => Promise<string>;
7
- };
8
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fencyai/react",
3
- "version": "0.1.59",
3
+ "version": "0.1.60",
4
4
  "description": "> TODO: description",
5
5
  "author": "staklau <steinaageklaussen@gmail.com>",
6
6
  "homepage": "",
@@ -34,7 +34,7 @@
34
34
  "prepublishOnly": "npm run build"
35
35
  },
36
36
  "devDependencies": {
37
- "@fencyai/js": "^0.1.59",
37
+ "@fencyai/js": "^0.1.60",
38
38
  "@types/jest": "^29.5.11",
39
39
  "@types/node": "^20.10.5",
40
40
  "@types/react": "^18.2.45",
@@ -43,7 +43,7 @@
43
43
  "typescript": "^5.3.3"
44
44
  },
45
45
  "peerDependencies": {
46
- "@fencyai/js": "^0.1.59",
46
+ "@fencyai/js": "^0.1.60",
47
47
  "react": ">=16.8.0",
48
48
  "zod": "^4.0.5"
49
49
  },
@@ -52,5 +52,5 @@
52
52
  "optional": false
53
53
  }
54
54
  },
55
- "gitHead": "27c0349b1a8de22d1175179a566598dba5daec6c"
55
+ "gitHead": "75f1fd665a806dcaa11208084cbb55af65382567"
56
56
  }