@nodaro/sdk 1.26.0 → 1.28.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 +40 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +174 -6
- package/dist/index.d.ts +174 -6
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -70,6 +70,12 @@ var WorkflowConflictError = class extends NodaroError {
|
|
|
70
70
|
currentVersion;
|
|
71
71
|
currentRecord;
|
|
72
72
|
};
|
|
73
|
+
var JobBlockedError = class extends NodaroError {
|
|
74
|
+
constructor(message = "Blocked by this deployment's content policy") {
|
|
75
|
+
super(message, "job_blocked", 422);
|
|
76
|
+
this.name = "JobBlockedError";
|
|
77
|
+
}
|
|
78
|
+
};
|
|
73
79
|
var JobFailedError = class extends NodaroError {
|
|
74
80
|
constructor(message, jobId, jobStatus = "failed") {
|
|
75
81
|
super(message, "job_failed", 0);
|
|
@@ -98,6 +104,14 @@ var JobAbortedError = class extends NodaroError {
|
|
|
98
104
|
}
|
|
99
105
|
jobId;
|
|
100
106
|
};
|
|
107
|
+
var JobHeldError = class extends NodaroError {
|
|
108
|
+
constructor(message, jobId) {
|
|
109
|
+
super(message, "job_held", 0);
|
|
110
|
+
this.jobId = jobId;
|
|
111
|
+
this.name = "JobHeldError";
|
|
112
|
+
}
|
|
113
|
+
jobId;
|
|
114
|
+
};
|
|
101
115
|
function throwFromResponse(status, body) {
|
|
102
116
|
const code = body.error?.code ?? "internal_error";
|
|
103
117
|
const message = body.error?.message ?? "Request failed";
|
|
@@ -110,6 +124,7 @@ function throwFromResponse(status, body) {
|
|
|
110
124
|
body.error?.currentRecord
|
|
111
125
|
);
|
|
112
126
|
}
|
|
127
|
+
if (status === 422 && code === "job_blocked") throw new JobBlockedError(message);
|
|
113
128
|
if (status === 403 && code === "insufficient_scope") {
|
|
114
129
|
throw new ForbiddenError(message, body.error?.missingScope);
|
|
115
130
|
}
|
|
@@ -361,6 +376,18 @@ var JobsResource = class {
|
|
|
361
376
|
`/v1/jobs/${encodeURIComponent(id)}/cancel`
|
|
362
377
|
);
|
|
363
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Delete a job and the private media it produced. Server route is
|
|
381
|
+
* `DELETE /v1/jobs/:jobId`. Only the job's owner (or an admin) may delete it;
|
|
382
|
+
* a job that is still running is deleted as-is — cancel it first when its
|
|
383
|
+
* worker should stop ({@link cancel}).
|
|
384
|
+
*/
|
|
385
|
+
delete(id) {
|
|
386
|
+
return this.client.request(
|
|
387
|
+
"DELETE",
|
|
388
|
+
`/v1/jobs/${encodeURIComponent(id)}`
|
|
389
|
+
);
|
|
390
|
+
}
|
|
364
391
|
};
|
|
365
392
|
|
|
366
393
|
// src/resources/video-pro.ts
|
|
@@ -479,8 +506,9 @@ var NodesResource = class {
|
|
|
479
506
|
* the candidate-grid path (generate N stills/clips in parallel). Each runs
|
|
480
507
|
* via {@link runAndWait}; resolves once ALL settle, to an array of
|
|
481
508
|
* `{ jobId, output }` in input order. Rejects (and the rejection wins) if any
|
|
482
|
-
* single run rejects — same typed errors as {@link runAndWait}
|
|
483
|
-
*
|
|
509
|
+
* single run rejects — same typed errors as {@link runAndWait}, including
|
|
510
|
+
* {@link JobHeldError} when one candidate is held for review while the
|
|
511
|
+
* others complete. A shared `signal` aborts the whole batch.
|
|
484
512
|
*
|
|
485
513
|
* @param type Node type slug, applied to every entry.
|
|
486
514
|
* @param paramsList One request body per candidate.
|
|
@@ -498,7 +526,10 @@ var NodesResource = class {
|
|
|
498
526
|
})
|
|
499
527
|
);
|
|
500
528
|
}
|
|
501
|
-
/** Poll an already-kicked job id until
|
|
529
|
+
/** Poll an already-kicked job id until it stops moving; resolve output_data
|
|
530
|
+
* or throw. Two non-terminal statuses end the loop: an abort, and
|
|
531
|
+
* `pending_review` (a job policy held the output for a human — see
|
|
532
|
+
* {@link JobHeldError}). */
|
|
502
533
|
async pollJob(jobId, label, opts) {
|
|
503
534
|
const pollMs = opts.pollMs ?? DEFAULT_POLL_MS;
|
|
504
535
|
const maxMs = opts.maxMs ?? DEFAULT_MAX_MS;
|
|
@@ -517,6 +548,9 @@ var NodesResource = class {
|
|
|
517
548
|
data.status
|
|
518
549
|
);
|
|
519
550
|
}
|
|
551
|
+
if (data.status === "pending_review") {
|
|
552
|
+
throw new JobHeldError(`${label} is awaiting review`, jobId);
|
|
553
|
+
}
|
|
520
554
|
if (Date.now() > deadline) {
|
|
521
555
|
throw new JobTimeoutError(`${label} timed out`, jobId, maxMs);
|
|
522
556
|
}
|
|
@@ -2718,7 +2752,7 @@ var WorkspacesResource = class {
|
|
|
2718
2752
|
return this.client.requestText("GET", `/v1/workspaces/${encodeURIComponent(id)}/usage`, { query: { ...opts, format: "csv" } });
|
|
2719
2753
|
}
|
|
2720
2754
|
};
|
|
2721
|
-
var SDK_VERSION = "1.
|
|
2755
|
+
var SDK_VERSION = "1.28.0" ;
|
|
2722
2756
|
var CLIENT_HEADER = "X-Nodaro-Client";
|
|
2723
2757
|
var isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
2724
2758
|
var NodaroClient = class _NodaroClient {
|
|
@@ -3064,7 +3098,9 @@ exports.ExecutionsResource = ExecutionsResource;
|
|
|
3064
3098
|
exports.ForbiddenError = ForbiddenError;
|
|
3065
3099
|
exports.InsufficientCreditsError = InsufficientCreditsError;
|
|
3066
3100
|
exports.JobAbortedError = JobAbortedError;
|
|
3101
|
+
exports.JobBlockedError = JobBlockedError;
|
|
3067
3102
|
exports.JobFailedError = JobFailedError;
|
|
3103
|
+
exports.JobHeldError = JobHeldError;
|
|
3068
3104
|
exports.JobTimeoutError = JobTimeoutError;
|
|
3069
3105
|
exports.JobsResource = JobsResource;
|
|
3070
3106
|
exports.LibraryResource = LibraryResource;
|