@fencyai/react 0.1.58 → 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.
- package/lib/hooks/useFiles/index.d.ts +1 -1
- package/lib/hooks/useFiles/index.js +20 -3
- package/lib/types/CreateFileParams.d.ts +3 -0
- package/lib/types/FencyProviderProps.d.ts +0 -3
- package/lib/types/SearchFilesParams.d.ts +6 -0
- package/lib/types/SearchFilesParams.js +1 -0
- package/lib/types/UseFiles.d.ts +3 -1
- package/package.json +6 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createFile as createFileApi, } from '@fencyai/js';
|
|
1
|
+
import { createFile as createFileApi, searchFiles as searchFilesApi, } from '@fencyai/js';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { useFencyContext } from '../../provider/useFencyContext';
|
|
4
4
|
import { useStream } from '../useStream';
|
|
@@ -7,7 +7,7 @@ export function useFiles(props) {
|
|
|
7
7
|
const context = useFencyContext();
|
|
8
8
|
const { createStream } = useStream({
|
|
9
9
|
onFileUploadCompleted: (streamData) => {
|
|
10
|
-
props
|
|
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
|
|
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
|
});
|
|
@@ -55,8 +59,21 @@ export function useFiles(props) {
|
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
};
|
|
62
|
+
const searchFiles = async (params) => {
|
|
63
|
+
const clientSecret = await params.fetchClientSecret();
|
|
64
|
+
const response = await searchFilesApi({
|
|
65
|
+
pk: context.fency.publishableKey,
|
|
66
|
+
request: {
|
|
67
|
+
text: params.text,
|
|
68
|
+
clientSecret: clientSecret.clientSecret,
|
|
69
|
+
},
|
|
70
|
+
baseUrl: context.fency.baseUrl,
|
|
71
|
+
});
|
|
72
|
+
return response;
|
|
73
|
+
};
|
|
58
74
|
return {
|
|
59
75
|
createFile,
|
|
76
|
+
searchFiles,
|
|
60
77
|
files,
|
|
61
78
|
};
|
|
62
79
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/types/UseFiles.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { CreateFileResponse, FencyFile } from '@fencyai/js';
|
|
1
|
+
import { CreateFileResponse, FencyFile, SearchFilesResponse } from '@fencyai/js';
|
|
2
2
|
import { CreateFileParams } from './CreateFileParams';
|
|
3
|
+
import { SearchFilesParams } from './SearchFilesParams';
|
|
3
4
|
export interface UseFiles {
|
|
4
5
|
createFile: (params: CreateFileParams) => Promise<CreateFileResponse>;
|
|
5
6
|
files: FencyFile[];
|
|
7
|
+
searchFiles: (params: SearchFilesParams) => Promise<SearchFilesResponse>;
|
|
6
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fencyai/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.60",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "staklau <steinaageklaussen@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
13
|
"import": "./lib/index.js",
|
|
14
|
-
"types": "./lib/index.d.ts"
|
|
14
|
+
"types": "./lib/index.d.ts",
|
|
15
|
+
"default": "./lib/index.js"
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
18
|
"directories": {
|
|
@@ -33,7 +34,7 @@
|
|
|
33
34
|
"prepublishOnly": "npm run build"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@fencyai/js": "^0.1.
|
|
37
|
+
"@fencyai/js": "^0.1.60",
|
|
37
38
|
"@types/jest": "^29.5.11",
|
|
38
39
|
"@types/node": "^20.10.5",
|
|
39
40
|
"@types/react": "^18.2.45",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
"typescript": "^5.3.3"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"@fencyai/js": "^0.1.
|
|
46
|
+
"@fencyai/js": "^0.1.60",
|
|
46
47
|
"react": ">=16.8.0",
|
|
47
48
|
"zod": "^4.0.5"
|
|
48
49
|
},
|
|
@@ -51,5 +52,5 @@
|
|
|
51
52
|
"optional": false
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "75f1fd665a806dcaa11208084cbb55af65382567"
|
|
55
56
|
}
|