@convertrilo/sdk 0.0.2 → 0.0.4

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.
@@ -110,6 +110,9 @@ export declare class ConvertriloClient {
110
110
  events?: string[];
111
111
  secret?: string;
112
112
  isActive?: boolean;
113
+ failureCount?: number;
114
+ lastTriggeredAt?: string | null;
115
+ lastFailedAt?: string | null;
113
116
  createdAt?: string;
114
117
  }>;
115
118
  deleteWebhook(id: string): Promise<unknown>;
@@ -562,7 +562,10 @@ export interface paths {
562
562
  path?: never;
563
563
  cookie?: never;
564
564
  };
565
- /** List webhooks */
565
+ /**
566
+ * List webhooks
567
+ * @description List managed webhook subscriptions for the authenticated user. Managed webhook deliveries include HMAC-SHA256 signatures.
568
+ */
566
569
  get: {
567
570
  parameters: {
568
571
  query?: never;
@@ -584,7 +587,11 @@ export interface paths {
584
587
  };
585
588
  };
586
589
  put?: never;
587
- /** Create a webhook */
590
+ /**
591
+ * Create a webhook
592
+ * @description Create a managed webhook subscription. The response includes `secret` exactly once.
593
+ * Store it securely and use it to verify `X-Webhook-Signature`.
594
+ */
588
595
  post: {
589
596
  parameters: {
590
597
  query?: never;
@@ -624,7 +631,10 @@ export interface paths {
624
631
  };
625
632
  get?: never;
626
633
  put?: never;
627
- /** Test a webhook */
634
+ /**
635
+ * Test a webhook
636
+ * @description Sends a `webhook.test` event to the configured URL using the same HMAC signature header as managed deliveries.
637
+ */
628
638
  post: {
629
639
  parameters: {
630
640
  query?: never;
@@ -668,7 +678,33 @@ export interface paths {
668
678
  };
669
679
  options?: never;
670
680
  head?: never;
671
- patch?: never;
681
+ /** Update a webhook */
682
+ patch: {
683
+ parameters: {
684
+ query?: never;
685
+ header?: never;
686
+ path: {
687
+ id: string;
688
+ };
689
+ cookie?: never;
690
+ };
691
+ requestBody: {
692
+ content: {
693
+ "application/json": components["schemas"]["WebhookUpdateRequest"];
694
+ };
695
+ };
696
+ responses: {
697
+ /** @description Updated */
698
+ 200: {
699
+ headers: {
700
+ [name: string]: unknown;
701
+ };
702
+ content: {
703
+ "application/json": components["schemas"]["WebhookResponse"];
704
+ };
705
+ };
706
+ };
707
+ };
672
708
  trace?: never;
673
709
  };
674
710
  "/jobs/bulk": {
@@ -1212,8 +1248,12 @@ export interface paths {
1212
1248
  * @description Crawls an S3 prefix or Google Drive folder, queues one encode job per video file,
1213
1249
  * and optionally delivers outputs to CDN, S3, or Google Drive.
1214
1250
  *
1215
- * For API integrations, Google Drive can be used without dashboard OAuth by passing
1216
- * `accessToken` in `sourceGoogleDrive` and/or `outputGoogleDrive`.
1251
+ * For API integrations, use bring-your-own credentials:
1252
+ * - S3-compatible storage: pass `sourceS3` and/or `outputS3` credentials from your backend.
1253
+ * - Google Drive: pass customer OAuth `accessToken` values in `sourceGoogleDrive` and/or `outputGoogleDrive`.
1254
+ * - Include `refreshToken` when jobs may outlive a short access token.
1255
+ *
1256
+ * Your users do not need to connect Google Drive inside the Convertrilo dashboard for API usage.
1217
1257
  */
1218
1258
  post: {
1219
1259
  parameters: {
@@ -1590,6 +1630,12 @@ export interface components {
1590
1630
  url: string;
1591
1631
  events: ("job.created" | "job.queued" | "job.running" | "job.completed" | "job.failed" | "job.canceled")[];
1592
1632
  };
1633
+ WebhookUpdateRequest: {
1634
+ /** Format: uri */
1635
+ url?: string;
1636
+ events?: ("job.created" | "job.queued" | "job.running" | "job.completed" | "job.failed" | "job.canceled")[];
1637
+ isActive?: boolean;
1638
+ };
1593
1639
  WebhookResponse: {
1594
1640
  /** Format: uuid */
1595
1641
  id?: string;
@@ -1598,6 +1644,11 @@ export interface components {
1598
1644
  /** @description HMAC secret, only returned on creation */
1599
1645
  secret?: string;
1600
1646
  isActive?: boolean;
1647
+ failureCount?: number;
1648
+ /** Format: date-time */
1649
+ lastTriggeredAt?: string | null;
1650
+ /** Format: date-time */
1651
+ lastFailedAt?: string | null;
1601
1652
  /** Format: date-time */
1602
1653
  createdAt?: string;
1603
1654
  };
@@ -1615,45 +1666,63 @@ export interface components {
1615
1666
  secretAccessKey?: string;
1616
1667
  forcePathStyle?: boolean;
1617
1668
  };
1669
+ /** @description Customer-owned S3-compatible folder source. Credentials should allow listing the prefix and reading objects. */
1618
1670
  S3FolderSource: {
1619
1671
  bucket: string;
1620
- /** @default */
1672
+ /**
1673
+ * @description Prefix to crawl. Only files with video extensions are queued.
1674
+ * @default
1675
+ */
1621
1676
  prefix?: string;
1622
- /** Format: uri */
1677
+ /**
1678
+ * Format: uri
1679
+ * @description Optional S3-compatible endpoint, for example Cloudflare R2, MinIO, or object storage providers.
1680
+ */
1623
1681
  endpoint?: string;
1624
1682
  region?: string;
1683
+ /** @description Optional source access key. Omit only when your backend/runtime provides credentials another way. */
1625
1684
  accessKeyId?: string;
1626
1685
  /** Format: password */
1627
1686
  secretAccessKey?: string;
1628
1687
  /** @default true */
1629
1688
  forcePathStyle?: boolean;
1630
1689
  };
1690
+ /** @description Customer-owned S3-compatible output destination. Credentials should allow writing encoded objects. */
1631
1691
  S3FolderOutput: {
1632
1692
  bucket: string;
1633
- /** @default outputs/ */
1693
+ /**
1694
+ * @description Output key prefix. The source file name is appended to this prefix.
1695
+ * @default outputs/
1696
+ */
1634
1697
  prefix?: string;
1635
- /** Format: uri */
1698
+ /**
1699
+ * Format: uri
1700
+ * @description Optional S3-compatible endpoint, for example Cloudflare R2, MinIO, or object storage providers.
1701
+ */
1636
1702
  endpoint?: string;
1637
1703
  region?: string;
1704
+ /** @description Optional output access key. Omit only when your backend/runtime provides credentials another way. */
1638
1705
  accessKeyId?: string;
1639
1706
  /** Format: password */
1640
1707
  secretAccessKey?: string;
1641
1708
  /** @default true */
1642
1709
  forcePathStyle?: boolean;
1643
1710
  };
1711
+ /** @description Google Drive folder source for API integrations. Pass a customer-owned OAuth token instead of sending the user through the Convertrilo dashboard. */
1644
1712
  GoogleDriveFolderSource: {
1645
1713
  folderId: string;
1646
- /** @description Short-lived Google OAuth access token supplied by the API caller. */
1714
+ /** @description Short-lived Google OAuth access token supplied by the API caller. Must allow reading/listing files in the folder. */
1647
1715
  accessToken?: string;
1648
- /** @description Optional Google refresh token supplied by the API caller for long-running jobs. */
1716
+ /** @description Optional Google refresh token supplied by the API caller. Recommended for long-running folder jobs so workers can refresh expired access tokens. */
1649
1717
  refreshToken?: string;
1650
1718
  };
1719
+ /** @description Google Drive output destination for API integrations. Pass a customer-owned OAuth token with upload access to the destination folder. */
1651
1720
  GoogleDriveOutput: {
1652
1721
  folderId: string;
1653
1722
  fileName?: string;
1654
- /** @description Short-lived Google OAuth access token supplied by the API caller. */
1723
+ /** @description Short-lived Google OAuth access token supplied by the API caller. Must allow uploading to the destination folder. */
1655
1724
  accessToken?: string;
1656
- /** @description Optional Google refresh token supplied by the API caller for long-running jobs. */
1725
+ /** @description Optional Google refresh token supplied by the API caller. Recommended for long-running jobs so workers can refresh expired access tokens. */
1657
1726
  refreshToken?: string;
1658
1727
  };
1659
1728
  OnDemandEncodeRequest: {
@@ -1698,7 +1767,10 @@ export interface components {
1698
1767
  priority?: "normal" | "high";
1699
1768
  /** @default 86400 */
1700
1769
  outputExpiry?: number;
1701
- /** Format: uri */
1770
+ /**
1771
+ * Format: uri
1772
+ * @description Optional one-off terminal callback URL for this job. Best-effort and unsigned. Use managed webhooks for signed HMAC delivery.
1773
+ */
1702
1774
  webhook?: string;
1703
1775
  outputS3?: components["schemas"]["S3Output"];
1704
1776
  outputGoogleDrive?: components["schemas"]["GoogleDriveOutput"];
package/openapi.yaml CHANGED
@@ -5,15 +5,26 @@ info:
5
5
  description: |
6
6
  JWT-protected API for creating and managing encode jobs. Supports browser-upload, direct URL ingest, or S3 source.
7
7
  Public endpoints are limited and rate-limited.
8
+
9
+ Swagger auth:
10
+ 1. Create an API key in Dashboard -> Developer.
11
+ 2. Click Authorize in these docs.
12
+ 3. Paste the raw API key into ApiKeyAuth.
13
+ 4. Protected endpoints can then be executed from Swagger.
14
+
15
+ API integrations should keep Convertrilo API keys and customer storage/OAuth tokens on the server.
16
+ For storage integrations, pass customer-owned S3 credentials or Google OAuth access/refresh tokens directly in the API request.
17
+ Convertrilo does not require your API users to visit the dashboard OAuth flow.
8
18
 
9
19
  Official TypeScript SDK: https://www.npmjs.com/package/@convertrilo/sdk
10
20
  SDK source and examples: https://github.com/serkandrgn/convertrilo-js
21
+ Interactive docs: https://api.convertrilo.com/docs
11
22
  externalDocs:
12
23
  description: Convertrilo TypeScript SDK
13
24
  url: https://github.com/serkandrgn/convertrilo-js
14
25
  servers:
15
- - url: http://localhost:3001
16
- description: Local backend
26
+ - url: /
27
+ description: Same origin as these docs
17
28
  - url: https://api.convertrilo.com
18
29
  description: Production
19
30
  components:
@@ -291,6 +302,24 @@ components:
291
302
  job.failed,
292
303
  job.canceled,
293
304
  ]
305
+ WebhookUpdateRequest:
306
+ type: object
307
+ properties:
308
+ url: { type: string, format: uri }
309
+ events:
310
+ type: array
311
+ items:
312
+ type: string
313
+ enum:
314
+ [
315
+ job.created,
316
+ job.queued,
317
+ job.running,
318
+ job.completed,
319
+ job.failed,
320
+ job.canceled,
321
+ ]
322
+ isActive: { type: boolean }
294
323
  WebhookResponse:
295
324
  type: object
296
325
  properties:
@@ -305,6 +334,9 @@ components:
305
334
  description: "HMAC secret, only returned on creation",
306
335
  }
307
336
  isActive: { type: boolean }
337
+ failureCount: { type: integer }
338
+ lastTriggeredAt: { type: string, format: date-time, nullable: true }
339
+ lastFailedAt: { type: string, format: date-time, nullable: true }
308
340
  createdAt: { type: string, format: date-time }
309
341
  WebhookListResponse:
310
342
  type: object
@@ -328,49 +360,69 @@ components:
328
360
  forcePathStyle: { type: boolean }
329
361
  S3FolderSource:
330
362
  type: object
363
+ description: Customer-owned S3-compatible folder source. Credentials should allow listing the prefix and reading objects.
331
364
  required: [bucket]
332
365
  properties:
333
366
  bucket: { type: string }
334
- prefix: { type: string, default: "" }
335
- endpoint: { type: string, format: uri }
367
+ prefix:
368
+ type: string
369
+ default: ""
370
+ description: Prefix to crawl. Only files with video extensions are queued.
371
+ endpoint:
372
+ type: string
373
+ format: uri
374
+ description: Optional S3-compatible endpoint, for example Cloudflare R2, MinIO, or object storage providers.
336
375
  region: { type: string }
337
- accessKeyId: { type: string }
376
+ accessKeyId:
377
+ type: string
378
+ description: Optional source access key. Omit only when your backend/runtime provides credentials another way.
338
379
  secretAccessKey: { type: string, format: password }
339
380
  forcePathStyle: { type: boolean, default: true }
340
381
  S3FolderOutput:
341
382
  type: object
383
+ description: Customer-owned S3-compatible output destination. Credentials should allow writing encoded objects.
342
384
  required: [bucket]
343
385
  properties:
344
386
  bucket: { type: string }
345
- prefix: { type: string, default: outputs/ }
346
- endpoint: { type: string, format: uri }
387
+ prefix:
388
+ type: string
389
+ default: outputs/
390
+ description: Output key prefix. The source file name is appended to this prefix.
391
+ endpoint:
392
+ type: string
393
+ format: uri
394
+ description: Optional S3-compatible endpoint, for example Cloudflare R2, MinIO, or object storage providers.
347
395
  region: { type: string }
348
- accessKeyId: { type: string }
396
+ accessKeyId:
397
+ type: string
398
+ description: Optional output access key. Omit only when your backend/runtime provides credentials another way.
349
399
  secretAccessKey: { type: string, format: password }
350
400
  forcePathStyle: { type: boolean, default: true }
351
401
  GoogleDriveFolderSource:
352
402
  type: object
403
+ description: Google Drive folder source for API integrations. Pass a customer-owned OAuth token instead of sending the user through the Convertrilo dashboard.
353
404
  required: [folderId]
354
405
  properties:
355
406
  folderId: { type: string }
356
407
  accessToken:
357
408
  type: string
358
- description: Short-lived Google OAuth access token supplied by the API caller.
409
+ description: Short-lived Google OAuth access token supplied by the API caller. Must allow reading/listing files in the folder.
359
410
  refreshToken:
360
411
  type: string
361
- description: Optional Google refresh token supplied by the API caller for long-running jobs.
412
+ description: Optional Google refresh token supplied by the API caller. Recommended for long-running folder jobs so workers can refresh expired access tokens.
362
413
  GoogleDriveOutput:
363
414
  type: object
415
+ description: Google Drive output destination for API integrations. Pass a customer-owned OAuth token with upload access to the destination folder.
364
416
  required: [folderId]
365
417
  properties:
366
418
  folderId: { type: string }
367
419
  fileName: { type: string }
368
420
  accessToken:
369
421
  type: string
370
- description: Short-lived Google OAuth access token supplied by the API caller.
422
+ description: Short-lived Google OAuth access token supplied by the API caller. Must allow uploading to the destination folder.
371
423
  refreshToken:
372
424
  type: string
373
- description: Optional Google refresh token supplied by the API caller for long-running jobs.
425
+ description: Optional Google refresh token supplied by the API caller. Recommended for long-running jobs so workers can refresh expired access tokens.
374
426
  OnDemandEncodeRequest:
375
427
  type: object
376
428
  required: [sourceUrl]
@@ -392,7 +444,10 @@ components:
392
444
  priority: { type: string, enum: [normal, high], default: normal }
393
445
  outputExpiry:
394
446
  { type: integer, minimum: 3600, maximum: 604800, default: 86400 }
395
- webhook: { type: string, format: uri }
447
+ webhook:
448
+ type: string
449
+ format: uri
450
+ description: Optional one-off terminal callback URL for this job. Best-effort and unsigned. Use managed webhooks for signed HMAC delivery.
396
451
  outputS3:
397
452
  $ref: "#/components/schemas/S3Output"
398
453
  outputGoogleDrive:
@@ -757,6 +812,7 @@ paths:
757
812
  get:
758
813
  security: [{ BearerAuth: [] }]
759
814
  summary: List webhooks
815
+ description: List managed webhook subscriptions for the authenticated user. Managed webhook deliveries include HMAC-SHA256 signatures.
760
816
  responses:
761
817
  "200":
762
818
  description: List of webhooks
@@ -767,12 +823,21 @@ paths:
767
823
  post:
768
824
  security: [{ BearerAuth: [] }]
769
825
  summary: Create a webhook
826
+ description: |
827
+ Create a managed webhook subscription. The response includes `secret` exactly once.
828
+ Store it securely and use it to verify `X-Webhook-Signature`.
770
829
  requestBody:
771
830
  required: true
772
831
  content:
773
832
  application/json:
774
833
  schema:
775
834
  $ref: "#/components/schemas/WebhookCreateRequest"
835
+ examples:
836
+ jobCompletionWebhook:
837
+ summary: Completion and failure notifications
838
+ value:
839
+ url: https://your-app.com/webhooks/convertrilo
840
+ events: [job.completed, job.failed, job.canceled]
776
841
  responses:
777
842
  "200":
778
843
  description: Created
@@ -781,6 +846,36 @@ paths:
781
846
  schema:
782
847
  $ref: "#/components/schemas/WebhookResponse"
783
848
  /webhooks/{id}:
849
+ patch:
850
+ security: [{ BearerAuth: [] }]
851
+ summary: Update a webhook
852
+ parameters:
853
+ - in: path
854
+ name: id
855
+ required: true
856
+ schema: { type: string, format: uuid }
857
+ requestBody:
858
+ required: true
859
+ content:
860
+ application/json:
861
+ schema:
862
+ $ref: "#/components/schemas/WebhookUpdateRequest"
863
+ examples:
864
+ reEnableWebhook:
865
+ summary: Re-enable a disabled webhook
866
+ value:
867
+ isActive: true
868
+ changeEvents:
869
+ summary: Receive only terminal job events
870
+ value:
871
+ events: [job.completed, job.failed, job.canceled]
872
+ responses:
873
+ "200":
874
+ description: Updated
875
+ content:
876
+ application/json:
877
+ schema:
878
+ $ref: "#/components/schemas/WebhookResponse"
784
879
  delete:
785
880
  security: [{ BearerAuth: [] }]
786
881
  summary: Delete a webhook
@@ -794,6 +889,7 @@ paths:
794
889
  post:
795
890
  security: [{ BearerAuth: [] }]
796
891
  summary: Test a webhook
892
+ description: Sends a `webhook.test` event to the configured URL using the same HMAC signature header as managed deliveries.
797
893
  parameters:
798
894
  - in: path
799
895
  name: id
@@ -1017,6 +1113,37 @@ paths:
1017
1113
  application/json:
1018
1114
  schema:
1019
1115
  $ref: "#/components/schemas/OnDemandEncodeRequest"
1116
+ examples:
1117
+ urlToCdn:
1118
+ summary: URL source to CDN output
1119
+ value:
1120
+ sourceUrl: https://example.com/video.mp4
1121
+ codec: h264
1122
+ resolution: 1080p
1123
+ quality: better
1124
+ urlToS3:
1125
+ summary: URL source to S3 output
1126
+ value:
1127
+ sourceUrl: https://example.com/video.mp4
1128
+ codec: h264
1129
+ resolution: 1080p
1130
+ outputS3:
1131
+ bucket: customer-output-bucket
1132
+ key: encoded/video-1080p.mp4
1133
+ region: us-east-1
1134
+ accessKeyId: AKIA...
1135
+ secretAccessKey: replace-with-secret
1136
+ urlToGoogleDrive:
1137
+ summary: URL source to Google Drive output with BYO token
1138
+ value:
1139
+ sourceUrl: https://example.com/video.mp4
1140
+ codec: h264
1141
+ resolution: 1080p
1142
+ outputGoogleDrive:
1143
+ folderId: GOOGLE_DRIVE_FOLDER_ID
1144
+ fileName: video-1080p.mp4
1145
+ accessToken: ya29...
1146
+ refreshToken: optional-refresh-token
1020
1147
  responses:
1021
1148
  "200":
1022
1149
  description: Job created and queued
@@ -1056,14 +1183,51 @@ paths:
1056
1183
  Crawls an S3 prefix or Google Drive folder, queues one encode job per video file,
1057
1184
  and optionally delivers outputs to CDN, S3, or Google Drive.
1058
1185
 
1059
- For API integrations, Google Drive can be used without dashboard OAuth by passing
1060
- `accessToken` in `sourceGoogleDrive` and/or `outputGoogleDrive`.
1186
+ For API integrations, use bring-your-own credentials:
1187
+ - S3-compatible storage: pass `sourceS3` and/or `outputS3` credentials from your backend.
1188
+ - Google Drive: pass customer OAuth `accessToken` values in `sourceGoogleDrive` and/or `outputGoogleDrive`.
1189
+ - Include `refreshToken` when jobs may outlive a short access token.
1190
+
1191
+ Your users do not need to connect Google Drive inside the Convertrilo dashboard for API usage.
1061
1192
  requestBody:
1062
1193
  required: true
1063
1194
  content:
1064
1195
  application/json:
1065
1196
  schema:
1066
1197
  $ref: "#/components/schemas/OnDemandFolderIngestRequest"
1198
+ examples:
1199
+ s3FolderToS3:
1200
+ summary: S3 folder source to S3 output
1201
+ value:
1202
+ sourceS3:
1203
+ bucket: customer-source-bucket
1204
+ prefix: incoming/
1205
+ region: us-east-1
1206
+ accessKeyId: AKIA...
1207
+ secretAccessKey: replace-with-secret
1208
+ outputDestination: s3
1209
+ outputS3:
1210
+ bucket: customer-output-bucket
1211
+ prefix: encoded/
1212
+ region: us-east-1
1213
+ accessKeyId: AKIA...
1214
+ secretAccessKey: replace-with-secret
1215
+ codec: h264
1216
+ resolution: 1080p
1217
+ googleDriveFolderToGoogleDrive:
1218
+ summary: Google Drive folder source to Google Drive output
1219
+ value:
1220
+ sourceGoogleDrive:
1221
+ folderId: SOURCE_FOLDER_ID
1222
+ accessToken: ya29...
1223
+ refreshToken: optional-refresh-token
1224
+ outputDestination: google-drive
1225
+ outputGoogleDrive:
1226
+ folderId: OUTPUT_FOLDER_ID
1227
+ accessToken: ya29...
1228
+ refreshToken: optional-refresh-token
1229
+ codec: h264
1230
+ resolution: 1080p
1067
1231
  responses:
1068
1232
  "200":
1069
1233
  description: Folder jobs queued
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@convertrilo/sdk",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "TypeScript client for the Convertrilo video encoding API",
5
5
  "private": false,
6
6
  "license": "MIT",