@fencyai/js 0.1.57 → 0.1.59

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.
@@ -0,0 +1,16 @@
1
+ import { SearchFilesRequest } from '../types/SearchFilesRequest';
2
+ import { SearchFilesResponse } from '../types/SearchFilesResponse';
3
+ /**
4
+ * Creates a website by making a POST request to the Fency API.
5
+ *
6
+ * @param pk - The publishable key (used as Bearer token)
7
+ * @param request - The request body
8
+ * @param options - Optional configuration (apiUrl, request overrides)
9
+ * @returns A promise that resolves to a CreateWebsiteResponse
10
+ * @throws Error if the request fails or the response is invalid
11
+ */
12
+ export declare function searchFiles(params: {
13
+ pk: string;
14
+ request: SearchFilesRequest;
15
+ baseUrl: string;
16
+ }): Promise<SearchFilesResponse>;
@@ -0,0 +1,36 @@
1
+ import { OpenAPI, PubService } from '../openapi';
2
+ import { getPackageVersion } from '../utils/version';
3
+ /**
4
+ * Creates a website by making a POST request to the Fency API.
5
+ *
6
+ * @param pk - The publishable key (used as Bearer token)
7
+ * @param request - The request body
8
+ * @param options - Optional configuration (apiUrl, request overrides)
9
+ * @returns A promise that resolves to a CreateWebsiteResponse
10
+ * @throws Error if the request fails or the response is invalid
11
+ */
12
+ export async function searchFiles(params) {
13
+ try {
14
+ OpenAPI.BASE = params.baseUrl;
15
+ OpenAPI.HEADERS = {
16
+ 'Content-Type': 'application/json',
17
+ Authorization: `Bearer ${params.pk}`,
18
+ 'X-Fency-Sdk-Version': getPackageVersion(),
19
+ 'X-Fency-Client-Secret': params.request.clientSecret,
20
+ };
21
+ const response = await PubService.searchFiles(params.request.text);
22
+ return {
23
+ type: 'success',
24
+ results: response.results,
25
+ };
26
+ }
27
+ catch (error) {
28
+ return {
29
+ type: 'error',
30
+ error: {
31
+ code: 'UnknownError',
32
+ message: `Unknown error!\n${error ? `Error: ${error}\n` : ''}`.trim(),
33
+ },
34
+ };
35
+ }
36
+ }
package/lib/index.d.ts CHANGED
@@ -5,23 +5,28 @@ export type { FencyInstance, FencyOptions } from './types';
5
5
  export type { AnthropicModel } from './types/AnthropicModel';
6
6
  export type { ChatCompletion, isChatCompletion } from './types/ChatCompletion';
7
7
  export type { ChatCompletionMessage } from './types/ChatCompletionMessage';
8
- export type { CreateClaudeChatCompletionRequestParams } from './types/CreateClaudeChatCompletionRequestParams';
8
+ export type { ClaudeChatCompletionMessage } from './types/ClaudeChatCompletionMessage';
9
9
  export type { CreateChatCompletionRequest } from './types/CreateChatCompletionRequest';
10
+ export type { CreateClaudeChatCompletionRequestParams } from './types/CreateClaudeChatCompletionRequestParams';
10
11
  export type { CreateGeminiChatCompletionRequestParams } from './types/CreateGeminiChatCompletionRequestParams';
11
12
  export type { CreateOpenAiChatCompletionRequestParams } from './types/CreateOpenAiChatCompletionRequestParams';
12
13
  export type { CreateStreamRequest } from './types/CreateStreamRequest';
13
14
  export type { CreateStreamResponse } from './types/CreateStreamResponse';
14
15
  export type { CreateWebsiteRequest } from './types/CreateWebsiteRequest';
15
16
  export type { FencyFile } from './types/FencyFile';
17
+ export type { GeminiChatCompletionMessage } from './types/GeminiChatCompletionMessage';
16
18
  export type { GeminiModel } from './types/GeminiModel';
17
19
  export type { OpenAiModel } from './types/OpenAiModel';
18
20
  export type { Stream } from './types/Stream';
19
21
  export type { Website } from './types/Website';
20
- export type { ClaudeChatCompletionMessage } from './types/ClaudeChatCompletionMessage';
21
- export type { GeminiChatCompletionMessage } from './types/GeminiChatCompletionMessage';
22
22
  export { createChatCompletion } from './api/createChatCompletion';
23
23
  export type { CreateChatCompletionResponse } from './api/createChatCompletion';
24
+ export { searchFiles } from './api/searchFiles';
25
+ export type { FileSearchItem, FileSearchResponse } from './openapi';
26
+ export type { SearchFilesRequest } from './types/SearchFilesRequest';
27
+ export type { SearchFilesResponse } from './types/SearchFilesResponse';
24
28
  export { createFile } from './api/createFile';
29
+ export type { S3PostRequestDto } from './openapi';
25
30
  export type { CreateFileRequest } from './types/CreateFileRequest';
26
31
  export type { CreateFileResponse } from './types/CreateFileResponse';
27
32
  export { createStream } from './api/createStream';
package/lib/index.js CHANGED
@@ -6,9 +6,11 @@ import { createStream } from './api/createStream';
6
6
  import { loadFency } from './loadFency';
7
7
  // create chat completion
8
8
  export { createChatCompletion } from './api/createChatCompletion';
9
+ // search files
10
+ export { searchFiles } from './api/searchFiles';
9
11
  // uploads
10
12
  export { createFile } from './api/createFile';
