@fencyai/js 0.1.42 → 0.1.43

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.
Files changed (107) hide show
  1. package/lib/api/createChatCompletion.d.ts +0 -4
  2. package/lib/api/createChatCompletion.js +15 -31
  3. package/lib/api/createStream.d.ts +14 -0
  4. package/lib/api/createStream.js +53 -0
  5. package/lib/api/createUpload.d.ts +16 -0
  6. package/lib/api/createUpload.js +53 -0
  7. package/lib/api/createWebsite.d.ts +16 -0
  8. package/lib/api/createWebsite.js +39 -0
  9. package/lib/index.d.ts +17 -5
  10. package/lib/index.js +10 -4
  11. package/lib/openapi/core/ApiError.d.ts +10 -0
  12. package/lib/openapi/core/ApiError.js +11 -0
  13. package/lib/openapi/core/ApiRequestOptions.d.ts +13 -0
  14. package/lib/openapi/core/ApiRequestOptions.js +1 -0
  15. package/lib/openapi/core/ApiResult.d.ts +7 -0
  16. package/lib/openapi/core/ApiResult.js +1 -0
  17. package/lib/openapi/core/CancelablePromise.d.ts +20 -0
  18. package/lib/openapi/core/CancelablePromise.js +111 -0
  19. package/lib/openapi/core/OpenAPI.d.ts +16 -0
  20. package/lib/openapi/core/OpenAPI.js +11 -0
  21. package/lib/openapi/core/request.d.ts +30 -0
  22. package/lib/openapi/core/request.js +275 -0
  23. package/lib/openapi/index.d.ts +31 -0
  24. package/lib/openapi/index.js +11 -0
  25. package/lib/openapi/models/ApiDtoType.d.ts +6 -0
  26. package/lib/openapi/models/ApiDtoType.js +11 -0
  27. package/lib/openapi/models/ChatCompletionDto.d.ts +10 -0
  28. package/lib/openapi/models/ChatCompletionDto.js +1 -0
  29. package/lib/openapi/models/ChatCompletionStreamCompletedEventDto.d.ts +9 -0
  30. package/lib/openapi/models/ChatCompletionStreamCompletedEventDto.js +1 -0
  31. package/lib/openapi/models/CreateAnthropicChatCompletionDto.d.ts +8 -0
  32. package/lib/openapi/models/CreateAnthropicChatCompletionDto.js +1 -0
  33. package/lib/openapi/models/CreateChatCompletionRequest.d.ts +10 -0
  34. package/lib/openapi/models/CreateChatCompletionRequest.js +1 -0
  35. package/lib/openapi/models/CreateChatCompletionStreamRequest.d.ts +3 -0
  36. package/lib/openapi/models/CreateChatCompletionStreamRequest.js +1 -0
  37. package/lib/openapi/models/CreateGeminiChatCompletionDto.d.ts +8 -0
  38. package/lib/openapi/models/CreateGeminiChatCompletionDto.js +1 -0
  39. package/lib/openapi/models/CreateOpenAiChatCompletionDto.d.ts +8 -0
  40. package/lib/openapi/models/CreateOpenAiChatCompletionDto.js +1 -0
  41. package/lib/openapi/models/CreateOpenAiChatCompletionMessageDto.d.ts +4 -0
  42. package/lib/openapi/models/CreateOpenAiChatCompletionMessageDto.js +1 -0
  43. package/lib/openapi/models/CreateStreamRequest.d.ts +6 -0
  44. package/lib/openapi/models/CreateStreamRequest.js +1 -0
  45. package/lib/openapi/models/CreateWebsiteRequest.d.ts +3 -0
  46. package/lib/openapi/models/CreateWebsiteRequest.js +1 -0
  47. package/lib/openapi/models/FileUploadCompletedEventDto.d.ts +11 -0
  48. package/lib/openapi/models/FileUploadCompletedEventDto.js +1 -0
  49. package/lib/openapi/models/NewChatCompletionStreamChunkEventDto.d.ts +10 -0
  50. package/lib/openapi/models/NewChatCompletionStreamChunkEventDto.js +1 -0
  51. package/lib/openapi/models/PubCreateUploadRequest.d.ts +6 -0
  52. package/lib/openapi/models/PubCreateUploadRequest.js +1 -0
  53. package/lib/openapi/models/PubUploadDto.d.ts +6 -0
  54. package/lib/openapi/models/PubUploadDto.js +1 -0
  55. package/lib/openapi/models/PubWebsiteDto.d.ts +5 -0
  56. package/lib/openapi/models/PubWebsiteDto.js +1 -0
  57. package/lib/openapi/models/S3PostRequestDto.d.ts +10 -0
  58. package/lib/openapi/models/S3PostRequestDto.js +1 -0
  59. package/lib/openapi/models/StoredChatCompletionId.d.ts +3 -0
  60. package/lib/openapi/models/StoredChatCompletionId.js +1 -0
  61. package/lib/openapi/models/StoredFileId.d.ts +3 -0
  62. package/lib/openapi/models/StoredFileId.js +1 -0
  63. package/lib/openapi/models/StoredStreamId.d.ts +3 -0
  64. package/lib/openapi/models/StoredStreamId.js +1 -0
  65. package/lib/openapi/models/StoredUploadId.d.ts +3 -0
  66. package/lib/openapi/models/StoredUploadId.js +1 -0
  67. package/lib/openapi/models/StreamDto.d.ts +6 -0
  68. package/lib/openapi/models/StreamDto.js +1 -0
  69. package/lib/openapi/models/StreamEventType.d.ts +7 -0
  70. package/lib/openapi/models/StreamEventType.js +12 -0
  71. package/lib/openapi/models/StreamNotFoundEventDto.d.ts +7 -0
  72. package/lib/openapi/models/StreamNotFoundEventDto.js +1 -0
  73. package/lib/openapi/models/StreamTimeoutEventDto.d.ts +7 -0
  74. package/lib/openapi/models/StreamTimeoutEventDto.js +1 -0
  75. package/lib/openapi/models/StreamType.d.ts +4 -0
  76. package/lib/openapi/models/StreamType.js +9 -0
  77. package/lib/openapi/services/PubService.d.ts +50 -0
  78. package/lib/openapi/services/PubService.js +71 -0
  79. package/lib/types/CreateStreamRequest.d.ts +6 -0
  80. package/lib/types/CreateStreamRequest.js +1 -0
  81. package/lib/types/CreateStreamResponse.d.ts +9 -0
  82. package/lib/types/CreateStreamResponse.js +1 -0
  83. package/lib/types/CreateUploadRequest.d.ts +6 -0
  84. package/lib/types/CreateUploadRequest.js +1 -0
  85. package/lib/types/CreateUploadResponse.d.ts +9 -0
  86. package/lib/types/CreateUploadResponse.js +1 -0
  87. package/lib/types/CreateWebsiteRequest.d.ts +3 -0
  88. package/lib/types/CreateWebsiteRequest.js +1 -0
  89. package/lib/types/CreateWebsiteResponse.d.ts +9 -0
  90. package/lib/types/CreateWebsiteResponse.js +1 -0
  91. package/lib/types/FencyFile.d.ts +8 -0
  92. package/lib/types/FencyFile.js +1 -0
  93. package/lib/types/FencyUpload.d.ts +6 -0
  94. package/lib/types/FencyUpload.js +1 -0
  95. package/lib/types/FencyWebsite.d.ts +5 -0
  96. package/lib/types/FencyWebsite.js +1 -0
  97. package/lib/types/S3PostRequest.d.ts +10 -0
  98. package/lib/types/S3PostRequest.js +1 -0
  99. package/lib/types/Stream.d.ts +5 -0
  100. package/lib/types/{ChatCompletionStream.js → Stream.js} +2 -2
  101. package/lib/types/StreamData.d.ts +31 -0
  102. package/lib/types/StreamData.js +1 -0
  103. package/lib/utils/version.js +1 -1
  104. package/package.json +5 -3
  105. package/lib/api/createChatCompletionStream.d.ts +0 -21
  106. package/lib/api/createChatCompletionStream.js +0 -46
  107. package/lib/types/ChatCompletionStream.d.ts +0 -5
