@babav/knowledge-core-client 0.2.0 → 0.4.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,16 @@ 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
+ /** Documents in the corpus whose filename contains `q` (case-insensitive), paginated. */
280
+ searchDocuments: (id: UUID, q: string, opts?: {
281
+ limit?: number;
282
+ cursor?: string;
283
+ }) => Promise<Page<Document>>;
284
+ /** Upload a file and ingest it ASYNCHRONOUSLY — resolves with the created
285
+ * document at status `pending` (HTTP 202); track via documents.get() polling
286
+ * the status to `indexed`/`failed`, or the tenant result webhook. */
271
287
  ingestDocument: (id: UUID, a: {
272
288
  file: FileData;
273
289
  filename: string;
@@ -292,6 +308,13 @@ export declare class KnowledgeCoreClient extends HttpBase {
292
308
  limit?: number;
293
309
  cursor?: string;
294
310
  }) => Promise<Page<Document>>;
311
+ /** Count documents in the folder: { total, indexed, in_flight, failed }. */
312
+ countDocuments: (folderId: UUID) => Promise<DocumentCount>;
313
+ /** Documents in the folder whose filename contains `q` (case-insensitive), paginated. */
314
+ searchDocuments: (folderId: UUID, q: string, opts?: {
315
+ limit?: number;
316
+ cursor?: string;
317
+ }) => Promise<Page<Document>>;
295
318
  };
296
319
  documents: {
297
320
  get: (id: UUID) => Promise<Document>;
package/dist/index.js CHANGED
@@ -164,8 +164,13 @@ 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
+ /** Documents in the corpus whose filename contains `q` (case-insensitive), paginated. */
170
+ searchDocuments: (id, q, opts) => this.request("GET", `/v1/corpora/${id}/documents/search`, { query: { q, ...opts } }),
171
+ /** Upload a file and ingest it ASYNCHRONOUSLY — resolves with the created
172
+ * document at status `pending` (HTTP 202); track via documents.get() polling
173
+ * the status to `indexed`/`failed`, or the tenant result webhook. */
169
174
  ingestDocument: (id, a) => {
170
175
  const fd = new FormData();
171
176
  fd.append("file", toBlob(a.file, a.content_type), a.filename);
@@ -190,6 +195,10 @@ export class KnowledgeCoreClient extends HttpBase {
190
195
  rename: (folderId, name) => this.request("PATCH", `/v1/folders/${folderId}`, { json: { name } }),
191
196
  delete: (folderId) => this.request("DELETE", `/v1/folders/${folderId}`),
192
197
  listDocuments: (folderId, q) => this.request("GET", `/v1/folders/${folderId}/documents`, { query: q }),
198
+ /** Count documents in the folder: { total, indexed, in_flight, failed }. */
199
+ countDocuments: (folderId) => this.request("GET", `/v1/folders/${folderId}/documents/count`),
200
+ /** Documents in the folder whose filename contains `q` (case-insensitive), paginated. */
201
+ searchDocuments: (folderId, q, opts) => this.request("GET", `/v1/folders/${folderId}/documents/search`, { query: { q, ...opts } }),
193
202
  };
194
203
  // --- documents ---
195
204
  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.4.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,15 @@ 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
+ /** Documents in the corpus whose filename contains `q` (case-insensitive), paginated. */
396
+ searchDocuments: (id: UUID, q: string, opts?: { limit?: number; cursor?: string }) =>
397
+ this.request<Page<Document>>("GET", `/v1/corpora/${id}/documents/search`, { query: { q, ...opts } }),
398
+ /** Upload a file and ingest it ASYNCHRONOUSLY — resolves with the created
399
+ * document at status `pending` (HTTP 202); track via documents.get() polling
400
+ * the status to `indexed`/`failed`, or the tenant result webhook. */
386
401
  ingestDocument: (id: UUID, a: { file: FileData; filename: string; content_type?: string; visibility?: Visibility; folder_id?: UUID; custom_metadata?: Record<string, unknown> }) => {
387
402
  const fd = new FormData();
388
403
  fd.append("file", toBlob(a.file, a.content_type), a.filename);
@@ -407,6 +422,12 @@ export class KnowledgeCoreClient extends HttpBase {
407
422
  delete: (folderId: UUID) => this.request<void>("DELETE", `/v1/folders/${folderId}`),
408
423
  listDocuments: (folderId: UUID, q?: { limit?: number; cursor?: string }) =>
409
424
  this.request<Page<Document>>("GET", `/v1/folders/${folderId}/documents`, { query: q }),
425
+ /** Count documents in the folder: { total, indexed, in_flight, failed }. */
426
+ countDocuments: (folderId: UUID) =>
427
+ this.request<DocumentCount>("GET", `/v1/folders/${folderId}/documents/count`),
428
+ /** Documents in the folder whose filename contains `q` (case-insensitive), paginated. */
429
+ searchDocuments: (folderId: UUID, q: string, opts?: { limit?: number; cursor?: string }) =>
430
+ this.request<Page<Document>>("GET", `/v1/folders/${folderId}/documents/search`, { query: { q, ...opts } }),
410
431
  };
411
432
 
412
433
  // --- documents ---