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