@rendobar/sdk 3.2.0 → 3.4.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 CHANGED
@@ -61,10 +61,10 @@ const RETRYABLE_STATUS_CODES = new Set([
61
61
  504
62
62
  ]);
63
63
  function createRequestFn(config) {
64
- const { baseUrl = "https://api.rendobar.com", apiKey, accessToken, credentials, orgId, timeout = DEFAULT_TIMEOUT, maxRetries = DEFAULT_MAX_RETRIES, debug = false, fetch: fetchFn = globalThis.fetch } = config;
64
+ const { baseUrl = "https://api.rendobar.com", apiKey, accessToken, credentials, orgId, client = "sdk", timeout = DEFAULT_TIMEOUT, maxRetries = DEFAULT_MAX_RETRIES, debug = false, fetch: fetchFn = globalThis.fetch } = config;
65
65
  return async function request(path, options = {}) {
66
66
  const url = buildUrl(baseUrl, path, options.query);
67
- const init = buildInit(options, apiKey, accessToken, credentials, orgId);
67
+ const init = buildInit(options, apiKey, accessToken, credentials, orgId, client);
68
68
  const combinedSignal = combineSignals(options.signal, timeout);
69
69
  let lastError;
70
70
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
@@ -109,11 +109,12 @@ function buildUrl(baseUrl, path, query) {
109
109
  }
110
110
  return url;
111
111
  }
112
- function buildInit(options, apiKey, accessToken, credentials, orgId) {
112
+ function buildInit(options, apiKey, accessToken, credentials, orgId, client) {
113
113
  const headers = { "Content-Type": "application/json" };
114
114
  if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`;
115
115
  else if (accessToken) headers["Authorization"] = `Bearer ${accessToken}`;
116
116
  if (orgId) headers["X-Org-Id"] = orgId;
117
+ if (client) headers["X-Rendobar-Client"] = client;
117
118
  const init = {
118
119
  method: options.method ?? "GET",
119
120
  headers
@@ -248,6 +249,12 @@ function createJobsResource(request) {
248
249
  },
249
250
  async types(options) {
250
251
  return request("/jobs/types", { signal: options?.signal });
252
+ },
253
+ async stats(params, options) {
254
+ return request("/jobs/stats", {
255
+ query: params,
256
+ signal: options?.signal
257
+ });
251
258
  }
252
259
  };
253
260
  }
@@ -292,6 +299,12 @@ function createBillingResource(request) {
292
299
  signal: options?.signal
293
300
  });
294
301
  },
302
+ async usageByClient(params, options) {
303
+ return request("/billing/usage-by-client", {
304
+ query: params,
305
+ signal: options?.signal
306
+ });
307
+ },
295
308
  async transactions(params, options) {
296
309
  return request("/billing/transactions", {
297
310
  query: params,
package/dist/index.d.cts CHANGED
@@ -2243,6 +2243,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2243
2243
  id: ZodString;
2244
2244
  orgId: ZodString;
2245
2245
  type: ZodString;
2246
+ source: ZodString;
2247
+ client: ZodNullable<ZodString>;
2248
+ batchId: ZodNullable<ZodString>;
2249
+ retryCount: ZodNumber;
2250
+ idempotencyKey: ZodNullable<ZodString>;
2251
+ mediaType: ZodNullable<ZodString>;
2246
2252
  inputs: ZodRecord<ZodString, ZodUnknown>;
2247
2253
  params: ZodRecord<ZodString, ZodUnknown>;
2248
2254
  cost: ZodNullable<ZodObject<{
@@ -2281,6 +2287,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2281
2287
  id: ZodString;
2282
2288
  orgId: ZodString;
2283
2289
  type: ZodString;
2290
+ source: ZodString;
2291
+ client: ZodNullable<ZodString>;
2292
+ batchId: ZodNullable<ZodString>;
2293
+ retryCount: ZodNumber;
2294
+ idempotencyKey: ZodNullable<ZodString>;
2295
+ mediaType: ZodNullable<ZodString>;
2284
2296
  inputs: ZodRecord<ZodString, ZodUnknown>;
2285
2297
  params: ZodRecord<ZodString, ZodUnknown>;
2286
2298
  cost: ZodNullable<ZodObject<{
@@ -2321,6 +2333,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2321
2333
  id: ZodString;
2322
2334
  orgId: ZodString;
2323
2335
  type: ZodString;
2336
+ source: ZodString;
2337
+ client: ZodNullable<ZodString>;
2338
+ batchId: ZodNullable<ZodString>;
2339
+ retryCount: ZodNumber;
2340
+ idempotencyKey: ZodNullable<ZodString>;
2341
+ mediaType: ZodNullable<ZodString>;
2324
2342
  inputs: ZodRecord<ZodString, ZodUnknown>;
2325
2343
  params: ZodRecord<ZodString, ZodUnknown>;
2326
2344
  cost: ZodNullable<ZodObject<{
@@ -2361,6 +2379,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2361
2379
  id: ZodString;
2362
2380
  orgId: ZodString;
2363
2381
  type: ZodString;
2382
+ source: ZodString;
2383
+ client: ZodNullable<ZodString>;
2384
+ batchId: ZodNullable<ZodString>;
2385
+ retryCount: ZodNumber;
2386
+ idempotencyKey: ZodNullable<ZodString>;
2387
+ mediaType: ZodNullable<ZodString>;
2364
2388
  inputs: ZodRecord<ZodString, ZodUnknown>;
2365
2389
  params: ZodRecord<ZodString, ZodUnknown>;
2366
2390
  cost: ZodNullable<ZodObject<{
@@ -2443,6 +2467,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2443
2467
  id: ZodString;
2444
2468
  orgId: ZodString;
2445
2469
  type: ZodString;
2470
+ source: ZodString;
2471
+ client: ZodNullable<ZodString>;
2472
+ batchId: ZodNullable<ZodString>;
2473
+ retryCount: ZodNumber;
2474
+ idempotencyKey: ZodNullable<ZodString>;
2475
+ mediaType: ZodNullable<ZodString>;
2446
2476
  inputs: ZodRecord<ZodString, ZodUnknown>;
2447
2477
  params: ZodRecord<ZodString, ZodUnknown>;
2448
2478
  cost: ZodNullable<ZodObject<{
@@ -2487,6 +2517,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2487
2517
  id: ZodString;
2488
2518
  orgId: ZodString;
2489
2519
  type: ZodString;
2520
+ source: ZodString;
2521
+ client: ZodNullable<ZodString>;
2522
+ batchId: ZodNullable<ZodString>;
2523
+ retryCount: ZodNumber;
2524
+ idempotencyKey: ZodNullable<ZodString>;
2525
+ mediaType: ZodNullable<ZodString>;
2490
2526
  inputs: ZodRecord<ZodString, ZodUnknown>;
2491
2527
  params: ZodRecord<ZodString, ZodUnknown>;
2492
2528
  cost: ZodNullable<ZodObject<{
@@ -2526,6 +2562,34 @@ declare const jobCreatedResponseSchema: ZodObject<{
2526
2562
  id: ZodString;
2527
2563
  status: ZodLiteral<"waiting">;
2528
2564
  }, $strip>;
2565
+ declare const jobStatsResponseSchema: ZodObject<{
2566
+ data: ZodObject<{
2567
+ window: ZodObject<{
2568
+ from: ZodNumber;
2569
+ to: ZodNumber;
2570
+ }, $strip>;
2571
+ totals: ZodObject<{
2572
+ jobs: ZodNumber;
2573
+ succeeded: ZodNumber;
2574
+ failed: ZodNumber;
2575
+ cancelled: ZodNumber;
2576
+ running: ZodNumber;
2577
+ }, $strip>;
2578
+ successRate: ZodNullable<ZodNumber>;
2579
+ avgDurationMs: ZodNullable<ZodNumber>;
2580
+ spend: ZodObject<{
2581
+ amount: ZodNumber;
2582
+ formatted: ZodString;
2583
+ }, $strip>;
2584
+ activity: ZodArray<ZodObject<{
2585
+ bucketStart: ZodNumber;
2586
+ succeeded: ZodNumber;
2587
+ failed: ZodNumber;
2588
+ other: ZodNumber;
2589
+ }, $strip>>;
2590
+ }, $strip>;
2591
+ }, $strip>;
2592
+ type JobStats = output<typeof jobStatsResponseSchema>["data"];
2529
2593
  declare const jobTypeSchema: ZodObject<{
2530
2594
  type: ZodString;
2531
2595
  tag: ZodString;
@@ -2610,6 +2674,12 @@ declare const usageSummarySchema: ZodObject<{
2610
2674
  computeSeconds: ZodNumber;
2611
2675
  }, $strip>>;
2612
2676
  }, $strip>;
2677
+ declare const usageByClientSchema: ZodArray<ZodObject<{
2678
+ client: ZodString;
2679
+ jobCount: ZodNumber;
2680
+ amountCharged: ZodNumber;
2681
+ amountFormatted: ZodString;
2682
+ }, $strip>>;
2613
2683
  declare const webhookEndpointSchema: ZodObject<{
2614
2684
  id: ZodString;
2615
2685
  name: ZodString;
@@ -2812,6 +2882,7 @@ type JobType = output<typeof jobTypeSchema>;
2812
2882
  type BillingState = output<typeof billingStateSchema>;
2813
2883
  type Transaction = output<typeof transactionSchema>;
2814
2884
  type UsageSummary = output<typeof usageSummarySchema>;
2885
+ type UsageByClient = output<typeof usageByClientSchema>;
2815
2886
  type WebhookEndpoint = output<typeof webhookEndpointSchema>;
2816
2887
  type WebhookDelivery = output<typeof webhookDeliverySchema>;
2817
2888
  type Organization = output<typeof organizationSchema>;
@@ -2840,6 +2911,12 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
2840
2911
  }, $strip>, ZodObject<{
2841
2912
  type: ZodLiteral<"job.result">;
2842
2913
  jobId: ZodString;
2914
+ }, $strip>, ZodObject<{
2915
+ type: ZodLiteral<"job.region_failover">;
2916
+ jobId: ZodString;
2917
+ fromRegion: ZodString;
2918
+ toRegion: ZodString;
2919
+ timestamp: ZodOptional<ZodNumber>;
2843
2920
  }, $strip>, ZodObject<{
2844
2921
  type: ZodLiteral<"balance.updated">;
2845
2922
  balance: ZodNumber;
@@ -3011,6 +3088,12 @@ interface ClientConfig {
3011
3088
  maxRetries?: number;
3012
3089
  /** Default org ID (sent as X-Org-Id header). */
3013
3090
  orgId?: string;
3091
+ /**
3092
+ * Client identifier sent as the X-Rendobar-Client header for usage
3093
+ * attribution. Defaults to "sdk". Wrappers built on this SDK should override
3094
+ * it (e.g. "cli", "n8n") so their traffic is attributed distinctly.
3095
+ */
3096
+ client?: string;
3014
3097
  /** Log request metadata to console.debug. Default: false */
3015
3098
  debug?: boolean;
3016
3099
  /** Custom fetch function for testing or special runtimes. */
@@ -3046,6 +3129,9 @@ declare function createClient(config?: ClientConfig): {
3046
3129
  types(options?: {
3047
3130
  signal?: AbortSignal;
3048
3131
  }): Promise<JobType[]>;
3132
+ stats(params?: StatsParams, options?: {
3133
+ signal?: AbortSignal;
3134
+ }): Promise<JobStats>;
3049
3135
  };
3050
3136
  billing: {
3051
3137
  state(options?: {
@@ -3054,6 +3140,11 @@ declare function createClient(config?: ClientConfig): {
3054
3140
  usage(params?: UsageParams, options?: {
3055
3141
  signal?: AbortSignal;
3056
3142
  }): Promise<UsageSummary>;
3143
+ usageByClient(params?: {
3144
+ days?: number;
3145
+ }, options?: {
3146
+ signal?: AbortSignal;
3147
+ }): Promise<UsageByClient>;
3057
3148
  transactions(params?: TransactionListParams, options?: {
3058
3149
  signal?: AbortSignal;
3059
3150
  }): Promise<{
@@ -3377,7 +3468,15 @@ type ListJobsParams = {
3377
3468
  status?: string;
3378
3469
  type?: string;
3379
3470
  limit?: number;
3380
- offset?: number;
3471
+ offset?: number; /** Sort field. Default: created. */
3472
+ sort?: "created" | "duration" | "cost"; /** Sort direction. Default: desc. */
3473
+ order?: "asc" | "desc"; /** Filter by originating client (sdk | cli | mcp | dashboard | ...). */
3474
+ client?: string; /** Filter jobs created at or after this Unix ms timestamp. */
3475
+ from?: number; /** Filter jobs created at or before this Unix ms timestamp. */
3476
+ to?: number;
3477
+ };
3478
+ type StatsParams = {
3479
+ /** Time window for the aggregate. Default: 24h. */window?: "24h" | "7d" | "30d";
3381
3480
  };
3382
3481
  type WaitOptions = {
3383
3482
  /** Max wait time in ms. Default: 300_000 (5 minutes). */timeout?: number; /** Initial poll interval in ms. Default: 2_000. Grows with exponential backoff. */
@@ -3489,4 +3588,4 @@ type AssetListPage = {
3489
3588
  meta: AssetListMeta;
3490
3589
  };
3491
3590
  //#endregion
3492
- export { ApiError, type ApiKey, type AssetResponse as Asset, type AssetDownloadResponse, type AssetInitResponse, type AssetListMeta, type AssetListPage, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateUploadOptions, type CreateWebhookParams, type FfmpegParams, type FileType, type JobResponse as Job, type JobCreatedResponse, type JobError, JobFailedError, type JobListPage, 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 Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadProgress, type UsageParams, type UsageSummary, type WaitOptions, WaitTimeoutError, type WebhookDelivery, type WebhookEndpoint, createClient, isApiError, jobData, outputUrl };
3591
+ export { ApiError, type ApiKey, type AssetResponse as Asset, type AssetDownloadResponse, type AssetInitResponse, type AssetListMeta, type AssetListPage, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateUploadOptions, type CreateWebhookParams, type FfmpegParams, type FileType, type JobResponse as Job, type JobCreatedResponse, type JobError, JobFailedError, type JobListPage, 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 StatsParams, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadProgress, type UsageParams, type UsageSummary, type WaitOptions, WaitTimeoutError, type WebhookDelivery, type WebhookEndpoint, createClient, isApiError, jobData, outputUrl };
package/dist/index.d.mts CHANGED
@@ -2243,6 +2243,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2243
2243
  id: ZodString;
2244
2244
  orgId: ZodString;
2245
2245
  type: ZodString;
2246
+ source: ZodString;
2247
+ client: ZodNullable<ZodString>;
2248
+ batchId: ZodNullable<ZodString>;
2249
+ retryCount: ZodNumber;
2250
+ idempotencyKey: ZodNullable<ZodString>;
2251
+ mediaType: ZodNullable<ZodString>;
2246
2252
  inputs: ZodRecord<ZodString, ZodUnknown>;
2247
2253
  params: ZodRecord<ZodString, ZodUnknown>;
2248
2254
  cost: ZodNullable<ZodObject<{
@@ -2281,6 +2287,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2281
2287
  id: ZodString;
2282
2288
  orgId: ZodString;
2283
2289
  type: ZodString;
2290
+ source: ZodString;
2291
+ client: ZodNullable<ZodString>;
2292
+ batchId: ZodNullable<ZodString>;
2293
+ retryCount: ZodNumber;
2294
+ idempotencyKey: ZodNullable<ZodString>;
2295
+ mediaType: ZodNullable<ZodString>;
2284
2296
  inputs: ZodRecord<ZodString, ZodUnknown>;
2285
2297
  params: ZodRecord<ZodString, ZodUnknown>;
2286
2298
  cost: ZodNullable<ZodObject<{
@@ -2321,6 +2333,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2321
2333
  id: ZodString;
2322
2334
  orgId: ZodString;
2323
2335
  type: ZodString;
2336
+ source: ZodString;
2337
+ client: ZodNullable<ZodString>;
2338
+ batchId: ZodNullable<ZodString>;
2339
+ retryCount: ZodNumber;
2340
+ idempotencyKey: ZodNullable<ZodString>;
2341
+ mediaType: ZodNullable<ZodString>;
2324
2342
  inputs: ZodRecord<ZodString, ZodUnknown>;
2325
2343
  params: ZodRecord<ZodString, ZodUnknown>;
2326
2344
  cost: ZodNullable<ZodObject<{
@@ -2361,6 +2379,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2361
2379
  id: ZodString;
2362
2380
  orgId: ZodString;
2363
2381
  type: ZodString;
2382
+ source: ZodString;
2383
+ client: ZodNullable<ZodString>;
2384
+ batchId: ZodNullable<ZodString>;
2385
+ retryCount: ZodNumber;
2386
+ idempotencyKey: ZodNullable<ZodString>;
2387
+ mediaType: ZodNullable<ZodString>;
2364
2388
  inputs: ZodRecord<ZodString, ZodUnknown>;
2365
2389
  params: ZodRecord<ZodString, ZodUnknown>;
2366
2390
  cost: ZodNullable<ZodObject<{
@@ -2443,6 +2467,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2443
2467
  id: ZodString;
2444
2468
  orgId: ZodString;
2445
2469
  type: ZodString;
2470
+ source: ZodString;
2471
+ client: ZodNullable<ZodString>;
2472
+ batchId: ZodNullable<ZodString>;
2473
+ retryCount: ZodNumber;
2474
+ idempotencyKey: ZodNullable<ZodString>;
2475
+ mediaType: ZodNullable<ZodString>;
2446
2476
  inputs: ZodRecord<ZodString, ZodUnknown>;
2447
2477
  params: ZodRecord<ZodString, ZodUnknown>;
2448
2478
  cost: ZodNullable<ZodObject<{
@@ -2487,6 +2517,12 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
2487
2517
  id: ZodString;
2488
2518
  orgId: ZodString;
2489
2519
  type: ZodString;
2520
+ source: ZodString;
2521
+ client: ZodNullable<ZodString>;
2522
+ batchId: ZodNullable<ZodString>;
2523
+ retryCount: ZodNumber;
2524
+ idempotencyKey: ZodNullable<ZodString>;
2525
+ mediaType: ZodNullable<ZodString>;
2490
2526
  inputs: ZodRecord<ZodString, ZodUnknown>;
2491
2527
  params: ZodRecord<ZodString, ZodUnknown>;
2492
2528
  cost: ZodNullable<ZodObject<{
@@ -2526,6 +2562,34 @@ declare const jobCreatedResponseSchema: ZodObject<{
2526
2562
  id: ZodString;
2527
2563
  status: ZodLiteral<"waiting">;
2528
2564
  }, $strip>;
2565
+ declare const jobStatsResponseSchema: ZodObject<{
2566
+ data: ZodObject<{
2567
+ window: ZodObject<{
2568
+ from: ZodNumber;
2569
+ to: ZodNumber;
2570
+ }, $strip>;
2571
+ totals: ZodObject<{
2572
+ jobs: ZodNumber;
2573
+ succeeded: ZodNumber;
2574
+ failed: ZodNumber;
2575
+ cancelled: ZodNumber;
2576
+ running: ZodNumber;
2577
+ }, $strip>;
2578
+ successRate: ZodNullable<ZodNumber>;
2579
+ avgDurationMs: ZodNullable<ZodNumber>;
2580
+ spend: ZodObject<{
2581
+ amount: ZodNumber;
2582
+ formatted: ZodString;
2583
+ }, $strip>;
2584
+ activity: ZodArray<ZodObject<{
2585
+ bucketStart: ZodNumber;
2586
+ succeeded: ZodNumber;
2587
+ failed: ZodNumber;
2588
+ other: ZodNumber;
2589
+ }, $strip>>;
2590
+ }, $strip>;
2591
+ }, $strip>;
2592
+ type JobStats = output<typeof jobStatsResponseSchema>["data"];
2529
2593
  declare const jobTypeSchema: ZodObject<{
2530
2594
  type: ZodString;
2531
2595
  tag: ZodString;
@@ -2610,6 +2674,12 @@ declare const usageSummarySchema: ZodObject<{
2610
2674
  computeSeconds: ZodNumber;
2611
2675
  }, $strip>>;
2612
2676
  }, $strip>;
2677
+ declare const usageByClientSchema: ZodArray<ZodObject<{
2678
+ client: ZodString;
2679
+ jobCount: ZodNumber;
2680
+ amountCharged: ZodNumber;
2681
+ amountFormatted: ZodString;
2682
+ }, $strip>>;
2613
2683
  declare const webhookEndpointSchema: ZodObject<{
2614
2684
  id: ZodString;
2615
2685
  name: ZodString;
@@ -2812,6 +2882,7 @@ type JobType = output<typeof jobTypeSchema>;
2812
2882
  type BillingState = output<typeof billingStateSchema>;
2813
2883
  type Transaction = output<typeof transactionSchema>;
2814
2884
  type UsageSummary = output<typeof usageSummarySchema>;
2885
+ type UsageByClient = output<typeof usageByClientSchema>;
2815
2886
  type WebhookEndpoint = output<typeof webhookEndpointSchema>;
2816
2887
  type WebhookDelivery = output<typeof webhookDeliverySchema>;
2817
2888
  type Organization = output<typeof organizationSchema>;
@@ -2840,6 +2911,12 @@ declare const orgEventSchema: ZodDiscriminatedUnion<[ZodObject<{
2840
2911
  }, $strip>, ZodObject<{
2841
2912
  type: ZodLiteral<"job.result">;
2842
2913
  jobId: ZodString;
2914
+ }, $strip>, ZodObject<{
2915
+ type: ZodLiteral<"job.region_failover">;
2916
+ jobId: ZodString;
2917
+ fromRegion: ZodString;
2918
+ toRegion: ZodString;
2919
+ timestamp: ZodOptional<ZodNumber>;
2843
2920
  }, $strip>, ZodObject<{
2844
2921
  type: ZodLiteral<"balance.updated">;
2845
2922
  balance: ZodNumber;
@@ -3011,6 +3088,12 @@ interface ClientConfig {
3011
3088
  maxRetries?: number;
3012
3089
  /** Default org ID (sent as X-Org-Id header). */
3013
3090
  orgId?: string;
3091
+ /**
3092
+ * Client identifier sent as the X-Rendobar-Client header for usage
3093
+ * attribution. Defaults to "sdk". Wrappers built on this SDK should override
3094
+ * it (e.g. "cli", "n8n") so their traffic is attributed distinctly.
3095
+ */
3096
+ client?: string;
3014
3097
  /** Log request metadata to console.debug. Default: false */
3015
3098
  debug?: boolean;
3016
3099
  /** Custom fetch function for testing or special runtimes. */
@@ -3046,6 +3129,9 @@ declare function createClient(config?: ClientConfig): {
3046
3129
  types(options?: {
3047
3130
  signal?: AbortSignal;
3048
3131
  }): Promise<JobType[]>;
3132
+ stats(params?: StatsParams, options?: {
3133
+ signal?: AbortSignal;
3134
+ }): Promise<JobStats>;
3049
3135
  };
3050
3136
  billing: {
3051
3137
  state(options?: {
@@ -3054,6 +3140,11 @@ declare function createClient(config?: ClientConfig): {
3054
3140
  usage(params?: UsageParams, options?: {
3055
3141
  signal?: AbortSignal;
3056
3142
  }): Promise<UsageSummary>;
3143
+ usageByClient(params?: {
3144
+ days?: number;
3145
+ }, options?: {
3146
+ signal?: AbortSignal;
3147
+ }): Promise<UsageByClient>;
3057
3148
  transactions(params?: TransactionListParams, options?: {
3058
3149
  signal?: AbortSignal;
3059
3150
  }): Promise<{
@@ -3377,7 +3468,15 @@ type ListJobsParams = {
3377
3468
  status?: string;
3378
3469
  type?: string;
3379
3470
  limit?: number;
3380
- offset?: number;
3471
+ offset?: number; /** Sort field. Default: created. */
3472
+ sort?: "created" | "duration" | "cost"; /** Sort direction. Default: desc. */
3473
+ order?: "asc" | "desc"; /** Filter by originating client (sdk | cli | mcp | dashboard | ...). */
3474
+ client?: string; /** Filter jobs created at or after this Unix ms timestamp. */
3475
+ from?: number; /** Filter jobs created at or before this Unix ms timestamp. */
3476
+ to?: number;
3477
+ };
3478
+ type StatsParams = {
3479
+ /** Time window for the aggregate. Default: 24h. */window?: "24h" | "7d" | "30d";
3381
3480
  };
3382
3481
  type WaitOptions = {
3383
3482
  /** Max wait time in ms. Default: 300_000 (5 minutes). */timeout?: number; /** Initial poll interval in ms. Default: 2_000. Grows with exponential backoff. */
@@ -3489,4 +3588,4 @@ type AssetListPage = {
3489
3588
  meta: AssetListMeta;
3490
3589
  };
3491
3590
  //#endregion
3492
- export { ApiError, type ApiKey, type AssetResponse as Asset, type AssetDownloadResponse, type AssetInitResponse, type AssetListMeta, type AssetListPage, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateUploadOptions, type CreateWebhookParams, type FfmpegParams, type FileType, type JobResponse as Job, type JobCreatedResponse, type JobError, JobFailedError, type JobListPage, 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 Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadProgress, type UsageParams, type UsageSummary, type WaitOptions, WaitTimeoutError, type WebhookDelivery, type WebhookEndpoint, createClient, isApiError, jobData, outputUrl };
3591
+ export { ApiError, type ApiKey, type AssetResponse as Asset, type AssetDownloadResponse, type AssetInitResponse, type AssetListMeta, type AssetListPage, type BatchResult, type BillingInvoice, type BillingState, type ClientConfig, type Cost, type CreateJobParams, type CreateUploadOptions, type CreateWebhookParams, type FfmpegParams, type FileType, type JobResponse as Job, type JobCreatedResponse, type JobError, JobFailedError, type JobListPage, 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 StatsParams, type Transaction, type TransactionListParams, type UpdateWebhookParams, type UploadProgress, type UsageParams, type UsageSummary, type WaitOptions, WaitTimeoutError, type WebhookDelivery, type WebhookEndpoint, createClient, isApiError, jobData, outputUrl };
package/dist/index.mjs CHANGED
@@ -60,10 +60,10 @@ const RETRYABLE_STATUS_CODES = new Set([
60
60
  504
61
61
  ]);
62
62
  function createRequestFn(config) {
63
- const { baseUrl = "https://api.rendobar.com", apiKey, accessToken, credentials, orgId, timeout = DEFAULT_TIMEOUT, maxRetries = DEFAULT_MAX_RETRIES, debug = false, fetch: fetchFn = globalThis.fetch } = config;
63
+ const { baseUrl = "https://api.rendobar.com", apiKey, accessToken, credentials, orgId, client = "sdk", timeout = DEFAULT_TIMEOUT, maxRetries = DEFAULT_MAX_RETRIES, debug = false, fetch: fetchFn = globalThis.fetch } = config;
64
64
  return async function request(path, options = {}) {
65
65
  const url = buildUrl(baseUrl, path, options.query);
66
- const init = buildInit(options, apiKey, accessToken, credentials, orgId);
66
+ const init = buildInit(options, apiKey, accessToken, credentials, orgId, client);
67
67
  const combinedSignal = combineSignals(options.signal, timeout);
68
68
  let lastError;
69
69
  for (let attempt = 0; attempt <= maxRetries; attempt++) {
@@ -108,11 +108,12 @@ function buildUrl(baseUrl, path, query) {
108
108
  }
109
109
  return url;
110
110
  }
111
- function buildInit(options, apiKey, accessToken, credentials, orgId) {
111
+ function buildInit(options, apiKey, accessToken, credentials, orgId, client) {
112
112
  const headers = { "Content-Type": "application/json" };
113
113
  if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`;
114
114
  else if (accessToken) headers["Authorization"] = `Bearer ${accessToken}`;
115
115
  if (orgId) headers["X-Org-Id"] = orgId;
116
+ if (client) headers["X-Rendobar-Client"] = client;
116
117
  const init = {
117
118
  method: options.method ?? "GET",
118
119
  headers
@@ -247,6 +248,12 @@ function createJobsResource(request) {
247
248
  },
248
249
  async types(options) {
249
250
  return request("/jobs/types", { signal: options?.signal });
251
+ },
252
+ async stats(params, options) {
253
+ return request("/jobs/stats", {
254
+ query: params,
255
+ signal: options?.signal
256
+ });
250
257
  }
251
258
  };
252
259
  }
@@ -291,6 +298,12 @@ function createBillingResource(request) {
291
298
  signal: options?.signal
292
299
  });
293
300
  },
301
+ async usageByClient(params, options) {
302
+ return request("/billing/usage-by-client", {
303
+ query: params,
304
+ signal: options?.signal
305
+ });
306
+ },
294
307
  async transactions(params, options) {
295
308
  return request("/billing/transactions", {
296
309
  query: params,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rendobar/sdk",
3
- "version": "3.2.0",
3
+ "version": "3.4.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript client for the Rendobar media processing API",
6
6
  "main": "./dist/index.cjs",