@babav/knowledge-core-client 0.2.0 → 0.3.0

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 CHANGED
@@ -108,6 +108,14 @@ export interface ContentUrl {
108
108
  content_type: string;
109
109
  filename: string;
110
110
  }
111
+ /** Document tally for a corpus or folder. `indexed` = searchable; `in_flight` =
112
+ * pending + ingesting (still processing); `failed` = terminal; `total` = all. */
113
+ export interface DocumentCount {
114
+ total: number;
115
+ indexed: number;
116
+ in_flight: number;
117
+ failed: number;
118
+ }
111
119
  export interface Conversation {
112
120
  id: UUID;
113
121
  title: string | null;
@@ -266,8 +274,11 @@ export declare class KnowledgeCoreClient extends HttpBase {
266
274
  limit?: number;
267
275
  cursor?: string;
268
276
  }) => Promise<Page<Document>>;
269
- /** Upload a file and ingest it SYNCHRONOUSLY resolves once the document is
270
- * indexed (or rejects 502 on a pipeline failure). */
277
+ /** Count documents in the corpus: { total, indexed, in_flight, failed }. */
278
+ countDocuments: (id: UUID) => Promise<DocumentCount>;
279
+ /** Upload a file and ingest it ASYNCHRONOUSLY — resolves with the created
280
+ * document at status `pending` (HTTP 202); track via documents.get() polling
281
+ * the status to `indexed`/`failed`, or the tenant result webhook. */
271
282
  ingestDocument: (id: UUID, a: {
272
283
  file: FileData;
273
284
  filename: string;
@@ -292,6 +303,8 @@ export declare class KnowledgeCoreClient extends HttpBase {
292
303
  limit?: number;
293
304
  cursor?: string;
294
305
  }) => Promise<Page<Document>>;
306
+ /** Count documents in the folder: { total, indexed, in_flight, failed }. */
307
+ countDocuments: (folderId: UUID) => Promise<DocumentCount>;
295
308
  };
296
309
  documents: {
297
310
  get: (id: UUID) => Promise<Document>;
package/dist/index.js CHANGED
@@ -164,8 +164,11 @@ export class KnowledgeCoreClient extends HttpBase {
164
164
  delete: (id, confirmName) => this.request("DELETE", `/v1/corpora/${id}`, { query: { confirm: confirmName } }),
165
165
  listFolders: (id) => this.pageAll(`/v1/corpora/${id}/folders`),
166
166
  listDocuments: (id, q) => this.request("GET", `/v1/corpora/${id}/documents`, { query: q }),
167
- /** Upload a file and ingest it SYNCHRONOUSLY resolves once the document is
168
- * indexed (or rejects 502 on a pipeline failure). */
167
+ /** Count documents in the corpus: { total, indexed, in_flight, failed }. */
168
+ countDocuments: (id) => this.request("GET", `/v1/corpora/${id}/documents/count`),
169
+ /** Upload a file and ingest it ASYNCHRONOUSLY — resolves with the created
170
+ * document at status `pending` (HTTP 202); track via documents.get() polling
171
+ * the status to `indexed`/`failed`, or the tenant result webhook. */
169
172
  ingestDocument: (id, a) => {
170
173
  const fd = new FormData();
171
174
  fd.append("file", toBlob(a.file, a.content_type), a.filename);
@@ -190,6 +193,8 @@ export class KnowledgeCoreClient extends HttpBase {
190
193
  rename: (folderId, name) => this.request("PATCH", `/v1/folders/${folderId}`, { json: { name } }),
191
194
  delete: (folderId) => this.request("DELETE", `/v1/folders/${folderId}`),
192
195
  listDocuments: (folderId, q) => this.request("GET", `/v1/folders/${folderId}/documents`, { query: q }),
196
+ /** Count documents in the folder: { total, indexed, in_flight, failed }. */
197
+ countDocuments: (folderId) => this.request("GET", `/v1/folders/${folderId}/documents/count`),
193
198
  };
194
199
  // --- documents ---
195
200
  documents = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babav/knowledge-core-client",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "TypeScript client for the Babav Knowledge Core API (Deno + Node 18+, zero deps).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/src/index.ts CHANGED
@@ -122,6 +122,14 @@ export interface ContentUrl {
122
122
  content_type: string;
123
123
  filename: string;
124
124
  }
125
+ /** Document tally for a corpus or folder. `indexed` = searchable; `in_flight` =
126
+ * pending + ingesting (still processing); `failed` = terminal; `total` = all. */
127
+ export interface DocumentCount {
128
+ total: number;
129
+ indexed: number;
130
+ in_flight: number;
131
+ failed: number;
132
+ }
125
133
  export interface Conversation {
126
134
  id: UUID;
127
135
  title: string | null;
@@ -381,8 +389,12 @@ export class KnowledgeCoreClient extends HttpBase {
381
389
  listFolders: (id: UUID) => this.pageAll<Folder>(`/v1/corpora/${id}/folders`),
382
390
  listDocuments: (id: UUID, q?: { limit?: number; cursor?: string }) =>
383
391
  this.request<Page<Document>>("GET", `/v1/corpora/${id}/documents`, { query: q }),
384
- /** Upload a file and ingest it SYNCHRONOUSLY resolves once the document is
385
- * indexed (or rejects 502 on a pipeline failure). */
392
+ /** Count documents in the corpus: { total, indexed, in_flight, failed }. */
393
+ countDocuments: (id: UUID) =>
394
+ this.request<DocumentCount>("GET", `/v1/corpora/${id}/documents/count`),
395
+ /** Upload a file and ingest it ASYNCHRONOUSLY — resolves with the created
396
+ * document at status `pending` (HTTP 202); track via documents.get() polling
397
+ * the status to `indexed`/`failed`, or the tenant result webhook. */
386
398
  ingestDocument: (id: UUID, a: { file: FileData; filename: string; content_type?: string; visibility?: Visibility; folder_id?: UUID; custom_metadata?: Record<string, unknown> }) => {
387
399
  const fd = new FormData();
388
400
  fd.append("file", toBlob(a.file, a.content_type), a.filename);
@@ -407,6 +419,9 @@ export class KnowledgeCoreClient extends HttpBase {
407
419
  delete: (folderId: UUID) => this.request<void>("DELETE", `/v1/folders/${folderId}`),
408
420
  listDocuments: (folderId: UUID, q?: { limit?: number; cursor?: string }) =>
409
421
  this.request<Page<Document>>("GET", `/v1/folders/${folderId}/documents`, { query: q }),
422
+ /** Count documents in the folder: { total, indexed, in_flight, failed }. */
423
+ countDocuments: (folderId: UUID) =>
424
+ this.request<DocumentCount>("GET", `/v1/folders/${folderId}/documents/count`),
410
425
  };
411
426
 
412
427
  // --- documents ---