@bodhiapp/bodhi-browser-types 0.0.32 → 0.0.33
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/dist/bodhiext.d.ts +4 -3
- package/dist/errors.d.ts +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/protocol.d.ts +6 -15
- package/package.json +2 -2
package/dist/bodhiext.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { AppStatus,
|
|
1
|
+
import { AppStatus, PingResponse } from '@bodhiapp/ts-client';
|
|
2
|
+
import { ErrorResponse, CreateChatCompletionRequest, CreateChatCompletionResponse, CreateChatCompletionStreamResponse } from '@bodhiapp/ts-client/openai';
|
|
2
3
|
/**
|
|
3
4
|
* HTTP response wrapper - body can be success type OR error type
|
|
4
5
|
* Use isApiErrorResponse() to narrow the type based on status
|
|
5
6
|
*/
|
|
6
7
|
export interface ApiResponse<T = unknown> {
|
|
7
|
-
body: T |
|
|
8
|
+
body: T | ErrorResponse;
|
|
8
9
|
status: number;
|
|
9
10
|
headers: Record<string, string>;
|
|
10
11
|
}
|
|
@@ -144,7 +145,7 @@ export interface BodhiExtPublicApi {
|
|
|
144
145
|
* Simple health check to verify extension connectivity.
|
|
145
146
|
*
|
|
146
147
|
* Returns ApiResponse - caller should check status to determine success/error.
|
|
147
|
-
* On success (2xx), body is PingResponse. On error (4xx/5xx), body is
|
|
148
|
+
* On success (2xx), body is PingResponse. On error (4xx/5xx), body is ErrorResponse.
|
|
148
149
|
*
|
|
149
150
|
* @returns Promise resolving to ApiResponse<PingResponse>
|
|
150
151
|
*/
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ErrorResponse } from '@bodhiapp/ts-client/openai';
|
|
2
2
|
import { ApiResponse } from './bodhiext';
|
|
3
3
|
/**
|
|
4
4
|
* Error codes for BodhiError
|
|
@@ -23,9 +23,9 @@ export declare class BodhiError extends Error {
|
|
|
23
23
|
*/
|
|
24
24
|
export declare class BodhiApiError extends BodhiError {
|
|
25
25
|
readonly status: number;
|
|
26
|
-
readonly body:
|
|
26
|
+
readonly body: ErrorResponse;
|
|
27
27
|
readonly headers?: Record<string, string>;
|
|
28
|
-
constructor(status: number, body:
|
|
28
|
+
constructor(status: number, body: ErrorResponse, message: string, headers?: Record<string, string>);
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Extract response body or throw BodhiApiError if status >= 400
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { ApiResponse, StreamChunk, ServerStateInfo, ChatCompletionsApi, ChatApi, BodhiExtPublicApi } from './bodhiext';
|
|
2
2
|
export { BodhiError, BodhiApiError, unwrapResponse, type BodhiErrorCode } from './errors';
|
|
3
|
-
export type { ApiRequest, ApiRequestMessage, OperationErrorResponse, ApiResponseSuccessMessage, OperationErrorResponseMessage, ApiResponseMessage,
|
|
3
|
+
export type { ApiRequest, ApiRequestMessage, OperationErrorResponse, ApiResponseSuccessMessage, OperationErrorResponseMessage, ApiResponseMessage, StreamChunkMessage, StreamApiErrorMessage, StreamErrorMessage, StreamMessage, StreamTextStartMessage, StreamTextChunkMessage, StreamTextDoneMessage, StreamTextErrorMessage, StreamTextMessage, StreamController, SSEChunk, ExtRequest, ExtRequestMessage, ExtError, ExtErrorResponse, ExtResponse, ExtResponseMessage, GetExtensionIdRequest, GetExtensionIdResponse, TestConnectionRequest, TestConnectionResponse, } from './protocol';
|
|
4
4
|
export { MESSAGE_TYPES, isOperationErrorResponse, isApiErrorResponse, isApiSuccessResponse, isStreamChunk, isStreamApiError, isStreamError, isExtError, isOpenAiApiErrorBody, isOperationErrorStructure, } from './protocol';
|
|
5
5
|
export { CONTENT_TYPE_JSON, CONTENT_TYPE_EVENT_STREAM, CONTENT_TYPE_HEADER, HTTP_METHOD_GET, HTTP_METHOD_POST, ENDPOINT_PING, ENDPOINT_CHAT_COMPLETIONS, DEFAULT_API_BASE_URL, DEFAULT_API_TIMEOUT, DEFAULT_STREAM_TIMEOUT, STORAGE_KEY_BACKEND_URL, SSE_DONE_MARKER, SSE_DATA_PREFIX, SSE_CHUNK_DELIMITER, EXT_ACTIONS, ERROR_TYPES, DOCUMENT_STATE_COMPLETE, EVENT_INITIALIZED, BODHI_STREAM_PORT, BODHI_STREAM_TEXT_PORT, ORIGIN_WILDCARD, ERROR_MISSING_REQUEST_ID, ERROR_CONNECTION_CLOSED, } from './common';
|
|
6
6
|
export type { ConnectionErrorType } from './common';
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ErrorResponse } from '@bodhiapp/ts-client/openai';
|
|
2
2
|
import { ApiResponse, ServerStateInfo } from './bodhiext';
|
|
3
3
|
/**
|
|
4
4
|
* Validate OpenAI API error body structure
|
|
5
5
|
* { error: { message: string, type: string } }
|
|
6
6
|
*/
|
|
7
|
-
export declare function isOpenAiApiErrorBody(body: unknown): body is
|
|
7
|
+
export declare function isOpenAiApiErrorBody(body: unknown): body is ErrorResponse;
|
|
8
8
|
/**
|
|
9
9
|
* Validate OperationErrorResponse structure
|
|
10
10
|
* { message: string, type: string }
|
|
@@ -39,7 +39,7 @@ export interface ApiRequestMessage<TReq = unknown> {
|
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Operation-level error response (network unreachable, timeout, extension error)
|
|
42
|
-
* NOT an API error (those come through ApiResponse with
|
|
42
|
+
* NOT an API error (those come through ApiResponse with ErrorResponse body)
|
|
43
43
|
* This is a response type, not a thrown error
|
|
44
44
|
*/
|
|
45
45
|
export interface OperationErrorResponse {
|
|
@@ -72,10 +72,10 @@ export type ApiResponseMessage<T = unknown> = ApiResponseSuccessMessage<T> | Ope
|
|
|
72
72
|
export declare function isOperationErrorResponse(msg: ApiResponseMessage): msg is OperationErrorResponseMessage;
|
|
73
73
|
/**
|
|
74
74
|
* Type guard to check if response is an API error (4xx/5xx)
|
|
75
|
-
* Narrows body type to
|
|
75
|
+
* Narrows body type to ErrorResponse
|
|
76
76
|
*/
|
|
77
77
|
export declare function isApiErrorResponse<T>(response: ApiResponse<T>): response is ApiResponse<T> & {
|
|
78
|
-
body:
|
|
78
|
+
body: ErrorResponse;
|
|
79
79
|
status: number;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
@@ -86,15 +86,6 @@ export declare function isApiSuccessResponse<T>(response: ApiResponse<T>): respo
|
|
|
86
86
|
body: T;
|
|
87
87
|
status: number;
|
|
88
88
|
};
|
|
89
|
-
export interface ErrorMessage {
|
|
90
|
-
type: string;
|
|
91
|
-
requestId: string;
|
|
92
|
-
response: {
|
|
93
|
-
body: ErrorBody;
|
|
94
|
-
status: number;
|
|
95
|
-
headers: Record<string, string>;
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
89
|
/**
|
|
99
90
|
* Stream chunk message - successful SSE chunk received
|
|
100
91
|
* Uses ApiResponse<T> wrapper for consistency with non-streaming pattern
|
|
@@ -111,7 +102,7 @@ export interface StreamChunkMessage<T = unknown> {
|
|
|
111
102
|
export interface StreamApiErrorMessage {
|
|
112
103
|
type: typeof MESSAGE_TYPES.STREAM_API_ERROR;
|
|
113
104
|
requestId: string;
|
|
114
|
-
response: ApiResponse<
|
|
105
|
+
response: ApiResponse<ErrorResponse>;
|
|
115
106
|
}
|
|
116
107
|
/**
|
|
117
108
|
* Stream error message - network/extension level error
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bodhiapp/bodhi-browser-types",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"description": "TypeScript types for Bodhi Browser Extension",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"clean": "rimraf dist"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@bodhiapp/ts-client": "
|
|
22
|
+
"@bodhiapp/ts-client": "0.1.29"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"rimraf": "^6.0.1",
|