@opengeni/sdk 0.44.6 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-ONKUBP7A.js → chunk-QKV5OCLJ.js} +146 -1
- package/dist/chunk-QKV5OCLJ.js.map +1 -0
- package/dist/client.d.ts +35 -1
- package/dist/core.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types.d.ts +59 -0
- package/package.json +1 -1
- package/src/client.ts +252 -0
- package/src/types.ts +92 -0
- package/dist/chunk-ONKUBP7A.js.map +0 -1
|
@@ -516,6 +516,119 @@ var OpenGeniClient = class {
|
|
|
516
516
|
}
|
|
517
517
|
return body;
|
|
518
518
|
}
|
|
519
|
+
async createTranscriptionRecording(workspaceId, input) {
|
|
520
|
+
return transcriptionRecordingResponse(
|
|
521
|
+
await this.requestJson(
|
|
522
|
+
"POST",
|
|
523
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings`,
|
|
524
|
+
{ recordingId: input.recordingId, mimeType: input.mimeType },
|
|
525
|
+
{},
|
|
526
|
+
input.signal ? { signal: input.signal } : {}
|
|
527
|
+
)
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
async getTranscriptionRecording(workspaceId, recordingId, options = {}) {
|
|
531
|
+
return transcriptionRecordingResponse(
|
|
532
|
+
await this.requestJson(
|
|
533
|
+
"GET",
|
|
534
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}`,
|
|
535
|
+
void 0,
|
|
536
|
+
{},
|
|
537
|
+
options.signal ? { signal: options.signal } : {}
|
|
538
|
+
)
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
async listTranscriptionRecordings(workspaceId, options = {}) {
|
|
542
|
+
const body = await this.requestJson(
|
|
543
|
+
"GET",
|
|
544
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings`,
|
|
545
|
+
void 0,
|
|
546
|
+
{},
|
|
547
|
+
options.signal ? { signal: options.signal } : {}
|
|
548
|
+
);
|
|
549
|
+
if (!isTranscriptionRecordingListResponse(body)) {
|
|
550
|
+
throw new OpenGeniApiError(502, "Invalid transcription recording list response.", {
|
|
551
|
+
code: "invalid_response"
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
return body;
|
|
555
|
+
}
|
|
556
|
+
async uploadTranscriptionRecordingChunk(workspaceId, recordingId, chunkNumber, input) {
|
|
557
|
+
const correlationId = crypto.randomUUID();
|
|
558
|
+
let response;
|
|
559
|
+
try {
|
|
560
|
+
response = await this.fetchImpl(
|
|
561
|
+
this.url(
|
|
562
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}/chunks/${chunkNumber}`
|
|
563
|
+
),
|
|
564
|
+
{
|
|
565
|
+
method: "PUT",
|
|
566
|
+
headers: {
|
|
567
|
+
...this.headers(correlationId),
|
|
568
|
+
Accept: "application/json",
|
|
569
|
+
"Content-Type": input.mimeType,
|
|
570
|
+
"x-opengeni-chunk-sha256": input.sha256,
|
|
571
|
+
"x-opengeni-chunk-start-milliseconds": String(input.startMilliseconds),
|
|
572
|
+
"x-opengeni-chunk-duration-milliseconds": String(input.durationMilliseconds)
|
|
573
|
+
},
|
|
574
|
+
body: input.audio instanceof Uint8Array ? Uint8Array.from(input.audio) : input.audio,
|
|
575
|
+
...input.signal ? { signal: input.signal } : {}
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
} catch (error) {
|
|
579
|
+
if (input.signal?.aborted) throw error;
|
|
580
|
+
throw mutationTransportError(correlationId);
|
|
581
|
+
}
|
|
582
|
+
assertApiContractResponse(response);
|
|
583
|
+
if (!response.ok) throw await apiErrorFromResponse(response, { method: "PUT", correlationId });
|
|
584
|
+
await assertJsonResponse(response, { method: "PUT", correlationId });
|
|
585
|
+
const body = await response.json().catch(() => null);
|
|
586
|
+
if (!isUploadTranscriptionRecordingChunkResponse(body)) {
|
|
587
|
+
throw new OpenGeniApiError(response.status, "Invalid transcription chunk response.", {
|
|
588
|
+
code: "invalid_response",
|
|
589
|
+
mutation: true,
|
|
590
|
+
correlationId
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
return body;
|
|
594
|
+
}
|
|
595
|
+
async finalizeTranscriptionRecording(workspaceId, recordingId, input) {
|
|
596
|
+
return transcriptionRecordingResponse(
|
|
597
|
+
await this.requestJson(
|
|
598
|
+
"POST",
|
|
599
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}/finalize`,
|
|
600
|
+
{
|
|
601
|
+
chunkCount: input.chunkCount,
|
|
602
|
+
totalBytes: input.totalBytes,
|
|
603
|
+
totalDurationMilliseconds: input.totalDurationMilliseconds
|
|
604
|
+
},
|
|
605
|
+
{},
|
|
606
|
+
input.signal ? { signal: input.signal } : {}
|
|
607
|
+
)
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
async processNextTranscriptionRecordingSegment(workspaceId, recordingId, options = {}) {
|
|
611
|
+
return transcriptionRecordingResponse(
|
|
612
|
+
await this.requestJson(
|
|
613
|
+
"POST",
|
|
614
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}/process-next`,
|
|
615
|
+
{},
|
|
616
|
+
{},
|
|
617
|
+
options.signal ? { signal: options.signal } : {}
|
|
618
|
+
)
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
async discardTranscriptionRecording(workspaceId, recordingId, options = {}) {
|
|
622
|
+
return transcriptionRecordingResponse(
|
|
623
|
+
await this.requestJson(
|
|
624
|
+
"DELETE",
|
|
625
|
+
`/v1/workspaces/${workspaceId}/transcription-recordings/${recordingId}`,
|
|
626
|
+
void 0,
|
|
627
|
+
{},
|
|
628
|
+
options.signal ? { signal: options.signal } : {}
|
|
629
|
+
)
|
|
630
|
+
);
|
|
631
|
+
}
|
|
519
632
|
async createSession(workspaceId, request) {
|
|
520
633
|
return await this.requestJson(
|
|
521
634
|
"POST",
|
|
@@ -2727,6 +2840,38 @@ function isTranscribeAudioResponse(value) {
|
|
|
2727
2840
|
const record = value;
|
|
2728
2841
|
return typeof record.text === "string" && Array.isArray(record.languages) && record.languages.every((language) => typeof language === "string");
|
|
2729
2842
|
}
|
|
2843
|
+
function isUploadTranscriptionRecordingChunkResponse(value) {
|
|
2844
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
2845
|
+
const record = value;
|
|
2846
|
+
if (!isTranscriptionRecordingResponse({ recording: record.recording, segments: [] })) {
|
|
2847
|
+
return false;
|
|
2848
|
+
}
|
|
2849
|
+
if (!record.chunk || typeof record.chunk !== "object" || Array.isArray(record.chunk)) {
|
|
2850
|
+
return false;
|
|
2851
|
+
}
|
|
2852
|
+
const chunk = record.chunk;
|
|
2853
|
+
return typeof chunk.chunkNumber === "number" && typeof chunk.byteLength === "number" && typeof chunk.sha256 === "string" && typeof chunk.startMilliseconds === "number" && typeof chunk.durationMilliseconds === "number" && typeof chunk.deduplicated === "boolean";
|
|
2854
|
+
}
|
|
2855
|
+
function isTranscriptionRecordingResponse(value) {
|
|
2856
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
2857
|
+
const response = value;
|
|
2858
|
+
if (!response.recording || typeof response.recording !== "object" || Array.isArray(response.recording)) {
|
|
2859
|
+
return false;
|
|
2860
|
+
}
|
|
2861
|
+
const recording = response.recording;
|
|
2862
|
+
return typeof recording.id === "string" && typeof recording.workspaceId === "string" && typeof recording.mimeType === "string" && typeof recording.state === "string" && typeof recording.nextChunkNumber === "number" && typeof recording.chunkCount === "number" && typeof recording.totalBytes === "number" && typeof recording.totalDurationMilliseconds === "number" && typeof recording.segmentCount === "number" && typeof recording.completedSegmentCount === "number" && (recording.transcriptText === null || typeof recording.transcriptText === "string") && Array.isArray(recording.languages) && (recording.errorCode === null || typeof recording.errorCode === "string") && typeof recording.retryable === "boolean" && typeof recording.objectsCleaned === "boolean" && typeof recording.createdAt === "string" && typeof recording.updatedAt === "string" && typeof recording.expiresAt === "string" && (response.retryAfterMilliseconds === void 0 || typeof response.retryAfterMilliseconds === "number" && Number.isInteger(response.retryAfterMilliseconds) && response.retryAfterMilliseconds > 0 && response.retryAfterMilliseconds <= 6e4) && Array.isArray(response.segments);
|
|
2863
|
+
}
|
|
2864
|
+
function transcriptionRecordingResponse(value) {
|
|
2865
|
+
if (isTranscriptionRecordingResponse(value)) return value;
|
|
2866
|
+
throw new OpenGeniApiError(502, "Invalid transcription recording response.", {
|
|
2867
|
+
code: "invalid_response"
|
|
2868
|
+
});
|
|
2869
|
+
}
|
|
2870
|
+
function isTranscriptionRecordingListResponse(value) {
|
|
2871
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
2872
|
+
const recordings = value.recordings;
|
|
2873
|
+
return Array.isArray(recordings) && recordings.length <= 50 && recordings.every((recording) => isTranscriptionRecordingResponse({ recording, segments: [] }));
|
|
2874
|
+
}
|
|
2730
2875
|
function filenameForAudioMimeType(mimeType) {
|
|
2731
2876
|
const bare = mimeType.trim().toLowerCase().split(";")[0] ?? "audio/webm";
|
|
2732
2877
|
switch (bare) {
|
|
@@ -3094,4 +3239,4 @@ export {
|
|
|
3094
3239
|
authorizeTranscriptionAdapter,
|
|
3095
3240
|
createTranscriptionSessionRequest
|
|
3096
3241
|
};
|
|
3097
|
-
//# sourceMappingURL=chunk-
|
|
3242
|
+
//# sourceMappingURL=chunk-QKV5OCLJ.js.map
|