@rendobar/sdk 5.1.1 → 5.3.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/index.cjs +25 -3
- package/dist/index.d.cts +124 -27
- package/dist/index.d.mts +124 -27
- package/dist/index.mjs +25 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -209,6 +209,25 @@ function createJobsResource(request) {
|
|
|
209
209
|
signal: options?.signal
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Create a job and wait for it to reach a terminal state, returning the
|
|
214
|
+
* finished job. A convenience wrapper over `create()` + `wait()` for
|
|
215
|
+
* callers who just want the result without juggling two calls — works for
|
|
216
|
+
* any job type, not just a specific product.
|
|
217
|
+
*
|
|
218
|
+
* Unlike `wait()` (which defaults `throwOnFailure` to `false` to preserve
|
|
219
|
+
* its existing behavior), `run()` defaults `throwOnFailure` to `true`: a
|
|
220
|
+
* job that ends "failed" or "cancelled" throws `JobFailedError` unless the
|
|
221
|
+
* caller explicitly opts out with `throwOnFailure: false`.
|
|
222
|
+
*/
|
|
223
|
+
async function run(params, options = {}) {
|
|
224
|
+
const { signal, throwOnFailure = true, ...waitOptions } = options;
|
|
225
|
+
return wait((await create(params, { signal })).id, {
|
|
226
|
+
...waitOptions,
|
|
227
|
+
signal,
|
|
228
|
+
throwOnFailure
|
|
229
|
+
});
|
|
230
|
+
}
|
|
212
231
|
async function get(id, options) {
|
|
213
232
|
return request(`/jobs/${id}`, { signal: options?.signal });
|
|
214
233
|
}
|
|
@@ -265,6 +284,7 @@ function createJobsResource(request) {
|
|
|
265
284
|
list,
|
|
266
285
|
listAll,
|
|
267
286
|
wait,
|
|
287
|
+
run,
|
|
268
288
|
cancel,
|
|
269
289
|
download,
|
|
270
290
|
logs,
|
|
@@ -397,9 +417,9 @@ function attemptTimeoutMs(sizeBytes, attempt) {
|
|
|
397
417
|
6e4
|
|
398
418
|
];
|
|
399
419
|
const RATE_BPS = [
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
420
|
+
512e3,
|
|
421
|
+
102400,
|
|
422
|
+
51200
|
|
403
423
|
];
|
|
404
424
|
const i = Math.min(attempt, GRACE_MS.length - 1);
|
|
405
425
|
return GRACE_MS[i] + Math.ceil(sizeBytes / RATE_BPS[i] * 1e3);
|
|
@@ -778,6 +798,7 @@ const KNOWN_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
778
798
|
"job.resources",
|
|
779
799
|
"job.metrics",
|
|
780
800
|
"job.context",
|
|
801
|
+
"job.preview",
|
|
781
802
|
"job.region_failover",
|
|
782
803
|
"balance.updated",
|
|
783
804
|
"subscription.updated",
|
|
@@ -877,6 +898,7 @@ function dispatchJobEvent(event, options) {
|
|
|
877
898
|
case "job.context":
|
|
878
899
|
options.onContext?.(event);
|
|
879
900
|
break;
|
|
901
|
+
case "job.preview": options.onPreview?.(event);
|
|
880
902
|
}
|
|
881
903
|
}
|
|
882
904
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -2195,6 +2195,7 @@ declare const fileSchema: ZodObject<{
|
|
|
2195
2195
|
width: ZodOptional<ZodNumber>;
|
|
2196
2196
|
height: ZodOptional<ZodNumber>;
|
|
2197
2197
|
durationMs: ZodOptional<ZodNumber>;
|
|
2198
|
+
seed: ZodOptional<ZodNumber>;
|
|
2198
2199
|
}, $strip>>;
|
|
2199
2200
|
}, $strip>;
|
|
2200
2201
|
declare const jobOutputSchema: ZodObject<{
|
|
@@ -2217,6 +2218,7 @@ declare const jobOutputSchema: ZodObject<{
|
|
|
2217
2218
|
width: ZodOptional<ZodNumber>;
|
|
2218
2219
|
height: ZodOptional<ZodNumber>;
|
|
2219
2220
|
durationMs: ZodOptional<ZodNumber>;
|
|
2221
|
+
seed: ZodOptional<ZodNumber>;
|
|
2220
2222
|
}, $strip>>;
|
|
2221
2223
|
}, $strip>>;
|
|
2222
2224
|
files: ZodArray<ZodObject<{
|
|
@@ -2237,6 +2239,7 @@ declare const jobOutputSchema: ZodObject<{
|
|
|
2237
2239
|
width: ZodOptional<ZodNumber>;
|
|
2238
2240
|
height: ZodOptional<ZodNumber>;
|
|
2239
2241
|
durationMs: ZodOptional<ZodNumber>;
|
|
2242
|
+
seed: ZodOptional<ZodNumber>;
|
|
2240
2243
|
}, $strip>>;
|
|
2241
2244
|
}, $strip>>;
|
|
2242
2245
|
expiresAt: ZodNullable<ZodNumber>;
|
|
@@ -2301,6 +2304,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2301
2304
|
completedAt: ZodNullable<ZodNumber>;
|
|
2302
2305
|
settledAt: ZodNullable<ZodNumber>;
|
|
2303
2306
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2307
|
+
webUrl: ZodString;
|
|
2308
|
+
model: ZodNullable<ZodString>;
|
|
2304
2309
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2305
2310
|
status: ZodEnum<{
|
|
2306
2311
|
delivered: "delivered";
|
|
@@ -2353,6 +2358,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2353
2358
|
completedAt: ZodNullable<ZodNumber>;
|
|
2354
2359
|
settledAt: ZodNullable<ZodNumber>;
|
|
2355
2360
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2361
|
+
webUrl: ZodString;
|
|
2362
|
+
model: ZodNullable<ZodString>;
|
|
2356
2363
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2357
2364
|
status: ZodEnum<{
|
|
2358
2365
|
delivered: "delivered";
|
|
@@ -2363,6 +2370,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2363
2370
|
status: ZodLiteral<"dispatched">;
|
|
2364
2371
|
progress: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2365
2372
|
eta: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2373
|
+
bootState: ZodOptional<ZodNullable<ZodObject<{
|
|
2374
|
+
phase: ZodString;
|
|
2375
|
+
detail: ZodString;
|
|
2376
|
+
elapsedMs: ZodNumber;
|
|
2377
|
+
typicalMs: ZodNullable<ZodNumber>;
|
|
2378
|
+
etaMs: ZodNullable<ZodNumber>;
|
|
2379
|
+
}, $strip>>>;
|
|
2366
2380
|
}, $strip>, ZodObject<{
|
|
2367
2381
|
id: ZodString;
|
|
2368
2382
|
orgId: ZodString;
|
|
@@ -2407,6 +2421,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2407
2421
|
completedAt: ZodNullable<ZodNumber>;
|
|
2408
2422
|
settledAt: ZodNullable<ZodNumber>;
|
|
2409
2423
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2424
|
+
webUrl: ZodString;
|
|
2425
|
+
model: ZodNullable<ZodString>;
|
|
2410
2426
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2411
2427
|
status: ZodEnum<{
|
|
2412
2428
|
delivered: "delivered";
|
|
@@ -2461,6 +2477,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2461
2477
|
completedAt: ZodNullable<ZodNumber>;
|
|
2462
2478
|
settledAt: ZodNullable<ZodNumber>;
|
|
2463
2479
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2480
|
+
webUrl: ZodString;
|
|
2481
|
+
model: ZodNullable<ZodString>;
|
|
2464
2482
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2465
2483
|
status: ZodEnum<{
|
|
2466
2484
|
delivered: "delivered";
|
|
@@ -2489,6 +2507,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2489
2507
|
width: ZodOptional<ZodNumber>;
|
|
2490
2508
|
height: ZodOptional<ZodNumber>;
|
|
2491
2509
|
durationMs: ZodOptional<ZodNumber>;
|
|
2510
|
+
seed: ZodOptional<ZodNumber>;
|
|
2492
2511
|
}, $strip>>;
|
|
2493
2512
|
}, $strip>>;
|
|
2494
2513
|
files: ZodArray<ZodObject<{
|
|
@@ -2509,6 +2528,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2509
2528
|
width: ZodOptional<ZodNumber>;
|
|
2510
2529
|
height: ZodOptional<ZodNumber>;
|
|
2511
2530
|
durationMs: ZodOptional<ZodNumber>;
|
|
2531
|
+
seed: ZodOptional<ZodNumber>;
|
|
2512
2532
|
}, $strip>>;
|
|
2513
2533
|
}, $strip>>;
|
|
2514
2534
|
expiresAt: ZodNullable<ZodNumber>;
|
|
@@ -2557,6 +2577,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2557
2577
|
completedAt: ZodNullable<ZodNumber>;
|
|
2558
2578
|
settledAt: ZodNullable<ZodNumber>;
|
|
2559
2579
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2580
|
+
webUrl: ZodString;
|
|
2581
|
+
model: ZodNullable<ZodString>;
|
|
2560
2582
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2561
2583
|
status: ZodEnum<{
|
|
2562
2584
|
delivered: "delivered";
|
|
@@ -2620,6 +2642,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2620
2642
|
completedAt: ZodNullable<ZodNumber>;
|
|
2621
2643
|
settledAt: ZodNullable<ZodNumber>;
|
|
2622
2644
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2645
|
+
webUrl: ZodString;
|
|
2646
|
+
model: ZodNullable<ZodString>;
|
|
2623
2647
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2624
2648
|
status: ZodEnum<{
|
|
2625
2649
|
delivered: "delivered";
|
|
@@ -3015,8 +3039,8 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
3015
3039
|
jobId: ZodString;
|
|
3016
3040
|
timestamp: ZodNumber;
|
|
3017
3041
|
machine: ZodString;
|
|
3018
|
-
cpu: ZodNumber
|
|
3019
|
-
memory: ZodNumber
|
|
3042
|
+
cpu: ZodOptional<ZodNumber>;
|
|
3043
|
+
memory: ZodOptional<ZodNumber>;
|
|
3020
3044
|
region: ZodOptional<ZodString>;
|
|
3021
3045
|
}, $strip>, ZodObject<{
|
|
3022
3046
|
type: ZodLiteral<"job.progress">;
|
|
@@ -3034,38 +3058,38 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
3034
3058
|
metrics: ZodOptional<ZodRecord<ZodString, ZodUnion<readonly [ZodNumber, ZodString]>>>;
|
|
3035
3059
|
}, $strip>, ZodObject<{
|
|
3036
3060
|
timestamp: ZodNumber;
|
|
3037
|
-
cpuPct: ZodNumber
|
|
3061
|
+
cpuPct: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3038
3062
|
cpuCores: ZodNumber;
|
|
3039
|
-
allocatedCores:
|
|
3063
|
+
allocatedCores: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3040
3064
|
memUsedMB: ZodNumber;
|
|
3041
|
-
memLimitMB: ZodNumber
|
|
3042
|
-
diskRMBps:
|
|
3043
|
-
diskWMBps:
|
|
3044
|
-
netRxMBps:
|
|
3045
|
-
netTxMBps:
|
|
3046
|
-
gpuPct:
|
|
3047
|
-
gpuMemUsedMB:
|
|
3048
|
-
gpuMemTotalMB:
|
|
3049
|
-
gpuTempC:
|
|
3050
|
-
gpuPowerW:
|
|
3065
|
+
memLimitMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3066
|
+
diskRMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3067
|
+
diskWMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3068
|
+
netRxMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3069
|
+
netTxMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3070
|
+
gpuPct: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3071
|
+
gpuMemUsedMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3072
|
+
gpuMemTotalMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3073
|
+
gpuTempC: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3074
|
+
gpuPowerW: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3051
3075
|
type: ZodLiteral<"job.resources">;
|
|
3052
3076
|
jobId: ZodString;
|
|
3053
3077
|
}, $strip>, ZodObject<{
|
|
3054
3078
|
timestamp: ZodNumber;
|
|
3055
|
-
cpuPct: ZodNumber
|
|
3079
|
+
cpuPct: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3056
3080
|
cpuCores: ZodNumber;
|
|
3057
|
-
allocatedCores:
|
|
3081
|
+
allocatedCores: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3058
3082
|
memUsedMB: ZodNumber;
|
|
3059
|
-
memLimitMB: ZodNumber
|
|
3060
|
-
diskRMBps:
|
|
3061
|
-
diskWMBps:
|
|
3062
|
-
netRxMBps:
|
|
3063
|
-
netTxMBps:
|
|
3064
|
-
gpuPct:
|
|
3065
|
-
gpuMemUsedMB:
|
|
3066
|
-
gpuMemTotalMB:
|
|
3067
|
-
gpuTempC:
|
|
3068
|
-
gpuPowerW:
|
|
3083
|
+
memLimitMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3084
|
+
diskRMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3085
|
+
diskWMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3086
|
+
netRxMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3087
|
+
netTxMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3088
|
+
gpuPct: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3089
|
+
gpuMemUsedMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3090
|
+
gpuMemTotalMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3091
|
+
gpuTempC: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3092
|
+
gpuPowerW: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3069
3093
|
type: ZodLiteral<"job.metrics">;
|
|
3070
3094
|
jobId: ZodString;
|
|
3071
3095
|
}, $strip>, ZodObject<{
|
|
@@ -3093,6 +3117,15 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
3093
3117
|
event: ZodOptional<ZodString>;
|
|
3094
3118
|
durationMs: ZodOptional<ZodNumber>;
|
|
3095
3119
|
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
3120
|
+
}, $strip>, ZodObject<{
|
|
3121
|
+
type: ZodLiteral<"job.preview">;
|
|
3122
|
+
jobId: ZodString;
|
|
3123
|
+
timestamp: ZodNumber;
|
|
3124
|
+
seq: ZodNumber;
|
|
3125
|
+
progress: ZodNullable<ZodNumber>;
|
|
3126
|
+
width: ZodNumber;
|
|
3127
|
+
height: ZodNumber;
|
|
3128
|
+
data: ZodString;
|
|
3096
3129
|
}, $strip>, ZodObject<{
|
|
3097
3130
|
type: ZodLiteral<"replay.done">;
|
|
3098
3131
|
}, $strip>, ZodObject<{
|
|
@@ -3332,6 +3365,7 @@ declare function createClient(config?: ClientConfig): {
|
|
|
3332
3365
|
}) => Promise<JobListPage>;
|
|
3333
3366
|
listAll: (params?: Omit<ListJobsParams, "offset">) => AsyncGenerator<JobResponse>;
|
|
3334
3367
|
wait: (id: string, options?: WaitOptions) => Promise<JobResponse>;
|
|
3368
|
+
run: (params: CreateJobParams, options?: WaitOptions) => Promise<JobResponse>;
|
|
3335
3369
|
cancel: (id: string, options?: {
|
|
3336
3370
|
signal?: AbortSignal;
|
|
3337
3371
|
}) => Promise<JobResponse>;
|
|
@@ -3641,6 +3675,14 @@ interface JobSubscribeOptions {
|
|
|
3641
3675
|
onMetrics?: (event: Extract<OrgEvent, {
|
|
3642
3676
|
type: "job.resources";
|
|
3643
3677
|
}>) => void;
|
|
3678
|
+
/**
|
|
3679
|
+
* Progressive preview frame of an image mid-generation. Ephemeral: 0..N per
|
|
3680
|
+
* job, never replayed on reconnect — only the latest frame is available to
|
|
3681
|
+
* late subscribers.
|
|
3682
|
+
*/
|
|
3683
|
+
onPreview?: (event: Extract<OrgEvent, {
|
|
3684
|
+
type: "job.preview";
|
|
3685
|
+
}>) => void;
|
|
3644
3686
|
onContext?: (event: Extract<OrgEvent, {
|
|
3645
3687
|
type: "job.context";
|
|
3646
3688
|
}>) => void;
|
|
@@ -3678,6 +3720,61 @@ interface FfmpegParams {
|
|
|
3678
3720
|
compute?: "auto" | "cpu" | "gpu";
|
|
3679
3721
|
}
|
|
3680
3722
|
//#endregion
|
|
3723
|
+
//#region src/jobs/image.d.ts
|
|
3724
|
+
/**
|
|
3725
|
+
* Public params types for the `image.generate` and `image.edit` jobs.
|
|
3726
|
+
*
|
|
3727
|
+
* Declared as plain interfaces here (rather than re-exported from
|
|
3728
|
+
* `@rendobar/shared`) for the same reason as `FfmpegParams` in `./ffmpeg.js`:
|
|
3729
|
+
* the SDK's dts bundler must not follow the shared package's job-registry
|
|
3730
|
+
* type graph — that graph pulls the full generation model catalog into the
|
|
3731
|
+
* .d.ts output and causes tsdown to OOM.
|
|
3732
|
+
*
|
|
3733
|
+
* The canonical runtime shape is the discriminated Zod unions in
|
|
3734
|
+
* `packages/shared/src/jobs/definitions/image-generate.job.ts` and
|
|
3735
|
+
* `image-edit.job.ts` (built from `GEN_BASE_PARAMS` in
|
|
3736
|
+
* `packages/shared/src/jobs/gen-registry.ts`) — keep these interfaces in
|
|
3737
|
+
* sync with them. Both jobs share the same base field set. The per-model
|
|
3738
|
+
* extras (`negativePrompt`, `guidance`, `steps`) are offered here as
|
|
3739
|
+
* optional on every model rather than reproduced as the catalog's per-model
|
|
3740
|
+
* discriminated union, so the SDK doesn't have to track which model
|
|
3741
|
+
* supports which knob — the API validates against the real per-model schema
|
|
3742
|
+
* and rejects a field the resolved model doesn't support.
|
|
3743
|
+
*/
|
|
3744
|
+
/**
|
|
3745
|
+
* Tier alias for a generation model. `"economy"` is the default when `model`
|
|
3746
|
+
* is omitted. Pin an exact model id (e.g. `"qwen-image-2512"`) instead of a
|
|
3747
|
+
* tier to reach that model's own controls.
|
|
3748
|
+
*/
|
|
3749
|
+
type GenModelTier = "economy" | "standard" | "premium";
|
|
3750
|
+
interface ImageGenBaseParams {
|
|
3751
|
+
/** Tier alias or exact model id. Defaults to the "economy" tier when omitted. */
|
|
3752
|
+
model?: GenModelTier | string;
|
|
3753
|
+
/** What you want. For image.edit, describe the change to make. Plain language, no special syntax. */
|
|
3754
|
+
prompt: string;
|
|
3755
|
+
/** Requested output width in pixels. Snapped to what the model can render. */
|
|
3756
|
+
width?: number;
|
|
3757
|
+
/** Requested output height in pixels. Snapped to what the model can render. */
|
|
3758
|
+
height?: number;
|
|
3759
|
+
/** Fixed seed for a reproducible result. The seed used is echoed back. */
|
|
3760
|
+
seed?: number;
|
|
3761
|
+
/** What to keep out of the image. Only some models support this. */
|
|
3762
|
+
negativePrompt?: string;
|
|
3763
|
+
/** How strictly to follow the prompt. Higher is stricter. Only some models support this. */
|
|
3764
|
+
guidance?: number;
|
|
3765
|
+
/** Denoise steps. More steps means more detail and more time. Range depends on the resolved model. */
|
|
3766
|
+
steps?: number;
|
|
3767
|
+
/** Rewrite the prompt for the model before generating. Defaults per model; omit to keep the model's default. */
|
|
3768
|
+
enhancePrompt?: boolean;
|
|
3769
|
+
}
|
|
3770
|
+
/** Public params type for the `image.generate` job. */
|
|
3771
|
+
interface ImageGenerateParams extends ImageGenBaseParams {}
|
|
3772
|
+
/**
|
|
3773
|
+
* Public params type for the `image.edit` job. Reference images (1-4) are
|
|
3774
|
+
* passed as job `inputs.images`, not here — see `CreateJobParams.inputs`.
|
|
3775
|
+
*/
|
|
3776
|
+
interface ImageEditParams extends ImageGenBaseParams {}
|
|
3777
|
+
//#endregion
|
|
3681
3778
|
//#region src/resources/jobs.d.ts
|
|
3682
3779
|
type CreateJobParams = {
|
|
3683
3780
|
type: string;
|
|
@@ -3852,4 +3949,4 @@ type AssetListPage = {
|
|
|
3852
3949
|
meta: AssetListMeta;
|
|
3853
3950
|
};
|
|
3854
3951
|
//#endregion
|
|
3855
|
-
export { ApiError, type ApiKey, type AssetResponse as Asset, type AssetDownloadResponse, type AssetInitResponse, type AssetListMeta, type AssetListPage, type BalanceDepletedData, type BalanceLowData, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateUploadOptions, type CreateWebhookParams, type FfmpegParams, type FileType, type JobResponse as Job, type JobCancelledData, type JobCompletedData, type JobCreatedData, type JobCreatedResponse, type JobError, type JobFailedData, JobFailedError, type JobListPage, type JobStartedData, type JobStats, type JobStep, type JobSubscribeOptions, type JobSubscription, type JobTimings, type JobType, type ListAssetsParams, type ListDeliveriesParams, type ListJobsParams, type LogEntryData, type OrgCurrentResponse, type OrgEvent, type OrgSettings, type Organization, type Output, type OutputFile, type PaginationMeta, type PaymentMethod, type RealtimeConnectOptions, type RealtimeConnection, type RendobarClient, type RetryDeliveryResult, type StatsParams, type TestEventData, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadProgress, type UsageParams, type UsageSummary, type WaitOptions, WaitTimeoutError, type WebhookDelivery, type WebhookEndpoint, type WebhookEventDataMap, type WebhookPayload, createClient, isApiError, jobData, outputUrl };
|
|
3952
|
+
export { ApiError, type ApiKey, type AssetResponse as Asset, type AssetDownloadResponse, type AssetInitResponse, type AssetListMeta, type AssetListPage, type BalanceDepletedData, type BalanceLowData, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateUploadOptions, type CreateWebhookParams, type FfmpegParams, type FileType, type GenModelTier, type ImageEditParams, type ImageGenerateParams, type JobResponse as Job, type JobCancelledData, type JobCompletedData, type JobCreatedData, type JobCreatedResponse, type JobError, type JobFailedData, JobFailedError, type JobListPage, type JobStartedData, type JobStats, type JobStep, type JobSubscribeOptions, type JobSubscription, type JobTimings, type JobType, type ListAssetsParams, type ListDeliveriesParams, type ListJobsParams, type LogEntryData, type OrgCurrentResponse, type OrgEvent, type OrgSettings, type Organization, type Output, type OutputFile, type PaginationMeta, type PaymentMethod, type RealtimeConnectOptions, type RealtimeConnection, type RendobarClient, type RetryDeliveryResult, type StatsParams, type TestEventData, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadProgress, type UsageParams, type UsageSummary, type WaitOptions, WaitTimeoutError, type WebhookDelivery, type WebhookEndpoint, type WebhookEventDataMap, type WebhookPayload, createClient, isApiError, jobData, outputUrl };
|
package/dist/index.d.mts
CHANGED
|
@@ -2195,6 +2195,7 @@ declare const fileSchema: ZodObject<{
|
|
|
2195
2195
|
width: ZodOptional<ZodNumber>;
|
|
2196
2196
|
height: ZodOptional<ZodNumber>;
|
|
2197
2197
|
durationMs: ZodOptional<ZodNumber>;
|
|
2198
|
+
seed: ZodOptional<ZodNumber>;
|
|
2198
2199
|
}, $strip>>;
|
|
2199
2200
|
}, $strip>;
|
|
2200
2201
|
declare const jobOutputSchema: ZodObject<{
|
|
@@ -2217,6 +2218,7 @@ declare const jobOutputSchema: ZodObject<{
|
|
|
2217
2218
|
width: ZodOptional<ZodNumber>;
|
|
2218
2219
|
height: ZodOptional<ZodNumber>;
|
|
2219
2220
|
durationMs: ZodOptional<ZodNumber>;
|
|
2221
|
+
seed: ZodOptional<ZodNumber>;
|
|
2220
2222
|
}, $strip>>;
|
|
2221
2223
|
}, $strip>>;
|
|
2222
2224
|
files: ZodArray<ZodObject<{
|
|
@@ -2237,6 +2239,7 @@ declare const jobOutputSchema: ZodObject<{
|
|
|
2237
2239
|
width: ZodOptional<ZodNumber>;
|
|
2238
2240
|
height: ZodOptional<ZodNumber>;
|
|
2239
2241
|
durationMs: ZodOptional<ZodNumber>;
|
|
2242
|
+
seed: ZodOptional<ZodNumber>;
|
|
2240
2243
|
}, $strip>>;
|
|
2241
2244
|
}, $strip>>;
|
|
2242
2245
|
expiresAt: ZodNullable<ZodNumber>;
|
|
@@ -2301,6 +2304,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2301
2304
|
completedAt: ZodNullable<ZodNumber>;
|
|
2302
2305
|
settledAt: ZodNullable<ZodNumber>;
|
|
2303
2306
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2307
|
+
webUrl: ZodString;
|
|
2308
|
+
model: ZodNullable<ZodString>;
|
|
2304
2309
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2305
2310
|
status: ZodEnum<{
|
|
2306
2311
|
delivered: "delivered";
|
|
@@ -2353,6 +2358,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2353
2358
|
completedAt: ZodNullable<ZodNumber>;
|
|
2354
2359
|
settledAt: ZodNullable<ZodNumber>;
|
|
2355
2360
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2361
|
+
webUrl: ZodString;
|
|
2362
|
+
model: ZodNullable<ZodString>;
|
|
2356
2363
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2357
2364
|
status: ZodEnum<{
|
|
2358
2365
|
delivered: "delivered";
|
|
@@ -2363,6 +2370,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2363
2370
|
status: ZodLiteral<"dispatched">;
|
|
2364
2371
|
progress: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2365
2372
|
eta: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2373
|
+
bootState: ZodOptional<ZodNullable<ZodObject<{
|
|
2374
|
+
phase: ZodString;
|
|
2375
|
+
detail: ZodString;
|
|
2376
|
+
elapsedMs: ZodNumber;
|
|
2377
|
+
typicalMs: ZodNullable<ZodNumber>;
|
|
2378
|
+
etaMs: ZodNullable<ZodNumber>;
|
|
2379
|
+
}, $strip>>>;
|
|
2366
2380
|
}, $strip>, ZodObject<{
|
|
2367
2381
|
id: ZodString;
|
|
2368
2382
|
orgId: ZodString;
|
|
@@ -2407,6 +2421,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2407
2421
|
completedAt: ZodNullable<ZodNumber>;
|
|
2408
2422
|
settledAt: ZodNullable<ZodNumber>;
|
|
2409
2423
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2424
|
+
webUrl: ZodString;
|
|
2425
|
+
model: ZodNullable<ZodString>;
|
|
2410
2426
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2411
2427
|
status: ZodEnum<{
|
|
2412
2428
|
delivered: "delivered";
|
|
@@ -2461,6 +2477,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2461
2477
|
completedAt: ZodNullable<ZodNumber>;
|
|
2462
2478
|
settledAt: ZodNullable<ZodNumber>;
|
|
2463
2479
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2480
|
+
webUrl: ZodString;
|
|
2481
|
+
model: ZodNullable<ZodString>;
|
|
2464
2482
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2465
2483
|
status: ZodEnum<{
|
|
2466
2484
|
delivered: "delivered";
|
|
@@ -2489,6 +2507,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2489
2507
|
width: ZodOptional<ZodNumber>;
|
|
2490
2508
|
height: ZodOptional<ZodNumber>;
|
|
2491
2509
|
durationMs: ZodOptional<ZodNumber>;
|
|
2510
|
+
seed: ZodOptional<ZodNumber>;
|
|
2492
2511
|
}, $strip>>;
|
|
2493
2512
|
}, $strip>>;
|
|
2494
2513
|
files: ZodArray<ZodObject<{
|
|
@@ -2509,6 +2528,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2509
2528
|
width: ZodOptional<ZodNumber>;
|
|
2510
2529
|
height: ZodOptional<ZodNumber>;
|
|
2511
2530
|
durationMs: ZodOptional<ZodNumber>;
|
|
2531
|
+
seed: ZodOptional<ZodNumber>;
|
|
2512
2532
|
}, $strip>>;
|
|
2513
2533
|
}, $strip>>;
|
|
2514
2534
|
expiresAt: ZodNullable<ZodNumber>;
|
|
@@ -2557,6 +2577,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2557
2577
|
completedAt: ZodNullable<ZodNumber>;
|
|
2558
2578
|
settledAt: ZodNullable<ZodNumber>;
|
|
2559
2579
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2580
|
+
webUrl: ZodString;
|
|
2581
|
+
model: ZodNullable<ZodString>;
|
|
2560
2582
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2561
2583
|
status: ZodEnum<{
|
|
2562
2584
|
delivered: "delivered";
|
|
@@ -2620,6 +2642,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2620
2642
|
completedAt: ZodNullable<ZodNumber>;
|
|
2621
2643
|
settledAt: ZodNullable<ZodNumber>;
|
|
2622
2644
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2645
|
+
webUrl: ZodString;
|
|
2646
|
+
model: ZodNullable<ZodString>;
|
|
2623
2647
|
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2624
2648
|
status: ZodEnum<{
|
|
2625
2649
|
delivered: "delivered";
|
|
@@ -3015,8 +3039,8 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
3015
3039
|
jobId: ZodString;
|
|
3016
3040
|
timestamp: ZodNumber;
|
|
3017
3041
|
machine: ZodString;
|
|
3018
|
-
cpu: ZodNumber
|
|
3019
|
-
memory: ZodNumber
|
|
3042
|
+
cpu: ZodOptional<ZodNumber>;
|
|
3043
|
+
memory: ZodOptional<ZodNumber>;
|
|
3020
3044
|
region: ZodOptional<ZodString>;
|
|
3021
3045
|
}, $strip>, ZodObject<{
|
|
3022
3046
|
type: ZodLiteral<"job.progress">;
|
|
@@ -3034,38 +3058,38 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
3034
3058
|
metrics: ZodOptional<ZodRecord<ZodString, ZodUnion<readonly [ZodNumber, ZodString]>>>;
|
|
3035
3059
|
}, $strip>, ZodObject<{
|
|
3036
3060
|
timestamp: ZodNumber;
|
|
3037
|
-
cpuPct: ZodNumber
|
|
3061
|
+
cpuPct: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3038
3062
|
cpuCores: ZodNumber;
|
|
3039
|
-
allocatedCores:
|
|
3063
|
+
allocatedCores: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3040
3064
|
memUsedMB: ZodNumber;
|
|
3041
|
-
memLimitMB: ZodNumber
|
|
3042
|
-
diskRMBps:
|
|
3043
|
-
diskWMBps:
|
|
3044
|
-
netRxMBps:
|
|
3045
|
-
netTxMBps:
|
|
3046
|
-
gpuPct:
|
|
3047
|
-
gpuMemUsedMB:
|
|
3048
|
-
gpuMemTotalMB:
|
|
3049
|
-
gpuTempC:
|
|
3050
|
-
gpuPowerW:
|
|
3065
|
+
memLimitMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3066
|
+
diskRMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3067
|
+
diskWMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3068
|
+
netRxMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3069
|
+
netTxMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3070
|
+
gpuPct: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3071
|
+
gpuMemUsedMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3072
|
+
gpuMemTotalMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3073
|
+
gpuTempC: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3074
|
+
gpuPowerW: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3051
3075
|
type: ZodLiteral<"job.resources">;
|
|
3052
3076
|
jobId: ZodString;
|
|
3053
3077
|
}, $strip>, ZodObject<{
|
|
3054
3078
|
timestamp: ZodNumber;
|
|
3055
|
-
cpuPct: ZodNumber
|
|
3079
|
+
cpuPct: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3056
3080
|
cpuCores: ZodNumber;
|
|
3057
|
-
allocatedCores:
|
|
3081
|
+
allocatedCores: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3058
3082
|
memUsedMB: ZodNumber;
|
|
3059
|
-
memLimitMB: ZodNumber
|
|
3060
|
-
diskRMBps:
|
|
3061
|
-
diskWMBps:
|
|
3062
|
-
netRxMBps:
|
|
3063
|
-
netTxMBps:
|
|
3064
|
-
gpuPct:
|
|
3065
|
-
gpuMemUsedMB:
|
|
3066
|
-
gpuMemTotalMB:
|
|
3067
|
-
gpuTempC:
|
|
3068
|
-
gpuPowerW:
|
|
3083
|
+
memLimitMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3084
|
+
diskRMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3085
|
+
diskWMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3086
|
+
netRxMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3087
|
+
netTxMBps: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3088
|
+
gpuPct: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3089
|
+
gpuMemUsedMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3090
|
+
gpuMemTotalMB: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3091
|
+
gpuTempC: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3092
|
+
gpuPowerW: ZodDefault<ZodNullable<ZodNumber>>;
|
|
3069
3093
|
type: ZodLiteral<"job.metrics">;
|
|
3070
3094
|
jobId: ZodString;
|
|
3071
3095
|
}, $strip>, ZodObject<{
|
|
@@ -3093,6 +3117,15 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
3093
3117
|
event: ZodOptional<ZodString>;
|
|
3094
3118
|
durationMs: ZodOptional<ZodNumber>;
|
|
3095
3119
|
meta: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
|
|
3120
|
+
}, $strip>, ZodObject<{
|
|
3121
|
+
type: ZodLiteral<"job.preview">;
|
|
3122
|
+
jobId: ZodString;
|
|
3123
|
+
timestamp: ZodNumber;
|
|
3124
|
+
seq: ZodNumber;
|
|
3125
|
+
progress: ZodNullable<ZodNumber>;
|
|
3126
|
+
width: ZodNumber;
|
|
3127
|
+
height: ZodNumber;
|
|
3128
|
+
data: ZodString;
|
|
3096
3129
|
}, $strip>, ZodObject<{
|
|
3097
3130
|
type: ZodLiteral<"replay.done">;
|
|
3098
3131
|
}, $strip>, ZodObject<{
|
|
@@ -3332,6 +3365,7 @@ declare function createClient(config?: ClientConfig): {
|
|
|
3332
3365
|
}) => Promise<JobListPage>;
|
|
3333
3366
|
listAll: (params?: Omit<ListJobsParams, "offset">) => AsyncGenerator<JobResponse>;
|
|
3334
3367
|
wait: (id: string, options?: WaitOptions) => Promise<JobResponse>;
|
|
3368
|
+
run: (params: CreateJobParams, options?: WaitOptions) => Promise<JobResponse>;
|
|
3335
3369
|
cancel: (id: string, options?: {
|
|
3336
3370
|
signal?: AbortSignal;
|
|
3337
3371
|
}) => Promise<JobResponse>;
|
|
@@ -3641,6 +3675,14 @@ interface JobSubscribeOptions {
|
|
|
3641
3675
|
onMetrics?: (event: Extract<OrgEvent, {
|
|
3642
3676
|
type: "job.resources";
|
|
3643
3677
|
}>) => void;
|
|
3678
|
+
/**
|
|
3679
|
+
* Progressive preview frame of an image mid-generation. Ephemeral: 0..N per
|
|
3680
|
+
* job, never replayed on reconnect — only the latest frame is available to
|
|
3681
|
+
* late subscribers.
|
|
3682
|
+
*/
|
|
3683
|
+
onPreview?: (event: Extract<OrgEvent, {
|
|
3684
|
+
type: "job.preview";
|
|
3685
|
+
}>) => void;
|
|
3644
3686
|
onContext?: (event: Extract<OrgEvent, {
|
|
3645
3687
|
type: "job.context";
|
|
3646
3688
|
}>) => void;
|
|
@@ -3678,6 +3720,61 @@ interface FfmpegParams {
|
|
|
3678
3720
|
compute?: "auto" | "cpu" | "gpu";
|
|
3679
3721
|
}
|
|
3680
3722
|
//#endregion
|
|
3723
|
+
//#region src/jobs/image.d.ts
|
|
3724
|
+
/**
|
|
3725
|
+
* Public params types for the `image.generate` and `image.edit` jobs.
|
|
3726
|
+
*
|
|
3727
|
+
* Declared as plain interfaces here (rather than re-exported from
|
|
3728
|
+
* `@rendobar/shared`) for the same reason as `FfmpegParams` in `./ffmpeg.js`:
|
|
3729
|
+
* the SDK's dts bundler must not follow the shared package's job-registry
|
|
3730
|
+
* type graph — that graph pulls the full generation model catalog into the
|
|
3731
|
+
* .d.ts output and causes tsdown to OOM.
|
|
3732
|
+
*
|
|
3733
|
+
* The canonical runtime shape is the discriminated Zod unions in
|
|
3734
|
+
* `packages/shared/src/jobs/definitions/image-generate.job.ts` and
|
|
3735
|
+
* `image-edit.job.ts` (built from `GEN_BASE_PARAMS` in
|
|
3736
|
+
* `packages/shared/src/jobs/gen-registry.ts`) — keep these interfaces in
|
|
3737
|
+
* sync with them. Both jobs share the same base field set. The per-model
|
|
3738
|
+
* extras (`negativePrompt`, `guidance`, `steps`) are offered here as
|
|
3739
|
+
* optional on every model rather than reproduced as the catalog's per-model
|
|
3740
|
+
* discriminated union, so the SDK doesn't have to track which model
|
|
3741
|
+
* supports which knob — the API validates against the real per-model schema
|
|
3742
|
+
* and rejects a field the resolved model doesn't support.
|
|
3743
|
+
*/
|
|
3744
|
+
/**
|
|
3745
|
+
* Tier alias for a generation model. `"economy"` is the default when `model`
|
|
3746
|
+
* is omitted. Pin an exact model id (e.g. `"qwen-image-2512"`) instead of a
|
|
3747
|
+
* tier to reach that model's own controls.
|
|
3748
|
+
*/
|
|
3749
|
+
type GenModelTier = "economy" | "standard" | "premium";
|
|
3750
|
+
interface ImageGenBaseParams {
|
|
3751
|
+
/** Tier alias or exact model id. Defaults to the "economy" tier when omitted. */
|
|
3752
|
+
model?: GenModelTier | string;
|
|
3753
|
+
/** What you want. For image.edit, describe the change to make. Plain language, no special syntax. */
|
|
3754
|
+
prompt: string;
|
|
3755
|
+
/** Requested output width in pixels. Snapped to what the model can render. */
|
|
3756
|
+
width?: number;
|
|
3757
|
+
/** Requested output height in pixels. Snapped to what the model can render. */
|
|
3758
|
+
height?: number;
|
|
3759
|
+
/** Fixed seed for a reproducible result. The seed used is echoed back. */
|
|
3760
|
+
seed?: number;
|
|
3761
|
+
/** What to keep out of the image. Only some models support this. */
|
|
3762
|
+
negativePrompt?: string;
|
|
3763
|
+
/** How strictly to follow the prompt. Higher is stricter. Only some models support this. */
|
|
3764
|
+
guidance?: number;
|
|
3765
|
+
/** Denoise steps. More steps means more detail and more time. Range depends on the resolved model. */
|
|
3766
|
+
steps?: number;
|
|
3767
|
+
/** Rewrite the prompt for the model before generating. Defaults per model; omit to keep the model's default. */
|
|
3768
|
+
enhancePrompt?: boolean;
|
|
3769
|
+
}
|
|
3770
|
+
/** Public params type for the `image.generate` job. */
|
|
3771
|
+
interface ImageGenerateParams extends ImageGenBaseParams {}
|
|
3772
|
+
/**
|
|
3773
|
+
* Public params type for the `image.edit` job. Reference images (1-4) are
|
|
3774
|
+
* passed as job `inputs.images`, not here — see `CreateJobParams.inputs`.
|
|
3775
|
+
*/
|
|
3776
|
+
interface ImageEditParams extends ImageGenBaseParams {}
|
|
3777
|
+
//#endregion
|
|
3681
3778
|
//#region src/resources/jobs.d.ts
|
|
3682
3779
|
type CreateJobParams = {
|
|
3683
3780
|
type: string;
|
|
@@ -3852,4 +3949,4 @@ type AssetListPage = {
|
|
|
3852
3949
|
meta: AssetListMeta;
|
|
3853
3950
|
};
|
|
3854
3951
|
//#endregion
|
|
3855
|
-
export { ApiError, type ApiKey, type AssetResponse as Asset, type AssetDownloadResponse, type AssetInitResponse, type AssetListMeta, type AssetListPage, type BalanceDepletedData, type BalanceLowData, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateUploadOptions, type CreateWebhookParams, type FfmpegParams, type FileType, type JobResponse as Job, type JobCancelledData, type JobCompletedData, type JobCreatedData, type JobCreatedResponse, type JobError, type JobFailedData, JobFailedError, type JobListPage, type JobStartedData, type JobStats, type JobStep, type JobSubscribeOptions, type JobSubscription, type JobTimings, type JobType, type ListAssetsParams, type ListDeliveriesParams, type ListJobsParams, type LogEntryData, type OrgCurrentResponse, type OrgEvent, type OrgSettings, type Organization, type Output, type OutputFile, type PaginationMeta, type PaymentMethod, type RealtimeConnectOptions, type RealtimeConnection, type RendobarClient, type RetryDeliveryResult, type StatsParams, type TestEventData, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadProgress, type UsageParams, type UsageSummary, type WaitOptions, WaitTimeoutError, type WebhookDelivery, type WebhookEndpoint, type WebhookEventDataMap, type WebhookPayload, createClient, isApiError, jobData, outputUrl };
|
|
3952
|
+
export { ApiError, type ApiKey, type AssetResponse as Asset, type AssetDownloadResponse, type AssetInitResponse, type AssetListMeta, type AssetListPage, type BalanceDepletedData, type BalanceLowData, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateUploadOptions, type CreateWebhookParams, type FfmpegParams, type FileType, type GenModelTier, type ImageEditParams, type ImageGenerateParams, type JobResponse as Job, type JobCancelledData, type JobCompletedData, type JobCreatedData, type JobCreatedResponse, type JobError, type JobFailedData, JobFailedError, type JobListPage, type JobStartedData, type JobStats, type JobStep, type JobSubscribeOptions, type JobSubscription, type JobTimings, type JobType, type ListAssetsParams, type ListDeliveriesParams, type ListJobsParams, type LogEntryData, type OrgCurrentResponse, type OrgEvent, type OrgSettings, type Organization, type Output, type OutputFile, type PaginationMeta, type PaymentMethod, type RealtimeConnectOptions, type RealtimeConnection, type RendobarClient, type RetryDeliveryResult, type StatsParams, type TestEventData, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadProgress, type UsageParams, type UsageSummary, type WaitOptions, WaitTimeoutError, type WebhookDelivery, type WebhookEndpoint, type WebhookEventDataMap, type WebhookPayload, createClient, isApiError, jobData, outputUrl };
|
package/dist/index.mjs
CHANGED
|
@@ -208,6 +208,25 @@ function createJobsResource(request) {
|
|
|
208
208
|
signal: options?.signal
|
|
209
209
|
});
|
|
210
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Create a job and wait for it to reach a terminal state, returning the
|
|
213
|
+
* finished job. A convenience wrapper over `create()` + `wait()` for
|
|
214
|
+
* callers who just want the result without juggling two calls — works for
|
|
215
|
+
* any job type, not just a specific product.
|
|
216
|
+
*
|
|
217
|
+
* Unlike `wait()` (which defaults `throwOnFailure` to `false` to preserve
|
|
218
|
+
* its existing behavior), `run()` defaults `throwOnFailure` to `true`: a
|
|
219
|
+
* job that ends "failed" or "cancelled" throws `JobFailedError` unless the
|
|
220
|
+
* caller explicitly opts out with `throwOnFailure: false`.
|
|
221
|
+
*/
|
|
222
|
+
async function run(params, options = {}) {
|
|
223
|
+
const { signal, throwOnFailure = true, ...waitOptions } = options;
|
|
224
|
+
return wait((await create(params, { signal })).id, {
|
|
225
|
+
...waitOptions,
|
|
226
|
+
signal,
|
|
227
|
+
throwOnFailure
|
|
228
|
+
});
|
|
229
|
+
}
|
|
211
230
|
async function get(id, options) {
|
|
212
231
|
return request(`/jobs/${id}`, { signal: options?.signal });
|
|
213
232
|
}
|
|
@@ -264,6 +283,7 @@ function createJobsResource(request) {
|
|
|
264
283
|
list,
|
|
265
284
|
listAll,
|
|
266
285
|
wait,
|
|
286
|
+
run,
|
|
267
287
|
cancel,
|
|
268
288
|
download,
|
|
269
289
|
logs,
|
|
@@ -396,9 +416,9 @@ function attemptTimeoutMs(sizeBytes, attempt) {
|
|
|
396
416
|
6e4
|
|
397
417
|
];
|
|
398
418
|
const RATE_BPS = [
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
419
|
+
512e3,
|
|
420
|
+
102400,
|
|
421
|
+
51200
|
|
402
422
|
];
|
|
403
423
|
const i = Math.min(attempt, GRACE_MS.length - 1);
|
|
404
424
|
return GRACE_MS[i] + Math.ceil(sizeBytes / RATE_BPS[i] * 1e3);
|
|
@@ -777,6 +797,7 @@ const KNOWN_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
777
797
|
"job.resources",
|
|
778
798
|
"job.metrics",
|
|
779
799
|
"job.context",
|
|
800
|
+
"job.preview",
|
|
780
801
|
"job.region_failover",
|
|
781
802
|
"balance.updated",
|
|
782
803
|
"subscription.updated",
|
|
@@ -876,6 +897,7 @@ function dispatchJobEvent(event, options) {
|
|
|
876
897
|
case "job.context":
|
|
877
898
|
options.onContext?.(event);
|
|
878
899
|
break;
|
|
900
|
+
case "job.preview": options.onPreview?.(event);
|
|
879
901
|
}
|
|
880
902
|
}
|
|
881
903
|
//#endregion
|