@babav/knowledge-core-client 0.37.0 → 0.38.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.
package/dist/index.d.ts CHANGED
@@ -325,6 +325,35 @@ export interface SectionsResponse {
325
325
  document_id: UUID;
326
326
  sections: SectionAnalytics[];
327
327
  }
328
+ /** One chunk's retrieval heat + where it sits in the document's view-PDF. `regions` are
329
+ * view-PDF points (origin bottom-left), possibly spanning pages; `method`/`regions` null (or
330
+ * method "unaligned") => no box to draw (heat still shown). retrieved=0 => never-retrieved. */
331
+ export interface ChunkHeat {
332
+ chunk_id: string;
333
+ seq: number;
334
+ retrieved: number;
335
+ reranked: number;
336
+ citation_count: number;
337
+ best_rerank_rank: number | null;
338
+ best_rerank_score: number | null;
339
+ method: string | null;
340
+ regions: {
341
+ page: number;
342
+ bbox: [number, number, number, number];
343
+ }[] | null;
344
+ }
345
+ /** Everything to overlay retrieval heat on the original document: a signed view-PDF URL
346
+ * (render with pdf.js), its per-page geometry, and every chunk's heat + boxes. */
347
+ export interface ChunkHeatmapResponse {
348
+ document_id: UUID;
349
+ view_pdf_url: string | null;
350
+ page_dims: {
351
+ w: number;
352
+ h: number;
353
+ rotation: number;
354
+ }[] | null;
355
+ chunks: ChunkHeat[];
356
+ }
328
357
  export interface MonthlyCorpus {
329
358
  corpus_id: UUID;
330
359
  yyyy_mm: string;
@@ -933,6 +962,9 @@ export declare class KnowledgeCoreClient extends HttpBase {
933
962
  document: (documentId: UUID) => Promise<DocumentAnalytics>;
934
963
  /** Parent-section grain for a document (never exposes chunk ids). */
935
964
  documentSections: (documentId: UUID) => Promise<SectionsResponse>;
965
+ /** Per-chunk retrieval heat + position in the document's view-PDF, plus a signed
966
+ * view-PDF URL — everything to overlay heat on the ORIGINAL document with pdf.js. */
967
+ documentChunks: (documentId: UUID) => Promise<ChunkHeatmapResponse>;
936
968
  /** Whole-corpus scatter payload: every document with x=retrieved_reach, y=conversion,
937
969
  * bubble=chunk_count, and a server-computed quadrant. No pagination (`truncated` if capped). */
938
970
  corpusScatter: (corpusId: UUID) => Promise<ScatterResponse>;
package/dist/index.js CHANGED
@@ -468,6 +468,9 @@ export class KnowledgeCoreClient extends HttpBase {
468
468
  document: (documentId) => this.request("GET", `/v1/analytics/documents/${documentId}`),
469
469
  /** Parent-section grain for a document (never exposes chunk ids). */
470
470
  documentSections: (documentId) => this.request("GET", `/v1/analytics/documents/${documentId}/sections`),
471
+ /** Per-chunk retrieval heat + position in the document's view-PDF, plus a signed
472
+ * view-PDF URL — everything to overlay heat on the ORIGINAL document with pdf.js. */
473
+ documentChunks: (documentId) => this.request("GET", `/v1/analytics/documents/${documentId}/chunks`),
471
474
  /** Whole-corpus scatter payload: every document with x=retrieved_reach, y=conversion,
472
475
  * bubble=chunk_count, and a server-computed quadrant. No pagination (`truncated` if capped). */
473
476
  corpusScatter: (corpusId) => this.request("GET", `/v1/analytics/corpora/${corpusId}/scatter`),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babav/knowledge-core-client",
3
- "version": "0.37.0",
3
+ "version": "0.38.1",
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
@@ -336,6 +336,24 @@ export interface SectionAnalytics {
336
336
  citation_count: number; best_rerank_score: number | null; band: AnalyticsBand;
337
337
  }
338
338
  export interface SectionsResponse { document_id: UUID; sections: SectionAnalytics[] }
339
+ /** One chunk's retrieval heat + where it sits in the document's view-PDF. `regions` are
340
+ * view-PDF points (origin bottom-left), possibly spanning pages; `method`/`regions` null (or
341
+ * method "unaligned") => no box to draw (heat still shown). retrieved=0 => never-retrieved. */
342
+ export interface ChunkHeat {
343
+ chunk_id: string; seq: number;
344
+ retrieved: number; reranked: number; citation_count: number;
345
+ best_rerank_rank: number | null; best_rerank_score: number | null;
346
+ method: string | null;
347
+ regions: { page: number; bbox: [number, number, number, number] }[] | null;
348
+ }
349
+ /** Everything to overlay retrieval heat on the original document: a signed view-PDF URL
350
+ * (render with pdf.js), its per-page geometry, and every chunk's heat + boxes. */
351
+ export interface ChunkHeatmapResponse {
352
+ document_id: UUID;
353
+ view_pdf_url: string | null;
354
+ page_dims: { w: number; h: number; rotation: number }[] | null;
355
+ chunks: ChunkHeat[];
356
+ }
339
357
  export interface MonthlyCorpus {
340
358
  corpus_id: UUID; yyyy_mm: string; queries: number; documents_retrieved: number;
341
359
  chunks_retrieved: number; citations: number; revenue_share: number;
@@ -1070,6 +1088,9 @@ export class KnowledgeCoreClient extends HttpBase {
1070
1088
  document: (documentId: UUID) => this.request<DocumentAnalytics>("GET", `/v1/analytics/documents/${documentId}`),
1071
1089
  /** Parent-section grain for a document (never exposes chunk ids). */
1072
1090
  documentSections: (documentId: UUID) => this.request<SectionsResponse>("GET", `/v1/analytics/documents/${documentId}/sections`),
1091
+ /** Per-chunk retrieval heat + position in the document's view-PDF, plus a signed
1092
+ * view-PDF URL — everything to overlay heat on the ORIGINAL document with pdf.js. */
1093
+ documentChunks: (documentId: UUID) => this.request<ChunkHeatmapResponse>("GET", `/v1/analytics/documents/${documentId}/chunks`),
1073
1094
  /** Whole-corpus scatter payload: every document with x=retrieved_reach, y=conversion,
1074
1095
  * bubble=chunk_count, and a server-computed quadrant. No pagination (`truncated` if capped). */
1075
1096
  corpusScatter: (corpusId: UUID) => this.request<ScatterResponse>("GET", `/v1/analytics/corpora/${corpusId}/scatter`),