@babav/knowledge-core-client 0.25.1 → 0.26.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 +37 -1
- package/dist/index.js +4 -1
- package/package.json +1 -1
- package/src/index.ts +28 -2
package/dist/index.d.ts
CHANGED
|
@@ -181,6 +181,16 @@ export interface Folder {
|
|
|
181
181
|
corpus_id: UUID;
|
|
182
182
|
name: string;
|
|
183
183
|
}
|
|
184
|
+
export interface Reach {
|
|
185
|
+
exposure_queries: number;
|
|
186
|
+
citation_reach: number | null;
|
|
187
|
+
retrieved_reach: number | null;
|
|
188
|
+
conversion: number | null;
|
|
189
|
+
citation_count: number;
|
|
190
|
+
chunks_reranked: number;
|
|
191
|
+
best_rerank_score: number | null;
|
|
192
|
+
band: AnalyticsBand;
|
|
193
|
+
}
|
|
184
194
|
export interface Document {
|
|
185
195
|
id: UUID;
|
|
186
196
|
corpus_id: UUID;
|
|
@@ -192,6 +202,7 @@ export interface Document {
|
|
|
192
202
|
chunk_count: number;
|
|
193
203
|
custom_metadata: Record<string, unknown>;
|
|
194
204
|
error: string | null;
|
|
205
|
+
reach?: Reach;
|
|
195
206
|
}
|
|
196
207
|
export interface ContentUrl {
|
|
197
208
|
content_url: string;
|
|
@@ -312,6 +323,25 @@ export interface RetrievalEventRow {
|
|
|
312
323
|
message_id: UUID | null;
|
|
313
324
|
documents: Array<Record<string, unknown>>;
|
|
314
325
|
}
|
|
326
|
+
export type Quadrant = "workhorse" | "hidden_gem" | "padding" | "cold" | "insufficient_data";
|
|
327
|
+
export interface ScatterDoc {
|
|
328
|
+
document_id: UUID;
|
|
329
|
+
filename: string | null;
|
|
330
|
+
x_retrieved_reach: number;
|
|
331
|
+
y_conversion: number;
|
|
332
|
+
chunk_count: number;
|
|
333
|
+
citation_count: number;
|
|
334
|
+
exposure_queries: number;
|
|
335
|
+
band: AnalyticsBand;
|
|
336
|
+
quadrant: Quadrant;
|
|
337
|
+
}
|
|
338
|
+
export interface ScatterResponse {
|
|
339
|
+
corpus_id: UUID;
|
|
340
|
+
corpus_total_queries: number;
|
|
341
|
+
generated_at: string;
|
|
342
|
+
truncated: boolean;
|
|
343
|
+
documents: ScatterDoc[];
|
|
344
|
+
}
|
|
315
345
|
export interface Conversation {
|
|
316
346
|
id: UUID;
|
|
317
347
|
title: string | null;
|
|
@@ -638,6 +668,7 @@ export declare class KnowledgeCoreClient extends HttpBase {
|
|
|
638
668
|
listDocuments: (folderId: UUID, q?: {
|
|
639
669
|
limit?: number;
|
|
640
670
|
cursor?: string;
|
|
671
|
+
include?: "reach";
|
|
641
672
|
}) => Promise<Page<Document>>;
|
|
642
673
|
/** Count documents in the folder: { total, indexed, in_flight, failed }. */
|
|
643
674
|
countDocuments: (folderId: UUID) => Promise<DocumentCount>;
|
|
@@ -651,7 +682,9 @@ export declare class KnowledgeCoreClient extends HttpBase {
|
|
|
651
682
|
events: (folderId: UUID, handlers: DocumentEventHandlers, signal?: AbortSignal) => Promise<void>;
|
|
652
683
|
};
|
|
653
684
|
documents: {
|
|
654
|
-
get: (id: UUID
|
|
685
|
+
get: (id: UUID, opts?: {
|
|
686
|
+
include?: "reach";
|
|
687
|
+
}) => Promise<Document>;
|
|
655
688
|
getCustomMetadata: (id: UUID) => Promise<Record<string, unknown>>;
|
|
656
689
|
/** Merge custom_metadata (a null value deletes a key). Returns the merged object. */
|
|
657
690
|
patchCustomMetadata: (id: UUID, custom_metadata: Record<string, unknown>) => Promise<Record<string, unknown>>;
|
|
@@ -777,6 +810,9 @@ export declare class KnowledgeCoreClient extends HttpBase {
|
|
|
777
810
|
document: (documentId: UUID) => Promise<DocumentAnalytics>;
|
|
778
811
|
/** Parent-section grain for a document (never exposes chunk ids). */
|
|
779
812
|
documentSections: (documentId: UUID) => Promise<SectionsResponse>;
|
|
813
|
+
/** Whole-corpus scatter payload: every document with x=retrieved_reach, y=conversion,
|
|
814
|
+
* bubble=chunk_count, and a server-computed quadrant. No pagination (`truncated` if capped). */
|
|
815
|
+
corpusScatter: (corpusId: UUID) => Promise<ScatterResponse>;
|
|
780
816
|
/** A corpus's monthly metrics + revenue_share (YYYY-MM). */
|
|
781
817
|
corpusMonthly: (corpusId: UUID, yyyyMm: string) => Promise<MonthlyCorpus>;
|
|
782
818
|
/** Cross-corpus monthly totals + per-corpus breakdown + unattributed share (YYYY-MM). */
|
package/dist/index.js
CHANGED
|
@@ -336,7 +336,7 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
336
336
|
};
|
|
337
337
|
// --- documents ---
|
|
338
338
|
documents = {
|
|
339
|
-
get: (id) => this.request("GET", `/v1/documents/${id}
|
|
339
|
+
get: (id, opts) => this.request("GET", `/v1/documents/${id}`, { query: opts }),
|
|
340
340
|
getCustomMetadata: (id) => this.request("GET", `/v1/documents/${id}/custom_metadata`),
|
|
341
341
|
/** Merge custom_metadata (a null value deletes a key). Returns the merged object. */
|
|
342
342
|
patchCustomMetadata: (id, custom_metadata) => this.request("PATCH", `/v1/documents/${id}/custom_metadata`, { json: custom_metadata }),
|
|
@@ -420,6 +420,9 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
420
420
|
document: (documentId) => this.request("GET", `/v1/analytics/documents/${documentId}`),
|
|
421
421
|
/** Parent-section grain for a document (never exposes chunk ids). */
|
|
422
422
|
documentSections: (documentId) => this.request("GET", `/v1/analytics/documents/${documentId}/sections`),
|
|
423
|
+
/** Whole-corpus scatter payload: every document with x=retrieved_reach, y=conversion,
|
|
424
|
+
* bubble=chunk_count, and a server-computed quadrant. No pagination (`truncated` if capped). */
|
|
425
|
+
corpusScatter: (corpusId) => this.request("GET", `/v1/analytics/corpora/${corpusId}/scatter`),
|
|
423
426
|
/** A corpus's monthly metrics + revenue_share (YYYY-MM). */
|
|
424
427
|
corpusMonthly: (corpusId, yyyyMm) => this.request("GET", `/v1/analytics/corpora/${corpusId}/monthly/${yyyyMm}`),
|
|
425
428
|
/** Cross-corpus monthly totals + per-corpus breakdown + unattributed share (YYYY-MM). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babav/knowledge-core-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "TypeScript client for the Babav Knowledge Core API (Deno + Node 18+, zero deps). Includes the babav.visual grammar TYPES at the ./visual subpath (types only; all visual rendering is server-side).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
package/src/index.ts
CHANGED
|
@@ -202,6 +202,16 @@ export interface Folder {
|
|
|
202
202
|
corpus_id: UUID;
|
|
203
203
|
name: string;
|
|
204
204
|
}
|
|
205
|
+
export interface Reach {
|
|
206
|
+
exposure_queries: number;
|
|
207
|
+
citation_reach: number | null; // DOCUMENT headline metric
|
|
208
|
+
retrieved_reach: number | null;
|
|
209
|
+
conversion: number | null;
|
|
210
|
+
citation_count: number;
|
|
211
|
+
chunks_reranked: number;
|
|
212
|
+
best_rerank_score: number | null;
|
|
213
|
+
band: AnalyticsBand;
|
|
214
|
+
}
|
|
205
215
|
export interface Document {
|
|
206
216
|
id: UUID;
|
|
207
217
|
corpus_id: UUID;
|
|
@@ -213,6 +223,7 @@ export interface Document {
|
|
|
213
223
|
chunk_count: number;
|
|
214
224
|
custom_metadata: Record<string, unknown>;
|
|
215
225
|
error: string | null;
|
|
226
|
+
reach?: Reach; // present only when requested with include=reach
|
|
216
227
|
}
|
|
217
228
|
export interface ContentUrl {
|
|
218
229
|
content_url: string;
|
|
@@ -293,6 +304,17 @@ export interface RetrievalEventRow {
|
|
|
293
304
|
id: UUID; created_at: string; corpus_ids: UUID[]; pool_size: number;
|
|
294
305
|
message_id: UUID | null; documents: Array<Record<string, unknown>>;
|
|
295
306
|
}
|
|
307
|
+
export type Quadrant = "workhorse" | "hidden_gem" | "padding" | "cold" | "insufficient_data";
|
|
308
|
+
export interface ScatterDoc {
|
|
309
|
+
document_id: UUID; filename: string | null;
|
|
310
|
+
x_retrieved_reach: number; y_conversion: number;
|
|
311
|
+
chunk_count: number; citation_count: number; exposure_queries: number;
|
|
312
|
+
band: AnalyticsBand; quadrant: Quadrant;
|
|
313
|
+
}
|
|
314
|
+
export interface ScatterResponse {
|
|
315
|
+
corpus_id: UUID; corpus_total_queries: number; generated_at: string;
|
|
316
|
+
truncated: boolean; documents: ScatterDoc[];
|
|
317
|
+
}
|
|
296
318
|
export interface Conversation {
|
|
297
319
|
id: UUID;
|
|
298
320
|
title: string | null;
|
|
@@ -792,7 +814,7 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
792
814
|
// folder cannot be deleted either way.
|
|
793
815
|
delete: (folderId: UUID, confirmName?: string) =>
|
|
794
816
|
this.request<void>("DELETE", `/v1/folders/${folderId}`, confirmName ? { query: { confirm: confirmName } } : undefined),
|
|
795
|
-
listDocuments: (folderId: UUID, q?: { limit?: number; cursor?: string }) =>
|
|
817
|
+
listDocuments: (folderId: UUID, q?: { limit?: number; cursor?: string; include?: "reach" }) =>
|
|
796
818
|
this.request<Page<Document>>("GET", `/v1/folders/${folderId}/documents`, { query: q }),
|
|
797
819
|
/** Count documents in the folder: { total, indexed, in_flight, failed }. */
|
|
798
820
|
countDocuments: (folderId: UUID) =>
|
|
@@ -808,7 +830,8 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
808
830
|
|
|
809
831
|
// --- documents ---
|
|
810
832
|
documents = {
|
|
811
|
-
get: (id: UUID
|
|
833
|
+
get: (id: UUID, opts?: { include?: "reach" }) =>
|
|
834
|
+
this.request<Document>("GET", `/v1/documents/${id}`, { query: opts }),
|
|
812
835
|
getCustomMetadata: (id: UUID) => this.request<Record<string, unknown>>("GET", `/v1/documents/${id}/custom_metadata`),
|
|
813
836
|
/** Merge custom_metadata (a null value deletes a key). Returns the merged object. */
|
|
814
837
|
patchCustomMetadata: (id: UUID, custom_metadata: Record<string, unknown>) =>
|
|
@@ -911,6 +934,9 @@ export class KnowledgeCoreClient extends HttpBase {
|
|
|
911
934
|
document: (documentId: UUID) => this.request<DocumentAnalytics>("GET", `/v1/analytics/documents/${documentId}`),
|
|
912
935
|
/** Parent-section grain for a document (never exposes chunk ids). */
|
|
913
936
|
documentSections: (documentId: UUID) => this.request<SectionsResponse>("GET", `/v1/analytics/documents/${documentId}/sections`),
|
|
937
|
+
/** Whole-corpus scatter payload: every document with x=retrieved_reach, y=conversion,
|
|
938
|
+
* bubble=chunk_count, and a server-computed quadrant. No pagination (`truncated` if capped). */
|
|
939
|
+
corpusScatter: (corpusId: UUID) => this.request<ScatterResponse>("GET", `/v1/analytics/corpora/${corpusId}/scatter`),
|
|
914
940
|
/** A corpus's monthly metrics + revenue_share (YYYY-MM). */
|
|
915
941
|
corpusMonthly: (corpusId: UUID, yyyyMm: string) => this.request<MonthlyCorpus>("GET", `/v1/analytics/corpora/${corpusId}/monthly/${yyyyMm}`),
|
|
916
942
|
/** Cross-corpus monthly totals + per-corpus breakdown + unattributed share (YYYY-MM). */
|