11
- // create chat completion stream
13
+ // create chat completion stre am
12
14
  export { createStream } from './api/createStream';
13
15
  // create website
14
16
  export { createWebsite } from './api/createWebsite';
@@ -15,6 +15,8 @@ export type { CreateOpenAiChatCompletionDto } from './models/CreateOpenAiChatCom
15
15
  export type { CreateOpenAiChatCompletionMessageDto } from './models/CreateOpenAiChatCompletionMessageDto';
16
16
  export type { CreateStreamRequest } from './models/CreateStreamRequest';
17
17
  export type { CreateWebsiteRequest } from './models/CreateWebsiteRequest';
18
+ export type { FileSearchItem } from './models/FileSearchItem';
19
+ export type { FileSearchResponse } from './models/FileSearchResponse';
18
20
  export type { FileTextContentReadyEventDto } from './models/FileTextContentReadyEventDto';
19
21
  export type { FileUploadCompletedEventDto } from './models/FileUploadCompletedEventDto';
20
22
  export type { NewChatCompletionStreamChunkEventDto } from './models/NewChatCompletionStreamChunkEventDto';
@@ -1,6 +1,6 @@
1
1
  export declare enum ApiDtoType {
2
2
  CHAT_COMPLETION = "ChatCompletion",
3
3
  STREAM = "Stream",
4
- CHAT_COMPLETION_SESSION = "ChatCompletionSession",
4
+ SESSION = "Session",
5
5
  USER = "User"
6
6
  }
@@ -6,6 +6,6 @@ export var ApiDtoType;
6
6
  (function (ApiDtoType) {
7
7
  ApiDtoType["CHAT_COMPLETION"] = "ChatCompletion";
8
8
  ApiDtoType["STREAM"] = "Stream";
9
- ApiDtoType["CHAT_COMPLETION_SESSION"] = "ChatCompletionSession";
9
+ ApiDtoType["SESSION"] = "Session";
10
10
  ApiDtoType["USER"] = "User";
11
11
  })(ApiDtoType || (ApiDtoType = {}));
@@ -0,0 +1,6 @@
1
+ export type FileSearchItem = {
2
+ fileId: string;
3
+ fileName: string;
4
+ pageNumbers: Array<number>;
5
+ score: number;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { FileSearchItem } from './FileSearchItem';
2
+ export type FileSearchResponse = {
3
+ results: Array<FileSearchItem>;
4
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -3,6 +3,7 @@ import type { ChatCompletionStreamCompletedEventDto } from '../models/ChatComple
3
3
  import type { CreateChatCompletionRequest } from '../models/CreateChatCompletionRequest';
4
4
  import type { CreateStreamRequest } from '../models/CreateStreamRequest';
5
5
  import type { CreateWebsiteRequest } from '../models/CreateWebsiteRequest';
6
+ import type { FileSearchResponse } from '../models/FileSearchResponse';
6
7
  import type { FileTextContentReadyEventDto } from '../models/FileTextContentReadyEventDto';
7
8
  import type { FileUploadCompletedEventDto } from '../models/FileUploadCompletedEventDto';
8
9
  import type { NewChatCompletionStreamChunkEventDto } from '../models/NewChatCompletionStreamChunkEventDto';
@@ -30,6 +31,13 @@ export declare class PubService {
30
31
  * @throws ApiError
31
32
  */
32
33
  static createFile(requestBody: PubCreateFileRequest): CancelablePromise<PubFileDto>;
34
+ /**
35
+ * Search files
36
+ * @param text
37
+ * @returns FileSearchResponse OK
38
+ * @throws ApiError
39
+ */
40
+ static searchFiles(text: string): CancelablePromise<FileSearchResponse>;
33
41
  /**
34
42
  * Create Chat Completion Stream
35
43
  * @param requestBody
@@ -29,6 +29,21 @@ export class PubService {
29
29
  mediaType: 'application/json',
30
30
  });
31
31
  }
32
+ /**
33
+ * Search files
34
+ * @param text
35
+ * @returns FileSearchResponse OK
36
+ * @throws ApiError
37
+ */
38
+ static searchFiles(text) {
39
+ return __request(OpenAPI, {
40
+ method: 'GET',
41
+ url: '/v1/pub/files/search',
42
+ query: {
43
+ 'text': text,
44
+ },
45
+ });
46
+ }
32
47
  /**
33
48
  * Create Chat Completion Stream
34
49
  * @param requestBody
@@ -0,0 +1,8 @@
1
+ export interface FileSearchItem {
2
+ id: string;
3
+ createdAt: string;
4
+ fileName: string;
5
+ mimeType: string;
6
+ fileSize: number;
7
+ text: string | null;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export interface SearchFilesRequest {
2
+ text: string;
3
+ clientSecret: string;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { FileSearchItem } from '../openapi';
2
+ import { ApiError } from './ApiError';
3
+ export type SearchFilesResponse = {
4
+ type: 'success';
5
+ results: FileSearchItem[];
6
+ } | {
7
+ type: 'error';
8
+ error: ApiError;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fencyai/js",
3
- "version": "0.1.57",
3
+ "version": "0.1.59",
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": {
@@ -41,5 +42,5 @@
41
42
  "ts-jest": "^29.1.1",
42
43
  "typescript": "^5.3.3"
43
44
  },
44
- "gitHead": "62c802daaad0e25cf4b807b9123ef09f17ca1090"
45
+ "gitHead": "27c0349b1a8de22d1175179a566598dba5daec6c"
45
46
  }