@stack0/sdk 0.5.5 → 0.5.7
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 +114 -1
- package/dist/cdn/index.d.ts +114 -1
- package/dist/cdn/index.js +24 -10
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +24 -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 +24 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -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;
|
|
@@ -492,6 +538,54 @@ interface MovePrivateFilesResponse {
|
|
|
492
538
|
type MergeStatus = TranscodingStatus;
|
|
493
539
|
type MergeQuality = VideoQuality;
|
|
494
540
|
type MergeOutputFormat = "mp4" | "webm";
|
|
541
|
+
/**
|
|
542
|
+
* Text overlay shadow configuration
|
|
543
|
+
*/
|
|
544
|
+
interface TextOverlayShadow {
|
|
545
|
+
/** Shadow color in hex format (e.g., "#000000") */
|
|
546
|
+
color?: string;
|
|
547
|
+
/** Horizontal shadow offset in pixels (0-20) */
|
|
548
|
+
offsetX?: number;
|
|
549
|
+
/** Vertical shadow offset in pixels (0-20) */
|
|
550
|
+
offsetY?: number;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Text overlay stroke/outline configuration
|
|
554
|
+
*/
|
|
555
|
+
interface TextOverlayStroke {
|
|
556
|
+
/** Stroke color in hex format (e.g., "#000000") */
|
|
557
|
+
color?: string;
|
|
558
|
+
/** Stroke width in pixels (1-10) */
|
|
559
|
+
width?: number;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Text overlay configuration for adding captions to videos/images.
|
|
563
|
+
* Perfect for creating TikTok/Instagram style videos with text overlays.
|
|
564
|
+
*/
|
|
565
|
+
interface TextOverlay {
|
|
566
|
+
/** The text to display (1-500 characters) */
|
|
567
|
+
text: string;
|
|
568
|
+
/** Vertical position of the text (default: "bottom") */
|
|
569
|
+
position?: "top" | "center" | "bottom";
|
|
570
|
+
/** Font size in pixels (12-200, default: 48) */
|
|
571
|
+
fontSize?: number;
|
|
572
|
+
/** Font family (default: "Liberation Sans") */
|
|
573
|
+
fontFamily?: string;
|
|
574
|
+
/** Font weight (default: "bold") */
|
|
575
|
+
fontWeight?: "normal" | "bold";
|
|
576
|
+
/** Text color in hex format (default: "#FFFFFF") */
|
|
577
|
+
color?: string;
|
|
578
|
+
/** Background color (e.g., "rgba(0,0,0,0.5)") */
|
|
579
|
+
backgroundColor?: string;
|
|
580
|
+
/** Padding from edges in pixels (0-100, default: 20) */
|
|
581
|
+
padding?: number;
|
|
582
|
+
/** Maximum width as percentage of video width (10-100, default: 90) */
|
|
583
|
+
maxWidth?: number;
|
|
584
|
+
/** Shadow configuration for depth effect */
|
|
585
|
+
shadow?: TextOverlayShadow;
|
|
586
|
+
/** Stroke/outline configuration for better visibility */
|
|
587
|
+
stroke?: TextOverlayStroke;
|
|
588
|
+
}
|
|
495
589
|
/**
|
|
496
590
|
* A single input item for the merge operation.
|
|
497
591
|
* Can be a video, image, or audio file.
|
|
@@ -505,6 +599,8 @@ interface MergeInputItem {
|
|
|
505
599
|
startTime?: number;
|
|
506
600
|
/** End time in seconds for trimming (videos only) */
|
|
507
601
|
endTime?: number;
|
|
602
|
+
/** Text overlay/caption configuration */
|
|
603
|
+
textOverlay?: TextOverlay;
|
|
508
604
|
}
|
|
509
605
|
/**
|
|
510
606
|
* Audio track overlay configuration for merge jobs.
|
|
@@ -667,6 +763,21 @@ declare class CDN {
|
|
|
667
763
|
* filename: 'image.jpg',
|
|
668
764
|
* mimeType: 'image/jpeg',
|
|
669
765
|
* });
|
|
766
|
+
*
|
|
767
|
+
* // With watermark
|
|
768
|
+
* const watermarkedAsset = await cdn.upload({
|
|
769
|
+
* projectSlug: 'my-project',
|
|
770
|
+
* file: fileBuffer,
|
|
771
|
+
* filename: 'photo.jpg',
|
|
772
|
+
* mimeType: 'image/jpeg',
|
|
773
|
+
* watermark: {
|
|
774
|
+
* assetId: 'logo-asset-id', // or url: 'https://example.com/logo.png'
|
|
775
|
+
* position: 'bottom-right',
|
|
776
|
+
* opacity: 50,
|
|
777
|
+
* sizingMode: 'relative',
|
|
778
|
+
* width: 15, // 15% of image width
|
|
779
|
+
* },
|
|
780
|
+
* });
|
|
670
781
|
* ```
|
|
671
782
|
*/
|
|
672
783
|
upload(options: {
|
|
@@ -676,6 +787,8 @@ declare class CDN {
|
|
|
676
787
|
mimeType: string;
|
|
677
788
|
folder?: string;
|
|
678
789
|
metadata?: Record<string, unknown>;
|
|
790
|
+
/** Watermark configuration for images (applied during upload processing) */
|
|
791
|
+
watermark?: ImageWatermarkConfig;
|
|
679
792
|
}): Promise<Asset>;
|
|
680
793
|
/**
|
|
681
794
|
* Get an asset by ID
|
|
@@ -1270,4 +1383,4 @@ declare class CDN {
|
|
|
1270
1383
|
private convertMergeJobWithOutputDates;
|
|
1271
1384
|
}
|
|
1272
1385
|
|
|
1273
|
-
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 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 };
|
|
1386
|
+
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 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 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;
|
|
@@ -492,6 +538,54 @@ interface MovePrivateFilesResponse {
|
|
|
492
538
|
type MergeStatus = TranscodingStatus;
|
|
493
539
|
type MergeQuality = VideoQuality;
|
|
494
540
|
type MergeOutputFormat = "mp4" | "webm";
|
|
541
|
+
/**
|
|
542
|
+
* Text overlay shadow configuration
|
|
543
|
+
*/
|
|
544
|
+
interface TextOverlayShadow {
|
|
545
|
+
/** Shadow color in hex format (e.g., "#000000") */
|
|
546
|
+
color?: string;
|
|
547
|
+
/** Horizontal shadow offset in pixels (0-20) */
|
|
548
|
+
offsetX?: number;
|
|
549
|
+
/** Vertical shadow offset in pixels (0-20) */
|
|
550
|
+
offsetY?: number;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Text overlay stroke/outline configuration
|
|
554
|
+
*/
|
|
555
|
+
interface TextOverlayStroke {
|
|
556
|
+
/** Stroke color in hex format (e.g., "#000000") */
|
|
557
|
+
color?: string;
|
|
558
|
+
/** Stroke width in pixels (1-10) */
|
|
559
|
+
width?: number;
|
|
560
|
+
}
|
|
561
|
+
/**
|
|
562
|
+
* Text overlay configuration for adding captions to videos/images.
|
|
563
|
+
* Perfect for creating TikTok/Instagram style videos with text overlays.
|
|
564
|
+
*/
|
|
565
|
+
interface TextOverlay {
|
|
566
|
+
/** The text to display (1-500 characters) */
|
|
567
|
+
text: string;
|
|
568
|
+
/** Vertical position of the text (default: "bottom") */
|
|
569
|
+
position?: "top" | "center" | "bottom";
|
|
570
|
+
/** Font size in pixels (12-200, default: 48) */
|
|
571
|
+
fontSize?: number;
|
|
572
|
+
/** Font family (default: "Liberation Sans") */
|
|
573
|
+
fontFamily?: string;
|
|
574
|
+
/** Font weight (default: "bold") */
|
|
575
|
+
fontWeight?: "normal" | "bold";
|
|
576
|
+
/** Text color in hex format (default: "#FFFFFF") */
|
|
577
|
+
color?: string;
|
|
578
|
+
/** Background color (e.g., "rgba(0,0,0,0.5)") */
|
|
579
|
+
backgroundColor?: string;
|
|
580
|
+
/** Padding from edges in pixels (0-100, default: 20) */
|
|
581
|
+
padding?: number;
|
|
582
|
+
/** Maximum width as percentage of video width (10-100, default: 90) */
|
|
583
|
+
maxWidth?: number;
|
|
584
|
+
/** Shadow configuration for depth effect */
|
|
585
|
+
shadow?: TextOverlayShadow;
|
|
586
|
+
/** Stroke/outline configuration for better visibility */
|
|
587
|
+
stroke?: TextOverlayStroke;
|
|
588
|
+
}
|
|
495
589
|
/**
|
|
496
590
|
* A single input item for the merge operation.
|
|
497
591
|
* Can be a video, image, or audio file.
|
|
@@ -505,6 +599,8 @@ interface MergeInputItem {
|
|
|
505
599
|
startTime?: number;
|
|
506
600
|
/** End time in seconds for trimming (videos only) */
|
|
507
601
|
endTime?: number;
|
|
602
|
+
/** Text overlay/caption configuration */
|
|
603
|
+
textOverlay?: TextOverlay;
|
|
508
604
|
}
|
|
509
605
|
/**
|
|
510
606
|
* Audio track overlay configuration for merge jobs.
|
|
@@ -667,6 +763,21 @@ declare class CDN {
|
|
|
667
763
|
* filename: 'image.jpg',
|
|
668
764
|
* mimeType: 'image/jpeg',
|
|
669
765
|
* });
|
|
766
|
+
*
|
|
767
|
+
* // With watermark
|
|
768
|
+
* const watermarkedAsset = await cdn.upload({
|
|
769
|
+
* projectSlug: 'my-project',
|
|
770
|
+
* file: fileBuffer,
|
|
771
|
+
* filename: 'photo.jpg',
|
|
772
|
+
* mimeType: 'image/jpeg',
|
|
773
|
+
* watermark: {
|
|
774
|
+
* assetId: 'logo-asset-id', // or url: 'https://example.com/logo.png'
|
|
775
|
+
* position: 'bottom-right',
|
|
776
|
+
* opacity: 50,
|
|
777
|
+
* sizingMode: 'relative',
|
|
778
|
+
* width: 15, // 15% of image width
|
|
779
|
+
* },
|
|
780
|
+
* });
|
|
670
781
|
* ```
|
|
671
782
|
*/
|
|
672
783
|
upload(options: {
|
|
@@ -676,6 +787,8 @@ declare class CDN {
|
|
|
676
787
|
mimeType: string;
|
|
677
788
|
folder?: string;
|
|
678
789
|
metadata?: Record<string, unknown>;
|
|
790
|
+
/** Watermark configuration for images (applied during upload processing) */
|
|
791
|
+
watermark?: ImageWatermarkConfig;
|
|
679
792
|
}): Promise<Asset>;
|
|
680
793
|
/**
|
|
681
794
|
* Get an asset by ID
|
|
@@ -1270,4 +1383,4 @@ declare class CDN {
|
|
|
1270
1383
|
private convertMergeJobWithOutputDates;
|
|
1271
1384
|
}
|
|
1272
1385
|
|
|
1273
|
-
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 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 };
|
|
1386
|
+
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 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 UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoOutputFormat, type VideoQuality, type VideoThumbnail, type VideoVariant, type WatermarkOptions };
|
package/dist/cdn/index.js
CHANGED
|
@@ -134,10 +134,25 @@ var CDN = class {
|
|
|
134
134
|
* filename: 'image.jpg',
|
|
135
135
|
* mimeType: 'image/jpeg',
|
|
136
136
|
* });
|
|
137
|
+
*
|
|
138
|
+
* // With watermark
|
|
139
|
+
* const watermarkedAsset = await cdn.upload({
|
|
140
|
+
* projectSlug: 'my-project',
|
|
141
|
+
* file: fileBuffer,
|
|
142
|
+
* filename: 'photo.jpg',
|
|
143
|
+
* mimeType: 'image/jpeg',
|
|
144
|
+
* watermark: {
|
|
145
|
+
* assetId: 'logo-asset-id', // or url: 'https://example.com/logo.png'
|
|
146
|
+
* position: 'bottom-right',
|
|
147
|
+
* opacity: 50,
|
|
148
|
+
* sizingMode: 'relative',
|
|
149
|
+
* width: 15, // 15% of image width
|
|
150
|
+
* },
|
|
151
|
+
* });
|
|
137
152
|
* ```
|
|
138
153
|
*/
|
|
139
154
|
async upload(options) {
|
|
140
|
-
const { projectSlug, file, filename, mimeType, folder, metadata } = options;
|
|
155
|
+
const { projectSlug, file, filename, mimeType, folder, metadata, watermark } = options;
|
|
141
156
|
let size;
|
|
142
157
|
if (file instanceof Blob) {
|
|
143
158
|
size = file.size;
|
|
@@ -152,7 +167,8 @@ var CDN = class {
|
|
|
152
167
|
mimeType,
|
|
153
168
|
size,
|
|
154
169
|
folder,
|
|
155
|
-
metadata
|
|
170
|
+
metadata,
|
|
171
|
+
watermark
|
|
156
172
|
});
|
|
157
173
|
const uploadResponse = await fetch(uploadUrl, {
|
|
158
174
|
method: "PUT",
|
|
@@ -653,10 +669,9 @@ var CDN = class {
|
|
|
653
669
|
* ```
|
|
654
670
|
*/
|
|
655
671
|
async getPrivateDownloadUrl(request) {
|
|
656
|
-
const response = await this.http.post(
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
);
|
|
672
|
+
const response = await this.http.post(`/cdn/private/${request.fileId}/download`, {
|
|
673
|
+
expiresIn: request.expiresIn
|
|
674
|
+
});
|
|
660
675
|
if (typeof response.expiresAt === "string") {
|
|
661
676
|
response.expiresAt = new Date(response.expiresAt);
|
|
662
677
|
}
|
|
@@ -794,10 +809,9 @@ var CDN = class {
|
|
|
794
809
|
* ```
|
|
795
810
|
*/
|
|
796
811
|
async getBundleDownloadUrl(request) {
|
|
797
|
-
const response = await this.http.post(
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
);
|
|
812
|
+
const response = await this.http.post(`/cdn/bundles/${request.bundleId}/download`, {
|
|
813
|
+
expiresIn: request.expiresIn
|
|
814
|
+
});
|
|
801
815
|
if (typeof response.expiresAt === "string") {
|
|
802
816
|
response.expiresAt = new Date(response.expiresAt);
|
|
803
817
|
}
|