@opengeni/contracts 0.38.2 → 0.39.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.
@@ -0,0 +1,169 @@
1
+ import { z } from "zod";
2
+
3
+ export const TranscriptionRecordingErrorCode = z.enum([
4
+ "permission_denied",
5
+ "not_supported",
6
+ "network",
7
+ "provider",
8
+ "policy_blocked",
9
+ "timeout",
10
+ "cancelled",
11
+ "unavailable",
12
+ "too_large",
13
+ "invalid_audio",
14
+ "unknown",
15
+ ]);
16
+ export type TranscriptionRecordingErrorCode = z.infer<typeof TranscriptionRecordingErrorCode>;
17
+
18
+ export const TranscriptionRecordingState = z.enum([
19
+ "uploading",
20
+ "segmenting",
21
+ "ready",
22
+ "transcribing",
23
+ "complete",
24
+ "failed",
25
+ "discarded",
26
+ ]);
27
+ export type TranscriptionRecordingState = z.infer<typeof TranscriptionRecordingState>;
28
+
29
+ export const TranscriptionRecordingSegmentState = z.enum([
30
+ "preparing",
31
+ "pending",
32
+ "transcribing",
33
+ "complete",
34
+ "failed",
35
+ ]);
36
+ export type TranscriptionRecordingSegmentState = z.infer<typeof TranscriptionRecordingSegmentState>;
37
+
38
+ export const ClientResumableVoiceInputConfig = z
39
+ .object({
40
+ maxDurationSeconds: z
41
+ .number()
42
+ .int()
43
+ .positive()
44
+ .max(8 * 60 * 60),
45
+ maxSizeBytes: z
46
+ .number()
47
+ .int()
48
+ .positive()
49
+ .max(512 * 1024 * 1024),
50
+ maxChunkSizeBytes: z
51
+ .number()
52
+ .int()
53
+ .positive()
54
+ .max(25 * 1024 * 1024),
55
+ providerSegmentSeconds: z.number().int().positive().max(600),
56
+ })
57
+ .strict();
58
+ export type ClientResumableVoiceInputConfig = z.infer<typeof ClientResumableVoiceInputConfig>;
59
+
60
+ export const CreateTranscriptionRecordingRequest = z
61
+ .object({
62
+ recordingId: z.string().uuid(),
63
+ mimeType: z.string().trim().min(1).max(128),
64
+ })
65
+ .strict();
66
+ export type CreateTranscriptionRecordingRequest = z.infer<
67
+ typeof CreateTranscriptionRecordingRequest
68
+ >;
69
+
70
+ export const FinalizeTranscriptionRecordingRequest = z
71
+ .object({
72
+ chunkCount: z.number().int().positive().max(100_000),
73
+ totalBytes: z
74
+ .number()
75
+ .int()
76
+ .positive()
77
+ .max(512 * 1024 * 1024),
78
+ totalDurationMilliseconds: z
79
+ .number()
80
+ .int()
81
+ .positive()
82
+ .max(8 * 60 * 60 * 1_000),
83
+ })
84
+ .strict();
85
+ export type FinalizeTranscriptionRecordingRequest = z.infer<
86
+ typeof FinalizeTranscriptionRecordingRequest
87
+ >;
88
+
89
+ export const TranscriptionRecordingChunk = z
90
+ .object({
91
+ chunkNumber: z.number().int().nonnegative(),
92
+ byteLength: z.number().int().positive(),
93
+ sha256: z.string().regex(/^[0-9a-f]{64}$/),
94
+ startMilliseconds: z.number().int().nonnegative(),
95
+ durationMilliseconds: z.number().int().nonnegative(),
96
+ deduplicated: z.boolean(),
97
+ })
98
+ .strict();
99
+ export type TranscriptionRecordingChunk = z.infer<typeof TranscriptionRecordingChunk>;
100
+
101
+ export const TranscriptionRecordingSegment = z
102
+ .object({
103
+ segmentNumber: z.number().int().nonnegative(),
104
+ state: TranscriptionRecordingSegmentState,
105
+ startMilliseconds: z.number().int().nonnegative(),
106
+ durationMilliseconds: z.number().int().positive(),
107
+ byteLength: z.number().int().positive(),
108
+ errorCode: TranscriptionRecordingErrorCode.nullable(),
109
+ retryable: z.boolean(),
110
+ })
111
+ .strict();
112
+ export type TranscriptionRecordingSegment = z.infer<typeof TranscriptionRecordingSegment>;
113
+
114
+ export const TranscriptionRecording = z
115
+ .object({
116
+ id: z.string().uuid(),
117
+ workspaceId: z.string().uuid(),
118
+ mimeType: z.string().trim().min(1).max(128),
119
+ state: TranscriptionRecordingState,
120
+ nextChunkNumber: z.number().int().nonnegative(),
121
+ chunkCount: z.number().int().nonnegative(),
122
+ totalBytes: z.number().int().nonnegative(),
123
+ totalDurationMilliseconds: z.number().int().nonnegative(),
124
+ segmentCount: z.number().int().nonnegative(),
125
+ completedSegmentCount: z.number().int().nonnegative(),
126
+ transcriptText: z.string().max(1_000_000).nullable(),
127
+ languages: z.array(z.string().trim().min(1).max(64)).max(64),
128
+ errorCode: TranscriptionRecordingErrorCode.nullable(),
129
+ retryable: z.boolean(),
130
+ objectsCleaned: z.boolean(),
131
+ createdAt: z.string().datetime(),
132
+ updatedAt: z.string().datetime(),
133
+ expiresAt: z.string().datetime(),
134
+ })
135
+ .strict();
136
+ export type TranscriptionRecording = z.infer<typeof TranscriptionRecording>;
137
+
138
+ export const TranscriptionRecordingResponse = z
139
+ .object({
140
+ recording: TranscriptionRecording,
141
+ segments: z.array(TranscriptionRecordingSegment).max(1_000),
142
+ retryAfterMilliseconds: z.number().int().positive().max(60_000).optional(),
143
+ })
144
+ .strict();
145
+ export type TranscriptionRecordingResponse = z.infer<typeof TranscriptionRecordingResponse>;
146
+
147
+ export const TranscriptionRecordingListResponse = z
148
+ .object({
149
+ recordings: z.array(TranscriptionRecording).max(50),
150
+ })
151
+ .strict();
152
+ export type TranscriptionRecordingListResponse = z.infer<typeof TranscriptionRecordingListResponse>;
153
+
154
+ export const UploadTranscriptionRecordingChunkResponse = z
155
+ .object({
156
+ recording: TranscriptionRecording,
157
+ chunk: TranscriptionRecordingChunk,
158
+ })
159
+ .strict();
160
+ export type UploadTranscriptionRecordingChunkResponse = z.infer<
161
+ typeof UploadTranscriptionRecordingChunkResponse
162
+ >;
163
+
164
+ export const TRANSCRIPTION_RECORDING_MAX_DURATION_SECONDS = 2 * 60 * 60;
165
+ export const TRANSCRIPTION_RECORDING_MAX_SIZE_BYTES = 512 * 1024 * 1024;
166
+ export const TRANSCRIPTION_RECORDING_MAX_CHUNK_SIZE_BYTES = 8 * 1024 * 1024;
167
+ export const TRANSCRIPTION_RECORDING_PROVIDER_SEGMENT_SECONDS = 50;
168
+ export const TRANSCRIPTION_RECORDING_RECOVERY_RETRY_AFTER_MILLISECONDS = 5_000;
169
+ export const TRANSCRIPTION_RECORDING_RETENTION_SECONDS = 24 * 60 * 60;