@rendobar/sdk 2.1.1 → 2.2.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/README.md +77 -3
- package/dist/index.cjs +38 -0
- package/dist/index.d.cts +376 -20
- package/dist/index.d.mts +376 -20
- package/dist/index.mjs +37 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,8 +23,10 @@ const job = await client.jobs.create({
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
// Wait for completion
|
|
26
|
+
import { outputUrl } from "@rendobar/sdk";
|
|
27
|
+
|
|
26
28
|
const result = await client.jobs.wait(job.id);
|
|
27
|
-
console.log(result
|
|
29
|
+
console.log(outputUrl(result)); // primary download/playable URL
|
|
28
30
|
```
|
|
29
31
|
|
|
30
32
|
## Authentication
|
|
@@ -99,6 +101,78 @@ const logs = await client.jobs.logs("job_abc");
|
|
|
99
101
|
const types = await client.jobs.types();
|
|
100
102
|
```
|
|
101
103
|
|
|
104
|
+
### Job output
|
|
105
|
+
|
|
106
|
+
Every job type returns the same output shape. A completed job carries an
|
|
107
|
+
`output` with four fields:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
type Output = {
|
|
111
|
+
data: unknown; // structured result (probe, detections, transcript), or null
|
|
112
|
+
file: OutputFile | null; // the headline file or stream manifest, or null
|
|
113
|
+
files: OutputFile[]; // every produced file (empty for data-only jobs)
|
|
114
|
+
expiresAt: number | null; // Unix ms URL expiry, set when files is non-empty
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
type OutputFile = {
|
|
118
|
+
url: string; // ready-to-fetch, time-limited URL
|
|
119
|
+
path: string; // path within the job output
|
|
120
|
+
type: "video" | "image" | "audio" | "captions" | "playlist" | "data" | "other";
|
|
121
|
+
size: number; // bytes
|
|
122
|
+
meta?: { format?: string; width?: number; height?: number; durationMs?: number };
|
|
123
|
+
};
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`output` exists only on a completed job (`status === "complete"`), so narrow on
|
|
127
|
+
status before reading it.
|
|
128
|
+
|
|
129
|
+
```typescript
|
|
130
|
+
import { outputUrl, jobData } from "@rendobar/sdk";
|
|
131
|
+
|
|
132
|
+
const job = await client.jobs.wait("job_abc");
|
|
133
|
+
|
|
134
|
+
// Headline URL: the single file, or a stream manifest (.m3u8/.mpd). Returns
|
|
135
|
+
// undefined for data-only jobs and pure file sets (no single headline).
|
|
136
|
+
const url = outputUrl(job);
|
|
137
|
+
|
|
138
|
+
// Or read it yourself after a status check
|
|
139
|
+
if (job.status === "complete") {
|
|
140
|
+
console.log(job.output.file?.url);
|
|
141
|
+
|
|
142
|
+
// Iterate every produced file (frame extraction, HLS segments, sprite sets)
|
|
143
|
+
for (const f of job.output.files) {
|
|
144
|
+
console.log(f.type, f.path, f.size, f.url);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// A failed job carries a structured error instead
|
|
149
|
+
if (job.status === "failed") {
|
|
150
|
+
console.log(job.error.code, job.error.message, job.error.detail);
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
For data jobs (`extract.metadata`, `caption.extract`, detections), the answer is
|
|
155
|
+
in `output.data`. It is `unknown` at the contract level because its shape is
|
|
156
|
+
job-type-specific. Use `jobData<T>(job)` to read it with your expected type, or
|
|
157
|
+
read `job.output.data` and narrow it yourself:
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { jobData } from "@rendobar/sdk";
|
|
161
|
+
|
|
162
|
+
type Metadata = { format: string; durationMs: number; width: number; height: number };
|
|
163
|
+
|
|
164
|
+
const job = await client.jobs.wait("job_abc");
|
|
165
|
+
const meta = jobData<Metadata>(job); // Metadata | null
|
|
166
|
+
|
|
167
|
+
if (meta) {
|
|
168
|
+
console.log(meta.format, meta.durationMs);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`T` is your claim about the shape for the job type you submitted. If the input is
|
|
173
|
+
untrusted, validate `output.data` yourself (e.g. with Zod) instead of asserting a
|
|
174
|
+
type.
|
|
175
|
+
|
|
102
176
|
## Raw FFmpeg
|
|
103
177
|
|
|
104
178
|
Run arbitrary FFmpeg commands in a sandboxed container. Commands are parsed, sanitized (protocol whitelist/blacklist flags blocked), and executed with a clean process environment.
|
|
@@ -120,7 +194,7 @@ const job = await client.jobs.create({
|
|
|
120
194
|
});
|
|
121
195
|
|
|
122
196
|
const done = await client.jobs.wait(job.id);
|
|
123
|
-
console.log(done
|
|
197
|
+
console.log(outputUrl(done));
|
|
124
198
|
```
|
|
125
199
|
|
|
126
200
|
Prefer named inputs? Pass them in the top-level `inputs` map and reference the keys in the command:
|
|
@@ -258,7 +332,7 @@ All response types are exported:
|
|
|
258
332
|
|
|
259
333
|
```typescript
|
|
260
334
|
import type {
|
|
261
|
-
Job, JobStep, JobType, JobCreatedResponse,
|
|
335
|
+
Job, JobStep, Output, OutputFile, FileType, JobError, Cost, JobType, JobCreatedResponse,
|
|
262
336
|
BillingState, Transaction, UsageSummary,
|
|
263
337
|
WebhookEndpoint, WebhookDelivery,
|
|
264
338
|
Organization, ApiKey, PaginationMeta,
|
package/dist/index.cjs
CHANGED
|
@@ -646,6 +646,44 @@ function createClient(config = {}) {
|
|
|
646
646
|
};
|
|
647
647
|
}
|
|
648
648
|
//#endregion
|
|
649
|
+
//#region src/types.ts
|
|
650
|
+
/**
|
|
651
|
+
* Primary playable/download URL for a completed job, or `undefined`.
|
|
652
|
+
*
|
|
653
|
+
* Returns `output.file.url` — the single download for a file job or the playlist
|
|
654
|
+
* URL for a stream. A pure set (multiple files, no headline) or a data-only job
|
|
655
|
+
* has no single primary URL: inspect `job.output.files` / `job.output.data`.
|
|
656
|
+
*/
|
|
657
|
+
function outputUrl(job) {
|
|
658
|
+
if (job.status !== "complete") return void 0;
|
|
659
|
+
return job.output.file?.url;
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Typed accessor for a completed job's structured `data`, or `null`.
|
|
663
|
+
*
|
|
664
|
+
* `output.data` is job-type-specific (probe result, detections, transcript) and
|
|
665
|
+
* is `unknown` at the contract level — its shape is documented per job type, not
|
|
666
|
+
* by the API schema. This helper applies the caller-supplied type `T` so you can
|
|
667
|
+
* read `data` without sprinkling assertions at each call site. `T` is your claim
|
|
668
|
+
* about the shape for the job type you submitted; validate it yourself (e.g. with
|
|
669
|
+
* Zod) if the input is untrusted.
|
|
670
|
+
*
|
|
671
|
+
* Returns `null` for non-complete jobs and for jobs with no structured data
|
|
672
|
+
* (pure file transforms).
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* type Metadata = { format: string; durationMs: number };
|
|
676
|
+
* const meta = jobData<Metadata>(await client.jobs.wait(id));
|
|
677
|
+
* if (meta) console.log(meta.durationMs);
|
|
678
|
+
*/
|
|
679
|
+
function jobData(job) {
|
|
680
|
+
if (job.status !== "complete") return null;
|
|
681
|
+
if (job.output.data == null) return null;
|
|
682
|
+
return job.output.data;
|
|
683
|
+
}
|
|
684
|
+
//#endregion
|
|
649
685
|
exports.ApiError = ApiError;
|
|
650
686
|
exports.createClient = createClient;
|
|
651
687
|
exports.isApiError = isApiError;
|
|
688
|
+
exports.jobData = jobData;
|
|
689
|
+
exports.outputUrl = outputUrl;
|
package/dist/index.d.cts
CHANGED
|
@@ -2109,29 +2109,156 @@ declare const jobStepSchema: ZodObject<{
|
|
|
2109
2109
|
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2110
2110
|
error: ZodOptional<ZodString>;
|
|
2111
2111
|
}, $strip>;
|
|
2112
|
-
|
|
2112
|
+
/**
|
|
2113
|
+
* File type, an OPEN enum (tolerant-reader contract). Derived from the file
|
|
2114
|
+
* extension. Clients MUST tolerate unknown future values and fall back to
|
|
2115
|
+
* treating the file as opaque ("other"). Adding a value here is non-breaking.
|
|
2116
|
+
*/
|
|
2117
|
+
declare const fileTypeSchema: ZodEnum<{
|
|
2118
|
+
video: "video";
|
|
2119
|
+
image: "image";
|
|
2120
|
+
audio: "audio";
|
|
2121
|
+
captions: "captions";
|
|
2122
|
+
playlist: "playlist";
|
|
2123
|
+
data: "data";
|
|
2124
|
+
other: "other";
|
|
2125
|
+
}>;
|
|
2126
|
+
/**
|
|
2127
|
+
* A single produced file. `url` is a ready-to-fetch, time-limited URL (signed
|
|
2128
|
+
* download URL for single-file jobs, token-in-path serving URL for served
|
|
2129
|
+
* multi-file jobs). `path` is the file's path within the job output (basename
|
|
2130
|
+
* for single-file jobs, prefix-relative path for served jobs).
|
|
2131
|
+
*/
|
|
2132
|
+
declare const fileSchema: ZodObject<{
|
|
2133
|
+
url: ZodString;
|
|
2134
|
+
path: ZodString;
|
|
2135
|
+
type: ZodEnum<{
|
|
2136
|
+
video: "video";
|
|
2137
|
+
image: "image";
|
|
2138
|
+
audio: "audio";
|
|
2139
|
+
captions: "captions";
|
|
2140
|
+
playlist: "playlist";
|
|
2141
|
+
data: "data";
|
|
2142
|
+
other: "other";
|
|
2143
|
+
}>;
|
|
2144
|
+
size: ZodNumber;
|
|
2145
|
+
meta: ZodOptional<ZodObject<{
|
|
2146
|
+
format: ZodOptional<ZodString>;
|
|
2147
|
+
width: ZodOptional<ZodNumber>;
|
|
2148
|
+
height: ZodOptional<ZodNumber>;
|
|
2149
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2150
|
+
}, $strip>>;
|
|
2151
|
+
}, $strip>;
|
|
2152
|
+
declare const jobOutputSchema: ZodObject<{
|
|
2153
|
+
data: ZodUnknown;
|
|
2154
|
+
file: ZodNullable<ZodObject<{
|
|
2155
|
+
url: ZodString;
|
|
2156
|
+
path: ZodString;
|
|
2157
|
+
type: ZodEnum<{
|
|
2158
|
+
video: "video";
|
|
2159
|
+
image: "image";
|
|
2160
|
+
audio: "audio";
|
|
2161
|
+
captions: "captions";
|
|
2162
|
+
playlist: "playlist";
|
|
2163
|
+
data: "data";
|
|
2164
|
+
other: "other";
|
|
2165
|
+
}>;
|
|
2166
|
+
size: ZodNumber;
|
|
2167
|
+
meta: ZodOptional<ZodObject<{
|
|
2168
|
+
format: ZodOptional<ZodString>;
|
|
2169
|
+
width: ZodOptional<ZodNumber>;
|
|
2170
|
+
height: ZodOptional<ZodNumber>;
|
|
2171
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2172
|
+
}, $strip>>;
|
|
2173
|
+
}, $strip>>;
|
|
2174
|
+
files: ZodArray<ZodObject<{
|
|
2175
|
+
url: ZodString;
|
|
2176
|
+
path: ZodString;
|
|
2177
|
+
type: ZodEnum<{
|
|
2178
|
+
video: "video";
|
|
2179
|
+
image: "image";
|
|
2180
|
+
audio: "audio";
|
|
2181
|
+
captions: "captions";
|
|
2182
|
+
playlist: "playlist";
|
|
2183
|
+
data: "data";
|
|
2184
|
+
other: "other";
|
|
2185
|
+
}>;
|
|
2186
|
+
size: ZodNumber;
|
|
2187
|
+
meta: ZodOptional<ZodObject<{
|
|
2188
|
+
format: ZodOptional<ZodString>;
|
|
2189
|
+
width: ZodOptional<ZodNumber>;
|
|
2190
|
+
height: ZodOptional<ZodNumber>;
|
|
2191
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2192
|
+
}, $strip>>;
|
|
2193
|
+
}, $strip>>;
|
|
2194
|
+
expiresAt: ZodNullable<ZodNumber>;
|
|
2195
|
+
}, $strip>;
|
|
2196
|
+
declare const jobErrorSchema: ZodObject<{
|
|
2197
|
+
code: ZodString;
|
|
2198
|
+
message: ZodString;
|
|
2199
|
+
detail: ZodNullable<ZodString>;
|
|
2200
|
+
retryable: ZodBoolean;
|
|
2201
|
+
}, $strip>;
|
|
2202
|
+
declare const jobCostSchema: ZodObject<{
|
|
2203
|
+
amount: ZodNumber;
|
|
2204
|
+
currency: ZodLiteral<"USD">;
|
|
2205
|
+
formatted: ZodString;
|
|
2206
|
+
}, $strip>;
|
|
2207
|
+
declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
2113
2208
|
id: ZodString;
|
|
2114
2209
|
orgId: ZodString;
|
|
2115
2210
|
type: ZodString;
|
|
2116
|
-
status: ZodString;
|
|
2117
2211
|
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2118
2212
|
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2119
|
-
outputRef: ZodNullable<ZodString>;
|
|
2120
|
-
outputUrl: ZodNullable<ZodString>;
|
|
2121
|
-
posterUrl: ZodNullable<ZodString>;
|
|
2122
|
-
outputMeta: ZodNullable<ZodRecord<ZodString, ZodUnknown>>;
|
|
2123
|
-
errorCode: ZodNullable<ZodString>;
|
|
2124
|
-
errorMessage: ZodNullable<ZodString>;
|
|
2125
|
-
price: ZodNullable<ZodNumber>;
|
|
2126
|
-
priceFormatted: ZodNullable<ZodString>;
|
|
2127
2213
|
cost: ZodNullable<ZodObject<{
|
|
2128
|
-
|
|
2129
|
-
currency:
|
|
2214
|
+
amount: ZodNumber;
|
|
2215
|
+
currency: ZodLiteral<"USD">;
|
|
2216
|
+
formatted: ZodString;
|
|
2130
2217
|
}, $strip>>;
|
|
2218
|
+
outputCategory: ZodEnum<{
|
|
2219
|
+
video: "video";
|
|
2220
|
+
image: "image";
|
|
2221
|
+
audio: "audio";
|
|
2222
|
+
captions: "captions";
|
|
2223
|
+
json: "json";
|
|
2224
|
+
raw: "raw";
|
|
2225
|
+
}>;
|
|
2226
|
+
steps: ZodArray<ZodObject<{
|
|
2227
|
+
id: ZodString;
|
|
2228
|
+
name: ZodString;
|
|
2229
|
+
status: ZodString;
|
|
2230
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2231
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2232
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2233
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2234
|
+
error: ZodOptional<ZodString>;
|
|
2235
|
+
}, $strip>>;
|
|
2236
|
+
logsAvailable: ZodBoolean;
|
|
2131
2237
|
createdAt: ZodNumber;
|
|
2132
2238
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2133
2239
|
startedAt: ZodNullable<ZodNumber>;
|
|
2134
2240
|
completedAt: ZodNullable<ZodNumber>;
|
|
2241
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2242
|
+
status: ZodLiteral<"waiting">;
|
|
2243
|
+
}, $strip>, ZodObject<{
|
|
2244
|
+
id: ZodString;
|
|
2245
|
+
orgId: ZodString;
|
|
2246
|
+
type: ZodString;
|
|
2247
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2248
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2249
|
+
cost: ZodNullable<ZodObject<{
|
|
2250
|
+
amount: ZodNumber;
|
|
2251
|
+
currency: ZodLiteral<"USD">;
|
|
2252
|
+
formatted: ZodString;
|
|
2253
|
+
}, $strip>>;
|
|
2254
|
+
outputCategory: ZodEnum<{
|
|
2255
|
+
video: "video";
|
|
2256
|
+
image: "image";
|
|
2257
|
+
audio: "audio";
|
|
2258
|
+
captions: "captions";
|
|
2259
|
+
json: "json";
|
|
2260
|
+
raw: "raw";
|
|
2261
|
+
}>;
|
|
2135
2262
|
steps: ZodArray<ZodObject<{
|
|
2136
2263
|
id: ZodString;
|
|
2137
2264
|
name: ZodString;
|
|
@@ -2142,13 +2269,212 @@ declare const jobResponseSchema: ZodObject<{
|
|
|
2142
2269
|
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2143
2270
|
error: ZodOptional<ZodString>;
|
|
2144
2271
|
}, $strip>>;
|
|
2145
|
-
outputCategory: ZodString;
|
|
2146
|
-
mediaType: ZodNullable<ZodString>;
|
|
2147
2272
|
logsAvailable: ZodBoolean;
|
|
2148
|
-
|
|
2149
|
-
|
|
2273
|
+
createdAt: ZodNumber;
|
|
2274
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2275
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2276
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2150
2277
|
settledAt: ZodNullable<ZodNumber>;
|
|
2151
|
-
|
|
2278
|
+
status: ZodLiteral<"dispatched">;
|
|
2279
|
+
progress: ZodOptional<ZodNumber>;
|
|
2280
|
+
eta: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2281
|
+
}, $strip>, ZodObject<{
|
|
2282
|
+
id: ZodString;
|
|
2283
|
+
orgId: ZodString;
|
|
2284
|
+
type: ZodString;
|
|
2285
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2286
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2287
|
+
cost: ZodNullable<ZodObject<{
|
|
2288
|
+
amount: ZodNumber;
|
|
2289
|
+
currency: ZodLiteral<"USD">;
|
|
2290
|
+
formatted: ZodString;
|
|
2291
|
+
}, $strip>>;
|
|
2292
|
+
outputCategory: ZodEnum<{
|
|
2293
|
+
video: "video";
|
|
2294
|
+
image: "image";
|
|
2295
|
+
audio: "audio";
|
|
2296
|
+
captions: "captions";
|
|
2297
|
+
json: "json";
|
|
2298
|
+
raw: "raw";
|
|
2299
|
+
}>;
|
|
2300
|
+
steps: ZodArray<ZodObject<{
|
|
2301
|
+
id: ZodString;
|
|
2302
|
+
name: ZodString;
|
|
2303
|
+
status: ZodString;
|
|
2304
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2305
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2306
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2307
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2308
|
+
error: ZodOptional<ZodString>;
|
|
2309
|
+
}, $strip>>;
|
|
2310
|
+
logsAvailable: ZodBoolean;
|
|
2311
|
+
createdAt: ZodNumber;
|
|
2312
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2313
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2314
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2315
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2316
|
+
status: ZodLiteral<"running">;
|
|
2317
|
+
progress: ZodNumber;
|
|
2318
|
+
eta: ZodNullable<ZodNumber>;
|
|
2319
|
+
}, $strip>, ZodObject<{
|
|
2320
|
+
id: ZodString;
|
|
2321
|
+
orgId: ZodString;
|
|
2322
|
+
type: ZodString;
|
|
2323
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2324
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2325
|
+
cost: ZodNullable<ZodObject<{
|
|
2326
|
+
amount: ZodNumber;
|
|
2327
|
+
currency: ZodLiteral<"USD">;
|
|
2328
|
+
formatted: ZodString;
|
|
2329
|
+
}, $strip>>;
|
|
2330
|
+
outputCategory: ZodEnum<{
|
|
2331
|
+
video: "video";
|
|
2332
|
+
image: "image";
|
|
2333
|
+
audio: "audio";
|
|
2334
|
+
captions: "captions";
|
|
2335
|
+
json: "json";
|
|
2336
|
+
raw: "raw";
|
|
2337
|
+
}>;
|
|
2338
|
+
steps: ZodArray<ZodObject<{
|
|
2339
|
+
id: ZodString;
|
|
2340
|
+
name: ZodString;
|
|
2341
|
+
status: ZodString;
|
|
2342
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2343
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2344
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2345
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2346
|
+
error: ZodOptional<ZodString>;
|
|
2347
|
+
}, $strip>>;
|
|
2348
|
+
logsAvailable: ZodBoolean;
|
|
2349
|
+
createdAt: ZodNumber;
|
|
2350
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2351
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2352
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2353
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2354
|
+
status: ZodLiteral<"complete">;
|
|
2355
|
+
output: ZodObject<{
|
|
2356
|
+
data: ZodUnknown;
|
|
2357
|
+
file: ZodNullable<ZodObject<{
|
|
2358
|
+
url: ZodString;
|
|
2359
|
+
path: ZodString;
|
|
2360
|
+
type: ZodEnum<{
|
|
2361
|
+
video: "video";
|
|
2362
|
+
image: "image";
|
|
2363
|
+
audio: "audio";
|
|
2364
|
+
captions: "captions";
|
|
2365
|
+
playlist: "playlist";
|
|
2366
|
+
data: "data";
|
|
2367
|
+
other: "other";
|
|
2368
|
+
}>;
|
|
2369
|
+
size: ZodNumber;
|
|
2370
|
+
meta: ZodOptional<ZodObject<{
|
|
2371
|
+
format: ZodOptional<ZodString>;
|
|
2372
|
+
width: ZodOptional<ZodNumber>;
|
|
2373
|
+
height: ZodOptional<ZodNumber>;
|
|
2374
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2375
|
+
}, $strip>>;
|
|
2376
|
+
}, $strip>>;
|
|
2377
|
+
files: ZodArray<ZodObject<{
|
|
2378
|
+
url: ZodString;
|
|
2379
|
+
path: ZodString;
|
|
2380
|
+
type: ZodEnum<{
|
|
2381
|
+
video: "video";
|
|
2382
|
+
image: "image";
|
|
2383
|
+
audio: "audio";
|
|
2384
|
+
captions: "captions";
|
|
2385
|
+
playlist: "playlist";
|
|
2386
|
+
data: "data";
|
|
2387
|
+
other: "other";
|
|
2388
|
+
}>;
|
|
2389
|
+
size: ZodNumber;
|
|
2390
|
+
meta: ZodOptional<ZodObject<{
|
|
2391
|
+
format: ZodOptional<ZodString>;
|
|
2392
|
+
width: ZodOptional<ZodNumber>;
|
|
2393
|
+
height: ZodOptional<ZodNumber>;
|
|
2394
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2395
|
+
}, $strip>>;
|
|
2396
|
+
}, $strip>>;
|
|
2397
|
+
expiresAt: ZodNullable<ZodNumber>;
|
|
2398
|
+
}, $strip>;
|
|
2399
|
+
}, $strip>, ZodObject<{
|
|
2400
|
+
id: ZodString;
|
|
2401
|
+
orgId: ZodString;
|
|
2402
|
+
type: ZodString;
|
|
2403
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2404
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2405
|
+
cost: ZodNullable<ZodObject<{
|
|
2406
|
+
amount: ZodNumber;
|
|
2407
|
+
currency: ZodLiteral<"USD">;
|
|
2408
|
+
formatted: ZodString;
|
|
2409
|
+
}, $strip>>;
|
|
2410
|
+
outputCategory: ZodEnum<{
|
|
2411
|
+
video: "video";
|
|
2412
|
+
image: "image";
|
|
2413
|
+
audio: "audio";
|
|
2414
|
+
captions: "captions";
|
|
2415
|
+
json: "json";
|
|
2416
|
+
raw: "raw";
|
|
2417
|
+
}>;
|
|
2418
|
+
steps: ZodArray<ZodObject<{
|
|
2419
|
+
id: ZodString;
|
|
2420
|
+
name: ZodString;
|
|
2421
|
+
status: ZodString;
|
|
2422
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2423
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2424
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2425
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2426
|
+
error: ZodOptional<ZodString>;
|
|
2427
|
+
}, $strip>>;
|
|
2428
|
+
logsAvailable: ZodBoolean;
|
|
2429
|
+
createdAt: ZodNumber;
|
|
2430
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2431
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2432
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2433
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2434
|
+
status: ZodLiteral<"failed">;
|
|
2435
|
+
error: ZodObject<{
|
|
2436
|
+
code: ZodString;
|
|
2437
|
+
message: ZodString;
|
|
2438
|
+
detail: ZodNullable<ZodString>;
|
|
2439
|
+
retryable: ZodBoolean;
|
|
2440
|
+
}, $strip>;
|
|
2441
|
+
}, $strip>, ZodObject<{
|
|
2442
|
+
id: ZodString;
|
|
2443
|
+
orgId: ZodString;
|
|
2444
|
+
type: ZodString;
|
|
2445
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2446
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2447
|
+
cost: ZodNullable<ZodObject<{
|
|
2448
|
+
amount: ZodNumber;
|
|
2449
|
+
currency: ZodLiteral<"USD">;
|
|
2450
|
+
formatted: ZodString;
|
|
2451
|
+
}, $strip>>;
|
|
2452
|
+
outputCategory: ZodEnum<{
|
|
2453
|
+
video: "video";
|
|
2454
|
+
image: "image";
|
|
2455
|
+
audio: "audio";
|
|
2456
|
+
captions: "captions";
|
|
2457
|
+
json: "json";
|
|
2458
|
+
raw: "raw";
|
|
2459
|
+
}>;
|
|
2460
|
+
steps: ZodArray<ZodObject<{
|
|
2461
|
+
id: ZodString;
|
|
2462
|
+
name: ZodString;
|
|
2463
|
+
status: ZodString;
|
|
2464
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2465
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2466
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2467
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2468
|
+
error: ZodOptional<ZodString>;
|
|
2469
|
+
}, $strip>>;
|
|
2470
|
+
logsAvailable: ZodBoolean;
|
|
2471
|
+
createdAt: ZodNumber;
|
|
2472
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2473
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2474
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2475
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2476
|
+
status: ZodLiteral<"cancelled">;
|
|
2477
|
+
}, $strip>], "status">;
|
|
2152
2478
|
declare const jobCreatedResponseSchema: ZodObject<{
|
|
2153
2479
|
id: ZodString;
|
|
2154
2480
|
status: ZodLiteral<"waiting">;
|
|
@@ -2300,6 +2626,11 @@ declare const paymentMethodSchema: ZodObject<{
|
|
|
2300
2626
|
}, $strip>;
|
|
2301
2627
|
type JobResponse = output<typeof jobResponseSchema>;
|
|
2302
2628
|
type JobStep = output<typeof jobStepSchema>;
|
|
2629
|
+
type Output = output<typeof jobOutputSchema>;
|
|
2630
|
+
type OutputFile = output<typeof fileSchema>;
|
|
2631
|
+
type FileType = output<typeof fileTypeSchema>;
|
|
2632
|
+
type JobError = output<typeof jobErrorSchema>;
|
|
2633
|
+
type Cost = output<typeof jobCostSchema>;
|
|
2303
2634
|
type JobCreatedResponse = output<typeof jobCreatedResponseSchema>;
|
|
2304
2635
|
type JobType = output<typeof jobTypeSchema>;
|
|
2305
2636
|
type BillingState = output<typeof billingStateSchema>;
|
|
@@ -2329,8 +2660,6 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2329
2660
|
}, $strip>, ZodObject<{
|
|
2330
2661
|
type: ZodLiteral<"job.result">;
|
|
2331
2662
|
jobId: ZodString;
|
|
2332
|
-
outputRef: ZodString;
|
|
2333
|
-
outputMeta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2334
2663
|
}, $strip>, ZodObject<{
|
|
2335
2664
|
type: ZodLiteral<"balance.updated">;
|
|
2336
2665
|
balance: ZodNumber;
|
|
@@ -2427,6 +2756,33 @@ interface LogEntryData {
|
|
|
2427
2756
|
}
|
|
2428
2757
|
//#endregion
|
|
2429
2758
|
//#region src/types.d.ts
|
|
2759
|
+
/**
|
|
2760
|
+
* Primary playable/download URL for a completed job, or `undefined`.
|
|
2761
|
+
*
|
|
2762
|
+
* Returns `output.file.url` — the single download for a file job or the playlist
|
|
2763
|
+
* URL for a stream. A pure set (multiple files, no headline) or a data-only job
|
|
2764
|
+
* has no single primary URL: inspect `job.output.files` / `job.output.data`.
|
|
2765
|
+
*/
|
|
2766
|
+
declare function outputUrl(job: JobResponse): string | undefined;
|
|
2767
|
+
/**
|
|
2768
|
+
* Typed accessor for a completed job's structured `data`, or `null`.
|
|
2769
|
+
*
|
|
2770
|
+
* `output.data` is job-type-specific (probe result, detections, transcript) and
|
|
2771
|
+
* is `unknown` at the contract level — its shape is documented per job type, not
|
|
2772
|
+
* by the API schema. This helper applies the caller-supplied type `T` so you can
|
|
2773
|
+
* read `data` without sprinkling assertions at each call site. `T` is your claim
|
|
2774
|
+
* about the shape for the job type you submitted; validate it yourself (e.g. with
|
|
2775
|
+
* Zod) if the input is untrusted.
|
|
2776
|
+
*
|
|
2777
|
+
* Returns `null` for non-complete jobs and for jobs with no structured data
|
|
2778
|
+
* (pure file transforms).
|
|
2779
|
+
*
|
|
2780
|
+
* @example
|
|
2781
|
+
* type Metadata = { format: string; durationMs: number };
|
|
2782
|
+
* const meta = jobData<Metadata>(await client.jobs.wait(id));
|
|
2783
|
+
* if (meta) console.log(meta.durationMs);
|
|
2784
|
+
*/
|
|
2785
|
+
declare function jobData<T>(job: JobResponse): T | null;
|
|
2430
2786
|
/**
|
|
2431
2787
|
* Per-job execution timing breakdown. Returned by `client.jobs.getTimings(id)`.
|
|
2432
2788
|
*
|
|
@@ -2891,4 +3247,4 @@ type Asset = {
|
|
|
2891
3247
|
updatedAt: number;
|
|
2892
3248
|
};
|
|
2893
3249
|
//#endregion
|
|
2894
|
-
export { ApiError, type ApiKey, type Asset, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type CreateJobParams, type CreateWebhookParams, type FfmpegParams, type JobResponse as Job, type JobCreatedResponse, type JobListPage, type JobStep, type JobSubscribeOptions, type JobSubscription, type JobTimings, type JobType, type ListDeliveriesParams, type ListJobsParams, type LogEntryData, type OrgCurrentResponse, type OrgEvent, type Organization, type PaginationMeta, type PaymentMethod, type RealtimeConnectOptions, type RealtimeConnection, type RendobarClient, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadResult, type UsageParams, type UsageSummary, type WaitOptions, type WebhookDelivery, type WebhookEndpoint, createClient, isApiError };
|
|
3250
|
+
export { ApiError, type ApiKey, type Asset, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateWebhookParams, type FfmpegParams, type FileType, type JobResponse as Job, type JobCreatedResponse, type JobError, type JobListPage, type JobStep, type JobSubscribeOptions, type JobSubscription, type JobTimings, type JobType, type ListDeliveriesParams, type ListJobsParams, type LogEntryData, type OrgCurrentResponse, type OrgEvent, type Organization, type Output, type OutputFile, type PaginationMeta, type PaymentMethod, type RealtimeConnectOptions, type RealtimeConnection, type RendobarClient, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadResult, type UsageParams, type UsageSummary, type WaitOptions, type WebhookDelivery, type WebhookEndpoint, createClient, isApiError, jobData, outputUrl };
|
package/dist/index.d.mts
CHANGED
|
@@ -2109,29 +2109,156 @@ declare const jobStepSchema: ZodObject<{
|
|
|
2109
2109
|
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2110
2110
|
error: ZodOptional<ZodString>;
|
|
2111
2111
|
}, $strip>;
|
|
2112
|
-
|
|
2112
|
+
/**
|
|
2113
|
+
* File type, an OPEN enum (tolerant-reader contract). Derived from the file
|
|
2114
|
+
* extension. Clients MUST tolerate unknown future values and fall back to
|
|
2115
|
+
* treating the file as opaque ("other"). Adding a value here is non-breaking.
|
|
2116
|
+
*/
|
|
2117
|
+
declare const fileTypeSchema: ZodEnum<{
|
|
2118
|
+
video: "video";
|
|
2119
|
+
image: "image";
|
|
2120
|
+
audio: "audio";
|
|
2121
|
+
captions: "captions";
|
|
2122
|
+
playlist: "playlist";
|
|
2123
|
+
data: "data";
|
|
2124
|
+
other: "other";
|
|
2125
|
+
}>;
|
|
2126
|
+
/**
|
|
2127
|
+
* A single produced file. `url` is a ready-to-fetch, time-limited URL (signed
|
|
2128
|
+
* download URL for single-file jobs, token-in-path serving URL for served
|
|
2129
|
+
* multi-file jobs). `path` is the file's path within the job output (basename
|
|
2130
|
+
* for single-file jobs, prefix-relative path for served jobs).
|
|
2131
|
+
*/
|
|
2132
|
+
declare const fileSchema: ZodObject<{
|
|
2133
|
+
url: ZodString;
|
|
2134
|
+
path: ZodString;
|
|
2135
|
+
type: ZodEnum<{
|
|
2136
|
+
video: "video";
|
|
2137
|
+
image: "image";
|
|
2138
|
+
audio: "audio";
|
|
2139
|
+
captions: "captions";
|
|
2140
|
+
playlist: "playlist";
|
|
2141
|
+
data: "data";
|
|
2142
|
+
other: "other";
|
|
2143
|
+
}>;
|
|
2144
|
+
size: ZodNumber;
|
|
2145
|
+
meta: ZodOptional<ZodObject<{
|
|
2146
|
+
format: ZodOptional<ZodString>;
|
|
2147
|
+
width: ZodOptional<ZodNumber>;
|
|
2148
|
+
height: ZodOptional<ZodNumber>;
|
|
2149
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2150
|
+
}, $strip>>;
|
|
2151
|
+
}, $strip>;
|
|
2152
|
+
declare const jobOutputSchema: ZodObject<{
|
|
2153
|
+
data: ZodUnknown;
|
|
2154
|
+
file: ZodNullable<ZodObject<{
|
|
2155
|
+
url: ZodString;
|
|
2156
|
+
path: ZodString;
|
|
2157
|
+
type: ZodEnum<{
|
|
2158
|
+
video: "video";
|
|
2159
|
+
image: "image";
|
|
2160
|
+
audio: "audio";
|
|
2161
|
+
captions: "captions";
|
|
2162
|
+
playlist: "playlist";
|
|
2163
|
+
data: "data";
|
|
2164
|
+
other: "other";
|
|
2165
|
+
}>;
|
|
2166
|
+
size: ZodNumber;
|
|
2167
|
+
meta: ZodOptional<ZodObject<{
|
|
2168
|
+
format: ZodOptional<ZodString>;
|
|
2169
|
+
width: ZodOptional<ZodNumber>;
|
|
2170
|
+
height: ZodOptional<ZodNumber>;
|
|
2171
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2172
|
+
}, $strip>>;
|
|
2173
|
+
}, $strip>>;
|
|
2174
|
+
files: ZodArray<ZodObject<{
|
|
2175
|
+
url: ZodString;
|
|
2176
|
+
path: ZodString;
|
|
2177
|
+
type: ZodEnum<{
|
|
2178
|
+
video: "video";
|
|
2179
|
+
image: "image";
|
|
2180
|
+
audio: "audio";
|
|
2181
|
+
captions: "captions";
|
|
2182
|
+
playlist: "playlist";
|
|
2183
|
+
data: "data";
|
|
2184
|
+
other: "other";
|
|
2185
|
+
}>;
|
|
2186
|
+
size: ZodNumber;
|
|
2187
|
+
meta: ZodOptional<ZodObject<{
|
|
2188
|
+
format: ZodOptional<ZodString>;
|
|
2189
|
+
width: ZodOptional<ZodNumber>;
|
|
2190
|
+
height: ZodOptional<ZodNumber>;
|
|
2191
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2192
|
+
}, $strip>>;
|
|
2193
|
+
}, $strip>>;
|
|
2194
|
+
expiresAt: ZodNullable<ZodNumber>;
|
|
2195
|
+
}, $strip>;
|
|
2196
|
+
declare const jobErrorSchema: ZodObject<{
|
|
2197
|
+
code: ZodString;
|
|
2198
|
+
message: ZodString;
|
|
2199
|
+
detail: ZodNullable<ZodString>;
|
|
2200
|
+
retryable: ZodBoolean;
|
|
2201
|
+
}, $strip>;
|
|
2202
|
+
declare const jobCostSchema: ZodObject<{
|
|
2203
|
+
amount: ZodNumber;
|
|
2204
|
+
currency: ZodLiteral<"USD">;
|
|
2205
|
+
formatted: ZodString;
|
|
2206
|
+
}, $strip>;
|
|
2207
|
+
declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
2113
2208
|
id: ZodString;
|
|
2114
2209
|
orgId: ZodString;
|
|
2115
2210
|
type: ZodString;
|
|
2116
|
-
status: ZodString;
|
|
2117
2211
|
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2118
2212
|
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2119
|
-
outputRef: ZodNullable<ZodString>;
|
|
2120
|
-
outputUrl: ZodNullable<ZodString>;
|
|
2121
|
-
posterUrl: ZodNullable<ZodString>;
|
|
2122
|
-
outputMeta: ZodNullable<ZodRecord<ZodString, ZodUnknown>>;
|
|
2123
|
-
errorCode: ZodNullable<ZodString>;
|
|
2124
|
-
errorMessage: ZodNullable<ZodString>;
|
|
2125
|
-
price: ZodNullable<ZodNumber>;
|
|
2126
|
-
priceFormatted: ZodNullable<ZodString>;
|
|
2127
2213
|
cost: ZodNullable<ZodObject<{
|
|
2128
|
-
|
|
2129
|
-
currency:
|
|
2214
|
+
amount: ZodNumber;
|
|
2215
|
+
currency: ZodLiteral<"USD">;
|
|
2216
|
+
formatted: ZodString;
|
|
2130
2217
|
}, $strip>>;
|
|
2218
|
+
outputCategory: ZodEnum<{
|
|
2219
|
+
video: "video";
|
|
2220
|
+
image: "image";
|
|
2221
|
+
audio: "audio";
|
|
2222
|
+
captions: "captions";
|
|
2223
|
+
json: "json";
|
|
2224
|
+
raw: "raw";
|
|
2225
|
+
}>;
|
|
2226
|
+
steps: ZodArray<ZodObject<{
|
|
2227
|
+
id: ZodString;
|
|
2228
|
+
name: ZodString;
|
|
2229
|
+
status: ZodString;
|
|
2230
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2231
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2232
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2233
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2234
|
+
error: ZodOptional<ZodString>;
|
|
2235
|
+
}, $strip>>;
|
|
2236
|
+
logsAvailable: ZodBoolean;
|
|
2131
2237
|
createdAt: ZodNumber;
|
|
2132
2238
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2133
2239
|
startedAt: ZodNullable<ZodNumber>;
|
|
2134
2240
|
completedAt: ZodNullable<ZodNumber>;
|
|
2241
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2242
|
+
status: ZodLiteral<"waiting">;
|
|
2243
|
+
}, $strip>, ZodObject<{
|
|
2244
|
+
id: ZodString;
|
|
2245
|
+
orgId: ZodString;
|
|
2246
|
+
type: ZodString;
|
|
2247
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2248
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2249
|
+
cost: ZodNullable<ZodObject<{
|
|
2250
|
+
amount: ZodNumber;
|
|
2251
|
+
currency: ZodLiteral<"USD">;
|
|
2252
|
+
formatted: ZodString;
|
|
2253
|
+
}, $strip>>;
|
|
2254
|
+
outputCategory: ZodEnum<{
|
|
2255
|
+
video: "video";
|
|
2256
|
+
image: "image";
|
|
2257
|
+
audio: "audio";
|
|
2258
|
+
captions: "captions";
|
|
2259
|
+
json: "json";
|
|
2260
|
+
raw: "raw";
|
|
2261
|
+
}>;
|
|
2135
2262
|
steps: ZodArray<ZodObject<{
|
|
2136
2263
|
id: ZodString;
|
|
2137
2264
|
name: ZodString;
|
|
@@ -2142,13 +2269,212 @@ declare const jobResponseSchema: ZodObject<{
|
|
|
2142
2269
|
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2143
2270
|
error: ZodOptional<ZodString>;
|
|
2144
2271
|
}, $strip>>;
|
|
2145
|
-
outputCategory: ZodString;
|
|
2146
|
-
mediaType: ZodNullable<ZodString>;
|
|
2147
2272
|
logsAvailable: ZodBoolean;
|
|
2148
|
-
|
|
2149
|
-
|
|
2273
|
+
createdAt: ZodNumber;
|
|
2274
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2275
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2276
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2150
2277
|
settledAt: ZodNullable<ZodNumber>;
|
|
2151
|
-
|
|
2278
|
+
status: ZodLiteral<"dispatched">;
|
|
2279
|
+
progress: ZodOptional<ZodNumber>;
|
|
2280
|
+
eta: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2281
|
+
}, $strip>, ZodObject<{
|
|
2282
|
+
id: ZodString;
|
|
2283
|
+
orgId: ZodString;
|
|
2284
|
+
type: ZodString;
|
|
2285
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2286
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2287
|
+
cost: ZodNullable<ZodObject<{
|
|
2288
|
+
amount: ZodNumber;
|
|
2289
|
+
currency: ZodLiteral<"USD">;
|
|
2290
|
+
formatted: ZodString;
|
|
2291
|
+
}, $strip>>;
|
|
2292
|
+
outputCategory: ZodEnum<{
|
|
2293
|
+
video: "video";
|
|
2294
|
+
image: "image";
|
|
2295
|
+
audio: "audio";
|
|
2296
|
+
captions: "captions";
|
|
2297
|
+
json: "json";
|
|
2298
|
+
raw: "raw";
|
|
2299
|
+
}>;
|
|
2300
|
+
steps: ZodArray<ZodObject<{
|
|
2301
|
+
id: ZodString;
|
|
2302
|
+
name: ZodString;
|
|
2303
|
+
status: ZodString;
|
|
2304
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2305
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2306
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2307
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2308
|
+
error: ZodOptional<ZodString>;
|
|
2309
|
+
}, $strip>>;
|
|
2310
|
+
logsAvailable: ZodBoolean;
|
|
2311
|
+
createdAt: ZodNumber;
|
|
2312
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2313
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2314
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2315
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2316
|
+
status: ZodLiteral<"running">;
|
|
2317
|
+
progress: ZodNumber;
|
|
2318
|
+
eta: ZodNullable<ZodNumber>;
|
|
2319
|
+
}, $strip>, ZodObject<{
|
|
2320
|
+
id: ZodString;
|
|
2321
|
+
orgId: ZodString;
|
|
2322
|
+
type: ZodString;
|
|
2323
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2324
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2325
|
+
cost: ZodNullable<ZodObject<{
|
|
2326
|
+
amount: ZodNumber;
|
|
2327
|
+
currency: ZodLiteral<"USD">;
|
|
2328
|
+
formatted: ZodString;
|
|
2329
|
+
}, $strip>>;
|
|
2330
|
+
outputCategory: ZodEnum<{
|
|
2331
|
+
video: "video";
|
|
2332
|
+
image: "image";
|
|
2333
|
+
audio: "audio";
|
|
2334
|
+
captions: "captions";
|
|
2335
|
+
json: "json";
|
|
2336
|
+
raw: "raw";
|
|
2337
|
+
}>;
|
|
2338
|
+
steps: ZodArray<ZodObject<{
|
|
2339
|
+
id: ZodString;
|
|
2340
|
+
name: ZodString;
|
|
2341
|
+
status: ZodString;
|
|
2342
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2343
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2344
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2345
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2346
|
+
error: ZodOptional<ZodString>;
|
|
2347
|
+
}, $strip>>;
|
|
2348
|
+
logsAvailable: ZodBoolean;
|
|
2349
|
+
createdAt: ZodNumber;
|
|
2350
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2351
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2352
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2353
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2354
|
+
status: ZodLiteral<"complete">;
|
|
2355
|
+
output: ZodObject<{
|
|
2356
|
+
data: ZodUnknown;
|
|
2357
|
+
file: ZodNullable<ZodObject<{
|
|
2358
|
+
url: ZodString;
|
|
2359
|
+
path: ZodString;
|
|
2360
|
+
type: ZodEnum<{
|
|
2361
|
+
video: "video";
|
|
2362
|
+
image: "image";
|
|
2363
|
+
audio: "audio";
|
|
2364
|
+
captions: "captions";
|
|
2365
|
+
playlist: "playlist";
|
|
2366
|
+
data: "data";
|
|
2367
|
+
other: "other";
|
|
2368
|
+
}>;
|
|
2369
|
+
size: ZodNumber;
|
|
2370
|
+
meta: ZodOptional<ZodObject<{
|
|
2371
|
+
format: ZodOptional<ZodString>;
|
|
2372
|
+
width: ZodOptional<ZodNumber>;
|
|
2373
|
+
height: ZodOptional<ZodNumber>;
|
|
2374
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2375
|
+
}, $strip>>;
|
|
2376
|
+
}, $strip>>;
|
|
2377
|
+
files: ZodArray<ZodObject<{
|
|
2378
|
+
url: ZodString;
|
|
2379
|
+
path: ZodString;
|
|
2380
|
+
type: ZodEnum<{
|
|
2381
|
+
video: "video";
|
|
2382
|
+
image: "image";
|
|
2383
|
+
audio: "audio";
|
|
2384
|
+
captions: "captions";
|
|
2385
|
+
playlist: "playlist";
|
|
2386
|
+
data: "data";
|
|
2387
|
+
other: "other";
|
|
2388
|
+
}>;
|
|
2389
|
+
size: ZodNumber;
|
|
2390
|
+
meta: ZodOptional<ZodObject<{
|
|
2391
|
+
format: ZodOptional<ZodString>;
|
|
2392
|
+
width: ZodOptional<ZodNumber>;
|
|
2393
|
+
height: ZodOptional<ZodNumber>;
|
|
2394
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2395
|
+
}, $strip>>;
|
|
2396
|
+
}, $strip>>;
|
|
2397
|
+
expiresAt: ZodNullable<ZodNumber>;
|
|
2398
|
+
}, $strip>;
|
|
2399
|
+
}, $strip>, ZodObject<{
|
|
2400
|
+
id: ZodString;
|
|
2401
|
+
orgId: ZodString;
|
|
2402
|
+
type: ZodString;
|
|
2403
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2404
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2405
|
+
cost: ZodNullable<ZodObject<{
|
|
2406
|
+
amount: ZodNumber;
|
|
2407
|
+
currency: ZodLiteral<"USD">;
|
|
2408
|
+
formatted: ZodString;
|
|
2409
|
+
}, $strip>>;
|
|
2410
|
+
outputCategory: ZodEnum<{
|
|
2411
|
+
video: "video";
|
|
2412
|
+
image: "image";
|
|
2413
|
+
audio: "audio";
|
|
2414
|
+
captions: "captions";
|
|
2415
|
+
json: "json";
|
|
2416
|
+
raw: "raw";
|
|
2417
|
+
}>;
|
|
2418
|
+
steps: ZodArray<ZodObject<{
|
|
2419
|
+
id: ZodString;
|
|
2420
|
+
name: ZodString;
|
|
2421
|
+
status: ZodString;
|
|
2422
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2423
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2424
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2425
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2426
|
+
error: ZodOptional<ZodString>;
|
|
2427
|
+
}, $strip>>;
|
|
2428
|
+
logsAvailable: ZodBoolean;
|
|
2429
|
+
createdAt: ZodNumber;
|
|
2430
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2431
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2432
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2433
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2434
|
+
status: ZodLiteral<"failed">;
|
|
2435
|
+
error: ZodObject<{
|
|
2436
|
+
code: ZodString;
|
|
2437
|
+
message: ZodString;
|
|
2438
|
+
detail: ZodNullable<ZodString>;
|
|
2439
|
+
retryable: ZodBoolean;
|
|
2440
|
+
}, $strip>;
|
|
2441
|
+
}, $strip>, ZodObject<{
|
|
2442
|
+
id: ZodString;
|
|
2443
|
+
orgId: ZodString;
|
|
2444
|
+
type: ZodString;
|
|
2445
|
+
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2446
|
+
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2447
|
+
cost: ZodNullable<ZodObject<{
|
|
2448
|
+
amount: ZodNumber;
|
|
2449
|
+
currency: ZodLiteral<"USD">;
|
|
2450
|
+
formatted: ZodString;
|
|
2451
|
+
}, $strip>>;
|
|
2452
|
+
outputCategory: ZodEnum<{
|
|
2453
|
+
video: "video";
|
|
2454
|
+
image: "image";
|
|
2455
|
+
audio: "audio";
|
|
2456
|
+
captions: "captions";
|
|
2457
|
+
json: "json";
|
|
2458
|
+
raw: "raw";
|
|
2459
|
+
}>;
|
|
2460
|
+
steps: ZodArray<ZodObject<{
|
|
2461
|
+
id: ZodString;
|
|
2462
|
+
name: ZodString;
|
|
2463
|
+
status: ZodString;
|
|
2464
|
+
startedAt: ZodOptional<ZodNumber>;
|
|
2465
|
+
completedAt: ZodOptional<ZodNumber>;
|
|
2466
|
+
durationMs: ZodOptional<ZodNumber>;
|
|
2467
|
+
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2468
|
+
error: ZodOptional<ZodString>;
|
|
2469
|
+
}, $strip>>;
|
|
2470
|
+
logsAvailable: ZodBoolean;
|
|
2471
|
+
createdAt: ZodNumber;
|
|
2472
|
+
dispatchedAt: ZodNullable<ZodNumber>;
|
|
2473
|
+
startedAt: ZodNullable<ZodNumber>;
|
|
2474
|
+
completedAt: ZodNullable<ZodNumber>;
|
|
2475
|
+
settledAt: ZodNullable<ZodNumber>;
|
|
2476
|
+
status: ZodLiteral<"cancelled">;
|
|
2477
|
+
}, $strip>], "status">;
|
|
2152
2478
|
declare const jobCreatedResponseSchema: ZodObject<{
|
|
2153
2479
|
id: ZodString;
|
|
2154
2480
|
status: ZodLiteral<"waiting">;
|
|
@@ -2300,6 +2626,11 @@ declare const paymentMethodSchema: ZodObject<{
|
|
|
2300
2626
|
}, $strip>;
|
|
2301
2627
|
type JobResponse = output<typeof jobResponseSchema>;
|
|
2302
2628
|
type JobStep = output<typeof jobStepSchema>;
|
|
2629
|
+
type Output = output<typeof jobOutputSchema>;
|
|
2630
|
+
type OutputFile = output<typeof fileSchema>;
|
|
2631
|
+
type FileType = output<typeof fileTypeSchema>;
|
|
2632
|
+
type JobError = output<typeof jobErrorSchema>;
|
|
2633
|
+
type Cost = output<typeof jobCostSchema>;
|
|
2303
2634
|
type JobCreatedResponse = output<typeof jobCreatedResponseSchema>;
|
|
2304
2635
|
type JobType = output<typeof jobTypeSchema>;
|
|
2305
2636
|
type BillingState = output<typeof billingStateSchema>;
|
|
@@ -2329,8 +2660,6 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2329
2660
|
}, $strip>, ZodObject<{
|
|
2330
2661
|
type: ZodLiteral<"job.result">;
|
|
2331
2662
|
jobId: ZodString;
|
|
2332
|
-
outputRef: ZodString;
|
|
2333
|
-
outputMeta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
2334
2663
|
}, $strip>, ZodObject<{
|
|
2335
2664
|
type: ZodLiteral<"balance.updated">;
|
|
2336
2665
|
balance: ZodNumber;
|
|
@@ -2427,6 +2756,33 @@ interface LogEntryData {
|
|
|
2427
2756
|
}
|
|
2428
2757
|
//#endregion
|
|
2429
2758
|
//#region src/types.d.ts
|
|
2759
|
+
/**
|
|
2760
|
+
* Primary playable/download URL for a completed job, or `undefined`.
|
|
2761
|
+
*
|
|
2762
|
+
* Returns `output.file.url` — the single download for a file job or the playlist
|
|
2763
|
+
* URL for a stream. A pure set (multiple files, no headline) or a data-only job
|
|
2764
|
+
* has no single primary URL: inspect `job.output.files` / `job.output.data`.
|
|
2765
|
+
*/
|
|
2766
|
+
declare function outputUrl(job: JobResponse): string | undefined;
|
|
2767
|
+
/**
|
|
2768
|
+
* Typed accessor for a completed job's structured `data`, or `null`.
|
|
2769
|
+
*
|
|
2770
|
+
* `output.data` is job-type-specific (probe result, detections, transcript) and
|
|
2771
|
+
* is `unknown` at the contract level — its shape is documented per job type, not
|
|
2772
|
+
* by the API schema. This helper applies the caller-supplied type `T` so you can
|
|
2773
|
+
* read `data` without sprinkling assertions at each call site. `T` is your claim
|
|
2774
|
+
* about the shape for the job type you submitted; validate it yourself (e.g. with
|
|
2775
|
+
* Zod) if the input is untrusted.
|
|
2776
|
+
*
|
|
2777
|
+
* Returns `null` for non-complete jobs and for jobs with no structured data
|
|
2778
|
+
* (pure file transforms).
|
|
2779
|
+
*
|
|
2780
|
+
* @example
|
|
2781
|
+
* type Metadata = { format: string; durationMs: number };
|
|
2782
|
+
* const meta = jobData<Metadata>(await client.jobs.wait(id));
|
|
2783
|
+
* if (meta) console.log(meta.durationMs);
|
|
2784
|
+
*/
|
|
2785
|
+
declare function jobData<T>(job: JobResponse): T | null;
|
|
2430
2786
|
/**
|
|
2431
2787
|
* Per-job execution timing breakdown. Returned by `client.jobs.getTimings(id)`.
|
|
2432
2788
|
*
|
|
@@ -2891,4 +3247,4 @@ type Asset = {
|
|
|
2891
3247
|
updatedAt: number;
|
|
2892
3248
|
};
|
|
2893
3249
|
//#endregion
|
|
2894
|
-
export { ApiError, type ApiKey, type Asset, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type CreateJobParams, type CreateWebhookParams, type FfmpegParams, type JobResponse as Job, type JobCreatedResponse, type JobListPage, type JobStep, type JobSubscribeOptions, type JobSubscription, type JobTimings, type JobType, type ListDeliveriesParams, type ListJobsParams, type LogEntryData, type OrgCurrentResponse, type OrgEvent, type Organization, type PaginationMeta, type PaymentMethod, type RealtimeConnectOptions, type RealtimeConnection, type RendobarClient, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadResult, type UsageParams, type UsageSummary, type WaitOptions, type WebhookDelivery, type WebhookEndpoint, createClient, isApiError };
|
|
3250
|
+
export { ApiError, type ApiKey, type Asset, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateWebhookParams, type FfmpegParams, type FileType, type JobResponse as Job, type JobCreatedResponse, type JobError, type JobListPage, type JobStep, type JobSubscribeOptions, type JobSubscription, type JobTimings, type JobType, type ListDeliveriesParams, type ListJobsParams, type LogEntryData, type OrgCurrentResponse, type OrgEvent, type Organization, type Output, type OutputFile, type PaginationMeta, type PaymentMethod, type RealtimeConnectOptions, type RealtimeConnection, type RendobarClient, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadResult, type UsageParams, type UsageSummary, type WaitOptions, type WebhookDelivery, type WebhookEndpoint, createClient, isApiError, jobData, outputUrl };
|
package/dist/index.mjs
CHANGED
|
@@ -645,4 +645,40 @@ function createClient(config = {}) {
|
|
|
645
645
|
};
|
|
646
646
|
}
|
|
647
647
|
//#endregion
|
|
648
|
-
|
|
648
|
+
//#region src/types.ts
|
|
649
|
+
/**
|
|
650
|
+
* Primary playable/download URL for a completed job, or `undefined`.
|
|
651
|
+
*
|
|
652
|
+
* Returns `output.file.url` — the single download for a file job or the playlist
|
|
653
|
+
* URL for a stream. A pure set (multiple files, no headline) or a data-only job
|
|
654
|
+
* has no single primary URL: inspect `job.output.files` / `job.output.data`.
|
|
655
|
+
*/
|
|
656
|
+
function outputUrl(job) {
|
|
657
|
+
if (job.status !== "complete") return void 0;
|
|
658
|
+
return job.output.file?.url;
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Typed accessor for a completed job's structured `data`, or `null`.
|
|
662
|
+
*
|
|
663
|
+
* `output.data` is job-type-specific (probe result, detections, transcript) and
|
|
664
|
+
* is `unknown` at the contract level — its shape is documented per job type, not
|
|
665
|
+
* by the API schema. This helper applies the caller-supplied type `T` so you can
|
|
666
|
+
* read `data` without sprinkling assertions at each call site. `T` is your claim
|
|
667
|
+
* about the shape for the job type you submitted; validate it yourself (e.g. with
|
|
668
|
+
* Zod) if the input is untrusted.
|
|
669
|
+
*
|
|
670
|
+
* Returns `null` for non-complete jobs and for jobs with no structured data
|
|
671
|
+
* (pure file transforms).
|
|
672
|
+
*
|
|
673
|
+
* @example
|
|
674
|
+
* type Metadata = { format: string; durationMs: number };
|
|
675
|
+
* const meta = jobData<Metadata>(await client.jobs.wait(id));
|
|
676
|
+
* if (meta) console.log(meta.durationMs);
|
|
677
|
+
*/
|
|
678
|
+
function jobData(job) {
|
|
679
|
+
if (job.status !== "complete") return null;
|
|
680
|
+
if (job.output.data == null) return null;
|
|
681
|
+
return job.output.data;
|
|
682
|
+
}
|
|
683
|
+
//#endregion
|
|
684
|
+
export { ApiError, createClient, isApiError, jobData, outputUrl };
|