@rendobar/sdk 4.2.0 → 5.0.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 +13 -7
- package/dist/index.d.cts +71 -11
- package/dist/index.d.mts +71 -11
- package/dist/index.mjs +13 -7
- package/package.json +3 -2
package/dist/index.cjs
CHANGED
|
@@ -176,7 +176,7 @@ function isAbortError(error) {
|
|
|
176
176
|
}
|
|
177
177
|
//#endregion
|
|
178
178
|
//#region src/resources/jobs.ts
|
|
179
|
-
const
|
|
179
|
+
const TERMINAL_JOB_STATUSES$1 = /* @__PURE__ */ new Set([
|
|
180
180
|
"complete",
|
|
181
181
|
"failed",
|
|
182
182
|
"cancelled"
|
|
@@ -190,7 +190,7 @@ function createJobsResource(request) {
|
|
|
190
190
|
if (signal?.aborted) throw new DOMException("Wait aborted", "AbortError");
|
|
191
191
|
const job = await request(`/jobs/${id}`, { signal });
|
|
192
192
|
onProgress?.(job);
|
|
193
|
-
if (
|
|
193
|
+
if (TERMINAL_JOB_STATUSES$1.has(job.status)) return resolveTerminal(id, job, throwOnFailure);
|
|
194
194
|
const remaining = deadline - Date.now();
|
|
195
195
|
const delay = Math.min(currentInterval, remaining);
|
|
196
196
|
if (delay <= 0) break;
|
|
@@ -199,7 +199,7 @@ function createJobsResource(request) {
|
|
|
199
199
|
}
|
|
200
200
|
const job = await request(`/jobs/${id}`, { signal });
|
|
201
201
|
onProgress?.(job);
|
|
202
|
-
if (
|
|
202
|
+
if (TERMINAL_JOB_STATUSES$1.has(job.status)) return resolveTerminal(id, job, throwOnFailure);
|
|
203
203
|
throw new WaitTimeoutError(id, job.status, timeout);
|
|
204
204
|
}
|
|
205
205
|
async function create(params, options) {
|
|
@@ -762,7 +762,7 @@ const WS_OPTIONS = {
|
|
|
762
762
|
reconnectionDelayGrowFactor: 1.5,
|
|
763
763
|
maxRetries: Infinity
|
|
764
764
|
};
|
|
765
|
-
const
|
|
765
|
+
const TERMINAL_JOB_STATUSES = /* @__PURE__ */ new Set([
|
|
766
766
|
"complete",
|
|
767
767
|
"failed",
|
|
768
768
|
"cancelled"
|
|
@@ -775,8 +775,10 @@ const KNOWN_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
775
775
|
"job.progress",
|
|
776
776
|
"job.step",
|
|
777
777
|
"job.log",
|
|
778
|
+
"job.resources",
|
|
778
779
|
"job.metrics",
|
|
779
780
|
"job.context",
|
|
781
|
+
"job.region_failover",
|
|
780
782
|
"balance.updated",
|
|
781
783
|
"subscription.updated",
|
|
782
784
|
"notification",
|
|
@@ -859,15 +861,19 @@ function dispatchJobEvent(event, options) {
|
|
|
859
861
|
case "job.status": {
|
|
860
862
|
const statusEvent = event;
|
|
861
863
|
options.onStatus?.(statusEvent);
|
|
862
|
-
if (
|
|
864
|
+
if (TERMINAL_JOB_STATUSES.has(statusEvent.status)) options.onComplete?.(statusEvent);
|
|
863
865
|
break;
|
|
864
866
|
}
|
|
865
867
|
case "job.result":
|
|
866
868
|
options.onResult?.(event);
|
|
867
869
|
break;
|
|
868
|
-
case "job.
|
|
869
|
-
|
|
870
|
+
case "job.resources":
|
|
871
|
+
case "job.metrics": {
|
|
872
|
+
const e = event;
|
|
873
|
+
options.onResources?.(e);
|
|
874
|
+
options.onMetrics?.(e);
|
|
870
875
|
break;
|
|
876
|
+
}
|
|
871
877
|
case "job.context":
|
|
872
878
|
options.onContext?.(event);
|
|
873
879
|
break;
|
package/dist/index.d.cts
CHANGED
|
@@ -2246,6 +2246,11 @@ declare const jobErrorSchema: ZodObject<{
|
|
|
2246
2246
|
message: ZodString;
|
|
2247
2247
|
detail: ZodNullable<ZodString>;
|
|
2248
2248
|
retryable: ZodBoolean;
|
|
2249
|
+
failedPhase: ZodOptional<ZodEnum<{
|
|
2250
|
+
preparing: "preparing";
|
|
2251
|
+
processing: "processing";
|
|
2252
|
+
finalizing: "finalizing";
|
|
2253
|
+
}>>;
|
|
2249
2254
|
}, $strip>;
|
|
2250
2255
|
declare const jobCostSchema: ZodObject<{
|
|
2251
2256
|
amount: ZodNumber;
|
|
@@ -2287,7 +2292,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2287
2292
|
error: ZodOptional<ZodString>;
|
|
2288
2293
|
}, $strip>>;
|
|
2289
2294
|
logsAvailable: ZodBoolean;
|
|
2290
|
-
|
|
2295
|
+
resourcesAvailable: ZodBoolean;
|
|
2296
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2291
2297
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2292
2298
|
createdAt: ZodNumber;
|
|
2293
2299
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2331,7 +2337,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2331
2337
|
error: ZodOptional<ZodString>;
|
|
2332
2338
|
}, $strip>>;
|
|
2333
2339
|
logsAvailable: ZodBoolean;
|
|
2334
|
-
|
|
2340
|
+
resourcesAvailable: ZodBoolean;
|
|
2341
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2335
2342
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2336
2343
|
createdAt: ZodNumber;
|
|
2337
2344
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2340,7 +2347,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2340
2347
|
settledAt: ZodNullable<ZodNumber>;
|
|
2341
2348
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2342
2349
|
status: ZodLiteral<"dispatched">;
|
|
2343
|
-
progress: ZodOptional<ZodNumber
|
|
2350
|
+
progress: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2344
2351
|
eta: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2345
2352
|
}, $strip>, ZodObject<{
|
|
2346
2353
|
id: ZodString;
|
|
@@ -2377,7 +2384,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2377
2384
|
error: ZodOptional<ZodString>;
|
|
2378
2385
|
}, $strip>>;
|
|
2379
2386
|
logsAvailable: ZodBoolean;
|
|
2380
|
-
|
|
2387
|
+
resourcesAvailable: ZodBoolean;
|
|
2388
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2381
2389
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2382
2390
|
createdAt: ZodNumber;
|
|
2383
2391
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2386,7 +2394,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2386
2394
|
settledAt: ZodNullable<ZodNumber>;
|
|
2387
2395
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2388
2396
|
status: ZodLiteral<"running">;
|
|
2389
|
-
progress: ZodNumber
|
|
2397
|
+
progress: ZodNullable<ZodNumber>;
|
|
2390
2398
|
eta: ZodNullable<ZodNumber>;
|
|
2391
2399
|
}, $strip>, ZodObject<{
|
|
2392
2400
|
id: ZodString;
|
|
@@ -2423,7 +2431,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2423
2431
|
error: ZodOptional<ZodString>;
|
|
2424
2432
|
}, $strip>>;
|
|
2425
2433
|
logsAvailable: ZodBoolean;
|
|
2426
|
-
|
|
2434
|
+
resourcesAvailable: ZodBoolean;
|
|
2435
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2427
2436
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2428
2437
|
createdAt: ZodNumber;
|
|
2429
2438
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2511,7 +2520,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2511
2520
|
error: ZodOptional<ZodString>;
|
|
2512
2521
|
}, $strip>>;
|
|
2513
2522
|
logsAvailable: ZodBoolean;
|
|
2514
|
-
|
|
2523
|
+
resourcesAvailable: ZodBoolean;
|
|
2524
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2515
2525
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2516
2526
|
createdAt: ZodNumber;
|
|
2517
2527
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2525,6 +2535,11 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2525
2535
|
message: ZodString;
|
|
2526
2536
|
detail: ZodNullable<ZodString>;
|
|
2527
2537
|
retryable: ZodBoolean;
|
|
2538
|
+
failedPhase: ZodOptional<ZodEnum<{
|
|
2539
|
+
preparing: "preparing";
|
|
2540
|
+
processing: "processing";
|
|
2541
|
+
finalizing: "finalizing";
|
|
2542
|
+
}>>;
|
|
2528
2543
|
}, $strip>;
|
|
2529
2544
|
}, $strip>, ZodObject<{
|
|
2530
2545
|
id: ZodString;
|
|
@@ -2561,7 +2576,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2561
2576
|
error: ZodOptional<ZodString>;
|
|
2562
2577
|
}, $strip>>;
|
|
2563
2578
|
logsAvailable: ZodBoolean;
|
|
2564
|
-
|
|
2579
|
+
resourcesAvailable: ZodBoolean;
|
|
2580
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2565
2581
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2566
2582
|
createdAt: ZodNumber;
|
|
2567
2583
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2964,14 +2980,35 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2964
2980
|
type: ZodLiteral<"job.progress">;
|
|
2965
2981
|
jobId: ZodString;
|
|
2966
2982
|
timestamp: ZodNumber;
|
|
2967
|
-
progress: ZodNumber
|
|
2983
|
+
progress: ZodNullable<ZodNumber>;
|
|
2984
|
+
phase: ZodOptional<ZodEnum<{
|
|
2985
|
+
preparing: "preparing";
|
|
2986
|
+
processing: "processing";
|
|
2987
|
+
finalizing: "finalizing";
|
|
2988
|
+
}>>;
|
|
2968
2989
|
step: ZodString;
|
|
2969
2990
|
stepProgress: ZodOptional<ZodNumber>;
|
|
2970
2991
|
eta: ZodOptional<ZodNumber>;
|
|
2971
2992
|
metrics: ZodOptional<ZodRecord<ZodString, ZodUnion<readonly [ZodNumber, ZodString]>>>;
|
|
2972
2993
|
}, $strip>, ZodObject<{
|
|
2973
|
-
|
|
2994
|
+
timestamp: ZodNumber;
|
|
2995
|
+
cpuPct: ZodNumber;
|
|
2996
|
+
cpuCores: ZodNumber;
|
|
2997
|
+
allocatedCores: ZodOptional<ZodNumber>;
|
|
2998
|
+
memUsedMB: ZodNumber;
|
|
2999
|
+
memLimitMB: ZodNumber;
|
|
3000
|
+
diskRMBps: ZodOptional<ZodNumber>;
|
|
3001
|
+
diskWMBps: ZodOptional<ZodNumber>;
|
|
3002
|
+
netRxMBps: ZodOptional<ZodNumber>;
|
|
3003
|
+
netTxMBps: ZodOptional<ZodNumber>;
|
|
3004
|
+
gpuPct: ZodOptional<ZodNumber>;
|
|
3005
|
+
gpuMemUsedMB: ZodOptional<ZodNumber>;
|
|
3006
|
+
gpuMemTotalMB: ZodOptional<ZodNumber>;
|
|
3007
|
+
gpuTempC: ZodOptional<ZodNumber>;
|
|
3008
|
+
gpuPowerW: ZodOptional<ZodNumber>;
|
|
3009
|
+
type: ZodLiteral<"job.resources">;
|
|
2974
3010
|
jobId: ZodString;
|
|
3011
|
+
}, $strip>, ZodObject<{
|
|
2975
3012
|
timestamp: ZodNumber;
|
|
2976
3013
|
cpuPct: ZodNumber;
|
|
2977
3014
|
cpuCores: ZodNumber;
|
|
@@ -2982,6 +3019,13 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2982
3019
|
diskWMBps: ZodOptional<ZodNumber>;
|
|
2983
3020
|
netRxMBps: ZodOptional<ZodNumber>;
|
|
2984
3021
|
netTxMBps: ZodOptional<ZodNumber>;
|
|
3022
|
+
gpuPct: ZodOptional<ZodNumber>;
|
|
3023
|
+
gpuMemUsedMB: ZodOptional<ZodNumber>;
|
|
3024
|
+
gpuMemTotalMB: ZodOptional<ZodNumber>;
|
|
3025
|
+
gpuTempC: ZodOptional<ZodNumber>;
|
|
3026
|
+
gpuPowerW: ZodOptional<ZodNumber>;
|
|
3027
|
+
type: ZodLiteral<"job.metrics">;
|
|
3028
|
+
jobId: ZodString;
|
|
2985
3029
|
}, $strip>, ZodObject<{
|
|
2986
3030
|
type: ZodLiteral<"job.step">;
|
|
2987
3031
|
jobId: ZodString;
|
|
@@ -3518,9 +3562,19 @@ interface RealtimeConnection {
|
|
|
3518
3562
|
disconnect: () => void;
|
|
3519
3563
|
}
|
|
3520
3564
|
interface JobSubscribeOptions {
|
|
3565
|
+
/**
|
|
3566
|
+
* Overall progress. Build your UI on `event.phase` (stable: preparing |
|
|
3567
|
+
* processing | finalizing) and `event.progress`. `event.step` is the internal
|
|
3568
|
+
* step id — implementation detail, prefer `phase`.
|
|
3569
|
+
*/
|
|
3521
3570
|
onProgress?: (event: Extract<OrgEvent, {
|
|
3522
3571
|
type: "job.progress";
|
|
3523
3572
|
}>) => void;
|
|
3573
|
+
/**
|
|
3574
|
+
* @deprecated Internal step transitions leak pipeline detail and vary by job
|
|
3575
|
+
* type. Use `onProgress` (it carries `phase`, and `step` when you need it).
|
|
3576
|
+
* Kept for the dashboard Trace/debug view; not recommended for app UIs.
|
|
3577
|
+
*/
|
|
3524
3578
|
onStep?: (event: Extract<OrgEvent, {
|
|
3525
3579
|
type: "job.step";
|
|
3526
3580
|
}>) => void;
|
|
@@ -3536,8 +3590,14 @@ interface JobSubscribeOptions {
|
|
|
3536
3590
|
onComplete?: (event: Extract<OrgEvent, {
|
|
3537
3591
|
type: "job.status";
|
|
3538
3592
|
}>) => void;
|
|
3593
|
+
/** Container resource utilization (CPU, memory, disk, network, GPU). */
|
|
3594
|
+
onResources?: (event: Extract<OrgEvent, {
|
|
3595
|
+
type: "job.resources";
|
|
3596
|
+
}>) => void;
|
|
3597
|
+
/** @deprecated renamed to onResources. Still fires for both event names.
|
|
3598
|
+
* Remove at the next SDK major — tracked in docs/DEPRECATIONS.md (Group A). */
|
|
3539
3599
|
onMetrics?: (event: Extract<OrgEvent, {
|
|
3540
|
-
type: "job.
|
|
3600
|
+
type: "job.resources";
|
|
3541
3601
|
}>) => void;
|
|
3542
3602
|
onContext?: (event: Extract<OrgEvent, {
|
|
3543
3603
|
type: "job.context";
|
package/dist/index.d.mts
CHANGED
|
@@ -2246,6 +2246,11 @@ declare const jobErrorSchema: ZodObject<{
|
|
|
2246
2246
|
message: ZodString;
|
|
2247
2247
|
detail: ZodNullable<ZodString>;
|
|
2248
2248
|
retryable: ZodBoolean;
|
|
2249
|
+
failedPhase: ZodOptional<ZodEnum<{
|
|
2250
|
+
preparing: "preparing";
|
|
2251
|
+
processing: "processing";
|
|
2252
|
+
finalizing: "finalizing";
|
|
2253
|
+
}>>;
|
|
2249
2254
|
}, $strip>;
|
|
2250
2255
|
declare const jobCostSchema: ZodObject<{
|
|
2251
2256
|
amount: ZodNumber;
|
|
@@ -2287,7 +2292,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2287
2292
|
error: ZodOptional<ZodString>;
|
|
2288
2293
|
}, $strip>>;
|
|
2289
2294
|
logsAvailable: ZodBoolean;
|
|
2290
|
-
|
|
2295
|
+
resourcesAvailable: ZodBoolean;
|
|
2296
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2291
2297
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2292
2298
|
createdAt: ZodNumber;
|
|
2293
2299
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2331,7 +2337,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2331
2337
|
error: ZodOptional<ZodString>;
|
|
2332
2338
|
}, $strip>>;
|
|
2333
2339
|
logsAvailable: ZodBoolean;
|
|
2334
|
-
|
|
2340
|
+
resourcesAvailable: ZodBoolean;
|
|
2341
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2335
2342
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2336
2343
|
createdAt: ZodNumber;
|
|
2337
2344
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2340,7 +2347,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2340
2347
|
settledAt: ZodNullable<ZodNumber>;
|
|
2341
2348
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2342
2349
|
status: ZodLiteral<"dispatched">;
|
|
2343
|
-
progress: ZodOptional<ZodNumber
|
|
2350
|
+
progress: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2344
2351
|
eta: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2345
2352
|
}, $strip>, ZodObject<{
|
|
2346
2353
|
id: ZodString;
|
|
@@ -2377,7 +2384,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2377
2384
|
error: ZodOptional<ZodString>;
|
|
2378
2385
|
}, $strip>>;
|
|
2379
2386
|
logsAvailable: ZodBoolean;
|
|
2380
|
-
|
|
2387
|
+
resourcesAvailable: ZodBoolean;
|
|
2388
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2381
2389
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2382
2390
|
createdAt: ZodNumber;
|
|
2383
2391
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2386,7 +2394,7 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2386
2394
|
settledAt: ZodNullable<ZodNumber>;
|
|
2387
2395
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2388
2396
|
status: ZodLiteral<"running">;
|
|
2389
|
-
progress: ZodNumber
|
|
2397
|
+
progress: ZodNullable<ZodNumber>;
|
|
2390
2398
|
eta: ZodNullable<ZodNumber>;
|
|
2391
2399
|
}, $strip>, ZodObject<{
|
|
2392
2400
|
id: ZodString;
|
|
@@ -2423,7 +2431,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2423
2431
|
error: ZodOptional<ZodString>;
|
|
2424
2432
|
}, $strip>>;
|
|
2425
2433
|
logsAvailable: ZodBoolean;
|
|
2426
|
-
|
|
2434
|
+
resourcesAvailable: ZodBoolean;
|
|
2435
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2427
2436
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2428
2437
|
createdAt: ZodNumber;
|
|
2429
2438
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2511,7 +2520,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2511
2520
|
error: ZodOptional<ZodString>;
|
|
2512
2521
|
}, $strip>>;
|
|
2513
2522
|
logsAvailable: ZodBoolean;
|
|
2514
|
-
|
|
2523
|
+
resourcesAvailable: ZodBoolean;
|
|
2524
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2515
2525
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2516
2526
|
createdAt: ZodNumber;
|
|
2517
2527
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2525,6 +2535,11 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2525
2535
|
message: ZodString;
|
|
2526
2536
|
detail: ZodNullable<ZodString>;
|
|
2527
2537
|
retryable: ZodBoolean;
|
|
2538
|
+
failedPhase: ZodOptional<ZodEnum<{
|
|
2539
|
+
preparing: "preparing";
|
|
2540
|
+
processing: "processing";
|
|
2541
|
+
finalizing: "finalizing";
|
|
2542
|
+
}>>;
|
|
2528
2543
|
}, $strip>;
|
|
2529
2544
|
}, $strip>, ZodObject<{
|
|
2530
2545
|
id: ZodString;
|
|
@@ -2561,7 +2576,8 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2561
2576
|
error: ZodOptional<ZodString>;
|
|
2562
2577
|
}, $strip>>;
|
|
2563
2578
|
logsAvailable: ZodBoolean;
|
|
2564
|
-
|
|
2579
|
+
resourcesAvailable: ZodBoolean;
|
|
2580
|
+
metricsAvailable: ZodOptional<ZodBoolean>;
|
|
2565
2581
|
region: ZodOptional<ZodNullable<ZodString>>;
|
|
2566
2582
|
createdAt: ZodNumber;
|
|
2567
2583
|
dispatchedAt: ZodNullable<ZodNumber>;
|
|
@@ -2964,14 +2980,35 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2964
2980
|
type: ZodLiteral<"job.progress">;
|
|
2965
2981
|
jobId: ZodString;
|
|
2966
2982
|
timestamp: ZodNumber;
|
|
2967
|
-
progress: ZodNumber
|
|
2983
|
+
progress: ZodNullable<ZodNumber>;
|
|
2984
|
+
phase: ZodOptional<ZodEnum<{
|
|
2985
|
+
preparing: "preparing";
|
|
2986
|
+
processing: "processing";
|
|
2987
|
+
finalizing: "finalizing";
|
|
2988
|
+
}>>;
|
|
2968
2989
|
step: ZodString;
|
|
2969
2990
|
stepProgress: ZodOptional<ZodNumber>;
|
|
2970
2991
|
eta: ZodOptional<ZodNumber>;
|
|
2971
2992
|
metrics: ZodOptional<ZodRecord<ZodString, ZodUnion<readonly [ZodNumber, ZodString]>>>;
|
|
2972
2993
|
}, $strip>, ZodObject<{
|
|
2973
|
-
|
|
2994
|
+
timestamp: ZodNumber;
|
|
2995
|
+
cpuPct: ZodNumber;
|
|
2996
|
+
cpuCores: ZodNumber;
|
|
2997
|
+
allocatedCores: ZodOptional<ZodNumber>;
|
|
2998
|
+
memUsedMB: ZodNumber;
|
|
2999
|
+
memLimitMB: ZodNumber;
|
|
3000
|
+
diskRMBps: ZodOptional<ZodNumber>;
|
|
3001
|
+
diskWMBps: ZodOptional<ZodNumber>;
|
|
3002
|
+
netRxMBps: ZodOptional<ZodNumber>;
|
|
3003
|
+
netTxMBps: ZodOptional<ZodNumber>;
|
|
3004
|
+
gpuPct: ZodOptional<ZodNumber>;
|
|
3005
|
+
gpuMemUsedMB: ZodOptional<ZodNumber>;
|
|
3006
|
+
gpuMemTotalMB: ZodOptional<ZodNumber>;
|
|
3007
|
+
gpuTempC: ZodOptional<ZodNumber>;
|
|
3008
|
+
gpuPowerW: ZodOptional<ZodNumber>;
|
|
3009
|
+
type: ZodLiteral<"job.resources">;
|
|
2974
3010
|
jobId: ZodString;
|
|
3011
|
+
}, $strip>, ZodObject<{
|
|
2975
3012
|
timestamp: ZodNumber;
|
|
2976
3013
|
cpuPct: ZodNumber;
|
|
2977
3014
|
cpuCores: ZodNumber;
|
|
@@ -2982,6 +3019,13 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2982
3019
|
diskWMBps: ZodOptional<ZodNumber>;
|
|
2983
3020
|
netRxMBps: ZodOptional<ZodNumber>;
|
|
2984
3021
|
netTxMBps: ZodOptional<ZodNumber>;
|
|
3022
|
+
gpuPct: ZodOptional<ZodNumber>;
|
|
3023
|
+
gpuMemUsedMB: ZodOptional<ZodNumber>;
|
|
3024
|
+
gpuMemTotalMB: ZodOptional<ZodNumber>;
|
|
3025
|
+
gpuTempC: ZodOptional<ZodNumber>;
|
|
3026
|
+
gpuPowerW: ZodOptional<ZodNumber>;
|
|
3027
|
+
type: ZodLiteral<"job.metrics">;
|
|
3028
|
+
jobId: ZodString;
|
|
2985
3029
|
}, $strip>, ZodObject<{
|
|
2986
3030
|
type: ZodLiteral<"job.step">;
|
|
2987
3031
|
jobId: ZodString;
|
|
@@ -3518,9 +3562,19 @@ interface RealtimeConnection {
|
|
|
3518
3562
|
disconnect: () => void;
|
|
3519
3563
|
}
|
|
3520
3564
|
interface JobSubscribeOptions {
|
|
3565
|
+
/**
|
|
3566
|
+
* Overall progress. Build your UI on `event.phase` (stable: preparing |
|
|
3567
|
+
* processing | finalizing) and `event.progress`. `event.step` is the internal
|
|
3568
|
+
* step id — implementation detail, prefer `phase`.
|
|
3569
|
+
*/
|
|
3521
3570
|
onProgress?: (event: Extract<OrgEvent, {
|
|
3522
3571
|
type: "job.progress";
|
|
3523
3572
|
}>) => void;
|
|
3573
|
+
/**
|
|
3574
|
+
* @deprecated Internal step transitions leak pipeline detail and vary by job
|
|
3575
|
+
* type. Use `onProgress` (it carries `phase`, and `step` when you need it).
|
|
3576
|
+
* Kept for the dashboard Trace/debug view; not recommended for app UIs.
|
|
3577
|
+
*/
|
|
3524
3578
|
onStep?: (event: Extract<OrgEvent, {
|
|
3525
3579
|
type: "job.step";
|
|
3526
3580
|
}>) => void;
|
|
@@ -3536,8 +3590,14 @@ interface JobSubscribeOptions {
|
|
|
3536
3590
|
onComplete?: (event: Extract<OrgEvent, {
|
|
3537
3591
|
type: "job.status";
|
|
3538
3592
|
}>) => void;
|
|
3593
|
+
/** Container resource utilization (CPU, memory, disk, network, GPU). */
|
|
3594
|
+
onResources?: (event: Extract<OrgEvent, {
|
|
3595
|
+
type: "job.resources";
|
|
3596
|
+
}>) => void;
|
|
3597
|
+
/** @deprecated renamed to onResources. Still fires for both event names.
|
|
3598
|
+
* Remove at the next SDK major — tracked in docs/DEPRECATIONS.md (Group A). */
|
|
3539
3599
|
onMetrics?: (event: Extract<OrgEvent, {
|
|
3540
|
-
type: "job.
|
|
3600
|
+
type: "job.resources";
|
|
3541
3601
|
}>) => void;
|
|
3542
3602
|
onContext?: (event: Extract<OrgEvent, {
|
|
3543
3603
|
type: "job.context";
|
package/dist/index.mjs
CHANGED
|
@@ -175,7 +175,7 @@ function isAbortError(error) {
|
|
|
175
175
|
}
|
|
176
176
|
//#endregion
|
|
177
177
|
//#region src/resources/jobs.ts
|
|
178
|
-
const
|
|
178
|
+
const TERMINAL_JOB_STATUSES$1 = /* @__PURE__ */ new Set([
|
|
179
179
|
"complete",
|
|
180
180
|
"failed",
|
|
181
181
|
"cancelled"
|
|
@@ -189,7 +189,7 @@ function createJobsResource(request) {
|
|
|
189
189
|
if (signal?.aborted) throw new DOMException("Wait aborted", "AbortError");
|
|
190
190
|
const job = await request(`/jobs/${id}`, { signal });
|
|
191
191
|
onProgress?.(job);
|
|
192
|
-
if (
|
|
192
|
+
if (TERMINAL_JOB_STATUSES$1.has(job.status)) return resolveTerminal(id, job, throwOnFailure);
|
|
193
193
|
const remaining = deadline - Date.now();
|
|
194
194
|
const delay = Math.min(currentInterval, remaining);
|
|
195
195
|
if (delay <= 0) break;
|
|
@@ -198,7 +198,7 @@ function createJobsResource(request) {
|
|
|
198
198
|
}
|
|
199
199
|
const job = await request(`/jobs/${id}`, { signal });
|
|
200
200
|
onProgress?.(job);
|
|
201
|
-
if (
|
|
201
|
+
if (TERMINAL_JOB_STATUSES$1.has(job.status)) return resolveTerminal(id, job, throwOnFailure);
|
|
202
202
|
throw new WaitTimeoutError(id, job.status, timeout);
|
|
203
203
|
}
|
|
204
204
|
async function create(params, options) {
|
|
@@ -761,7 +761,7 @@ const WS_OPTIONS = {
|
|
|
761
761
|
reconnectionDelayGrowFactor: 1.5,
|
|
762
762
|
maxRetries: Infinity
|
|
763
763
|
};
|
|
764
|
-
const
|
|
764
|
+
const TERMINAL_JOB_STATUSES = /* @__PURE__ */ new Set([
|
|
765
765
|
"complete",
|
|
766
766
|
"failed",
|
|
767
767
|
"cancelled"
|
|
@@ -774,8 +774,10 @@ const KNOWN_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
774
774
|
"job.progress",
|
|
775
775
|
"job.step",
|
|
776
776
|
"job.log",
|
|
777
|
+
"job.resources",
|
|
777
778
|
"job.metrics",
|
|
778
779
|
"job.context",
|
|
780
|
+
"job.region_failover",
|
|
779
781
|
"balance.updated",
|
|
780
782
|
"subscription.updated",
|
|
781
783
|
"notification",
|
|
@@ -858,15 +860,19 @@ function dispatchJobEvent(event, options) {
|
|
|
858
860
|
case "job.status": {
|
|
859
861
|
const statusEvent = event;
|
|
860
862
|
options.onStatus?.(statusEvent);
|
|
861
|
-
if (
|
|
863
|
+
if (TERMINAL_JOB_STATUSES.has(statusEvent.status)) options.onComplete?.(statusEvent);
|
|
862
864
|
break;
|
|
863
865
|
}
|
|
864
866
|
case "job.result":
|
|
865
867
|
options.onResult?.(event);
|
|
866
868
|
break;
|
|
867
|
-
case "job.
|
|
868
|
-
|
|
869
|
+
case "job.resources":
|
|
870
|
+
case "job.metrics": {
|
|
871
|
+
const e = event;
|
|
872
|
+
options.onResources?.(e);
|
|
873
|
+
options.onMetrics?.(e);
|
|
869
874
|
break;
|
|
875
|
+
}
|
|
870
876
|
case "job.context":
|
|
871
877
|
options.onContext?.(event);
|
|
872
878
|
break;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rendobar/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TypeScript client for the Rendobar media processing API",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"build": "tsdown",
|
|
35
35
|
"typecheck": "tsc --noEmit",
|
|
36
36
|
"test": "vitest run",
|
|
37
|
-
"test:watch": "vitest"
|
|
37
|
+
"test:watch": "vitest",
|
|
38
|
+
"test:live": "vitest run src/__tests__/live"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
41
|
"partysocket": "^1.1.16"
|