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

Commit c6b266a

Browse files
Merge pull request #49 from tensorlakeai/feat/fix-upload
feat: updated return type
2 parents 9fec1fe + b998089 commit c6b266a

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
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.67",
3+
"version": "0.0.68",
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

+23-18
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,6 @@ class IndexifyClient {
378378
const isNodeEnv = typeof window === "undefined";
379379
const extractionGraphNamesArray = Array.isArray(extractionGraphNames) ? extractionGraphNames : [extractionGraphNames];
380380

381-
let contentId: string | undefined;
382-
383381
for (const extractionGraph of extractionGraphNamesArray) {
384382
let formData: any;
385383

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

404-
const response = await this.client.post(
405-
`/extraction_graphs/${extractionGraph}/extract`,
406-
formData,
407-
{
408-
params: { id: newContentId },
409-
headers: {
410-
"Content-Type": "multipart/form-data",
411-
"accept": "*/*"
402+
try {
403+
const response = await this.client.post(
404+
`/namespaces/default/extraction_graphs/${extractionGraph}/extract`,
405+
formData,
406+
{
407+
params: newContentId ? { id: newContentId } : undefined,
408+
headers: {
409+
"Content-Type": "multipart/form-data",
410+
"accept": "*/*"
411+
}
412412
}
413-
}
414-
);
413+
);
415414

416-
contentId = response.data.content_id || newContentId;
415+
const contentId = response.data.content_id;
417416

418-
if (contentId) {
419-
return contentId;
417+
if (contentId) {
418+
console.log(`Content ID retrieved: ${contentId}`);
419+
return contentId;
420+
} else {
421+
console.warn(`Unexpected: No content ID found in response for extraction graph: ${extractionGraph}`);
422+
}
423+
} catch (error) {
424+
console.error(`Error during extraction for graph ${extractionGraph}:`, error);
420425
}
421-
422426
}
423-
424-
throw new Error("No content ID was retrieved from the extraction process");
427+
428+
console.error(`Failed to retrieve content ID for all extraction graphs: ${extractionGraphNamesArray.join(", ")}`);
429+
return "";
425430
}
426431

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

0 commit comments

Comments
 (0)