@stack0/sdk 0.5.4 → 0.5.6
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/cdn/index.d.mts +264 -1
- package/dist/cdn/index.d.ts +264 -1
- package/dist/cdn/index.js +131 -10
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +131 -10
- package/dist/cdn/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +131 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +131 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cdn/index.d.mts
CHANGED
|
@@ -32,6 +32,11 @@ interface UploadUrlRequest {
|
|
|
32
32
|
size: number;
|
|
33
33
|
folder?: string;
|
|
34
34
|
metadata?: Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Watermark configuration for images.
|
|
37
|
+
* When provided, the watermark will be automatically applied during upload processing.
|
|
38
|
+
*/
|
|
39
|
+
watermark?: ImageWatermarkConfig;
|
|
35
40
|
}
|
|
36
41
|
interface UploadUrlResponse {
|
|
37
42
|
uploadUrl: string;
|
|
@@ -171,6 +176,47 @@ interface WatermarkOptions {
|
|
|
171
176
|
position: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center";
|
|
172
177
|
opacity?: number;
|
|
173
178
|
}
|
|
179
|
+
/** Position options for image watermarks */
|
|
180
|
+
type ImageWatermarkPosition = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
181
|
+
/** Sizing mode for image watermarks */
|
|
182
|
+
type ImageWatermarkSizingMode = "absolute" | "relative";
|
|
183
|
+
/**
|
|
184
|
+
* Configuration for applying a watermark to an uploaded image.
|
|
185
|
+
* Watermarks are applied automatically during the upload processing.
|
|
186
|
+
*/
|
|
187
|
+
interface ImageWatermarkConfig {
|
|
188
|
+
/**
|
|
189
|
+
* Source of the watermark image.
|
|
190
|
+
* Provide either assetId (another CDN asset) or url (direct URL).
|
|
191
|
+
*/
|
|
192
|
+
assetId?: string;
|
|
193
|
+
/** Direct URL to watermark image (alternative to assetId) */
|
|
194
|
+
url?: string;
|
|
195
|
+
/** Position of the watermark on the image (default: "bottom-right") */
|
|
196
|
+
position?: ImageWatermarkPosition;
|
|
197
|
+
/** Horizontal offset from position in pixels (default: 0) */
|
|
198
|
+
offsetX?: number;
|
|
199
|
+
/** Vertical offset from position in pixels (default: 0) */
|
|
200
|
+
offsetY?: number;
|
|
201
|
+
/**
|
|
202
|
+
* Sizing mode for the watermark.
|
|
203
|
+
* - "absolute": Use exact width/height in pixels
|
|
204
|
+
* - "relative": Width/height as percentage of the main image (1-100)
|
|
205
|
+
*/
|
|
206
|
+
sizingMode?: ImageWatermarkSizingMode;
|
|
207
|
+
/** Width of the watermark (pixels or percentage based on sizingMode) */
|
|
208
|
+
width?: number;
|
|
209
|
+
/** Height of the watermark (pixels or percentage based on sizingMode) */
|
|
210
|
+
height?: number;
|
|
211
|
+
/** Opacity of the watermark (0-100, default: 100) */
|
|
212
|
+
opacity?: number;
|
|
213
|
+
/** Rotation angle in degrees (-360 to 360, default: 0) */
|
|
214
|
+
rotation?: number;
|
|
215
|
+
/** Whether to tile/repeat the watermark across the image (default: false) */
|
|
216
|
+
tile?: boolean;
|
|
217
|
+
/** Spacing between tiles when tile is true (pixels, default: 100) */
|
|
218
|
+
tileSpacing?: number;
|
|
219
|
+
}
|
|
174
220
|
interface TrimOptions {
|
|
175
221
|
start: number;
|
|
176
222
|
end: number;
|
|
@@ -489,6 +535,135 @@ interface MovePrivateFilesResponse {
|
|
|
489
535
|
success: boolean;
|
|
490
536
|
movedCount: number;
|
|
491
537
|
}
|
|
538
|
+
type MergeStatus = TranscodingStatus;
|
|
539
|
+
type MergeQuality = VideoQuality;
|
|
540
|
+
type MergeOutputFormat = "mp4" | "webm";
|
|
541
|
+
/**
|
|
542
|
+
* A single input item for the merge operation.
|
|
543
|
+
* Can be a video, image, or audio file.
|
|
544
|
+
*/
|
|
545
|
+
interface MergeInputItem {
|
|
546
|
+
/** Asset ID of the file to include */
|
|
547
|
+
assetId: string;
|
|
548
|
+
/** Duration in seconds (required for images, optional for videos) */
|
|
549
|
+
duration?: number;
|
|
550
|
+
/** Start time in seconds for trimming (videos only) */
|
|
551
|
+
startTime?: number;
|
|
552
|
+
/** End time in seconds for trimming (videos only) */
|
|
553
|
+
endTime?: number;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Audio track overlay configuration for merge jobs.
|
|
557
|
+
* Allows adding background audio to the merged video.
|
|
558
|
+
*/
|
|
559
|
+
interface AudioTrackInput {
|
|
560
|
+
/** Asset ID of the audio file */
|
|
561
|
+
assetId: string;
|
|
562
|
+
/** Loop audio if shorter than video (default: false) */
|
|
563
|
+
loop?: boolean;
|
|
564
|
+
/** Fade in duration in seconds (0-10) */
|
|
565
|
+
fadeIn?: number;
|
|
566
|
+
/** Fade out duration in seconds (0-10) */
|
|
567
|
+
fadeOut?: number;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Output configuration for merge jobs
|
|
571
|
+
*/
|
|
572
|
+
interface MergeOutputConfig {
|
|
573
|
+
/** Output format (default: mp4) */
|
|
574
|
+
format?: MergeOutputFormat;
|
|
575
|
+
/** Output quality (default: 720p) */
|
|
576
|
+
quality?: MergeQuality;
|
|
577
|
+
/** Custom filename for the output */
|
|
578
|
+
filename?: string;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Request to create a merge job
|
|
582
|
+
*/
|
|
583
|
+
interface CreateMergeJobRequest {
|
|
584
|
+
/** Project slug to create the merge job in */
|
|
585
|
+
projectSlug: string;
|
|
586
|
+
/** Array of assets to merge (in order), 1-100 items */
|
|
587
|
+
inputs: MergeInputItem[];
|
|
588
|
+
/** Optional audio track to overlay */
|
|
589
|
+
audioTrack?: AudioTrackInput;
|
|
590
|
+
/** Output configuration */
|
|
591
|
+
output?: MergeOutputConfig;
|
|
592
|
+
/** Webhook URL for completion notification */
|
|
593
|
+
webhookUrl?: string;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Request to get a merge job by ID
|
|
597
|
+
*/
|
|
598
|
+
interface GetMergeJobRequest {
|
|
599
|
+
/** Merge job ID (UUID) */
|
|
600
|
+
jobId: string;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Request to list merge jobs
|
|
604
|
+
*/
|
|
605
|
+
interface ListMergeJobsRequest {
|
|
606
|
+
/** Project slug to list jobs for */
|
|
607
|
+
projectSlug: string;
|
|
608
|
+
/** Filter by status */
|
|
609
|
+
status?: MergeStatus;
|
|
610
|
+
/** Maximum number of results (default: 20, max: 100) */
|
|
611
|
+
limit?: number;
|
|
612
|
+
/** Offset for pagination */
|
|
613
|
+
offset?: number;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Request to cancel a merge job
|
|
617
|
+
*/
|
|
618
|
+
interface CancelMergeJobRequest {
|
|
619
|
+
/** Merge job ID (UUID) */
|
|
620
|
+
jobId: string;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Merge job response
|
|
624
|
+
*/
|
|
625
|
+
interface MergeJob {
|
|
626
|
+
id: string;
|
|
627
|
+
organizationId: string;
|
|
628
|
+
projectId: string;
|
|
629
|
+
environment: "sandbox" | "production";
|
|
630
|
+
inputs: MergeInputItem[];
|
|
631
|
+
audioTrackAssetId: string | null;
|
|
632
|
+
outputFormat: MergeOutputFormat;
|
|
633
|
+
outputQuality: MergeQuality;
|
|
634
|
+
outputFilename: string | null;
|
|
635
|
+
outputAssetId: string | null;
|
|
636
|
+
status: MergeStatus;
|
|
637
|
+
progress: number | null;
|
|
638
|
+
errorMessage: string | null;
|
|
639
|
+
startedAt: Date | null;
|
|
640
|
+
completedAt: Date | null;
|
|
641
|
+
totalDurationSeconds: number | null;
|
|
642
|
+
webhookUrl: string | null;
|
|
643
|
+
createdAt: Date;
|
|
644
|
+
updatedAt: Date | null;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Merge job with output asset details
|
|
648
|
+
*/
|
|
649
|
+
interface MergeJobWithOutput extends MergeJob {
|
|
650
|
+
outputAsset: {
|
|
651
|
+
id: string;
|
|
652
|
+
cdnUrl: string;
|
|
653
|
+
directUrl: string;
|
|
654
|
+
filename: string;
|
|
655
|
+
size: number;
|
|
656
|
+
duration: number | null;
|
|
657
|
+
} | null;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* List merge jobs response
|
|
661
|
+
*/
|
|
662
|
+
interface ListMergeJobsResponse {
|
|
663
|
+
jobs: MergeJob[];
|
|
664
|
+
total: number;
|
|
665
|
+
hasMore: boolean;
|
|
666
|
+
}
|
|
492
667
|
|
|
493
668
|
/**
|
|
494
669
|
* Stack0 CDN Client
|
|
@@ -538,6 +713,21 @@ declare class CDN {
|
|
|
538
713
|
* filename: 'image.jpg',
|
|
539
714
|
* mimeType: 'image/jpeg',
|
|
540
715
|
* });
|
|
716
|
+
*
|
|
717
|
+
* // With watermark
|
|
718
|
+
* const watermarkedAsset = await cdn.upload({
|
|
719
|
+
* projectSlug: 'my-project',
|
|
720
|
+
* file: fileBuffer,
|
|
721
|
+
* filename: 'photo.jpg',
|
|
722
|
+
* mimeType: 'image/jpeg',
|
|
723
|
+
* watermark: {
|
|
724
|
+
* assetId: 'logo-asset-id', // or url: 'https://example.com/logo.png'
|
|
725
|
+
* position: 'bottom-right',
|
|
726
|
+
* opacity: 50,
|
|
727
|
+
* sizingMode: 'relative',
|
|
728
|
+
* width: 15, // 15% of image width
|
|
729
|
+
* },
|
|
730
|
+
* });
|
|
541
731
|
* ```
|
|
542
732
|
*/
|
|
543
733
|
upload(options: {
|
|
@@ -547,6 +737,8 @@ declare class CDN {
|
|
|
547
737
|
mimeType: string;
|
|
548
738
|
folder?: string;
|
|
549
739
|
metadata?: Record<string, unknown>;
|
|
740
|
+
/** Watermark configuration for images (applied during upload processing) */
|
|
741
|
+
watermark?: ImageWatermarkConfig;
|
|
550
742
|
}): Promise<Asset>;
|
|
551
743
|
/**
|
|
552
744
|
* Get an asset by ID
|
|
@@ -1068,6 +1260,77 @@ declare class CDN {
|
|
|
1068
1260
|
* ```
|
|
1069
1261
|
*/
|
|
1070
1262
|
movePrivateFiles(request: MovePrivateFilesRequest): Promise<MovePrivateFilesResponse>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Create a merge job to combine multiple videos/images with optional audio overlay
|
|
1265
|
+
*
|
|
1266
|
+
* Merge jobs combine multiple assets (videos, images) in sequence and can
|
|
1267
|
+
* optionally overlay an audio track. Images require a duration to be specified.
|
|
1268
|
+
*
|
|
1269
|
+
* @example
|
|
1270
|
+
* ```typescript
|
|
1271
|
+
* const job = await cdn.createMergeJob({
|
|
1272
|
+
* projectSlug: 'my-project',
|
|
1273
|
+
* inputs: [
|
|
1274
|
+
* { assetId: 'intro-video-id' },
|
|
1275
|
+
* { assetId: 'image-id', duration: 5 }, // Show image for 5 seconds
|
|
1276
|
+
* { assetId: 'main-video-id', startTime: 10, endTime: 60 }, // Trim to 50 seconds
|
|
1277
|
+
* ],
|
|
1278
|
+
* audioTrack: {
|
|
1279
|
+
* assetId: 'background-music-id',
|
|
1280
|
+
* loop: true,
|
|
1281
|
+
* fadeIn: 2,
|
|
1282
|
+
* fadeOut: 3,
|
|
1283
|
+
* },
|
|
1284
|
+
* output: {
|
|
1285
|
+
* format: 'mp4',
|
|
1286
|
+
* quality: '1080p',
|
|
1287
|
+
* filename: 'final-video.mp4',
|
|
1288
|
+
* },
|
|
1289
|
+
* webhookUrl: 'https://your-app.com/webhook',
|
|
1290
|
+
* });
|
|
1291
|
+
* console.log(`Merge job started: ${job.id}`);
|
|
1292
|
+
* ```
|
|
1293
|
+
*/
|
|
1294
|
+
createMergeJob(request: CreateMergeJobRequest): Promise<MergeJob>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Get a merge job by ID with output asset details
|
|
1297
|
+
*
|
|
1298
|
+
* @example
|
|
1299
|
+
* ```typescript
|
|
1300
|
+
* const job = await cdn.getMergeJob('job-id');
|
|
1301
|
+
* if (job.status === 'completed' && job.outputAsset) {
|
|
1302
|
+
* console.log(`Output video: ${job.outputAsset.cdnUrl}`);
|
|
1303
|
+
* }
|
|
1304
|
+
* ```
|
|
1305
|
+
*/
|
|
1306
|
+
getMergeJob(jobId: string): Promise<MergeJobWithOutput>;
|
|
1307
|
+
/**
|
|
1308
|
+
* List merge jobs with optional filters
|
|
1309
|
+
*
|
|
1310
|
+
* @example
|
|
1311
|
+
* ```typescript
|
|
1312
|
+
* const { jobs, total, hasMore } = await cdn.listMergeJobs({
|
|
1313
|
+
* projectSlug: 'my-project',
|
|
1314
|
+
* status: 'completed',
|
|
1315
|
+
* limit: 20,
|
|
1316
|
+
* });
|
|
1317
|
+
* ```
|
|
1318
|
+
*/
|
|
1319
|
+
listMergeJobs(request: ListMergeJobsRequest): Promise<ListMergeJobsResponse>;
|
|
1320
|
+
/**
|
|
1321
|
+
* Cancel a pending or processing merge job
|
|
1322
|
+
*
|
|
1323
|
+
* @example
|
|
1324
|
+
* ```typescript
|
|
1325
|
+
* await cdn.cancelMergeJob('job-id');
|
|
1326
|
+
* console.log('Merge job cancelled');
|
|
1327
|
+
* ```
|
|
1328
|
+
*/
|
|
1329
|
+
cancelMergeJob(jobId: string): Promise<{
|
|
1330
|
+
success: boolean;
|
|
1331
|
+
}>;
|
|
1332
|
+
private convertMergeJobDates;
|
|
1333
|
+
private convertMergeJobWithOutputDates;
|
|
1071
1334
|
}
|
|
1072
1335
|
|
|
1073
|
-
export { type Asset, type AssetStatus, type AssetType, type BundleDownloadUrlRequest, type BundleDownloadUrlResponse, type BundleStatus, CDN, 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 DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type DownloadBundle, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderListItem, type FolderTreeNode, type GetAssetRequest, type GetFolderByPathRequest, type GetFolderRequest, type GetFolderTreeRequest, type ListAssetsRequest, type ListAssetsResponse, type ListBundlesRequest, type ListBundlesResponse, type ListFoldersRequest, type ListFoldersResponse, type ListJobsRequest, type ListJobsResponse, type ListPrivateFilesRequest, type ListPrivateFilesResponse, type ListThumbnailsRequest, type ListThumbnailsResponse, 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 StreamingUrls, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UpdateFolderRequest, type UpdatePrivateFileRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };
|
|
1336
|
+
export { type Asset, type AssetStatus, type AssetType, type AudioTrackInput, type BundleDownloadUrlRequest, type BundleDownloadUrlResponse, type BundleStatus, CDN, 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 CreateMergeJobRequest, type DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type DownloadBundle, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderListItem, type FolderTreeNode, type GetAssetRequest, type GetFolderByPathRequest, type GetFolderRequest, type GetFolderTreeRequest, type GetMergeJobRequest, type ImageWatermarkConfig, type ImageWatermarkPosition, type ImageWatermarkSizingMode, type ListAssetsRequest, type ListAssetsResponse, type ListBundlesRequest, type ListBundlesResponse, type ListFoldersRequest, type ListFoldersResponse, type ListJobsRequest, type ListJobsResponse, type ListMergeJobsRequest, type ListMergeJobsResponse, type ListPrivateFilesRequest, type ListPrivateFilesResponse, type ListThumbnailsRequest, type ListThumbnailsResponse, 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 StreamingUrls, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UpdateFolderRequest, type UpdatePrivateFileRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };
|
package/dist/cdn/index.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ interface UploadUrlRequest {
|
|
|
32
32
|
size: number;
|
|
33
33
|
folder?: string;
|
|
34
34
|
metadata?: Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Watermark configuration for images.
|
|
37
|
+
* When provided, the watermark will be automatically applied during upload processing.
|
|
38
|
+
*/
|
|
39
|
+
watermark?: ImageWatermarkConfig;
|
|
35
40
|
}
|
|
36
41
|
interface UploadUrlResponse {
|
|
37
42
|
uploadUrl: string;
|
|
@@ -171,6 +176,47 @@ interface WatermarkOptions {
|
|
|
171
176
|
position: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center";
|
|
172
177
|
opacity?: number;
|
|
173
178
|
}
|
|
179
|
+
/** Position options for image watermarks */
|
|
180
|
+
type ImageWatermarkPosition = "top-left" | "top-center" | "top-right" | "center-left" | "center" | "center-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
181
|
+
/** Sizing mode for image watermarks */
|
|
182
|
+
type ImageWatermarkSizingMode = "absolute" | "relative";
|
|
183
|
+
/**
|
|
184
|
+
* Configuration for applying a watermark to an uploaded image.
|
|
185
|
+
* Watermarks are applied automatically during the upload processing.
|
|
186
|
+
*/
|
|
187
|
+
interface ImageWatermarkConfig {
|
|
188
|
+
/**
|
|
189
|
+
* Source of the watermark image.
|
|
190
|
+
* Provide either assetId (another CDN asset) or url (direct URL).
|
|
191
|
+
*/
|
|
192
|
+
assetId?: string;
|
|
193
|
+
/** Direct URL to watermark image (alternative to assetId) */
|
|
194
|
+
url?: string;
|
|
195
|
+
/** Position of the watermark on the image (default: "bottom-right") */
|
|
196
|
+
position?: ImageWatermarkPosition;
|
|
197
|
+
/** Horizontal offset from position in pixels (default: 0) */
|
|
198
|
+
offsetX?: number;
|
|
199
|
+
/** Vertical offset from position in pixels (default: 0) */
|
|
200
|
+
offsetY?: number;
|
|
201
|
+
/**
|
|
202
|
+
* Sizing mode for the watermark.
|
|
203
|
+
* - "absolute": Use exact width/height in pixels
|
|
204
|
+
* - "relative": Width/height as percentage of the main image (1-100)
|
|
205
|
+
*/
|
|
206
|
+
sizingMode?: ImageWatermarkSizingMode;
|
|
207
|
+
/** Width of the watermark (pixels or percentage based on sizingMode) */
|
|
208
|
+
width?: number;
|
|
209
|
+
/** Height of the watermark (pixels or percentage based on sizingMode) */
|
|
210
|
+
height?: number;
|
|
211
|
+
/** Opacity of the watermark (0-100, default: 100) */
|
|
212
|
+
opacity?: number;
|
|
213
|
+
/** Rotation angle in degrees (-360 to 360, default: 0) */
|
|
214
|
+
rotation?: number;
|
|
215
|
+
/** Whether to tile/repeat the watermark across the image (default: false) */
|
|
216
|
+
tile?: boolean;
|
|
217
|
+
/** Spacing between tiles when tile is true (pixels, default: 100) */
|
|
218
|
+
tileSpacing?: number;
|
|
219
|
+
}
|
|
174
220
|
interface TrimOptions {
|
|
175
221
|
start: number;
|
|
176
222
|
end: number;
|
|
@@ -489,6 +535,135 @@ interface MovePrivateFilesResponse {
|
|
|
489
535
|
success: boolean;
|
|
490
536
|
movedCount: number;
|
|
491
537
|
}
|
|
538
|
+
type MergeStatus = TranscodingStatus;
|
|
539
|
+
type MergeQuality = VideoQuality;
|
|
540
|
+
type MergeOutputFormat = "mp4" | "webm";
|
|
541
|
+
/**
|
|
542
|
+
* A single input item for the merge operation.
|
|
543
|
+
* Can be a video, image, or audio file.
|
|
544
|
+
*/
|
|
545
|
+
interface MergeInputItem {
|
|
546
|
+
/** Asset ID of the file to include */
|
|
547
|
+
assetId: string;
|
|
548
|
+
/** Duration in seconds (required for images, optional for videos) */
|
|
549
|
+
duration?: number;
|
|
550
|
+
/** Start time in seconds for trimming (videos only) */
|
|
551
|
+
startTime?: number;
|
|
552
|
+
/** End time in seconds for trimming (videos only) */
|
|
553
|
+
endTime?: number;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Audio track overlay configuration for merge jobs.
|
|
557
|
+
* Allows adding background audio to the merged video.
|
|
558
|
+
*/
|
|
559
|
+
interface AudioTrackInput {
|
|
560
|
+
/** Asset ID of the audio file */
|
|
561
|
+
assetId: string;
|
|
562
|
+
/** Loop audio if shorter than video (default: false) */
|
|
563
|
+
loop?: boolean;
|
|
564
|
+
/** Fade in duration in seconds (0-10) */
|
|
565
|
+
fadeIn?: number;
|
|
566
|
+
/** Fade out duration in seconds (0-10) */
|
|
567
|
+
fadeOut?: number;
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Output configuration for merge jobs
|
|
571
|
+
*/
|
|
572
|
+
interface MergeOutputConfig {
|
|
573
|
+
/** Output format (default: mp4) */
|
|
574
|
+
format?: MergeOutputFormat;
|
|
575
|
+
/** Output quality (default: 720p) */
|
|
576
|
+
quality?: MergeQuality;
|
|
577
|
+
/** Custom filename for the output */
|
|
578
|
+
filename?: string;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Request to create a merge job
|
|
582
|
+
*/
|
|
583
|
+
interface CreateMergeJobRequest {
|
|
584
|
+
/** Project slug to create the merge job in */
|
|
585
|
+
projectSlug: string;
|
|
586
|
+
/** Array of assets to merge (in order), 1-100 items */
|
|
587
|
+
inputs: MergeInputItem[];
|
|
588
|
+
/** Optional audio track to overlay */
|
|
589
|
+
audioTrack?: AudioTrackInput;
|
|
590
|
+
/** Output configuration */
|
|
591
|
+
output?: MergeOutputConfig;
|
|
592
|
+
/** Webhook URL for completion notification */
|
|
593
|
+
webhookUrl?: string;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Request to get a merge job by ID
|
|
597
|
+
*/
|
|
598
|
+
interface GetMergeJobRequest {
|
|
599
|
+
/** Merge job ID (UUID) */
|
|
600
|
+
jobId: string;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* Request to list merge jobs
|
|
604
|
+
*/
|
|
605
|
+
interface ListMergeJobsRequest {
|
|
606
|
+
/** Project slug to list jobs for */
|
|
607
|
+
projectSlug: string;
|
|
608
|
+
/** Filter by status */
|
|
609
|
+
status?: MergeStatus;
|
|
610
|
+
/** Maximum number of results (default: 20, max: 100) */
|
|
611
|
+
limit?: number;
|
|
612
|
+
/** Offset for pagination */
|
|
613
|
+
offset?: number;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Request to cancel a merge job
|
|
617
|
+
*/
|
|
618
|
+
interface CancelMergeJobRequest {
|
|
619
|
+
/** Merge job ID (UUID) */
|
|
620
|
+
jobId: string;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Merge job response
|
|
624
|
+
*/
|
|
625
|
+
interface MergeJob {
|
|
626
|
+
id: string;
|
|
627
|
+
organizationId: string;
|
|
628
|
+
projectId: string;
|
|
629
|
+
environment: "sandbox" | "production";
|
|
630
|
+
inputs: MergeInputItem[];
|
|
631
|
+
audioTrackAssetId: string | null;
|
|
632
|
+
outputFormat: MergeOutputFormat;
|
|
633
|
+
outputQuality: MergeQuality;
|
|
634
|
+
outputFilename: string | null;
|
|
635
|
+
outputAssetId: string | null;
|
|
636
|
+
status: MergeStatus;
|
|
637
|
+
progress: number | null;
|
|
638
|
+
errorMessage: string | null;
|
|
639
|
+
startedAt: Date | null;
|
|
640
|
+
completedAt: Date | null;
|
|
641
|
+
totalDurationSeconds: number | null;
|
|
642
|
+
webhookUrl: string | null;
|
|
643
|
+
createdAt: Date;
|
|
644
|
+
updatedAt: Date | null;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* Merge job with output asset details
|
|
648
|
+
*/
|
|
649
|
+
interface MergeJobWithOutput extends MergeJob {
|
|
650
|
+
outputAsset: {
|
|
651
|
+
id: string;
|
|
652
|
+
cdnUrl: string;
|
|
653
|
+
directUrl: string;
|
|
654
|
+
filename: string;
|
|
655
|
+
size: number;
|
|
656
|
+
duration: number | null;
|
|
657
|
+
} | null;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* List merge jobs response
|
|
661
|
+
*/
|
|
662
|
+
interface ListMergeJobsResponse {
|
|
663
|
+
jobs: MergeJob[];
|
|
664
|
+
total: number;
|
|
665
|
+
hasMore: boolean;
|
|
666
|
+
}
|
|
492
667
|
|
|
493
668
|
/**
|
|
494
669
|
* Stack0 CDN Client
|
|
@@ -538,6 +713,21 @@ declare class CDN {
|
|
|
538
713
|
* filename: 'image.jpg',
|
|
539
714
|
* mimeType: 'image/jpeg',
|
|
540
715
|
* });
|
|
716
|
+
*
|
|
717
|
+
* // With watermark
|
|
718
|
+
* const watermarkedAsset = await cdn.upload({
|
|
719
|
+
* projectSlug: 'my-project',
|
|
720
|
+
* file: fileBuffer,
|
|
721
|
+
* filename: 'photo.jpg',
|
|
722
|
+
* mimeType: 'image/jpeg',
|
|
723
|
+
* watermark: {
|
|
724
|
+
* assetId: 'logo-asset-id', // or url: 'https://example.com/logo.png'
|
|
725
|
+
* position: 'bottom-right',
|
|
726
|
+
* opacity: 50,
|
|
727
|
+
* sizingMode: 'relative',
|
|
728
|
+
* width: 15, // 15% of image width
|
|
729
|
+
* },
|
|
730
|
+
* });
|
|
541
731
|
* ```
|
|
542
732
|
*/
|
|
543
733
|
upload(options: {
|
|
@@ -547,6 +737,8 @@ declare class CDN {
|
|
|
547
737
|
mimeType: string;
|
|
548
738
|
folder?: string;
|
|
549
739
|
metadata?: Record<string, unknown>;
|
|
740
|
+
/** Watermark configuration for images (applied during upload processing) */
|
|
741
|
+
watermark?: ImageWatermarkConfig;
|
|
550
742
|
}): Promise<Asset>;
|
|
551
743
|
/**
|
|
552
744
|
* Get an asset by ID
|
|
@@ -1068,6 +1260,77 @@ declare class CDN {
|
|
|
1068
1260
|
* ```
|
|
1069
1261
|
*/
|
|
1070
1262
|
movePrivateFiles(request: MovePrivateFilesRequest): Promise<MovePrivateFilesResponse>;
|
|
1263
|
+
/**
|
|
1264
|
+
* Create a merge job to combine multiple videos/images with optional audio overlay
|
|
1265
|
+
*
|
|
1266
|
+
* Merge jobs combine multiple assets (videos, images) in sequence and can
|
|
1267
|
+
* optionally overlay an audio track. Images require a duration to be specified.
|
|
1268
|
+
*
|
|
1269
|
+
* @example
|
|
1270
|
+
* ```typescript
|
|
1271
|
+
* const job = await cdn.createMergeJob({
|
|
1272
|
+
* projectSlug: 'my-project',
|
|
1273
|
+
* inputs: [
|
|
1274
|
+
* { assetId: 'intro-video-id' },
|
|
1275
|
+
* { assetId: 'image-id', duration: 5 }, // Show image for 5 seconds
|
|
1276
|
+
* { assetId: 'main-video-id', startTime: 10, endTime: 60 }, // Trim to 50 seconds
|
|
1277
|
+
* ],
|
|
1278
|
+
* audioTrack: {
|
|
1279
|
+
* assetId: 'background-music-id',
|
|
1280
|
+
* loop: true,
|
|
1281
|
+
* fadeIn: 2,
|
|
1282
|
+
* fadeOut: 3,
|
|
1283
|
+
* },
|
|
1284
|
+
* output: {
|
|
1285
|
+
* format: 'mp4',
|
|
1286
|
+
* quality: '1080p',
|
|
1287
|
+
* filename: 'final-video.mp4',
|
|
1288
|
+
* },
|
|
1289
|
+
* webhookUrl: 'https://your-app.com/webhook',
|
|
1290
|
+
* });
|
|
1291
|
+
* console.log(`Merge job started: ${job.id}`);
|
|
1292
|
+
* ```
|
|
1293
|
+
*/
|
|
1294
|
+
createMergeJob(request: CreateMergeJobRequest): Promise<MergeJob>;
|
|
1295
|
+
/**
|
|
1296
|
+
* Get a merge job by ID with output asset details
|
|
1297
|
+
*
|
|
1298
|
+
* @example
|
|
1299
|
+
* ```typescript
|
|
1300
|
+
* const job = await cdn.getMergeJob('job-id');
|
|
1301
|
+
* if (job.status === 'completed' && job.outputAsset) {
|
|
1302
|
+
* console.log(`Output video: ${job.outputAsset.cdnUrl}`);
|
|
1303
|
+
* }
|
|
1304
|
+
* ```
|
|
1305
|
+
*/
|
|
1306
|
+
getMergeJob(jobId: string): Promise<MergeJobWithOutput>;
|
|
1307
|
+
/**
|
|
1308
|
+
* List merge jobs with optional filters
|
|
1309
|
+
*
|
|
1310
|
+
* @example
|
|
1311
|
+
* ```typescript
|
|
1312
|
+
* const { jobs, total, hasMore } = await cdn.listMergeJobs({
|
|
1313
|
+
* projectSlug: 'my-project',
|
|
1314
|
+
* status: 'completed',
|
|
1315
|
+
* limit: 20,
|
|
1316
|
+
* });
|
|
1317
|
+
* ```
|
|
1318
|
+
*/
|
|
1319
|
+
listMergeJobs(request: ListMergeJobsRequest): Promise<ListMergeJobsResponse>;
|
|
1320
|
+
/**
|
|
1321
|
+
* Cancel a pending or processing merge job
|
|
1322
|
+
*
|
|
1323
|
+
* @example
|
|
1324
|
+
* ```typescript
|
|
1325
|
+
* await cdn.cancelMergeJob('job-id');
|
|
1326
|
+
* console.log('Merge job cancelled');
|
|
1327
|
+
* ```
|
|
1328
|
+
*/
|
|
1329
|
+
cancelMergeJob(jobId: string): Promise<{
|
|
1330
|
+
success: boolean;
|
|
1331
|
+
}>;
|
|
1332
|
+
private convertMergeJobDates;
|
|
1333
|
+
private convertMergeJobWithOutputDates;
|
|
1071
1334
|
}
|
|
1072
1335
|
|
|
1073
|
-
export { type Asset, type AssetStatus, type AssetType, type BundleDownloadUrlRequest, type BundleDownloadUrlResponse, type BundleStatus, CDN, 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 DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type DownloadBundle, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderListItem, type FolderTreeNode, type GetAssetRequest, type GetFolderByPathRequest, type GetFolderRequest, type GetFolderTreeRequest, type ListAssetsRequest, type ListAssetsResponse, type ListBundlesRequest, type ListBundlesResponse, type ListFoldersRequest, type ListFoldersResponse, type ListJobsRequest, type ListJobsResponse, type ListPrivateFilesRequest, type ListPrivateFilesResponse, type ListThumbnailsRequest, type ListThumbnailsResponse, 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 StreamingUrls, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UpdateFolderRequest, type UpdatePrivateFileRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };
|
|
1336
|
+
export { type Asset, type AssetStatus, type AssetType, type AudioTrackInput, type BundleDownloadUrlRequest, type BundleDownloadUrlResponse, type BundleStatus, CDN, 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 CreateMergeJobRequest, type DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type DownloadBundle, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderListItem, type FolderTreeNode, type GetAssetRequest, type GetFolderByPathRequest, type GetFolderRequest, type GetFolderTreeRequest, type GetMergeJobRequest, type ImageWatermarkConfig, type ImageWatermarkPosition, type ImageWatermarkSizingMode, type ListAssetsRequest, type ListAssetsResponse, type ListBundlesRequest, type ListBundlesResponse, type ListFoldersRequest, type ListFoldersResponse, type ListJobsRequest, type ListJobsResponse, type ListMergeJobsRequest, type ListMergeJobsResponse, type ListPrivateFilesRequest, type ListPrivateFilesResponse, type ListThumbnailsRequest, type ListThumbnailsResponse, 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 StreamingUrls, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UpdateFolderRequest, type UpdatePrivateFileRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };
|