Skip to content
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
2 changes: 1 addition & 1 deletion src/parsing/v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export { InferenceResult } from "./inferenceResult";
export { Job } from "./job";
export { JobResponse } from "./jobResponse";
export { RawText } from "./rawText";
export { JobResponseWebhook } from "./jobResponseWebhook";
export { JobWebhook } from "./jobWebhook";
14 changes: 13 additions & 1 deletion src/parsing/v2/inferenceFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,29 @@ export class InferenceFile {
* Optional alias for the file.
*/
public alias: string;
/**
* Page count.
*/
public pageCount: number;
/**
* MIME type.
*/
public mimeType: string;

constructor(serverResponse: StringDict) {
this.name = serverResponse["name"];
this.alias = serverResponse["alias"];
this.pageCount = serverResponse["page_count"];
this.mimeType = serverResponse["mime_type"];
}

toString () {
return(
"File\n" +
"====\n" +
`:Name: ${this.name}\n` +
`:Alias:${this.alias ? " " + this.alias : ""}\n`);
`:Alias:${this.alias ? " " + this.alias : ""}\n`) +
`:Page Count: ${this.pageCount}\n` +
`:MIME Type: ${this.mimeType}\n`;
}
}
4 changes: 2 additions & 2 deletions src/parsing/v2/job.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { StringDict } from "../common";
import { ErrorResponse } from "./errorResponse";
import { JobResponseWebhook } from "./jobResponseWebhook";
import { JobWebhook } from "./jobWebhook";
import { parseDate } from "../common";

/**
Expand Down Expand Up @@ -47,7 +47,7 @@ export class Job {
/**
* ID of webhooks associated with the job.
*/
public webhooks: Array<JobResponseWebhook>;
public webhooks: Array<JobWebhook>;

constructor(serverResponse: StringDict) {
this.id = serverResponse["id"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { ErrorResponse } from "./errorResponse";
import { StringDict, parseDate } from "../common";

/**
* JobResponseWebhook information.
* JobWebhook information.
*/
export class JobResponseWebhook {
export class JobWebhook {
/**
* JobResponseWebhook ID.
* JobWebhook ID.
*/
public id: string;
/**
Expand Down
4 changes: 3 additions & 1 deletion tests/parsing/v2/inference.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from "chai";
import path from "node:path";
import { InferenceResponse } from "../../../src/parsing/v2";
import { ClientV2, LocalResponse } from "../../../src";
import { LocalResponse } from "../../../src";
import { ListField, ObjectField, SimpleField } from "../../../src/parsing/v2/field";
import { promises as fs } from "node:fs";

Expand Down Expand Up @@ -69,6 +69,8 @@ describe("inference", async () => {
expect(file).to.not.be.undefined;
expect(file.name).to.eq("complete.jpg");
expect(file.alias ?? null).to.be.null;
expect(file.pageCount).to.eq(1);
expect(file.mimeType).to.eq("image/jpeg");

const fields = inf.result.fields;
expect(fields).to.be.not.empty;
Expand Down
Loading