Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

Commit 0b1f9c8

Browse files
Merge pull request #46 from tensorlakeai/feat/analytics-api
feat: add analytics API
2 parents c63b32d + 18f60f2 commit 0b1f9c8

File tree

4 files changed

+76
-49
lines changed

4 files changed

+76
-49
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "getindexify",
3-
"version": "0.0.64",
3+
"version": "0.0.65",
44
"description": "This is the TypeScript client for interacting with the Indexify service.",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",

src/client.ts

+60-45
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
IContent,
1616
IExtractResponse,
1717
IExtractedMetadata,
18+
ExtractionGraphAnalytics,
1819
} from "./types";
1920
import { v4 as uuidv4 } from "uuid";
2021
import CryptoJS from "crypto-js";
@@ -450,6 +451,20 @@ class IndexifyClient {
450451
return resp.data;
451452
}
452453

454+
async getExtractionGraphAnalytics({
455+
namespace,
456+
extractionGraph,
457+
}: {
458+
namespace: string;
459+
extractionGraph: string;
460+
}): Promise<ExtractionGraphAnalytics> {
461+
const response = await this.client.get(
462+
`namespaces/${namespace}/extraction_graphs/${extractionGraph}/analytics`
463+
);
464+
465+
return response.data;
466+
}
467+
453468
async waitForExtraction(contentIds: string | string[]): Promise<void> {
454469
const ids = Array.isArray(contentIds) ? contentIds : [contentIds];
455470

@@ -525,51 +540,51 @@ class IndexifyClient {
525540
}
526541

527542
async listContent(
528-
extractionGraph: string,
529-
namespace?: string,
530-
params?: {
531-
namespace: string;
532-
extractionGraph: string;
533-
source?: string;
534-
ingestedContentId?: string;
535-
parentId?: string;
536-
labelsFilter?: string[];
537-
startId?: string;
538-
limit?: number;
539-
returnTotal?: boolean;
540-
}
541-
): Promise<{ contentList: IContentMetadata[]; total?: number }> {
542-
const defaultParams = {
543-
namespace: namespace || this.namespace,
544-
extraction_graph: extractionGraph,
545-
return_total: false,
546-
};
547-
548-
const mergedParams = {
549-
...defaultParams,
550-
...params,
551-
namespace: params?.namespace || namespace || this.namespace,
552-
extraction_graph: params?.extractionGraph || extractionGraph,
553-
labels_filter: params?.labelsFilter,
554-
ingested_content_id: params?.ingestedContentId,
555-
parent_id: params?.parentId,
556-
start_id: params?.startId,
557-
};
558-
559-
const response = await this.client.get(
560-
`extraction_graphs/${mergedParams.extraction_graph}/content`,
561-
{ params: mergedParams }
562-
);
563-
564-
const contentList = response.data.content_list.map((item: IBaseContentMetadata) =>
565-
this.baseContentToContentMetadata(item)
566-
);
567-
568-
return {
569-
contentList,
570-
total: mergedParams.return_total ? response.data.total : undefined
571-
};
572-
}
543+
extractionGraph: string,
544+
namespace?: string,
545+
params?: {
546+
namespace: string;
547+
extractionGraph: string;
548+
source?: string;
549+
ingestedContentId?: string;
550+
parentId?: string;
551+
labelsFilter?: string[];
552+
startId?: string;
553+
limit?: number;
554+
returnTotal?: boolean;
555+
}
556+
): Promise<{ contentList: IContentMetadata[]; total?: number }> {
557+
const defaultParams = {
558+
namespace: namespace || this.namespace,
559+
extraction_graph: extractionGraph,
560+
return_total: false,
561+
};
562+
563+
const mergedParams = {
564+
...defaultParams,
565+
...params,
566+
namespace: params?.namespace || namespace || this.namespace,
567+
extraction_graph: params?.extractionGraph || extractionGraph,
568+
labels_filter: params?.labelsFilter,
569+
ingested_content_id: params?.ingestedContentId,
570+
parent_id: params?.parentId,
571+
start_id: params?.startId,
572+
};
573+
574+
const response = await this.client.get(
575+
`extraction_graphs/${mergedParams.extraction_graph}/content`,
576+
{ params: mergedParams }
577+
);
578+
579+
const contentList = response.data.content_list.map((item: IBaseContentMetadata) =>
580+
this.baseContentToContentMetadata(item)
581+
);
582+
583+
return {
584+
contentList,
585+
total: mergedParams.return_total ? response.data.total : undefined
586+
};
587+
}
573588

574589
async sqlQuery(query: string): Promise<any> {
575590
const response = await this.client.post(

src/types.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,16 @@ export interface StateChange extends IBase {
160160
created_at: number;
161161
processed_at: number;
162162
refcnt_object_id: string | null;
163-
}
163+
}
164+
165+
export interface ExtractionPolicyStatus {
166+
pending: number;
167+
success: number;
168+
failure: number;
169+
}
170+
171+
export interface ExtractionGraphAnalytics {
172+
task_analytics: {
173+
[policyName: string]: ExtractionPolicyStatus;
174+
};
175+
}

0 commit comments

Comments
 (0)