@omelhorsite/sdk 0.3.0 → 0.4.1
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/README.md +113 -131
- package/dist/index.js +1049 -1246
- package/dist/types/auth/device.d.ts +1 -1
- package/dist/types/auth/index.d.ts +2 -2
- package/dist/types/auth/tokens.d.ts +15 -15
- package/dist/types/client.d.ts +10 -10
- package/dist/types/errors.d.ts +12 -15
- package/dist/types/http.d.ts +74 -118
- package/dist/types/index.d.ts +2 -2
- package/dist/types/internal/attachments.d.ts +17 -0
- package/dist/types/internal/helpers.d.ts +9 -0
- package/dist/types/listing.d.ts +90 -0
- package/dist/types/local/qr.d.ts +1 -1
- package/dist/types/local/wordlist.d.ts +2 -3
- package/dist/types/resources/account.d.ts +19 -19
- package/dist/types/resources/admin/authorizedApplications.d.ts +133 -0
- package/dist/types/resources/admin/chests.d.ts +51 -0
- package/dist/types/resources/admin/eventAlerts.d.ts +60 -0
- package/dist/types/resources/admin/identities.d.ts +99 -0
- package/dist/types/resources/admin/index.d.ts +77 -0
- package/dist/types/resources/admin/jobs.d.ts +97 -0
- package/dist/types/resources/admin/myOauthApplications.d.ts +282 -0
- package/dist/types/resources/admin/notepads.d.ts +49 -0
- package/dist/types/resources/admin/oauthApplications.d.ts +309 -0
- package/dist/types/resources/admin/quotas.d.ts +114 -0
- package/dist/types/resources/admin/shortLinks.d.ts +201 -0
- package/dist/types/resources/admin/types.d.ts +222 -0
- package/dist/types/resources/admin/vocalSeparations.d.ts +98 -0
- package/dist/types/resources/admin.d.ts +17 -13
- package/dist/types/resources/auth/index.d.ts +1 -1
- package/dist/types/resources/auth/passkeys.d.ts +127 -163
- package/dist/types/resources/auth/sessions.d.ts +116 -161
- package/dist/types/resources/chests.d.ts +27 -31
- package/dist/types/resources/content/analysis.d.ts +62 -0
- package/dist/types/resources/content/blogs.d.ts +471 -0
- package/dist/types/resources/content/feedbacks.d.ts +263 -0
- package/dist/types/resources/content/index.d.ts +52 -0
- package/dist/types/resources/content/intel/articles.d.ts +230 -0
- package/dist/types/resources/content/intel/config.d.ts +135 -0
- package/dist/types/resources/content/intel/index.d.ts +53 -0
- package/dist/types/resources/content/intel/items.d.ts +91 -0
- package/dist/types/resources/content/intel/reports.d.ts +108 -0
- package/dist/types/resources/content/intel/scripts.d.ts +152 -0
- package/dist/types/resources/content/intel/sources.d.ts +236 -0
- package/dist/types/resources/content/intel/stats.d.ts +105 -0
- package/dist/types/resources/content/intel/types.d.ts +86 -0
- package/dist/types/resources/content/jokes.d.ts +93 -0
- package/dist/types/resources/content/notifications.d.ts +147 -0
- package/dist/types/resources/content/serviceUsages.d.ts +73 -0
- package/dist/types/resources/content/servicesStatus.d.ts +194 -0
- package/dist/types/resources/content/siteConfig.d.ts +43 -0
- package/dist/types/resources/content/spaceInvaders.d.ts +154 -0
- package/dist/types/resources/content.d.ts +41 -236
- package/dist/types/resources/dynamicQrs.d.ts +29 -45
- package/dist/types/resources/forms.d.ts +37 -58
- package/dist/types/resources/jobs.d.ts +35 -44
- package/dist/types/resources/library/annotations.d.ts +162 -0
- package/dist/types/resources/library/books.d.ts +534 -0
- package/dist/types/resources/library/chat.d.ts +259 -0
- package/dist/types/resources/library/index.d.ts +39 -0
- package/dist/types/resources/library/shelves.d.ts +237 -0
- package/dist/types/resources/library/types.d.ts +120 -0
- package/dist/types/resources/library.d.ts +20 -22
- package/dist/types/resources/media.d.ts +48 -61
- package/dist/types/resources/movies/addons.d.ts +388 -0
- package/dist/types/resources/movies/collections.d.ts +352 -0
- package/dist/types/resources/movies/index.d.ts +29 -0
- package/dist/types/resources/movies/types.d.ts +50 -0
- package/dist/types/resources/movies/watchProgress.d.ts +277 -0
- package/dist/types/resources/movies.d.ts +27 -53
- package/dist/types/resources/music/artists.d.ts +182 -246
- package/dist/types/resources/music/imports.d.ts +190 -218
- package/dist/types/resources/music/index.d.ts +8 -7
- package/dist/types/resources/music/playlists.d.ts +85 -117
- package/dist/types/resources/music/social.d.ts +153 -228
- package/dist/types/resources/music/songs.d.ts +165 -227
- package/dist/types/resources/realtime.d.ts +75 -88
- package/dist/types/resources/shortLinks.d.ts +38 -47
- package/dist/types/resources/social/groupChats.d.ts +458 -0
- package/dist/types/resources/social/index.d.ts +19 -0
- package/dist/types/resources/social/messages.d.ts +424 -0
- package/dist/types/resources/social/relationships.d.ts +322 -0
- package/dist/types/resources/social/types.d.ts +37 -0
- package/dist/types/resources/social.d.ts +21 -3
- package/dist/types/resources/storage/upload.d.ts +42 -56
- package/dist/types/resources/storage.d.ts +94 -109
- package/dist/types/resources/tickets.d.ts +19 -10
- package/dist/types/resources/tools/backgroundRemoval.d.ts +11 -13
- package/dist/types/resources/tools/captions.d.ts +107 -135
- package/dist/types/resources/tools/upscale.d.ts +12 -16
- package/dist/types/types.d.ts +29 -38
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* handing back a busy row would just guarantee the caller's next call is the
|
|
17
17
|
* 409. Use {@link CaptionsNamespace.get} to poll a job somebody else started.
|
|
18
18
|
*
|
|
19
|
-
* Limits, all enforced
|
|
19
|
+
* Limits, all enforced server-side:
|
|
20
20
|
*
|
|
21
21
|
* | | |
|
|
22
22
|
* |---|---|
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
* window that would cross the ceiling rather than truncating it.
|
|
40
40
|
*
|
|
41
41
|
* **The 250 MiB ceiling is not reachable through {@link CaptionsNamespace.create}.**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
42
|
+
* Any single request body over roughly 100 MB is answered 413 before the API
|
|
43
|
+
* sees it, so the API also exposes a three-call chunked upload -
|
|
44
44
|
* `POST /caption_jobs/uploads` opens a session and returns a signed
|
|
45
45
|
* `upload_token` plus a `part_size` (32 MiB), `POST /caption_jobs/uploads/parts?offset=`
|
|
46
46
|
* streams each raw part under an `X-Upload-Token` header, and
|
|
@@ -53,12 +53,9 @@
|
|
|
53
53
|
* be small, and for the three methods under `upload` only to drive the parts
|
|
54
54
|
* yourself.
|
|
55
55
|
*
|
|
56
|
-
* One caveat
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* `fonts`). A session or a first-party bearer token reaches them; a token
|
|
60
|
-
* minted through the OIDC provider does not, and for one of those only
|
|
61
|
-
* `create` is open.
|
|
56
|
+
* One caveat: an OAuth access token gets `403 insufficient_scope` on the three
|
|
57
|
+
* chunked routes and on `fonts`; of the upload paths, only `create` is open to
|
|
58
|
+
* one. A session token reaches them all.
|
|
62
59
|
*/
|
|
63
60
|
import { Resource } from "../../http";
|
|
64
61
|
import type { FileInput, Id, OperationOptions, Progress, RequestOptions } from "../../types";
|
|
@@ -69,7 +66,7 @@ import { type SecondsQuota, type ToolCaptcha, type ToolRecord, type ToolRunOptio
|
|
|
69
66
|
*/
|
|
70
67
|
export type CaptionStatus = "uploaded" | "transcribing" | "transcribed" | "rendering" | "complete" | "failed";
|
|
71
68
|
/**
|
|
72
|
-
* The two statuses with
|
|
69
|
+
* The two statuses with work in flight.
|
|
73
70
|
*
|
|
74
71
|
* A job in one of these refuses new work with a 409. Note this is NOT the
|
|
75
72
|
* complement of "terminal": `"uploaded"` and `"transcribed"` are idle but not
|
|
@@ -82,12 +79,12 @@ export declare function isCaptionBusy(status: string): boolean;
|
|
|
82
79
|
* One timed word of the transcript.
|
|
83
80
|
*
|
|
84
81
|
* `text`, `t0`, `t1` - NOT `word`, `start`, `end`. These are the keys the
|
|
85
|
-
* render endpoint permits and the keys
|
|
82
|
+
* render endpoint permits and the keys a transcription writes onto the row, so
|
|
86
83
|
* a word object built any other way is silently dropped server-side and the
|
|
87
84
|
* render fails with "No words to render".
|
|
88
85
|
*
|
|
89
86
|
* Timings are seconds from the START OF THE VIDEO, not from the start of the
|
|
90
|
-
* transcribed window: the
|
|
87
|
+
* transcribed window: the server shifts them onto the video clock before
|
|
91
88
|
* saving, so an edited list can be sent straight back.
|
|
92
89
|
*/
|
|
93
90
|
export interface CaptionWord {
|
|
@@ -101,8 +98,8 @@ export interface CaptionWord {
|
|
|
101
98
|
/**
|
|
102
99
|
* An RGB triple, each channel clamped to `[0, 255]` server-side.
|
|
103
100
|
*
|
|
104
|
-
* The
|
|
105
|
-
*
|
|
101
|
+
* The server reads the key only when the array has EXACTLY three entries; two
|
|
102
|
+
* or four is dropped in silence, which costs a whole render to discover.
|
|
106
103
|
*/
|
|
107
104
|
export type CaptionRgb = readonly [number, number, number] | readonly number[];
|
|
108
105
|
/**
|
|
@@ -110,19 +107,19 @@ export type CaptionRgb = readonly [number, number, number] | readonly number[];
|
|
|
110
107
|
*
|
|
111
108
|
* Open bag, because the renderer gains options without an SDK release and
|
|
112
109
|
* unknown keys are dropped server-side rather than rejected. The named keys are
|
|
113
|
-
* the ones the
|
|
114
|
-
*
|
|
115
|
-
*
|
|
110
|
+
* the ones the server permits today; anything else - a font name, a hex
|
|
111
|
+
* colour - is accepted by the request and then thrown away, which is worth
|
|
112
|
+
* knowing before spending a render on it.
|
|
116
113
|
*
|
|
117
114
|
* Every numeric key is CLAMPED, not validated: a value outside the range comes
|
|
118
115
|
* back as the nearest end of it rather than as a 400.
|
|
119
116
|
*/
|
|
120
117
|
export interface CaptionStyle {
|
|
121
118
|
/**
|
|
122
|
-
* A font KEY from {@link CaptionsNamespace.fonts}, never a path: the
|
|
123
|
-
* resolves the key against
|
|
124
|
-
*
|
|
125
|
-
*
|
|
119
|
+
* A font KEY from {@link CaptionsNamespace.fonts}, never a path: the
|
|
120
|
+
* renderer resolves the key against its installed faces, so a caller cannot
|
|
121
|
+
* point it at a file. Must match `/\A[a-z0-9_-]{1,40}\z/`; anything else is
|
|
122
|
+
* dropped and the renderer uses its own default.
|
|
126
123
|
*/
|
|
127
124
|
readonly font?: string;
|
|
128
125
|
/** Font size as a fraction of the video height. Clamped to `[0.03, 0.09]`. */
|
|
@@ -130,8 +127,8 @@ export interface CaptionStyle {
|
|
|
130
127
|
/**
|
|
131
128
|
* Outline thickness as a fraction of the font size. Clamped to `[0, 0.3]`,
|
|
132
129
|
* and `0` is a legitimate choice meaning no outline at all - which is why
|
|
133
|
-
* the
|
|
134
|
-
*
|
|
130
|
+
* the server reads this key whenever it is PRESENT rather than when it is
|
|
131
|
+
* truthy, unlike every other numeric key here.
|
|
135
132
|
*/
|
|
136
133
|
readonly stroke_factor?: number;
|
|
137
134
|
/** Vertical placement, `0` top to `1` bottom. Clamped to `[0.3, 0.9]`. */
|
|
@@ -160,25 +157,22 @@ export interface CaptionStyle {
|
|
|
160
157
|
* A caption job.
|
|
161
158
|
*
|
|
162
159
|
* Every route that answers with one - create, the chunked upload's finish
|
|
163
|
-
* call, show, transcribe and render -
|
|
164
|
-
*
|
|
160
|
+
* call, show, transcribe and render - answers the same shape, so every key
|
|
161
|
+
* below is present on every response.
|
|
165
162
|
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* numbers. On a row whose upload has only just been probed they are the probed
|
|
169
|
-
* values; the sidecar's precise metadata overwrites them a moment later.
|
|
163
|
+
* `width`, `height`, `fps`, `duration` and `transcribed_seconds` are always
|
|
164
|
+
* real numbers: `0` until the probe fills them in.
|
|
170
165
|
*/
|
|
171
166
|
export interface CaptionJob extends ToolRecord {
|
|
172
167
|
readonly status: CaptionStatus;
|
|
173
|
-
/** Original upload name. The
|
|
174
|
-
*
|
|
168
|
+
/** Original upload name. The server substitutes `"video.mp4"` for a blank
|
|
169
|
+
* one, so this is never empty in practice. */
|
|
175
170
|
readonly filename: string;
|
|
176
|
-
/** Pixels. `
|
|
171
|
+
/** Pixels. `0` means "not probed yet", not unknown. */
|
|
177
172
|
readonly width: number;
|
|
178
173
|
readonly height: number;
|
|
179
|
-
/** `NOT NULL DEFAULT 0.0`. */
|
|
180
174
|
readonly fps: number;
|
|
181
|
-
/** Seconds of video, probed at upload.
|
|
175
|
+
/** Seconds of video, probed at upload. */
|
|
182
176
|
readonly duration: number;
|
|
183
177
|
/** Language of the last transcribe call, `"auto"` included. `null` before the first. */
|
|
184
178
|
readonly language: string | null;
|
|
@@ -187,27 +181,25 @@ export interface CaptionJob extends ToolRecord {
|
|
|
187
181
|
readonly window_end: number | null;
|
|
188
182
|
/**
|
|
189
183
|
* Seconds charged against the quota so far, accumulated across every window
|
|
190
|
-
* transcribed on this job.
|
|
184
|
+
* transcribed on this job.
|
|
191
185
|
*/
|
|
192
186
|
readonly transcribed_seconds: number;
|
|
193
187
|
/**
|
|
194
188
|
* Timed words, from `"transcribed"` onwards.
|
|
195
189
|
*
|
|
196
|
-
* `null` and not `[]` when there are none
|
|
197
|
-
*
|
|
198
|
-
* `nil` in Ruby. So an empty list arrives as `null`, and the key is present
|
|
199
|
-
* either way.
|
|
190
|
+
* `null` and not `[]` when there are none, and the key is present either
|
|
191
|
+
* way.
|
|
200
192
|
*/
|
|
201
193
|
readonly words: CaptionWord[] | null;
|
|
202
|
-
/** What the renderer is doing right now, read live
|
|
203
|
-
*
|
|
194
|
+
/** What the renderer is doing right now, read live. `null` unless the
|
|
195
|
+
* status is `"rendering"`. */
|
|
204
196
|
readonly render_stage: string | null;
|
|
205
197
|
/** Signed URL of the finished video once complete and attached, `null` otherwise. */
|
|
206
198
|
readonly output_url: string | null;
|
|
207
199
|
}
|
|
208
200
|
/** Arguments for uploading a video. */
|
|
209
201
|
export interface CreateCaptionJobInput extends ToolCaptcha {
|
|
210
|
-
/** The video. Sent as the `video` form field.
|
|
202
|
+
/** The video. Sent as the `video` form field. Caps: 250 MiB, 20 minutes. */
|
|
211
203
|
readonly video: FileInput;
|
|
212
204
|
}
|
|
213
205
|
/** Arguments for transcribing a window. */
|
|
@@ -223,7 +215,7 @@ export interface TranscribeCaptionInput {
|
|
|
223
215
|
export interface RenderCaptionInput {
|
|
224
216
|
/**
|
|
225
217
|
* Words to burn in. Omit to use the words already on the row; pass an edited
|
|
226
|
-
* array to fix what the
|
|
218
|
+
* array to fix what the transcription misheard. Cap: 3000 words, 80
|
|
227
219
|
* characters each.
|
|
228
220
|
*
|
|
229
221
|
* Omitting costs one extra `GET`: the render endpoint has no fallback of its
|
|
@@ -237,59 +229,55 @@ export interface RenderCaptionInput {
|
|
|
237
229
|
* Renders a caption job as a {@link Progress}, render stage included.
|
|
238
230
|
*
|
|
239
231
|
* Same liberty as the vocal separator takes with the queue position: the
|
|
240
|
-
*
|
|
232
|
+
* render stage is folded into `status` - `"rendering (encoding)"` - because
|
|
241
233
|
* `status` is the only part of a {@link Progress} a host renders as text, and a
|
|
242
234
|
* whole-file re-encode is long enough that "rendering" alone tells a person
|
|
243
235
|
* nothing.
|
|
244
236
|
*/
|
|
245
237
|
export declare function captionProgress(record: CaptionJob): Progress;
|
|
246
238
|
/**
|
|
247
|
-
* Largest file the
|
|
239
|
+
* Largest file the server will accept, chunked or not: 250 MiB exactly.
|
|
248
240
|
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
241
|
+
* Not checked client-side on purpose - the server owns the number, and the
|
|
242
|
+
* chunked path finds out in one cheap round trip because
|
|
243
|
+
* {@link CaptionsNamespace.startUpload} is given the size before a single byte
|
|
244
|
+
* moves.
|
|
253
245
|
*/
|
|
254
246
|
export declare const CAPTION_MAX_UPLOAD_BYTES: number;
|
|
255
247
|
/**
|
|
256
248
|
* Where {@link CaptionsNamespace.upload} stops using one `POST` and starts
|
|
257
249
|
* using the three-call path: 64 MiB.
|
|
258
250
|
*
|
|
259
|
-
* This is a CLIENT-SIDE choice, not a protocol constant
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* it a single request is a 413 that says nothing useful.
|
|
251
|
+
* This is a CLIENT-SIDE choice, not a protocol constant. The ~100 MB ceiling
|
|
252
|
+
* is on the whole request, and a `multipart/form-data` envelope rides on top
|
|
253
|
+
* of the file's own bytes, so the switch sits well under the cap rather than
|
|
254
|
+
* at it. Below it a single request is one round trip and one probe; above it
|
|
255
|
+
* a single request is a 413 that says nothing useful.
|
|
265
256
|
*
|
|
266
257
|
* Override it per call with {@link UploadCaptionVideoInput.chunkedThreshold} -
|
|
267
258
|
* for instance `0`, to exercise the chunked path on a small file.
|
|
268
259
|
*/
|
|
269
260
|
export declare const CAPTION_CHUNKED_THRESHOLD: number;
|
|
270
261
|
/**
|
|
271
|
-
* Part size, 32 MiB. The same number as the storage tier's,
|
|
272
|
-
* rather than by sharing
|
|
262
|
+
* Part size, 32 MiB. The same number as the storage tier's, by coincidence
|
|
263
|
+
* rather than by sharing.
|
|
273
264
|
*
|
|
274
265
|
* It is BOTH the size the server reports in the session and the ceiling the
|
|
275
|
-
* server validates each part against
|
|
276
|
-
*
|
|
277
|
-
* {@link resolveCaptionPartSize} for what that means when the two disagree.
|
|
266
|
+
* server validates each part against. See {@link resolveCaptionPartSize} for
|
|
267
|
+
* what that means when the two disagree.
|
|
278
268
|
*/
|
|
279
269
|
export declare const CAPTION_PART_SIZE: number;
|
|
280
270
|
/**
|
|
281
271
|
* Parts in flight at once by default.
|
|
282
272
|
*
|
|
283
|
-
* Three
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
287
|
-
* way to the sidecar, unlike a storage upload.
|
|
273
|
+
* Three. A single sequential stream leaves a home connection idle between
|
|
274
|
+
* round trips; three fills it without holding an unfair share of the API,
|
|
275
|
+
* since these bytes pass THROUGH the API on their way to storage, unlike a
|
|
276
|
+
* storage upload.
|
|
288
277
|
*/
|
|
289
278
|
export declare const CAPTION_UPLOAD_CONCURRENCY = 3;
|
|
290
279
|
/**
|
|
291
|
-
* How long an upload session stays usable: six hours
|
|
292
|
-
* `CaptionJobsController::UPLOAD_TOKEN_TTL`.
|
|
280
|
+
* How long an upload session stays usable: six hours.
|
|
293
281
|
*
|
|
294
282
|
* The window for a resume. Past it the token verifies as expired and every
|
|
295
283
|
* call answers 400 "Invalid or expired upload session", parts already sent
|
|
@@ -322,7 +310,7 @@ export interface StartCaptionUploadInput extends ToolCaptcha {
|
|
|
322
310
|
* Not an estimate and not a ceiling: the number is sealed into the token and
|
|
323
311
|
* every part is checked against it, so a declared size below the real one
|
|
324
312
|
* makes the last part fail with 400 "Part exceeds declared size", and a
|
|
325
|
-
* declared size above it leaves the
|
|
313
|
+
* declared size above it leaves the server waiting for bytes that never
|
|
326
314
|
* come and `finish` probing a truncated file.
|
|
327
315
|
*/
|
|
328
316
|
readonly size: number;
|
|
@@ -364,7 +352,7 @@ export interface CaptionUploadResume {
|
|
|
364
352
|
* Keep the whole session where you can. A bare token has no `part_size`, so
|
|
365
353
|
* the driver slices with {@link CAPTION_PART_SIZE} instead - which is the
|
|
366
354
|
* server's own number today, and therefore the same offsets, but it stops
|
|
367
|
-
* being true the day the
|
|
355
|
+
* being true the day the server changes it.
|
|
368
356
|
*/
|
|
369
357
|
readonly session: CaptionUploadSession | string;
|
|
370
358
|
/**
|
|
@@ -413,18 +401,16 @@ export declare function captionUploadSize(video: FileInput): number | undefined;
|
|
|
413
401
|
* Follows the storage driver's rule - slice with the number the SERVER named,
|
|
414
402
|
* never with the SDK's copy of it - but with a ceiling the storage tier does
|
|
415
403
|
* not need, because the two ends of this protocol read the number from
|
|
416
|
-
* different places
|
|
417
|
-
*
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
404
|
+
* different places: the session reports a `part_size`, while each part is
|
|
405
|
+
* validated against the server's own constant. They are the same today and
|
|
406
|
+
* can only disagree mid-deploy, and the disagreement is one-sided: honouring
|
|
407
|
+
* a larger reported size would make every part a 400 "Invalid part", while
|
|
408
|
+
* capping at the size this SDK knows the validator uses only sends smaller
|
|
409
|
+
* parts, which is always legal. So the reported number wins downwards and
|
|
410
|
+
* loses upwards.
|
|
423
411
|
*
|
|
424
412
|
* A missing, zero or nonsense `part_size` falls back to
|
|
425
|
-
* {@link CAPTION_PART_SIZE}.
|
|
426
|
-
* threshold instead, which is above the validator's ceiling - a fallback that
|
|
427
|
-
* would reject every part if it ever fired.
|
|
413
|
+
* {@link CAPTION_PART_SIZE}.
|
|
428
414
|
*/
|
|
429
415
|
export declare function resolveCaptionPartSize(reported: number | undefined): number;
|
|
430
416
|
/** The `captions` tool, reachable as `oms.tools.captions`. */
|
|
@@ -448,15 +434,15 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
448
434
|
* {@link CaptionStyle.font}.
|
|
449
435
|
*
|
|
450
436
|
* Plain strings, not objects and not display names: they are the keys the
|
|
451
|
-
*
|
|
452
|
-
*
|
|
437
|
+
* renderer resolves against its installed faces, which is the whole reason
|
|
438
|
+
* a caller cannot pass a path.
|
|
453
439
|
*
|
|
454
|
-
* The
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
*
|
|
459
|
-
*
|
|
440
|
+
* The endpoint answers `{ fonts: [...] }`; this unwraps it. It also NEVER
|
|
441
|
+
* fails: a renderer that is down or slow is answered as an empty list with
|
|
442
|
+
* a 200, so `[]` means "could not ask right now" just as much as it means
|
|
443
|
+
* "no fonts", and the two are not distinguishable. Do not treat an empty
|
|
444
|
+
* answer as a reason to refuse a render - omitting `font` lets the renderer
|
|
445
|
+
* use its own default.
|
|
460
446
|
*
|
|
461
447
|
* Cached server-side for ten minutes, so polling it buys nothing.
|
|
462
448
|
*/
|
|
@@ -464,11 +450,6 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
464
450
|
/**
|
|
465
451
|
* `POST /caption_jobs` - step 1. Uploads the video and probes it.
|
|
466
452
|
*
|
|
467
|
-
* The bytes go to the captions sidecar, which keeps the file; Rails stores
|
|
468
|
-
* only the row and, at the end, the rendered output. That is also why a
|
|
469
|
-
* caption job cannot be resumed after the sidecar's volume is wiped: the row
|
|
470
|
-
* survives and the video does not, and step 2 then fails.
|
|
471
|
-
*
|
|
472
453
|
* Answers with the row in `"uploaded"`, carrying the probed `width`,
|
|
473
454
|
* `height`, `fps` and `duration`. Nothing is running yet, so this call does
|
|
474
455
|
* not wait.
|
|
@@ -477,8 +458,8 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
477
458
|
* 250 MiB and leaves an orphan job behind. Pass `retry: {}` to opt back in.
|
|
478
459
|
*
|
|
479
460
|
* @throws {OmsApiError} 413 over 250 MiB, 400 over 20 minutes or when the
|
|
480
|
-
* file cannot be read, 503 when the captions
|
|
481
|
-
* case
|
|
461
|
+
* file cannot be read, 503 when the captions service is unavailable - in
|
|
462
|
+
* which case no job is left behind.
|
|
482
463
|
* @throws {OmsQuotaError} 429 from the expensive-tools throttle. The upload
|
|
483
464
|
* itself spends no daily quota.
|
|
484
465
|
* @throws {OmsAuthError} 401 when anonymous and the captcha is missing or bad.
|
|
@@ -508,8 +489,8 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
508
489
|
* new window's words and ADDS its seconds to `transcribed_seconds`, so
|
|
509
490
|
* re-transcribing costs quota every time and does not give you both windows.
|
|
510
491
|
*
|
|
511
|
-
* `language` defaults to `"auto"` server-side.
|
|
512
|
-
*
|
|
492
|
+
* `language` defaults to `"auto"` server-side. Detection is good enough that
|
|
493
|
+
* a hint is worth passing only when it has already got it wrong.
|
|
513
494
|
*
|
|
514
495
|
* Resolves with a `"failed"` row rather than throwing when the transcription
|
|
515
496
|
* itself failed - including the common case of a window with no speech in
|
|
@@ -526,9 +507,7 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
526
507
|
*/
|
|
527
508
|
transcribe(id: Id, input: TranscribeCaptionInput, options?: ToolRunOptions): Promise<CaptionJob>;
|
|
528
509
|
/**
|
|
529
|
-
* `POST /caption_jobs/:id/render` - step 3.
|
|
530
|
-
* the route is `start_render`, because `render` clashes with Rails' own
|
|
531
|
-
* method and that is the backend's problem, not the SDK's.
|
|
510
|
+
* `POST /caption_jobs/:id/render` - step 3.
|
|
532
511
|
*
|
|
533
512
|
* WAITS, like {@link transcribe}, and for the same reason.
|
|
534
513
|
*
|
|
@@ -554,11 +533,10 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
554
533
|
*/
|
|
555
534
|
render(id: Id, input?: RenderCaptionInput, options?: ToolRunOptions): Promise<CaptionJob>;
|
|
556
535
|
/**
|
|
557
|
-
* `DELETE /caption_jobs/:id` - drops the
|
|
536
|
+
* `DELETE /caption_jobs/:id` - drops the job and its uploaded video.
|
|
558
537
|
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
* sidecar's disk until the 24-hour sweep otherwise.
|
|
538
|
+
* Worth calling on a job you have finished with; otherwise the video is
|
|
539
|
+
* kept until the 24-hour sweep.
|
|
562
540
|
*
|
|
563
541
|
* @throws {OmsApiError} 404 when it is already gone.
|
|
564
542
|
* @throws {OmsAuthError} 401 when the job belongs to someone else.
|
|
@@ -592,8 +570,8 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
592
570
|
* Under {@link CAPTION_CHUNKED_THRESHOLD} it is exactly {@link create}: one
|
|
593
571
|
* `POST`, one probe, one round trip. At or above it, it is
|
|
594
572
|
* {@link createChunked}. The answer is the same `"uploaded"` row either way,
|
|
595
|
-
* because `finish` and `create`
|
|
596
|
-
*
|
|
573
|
+
* because `finish` and `create` answer the same shape - so the caller's
|
|
574
|
+
* step 2 does not need to know which path ran.
|
|
597
575
|
*
|
|
598
576
|
* The size comes from {@link captionUploadSize}, which cannot always find
|
|
599
577
|
* one: a `ReadableStream` and some React Native picks have no length until
|
|
@@ -621,20 +599,19 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
621
599
|
* the assembled file and creates the row, so this resolves with the same
|
|
622
600
|
* `"uploaded"` row {@link create} would have answered.
|
|
623
601
|
*
|
|
624
|
-
* Nothing is cleaned up on failure and nothing needs to be: the
|
|
625
|
-
*
|
|
626
|
-
* abandoned before `finish` leaves
|
|
627
|
-
*
|
|
628
|
-
* session - the backend has `CaptionsClient.abort_upload` but no route onto
|
|
629
|
-
* it - so an abandoned upload is simply abandoned.
|
|
602
|
+
* Nothing is cleaned up on failure and nothing needs to be: the server
|
|
603
|
+
* discards the parts itself when `finish` rejects the file, and a run
|
|
604
|
+
* abandoned before `finish` leaves no job behind. There is no way to abort
|
|
605
|
+
* a session, so an abandoned upload is simply abandoned.
|
|
630
606
|
*
|
|
631
607
|
* **React Native cannot take this path.** The bytes have to be sliced, and a
|
|
632
608
|
* picked `{ uri, name, type }` is a handle into the device that only a native
|
|
633
609
|
* module can open - so this throws for one rather than uploading an empty
|
|
634
610
|
* file with a 200 on it. What works on a phone is {@link create} (the
|
|
635
611
|
* transport hands the descriptor to RN's own `FormData` verbatim and the
|
|
636
|
-
* platform streams it off disk), which caps out at
|
|
637
|
-
* that the only ways through are reading the file into a
|
|
612
|
+
* platform streams it off disk), which caps out at the ~100 MB request
|
|
613
|
+
* limit. Past that the only ways through are reading the file into a
|
|
614
|
+
* `Uint8Array` first -
|
|
638
615
|
* Expo's `new File(uri).bytes()`, which means the whole video in the JS heap,
|
|
639
616
|
* so it is not a plan for 250 MiB - or shrinking the video on the device.
|
|
640
617
|
*
|
|
@@ -665,20 +642,19 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
665
642
|
*
|
|
666
643
|
* Three things happen here and nowhere else in the flow: the captcha is
|
|
667
644
|
* verified, the 250 MiB ceiling is checked against the DECLARED size, and the
|
|
668
|
-
* job id is minted - early,
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
* until {@link finishUpload} returns.
|
|
645
|
+
* job id is minted - early, but the job itself does not exist until the file
|
|
646
|
+
* is whole. So a session is not a job: {@link get} has nothing to find until
|
|
647
|
+
* {@link finishUpload} returns.
|
|
672
648
|
*
|
|
673
|
-
* NOT retried by default. A replay opens a SECOND
|
|
674
|
-
*
|
|
675
|
-
*
|
|
649
|
+
* NOT retried by default. A replay opens a SECOND session under a second job
|
|
650
|
+
* id and hands back a second token, and the first is then orphaned with no
|
|
651
|
+
* way to abort it.
|
|
676
652
|
*
|
|
677
653
|
* Rate limit: 20 a minute, shared with every other expensive tool - the same
|
|
678
654
|
* bucket `POST /caption_jobs` counts against, since this is its twin.
|
|
679
655
|
*
|
|
680
656
|
* @throws {OmsApiError} 413 when `size` is over 250 MiB, 400 when it is not
|
|
681
|
-
* positive, 503 when the captions
|
|
657
|
+
* positive, 503 when the captions service is unavailable.
|
|
682
658
|
* @throws {OmsAuthError} 401 when anonymous and the captcha is missing or bad.
|
|
683
659
|
* @throws {OmsQuotaError} 429 from the expensive-tools throttle. No daily
|
|
684
660
|
* quota is spent by an upload - only a transcribed window is metered.
|
|
@@ -688,10 +664,7 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
688
664
|
* `POST /caption_jobs/uploads/parts?offset=` - one part, as raw bytes.
|
|
689
665
|
*
|
|
690
666
|
* The body is the part itself, `application/octet-stream`, with no envelope:
|
|
691
|
-
* not a form field, not base64, not JSON.
|
|
692
|
-
* - it streams the request body straight through to the sidecar - so a 32 MiB
|
|
693
|
-
* part costs 32 MiB of socket rather than 32 MiB of Ruby heap, and that is
|
|
694
|
-
* why the endpoint takes bytes rather than a multipart part.
|
|
667
|
+
* not a form field, not base64, not JSON.
|
|
695
668
|
*
|
|
696
669
|
* RETRIED BY DEFAULT, which no other writing method in this SDK is. The
|
|
697
670
|
* server writes the part at the offset the query names, so a replay is the
|
|
@@ -707,24 +680,23 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
707
680
|
*
|
|
708
681
|
* @param session The session from {@link startUpload}, or its token.
|
|
709
682
|
* @param offset Byte offset of this part in the whole file, from `0`.
|
|
710
|
-
* @returns The byte count the
|
|
683
|
+
* @returns The byte count the server acknowledged, from `{ received }`.
|
|
711
684
|
* @throws {OmsApiError} 400 for an over-long part, an offset past the
|
|
712
685
|
* declared size, or a token that has expired (six hours); 503 when the
|
|
713
|
-
*
|
|
686
|
+
* captions service is unavailable.
|
|
714
687
|
*/
|
|
715
688
|
uploadPart(session: CaptionUploadSession | string, offset: number, part: Blob | Uint8Array, options?: RequestOptions): Promise<number>;
|
|
716
689
|
/**
|
|
717
690
|
* `POST /caption_jobs/uploads/finish` - assembles, probes and creates the row.
|
|
718
691
|
*
|
|
719
|
-
* This is where a chunked upload becomes a job: the
|
|
720
|
-
*
|
|
721
|
-
*
|
|
722
|
-
*
|
|
692
|
+
* This is where a chunked upload becomes a job: the parts are joined and
|
|
693
|
+
* probed, and only then is a `CaptionJob` created, with the id that was
|
|
694
|
+
* sealed into the token at the start. The answer is the same shape
|
|
695
|
+
* {@link create} returns, in `"uploaded"`.
|
|
723
696
|
*
|
|
724
697
|
* It is also where a bad upload is caught. A file that does not decode, or
|
|
725
|
-
* one over 20 minutes, is a 400 - and the
|
|
726
|
-
*
|
|
727
|
-
* retry: the parts are gone with it.
|
|
698
|
+
* one over 20 minutes, is a 400 - and the server discards the parts before
|
|
699
|
+
* answering, so there is nothing to clean up and nothing to retry.
|
|
728
700
|
*
|
|
729
701
|
* NOT retried by default. The row is created with a fixed id, so a replay
|
|
730
702
|
* that lands after a lost answer fails on the id already existing and reports
|
|
@@ -732,7 +704,7 @@ export declare class CaptionsNamespace extends Resource {
|
|
|
732
704
|
*
|
|
733
705
|
* @throws {OmsApiError} 400 when the assembled file cannot be read or runs
|
|
734
706
|
* past 20 minutes, 400 "Invalid or expired upload session" for a token that
|
|
735
|
-
* is over six hours old, 503 when the
|
|
707
|
+
* is over six hours old, 503 when the captions service is unavailable.
|
|
736
708
|
*/
|
|
737
709
|
finishUpload(session: CaptionUploadSession | string, options?: RequestOptions): Promise<CaptionJob>;
|
|
738
710
|
/**
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Upscaling: enlarges an image without turning it to mush.
|
|
3
3
|
*
|
|
4
|
-
* Same shape as background removal: `POST /upscales` enqueues a
|
|
4
|
+
* Same shape as background removal: `POST /upscales` enqueues a job and
|
|
5
5
|
* answers with a row plus a `job_id` and, when anonymous, a `watch_token`.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Limits: 20 MiB, and the scale must be one of `"2"`, `"3"`, `"4"`.
|
|
8
8
|
*
|
|
9
|
-
* Like background removal, this tool
|
|
10
|
-
*
|
|
9
|
+
* Like background removal, this tool has no daily quota, so there is no
|
|
10
|
+
* `quota()` to call first.
|
|
11
11
|
*/
|
|
12
12
|
import { Resource } from "../../http";
|
|
13
13
|
import type { FileInput, Id, RequestOptions } from "../../types";
|
|
@@ -15,7 +15,7 @@ import { type ToolCaptcha, type ToolJobHandle, type ToolRecord, type ToolRunOpti
|
|
|
15
15
|
/**
|
|
16
16
|
* Enlargement factor, as the string the API expects.
|
|
17
17
|
*
|
|
18
|
-
* A string and not a number because the
|
|
18
|
+
* A string and not a number because the server compares it against an
|
|
19
19
|
* allow-list of strings; `4` and `"4"` are not the same request.
|
|
20
20
|
*/
|
|
21
21
|
export type UpscaleScale = "2" | "3" | "4";
|
|
@@ -23,19 +23,15 @@ export type UpscaleScale = "2" | "3" | "4";
|
|
|
23
23
|
* An upscale run.
|
|
24
24
|
*
|
|
25
25
|
* Both routes that answer with one - `POST /upscales` and `GET /upscales/:id` -
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* record reachable through the API.
|
|
26
|
+
* answer the same shape, so `result_url` is always PRESENT and simply `null`
|
|
27
|
+
* until the run completes.
|
|
29
28
|
*
|
|
30
29
|
* `progress_percent`, inherited from {@link ToolRecord}, is never sent for this
|
|
31
|
-
* tool
|
|
32
|
-
*
|
|
30
|
+
* tool. Progress for an upscale lives on the {@link Job} row that
|
|
31
|
+
* {@link UpscaleCreated.job_id} names.
|
|
33
32
|
*/
|
|
34
33
|
export interface Upscale extends ToolRecord {
|
|
35
|
-
/**
|
|
36
|
-
* One of `"2"`, `"3"`, `"4"` - a string, because the column is a string and
|
|
37
|
-
* the allow-list is `%w[2 3 4]`. Never `null`: `NOT NULL DEFAULT '4'`.
|
|
38
|
-
*/
|
|
34
|
+
/** One of `"2"`, `"3"`, `"4"` - a string. Never `null`; defaults to `"4"`. */
|
|
39
35
|
readonly scale: string;
|
|
40
36
|
/**
|
|
41
37
|
* Signed URL of the enlarged PNG, or `null`. `null` covers three different
|
|
@@ -49,9 +45,9 @@ export interface Upscale extends ToolRecord {
|
|
|
49
45
|
export type UpscaleCreated = Upscale & ToolJobHandle;
|
|
50
46
|
/** Arguments for starting a run. */
|
|
51
47
|
export interface CreateUpscaleInput extends ToolCaptcha {
|
|
52
|
-
/** The image.
|
|
48
|
+
/** The image. Cap: 20 MiB. */
|
|
53
49
|
readonly file: FileInput;
|
|
54
|
-
/** Defaults to `"4"`, which is what the
|
|
50
|
+
/** Defaults to `"4"`, which is what the server picks when none is sent. */
|
|
55
51
|
readonly scale?: UpscaleScale;
|
|
56
52
|
}
|
|
57
53
|
/** The `upscale` tool, reachable as `oms.tools.upscale`. */
|