@stack0/sdk 0.5.15 → 0.5.17

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 CHANGED
@@ -483,14 +483,17 @@ console.log(`Progress: ${status.progress}%`);
483
483
  const urls = await stack0.cdn.getStreamingUrls('asset-id');
484
484
  console.log(urls.hlsUrl);
485
485
 
486
- // Generate thumbnails
487
- const thumb = await stack0.cdn.getThumbnail({
486
+ // Get a thumbnail at a timestamp (generated on miss; waits until ready)
487
+ const thumb = await stack0.cdn.getThumbnailAndWait({
488
488
  assetId: 'video-asset-id',
489
489
  timestamp: 10.5,
490
490
  width: 320,
491
491
  format: 'webp',
492
492
  });
493
493
 
494
+ // Non-blocking variant: returns { status: 'pending', url: null } while generating
495
+ const maybe = await stack0.cdn.getThumbnail({ assetId: 'video-asset-id', timestamp: 0 });
496
+
494
497
  // Extract audio
495
498
  const { jobId } = await stack0.cdn.extractAudio({
496
499
  projectSlug: 'my-project',
@@ -534,6 +537,28 @@ const mergeJob = await stack0.cdn.createMergeJob({
534
537
  audioTrack: { assetId: 'music-id', loop: true, fadeIn: 2, fadeOut: 3 },
535
538
  output: { format: 'mp4', quality: '1080p', filename: 'final.mp4' },
536
539
  });
540
+
541
+ // Composite a screen recording onto a held phone (screen keyed #F500FA):
542
+ // the keyed background sits on top, so fingers occlude the inset recording
543
+ const composited = await stack0.cdn.createMergeJob({
544
+ projectSlug: 'my-project',
545
+ inputs: [
546
+ {
547
+ assetId: 'app-screen-recording',
548
+ composite: {
549
+ backgroundAssetId: 'holding-phone-shot',
550
+ quad: {
551
+ topLeft: { x: 320, y: 480 },
552
+ topRight: { x: 760, y: 500 },
553
+ bottomLeft: { x: 300, y: 1400 },
554
+ bottomRight: { x: 740, y: 1440 },
555
+ },
556
+ fit: 'cover',
557
+ chromaKey: { color: '#F500FA', similarity: 0.34, blend: 0.06 },
558
+ },
559
+ },
560
+ ],
561
+ });
537
562
  ```
538
563
 
539
564
  ### Private Files
@@ -181,53 +181,58 @@ interface VideoVariant {
181
181
  /**
182
182
  * Watermark burned into a video during transcode.
183
183
  *
184
- * The image-watermark fields mirror the image-upload watermark config
185
- * ({@link ImageWatermarkConfig}), so the same settings you use to watermark photos work
186
- * for video — the original asset stays clean and every transcoded rendition is watermarked.
187
- * Set `type: "text"` to burn a text string instead of a logo.
184
+ * Image watermarks mirror the image-upload controls. Image and text watermarks share
185
+ * placement, opacity, rotation, and tiling. The original asset stays clean and every
186
+ * transcoded rendition is watermarked.
188
187
  */
189
- interface WatermarkOptions {
190
- /** "image" (default) composites a logo; "text" burns a text string. */
191
- type?: "image" | "text";
192
- /** Logo source: another CDN asset (image watermark). Provide `assetId` or `url`. */
193
- assetId?: string;
194
- /** Logo source: a direct URL (image watermark, alternative to `assetId`). */
195
- url?: string;
196
- /** Text to render (required when `type` is "text"). */
197
- text?: string;
198
- /** Font family for text watermarks. */
199
- fontFamily?: string;
200
- /** Font size in pixels for text watermarks. */
201
- fontSize?: number;
202
- /** Text color as `#RRGGBB` (text watermarks). */
203
- fontColor?: string;
188
+ interface BaseVideoWatermarkOptions {
204
189
  /** Placement on the frame (default: "bottom-right"). */
205
190
  position?: ImageWatermarkPosition;
206
191
  /** Horizontal inset from the anchored edge in pixels (default: 20). */
207
192
  offsetX?: number;
208
193
  /** Vertical inset from the anchored edge in pixels (default: 20). */
209
194
  offsetY?: number;
210
- /** "relative" sizes by a percentage of the video width; "absolute" uses width/height (default: "relative"). */
211
- sizingMode?: ImageWatermarkSizingMode;
212
- /** Absolute width in pixels (used when `sizingMode` is "absolute"). */
213
- width?: number;
214
- /** Absolute height in pixels (used when `sizingMode` is "absolute"). */
215
- height?: number;
216
- /** Relative size as a percentage of the video width (used when `sizingMode` is "relative"; default: 15). */
217
- scale?: number;
218
195
  /** Opacity 0-100 (default: 80). */
219
196
  opacity?: number;
220
- /** Tile the watermark across the whole frame, e.g. for copyright protection (default: false). */
197
+ /** Repeat the watermark across the whole frame (default: false). */
221
198
  tile?: boolean;
222
199
  /** Horizontal spacing between tiles in pixels (default: 100). */
223
200
  tileSpacingX?: number;
224
201
  /** Vertical spacing between tiles in pixels (default: 100). */
225
202
  tileSpacingY?: number;
226
- /** Rotation in degrees, -360 to 360 (default: 0). Image watermarks only. */
203
+ /** Rotation in degrees, -360 to 360 (default: 0). */
227
204
  rotation?: number;
228
- /** Corner radius in pixels clipping the logo, 0-500 (default: 0). Image watermarks only. */
205
+ }
206
+ interface ImageVideoWatermarkOptions extends BaseVideoWatermarkOptions {
207
+ /** Omit for backward compatibility; image is the default watermark type. */
208
+ type?: "image";
209
+ /** Logo source: another CDN asset. Provide `assetId` or `url`. */
210
+ assetId?: string;
211
+ /** Logo source: a direct URL (alternative to `assetId`). */
212
+ url?: string;
213
+ /** "relative" sizes by a percentage of the video width; "absolute" uses width/height (default: "relative"). */
214
+ sizingMode?: ImageWatermarkSizingMode;
215
+ /** Absolute width in pixels (used when `sizingMode` is "absolute"). */
216
+ width?: number;
217
+ /** Absolute height in pixels (used when `sizingMode` is "absolute"). */
218
+ height?: number;
219
+ /** Relative size as a percentage of the video width (used when `sizingMode` is "relative"; default: 15). */
220
+ scale?: number;
221
+ /** Corner radius in pixels clipping the logo, 0-500 (default: 0). */
229
222
  borderRadius?: number;
230
223
  }
224
+ interface TextVideoWatermarkOptions extends BaseVideoWatermarkOptions {
225
+ type: "text";
226
+ /** Text to render. */
227
+ text: string;
228
+ /** Font family (default: "Liberation Sans"). */
229
+ fontFamily?: string;
230
+ /** Font size in pixels (default: 48). */
231
+ fontSize?: number;
232
+ /** Text color as `#RRGGBB` (default: "#FFFFFF"). */
233
+ fontColor?: string;
234
+ }
235
+ type WatermarkOptions = ImageVideoWatermarkOptions | TextVideoWatermarkOptions;
231
236
  /** Position options for image watermarks */
232
237
  type ImageWatermarkPosition = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
233
238
  /** Sizing mode for image watermarks */
@@ -330,10 +335,16 @@ interface ThumbnailRequest {
330
335
  format?: "jpg" | "png" | "webp";
331
336
  }
332
337
  interface ThumbnailResponse {
333
- url: string;
338
+ id: string | null;
339
+ assetId: string;
334
340
  timestamp: number;
335
- width: number;
336
- height: number;
341
+ /** CDN URL of the frame; null while status is "pending" */
342
+ url: string | null;
343
+ width: number | null;
344
+ height: number | null;
345
+ format: string;
346
+ /** "ready" when the frame exists; "pending" while generation is queued/in flight */
347
+ status: "ready" | "pending";
337
348
  }
338
349
  interface RegenerateThumbnailRequest {
339
350
  assetId: string;
@@ -688,6 +699,63 @@ interface TextOverlay {
688
699
  /** Stroke/outline configuration for better visibility */
689
700
  stroke?: TextOverlayStroke;
690
701
  }
702
+ /** A point in background pixel coordinates */
703
+ interface CompositePoint {
704
+ x: number;
705
+ y: number;
706
+ }
707
+ /**
708
+ * Perspective destination quad: where the overlay's four corners land on the
709
+ * background, in background pixels. Use for corner-pinning a clip onto an
710
+ * angled surface like a phone screen in a held-phone shot.
711
+ */
712
+ interface CompositeQuad {
713
+ topLeft: CompositePoint;
714
+ topRight: CompositePoint;
715
+ bottomLeft: CompositePoint;
716
+ bottomRight: CompositePoint;
717
+ }
718
+ /** Axis-aligned destination rectangle in background pixels (no perspective) */
719
+ interface CompositeRect {
720
+ x: number;
721
+ y: number;
722
+ width: number;
723
+ height: number;
724
+ }
725
+ /**
726
+ * Chroma key applied to the background: the keyed color becomes transparent so
727
+ * the overlay shows through only there, and real foreground (fingers, hands)
728
+ * occludes the overlay.
729
+ */
730
+ interface CompositeChromaKey {
731
+ /** Key color in hex format (e.g., "#F500FA") */
732
+ color: string;
733
+ /** Color distance tolerance 0.01-1 (default: 0.3) */
734
+ similarity?: number;
735
+ /** Edge blend 0-1 (default: 0.1) */
736
+ blend?: number;
737
+ }
738
+ /**
739
+ * Composite configuration: place this input (the overlay) into a region of a
740
+ * background asset. The background can be an image or video. The keyed or
741
+ * masked background is layered on top of the placed overlay, so foreground in
742
+ * the background shot occludes the inset — ideal for "POV holding my phone"
743
+ * style UGC where an app recording is pinned onto the phone's (keyed) screen.
744
+ */
745
+ interface CompositeConfig {
746
+ /** Asset ID of the background image or video */
747
+ backgroundAssetId: string;
748
+ /** Perspective corner-pin destination (requires chromaKey or maskAssetId) */
749
+ quad?: CompositeQuad;
750
+ /** Axis-aligned destination rectangle (simple PiP when no key/mask) */
751
+ rect?: CompositeRect;
752
+ /** How the overlay fills the destination region's aspect ratio (default: "cover") */
753
+ fit?: "cover" | "contain" | "fill";
754
+ /** Chroma key applied to the background */
755
+ chromaKey?: CompositeChromaKey;
756
+ /** Grayscale mask image asset: white keeps the background, black reveals the overlay */
757
+ maskAssetId?: string;
758
+ }
691
759
  /**
692
760
  * A single input item for the merge operation.
693
761
  * Can be a video, image, or audio file.
@@ -703,6 +771,8 @@ interface MergeInputItem {
703
771
  endTime?: number;
704
772
  /** Text overlay/caption configuration */
705
773
  textOverlay?: TextOverlay;
774
+ /** Composite this input into a region of a background asset */
775
+ composite?: CompositeConfig;
706
776
  }
707
777
  /**
708
778
  * Audio track overlay configuration for merge jobs.
@@ -1304,7 +1374,12 @@ declare class CDN {
1304
1374
  */
1305
1375
  getStreamingUrls(assetId: string): Promise<StreamingUrls>;
1306
1376
  /**
1307
- * Generate a thumbnail from a video at a specific timestamp
1377
+ * Get the thumbnail at a specific timestamp, generating it on miss
1378
+ *
1379
+ * If no thumbnail exists at that timestamp yet, generation is queued
1380
+ * automatically and a response with `status: "pending"` (null url) is
1381
+ * returned. Poll until `status` is "ready", or use
1382
+ * {@link getThumbnailAndWait} to do that for you.
1308
1383
  *
1309
1384
  * @example
1310
1385
  * ```typescript
@@ -1314,24 +1389,48 @@ declare class CDN {
1314
1389
  * width: 320,
1315
1390
  * format: 'webp',
1316
1391
  * });
1317
- * console.log(`Thumbnail URL: ${thumbnail.url}`);
1392
+ * if (thumbnail.status === 'ready') {
1393
+ * console.log(`Thumbnail URL: ${thumbnail.url}`);
1394
+ * }
1318
1395
  * ```
1319
1396
  */
1320
1397
  getThumbnail(request: ThumbnailRequest): Promise<ThumbnailResponse>;
1398
+ /**
1399
+ * Get the thumbnail at a specific timestamp, waiting for generation to complete
1400
+ *
1401
+ * Calls {@link getThumbnail} and polls until the thumbnail is ready.
1402
+ *
1403
+ * @example
1404
+ * ```typescript
1405
+ * const thumbnail = await cdn.getThumbnailAndWait({
1406
+ * assetId: 'video-asset-id',
1407
+ * timestamp: 3.5,
1408
+ * });
1409
+ * console.log(`Thumbnail URL: ${thumbnail.url}`);
1410
+ * ```
1411
+ */
1412
+ getThumbnailAndWait(request: ThumbnailRequest, options?: {
1413
+ pollInterval?: number;
1414
+ timeout?: number;
1415
+ }): Promise<ThumbnailResponse>;
1321
1416
  /**
1322
1417
  * Regenerate a thumbnail for a video (force regeneration even if one exists)
1323
1418
  *
1324
- * Useful for retrying failed thumbnail generation or regenerating with different settings.
1419
+ * Useful for retrying failed thumbnail generation or regenerating with
1420
+ * different settings. Regeneration is async: poll {@link getThumbnail} (or
1421
+ * use {@link getThumbnailAndWait}) at the same timestamp until the new
1422
+ * frame is ready.
1325
1423
  *
1326
1424
  * @example
1327
1425
  * ```typescript
1328
- * const result = await cdn.regenerateThumbnail({
1426
+ * await cdn.regenerateThumbnail({
1329
1427
  * assetId: 'video-asset-id',
1330
1428
  * timestamp: 5, // 5 seconds into the video
1331
1429
  * width: 1280,
1332
1430
  * format: 'jpg',
1333
1431
  * });
1334
- * console.log(`Thumbnail regeneration queued: ${result.status}`);
1432
+ * const thumbnail = await cdn.getThumbnailAndWait({ assetId: 'video-asset-id', timestamp: 5 });
1433
+ * console.log(`Thumbnail URL: ${thumbnail.url}`);
1335
1434
  * ```
1336
1435
  */
1337
1436
  regenerateThumbnail(request: RegenerateThumbnailRequest): Promise<RegenerateThumbnailResponse>;
@@ -1711,6 +1810,33 @@ declare class CDN {
1711
1810
  * });
1712
1811
  * console.log(`Merge job started: ${job.id}`);
1713
1812
  * ```
1813
+ *
1814
+ * @example Composite a screen recording onto a held phone ("POV holding my phone"):
1815
+ * ```typescript
1816
+ * const job = await cdn.createMergeJob({
1817
+ * projectSlug: 'my-project',
1818
+ * inputs: [
1819
+ * { assetId: 'reaction-clip-id' },
1820
+ * {
1821
+ * assetId: 'app-recording-id', // the overlay clip
1822
+ * composite: {
1823
+ * backgroundAssetId: 'holding-phone-shot-id', // image or video
1824
+ * // Corner-pin onto the angled screen (background pixel coords, TL/TR/BL/BR)
1825
+ * quad: {
1826
+ * topLeft: { x: 320, y: 480 },
1827
+ * topRight: { x: 760, y: 500 },
1828
+ * bottomLeft: { x: 300, y: 1400 },
1829
+ * bottomRight: { x: 740, y: 1440 },
1830
+ * },
1831
+ * fit: 'cover',
1832
+ * // Screen area painted #F500FA in the background is keyed out, so the
1833
+ * // recording shows through and fingers over the screen occlude it
1834
+ * chromaKey: { color: '#F500FA', similarity: 0.34, blend: 0.06 },
1835
+ * },
1836
+ * },
1837
+ * ],
1838
+ * });
1839
+ * ```
1714
1840
  */
1715
1841
  createMergeJob(request: CreateMergeJobRequest): Promise<MergeJob>;
1716
1842
  /**
@@ -1869,4 +1995,4 @@ declare class CDN {
1869
1995
  private convertImportFileDates;
1870
1996
  }
1871
1997
 
1872
- export { type Asset, type AssetStatus, type AssetType, type AudioTrackInput, type BundleDownloadUrlRequest, type BundleDownloadUrlResponse, type BundleStatus, CDN, type CancelImportResponse, type CancelMergeJobRequest, type CdnEnvironment, type CdnStorageBreakdownItem, type CdnStorageBreakdownRequest, type CdnStorageBreakdownResponse, type CdnUsageDataPoint, type CdnUsageHistoryRequest, type CdnUsageHistoryResponse, type CdnUsageRequest, type CdnUsageResponse, type ConfirmUploadRequest, type ConfirmUploadResponse, type CreateBundleRequest, type CreateBundleResponse, type CreateFolderRequest, type CreateImportRequest, type CreateImportResponse, type CreateMergeJobRequest, type DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type DownloadBundle, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderListItem, type FolderTreeNode, type GenerateGifRequest, type GetAssetRequest, type GetFolderByPathRequest, type GetFolderRequest, type GetFolderTreeRequest, type GetMergeJobRequest, type GifStatus, type ImageWatermarkConfig, type ImageWatermarkPosition, type ImageWatermarkSizingMode, type ImportAuthType, type ImportError, type ImportFile, type ImportFileStatus, type ImportJob, type ImportJobStatus, type ImportJobSummary, type ImportPathMode, type ListAssetsRequest, type ListAssetsResponse, type ListBundlesRequest, type ListBundlesResponse, type ListFoldersRequest, type ListFoldersResponse, type ListGifsRequest, type ListImportFilesRequest, type ListImportFilesResponse, type ListImportsRequest, type ListImportsResponse, type ListJobsRequest, type ListJobsResponse, type ListMergeJobsRequest, type ListMergeJobsResponse, type ListPrivateFilesRequest, type ListPrivateFilesResponse, type ListThumbnailsRequest, type ListThumbnailsResponse, type MergeAspectRatio, type MergeInputItem, type MergeJob, type MergeJobWithOutput, type MergeOutputConfig, type MergeOutputFormat, type MergeQuality, type MergeStatus, type MoveAssetsRequest, type MoveAssetsResponse, type MoveFolderRequest, type MoveFolderResponse, type MovePrivateFilesRequest, type MovePrivateFilesResponse, type PrivateDownloadUrlRequest, type PrivateDownloadUrlResponse, type PrivateFile, type PrivateFileStatus, type PrivateUploadUrlRequest, type PrivateUploadUrlResponse, type RegenerateThumbnailRequest, type RegenerateThumbnailResponse, type RetryImportResponse, type StreamingUrls, type TextOverlay, type TextOverlayShadow, type TextOverlayStroke, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UpdateFolderRequest, type UpdatePrivateFileRequest, type UploadFromUrlRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoGif, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };
1998
+ export { type Asset, type AssetStatus, type AssetType, type AudioTrackInput, type BundleDownloadUrlRequest, type BundleDownloadUrlResponse, type BundleStatus, CDN, type CancelImportResponse, type CancelMergeJobRequest, type CdnEnvironment, type CdnStorageBreakdownItem, type CdnStorageBreakdownRequest, type CdnStorageBreakdownResponse, type CdnUsageDataPoint, type CdnUsageHistoryRequest, type CdnUsageHistoryResponse, type CdnUsageRequest, type CdnUsageResponse, type CompositeChromaKey, type CompositeConfig, type CompositePoint, type CompositeQuad, type CompositeRect, type ConfirmUploadRequest, type ConfirmUploadResponse, type CreateBundleRequest, type CreateBundleResponse, type CreateFolderRequest, type CreateImportRequest, type CreateImportResponse, type CreateMergeJobRequest, type DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type DownloadBundle, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderListItem, type FolderTreeNode, type GenerateGifRequest, type GetAssetRequest, type GetFolderByPathRequest, type GetFolderRequest, type GetFolderTreeRequest, type GetMergeJobRequest, type GifStatus, type ImageVideoWatermarkOptions, type ImageWatermarkConfig, type ImageWatermarkPosition, type ImageWatermarkSizingMode, type ImportAuthType, type ImportError, type ImportFile, type ImportFileStatus, type ImportJob, type ImportJobStatus, type ImportJobSummary, type ImportPathMode, type ListAssetsRequest, type ListAssetsResponse, type ListBundlesRequest, type ListBundlesResponse, type ListFoldersRequest, type ListFoldersResponse, type ListGifsRequest, type ListImportFilesRequest, type ListImportFilesResponse, type ListImportsRequest, type ListImportsResponse, type ListJobsRequest, type ListJobsResponse, type ListMergeJobsRequest, type ListMergeJobsResponse, type ListPrivateFilesRequest, type ListPrivateFilesResponse, type ListThumbnailsRequest, type ListThumbnailsResponse, type MergeAspectRatio, type MergeInputItem, type MergeJob, type MergeJobWithOutput, type MergeOutputConfig, type MergeOutputFormat, type MergeQuality, type MergeStatus, type MoveAssetsRequest, type MoveAssetsResponse, type MoveFolderRequest, type MoveFolderResponse, type MovePrivateFilesRequest, type MovePrivateFilesResponse, type PrivateDownloadUrlRequest, type PrivateDownloadUrlResponse, type PrivateFile, type PrivateFileStatus, type PrivateUploadUrlRequest, type PrivateUploadUrlResponse, type RegenerateThumbnailRequest, type RegenerateThumbnailResponse, type RetryImportResponse, type StreamingUrls, type TextOverlay, type TextOverlayShadow, type TextOverlayStroke, type TextVideoWatermarkOptions, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UpdateFolderRequest, type UpdatePrivateFileRequest, type UploadFromUrlRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoGif, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };
@@ -181,53 +181,58 @@ interface VideoVariant {
181
181
  /**
182
182
  * Watermark burned into a video during transcode.
183
183
  *
184
- * The image-watermark fields mirror the image-upload watermark config
185
- * ({@link ImageWatermarkConfig}), so the same settings you use to watermark photos work
186
- * for video — the original asset stays clean and every transcoded rendition is watermarked.
187
- * Set `type: "text"` to burn a text string instead of a logo.
184
+ * Image watermarks mirror the image-upload controls. Image and text watermarks share
185
+ * placement, opacity, rotation, and tiling. The original asset stays clean and every
186
+ * transcoded rendition is watermarked.
188
187
  */
189
- interface WatermarkOptions {
190
- /** "image" (default) composites a logo; "text" burns a text string. */
191
- type?: "image" | "text";
192
- /** Logo source: another CDN asset (image watermark). Provide `assetId` or `url`. */
193
- assetId?: string;
194
- /** Logo source: a direct URL (image watermark, alternative to `assetId`). */
195
- url?: string;
196
- /** Text to render (required when `type` is "text"). */
197
- text?: string;
198
- /** Font family for text watermarks. */
199
- fontFamily?: string;
200
- /** Font size in pixels for text watermarks. */
201
- fontSize?: number;
202
- /** Text color as `#RRGGBB` (text watermarks). */
203
- fontColor?: string;
188
+ interface BaseVideoWatermarkOptions {
204
189
  /** Placement on the frame (default: "bottom-right"). */
205
190
  position?: ImageWatermarkPosition;
206
191
  /** Horizontal inset from the anchored edge in pixels (default: 20). */
207
192
  offsetX?: number;
208
193
  /** Vertical inset from the anchored edge in pixels (default: 20). */
209
194
  offsetY?: number;
210
- /** "relative" sizes by a percentage of the video width; "absolute" uses width/height (default: "relative"). */
211
- sizingMode?: ImageWatermarkSizingMode;
212
- /** Absolute width in pixels (used when `sizingMode` is "absolute"). */
213
- width?: number;
214
- /** Absolute height in pixels (used when `sizingMode` is "absolute"). */
215
- height?: number;
216
- /** Relative size as a percentage of the video width (used when `sizingMode` is "relative"; default: 15). */
217
- scale?: number;
218
195
  /** Opacity 0-100 (default: 80). */
219
196
  opacity?: number;
220
- /** Tile the watermark across the whole frame, e.g. for copyright protection (default: false). */
197
+ /** Repeat the watermark across the whole frame (default: false). */
221
198
  tile?: boolean;
222
199
  /** Horizontal spacing between tiles in pixels (default: 100). */
223
200
  tileSpacingX?: number;
224
201
  /** Vertical spacing between tiles in pixels (default: 100). */
225
202
  tileSpacingY?: number;
226
- /** Rotation in degrees, -360 to 360 (default: 0). Image watermarks only. */
203
+ /** Rotation in degrees, -360 to 360 (default: 0). */
227
204
  rotation?: number;
228
- /** Corner radius in pixels clipping the logo, 0-500 (default: 0). Image watermarks only. */
205
+ }
206
+ interface ImageVideoWatermarkOptions extends BaseVideoWatermarkOptions {
207
+ /** Omit for backward compatibility; image is the default watermark type. */
208
+ type?: "image";
209
+ /** Logo source: another CDN asset. Provide `assetId` or `url`. */
210
+ assetId?: string;
211
+ /** Logo source: a direct URL (alternative to `assetId`). */
212
+ url?: string;
213
+ /** "relative" sizes by a percentage of the video width; "absolute" uses width/height (default: "relative"). */
214
+ sizingMode?: ImageWatermarkSizingMode;
215
+ /** Absolute width in pixels (used when `sizingMode` is "absolute"). */
216
+ width?: number;
217
+ /** Absolute height in pixels (used when `sizingMode` is "absolute"). */
218
+ height?: number;
219
+ /** Relative size as a percentage of the video width (used when `sizingMode` is "relative"; default: 15). */
220
+ scale?: number;
221
+ /** Corner radius in pixels clipping the logo, 0-500 (default: 0). */
229
222
  borderRadius?: number;
230
223
  }
224
+ interface TextVideoWatermarkOptions extends BaseVideoWatermarkOptions {
225
+ type: "text";
226
+ /** Text to render. */
227
+ text: string;
228
+ /** Font family (default: "Liberation Sans"). */
229
+ fontFamily?: string;
230
+ /** Font size in pixels (default: 48). */
231
+ fontSize?: number;
232
+ /** Text color as `#RRGGBB` (default: "#FFFFFF"). */
233
+ fontColor?: string;
234
+ }
235
+ type WatermarkOptions = ImageVideoWatermarkOptions | TextVideoWatermarkOptions;
231
236
  /** Position options for image watermarks */
232
237
  type ImageWatermarkPosition = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
233
238
  /** Sizing mode for image watermarks */
@@ -330,10 +335,16 @@ interface ThumbnailRequest {
330
335
  format?: "jpg" | "png" | "webp";
331
336
  }
332
337
  interface ThumbnailResponse {
333
- url: string;
338
+ id: string | null;
339
+ assetId: string;
334
340
  timestamp: number;
335
- width: number;
336
- height: number;
341
+ /** CDN URL of the frame; null while status is "pending" */
342
+ url: string | null;
343
+ width: number | null;
344
+ height: number | null;
345
+ format: string;
346
+ /** "ready" when the frame exists; "pending" while generation is queued/in flight */
347
+ status: "ready" | "pending";
337
348
  }
338
349
  interface RegenerateThumbnailRequest {
339
350
  assetId: string;
@@ -688,6 +699,63 @@ interface TextOverlay {
688
699
  /** Stroke/outline configuration for better visibility */
689
700
  stroke?: TextOverlayStroke;
690
701
  }
702
+ /** A point in background pixel coordinates */
703
+ interface CompositePoint {
704
+ x: number;
705
+ y: number;
706
+ }
707
+ /**
708
+ * Perspective destination quad: where the overlay's four corners land on the
709
+ * background, in background pixels. Use for corner-pinning a clip onto an
710
+ * angled surface like a phone screen in a held-phone shot.
711
+ */
712
+ interface CompositeQuad {
713
+ topLeft: CompositePoint;
714
+ topRight: CompositePoint;
715
+ bottomLeft: CompositePoint;
716
+ bottomRight: CompositePoint;
717
+ }
718
+ /** Axis-aligned destination rectangle in background pixels (no perspective) */
719
+ interface CompositeRect {
720
+ x: number;
721
+ y: number;
722
+ width: number;
723
+ height: number;
724
+ }
725
+ /**
726
+ * Chroma key applied to the background: the keyed color becomes transparent so
727
+ * the overlay shows through only there, and real foreground (fingers, hands)
728
+ * occludes the overlay.
729
+ */
730
+ interface CompositeChromaKey {
731
+ /** Key color in hex format (e.g., "#F500FA") */
732
+ color: string;
733
+ /** Color distance tolerance 0.01-1 (default: 0.3) */
734
+ similarity?: number;
735
+ /** Edge blend 0-1 (default: 0.1) */
736
+ blend?: number;
737
+ }
738
+ /**
739
+ * Composite configuration: place this input (the overlay) into a region of a
740
+ * background asset. The background can be an image or video. The keyed or
741
+ * masked background is layered on top of the placed overlay, so foreground in
742
+ * the background shot occludes the inset — ideal for "POV holding my phone"
743
+ * style UGC where an app recording is pinned onto the phone's (keyed) screen.
744
+ */
745
+ interface CompositeConfig {
746
+ /** Asset ID of the background image or video */
747
+ backgroundAssetId: string;
748
+ /** Perspective corner-pin destination (requires chromaKey or maskAssetId) */
749
+ quad?: CompositeQuad;
750
+ /** Axis-aligned destination rectangle (simple PiP when no key/mask) */
751
+ rect?: CompositeRect;
752
+ /** How the overlay fills the destination region's aspect ratio (default: "cover") */
753
+ fit?: "cover" | "contain" | "fill";
754
+ /** Chroma key applied to the background */
755
+ chromaKey?: CompositeChromaKey;
756
+ /** Grayscale mask image asset: white keeps the background, black reveals the overlay */
757
+ maskAssetId?: string;
758
+ }
691
759
  /**
692
760
  * A single input item for the merge operation.
693
761
  * Can be a video, image, or audio file.
@@ -703,6 +771,8 @@ interface MergeInputItem {
703
771
  endTime?: number;
704
772
  /** Text overlay/caption configuration */
705
773
  textOverlay?: TextOverlay;
774
+ /** Composite this input into a region of a background asset */
775
+ composite?: CompositeConfig;
706
776
  }
707
777
  /**
708
778
  * Audio track overlay configuration for merge jobs.
@@ -1304,7 +1374,12 @@ declare class CDN {
1304
1374
  */
1305
1375
  getStreamingUrls(assetId: string): Promise<StreamingUrls>;
1306
1376
  /**
1307
- * Generate a thumbnail from a video at a specific timestamp
1377
+ * Get the thumbnail at a specific timestamp, generating it on miss
1378
+ *
1379
+ * If no thumbnail exists at that timestamp yet, generation is queued
1380
+ * automatically and a response with `status: "pending"` (null url) is
1381
+ * returned. Poll until `status` is "ready", or use
1382
+ * {@link getThumbnailAndWait} to do that for you.
1308
1383
  *
1309
1384
  * @example
1310
1385
  * ```typescript
@@ -1314,24 +1389,48 @@ declare class CDN {
1314
1389
  * width: 320,
1315
1390
  * format: 'webp',
1316
1391
  * });
1317
- * console.log(`Thumbnail URL: ${thumbnail.url}`);
1392
+ * if (thumbnail.status === 'ready') {
1393
+ * console.log(`Thumbnail URL: ${thumbnail.url}`);
1394
+ * }
1318
1395
  * ```
1319
1396
  */
1320
1397
  getThumbnail(request: ThumbnailRequest): Promise<ThumbnailResponse>;
1398
+ /**
1399
+ * Get the thumbnail at a specific timestamp, waiting for generation to complete
1400
+ *
1401
+ * Calls {@link getThumbnail} and polls until the thumbnail is ready.
1402
+ *
1403
+ * @example
1404
+ * ```typescript
1405
+ * const thumbnail = await cdn.getThumbnailAndWait({
1406
+ * assetId: 'video-asset-id',
1407
+ * timestamp: 3.5,
1408
+ * });
1409
+ * console.log(`Thumbnail URL: ${thumbnail.url}`);
1410
+ * ```
1411
+ */
1412
+ getThumbnailAndWait(request: ThumbnailRequest, options?: {
1413
+ pollInterval?: number;
1414
+ timeout?: number;
1415
+ }): Promise<ThumbnailResponse>;
1321
1416
  /**
1322
1417
  * Regenerate a thumbnail for a video (force regeneration even if one exists)
1323
1418
  *
1324
- * Useful for retrying failed thumbnail generation or regenerating with different settings.
1419
+ * Useful for retrying failed thumbnail generation or regenerating with
1420
+ * different settings. Regeneration is async: poll {@link getThumbnail} (or
1421
+ * use {@link getThumbnailAndWait}) at the same timestamp until the new
1422
+ * frame is ready.
1325
1423
  *
1326
1424
  * @example
1327
1425
  * ```typescript
1328
- * const result = await cdn.regenerateThumbnail({
1426
+ * await cdn.regenerateThumbnail({
1329
1427
  * assetId: 'video-asset-id',
1330
1428
  * timestamp: 5, // 5 seconds into the video
1331
1429
  * width: 1280,
1332
1430
  * format: 'jpg',
1333
1431
  * });
1334
- * console.log(`Thumbnail regeneration queued: ${result.status}`);
1432
+ * const thumbnail = await cdn.getThumbnailAndWait({ assetId: 'video-asset-id', timestamp: 5 });
1433
+ * console.log(`Thumbnail URL: ${thumbnail.url}`);
1335
1434
  * ```
1336
1435
  */
1337
1436
  regenerateThumbnail(request: RegenerateThumbnailRequest): Promise<RegenerateThumbnailResponse>;
@@ -1711,6 +1810,33 @@ declare class CDN {
1711
1810
  * });
1712
1811
  * console.log(`Merge job started: ${job.id}`);
1713
1812
  * ```
1813
+ *
1814
+ * @example Composite a screen recording onto a held phone ("POV holding my phone"):
1815
+ * ```typescript
1816
+ * const job = await cdn.createMergeJob({
1817
+ * projectSlug: 'my-project',
1818
+ * inputs: [
1819
+ * { assetId: 'reaction-clip-id' },
1820
+ * {
1821
+ * assetId: 'app-recording-id', // the overlay clip
1822
+ * composite: {
1823
+ * backgroundAssetId: 'holding-phone-shot-id', // image or video
1824
+ * // Corner-pin onto the angled screen (background pixel coords, TL/TR/BL/BR)
1825
+ * quad: {
1826
+ * topLeft: { x: 320, y: 480 },
1827
+ * topRight: { x: 760, y: 500 },
1828
+ * bottomLeft: { x: 300, y: 1400 },
1829
+ * bottomRight: { x: 740, y: 1440 },
1830
+ * },
1831
+ * fit: 'cover',
1832
+ * // Screen area painted #F500FA in the background is keyed out, so the
1833
+ * // recording shows through and fingers over the screen occlude it
1834
+ * chromaKey: { color: '#F500FA', similarity: 0.34, blend: 0.06 },
1835
+ * },
1836
+ * },
1837
+ * ],
1838
+ * });
1839
+ * ```
1714
1840
  */
1715
1841
  createMergeJob(request: CreateMergeJobRequest): Promise<MergeJob>;
1716
1842
  /**
@@ -1869,4 +1995,4 @@ declare class CDN {
1869
1995
  private convertImportFileDates;
1870
1996
  }
1871
1997
 
1872
- export { type Asset, type AssetStatus, type AssetType, type AudioTrackInput, type BundleDownloadUrlRequest, type BundleDownloadUrlResponse, type BundleStatus, CDN, type CancelImportResponse, type CancelMergeJobRequest, type CdnEnvironment, type CdnStorageBreakdownItem, type CdnStorageBreakdownRequest, type CdnStorageBreakdownResponse, type CdnUsageDataPoint, type CdnUsageHistoryRequest, type CdnUsageHistoryResponse, type CdnUsageRequest, type CdnUsageResponse, type ConfirmUploadRequest, type ConfirmUploadResponse, type CreateBundleRequest, type CreateBundleResponse, type CreateFolderRequest, type CreateImportRequest, type CreateImportResponse, type CreateMergeJobRequest, type DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type DownloadBundle, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderListItem, type FolderTreeNode, type GenerateGifRequest, type GetAssetRequest, type GetFolderByPathRequest, type GetFolderRequest, type GetFolderTreeRequest, type GetMergeJobRequest, type GifStatus, type ImageWatermarkConfig, type ImageWatermarkPosition, type ImageWatermarkSizingMode, type ImportAuthType, type ImportError, type ImportFile, type ImportFileStatus, type ImportJob, type ImportJobStatus, type ImportJobSummary, type ImportPathMode, type ListAssetsRequest, type ListAssetsResponse, type ListBundlesRequest, type ListBundlesResponse, type ListFoldersRequest, type ListFoldersResponse, type ListGifsRequest, type ListImportFilesRequest, type ListImportFilesResponse, type ListImportsRequest, type ListImportsResponse, type ListJobsRequest, type ListJobsResponse, type ListMergeJobsRequest, type ListMergeJobsResponse, type ListPrivateFilesRequest, type ListPrivateFilesResponse, type ListThumbnailsRequest, type ListThumbnailsResponse, type MergeAspectRatio, type MergeInputItem, type MergeJob, type MergeJobWithOutput, type MergeOutputConfig, type MergeOutputFormat, type MergeQuality, type MergeStatus, type MoveAssetsRequest, type MoveAssetsResponse, type MoveFolderRequest, type MoveFolderResponse, type MovePrivateFilesRequest, type MovePrivateFilesResponse, type PrivateDownloadUrlRequest, type PrivateDownloadUrlResponse, type PrivateFile, type PrivateFileStatus, type PrivateUploadUrlRequest, type PrivateUploadUrlResponse, type RegenerateThumbnailRequest, type RegenerateThumbnailResponse, type RetryImportResponse, type StreamingUrls, type TextOverlay, type TextOverlayShadow, type TextOverlayStroke, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UpdateFolderRequest, type UpdatePrivateFileRequest, type UploadFromUrlRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoGif, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };
1998
+ export { type Asset, type AssetStatus, type AssetType, type AudioTrackInput, type BundleDownloadUrlRequest, type BundleDownloadUrlResponse, type BundleStatus, CDN, type CancelImportResponse, type CancelMergeJobRequest, type CdnEnvironment, type CdnStorageBreakdownItem, type CdnStorageBreakdownRequest, type CdnStorageBreakdownResponse, type CdnUsageDataPoint, type CdnUsageHistoryRequest, type CdnUsageHistoryResponse, type CdnUsageRequest, type CdnUsageResponse, type CompositeChromaKey, type CompositeConfig, type CompositePoint, type CompositeQuad, type CompositeRect, type ConfirmUploadRequest, type ConfirmUploadResponse, type CreateBundleRequest, type CreateBundleResponse, type CreateFolderRequest, type CreateImportRequest, type CreateImportResponse, type CreateMergeJobRequest, type DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type DownloadBundle, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderListItem, type FolderTreeNode, type GenerateGifRequest, type GetAssetRequest, type GetFolderByPathRequest, type GetFolderRequest, type GetFolderTreeRequest, type GetMergeJobRequest, type GifStatus, type ImageVideoWatermarkOptions, type ImageWatermarkConfig, type ImageWatermarkPosition, type ImageWatermarkSizingMode, type ImportAuthType, type ImportError, type ImportFile, type ImportFileStatus, type ImportJob, type ImportJobStatus, type ImportJobSummary, type ImportPathMode, type ListAssetsRequest, type ListAssetsResponse, type ListBundlesRequest, type ListBundlesResponse, type ListFoldersRequest, type ListFoldersResponse, type ListGifsRequest, type ListImportFilesRequest, type ListImportFilesResponse, type ListImportsRequest, type ListImportsResponse, type ListJobsRequest, type ListJobsResponse, type ListMergeJobsRequest, type ListMergeJobsResponse, type ListPrivateFilesRequest, type ListPrivateFilesResponse, type ListThumbnailsRequest, type ListThumbnailsResponse, type MergeAspectRatio, type MergeInputItem, type MergeJob, type MergeJobWithOutput, type MergeOutputConfig, type MergeOutputFormat, type MergeQuality, type MergeStatus, type MoveAssetsRequest, type MoveAssetsResponse, type MoveFolderRequest, type MoveFolderResponse, type MovePrivateFilesRequest, type MovePrivateFilesResponse, type PrivateDownloadUrlRequest, type PrivateDownloadUrlResponse, type PrivateFile, type PrivateFileStatus, type PrivateUploadUrlRequest, type PrivateUploadUrlResponse, type RegenerateThumbnailRequest, type RegenerateThumbnailResponse, type RetryImportResponse, type StreamingUrls, type TextOverlay, type TextOverlayShadow, type TextOverlayStroke, type TextVideoWatermarkOptions, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UpdateFolderRequest, type UpdatePrivateFileRequest, type UploadFromUrlRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoGif, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };