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

feat: updated return type #49

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "getindexify",
"version": "0.0.67",
"version": "0.0.68",
"description": "This is the TypeScript client for interacting with the Indexify service.",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
41 changes: 23 additions & 18 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,6 @@ class IndexifyClient {
const isNodeEnv = typeof window === "undefined";
const extractionGraphNamesArray = Array.isArray(extractionGraphNames) ? extractionGraphNames : [extractionGraphNames];

let contentId: string | undefined;

for (const extractionGraph of extractionGraphNamesArray) {
let formData: any;

Expand All @@ -401,27 +399,34 @@ class IndexifyClient {
formData.append("file", fileInput);
}

const response = await this.client.post(
`/extraction_graphs/${extractionGraph}/extract`,
formData,
{
params: { id: newContentId },
headers: {
"Content-Type": "multipart/form-data",
"accept": "*/*"
try {
const response = await this.client.post(
`/namespaces/default/extraction_graphs/${extractionGraph}/extract`,
formData,
{
params: newContentId ? { id: newContentId } : undefined,
headers: {
"Content-Type": "multipart/form-data",
"accept": "*/*"
}
}
}
);
);

contentId = response.data.content_id || newContentId;
const contentId = response.data.content_id;

if (contentId) {
return contentId;
if (contentId) {
console.log(`Content ID retrieved: ${contentId}`);
return contentId;
} else {
console.warn(`Unexpected: No content ID found in response for extraction graph: ${extractionGraph}`);
}
} catch (error) {
console.error(`Error during extraction for graph ${extractionGraph}:`, error);
}

}

throw new Error("No content ID was retrieved from the extraction process");

console.error(`Failed to retrieve content ID for all extraction graphs: ${extractionGraphNamesArray.join(", ")}`);
return "";
}

async getExtractionGraphs(): Promise<ExtractionGraph[]> {
Expand Down