@rendobar/sdk 1.0.0 → 2.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/README.md +38 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +51 -14
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +51 -14
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -99,6 +99,44 @@ const logs = await client.jobs.logs("job_abc");
|
|
|
99
99
|
const types = await client.jobs.types();
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
+
## Raw FFmpeg
|
|
103
|
+
|
|
104
|
+
Run arbitrary FFmpeg commands in a sandboxed container. Commands are parsed, sanitized (protocol whitelist/blacklist flags blocked), and executed with a clean process environment.
|
|
105
|
+
|
|
106
|
+
Put input URLs directly in `-i` positions — they're extracted automatically and staged via presigned R2 URLs before execution:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
import { createClient } from "@rendobar/sdk";
|
|
110
|
+
|
|
111
|
+
const client = createClient({ apiKey: process.env.RENDOBAR_API_KEY });
|
|
112
|
+
|
|
113
|
+
const job = await client.jobs.create({
|
|
114
|
+
type: "raw.ffmpeg",
|
|
115
|
+
params: {
|
|
116
|
+
command:
|
|
117
|
+
"ffmpeg -i https://cdn.example.com/source.mp4 " +
|
|
118
|
+
"-vf scale=1280:720 -c:v libx264 -crf 23 output.mp4",
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const done = await client.jobs.wait(job.id);
|
|
123
|
+
console.log(done.outputUrl);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Prefer named inputs? Pass them in the top-level `inputs` map and reference the keys in the command:
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
await client.jobs.create({
|
|
130
|
+
type: "raw.ffmpeg",
|
|
131
|
+
inputs: { source: "https://cdn.example.com/source.mp4" },
|
|
132
|
+
params: { command: "ffmpeg -i source -vf scale=1280:720 output.mp4" },
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Need a typed params object? Import `RawFfmpegParams` — optional fields (`outputFormat`, `timeout`) have server-side defaults.
|
|
137
|
+
|
|
138
|
+
See the [FFmpeg guide](https://rendobar.com/docs/guides/raw-ffmpeg) for the full security model and supported flags.
|
|
139
|
+
|
|
102
140
|
## Billing
|
|
103
141
|
|
|
104
142
|
```typescript
|
package/dist/index.cjs
CHANGED
|
@@ -214,6 +214,9 @@ function createJobsResource(request) {
|
|
|
214
214
|
async logs(id, options) {
|
|
215
215
|
return request(`/jobs/${id}/logs`, { signal: options?.signal });
|
|
216
216
|
},
|
|
217
|
+
async getTimings(id, options) {
|
|
218
|
+
return request(`/jobs/${id}/timings`, { signal: options?.signal });
|
|
219
|
+
},
|
|
217
220
|
async types(options) {
|
|
218
221
|
return request("/jobs/types", { signal: options?.signal });
|
|
219
222
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -2114,11 +2114,11 @@ declare const jobResponseSchema: ZodObject<{
|
|
|
2114
2114
|
orgId: ZodString;
|
|
2115
2115
|
type: ZodString;
|
|
2116
2116
|
status: ZodString;
|
|
2117
|
-
aiPattern: ZodNullable<ZodString>;
|
|
2118
2117
|
inputs: ZodRecord<ZodString, ZodUnknown>;
|
|
2119
2118
|
params: ZodRecord<ZodString, ZodUnknown>;
|
|
2120
2119
|
outputRef: ZodNullable<ZodString>;
|
|
2121
2120
|
outputUrl: ZodNullable<ZodString>;
|
|
2121
|
+
posterUrl: ZodNullable<ZodString>;
|
|
2122
2122
|
outputMeta: ZodNullable<ZodRecord<ZodString, ZodUnknown>>;
|
|
2123
2123
|
errorCode: ZodNullable<ZodString>;
|
|
2124
2124
|
errorMessage: ZodNullable<ZodString>;
|
|
@@ -2147,18 +2147,7 @@ declare const jobResponseSchema: ZodObject<{
|
|
|
2147
2147
|
logsAvailable: ZodBoolean;
|
|
2148
2148
|
providerType: ZodNullable<ZodString>;
|
|
2149
2149
|
providerRunId: ZodNullable<ZodString>;
|
|
2150
|
-
apiTotalMs: ZodNullable<ZodNumber>;
|
|
2151
|
-
apiPrechecksMs: ZodNullable<ZodNumber>;
|
|
2152
|
-
apiValidationMs: ZodNullable<ZodNumber>;
|
|
2153
|
-
apiDbInsertMs: ZodNullable<ZodNumber>;
|
|
2154
|
-
apiDispatchMs: ZodNullable<ZodNumber>;
|
|
2155
|
-
execDownloadMs: ZodNullable<ZodNumber>;
|
|
2156
|
-
execExecuteMs: ZodNullable<ZodNumber>;
|
|
2157
|
-
execUploadMs: ZodNullable<ZodNumber>;
|
|
2158
|
-
queueWaitMs: ZodNullable<ZodNumber>;
|
|
2159
|
-
consumerTotalMs: ZodNullable<ZodNumber>;
|
|
2160
2150
|
settledAt: ZodNullable<ZodNumber>;
|
|
2161
|
-
execTotalMs: ZodNullable<ZodNumber>;
|
|
2162
2151
|
}, $strip>;
|
|
2163
2152
|
declare const jobCreatedResponseSchema: ZodObject<{
|
|
2164
2153
|
id: ZodString;
|
|
@@ -2436,6 +2425,28 @@ interface LogEntryData {
|
|
|
2436
2425
|
meta?: Record<string, unknown>;
|
|
2437
2426
|
}
|
|
2438
2427
|
//#endregion
|
|
2428
|
+
//#region src/types.d.ts
|
|
2429
|
+
/**
|
|
2430
|
+
* Per-job execution timing breakdown. Returned by `client.jobs.getTimings(id)`.
|
|
2431
|
+
*
|
|
2432
|
+
* All values are milliseconds, or `null` if the corresponding stage did not
|
|
2433
|
+
* execute (e.g. a sync-completed job has no executor or queue timings).
|
|
2434
|
+
*/
|
|
2435
|
+
interface JobTimings {
|
|
2436
|
+
jobId: string;
|
|
2437
|
+
apiTotalMs: number | null;
|
|
2438
|
+
apiPrechecksMs: number | null;
|
|
2439
|
+
apiValidationMs: number | null;
|
|
2440
|
+
apiDbInsertMs: number | null;
|
|
2441
|
+
apiDispatchMs: number | null;
|
|
2442
|
+
execDownloadMs: number | null;
|
|
2443
|
+
execExecuteMs: number | null;
|
|
2444
|
+
execUploadMs: number | null;
|
|
2445
|
+
execTotalMs: number | null;
|
|
2446
|
+
queueWaitMs: number | null;
|
|
2447
|
+
consumerTotalMs: number | null;
|
|
2448
|
+
}
|
|
2449
|
+
//#endregion
|
|
2439
2450
|
//#region src/client.d.ts
|
|
2440
2451
|
interface ClientConfig {
|
|
2441
2452
|
/** API key (Bearer rb_...). Mutually exclusive with credentials. */
|
|
@@ -2479,6 +2490,9 @@ declare function createClient(config?: ClientConfig): {
|
|
|
2479
2490
|
logs(id: string, options?: {
|
|
2480
2491
|
signal?: AbortSignal;
|
|
2481
2492
|
}): Promise<LogEntryData[]>;
|
|
2493
|
+
getTimings(id: string, options?: {
|
|
2494
|
+
signal?: AbortSignal;
|
|
2495
|
+
}): Promise<JobTimings>;
|
|
2482
2496
|
types(options?: {
|
|
2483
2497
|
signal?: AbortSignal;
|
|
2484
2498
|
}): Promise<JobType[]>;
|
|
@@ -2734,6 +2748,30 @@ interface JobSubscription {
|
|
|
2734
2748
|
unsubscribe: () => void;
|
|
2735
2749
|
}
|
|
2736
2750
|
//#endregion
|
|
2751
|
+
//#region src/jobs/raw-ffmpeg.d.ts
|
|
2752
|
+
/**
|
|
2753
|
+
* Public params type for the `raw.ffmpeg` job.
|
|
2754
|
+
*
|
|
2755
|
+
* Declared as a plain interface here (rather than re-exported from
|
|
2756
|
+
* `@rendobar/shared`) so the SDK's dts bundler does not have to follow
|
|
2757
|
+
* the shared package's full job-registry type graph — that graph pulls
|
|
2758
|
+
* pipelines, templates, and every job definition into the .d.ts output
|
|
2759
|
+
* and causes tsdown to OOM.
|
|
2760
|
+
*
|
|
2761
|
+
* The canonical runtime shape is the Zod schema in
|
|
2762
|
+
* `packages/shared/src/jobs/definitions/raw-ffmpeg.job.ts` — keep this
|
|
2763
|
+
* interface in sync with it. Optional fields match `.default(...)`
|
|
2764
|
+
* semantics on the schema side.
|
|
2765
|
+
*/
|
|
2766
|
+
interface RawFfmpegParams {
|
|
2767
|
+
/** Raw FFmpeg command. The leading "ffmpeg" is stripped if present. */
|
|
2768
|
+
command: string;
|
|
2769
|
+
/** Output container/format. Inferred from the trailing filename if omitted. */
|
|
2770
|
+
outputFormat?: "mp4" | "mkv" | "webm" | "mov" | "avi" | "ts" | "gif" | "png" | "jpg" | "mp3" | "wav" | "flac" | "ogg" | "aac" | "opus" | "m4a" | "srt" | "vtt";
|
|
2771
|
+
/** Maximum execution time in seconds (1 - 900). Defaults to 120. */
|
|
2772
|
+
timeout?: number;
|
|
2773
|
+
}
|
|
2774
|
+
//#endregion
|
|
2737
2775
|
//#region src/resources/jobs.d.ts
|
|
2738
2776
|
type CreateJobParams = {
|
|
2739
2777
|
type: string;
|
|
@@ -2811,7 +2849,6 @@ type OrgCurrentResponse = {
|
|
|
2811
2849
|
};
|
|
2812
2850
|
balance: {
|
|
2813
2851
|
balance: number;
|
|
2814
|
-
rollover: number;
|
|
2815
2852
|
balanceFormatted: string;
|
|
2816
2853
|
};
|
|
2817
2854
|
};
|
|
@@ -2847,5 +2884,5 @@ type Asset = {
|
|
|
2847
2884
|
updatedAt: number;
|
|
2848
2885
|
};
|
|
2849
2886
|
//#endregion
|
|
2850
|
-
export { ApiError, type ApiKey, type Asset, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type CreateJobParams, type CreateWebhookParams, type JobResponse as Job, type JobCreatedResponse, type JobListPage, type JobStep, type JobSubscribeOptions, type JobSubscription, 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 };
|
|
2887
|
+
export { ApiError, type ApiKey, type Asset, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type CreateJobParams, type CreateWebhookParams, 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 RawFfmpegParams, 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 };
|
|
2851
2888
|
//# sourceMappingURL=index.d.cts.map
|