@@ -0,0 +1,50 @@
1
+ import type { ChatCompletionDto } from '../models/ChatCompletionDto';
2
+ import type { ChatCompletionStreamCompletedEventDto } from '../models/ChatCompletionStreamCompletedEventDto';
3
+ import type { CreateChatCompletionRequest } from '../models/CreateChatCompletionRequest';
4
+ import type { CreateStreamRequest } from '../models/CreateStreamRequest';
5
+ import type { CreateWebsiteRequest } from '../models/CreateWebsiteRequest';
6
+ import type { FileUploadCompletedEventDto } from '../models/FileUploadCompletedEventDto';
7
+ import type { NewChatCompletionStreamChunkEventDto } from '../models/NewChatCompletionStreamChunkEventDto';
8
+ import type { PubCreateUploadRequest } from '../models/PubCreateUploadRequest';
9
+ import type { PubUploadDto } from '../models/PubUploadDto';
10
+ import type { PubWebsiteDto } from '../models/PubWebsiteDto';
11
+ import type { StreamDto } from '../models/StreamDto';
12
+ import type { StreamNotFoundEventDto } from '../models/StreamNotFoundEventDto';
13
+ import type { StreamTimeoutEventDto } from '../models/StreamTimeoutEventDto';
14
+ import type { CancelablePromise } from '../core/CancelablePromise';
15
+ export declare class PubService {
16
+ /**
17
+ * Create Chat Completion
18
+ * @param requestBody
19
+ * @returns any OK
20
+ * @throws ApiError
21
+ */
22
+ static createChatCompletion(requestBody: CreateChatCompletionRequest): CancelablePromise<ChatCompletionDto>;
23
+ /**
24
+ * Create Chat Completion Stream
25
+ * @param requestBody
26
+ * @returns StreamDto Created
27
+ * @throws ApiError
28
+ */
29
+ static createStream(requestBody: CreateStreamRequest): CancelablePromise<StreamDto>;
30
+ /**
31
+ * Get pub types
32
+ * @returns any OK
33
+ * @throws ApiError
34
+ */
35
+ static getPubTypes(): CancelablePromise<(StreamTimeoutEventDto | StreamNotFoundEventDto | NewChatCompletionStreamChunkEventDto | ChatCompletionStreamCompletedEventDto | FileUploadCompletedEventDto)>;
36
+ /**
37
+ * Create Upload
38
+ * @param requestBody
39
+ * @returns PubUploadDto Created
40
+ * @throws ApiError
41
+ */
42
+ static createUpload(requestBody: PubCreateUploadRequest): CancelablePromise<PubUploadDto>;
43
+ /**
44
+ * Create Website
45
+ * @param requestBody
46
+ * @returns PubWebsiteDto Created
47
+ * @throws ApiError
48
+ */
49
+ static createWebsite(requestBody: CreateWebsiteRequest): CancelablePromise<PubWebsiteDto>;
50
+ }
@@ -0,0 +1,71 @@
1
+ import { OpenAPI } from '../core/OpenAPI';
2
+ import { request as __request } from '../core/request';
3
+ export class PubService {
4
+ /**
5
+ * Create Chat Completion
6
+ * @param requestBody
7
+ * @returns any OK
8
+ * @throws ApiError
9
+ */
10
+ static createChatCompletion(requestBody) {
11
+ return __request(OpenAPI, {
12
+ method: 'POST',
13
+ url: '/v1/pub/chat-completions',
14
+ body: requestBody,
15
+ mediaType: 'application/json',
16
+ });
17
+ }
18
+ /**
19
+ * Create Chat Completion Stream
20
+ * @param requestBody
21
+ * @returns StreamDto Created
22
+ * @throws ApiError
23
+ */
24
+ static createStream(requestBody) {
25
+ return __request(OpenAPI, {
26
+ method: 'POST',
27
+ url: '/v1/pub/streams',
28
+ body: requestBody,
29
+ mediaType: 'application/json',
30
+ });
31
+ }
32
+ /**
33
+ * Get pub types
34
+ * @returns any OK
35
+ * @throws ApiError
36
+ */
37
+ static getPubTypes() {
38
+ return __request(OpenAPI, {
39
+ method: 'POST',
40
+ url: '/v1/pub/types',
41
+ });
42
+ }
43
+ /**
44
+ * Create Upload
45
+ * @param requestBody
46
+ * @returns PubUploadDto Created
47
+ * @throws ApiError
48
+ */
49
+ static createUpload(requestBody) {
50
+ return __request(OpenAPI, {
51
+ method: 'POST',
52
+ url: '/v1/pub/uploads',
53
+ body: requestBody,
54
+ mediaType: 'application/json',
55
+ });
56
+ }
57
+ /**
58
+ * Create Website
59
+ * @param requestBody
60
+ * @returns PubWebsiteDto Created
61
+ * @throws ApiError
62
+ */
63
+ static createWebsite(requestBody) {
64
+ return __request(OpenAPI, {
65
+ method: 'POST',
66
+ url: '/v1/pub/websites',
67
+ body: requestBody,
68
+ mediaType: 'application/json',
69
+ });
70
+ }
71
+ }
@@ -0,0 +1,6 @@
1
+ export interface CreateStreamRequest {
2
+ type: 'ChatCompletionStream' | 'FileUploadStream';
3
+ chatCompletionStreamOptions?: {
4
+ sessionClientSecret?: string;
5
+ };
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ApiError } from './ApiError';
2
+ import { Stream } from './Stream';
3
+ export type CreateStreamResponse = {
4
+ type: 'success';
5
+ stream: Stream;
6
+ } | {
7
+ type: 'error';
8
+ error: ApiError;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export interface CreateUploadRequest {
2
+ streamId: string;
3
+ fileName: string;
4
+ fileType: string;
5
+ fileSize: number;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ApiError } from './ApiError';
2
+ import { FencyUpload } from './FencyUpload';
3
+ export type CreateUploadResponse = {
4
+ type: 'success';
5
+ upload: FencyUpload;
6
+ } | {
7
+ type: 'error';
8
+ error: ApiError;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export interface CreateWebsiteRequest {
2
+ url: string;
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ApiError } from './ApiError';
2
+ import { FencyWebsite } from './FencyWebsite';
3
+ export type CreateWebsiteResponse = {
4
+ type: 'success';
5
+ website: FencyWebsite;
6
+ } | {
7
+ type: 'error';
8
+ error: ApiError;
9
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export interface FencyFile {
2
+ id: string;
3
+ createdAt: string;
4
+ content: string | null;
5
+ size: number | null;
6
+ type: string | null;
7
+ name: string | null;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ import { S3PostRequest } from './S3PostRequest';
2
+ export interface FencyUpload {
3
+ id: string;
4
+ createdAt: string;
5
+ s3PostRequest: S3PostRequest;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export type FencyWebsite = {
2
+ id: string;
3
+ createdAt: string;
4
+ content: string;
5
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ export interface S3PostRequest {
2
+ xAmzDate: string;
3
+ xAmzSignature: string;
4
+ xAmzAlgorithm: string;
5
+ xAmzCredential: string;
6
+ policy: string;
7
+ key: string;
8
+ uploadUrl: string;
9
+ sessionToken: string;
10
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ export interface Stream {
2
+ id: string;
3
+ createdAt: string;
4
+ }
5
+ export declare const isStream: (data: any) => data is Stream;
@@ -1,7 +1,7 @@
1
- export const isChatCompletionStream = (data) => {
1
+ export const isStream = (data) => {
2
2
  return (typeof data === 'object' &&
3
3
  data !== null &&
4
4
  'id' in data &&
5
5
  'createdAt' in data &&
6
- data.type === 'ChatCompletionStream');
6
+ data.type === 'Stream');
7
7
  };
@@ -0,0 +1,31 @@
1
+ export type NewChatCompletionStreamChunk = {
2
+ type: 'NewChatCompletionStreamChunk';
3
+ streamId: string;
4
+ chatCompletionId: string;
5
+ timestamp: string;
6
+ content: string;
7
+ };
8
+ export type ChatCompletionStreamCompleted = {
9
+ type: 'ChatCompletionStreamCompleted';
10
+ streamId: string;
11
+ chatCompletionId: string;
12
+ timestamp: string;
13
+ };
14
+ export type StreamTimeout = {
15
+ type: 'StreamTimeout';
16
+ streamId: string;
17
+ timestamp: string;
18
+ };
19
+ export type StreamNotFound = {
20
+ type: 'StreamNotFound';
21
+ streamId: string;
22
+ timestamp: string;
23
+ };
24
+ export type FileUploadCompleted = {
25
+ type: 'FileUploadCompleted';
26
+ streamId: string;
27
+ uploadId: string;
28
+ fileId: string;
29
+ timestamp: string;
30
+ };
31
+ export type StreamData = NewChatCompletionStreamChunk | ChatCompletionStreamCompleted | StreamTimeout | StreamNotFound | FileUploadCompleted;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  // Browser-compatible version utility
2
2
  // The version is set at build time and can be overridden if needed
3
3
  // Build-time version constant - this should be updated during the build process
4
- const SDK_VERSION = '0.1.41';
4
+ const SDK_VERSION = '0.1.42';
5
5
  // Allow runtime override if needed
6
6
  let versionOverride = null;
7
7
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fencyai/js",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "description": "> TODO: description",
5
5
  "author": "staklau <steinaageklaussen@gmail.com>",
6
6
  "homepage": "",
@@ -30,14 +30,16 @@
30
30
  "test": "jest",
31
31
  "test:watch": "jest --watch",
32
32
  "dev": "tsc --watch",
33
- "prepublishOnly": "npm run build"
33
+ "prepublishOnly": "npm run build",
34
+ "codegen": "openapi --input http://localhost:8080/v1/pub/swagger.json --output ./src/openapi"
34
35
  },
35
36
  "devDependencies": {
36
37
  "@types/jest": "^29.5.11",
37
38
  "@types/node": "^20.10.5",
38
39
  "jest": "^29.7.0",
40
+ "openapi-typescript-codegen": "^0.29.0",
39
41
  "ts-jest": "^29.1.1",
40
42
  "typescript": "^5.3.3"
41
43
  },
42
- "gitHead": "a8e44437447dc885782eaf34c5df4cca71012e3f"
44
+ "gitHead": "0c797d40ee1243848951a464a5140d9defbb5785"
43
45
  }
@@ -1,21 +0,0 @@
1
- import { ApiError } from '../types/ApiError';
2
- import { ChatCompletionStream } from '../types/ChatCompletionStream';
3
- /**
4
- * Creates a new stream by making a POST request to the Fency API.
5
- *
6
- * @param pk - The publishable key (used as Bearer token and default name)
7
- * @param options - Optional configuration (apiUrl, name)
8
- * @returns A promise that resolves to a ChatCompletionStream
9
- * @throws Error if the request fails or the response is invalid
10
- */
11
- export type CreateChatCompletionStreamResponse = {
12
- type: 'success';
13
- stream: ChatCompletionStream;
14
- } | {
15
- type: 'error';
16
- error: ApiError;
17
- };
18
- export declare function createChatCompletionStream(params: {
19
- pk: string;
20
- baseUrl: string;
21
- }): Promise<CreateChatCompletionStreamResponse>;
@@ -1,46 +0,0 @@
1
- import { isChatCompletionStream, } from '../types/ChatCompletionStream';
2
- import { parseNonOkResponse } from '../utils/parseNonOkResponse';
3
- import { getPackageVersion } from '../utils/version';
4
- export async function createChatCompletionStream(params) {
5
- const apiUrl = `${params.baseUrl}/v1/pub/chat-completion-streams`;
6
- try {
7
- const response = await fetch(apiUrl, {
8
- method: 'POST',
9
- headers: {
10
- 'Content-Type': 'application/json',
11
- Authorization: `Bearer ${params.pk}`,
12
- 'X-Fency-Sdk-Version': getPackageVersion(),
13
- },
14
- });
15
- if (!response.ok) {
16
- const error = await parseNonOkResponse(response);
17
- return {
18
- type: 'error',
19
- error: error,
20
- };
21
- }
22
- const stream = await response.json();
23
- if (!isChatCompletionStream(stream)) {
24
- return {
25
- type: 'error',
26
- error: {
27
- code: 'InvalidResponse',
28
- message: `Invalid stream response: ${JSON.stringify(stream)}`,
29
- },
30
- };
31
- }
32
- return {
33
- type: 'success',
34
- stream: stream,
35
- };
36
- }
37
- catch (error) {
38
- return {
39
- type: 'error',
40
- error: {
41
- code: 'UnknownError',
42
- message: `Unknown error!\n${error ? `Error: ${error}\n` : ''}`.trim(),
43
- },
44
- };
45
- }
46
- }
@@ -1,5 +0,0 @@
1
- export interface ChatCompletionStream {
2
- id: string;
3
- createdAt: string;
4
- }
5
- export declare const isChatCompletionStream: (data: any) => data is ChatCompletionStream;