@stack0/sdk 0.5.5 → 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.
@@ -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;
@@ -667,6 +713,21 @@ declare class CDN {
667
713
  * filename: 'image.jpg',
668
714
  * mimeType: 'image/jpeg',
669
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
+ * });
670
731
  * ```
671
732
  */
672
733
  upload(options: {
@@ -676,6 +737,8 @@ declare class CDN {
676
737
  mimeType: string;
677
738
  folder?: string;
678
739
  metadata?: Record<string, unknown>;
740
+ /** Watermark configuration for images (applied during upload processing) */
741
+ watermark?: ImageWatermarkConfig;
679
742
  }): Promise<Asset>;
680
743
  /**
681
744
  * Get an asset by ID
@@ -1270,4 +1333,4 @@ declare class CDN {
1270
1333
  private convertMergeJobWithOutputDates;
1271
1334
  }
1272
1335
 
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 };
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 };
@@ -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;
@@ -667,6 +713,21 @@ declare class CDN {
667
713
  * filename: 'image.jpg',
668
714
  * mimeType: 'image/jpeg',
669
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
+ * });
670
731
  * ```
671
732
  */
672
733
  upload(options: {
@@ -676,6 +737,8 @@ declare class CDN {
676
737
  mimeType: string;
677
738
  folder?: string;
678
739
  metadata?: Record<string, unknown>;
740
+ /** Watermark configuration for images (applied during upload processing) */
741
+ watermark?: ImageWatermarkConfig;
679
742
  }): Promise<Asset>;
680
743
  /**
681
744
  * Get an asset by ID
@@ -1270,4 +1333,4 @@ declare class CDN {
1270
1333
  private convertMergeJobWithOutputDates;
1271
1334
  }
1272
1335
 
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 };
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.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
- `/cdn/private/${request.fileId}/download`,
658
- { expiresIn: request.expiresIn }
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
- `/cdn/bundles/${request.bundleId}/download`,
799
- { expiresIn: request.expiresIn }
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
  }