@fencyai/js 0.1.106 → 0.1.108
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/api/createAgentTask.d.ts +2 -1
- package/lib/api/createAgentTask.js +4 -4
- package/lib/api/createFileDownloadLink.d.ts +2 -1
- package/lib/api/createFileDownloadLink.js +5 -3
- package/lib/api/createStream.d.ts +1 -1
- package/lib/api/createStream.js +20 -4
- package/lib/index.d.ts +10 -5
- package/lib/index.js +2 -3
- package/lib/loadFency.d.ts +2 -1
- package/lib/openapi/client/index.d.ts +9 -0
- package/lib/openapi/client/index.js +9 -0
- package/lib/openapi/{models → client/models}/PubCreateAgentTaskRequest.d.ts +0 -1
- package/lib/openapi/client/services/PubService.d.ts +20 -0
- package/lib/openapi/client/services/PubService.js +33 -0
- package/lib/openapi/stream/core/ApiError.d.ts +10 -0
- package/lib/openapi/stream/core/ApiError.js +11 -0
- package/lib/openapi/stream/core/ApiRequestOptions.d.ts +13 -0
- package/lib/openapi/stream/core/ApiResult.d.ts +7 -0
- package/lib/openapi/stream/core/CancelablePromise.d.ts +20 -0
- package/lib/openapi/stream/core/CancelablePromise.js +111 -0
- package/lib/openapi/stream/core/OpenAPI.d.ts +16 -0
- package/lib/openapi/stream/core/OpenAPI.js +11 -0
- package/lib/openapi/stream/core/request.d.ts +30 -0
- package/lib/openapi/stream/core/request.js +275 -0
- package/lib/openapi/{index.d.ts → stream/index.d.ts} +0 -10
- package/lib/openapi/{index.js → stream/index.js} +0 -1
- package/lib/openapi/{models → stream/models}/StreamDto.d.ts +1 -0
- package/lib/openapi/stream/services/PubService.d.ts +24 -0
- package/lib/openapi/stream/services/PubService.js +26 -0
- package/lib/types/AgentTask.d.ts +1 -1
- package/lib/types/Stream.d.ts +1 -0
- package/lib/types/index.d.ts +1 -22
- package/lib/types/index.js +1 -2
- package/lib/utils/version.js +1 -1
- package/package.json +3 -3
- package/lib/api/listMemoryTypes.d.ts +0 -6
- package/lib/api/listMemoryTypes.js +0 -28
- package/lib/api/searchMemories.d.ts +0 -8
- package/lib/api/searchMemories.js +0 -27
- package/lib/openapi/models/ListMemoryTypesResponse.d.ts +0 -6
- package/lib/openapi/models/PaginationDto.d.ts +0 -4
- package/lib/openapi/models/PubMemoryDto.d.ts +0 -5
- package/lib/openapi/models/PubMemoryDto.js +0 -1
- package/lib/openapi/models/PubMemoryTypeDto.d.ts +0 -5
- package/lib/openapi/models/PubMemoryTypeDto.js +0 -1
- package/lib/openapi/models/PubSearchMemoriesRequest.d.ts +0 -4
- package/lib/openapi/models/PubSearchMemoriesRequest.js +0 -1
- package/lib/openapi/models/PubSearchMemoriesResponse.d.ts +0 -4
- package/lib/openapi/models/PubSearchMemoriesResponse.js +0 -1
- package/lib/openapi/services/PubService.d.ts +0 -63
- package/lib/openapi/services/PubService.js +0 -96
- package/lib/types/AnthropicModel.d.ts +0 -1
- package/lib/types/AnthropicModel.js +0 -1
- package/lib/types/ChatCompletion.d.ts +0 -8
- package/lib/types/ChatCompletion.js +0 -7
- package/lib/types/ChatCompletionMessage.d.ts +0 -4
- package/lib/types/ChatCompletionMessage.js +0 -1
- package/lib/types/ClaudeChatCompletionMessage.d.ts +0 -4
- package/lib/types/ClaudeChatCompletionMessage.js +0 -1
- package/lib/types/CreateChatCompletionRequest.d.ts +0 -10
- package/lib/types/CreateChatCompletionRequest.js +0 -1
- package/lib/types/CreateChatCompletionResponse.d.ts +0 -9
- package/lib/types/CreateChatCompletionResponse.js +0 -1
- package/lib/types/CreateClaudeChatCompletionRequestParams.d.ts +0 -10
- package/lib/types/CreateClaudeChatCompletionRequestParams.js +0 -1
- package/lib/types/CreateGeminiChatCompletionRequestParams.d.ts +0 -11
- package/lib/types/CreateGeminiChatCompletionRequestParams.js +0 -1
- package/lib/types/CreateOpenAiChatCompletionRequestParams.d.ts +0 -9
- package/lib/types/CreateOpenAiChatCompletionRequestParams.js +0 -1
- package/lib/types/GeminiChatCompletionMessage.d.ts +0 -4
- package/lib/types/GeminiChatCompletionMessage.js +0 -1
- package/lib/types/GeminiModel.d.ts +0 -1
- package/lib/types/GeminiModel.js +0 -1
- package/lib/types/ListMemoryTypesResponse.d.ts +0 -10
- package/lib/types/ListMemoryTypesResponse.js +0 -1
- package/lib/types/OpenAiModel.d.ts +0 -1
- package/lib/types/OpenAiModel.js +0 -1
- package/lib/types/SearchMemoriesRequest.d.ts +0 -4
- package/lib/types/SearchMemoriesRequest.js +0 -1
- package/lib/types/SearchMemoriesResponse.d.ts +0 -9
- package/lib/types/SearchMemoriesResponse.js +0 -1
- /package/lib/openapi/{core → client/core}/ApiError.d.ts +0 -0
- /package/lib/openapi/{core → client/core}/ApiError.js +0 -0
- /package/lib/openapi/{core → client/core}/ApiRequestOptions.d.ts +0 -0
- /package/lib/openapi/{core → client/core}/ApiRequestOptions.js +0 -0
- /package/lib/openapi/{core → client/core}/ApiResult.d.ts +0 -0
- /package/lib/openapi/{core → client/core}/ApiResult.js +0 -0
- /package/lib/openapi/{core → client/core}/CancelablePromise.d.ts +0 -0
- /package/lib/openapi/{core → client/core}/CancelablePromise.js +0 -0
- /package/lib/openapi/{core → client/core}/OpenAPI.d.ts +0 -0
- /package/lib/openapi/{core → client/core}/OpenAPI.js +0 -0
- /package/lib/openapi/{core → client/core}/request.d.ts +0 -0
- /package/lib/openapi/{core → client/core}/request.js +0 -0
- /package/lib/openapi/{models → client/models}/AgentTaskStatusDto.d.ts +0 -0
- /package/lib/openapi/{models → client/models}/AgentTaskStatusDto.js +0 -0
- /package/lib/openapi/{models → client/models}/PubAgentTaskDto.d.ts +0 -0
- /package/lib/openapi/{models → client/models}/PubAgentTaskDto.js +0 -0
- /package/lib/openapi/{models → client/models}/PubCreateAgentTaskRequest.js +0 -0
- /package/lib/openapi/{models → client/models}/PubCreateFileDownloadLinkResponse.d.ts +0 -0
- /package/lib/openapi/{models → client/models}/PubCreateFileDownloadLinkResponse.js +0 -0
- /package/lib/openapi/{models/AgentTaskProgressItemUpdatedEventDto.js → stream/core/ApiRequestOptions.js} +0 -0
- /package/lib/openapi/{models/ChatCompletionStreamCompletedEventDto.js → stream/core/ApiResult.js} +0 -0
- /package/lib/openapi/{models → stream/models}/AgentTaskProgressItemType.d.ts +0 -0
- /package/lib/openapi/{models → stream/models}/AgentTaskProgressItemType.js +0 -0
- /package/lib/openapi/{models → stream/models}/AgentTaskProgressItemUpdatedEventDto.d.ts +0 -0
- /package/lib/openapi/{models/FileSearchIndexReadyEventDto.js → stream/models/AgentTaskProgressItemUpdatedEventDto.js} +0 -0
- /package/lib/openapi/{models → stream/models}/ApiDtoType.d.ts +0 -0
- /package/lib/openapi/{models → stream/models}/ApiDtoType.js +0 -0
- /package/lib/openapi/{models → stream/models}/ChatCompletionStreamCompletedEventDto.d.ts +0 -0
- /package/lib/openapi/{models/FileTextContentReadyEventDto.js → stream/models/ChatCompletionStreamCompletedEventDto.js} +0 -0
- /package/lib/openapi/{models → stream/models}/FileSearchIndexReadyEventDto.d.ts +0 -0
- /package/lib/openapi/{models/FileUploadCompletedEventDto.js → stream/models/FileSearchIndexReadyEventDto.js} +0 -0
- /package/lib/openapi/{models → stream/models}/FileTextContentReadyEventDto.d.ts +0 -0
- /package/lib/openapi/{models/ListMemoryTypesResponse.js → stream/models/FileTextContentReadyEventDto.js} +0 -0
- /package/lib/openapi/{models → stream/models}/FileUploadCompletedEventDto.d.ts +0 -0
- /package/lib/openapi/{models/NewChatCompletionStreamChunkEventDto.js → stream/models/FileUploadCompletedEventDto.js} +0 -0
- /package/lib/openapi/{models → stream/models}/NewChatCompletionStreamChunkEventDto.d.ts +0 -0
- /package/lib/openapi/{models/PaginationDto.js → stream/models/NewChatCompletionStreamChunkEventDto.js} +0 -0
- /package/lib/openapi/{models → stream/models}/StreamDto.js +0 -0
- /package/lib/openapi/{models → stream/models}/StreamEventType.d.ts +0 -0
- /package/lib/openapi/{models → stream/models}/StreamEventType.js +0 -0
- /package/lib/openapi/{models → stream/models}/StreamNotFoundEventDto.d.ts +0 -0
- /package/lib/openapi/{models → stream/models}/StreamNotFoundEventDto.js +0 -0
- /package/lib/openapi/{models → stream/models}/StreamTimeoutEventDto.d.ts +0 -0
- /package/lib/openapi/{models → stream/models}/StreamTimeoutEventDto.js +0 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { OpenAPI, PubService } from '../openapi';
|
|
1
|
+
import { OpenAPI, PubService } from '../openapi/client';
|
|
2
2
|
import { getPackageVersion } from '../utils/version';
|
|
3
3
|
export async function createAgentTask(params) {
|
|
4
4
|
try {
|
|
5
5
|
OpenAPI.BASE = params.baseUrl;
|
|
6
6
|
OpenAPI.HEADERS = {
|
|
7
7
|
'Content-Type': 'application/json',
|
|
8
|
-
Authorization: `Bearer ${params.pk}`,
|
|
9
8
|
'X-Fency-Sdk-Version': getPackageVersion(),
|
|
10
|
-
'X-Fency-
|
|
9
|
+
'X-Fency-Publishable-Key': params.pk,
|
|
10
|
+
'X-Fency-Client-Token': params.clientToken,
|
|
11
|
+
'X-Fency-Stream-Token': params.streamToken,
|
|
11
12
|
};
|
|
12
13
|
const response = await PubService.createAgentTask({
|
|
13
14
|
queryText: params.request.queryText,
|
|
14
|
-
streamId: params.request.streamId,
|
|
15
15
|
jsonSchema: params.request.jsonSchema,
|
|
16
16
|
todos: params.request.todos ?? [],
|
|
17
17
|
});
|
|
@@ -2,7 +2,8 @@ import { CreateFileDownloadLinkRequest } from '../types/CreateFileDownloadLinkRe
|
|
|
2
2
|
import { CreateFileDownloadLinkResponse } from '../types/CreateFileDownloadLinkResponse';
|
|
3
3
|
export declare function createFileDownloadLink(params: {
|
|
4
4
|
pk: string;
|
|
5
|
-
|
|
5
|
+
clientToken: string;
|
|
6
|
+
streamToken: string;
|
|
6
7
|
request: CreateFileDownloadLinkRequest;
|
|
7
8
|
baseUrl: string;
|
|
8
9
|
}): Promise<CreateFileDownloadLinkResponse>;
|
|
@@ -4,7 +4,8 @@ export async function createFileDownloadLink(params) {
|
|
|
4
4
|
const response = await createFileDownloadLinkApi({
|
|
5
5
|
baseUrl: params.baseUrl,
|
|
6
6
|
pk: params.pk,
|
|
7
|
-
|
|
7
|
+
clientToken: params.clientToken,
|
|
8
|
+
streamToken: params.streamToken,
|
|
8
9
|
fileId: params.request.fileId,
|
|
9
10
|
});
|
|
10
11
|
return {
|
|
@@ -21,9 +22,10 @@ async function createFileDownloadLinkApi(params) {
|
|
|
21
22
|
method: 'POST',
|
|
22
23
|
headers: {
|
|
23
24
|
'Content-Type': 'application/json',
|
|
24
|
-
Authorization: `Bearer ${params.pk}`,
|
|
25
25
|
'X-Fency-Sdk-Version': getPackageVersion(),
|
|
26
|
-
'X-Fency-
|
|
26
|
+
'X-Fency-Publishable-Key': params.pk,
|
|
27
|
+
'X-Fency-Client-Token': params.clientToken,
|
|
28
|
+
'X-Fency-Stream-Token': params.streamToken,
|
|
27
29
|
},
|
|
28
30
|
});
|
|
29
31
|
if (!response.ok) {
|
package/lib/api/createStream.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { OpenAPI
|
|
1
|
+
import { OpenAPI } from '../openapi/stream';
|
|
2
2
|
import { getPackageVersion } from '../utils/version';
|
|
3
3
|
export async function createStream(params) {
|
|
4
4
|
try {
|
|
5
5
|
OpenAPI.BASE = params.baseUrl;
|
|
6
6
|
OpenAPI.HEADERS = {
|
|
7
7
|
'Content-Type': 'application/json',
|
|
8
|
-
Authorization: `Bearer ${params.pk}`,
|
|
9
8
|
'X-Fency-Sdk-Version': getPackageVersion(),
|
|
10
|
-
'X-Fency-
|
|
9
|
+
'X-Fency-Publishable-Key': params.pk,
|
|
10
|
+
'X-Fency-Client-Token': params.clientToken,
|
|
11
11
|
};
|
|
12
|
-
const response = await
|
|
12
|
+
const response = await createStreamApi(params);
|
|
13
13
|
return {
|
|
14
14
|
type: 'success',
|
|
15
15
|
stream: {
|
|
16
16
|
id: response.id,
|
|
17
17
|
createdAt: response.createdAt,
|
|
18
|
+
token: response.token,
|
|
18
19
|
},
|
|
19
20
|
};
|
|
20
21
|
}
|
|
@@ -28,3 +29,18 @@ export async function createStream(params) {
|
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
}
|
|
32
|
+
const createStreamApi = async (params) => {
|
|
33
|
+
const response = await fetch(`${params.baseUrl}/pub/stream/streams`, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
'X-Fency-Sdk-Version': getPackageVersion(),
|
|
38
|
+
'X-Fency-Publishable-Key': params.pk,
|
|
39
|
+
'X-Fency-Client-Token': params.clientToken,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
throw new Error(`Failed to create stream: ${response.statusText}`);
|
|
44
|
+
}
|
|
45
|
+
return response.json();
|
|
46
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
export { loadFency } from './loadFency';
|
|
2
|
-
export type { FencyInstance
|
|
2
|
+
export type { FencyInstance } from './types/FencyInstance';
|
|
3
|
+
export type { FencyOptions } from './types/FencyOptions';
|
|
3
4
|
export * from './types/index';
|
|
4
|
-
export
|
|
5
|
-
export {
|
|
5
|
+
export { AgentTaskProgressItemType } from './openapi/stream/models/AgentTaskProgressItemType';
|
|
6
|
+
export type { AgentTaskProgressItemUpdatedEventDto } from './openapi/stream/models/AgentTaskProgressItemUpdatedEventDto';
|
|
7
|
+
export type { ChatCompletionStreamCompletedEventDto } from './openapi/stream/models/ChatCompletionStreamCompletedEventDto';
|
|
8
|
+
export type { FileTextContentReadyEventDto } from './openapi/stream/models/FileTextContentReadyEventDto';
|
|
9
|
+
export type { FileUploadCompletedEventDto } from './openapi/stream/models/FileUploadCompletedEventDto';
|
|
10
|
+
export type { NewChatCompletionStreamChunkEventDto } from './openapi/stream/models/NewChatCompletionStreamChunkEventDto';
|
|
11
|
+
export type { StreamNotFoundEventDto } from './openapi/stream/models/StreamNotFoundEventDto';
|
|
12
|
+
export type { StreamTimeoutEventDto } from './openapi/stream/models/StreamTimeoutEventDto';
|
|
6
13
|
export { createAgentTask } from './api/createAgentTask';
|
|
7
14
|
export { createStream } from './api/createStream';
|
|
8
|
-
export { listMemoryTypes } from './api/listMemoryTypes';
|
|
9
|
-
export { searchMemories } from './api/searchMemories';
|
|
10
15
|
export { createFileDownloadLink } from './api/createFileDownloadLink';
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { loadFency } from './loadFency';
|
|
2
2
|
export * from './types/index';
|
|
3
|
-
|
|
3
|
+
// stream event types
|
|
4
|
+
export { AgentTaskProgressItemType } from './openapi/stream/models/AgentTaskProgressItemType';
|
|
4
5
|
// api
|
|
5
6
|
export { createAgentTask } from './api/createAgentTask';
|
|
6
7
|
export { createStream } from './api/createStream';
|
|
7
|
-
export { listMemoryTypes } from './api/listMemoryTypes';
|
|
8
|
-
export { searchMemories } from './api/searchMemories';
|
|
9
8
|
export { createFileDownloadLink } from './api/createFileDownloadLink';
|
package/lib/loadFency.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { FencyInstance
|
|
1
|
+
import { FencyInstance } from './types/FencyInstance';
|
|
2
|
+
import { FencyOptions } from './types/FencyOptions';
|
|
2
3
|
/**
|
|
3
4
|
* Loads the Fency library with the given publishable key.
|
|
4
5
|
* This method should be called outside of a component's render to avoid
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ApiError } from './core/ApiError';
|
|
2
|
+
export { CancelablePromise, CancelError } from './core/CancelablePromise';
|
|
3
|
+
export { OpenAPI } from './core/OpenAPI';
|
|
4
|
+
export type { OpenAPIConfig } from './core/OpenAPI';
|
|
5
|
+
export { AgentTaskStatusDto } from './models/AgentTaskStatusDto';
|
|
6
|
+
export type { PubAgentTaskDto } from './models/PubAgentTaskDto';
|
|
7
|
+
export type { PubCreateAgentTaskRequest } from './models/PubCreateAgentTaskRequest';
|
|
8
|
+
export type { PubCreateFileDownloadLinkResponse } from './models/PubCreateFileDownloadLinkResponse';
|
|
9
|
+
export { PubService } from './services/PubService';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export { ApiError } from './core/ApiError';
|
|
6
|
+
export { CancelablePromise, CancelError } from './core/CancelablePromise';
|
|
7
|
+
export { OpenAPI } from './core/OpenAPI';
|
|
8
|
+
export { AgentTaskStatusDto } from './models/AgentTaskStatusDto';
|
|
9
|
+
export { PubService } from './services/PubService';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PubAgentTaskDto } from '../models/PubAgentTaskDto';
|
|
2
|
+
import type { PubCreateAgentTaskRequest } from '../models/PubCreateAgentTaskRequest';
|
|
3
|
+
import type { PubCreateFileDownloadLinkResponse } from '../models/PubCreateFileDownloadLinkResponse';
|
|
4
|
+
import type { CancelablePromise } from '../core/CancelablePromise';
|
|
5
|
+
export declare class PubService {
|
|
6
|
+
/**
|
|
7
|
+
* Create AgentTask
|
|
8
|
+
* @param requestBody
|
|
9
|
+
* @returns PubAgentTaskDto Created
|
|
10
|
+
* @throws ApiError
|
|
11
|
+
*/
|
|
12
|
+
static createAgentTask(requestBody: PubCreateAgentTaskRequest): CancelablePromise<PubAgentTaskDto>;
|
|
13
|
+
/**
|
|
14
|
+
* Create File Download Link
|
|
15
|
+
* @param fileId
|
|
16
|
+
* @returns PubCreateFileDownloadLinkResponse OK
|
|
17
|
+
* @throws ApiError
|
|
18
|
+
*/
|
|
19
|
+
static createFileDownloadLink(fileId: string): CancelablePromise<PubCreateFileDownloadLinkResponse>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OpenAPI } from '../core/OpenAPI';
|
|
2
|
+
import { request as __request } from '../core/request';
|
|
3
|
+
export class PubService {
|
|
4
|
+
/**
|
|
5
|
+
* Create AgentTask
|
|
6
|
+
* @param requestBody
|
|
7
|
+
* @returns PubAgentTaskDto Created
|
|
8
|
+
* @throws ApiError
|
|
9
|
+
*/
|
|
10
|
+
static createAgentTask(requestBody) {
|
|
11
|
+
return __request(OpenAPI, {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
url: '/pub/client/agent-tasks',
|
|
14
|
+
body: requestBody,
|
|
15
|
+
mediaType: 'application/json',
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create File Download Link
|
|
20
|
+
* @param fileId
|
|
21
|
+
* @returns PubCreateFileDownloadLinkResponse OK
|
|
22
|
+
* @throws ApiError
|
|
23
|
+
*/
|
|
24
|
+
static createFileDownloadLink(fileId) {
|
|
25
|
+
return __request(OpenAPI, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
url: '/pub/client/files/{fileId}/download-links',
|
|
28
|
+
path: {
|
|
29
|
+
'fileId': fileId,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
+
import type { ApiResult } from './ApiResult';
|
|
3
|
+
export declare class ApiError extends Error {
|
|
4
|
+
readonly url: string;
|
|
5
|
+
readonly status: number;
|
|
6
|
+
readonly statusText: string;
|
|
7
|
+
readonly body: any;
|
|
8
|
+
readonly request: ApiRequestOptions;
|
|
9
|
+
constructor(request: ApiRequestOptions, response: ApiResult, message: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class ApiError extends Error {
|
|
2
|
+
constructor(request, response, message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'ApiError';
|
|
5
|
+
this.url = response.url;
|
|
6
|
+
this.status = response.status;
|
|
7
|
+
this.statusText = response.statusText;
|
|
8
|
+
this.body = response.body;
|
|
9
|
+
this.request = request;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ApiRequestOptions = {
|
|
2
|
+
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
3
|
+
readonly url: string;
|
|
4
|
+
readonly path?: Record<string, any>;
|
|
5
|
+
readonly cookies?: Record<string, any>;
|
|
6
|
+
readonly headers?: Record<string, any>;
|
|
7
|
+
readonly query?: Record<string, any>;
|
|
8
|
+
readonly formData?: Record<string, any>;
|
|
9
|
+
readonly body?: any;
|
|
10
|
+
readonly mediaType?: string;
|
|
11
|
+
readonly responseHeader?: string;
|
|
12
|
+
readonly errors?: Record<number, string>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class CancelError extends Error {
|
|
2
|
+
constructor(message: string);
|
|
3
|
+
get isCancelled(): boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface OnCancel {
|
|
6
|
+
readonly isResolved: boolean;
|
|
7
|
+
readonly isRejected: boolean;
|
|
8
|
+
readonly isCancelled: boolean;
|
|
9
|
+
(cancelHandler: () => void): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class CancelablePromise<T> implements Promise<T> {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
|
|
14
|
+
get [Symbol.toStringTag](): string;
|
|
15
|
+
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
16
|
+
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
17
|
+
finally(onFinally?: (() => void) | null): Promise<T>;
|
|
18
|
+
cancel(): void;
|
|
19
|
+
get isCancelled(): boolean;
|
|
20
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _CancelablePromise_isResolved, _CancelablePromise_isRejected, _CancelablePromise_isCancelled, _CancelablePromise_cancelHandlers, _CancelablePromise_promise, _CancelablePromise_resolve, _CancelablePromise_reject;
|
|
13
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
14
|
+
/* istanbul ignore file */
|
|
15
|
+
/* tslint:disable */
|
|
16
|
+
/* eslint-disable */
|
|
17
|
+
export class CancelError extends Error {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'CancelError';
|
|
21
|
+
}
|
|
22
|
+
get isCancelled() {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class CancelablePromise {
|
|
27
|
+
constructor(executor) {
|
|
28
|
+
_CancelablePromise_isResolved.set(this, void 0);
|
|
29
|
+
_CancelablePromise_isRejected.set(this, void 0);
|
|
30
|
+
_CancelablePromise_isCancelled.set(this, void 0);
|
|
31
|
+
_CancelablePromise_cancelHandlers.set(this, void 0);
|
|
32
|
+
_CancelablePromise_promise.set(this, void 0);
|
|
33
|
+
_CancelablePromise_resolve.set(this, void 0);
|
|
34
|
+
_CancelablePromise_reject.set(this, void 0);
|
|
35
|
+
__classPrivateFieldSet(this, _CancelablePromise_isResolved, false, "f");
|
|
36
|
+
__classPrivateFieldSet(this, _CancelablePromise_isRejected, false, "f");
|
|
37
|
+
__classPrivateFieldSet(this, _CancelablePromise_isCancelled, false, "f");
|
|
38
|
+
__classPrivateFieldSet(this, _CancelablePromise_cancelHandlers, [], "f");
|
|
39
|
+
__classPrivateFieldSet(this, _CancelablePromise_promise, new Promise((resolve, reject) => {
|
|
40
|
+
__classPrivateFieldSet(this, _CancelablePromise_resolve, resolve, "f");
|
|
41
|
+
__classPrivateFieldSet(this, _CancelablePromise_reject, reject, "f");
|
|
42
|
+
const onResolve = (value) => {
|
|
43
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
__classPrivateFieldSet(this, _CancelablePromise_isResolved, true, "f");
|
|
47
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_resolve, "f"))
|
|
48
|
+
__classPrivateFieldGet(this, _CancelablePromise_resolve, "f").call(this, value);
|
|
49
|
+
};
|
|
50
|
+
const onReject = (reason) => {
|
|
51
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
__classPrivateFieldSet(this, _CancelablePromise_isRejected, true, "f");
|
|
55
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_reject, "f"))
|
|
56
|
+
__classPrivateFieldGet(this, _CancelablePromise_reject, "f").call(this, reason);
|
|
57
|
+
};
|
|
58
|
+
const onCancel = (cancelHandler) => {
|
|
59
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").push(cancelHandler);
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(onCancel, 'isResolved', {
|
|
65
|
+
get: () => __classPrivateFieldGet(this, _CancelablePromise_isResolved, "f"),
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(onCancel, 'isRejected', {
|
|
68
|
+
get: () => __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f"),
|
|
69
|
+
});
|
|
70
|
+
Object.defineProperty(onCancel, 'isCancelled', {
|
|
71
|
+
get: () => __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f"),
|
|
72
|
+
});
|
|
73
|
+
return executor(onResolve, onReject, onCancel);
|
|
74
|
+
}), "f");
|
|
75
|
+
}
|
|
76
|
+
get [(_CancelablePromise_isResolved = new WeakMap(), _CancelablePromise_isRejected = new WeakMap(), _CancelablePromise_isCancelled = new WeakMap(), _CancelablePromise_cancelHandlers = new WeakMap(), _CancelablePromise_promise = new WeakMap(), _CancelablePromise_resolve = new WeakMap(), _CancelablePromise_reject = new WeakMap(), Symbol.toStringTag)]() {
|
|
77
|
+
return "Cancellable Promise";
|
|
78
|
+
}
|
|
79
|
+
then(onFulfilled, onRejected) {
|
|
80
|
+
return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").then(onFulfilled, onRejected);
|
|
81
|
+
}
|
|
82
|
+
catch(onRejected) {
|
|
83
|
+
return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").catch(onRejected);
|
|
84
|
+
}
|
|
85
|
+
finally(onFinally) {
|
|
86
|
+
return __classPrivateFieldGet(this, _CancelablePromise_promise, "f").finally(onFinally);
|
|
87
|
+
}
|
|
88
|
+
cancel() {
|
|
89
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_isResolved, "f") || __classPrivateFieldGet(this, _CancelablePromise_isRejected, "f") || __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f")) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
__classPrivateFieldSet(this, _CancelablePromise_isCancelled, true, "f");
|
|
93
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length) {
|
|
94
|
+
try {
|
|
95
|
+
for (const cancelHandler of __classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f")) {
|
|
96
|
+
cancelHandler();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.warn('Cancellation threw an error', error);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
__classPrivateFieldGet(this, _CancelablePromise_cancelHandlers, "f").length = 0;
|
|
105
|
+
if (__classPrivateFieldGet(this, _CancelablePromise_reject, "f"))
|
|
106
|
+
__classPrivateFieldGet(this, _CancelablePromise_reject, "f").call(this, new CancelError('Request aborted'));
|
|
107
|
+
}
|
|
108
|
+
get isCancelled() {
|
|
109
|
+
return __classPrivateFieldGet(this, _CancelablePromise_isCancelled, "f");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
3
|
+
type Headers = Record<string, string>;
|
|
4
|
+
export type OpenAPIConfig = {
|
|
5
|
+
BASE: string;
|
|
6
|
+
VERSION: string;
|
|
7
|
+
WITH_CREDENTIALS: boolean;
|
|
8
|
+
CREDENTIALS: 'include' | 'omit' | 'same-origin';
|
|
9
|
+
TOKEN?: string | Resolver<string> | undefined;
|
|
10
|
+
USERNAME?: string | Resolver<string> | undefined;
|
|
11
|
+
PASSWORD?: string | Resolver<string> | undefined;
|
|
12
|
+
HEADERS?: Headers | Resolver<Headers> | undefined;
|
|
13
|
+
ENCODE_PATH?: ((path: string) => string) | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare const OpenAPI: OpenAPIConfig;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
+
import type { ApiResult } from './ApiResult';
|
|
3
|
+
import { CancelablePromise } from './CancelablePromise';
|
|
4
|
+
import type { OnCancel } from './CancelablePromise';
|
|
5
|
+
import type { OpenAPIConfig } from './OpenAPI';
|
|
6
|
+
export declare const isDefined: <T>(value: T | null | undefined) => value is Exclude<T, null | undefined>;
|
|
7
|
+
export declare const isString: (value: any) => value is string;
|
|
8
|
+
export declare const isStringWithValue: (value: any) => value is string;
|
|
9
|
+
export declare const isBlob: (value: any) => value is Blob;
|
|
10
|
+
export declare const isFormData: (value: any) => value is FormData;
|
|
11
|
+
export declare const base64: (str: string) => string;
|
|
12
|
+
export declare const getQueryString: (params: Record<string, any>) => string;
|
|
13
|
+
export declare const getFormData: (options: ApiRequestOptions) => FormData | undefined;
|
|
14
|
+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
15
|
+
export declare const resolve: <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>) => Promise<T | undefined>;
|
|
16
|
+
export declare const getHeaders: (config: OpenAPIConfig, options: ApiRequestOptions) => Promise<Headers>;
|
|
17
|
+
export declare const getRequestBody: (options: ApiRequestOptions) => any;
|
|
18
|
+
export declare const sendRequest: (config: OpenAPIConfig, options: ApiRequestOptions, url: string, body: any, formData: FormData | undefined, headers: Headers, onCancel: OnCancel) => Promise<Response>;
|
|
19
|
+
export declare const getResponseHeader: (response: Response, responseHeader?: string) => string | undefined;
|
|
20
|
+
export declare const getResponseBody: (response: Response) => Promise<any>;
|
|
21
|
+
export declare const catchErrorCodes: (options: ApiRequestOptions, result: ApiResult) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Request method
|
|
24
|
+
* @param config The OpenAPI configuration object
|
|
25
|
+
* @param options The request options from the service
|
|
26
|
+
* @returns CancelablePromise<T>
|
|
27
|
+
* @throws ApiError
|
|
28
|
+
*/
|
|
29
|
+
export declare const request: <T>(config: OpenAPIConfig, options: ApiRequestOptions) => CancelablePromise<T>;
|
|
30
|
+
export {};
|