@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/index.mjs CHANGED
@@ -911,10 +911,25 @@ var CDN = class {
911
911
  * filename: 'image.jpg',
912
912
  * mimeType: 'image/jpeg',
913
913
  * });
914
+ *
915
+ * // With watermark
916
+ * const watermarkedAsset = await cdn.upload({
917
+ * projectSlug: 'my-project',
918
+ * file: fileBuffer,
919
+ * filename: 'photo.jpg',
920
+ * mimeType: 'image/jpeg',
921
+ * watermark: {
922
+ * assetId: 'logo-asset-id', // or url: 'https://example.com/logo.png'
923
+ * position: 'bottom-right',
924
+ * opacity: 50,
925
+ * sizingMode: 'relative',
926
+ * width: 15, // 15% of image width
927
+ * },
928
+ * });
914
929
  * ```
915
930
  */
916
931
  async upload(options) {
917
- const { projectSlug, file, filename, mimeType, folder, metadata } = options;
932
+ const { projectSlug, file, filename, mimeType, folder, metadata, watermark } = options;
918
933
  let size;
919
934
  if (file instanceof Blob) {
920
935
  size = file.size;
@@ -929,7 +944,8 @@ var CDN = class {
929
944
  mimeType,
930
945
  size,
931
946
  folder,
932
- metadata
947
+ metadata,
948
+ watermark
933
949
  });
934
950
  const uploadResponse = await fetch(uploadUrl, {
935
951
  method: "PUT",
@@ -1430,10 +1446,9 @@ var CDN = class {
1430
1446
  * ```
1431
1447
  */
1432
1448
  async getPrivateDownloadUrl(request) {
1433
- const response = await this.http.post(
1434
- `/cdn/private/${request.fileId}/download`,
1435
- { expiresIn: request.expiresIn }
1436
- );
1449
+ const response = await this.http.post(`/cdn/private/${request.fileId}/download`, {
1450
+ expiresIn: request.expiresIn
1451
+ });
1437
1452
  if (typeof response.expiresAt === "string") {
1438
1453
  response.expiresAt = new Date(response.expiresAt);
1439
1454
  }
@@ -1571,10 +1586,9 @@ var CDN = class {
1571
1586
  * ```
1572
1587
  */
1573
1588
  async getBundleDownloadUrl(request) {
1574
- const response = await this.http.post(
1575
- `/cdn/bundles/${request.bundleId}/download`,
1576
- { expiresIn: request.expiresIn }
1577
- );
1589
+ const response = await this.http.post(`/cdn/bundles/${request.bundleId}/download`, {
1590
+ expiresIn: request.expiresIn
1591
+ });
1578
1592
  if (typeof response.expiresAt === "string") {
1579
1593
  response.expiresAt = new Date(response.expiresAt);
1580
1594
  }
@@ -1816,6 +1830,113 @@ var CDN = class {
1816
1830
  async movePrivateFiles(request) {
1817
1831
  return this.http.post("/cdn/private/move", request);
1818
1832
  }
1833
+ // ============================================================================
1834
+ // Video Merge Methods
1835
+ // ============================================================================
1836
+ /**
1837
+ * Create a merge job to combine multiple videos/images with optional audio overlay
1838
+ *
1839
+ * Merge jobs combine multiple assets (videos, images) in sequence and can
1840
+ * optionally overlay an audio track. Images require a duration to be specified.
1841
+ *
1842
+ * @example
1843
+ * ```typescript
1844
+ * const job = await cdn.createMergeJob({
1845
+ * projectSlug: 'my-project',
1846
+ * inputs: [
1847
+ * { assetId: 'intro-video-id' },
1848
+ * { assetId: 'image-id', duration: 5 }, // Show image for 5 seconds
1849
+ * { assetId: 'main-video-id', startTime: 10, endTime: 60 }, // Trim to 50 seconds
1850
+ * ],
1851
+ * audioTrack: {
1852
+ * assetId: 'background-music-id',
1853
+ * loop: true,
1854
+ * fadeIn: 2,
1855
+ * fadeOut: 3,
1856
+ * },
1857
+ * output: {
1858
+ * format: 'mp4',
1859
+ * quality: '1080p',
1860
+ * filename: 'final-video.mp4',
1861
+ * },
1862
+ * webhookUrl: 'https://your-app.com/webhook',
1863
+ * });
1864
+ * console.log(`Merge job started: ${job.id}`);
1865
+ * ```
1866
+ */
1867
+ async createMergeJob(request) {
1868
+ const response = await this.http.post("/cdn/video/merge", request);
1869
+ return this.convertMergeJobDates(response);
1870
+ }
1871
+ /**
1872
+ * Get a merge job by ID with output asset details
1873
+ *
1874
+ * @example
1875
+ * ```typescript
1876
+ * const job = await cdn.getMergeJob('job-id');
1877
+ * if (job.status === 'completed' && job.outputAsset) {
1878
+ * console.log(`Output video: ${job.outputAsset.cdnUrl}`);
1879
+ * }
1880
+ * ```
1881
+ */
1882
+ async getMergeJob(jobId) {
1883
+ const response = await this.http.get(`/cdn/video/merge/${jobId}`);
1884
+ return this.convertMergeJobWithOutputDates(response);
1885
+ }
1886
+ /**
1887
+ * List merge jobs with optional filters
1888
+ *
1889
+ * @example
1890
+ * ```typescript
1891
+ * const { jobs, total, hasMore } = await cdn.listMergeJobs({
1892
+ * projectSlug: 'my-project',
1893
+ * status: 'completed',
1894
+ * limit: 20,
1895
+ * });
1896
+ * ```
1897
+ */
1898
+ async listMergeJobs(request) {
1899
+ const params = new URLSearchParams();
1900
+ params.set("projectSlug", request.projectSlug);
1901
+ if (request.status) params.set("status", request.status);
1902
+ if (request.limit) params.set("limit", request.limit.toString());
1903
+ if (request.offset) params.set("offset", request.offset.toString());
1904
+ const response = await this.http.get(`/cdn/video/merge?${params.toString()}`);
1905
+ return {
1906
+ ...response,
1907
+ jobs: response.jobs.map((job) => this.convertMergeJobDates(job))
1908
+ };
1909
+ }
1910
+ /**
1911
+ * Cancel a pending or processing merge job
1912
+ *
1913
+ * @example
1914
+ * ```typescript
1915
+ * await cdn.cancelMergeJob('job-id');
1916
+ * console.log('Merge job cancelled');
1917
+ * ```
1918
+ */
1919
+ async cancelMergeJob(jobId) {
1920
+ return this.http.post(`/cdn/video/merge/${jobId}/cancel`, {});
1921
+ }
1922
+ convertMergeJobDates(job) {
1923
+ if (typeof job.createdAt === "string") {
1924
+ job.createdAt = new Date(job.createdAt);
1925
+ }
1926
+ if (job.updatedAt && typeof job.updatedAt === "string") {
1927
+ job.updatedAt = new Date(job.updatedAt);
1928
+ }
1929
+ if (job.startedAt && typeof job.startedAt === "string") {
1930
+ job.startedAt = new Date(job.startedAt);
1931
+ }
1932
+ if (job.completedAt && typeof job.completedAt === "string") {
1933
+ job.completedAt = new Date(job.completedAt);
1934
+ }
1935
+ return job;
1936
+ }
1937
+ convertMergeJobWithOutputDates(job) {
1938
+ return this.convertMergeJobDates(job);
1939
+ }
1819
1940
  };
1820
1941
 
1821
1942
  // src/screenshots/client.ts