@bodhiapp/reference-api-types 0.0.1

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 (3) hide show
  1. package/README.md +60 -0
  2. package/dist/index.d.ts +144 -0
  3. package/package.json +34 -0
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @bodhiapp/reference-api-types
2
+
3
+ TypeScript **request/response types** for the [Bodhi Models Reference API](https://api.getbodhi.app) —
4
+ the v1 live HuggingFace proxy for local (GGUF) models.
5
+
6
+ **Types only.** This package ships **no runtime** — no `fetch`/`axios` wrapper, no HTTP client. It
7
+ exports interfaces so you can type your own requests and responses. Use your existing client (e.g.
8
+ BodhiApp's `referenceApiClient.ts`) and annotate it with these types.
9
+
10
+ These types are the **single source of truth**: the API server imports the same definitions, so the
11
+ published types cannot drift from the wire shapes.
12
+
13
+ ## Install
14
+
15
+ ```sh
16
+ npm install @bodhiapp/reference-api-types
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```ts
22
+ import type {
23
+ Model,
24
+ ListModelsQuery,
25
+ ListModelsResponse,
26
+ GetModelResponse,
27
+ ErrorResponse,
28
+ } from '@bodhiapp/reference-api-types'
29
+
30
+ // Type a list request + response (you bring your own fetch).
31
+ async function listModels(client: { get<T>(path: string): Promise<T> }, query: ListModelsQuery) {
32
+ const qs = new URLSearchParams(query as Record<string, string>).toString()
33
+ return client.get<ListModelsResponse>(`/api/v1/models?${qs}`)
34
+ }
35
+
36
+ // Type a single-model response (includes the quants[] table).
37
+ async function getModel(client: { get<T>(path: string): Promise<T> }, ns: string, repo: string) {
38
+ return client.get<GetModelResponse>(`/api/v1/models/huggingface/${ns}/${repo}`)
39
+ }
40
+ ```
41
+
42
+ ## Exports
43
+
44
+ | Type | For |
45
+ |---|---|
46
+ | `Model`, `Quant` | the model DTO + its quantization entries |
47
+ | `ListModelsQuery` | query params for `GET /api/v1/models` |
48
+ | `ListModelsResponse` | response of the list endpoint |
49
+ | `GetModelQuery`, `GetModelResponse` | the single-model endpoint |
50
+ | `ErrorResponse`, `ErrorCode` | the error envelope |
51
+ | `ModelType`, `ModelSource`, `Specialisation`, `SortKey`, `SortOrder` | the supported enum values |
52
+
53
+ For the full API contract (semantics, auth, pagination, recipes) see `docs/functional/` in the
54
+ [api-getbodhi-app](https://github.com/BodhiSearch/api-getbodhi-app) repo, or the live OpenAPI doc at
55
+ `/api/openapi.json` (Swagger UI at `/api/doc`).
56
+
57
+ ## Release
58
+
59
+ Published from local via `just publish-api-types` (version = next patch from npmjs). See the repo's
60
+ `justfile` and `scripts/release.sh`.
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Request/response types for the Bodhi Models Reference API — the v1 live HuggingFace proxy for
3
+ * local (GGUF) models. Types only: this package ships no runtime, no fetch/HTTP client. Import these
4
+ * to type your own requests/responses.
5
+ *
6
+ * This is the SINGLE SOURCE OF TRUTH for the API's wire shapes — the API worker imports the same
7
+ * types, so the published types and the server cannot drift.
8
+ */
9
+ /** v1 supports only GGUF. */
10
+ export type ModelType = 'gguf';
11
+ /** v1 supports only HuggingFace. */
12
+ export type ModelSource = 'huggingface';
13
+ /** Derived specialisation tags that are filterable in v1. */
14
+ export type Specialisation = 'coding' | 'reasoning' | 'vision';
15
+ /** Sort keys for the list endpoint. */
16
+ export type SortKey = 'downloads' | 'likes' | 'last_modified' | 'created_at' | 'trending';
17
+ /** Sort direction. */
18
+ export type SortOrder = 'asc' | 'desc';
19
+ /** One quantization variant of a model (single-model response only). */
20
+ export interface Quant {
21
+ name: string;
22
+ /** Bytes. Split multi-part files are merged and summed. */
23
+ size: number | null;
24
+ /** Bit-width (Q4_K_M→4, Q8_0→8, F16/BF16→16). */
25
+ bits: number | null;
26
+ /** Method/mix variant (Q4_K_M→"K_M", Q8_0→"0", IQ4_XS→"XS"). */
27
+ method: string | null;
28
+ /** At most one per repo — the suggested default to pull. */
29
+ recommended: boolean;
30
+ }
31
+ /**
32
+ * A model, shared by list items and the single-model response. All fields are nullable unless noted.
33
+ * `quants` is present only on the single-model response.
34
+ *
35
+ * Note: `max_quant_size_bytes`, `total_size_bytes`, `context_max`, and `architecture` are typically
36
+ * null on LIST rows — they are populated on the single-model response (which fetches the file tree).
37
+ */
38
+ export interface Model {
39
+ /** non-null. v1 always "huggingface". */
40
+ source: string;
41
+ /** non-null. v1 always "gguf". */
42
+ type: string;
43
+ /** non-null. HF org/user. */
44
+ namespace: string;
45
+ /** non-null. */
46
+ repo: string;
47
+ pipeline_tag: string | null;
48
+ library: string | null;
49
+ license: string | null;
50
+ languages: string[] | null;
51
+ tags: string[] | null;
52
+ /** Derived: tool-use | vision | reasoning | structured | embedding. Display-only (not filterable in v1). */
53
+ capabilities: string[] | null;
54
+ /** Derived: coding | reasoning | vision (etc.). */
55
+ specialisation: string[] | null;
56
+ quant_count: number | null;
57
+ /** Distinct bit-widths present (e.g. [4, 8]). */
58
+ quant_bits: number[] | null;
59
+ /** Distinct quant methods present (e.g. ["K_M", "0"]). */
60
+ quant_methods: string[] | null;
61
+ /** Largest GGUF quant, bytes. Null on list rows. */
62
+ max_quant_size_bytes: number | null;
63
+ /** Total of all GGUF artifacts, bytes. Null on list rows. */
64
+ total_size_bytes: number | null;
65
+ /** e.g. "qwen2", "Qwen3-MoE". Null on list rows. */
66
+ architecture: string | null;
67
+ /** Tokens. Null on list rows. */
68
+ context_max: number | null;
69
+ /** Billions of params. String for decimal precision. */
70
+ params_b: string | null;
71
+ provider: string | null;
72
+ downloads: number | null;
73
+ likes: number | null;
74
+ trending_score: number | null;
75
+ created_at: string | null;
76
+ last_modified: string | null;
77
+ /** non-null. Editorially curated. Default false. */
78
+ curated: boolean;
79
+ /** non-null. Publisher is a trusted/verified org. Default false. */
80
+ owner_verified: boolean;
81
+ /** non-null. When this row was last refreshed. */
82
+ fetched_at: string;
83
+ /** Only on the single-model response. */
84
+ quants?: Quant[];
85
+ }
86
+ /**
87
+ * Query parameters for `GET /api/v1/models`. All optional. Only the parameters listed here are
88
+ * supported in v1 — anything else is intentionally absent (a live HuggingFace proxy can only
89
+ * filter/sort on what HuggingFace supports server-side).
90
+ */
91
+ export interface ListModelsQuery {
92
+ /** v1: "gguf" only; else 422. */
93
+ type?: ModelType | string;
94
+ /** v1: "huggingface" only; else 422. */
95
+ source?: ModelSource | string;
96
+ /** Full-text search. Setting `q` disables the cursor. */
97
+ q?: string;
98
+ /** Publisher/org (HF org/user). Repeatable. */
99
+ author?: string | string[];
100
+ /** Task/kind. Defaults to text-generation; e.g. "image-text-to-text" for multimodal GGUF models. */
101
+ pipeline_tag?: string;
102
+ library?: string;
103
+ /** Repeatable; OR. */
104
+ language?: string | string[];
105
+ /** Repeatable; OR. */
106
+ license?: string | string[];
107
+ /** Raw HF tags; repeatable; AND. */
108
+ tag?: string | string[];
109
+ /** Repeatable; AND. Catalog-wide. */
110
+ specialisation?: Specialisation | Specialisation[];
111
+ /** Default "downloads". */
112
+ sort?: SortKey;
113
+ /** Default "desc". */
114
+ order?: SortOrder;
115
+ /** Min params (billions). Page-local filter. */
116
+ params_min?: number;
117
+ /** Max params (billions). Page-local filter. */
118
+ params_max?: number;
119
+ /** Opaque keyset cursor from a prior next_cursor. Ignored when `q` is set. */
120
+ cursor?: string;
121
+ /** 1–200. Default 50. */
122
+ limit?: number;
123
+ }
124
+ /** Response of `GET /api/v1/models`. */
125
+ export interface ListModelsResponse {
126
+ items: Model[];
127
+ /** Opaque keyset cursor; null = last page (or when `q` is set). */
128
+ next_cursor: string | null;
129
+ /** Reserved; always null (HuggingFace gives no cheap exact count). */
130
+ total_estimate: number | null;
131
+ }
132
+ /** Query parameters for `GET /api/v1/models/{source}/{namespace}/{repo}`. */
133
+ export interface GetModelQuery {
134
+ /** Comma-separated extra sections: "files", "readme". Reserved. */
135
+ include?: string;
136
+ }
137
+ /** Response of the single-model endpoint: a Model with its `quants` table populated. */
138
+ export type GetModelResponse = Model;
139
+ export type ErrorCode = 'validation' | 'unauthorized' | 'not_found' | 'unsupported_source' | 'unsupported_type' | 'internal';
140
+ /** Error envelope returned on non-2xx responses. */
141
+ export interface ErrorResponse {
142
+ error: ErrorCode | string;
143
+ message?: string;
144
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@bodhiapp/reference-api-types",
3
+ "version": "0.0.1",
4
+ "description": "TypeScript request/response types for the Bodhi Models Reference API (types only — no runtime).",
5
+ "type": "module",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts"
10
+ }
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md"
15
+ ],
16
+ "sideEffects": false,
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "provenance": false
20
+ },
21
+ "scripts": {
22
+ "build": "tsc -p tsconfig.json",
23
+ "clean": "rm -rf dist"
24
+ },
25
+ "license": "MIT",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "https://github.com/BodhiSearch/api-getbodhi-app.git",
29
+ "directory": "packages/api-types"
30
+ },
31
+ "devDependencies": {
32
+ "typescript": "~6.0.2"
33
+ }
34
+ }