@bodhiapp/ts-client 0.1.2 → 0.1.3
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/index.d.ts +0 -1
- package/dist/index.js +18 -16
- package/dist/index.mjs +2 -0
- package/dist/types/api.d.ts +1327 -0
- package/package.json +13 -9
- package/dist/client.d.ts +0 -23
- package/dist/client.js +0 -47
package/package.json
CHANGED
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bodhiapp/ts-client",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "TypeScript
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "TypeScript types for Bodhi API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"dist"
|
|
9
10
|
],
|
|
10
11
|
"scripts": {
|
|
11
|
-
"build": "npm run generate &&
|
|
12
|
+
"build": "npm run generate && npm run bundle",
|
|
12
13
|
"generate": "npm run generate:openapi && npm run generate:types",
|
|
13
14
|
"generate:openapi": "cd .. && cargo run --package xtask openapi",
|
|
14
15
|
"generate:types": "openapi-typescript ../openapi.json --output src/types/api.d.ts --export-type components",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
16
|
+
"bundle": "npm run bundle:types && npm run bundle:esm && npm run bundle:cjs",
|
|
17
|
+
"bundle:types": "tsc --emitDeclarationOnly --outDir dist && mkdir -p dist/types && cp src/types/api.d.ts dist/types/api.d.ts",
|
|
18
|
+
"bundle:esm": "esbuild src/index.ts --bundle --platform=neutral --format=esm --outfile=dist/index.mjs --external:./types/api --allow-overwrite",
|
|
19
|
+
"bundle:cjs": "esbuild src/index.ts --bundle --platform=neutral --format=cjs --outfile=dist/index.js --external:./types/api --allow-overwrite",
|
|
20
|
+
"test": "echo \"No tests required - type-only package\" && exit 0",
|
|
21
|
+
"clean": "rm -rf dist"
|
|
18
22
|
},
|
|
19
23
|
"keywords": [
|
|
20
24
|
"bodhi",
|
|
21
25
|
"api",
|
|
22
|
-
"
|
|
26
|
+
"types",
|
|
23
27
|
"typescript"
|
|
24
28
|
],
|
|
25
29
|
"author": "Bodhi Team",
|
|
26
30
|
"license": "Apache-2.0",
|
|
27
31
|
"devDependencies": {
|
|
32
|
+
"esbuild": "^0.20.2",
|
|
28
33
|
"openapi-typescript": "^6.7.3",
|
|
29
|
-
"typescript": "^5.3.3"
|
|
30
|
-
"vitest": "^1.2.1"
|
|
34
|
+
"typescript": "^5.3.3"
|
|
31
35
|
},
|
|
32
36
|
"publishConfig": {
|
|
33
37
|
"access": "public"
|
package/dist/client.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { operations } from './types/api';
|
|
2
|
-
export interface ClientOptions {
|
|
3
|
-
baseUrl: string;
|
|
4
|
-
apiKey?: string;
|
|
5
|
-
headers?: Record<string, string>;
|
|
6
|
-
}
|
|
7
|
-
export declare class BodhiClient {
|
|
8
|
-
private baseUrl;
|
|
9
|
-
private headers;
|
|
10
|
-
constructor(options: ClientOptions);
|
|
11
|
-
/**
|
|
12
|
-
* Make a request to the Bodhi API
|
|
13
|
-
*/
|
|
14
|
-
request<T>(method: string, path: string, body?: unknown, additionalHeaders?: Record<string, string>): Promise<T>;
|
|
15
|
-
/**
|
|
16
|
-
* Create a chat completion
|
|
17
|
-
*/
|
|
18
|
-
createChatCompletion(params: operations['createChatCompletion']['requestBody']['content']['application/json']): Promise<operations['createChatCompletion']['responses']['200']['content']['application/json']>;
|
|
19
|
-
/**
|
|
20
|
-
* List available models
|
|
21
|
-
*/
|
|
22
|
-
listModels(): Promise<operations['listModels']['responses']['200']['content']['application/json']>;
|
|
23
|
-
}
|
package/dist/client.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BodhiClient = void 0;
|
|
4
|
-
class BodhiClient {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.baseUrl = options.baseUrl.endsWith('/') ? options.baseUrl.slice(0, -1) : options.baseUrl;
|
|
7
|
-
this.headers = {
|
|
8
|
-
'Content-Type': 'application/json',
|
|
9
|
-
...options.headers,
|
|
10
|
-
};
|
|
11
|
-
if (options.apiKey) {
|
|
12
|
-
this.headers['Authorization'] = `Bearer ${options.apiKey}`;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Make a request to the Bodhi API
|
|
17
|
-
*/
|
|
18
|
-
async request(method, path, body, additionalHeaders) {
|
|
19
|
-
const url = `${this.baseUrl}${path.startsWith('/') ? path : `/${path}`}`;
|
|
20
|
-
const response = await fetch(url, {
|
|
21
|
-
method,
|
|
22
|
-
headers: {
|
|
23
|
-
...this.headers,
|
|
24
|
-
...additionalHeaders,
|
|
25
|
-
},
|
|
26
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
27
|
-
});
|
|
28
|
-
if (!response.ok) {
|
|
29
|
-
const errorText = await response.text();
|
|
30
|
-
throw new Error(`Request failed with status ${response.status}: ${errorText}`);
|
|
31
|
-
}
|
|
32
|
-
return response.json();
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Create a chat completion
|
|
36
|
-
*/
|
|
37
|
-
async createChatCompletion(params) {
|
|
38
|
-
return this.request('POST', '/v1/chat/completions', params);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* List available models
|
|
42
|
-
*/
|
|
43
|
-
async listModels() {
|
|
44
|
-
return this.request('GET', '/v1/models');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.BodhiClient = BodhiClient;
|