Skip to content

Commit 23d0490

Browse files
authored
Merge pull request #143 from AssemblyAI/EA17A79D514289B819B9AE7C9AB1132F
Sync from internal repo
2 parents d9a7994 + cf335e4 commit 23d0490

3 files changed

Lines changed: 73 additions & 1 deletion

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "assemblyai",
3-
"version": "4.29.0",
3+
"version": "4.30.0",
44
"description": "The AssemblyAI JavaScript SDK provides an easy-to-use interface for interacting with the AssemblyAI API, which supports async and real-time transcription, as well as the latest LeMUR models.",
55
"engines": {
66
"node": ">=18"

src/types/openapi.generated.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,18 @@ type OneOf<T extends any[]> = T extends [infer Only]
2121
*/
2222
export type AudioIntelligenceModelStatus = "success" | "unavailable";
2323

24+
export interface TranscriptWarning {
25+
/** The warning message. */
26+
message: string;
27+
}
28+
2429
export interface TranscriptMetadata {
2530
/** The domain that was actually used for the transcription. */
2631
domain_used?: string | null;
2732
/** An optional warning message, if applicable. */
2833
warning?: string | null;
34+
/** A list of warning objects, if applicable. */
35+
warnings?: TranscriptWarning[] | null;
2936
}
3037

3138
/**

tests/unit/transcript.test.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,4 +503,69 @@ describe("transcript", () => {
503503
expect(transcript.id).toBe(transcriptId);
504504
expect(transcript.speech_model_used).toBeUndefined();
505505
});
506+
507+
it("should handle transcript response with metadata warnings", async () => {
508+
const transcriptWithWarnings = {
509+
id: transcriptId,
510+
status: "completed",
511+
metadata: {
512+
domain_used: null,
513+
warnings: [
514+
{
515+
message:
516+
"Skipped medical-v1 correction because the language is not supported",
517+
},
518+
],
519+
},
520+
};
521+
fetchMock.doMockOnceIf(
522+
requestMatches({ url: `/v2/transcript/${transcriptId}`, method: "GET" }),
523+
JSON.stringify(transcriptWithWarnings),
524+
);
525+
const transcript = await assembly.transcripts.get(transcriptId);
526+
527+
expect(transcript.id).toBe(transcriptId);
528+
expect(transcript.metadata).toBeDefined();
529+
expect(transcript.metadata!.warnings).toHaveLength(1);
530+
expect(transcript.metadata!.warnings![0].message).toBe(
531+
"Skipped medical-v1 correction because the language is not supported",
532+
);
533+
expect(transcript.metadata!.domain_used).toBeNull();
534+
});
535+
536+
it("should handle transcript response with metadata but no warnings key", async () => {
537+
const transcriptWithMetadataNoWarnings = {
538+
id: transcriptId,
539+
status: "completed",
540+
metadata: {
541+
domain_used: null,
542+
},
543+
};
544+
fetchMock.doMockOnceIf(
545+
requestMatches({ url: `/v2/transcript/${transcriptId}`, method: "GET" }),
546+
JSON.stringify(transcriptWithMetadataNoWarnings),
547+
);
548+
const transcript = await assembly.transcripts.get(transcriptId);
549+
550+
expect(transcript.id).toBe(transcriptId);
551+
expect(transcript.metadata).toBeDefined();
552+
expect(transcript.metadata!.domain_used).toBeNull();
553+
expect(transcript.metadata!.warnings).toBeUndefined();
554+
});
555+
556+
it("should handle transcript response without metadata", async () => {
557+
const transcriptWithoutMetadata = {
558+
id: transcriptId,
559+
status: "completed",
560+
// metadata intentionally omitted
561+
};
562+
fetchMock.doMockOnceIf(
563+
requestMatches({ url: `/v2/transcript/${transcriptId}`, method: "GET" }),
564+
JSON.stringify(transcriptWithoutMetadata),
565+
);
566+
const transcript = await assembly.transcripts.get(transcriptId);
567+
568+
expect(transcript.id).toBe(transcriptId);
569+
expect(transcript.metadata).toBeUndefined();
570+
});
506571
});

0 commit comments

Comments
 (0)