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

Commit 4bcfb9c

Browse files
Merge pull request #42 from tensorlakeai/chore/api-filters
chore: api filters for listContent
2 parents 33bf564 + 3666b8b commit 4bcfb9c

File tree

3 files changed

+53
-15
lines changed

3 files changed

+53
-15
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.53",
3+
"version": "0.0.54",
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

+50-12
Original file line numberDiff line numberDiff line change
@@ -334,9 +334,30 @@ class IndexifyClient {
334334
async getTasks(
335335
extractionGraph: string,
336336
extractionPolicy: string,
337+
params?: {
338+
namespace: string;
339+
extractionGraph: string;
340+
extractionPolicy: string;
341+
contentId?: string;
342+
outcome?: string;
343+
startId?: string;
344+
limit?: number;
345+
returnTotal?: boolean;
346+
}
337347
): Promise<ITask[]> {
348+
349+
const defaultParams = {
350+
namespace: this.namespace,
351+
extractionGraph: extractionGraph,
352+
extractionPolicy: extractionPolicy,
353+
returnTotal: false,
354+
...params
355+
};
356+
338357
const response = await this.client.get(
339-
`/extraction_graphs/${extractionGraph}/extraction_policies/${extractionPolicy}/tasks`,
358+
`/extraction_graphs/${extractionGraph}/extraction_policies/${extractionPolicy}/tasks`, {
359+
params: defaultParams
360+
}
340361
);
341362

342363
return response.data.tasks;
@@ -533,21 +554,38 @@ class IndexifyClient {
533554
async listContent(
534555
extractionGraph: string,
535556
namespace?: string,
536-
): Promise<IContentMetadata[]> {
537-
let response;
538-
if (namespace) {
539-
response = await axios.get(
540-
`/namespaces/${namespace}/extraction_graphs/${extractionGraph}/content`
541-
);
542-
} else {
543-
response = await this.client.get(
544-
`extraction_graphs/${extractionGraph}/content`
545-
);
557+
params?: {
558+
namespace: string;
559+
extractionGraph: string;
560+
source?: string;
561+
parentId?: string;
562+
labelsFilter?: string[];
563+
startId?: string;
564+
limit?: number;
565+
returnTotal?: boolean;
546566
}
567+
): Promise<{ contentList: IContentMetadata[]; total?: number }> {
568+
569+
const defaultParams = {
570+
namespace: namespace,
571+
extractionGraph: extractionGraph,
572+
returnTotal: false,
573+
...params
574+
};
575+
576+
const response = await this.client.get(
577+
`extraction_graphs/${extractionGraph}/content`, {
578+
params: defaultParams
579+
}
580+
);
547581

548-
return response.data.content_list.map((item: IBaseContentMetadata) =>
582+
const contentList = response.data.content_list.map((item: IBaseContentMetadata) =>
549583
this.baseContentToContentMetadata(item)
550584
);
585+
586+
const totalCount = response.data.total;
587+
588+
return { contentList, total: totalCount };
551589
}
552590

553591
async sqlQuery(query: string): Promise<any> {

0 commit comments

Comments
 (0)