@fencyai/react 0.1.63 → 0.1.65

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.
@@ -20,6 +20,12 @@ export function useCreateFiles(props) {
20
20
  ? { ...fileUpload, textContent: streamData.textContent }
21
21
  : fileUpload));
22
22
  },
23
+ onFileSearchIndexReady: (streamData) => {
24
+ props?.onFileSearchIndexReady?.(streamData);
25
+ setFiles((prev) => prev.map((fileUpload) => fileUpload.id === streamData.fileId
26
+ ? { ...fileUpload, searchIndexReady: true }
27
+ : fileUpload));
28
+ },
23
29
  });
24
30
  const createFile = async (params) => {
25
31
  const clientSecret = params.fetchClientSecret
@@ -2,6 +2,7 @@ import { listFiles as listFilesApi } from '@fencyai/js';
2
2
  import { useState } from 'react';
3
3
  import { useFencyContext } from '../../provider/useFencyContext';
4
4
  export function useListFiles(props) {
5
+ const [currentPageParams, setCurrentPageParams] = useState(null);
5
6
  const [currentPage, setCurrentPage] = useState(null);
6
7
  const context = useFencyContext();
7
8
  const listFilesInternal = async (params) => {
@@ -104,6 +105,18 @@ export function useListFiles(props) {
104
105
  listFirstPage,
105
106
  listNextPage,
106
107
  listPreviousPage,
108
+ refetchCurrentPage: async () => {
109
+ if (currentPageParams == null) {
110
+ return {
111
+ type: 'error',
112
+ error: {
113
+ code: 'NO_CURRENT_PAGE',
114
+ message: 'No current page, please call listFirstPage first.',
115
+ },
116
+ };
117
+ }
118
+ return listFilesInternal(currentPageParams);
119
+ },
107
120
  currentPage,
108
121
  };
109
122
  }
@@ -47,6 +47,9 @@ export const useStream = (props) => {
47
47
  case 'WebsiteTextContentReady':
48
48
  props?.onWebsiteTextContentReady?.(streamData);
49
49
  return true;
50
+ case 'FileSearchIndexReady':
51
+ props?.onFileSearchIndexReady?.(streamData);
52
+ return true;
50
53
  }
51
54
  },
52
55
  });
@@ -34,6 +34,8 @@ const toStreamDataRaw = (data) => {
34
34
  return toWebsiteHtmlContentReady(data);
35
35
  case 'WebsiteTextContentReady':
36
36
  return toWebsiteTextContentReady(data);
37
+ case 'FileSearchIndexReady':
38
+ return toFileSearchIndexReady(data);
37
39
  }
38
40
  return null;
39
41
  };
@@ -104,3 +106,11 @@ const toWebsiteTextContentReady = (data) => {
104
106
  timestamp: data.timestamp,
105
107
  };
106
108
  };
109
+ const toFileSearchIndexReady = (data) => {
110
+ return {
111
+ type: 'FileSearchIndexReady',
112
+ streamId: data.streamId,
113
+ fileId: data.fileId,
114
+ timestamp: data.timestamp,
115
+ };
116
+ };
@@ -49,4 +49,10 @@ export type WebsiteTextContentReady = {
49
49
  textContent: string;
50
50
  timestamp: string;
51
51
  };
52
- export type StreamData = NewChatCompletionStreamChunk | ChatCompletionStreamCompleted | StreamTimeout | StreamNotFound | FileUploadCompleted | FileTextContentReady | WebsiteHtmlContentReady | WebsiteTextContentReady;
52
+ export type FileSearchIndexReady = {
53
+ type: 'FileSearchIndexReady';
54
+ streamId: string;
55
+ fileId: string;
56
+ timestamp: string;
57
+ };
58
+ export type StreamData = NewChatCompletionStreamChunk | ChatCompletionStreamCompleted | StreamTimeout | StreamNotFound | FileUploadCompleted | FileTextContentReady | WebsiteHtmlContentReady | WebsiteTextContentReady | FileSearchIndexReady;
@@ -1,5 +1,6 @@
1
- import { FileTextContentReady, FileUploadCompleted } from './StreamData';
1
+ import { FileSearchIndexReady, FileTextContentReady, FileUploadCompleted } from './StreamData';
2
2
  export interface UseCreateFilesProps {
3
3
  onUploadCompleted?: (event: FileUploadCompleted) => void;
4
4
  onTextContentReady?: (event: FileTextContentReady) => void;
5
+ onFileSearchIndexReady?: (event: FileSearchIndexReady) => void;
5
6
  }
@@ -5,5 +5,6 @@ export interface UseListFiles {
5
5
  listFirstPage: (params: ListFilesParams) => Promise<ListFilesResult>;
6
6
  listNextPage: (params: ListFilesParams) => Promise<ListFilesResult>;
7
7
  listPreviousPage: (params: ListFilesParams) => Promise<ListFilesResult>;
8
+ refetchCurrentPage: () => Promise<ListFilesResult>;
8
9
  currentPage: ListFilesPage | null;
9
10
  }
@@ -1,4 +1,4 @@
1
- import { ChatCompletionStreamCompleted, NewChatCompletionStreamChunk, StreamNotFound, StreamTimeout, FileUploadCompleted, FileTextContentReady, WebsiteHtmlContentReady, WebsiteTextContentReady } from './StreamData';
1
+ import { ChatCompletionStreamCompleted, NewChatCompletionStreamChunk, StreamNotFound, StreamTimeout, FileUploadCompleted, FileTextContentReady, WebsiteHtmlContentReady, WebsiteTextContentReady, FileSearchIndexReady } from './StreamData';
2
2
  import { StreamError } from './StreamError';
3
3
  export interface UseStreamProps {
4
4
  onNewChatCompletionStreamChunk?: (streamData: NewChatCompletionStreamChunk) => void;
@@ -9,5 +9,6 @@ export interface UseStreamProps {
9
9
  onFileTextContentReady?: (error: FileTextContentReady) => void;
10
10
  onWebsiteHtmlContentReady?: (error: WebsiteHtmlContentReady) => void;
11
11
  onWebsiteTextContentReady?: (error: WebsiteTextContentReady) => void;
12
+ onFileSearchIndexReady?: (error: FileSearchIndexReady) => void;
12
13
  onStreamError?: (error: StreamError) => void;
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fencyai/react",
3
- "version": "0.1.63",
3
+ "version": "0.1.65",
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.63",
37
+ "@fencyai/js": "^0.1.65",
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.63",
46
+ "@fencyai/js": "^0.1.65",
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": "fa1e08330dd81d0dafb1da3ad76417cf32b490a6"
55
+ "gitHead": "a116006ab2adce36c44a0ebc76da09aae6243148"
56
56
  }