@stack0/sdk 0.2.9 → 0.3.1
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/README.md +233 -10
- package/dist/cdn/index.d.mts +239 -26
- package/dist/cdn/index.d.ts +239 -26
- package/dist/cdn/index.js +219 -20
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +219 -20
- package/dist/cdn/index.mjs.map +1 -1
- package/dist/extraction/index.d.mts +1 -1
- package/dist/extraction/index.d.ts +1 -1
- package/dist/extraction/index.js +33 -29
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/index.mjs +33 -29
- package/dist/extraction/index.mjs.map +1 -1
- package/dist/http-client-Cgie_Rv6.d.mts +25 -0
- package/dist/http-client-Cgie_Rv6.d.ts +25 -0
- package/dist/index.d.mts +1006 -3
- package/dist/index.d.ts +1006 -3
- package/dist/index.js +958 -69
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +957 -70
- package/dist/index.mjs.map +1 -1
- package/dist/mail/index.d.mts +1 -1
- package/dist/mail/index.d.ts +1 -1
- package/dist/mail/index.js +13 -5
- package/dist/mail/index.js.map +1 -1
- package/dist/mail/index.mjs +13 -5
- package/dist/mail/index.mjs.map +1 -1
- package/dist/screenshots/index.d.mts +1 -1
- package/dist/screenshots/index.d.ts +1 -1
- package/dist/screenshots/index.js +32 -26
- package/dist/screenshots/index.js.map +1 -1
- package/dist/screenshots/index.mjs +32 -26
- package/dist/screenshots/index.mjs.map +1 -1
- package/dist/webdata/index.d.mts +1 -1
- package/dist/webdata/index.d.ts +1 -1
- package/dist/webdata/index.js +37 -8
- package/dist/webdata/index.js.map +1 -1
- package/dist/webdata/index.mjs +37 -8
- package/dist/webdata/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/http-client-Wr9lXo9_.d.mts +0 -10
- package/dist/http-client-Wr9lXo9_.d.ts +0 -10
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@ import { Stack0 } from '@stack0/sdk';
|
|
|
50
50
|
const stack0 = new Stack0({
|
|
51
51
|
apiKey: 'stack0_...', // Required: Your API key
|
|
52
52
|
baseUrl: 'https://api.stack0.dev/v1', // Optional: Custom API endpoint
|
|
53
|
+
cdnUrl: 'https://cdn.yourproject.stack0.dev', // Optional: For client-side image transforms
|
|
53
54
|
});
|
|
54
55
|
```
|
|
55
56
|
|
|
@@ -169,24 +170,46 @@ await stack0.cdn.move({
|
|
|
169
170
|
|
|
170
171
|
### Image Transformations
|
|
171
172
|
|
|
172
|
-
|
|
173
|
+
Generate optimized and transformed image URLs client-side (no API call):
|
|
173
174
|
|
|
174
175
|
```typescript
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
quality: 80,
|
|
183
|
-
},
|
|
176
|
+
// Using asset's cdnUrl directly (recommended)
|
|
177
|
+
const url = stack0.cdn.getTransformUrl(asset.cdnUrl, {
|
|
178
|
+
width: 800,
|
|
179
|
+
height: 600,
|
|
180
|
+
fit: 'cover', // 'cover', 'contain', 'fill', 'inside', 'outside'
|
|
181
|
+
format: 'webp', // 'webp', 'jpeg', 'png', 'avif', 'auto'
|
|
182
|
+
quality: 80,
|
|
184
183
|
});
|
|
185
184
|
|
|
185
|
+
// Or using s3Key when cdnUrl is configured in Stack0 options
|
|
186
|
+
const url = stack0.cdn.getTransformUrl(asset.s3Key, { width: 400 });
|
|
187
|
+
|
|
186
188
|
// Use in <img> tag
|
|
187
189
|
// <img src={url} alt="Optimized image" />
|
|
188
190
|
```
|
|
189
191
|
|
|
192
|
+
Advanced transform options:
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
const url = stack0.cdn.getTransformUrl(asset.cdnUrl, {
|
|
196
|
+
width: 800,
|
|
197
|
+
height: 600,
|
|
198
|
+
fit: 'cover',
|
|
199
|
+
format: 'webp',
|
|
200
|
+
quality: 80,
|
|
201
|
+
crop: 'attention', // Smart crop: 'attention', 'entropy', 'center', etc.
|
|
202
|
+
blur: 5, // Blur sigma (0.3-100)
|
|
203
|
+
sharpen: 1.5, // Sharpen sigma
|
|
204
|
+
brightness: 10, // -100 to 100
|
|
205
|
+
saturation: -50, // -100 to 100
|
|
206
|
+
grayscale: true, // Convert to grayscale
|
|
207
|
+
rotate: 90, // 0, 90, 180, 270
|
|
208
|
+
flip: true, // Flip vertically
|
|
209
|
+
flop: true, // Flip horizontally
|
|
210
|
+
});
|
|
211
|
+
```
|
|
212
|
+
|
|
190
213
|
### Folders
|
|
191
214
|
|
|
192
215
|
```typescript
|
|
@@ -208,6 +231,105 @@ await stack0.cdn.deleteFolder('folder-id');
|
|
|
208
231
|
await stack0.cdn.deleteFolder('folder-id', true); // Delete with contents
|
|
209
232
|
```
|
|
210
233
|
|
|
234
|
+
### Video Transcoding
|
|
235
|
+
|
|
236
|
+
Transcode videos into HLS adaptive streaming or MP4 formats for optimal playback.
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
// Start a transcoding job
|
|
240
|
+
const job = await stack0.cdn.transcode({
|
|
241
|
+
projectSlug: 'my-project',
|
|
242
|
+
assetId: 'video-asset-id',
|
|
243
|
+
outputFormat: 'hls', // 'hls' for adaptive streaming, 'mp4' for progressive download
|
|
244
|
+
variants: [
|
|
245
|
+
{ quality: '720p', codec: 'h264' },
|
|
246
|
+
{ quality: '1080p', codec: 'h264' },
|
|
247
|
+
],
|
|
248
|
+
webhookUrl: 'https://your-app.com/webhook', // Optional: get notified when complete
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
console.log(`Job started: ${job.id}, Status: ${job.status}`);
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Check Job Status
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
// Get job by ID
|
|
258
|
+
const job = await stack0.cdn.getJob('job-id');
|
|
259
|
+
console.log(`Status: ${job.status}, Progress: ${job.progress}%`);
|
|
260
|
+
|
|
261
|
+
// List all jobs
|
|
262
|
+
const { jobs, total } = await stack0.cdn.listJobs({
|
|
263
|
+
projectSlug: 'my-project',
|
|
264
|
+
status: 'processing', // Optional filter
|
|
265
|
+
limit: 20,
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// Cancel a pending/processing job
|
|
269
|
+
await stack0.cdn.cancelJob('job-id');
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Get Streaming URLs
|
|
273
|
+
|
|
274
|
+
```typescript
|
|
275
|
+
const urls = await stack0.cdn.getStreamingUrls('asset-id');
|
|
276
|
+
|
|
277
|
+
// HLS URL for adaptive streaming (recommended)
|
|
278
|
+
console.log(`HLS Master Playlist: ${urls.hlsUrl}`);
|
|
279
|
+
|
|
280
|
+
// MP4 URLs for direct download
|
|
281
|
+
for (const mp4 of urls.mp4Urls) {
|
|
282
|
+
console.log(`${mp4.quality}: ${mp4.url}`);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// Thumbnails
|
|
286
|
+
for (const thumb of urls.thumbnails) {
|
|
287
|
+
console.log(`Thumbnail at ${thumb.timestamp}s: ${thumb.url}`);
|
|
288
|
+
}
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Generate Thumbnails
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
const thumbnail = await stack0.cdn.getThumbnail({
|
|
295
|
+
assetId: 'video-asset-id',
|
|
296
|
+
timestamp: 10.5, // 10.5 seconds into the video
|
|
297
|
+
width: 320, // Optional: resize
|
|
298
|
+
format: 'webp', // 'jpg', 'png', 'webp'
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
console.log(`Thumbnail URL: ${thumbnail.url}`);
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Extract Audio
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
const { jobId, status } = await stack0.cdn.extractAudio({
|
|
308
|
+
projectSlug: 'my-project',
|
|
309
|
+
assetId: 'video-asset-id',
|
|
310
|
+
format: 'mp3', // 'mp3', 'aac', 'wav'
|
|
311
|
+
bitrate: 192, // Optional: kbps
|
|
312
|
+
});
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### Video Playback with HLS.js
|
|
316
|
+
|
|
317
|
+
```typescript
|
|
318
|
+
import Hls from 'hls.js';
|
|
319
|
+
|
|
320
|
+
const urls = await stack0.cdn.getStreamingUrls('asset-id');
|
|
321
|
+
|
|
322
|
+
const video = document.getElementById('video');
|
|
323
|
+
if (Hls.isSupported() && urls.hlsUrl) {
|
|
324
|
+
const hls = new Hls();
|
|
325
|
+
hls.loadSource(urls.hlsUrl);
|
|
326
|
+
hls.attachMedia(video);
|
|
327
|
+
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
|
328
|
+
// Safari native HLS support
|
|
329
|
+
video.src = urls.hlsUrl;
|
|
330
|
+
}
|
|
331
|
+
```
|
|
332
|
+
|
|
211
333
|
## Mail API
|
|
212
334
|
|
|
213
335
|
The Mail API is compatible with the Resend API for easy migration.
|
|
@@ -377,6 +499,107 @@ const stack0 = new Stack0({ apiKey: 'stack0_...' });
|
|
|
377
499
|
await stack0.mail.send({ ... });
|
|
378
500
|
```
|
|
379
501
|
|
|
502
|
+
## Screenshots API
|
|
503
|
+
|
|
504
|
+
Capture high-quality screenshots of any webpage.
|
|
505
|
+
|
|
506
|
+
### Basic Screenshot
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
// Capture a screenshot and wait for completion
|
|
510
|
+
const screenshot = await stack0.screenshots.captureAndWait({
|
|
511
|
+
url: 'https://example.com',
|
|
512
|
+
format: 'png',
|
|
513
|
+
fullPage: true,
|
|
514
|
+
blockAds: true,
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
console.log(screenshot.imageUrl);
|
|
518
|
+
console.log(screenshot.imageWidth, screenshot.imageHeight);
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
### Screenshot Options
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
const screenshot = await stack0.screenshots.captureAndWait({
|
|
525
|
+
url: 'https://example.com',
|
|
526
|
+
format: 'png', // 'png' | 'jpeg' | 'webp' | 'pdf'
|
|
527
|
+
quality: 90, // JPEG/WebP quality
|
|
528
|
+
fullPage: true,
|
|
529
|
+
deviceType: 'desktop', // 'desktop' | 'tablet' | 'mobile'
|
|
530
|
+
viewportWidth: 1280,
|
|
531
|
+
viewportHeight: 720,
|
|
532
|
+
// Block unwanted elements
|
|
533
|
+
blockAds: true,
|
|
534
|
+
blockCookieBanners: true,
|
|
535
|
+
blockChatWidgets: true,
|
|
536
|
+
// Wait for content
|
|
537
|
+
waitForSelector: '.main-content',
|
|
538
|
+
waitForTimeout: 2000,
|
|
539
|
+
// Custom headers/cookies for auth
|
|
540
|
+
headers: { 'Authorization': 'Bearer token' },
|
|
541
|
+
cookies: [{ name: 'session', value: 'abc123' }],
|
|
542
|
+
});
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
### Batch Screenshots
|
|
546
|
+
|
|
547
|
+
```typescript
|
|
548
|
+
const job = await stack0.screenshots.batchAndWait({
|
|
549
|
+
urls: ['https://example.com', 'https://example.org'],
|
|
550
|
+
config: { format: 'png', fullPage: true },
|
|
551
|
+
});
|
|
552
|
+
|
|
553
|
+
console.log(`Success: ${job.successfulUrls}, Failed: ${job.failedUrls}`);
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
## Extraction API
|
|
557
|
+
|
|
558
|
+
Extract structured data from any webpage using AI.
|
|
559
|
+
|
|
560
|
+
### Basic Extraction
|
|
561
|
+
|
|
562
|
+
```typescript
|
|
563
|
+
// Extract content as markdown
|
|
564
|
+
const extraction = await stack0.extraction.extractAndWait({
|
|
565
|
+
url: 'https://example.com/article',
|
|
566
|
+
mode: 'markdown',
|
|
567
|
+
includeMetadata: true,
|
|
568
|
+
});
|
|
569
|
+
|
|
570
|
+
console.log(extraction.markdown);
|
|
571
|
+
console.log(extraction.pageMetadata?.title);
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
### Schema-Based Extraction
|
|
575
|
+
|
|
576
|
+
```typescript
|
|
577
|
+
// Extract structured data using a JSON schema
|
|
578
|
+
const extraction = await stack0.extraction.extractAndWait({
|
|
579
|
+
url: 'https://example.com/product',
|
|
580
|
+
mode: 'schema',
|
|
581
|
+
schema: {
|
|
582
|
+
type: 'object',
|
|
583
|
+
properties: {
|
|
584
|
+
name: { type: 'string' },
|
|
585
|
+
price: { type: 'number' },
|
|
586
|
+
description: { type: 'string' },
|
|
587
|
+
},
|
|
588
|
+
required: ['name', 'price'],
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
console.log(extraction.extractedData);
|
|
593
|
+
// { name: 'Product Name', price: 29.99, description: '...' }
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### Extraction Modes
|
|
597
|
+
|
|
598
|
+
- `markdown`: AI-cleaned markdown content
|
|
599
|
+
- `schema`: Structured data matching your schema
|
|
600
|
+
- `auto`: AI determines best extraction
|
|
601
|
+
- `raw`: Raw HTML content
|
|
602
|
+
|
|
380
603
|
## Support
|
|
381
604
|
|
|
382
605
|
- Documentation: https://docs.stack0.com
|
package/dist/cdn/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as HttpClientConfig } from '../http-client-Cgie_Rv6.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Type definitions for Stack0 CDN API
|
|
@@ -92,22 +92,42 @@ interface MoveAssetsResponse {
|
|
|
92
92
|
movedCount: number;
|
|
93
93
|
}
|
|
94
94
|
interface TransformOptions {
|
|
95
|
+
/** Output width (snapped to nearest allowed width for caching) */
|
|
95
96
|
width?: number;
|
|
97
|
+
/** Output height */
|
|
96
98
|
height?: number;
|
|
99
|
+
/** Resize fit mode */
|
|
97
100
|
fit?: "cover" | "contain" | "fill" | "inside" | "outside";
|
|
98
|
-
|
|
101
|
+
/** Output format */
|
|
102
|
+
format?: "webp" | "jpeg" | "png" | "avif" | "auto";
|
|
103
|
+
/** Quality 1-100 */
|
|
99
104
|
quality?: number;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
/** Smart crop position */
|
|
106
|
+
crop?: "attention" | "entropy" | "center" | "top" | "bottom" | "left" | "right";
|
|
107
|
+
/** Manual crop X offset */
|
|
108
|
+
cropX?: number;
|
|
109
|
+
/** Manual crop Y offset */
|
|
110
|
+
cropY?: number;
|
|
111
|
+
/** Manual crop width */
|
|
112
|
+
cropWidth?: number;
|
|
113
|
+
/** Manual crop height */
|
|
114
|
+
cropHeight?: number;
|
|
115
|
+
/** Blur sigma (0.3-100) */
|
|
116
|
+
blur?: number;
|
|
117
|
+
/** Sharpen sigma */
|
|
118
|
+
sharpen?: number;
|
|
119
|
+
/** Brightness adjustment (-100 to 100) */
|
|
120
|
+
brightness?: number;
|
|
121
|
+
/** Saturation adjustment (-100 to 100) */
|
|
122
|
+
saturation?: number;
|
|
123
|
+
/** Convert to grayscale */
|
|
124
|
+
grayscale?: boolean;
|
|
125
|
+
/** Rotation angle (0, 90, 180, 270) */
|
|
126
|
+
rotate?: number;
|
|
127
|
+
/** Flip vertically */
|
|
128
|
+
flip?: boolean;
|
|
129
|
+
/** Flop horizontally */
|
|
130
|
+
flop?: boolean;
|
|
111
131
|
}
|
|
112
132
|
interface FolderTreeNode {
|
|
113
133
|
id: string;
|
|
@@ -135,6 +155,95 @@ interface Folder {
|
|
|
135
155
|
createdAt: Date;
|
|
136
156
|
updatedAt: Date | null;
|
|
137
157
|
}
|
|
158
|
+
type VideoQuality = "360p" | "480p" | "720p" | "1080p" | "1440p" | "2160p";
|
|
159
|
+
type VideoCodec = "h264" | "h265";
|
|
160
|
+
type VideoOutputFormat = "hls" | "mp4";
|
|
161
|
+
type TranscodingStatus = "pending" | "queued" | "processing" | "completed" | "failed" | "cancelled";
|
|
162
|
+
interface VideoVariant {
|
|
163
|
+
quality: VideoQuality;
|
|
164
|
+
codec?: VideoCodec;
|
|
165
|
+
bitrate?: number;
|
|
166
|
+
}
|
|
167
|
+
interface WatermarkOptions {
|
|
168
|
+
type: "image" | "text";
|
|
169
|
+
imageAssetId?: string;
|
|
170
|
+
text?: string;
|
|
171
|
+
position: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center";
|
|
172
|
+
opacity?: number;
|
|
173
|
+
}
|
|
174
|
+
interface TrimOptions {
|
|
175
|
+
start: number;
|
|
176
|
+
end: number;
|
|
177
|
+
}
|
|
178
|
+
interface TranscodeVideoRequest {
|
|
179
|
+
projectSlug: string;
|
|
180
|
+
assetId: string;
|
|
181
|
+
outputFormat: VideoOutputFormat;
|
|
182
|
+
variants: VideoVariant[];
|
|
183
|
+
watermark?: WatermarkOptions;
|
|
184
|
+
trim?: TrimOptions;
|
|
185
|
+
webhookUrl?: string;
|
|
186
|
+
}
|
|
187
|
+
interface TranscodeJob {
|
|
188
|
+
id: string;
|
|
189
|
+
assetId: string;
|
|
190
|
+
status: TranscodingStatus;
|
|
191
|
+
outputFormat: VideoOutputFormat;
|
|
192
|
+
variants: VideoVariant[];
|
|
193
|
+
progress: number | null;
|
|
194
|
+
error: string | null;
|
|
195
|
+
mediaConvertJobId: string | null;
|
|
196
|
+
createdAt: Date;
|
|
197
|
+
startedAt: Date | null;
|
|
198
|
+
completedAt: Date | null;
|
|
199
|
+
}
|
|
200
|
+
interface ListJobsRequest {
|
|
201
|
+
projectSlug: string;
|
|
202
|
+
assetId?: string;
|
|
203
|
+
status?: TranscodingStatus;
|
|
204
|
+
limit?: number;
|
|
205
|
+
offset?: number;
|
|
206
|
+
}
|
|
207
|
+
interface ListJobsResponse {
|
|
208
|
+
jobs: TranscodeJob[];
|
|
209
|
+
total: number;
|
|
210
|
+
hasMore: boolean;
|
|
211
|
+
}
|
|
212
|
+
interface StreamingUrls {
|
|
213
|
+
hlsUrl: string | null;
|
|
214
|
+
mp4Urls: Array<{
|
|
215
|
+
quality: VideoQuality;
|
|
216
|
+
url: string;
|
|
217
|
+
}>;
|
|
218
|
+
thumbnails: Array<{
|
|
219
|
+
url: string;
|
|
220
|
+
timestamp: number;
|
|
221
|
+
width: number;
|
|
222
|
+
height: number;
|
|
223
|
+
}>;
|
|
224
|
+
}
|
|
225
|
+
interface ThumbnailRequest {
|
|
226
|
+
assetId: string;
|
|
227
|
+
timestamp: number;
|
|
228
|
+
width?: number;
|
|
229
|
+
format?: "jpg" | "png" | "webp";
|
|
230
|
+
}
|
|
231
|
+
interface ThumbnailResponse {
|
|
232
|
+
url: string;
|
|
233
|
+
timestamp: number;
|
|
234
|
+
width: number;
|
|
235
|
+
height: number;
|
|
236
|
+
}
|
|
237
|
+
interface ExtractAudioRequest {
|
|
238
|
+
projectSlug: string;
|
|
239
|
+
assetId: string;
|
|
240
|
+
format: "mp3" | "aac" | "wav";
|
|
241
|
+
bitrate?: number;
|
|
242
|
+
}
|
|
243
|
+
interface ExtractAudioResponse {
|
|
244
|
+
jobId: string;
|
|
245
|
+
status: TranscodingStatus;
|
|
246
|
+
}
|
|
138
247
|
|
|
139
248
|
/**
|
|
140
249
|
* Stack0 CDN Client
|
|
@@ -143,7 +252,8 @@ interface Folder {
|
|
|
143
252
|
|
|
144
253
|
declare class CDN {
|
|
145
254
|
private http;
|
|
146
|
-
|
|
255
|
+
private cdnUrl?;
|
|
256
|
+
constructor(config: HttpClientConfig, cdnUrl?: string);
|
|
147
257
|
/**
|
|
148
258
|
* Generate a presigned URL for uploading a file
|
|
149
259
|
*
|
|
@@ -263,23 +373,32 @@ declare class CDN {
|
|
|
263
373
|
*/
|
|
264
374
|
move(request: MoveAssetsRequest): Promise<MoveAssetsResponse>;
|
|
265
375
|
/**
|
|
266
|
-
* Get a transformed image URL
|
|
376
|
+
* Get a transformed image URL (client-side, no API call)
|
|
267
377
|
*
|
|
268
378
|
* @example
|
|
269
379
|
* ```typescript
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* quality: 80,
|
|
278
|
-
* },
|
|
380
|
+
* // Using asset's cdnUrl directly
|
|
381
|
+
* const url = cdn.getTransformUrl(asset.cdnUrl, {
|
|
382
|
+
* width: 800,
|
|
383
|
+
* height: 600,
|
|
384
|
+
* fit: 'cover',
|
|
385
|
+
* format: 'webp',
|
|
386
|
+
* quality: 80,
|
|
279
387
|
* });
|
|
388
|
+
*
|
|
389
|
+
* // Or using cdnUrl from SDK config + s3Key
|
|
390
|
+
* const url = cdn.getTransformUrl(asset.s3Key, { width: 400 });
|
|
280
391
|
* ```
|
|
281
392
|
*/
|
|
282
|
-
getTransformUrl(
|
|
393
|
+
getTransformUrl(assetUrlOrS3Key: string, options: TransformOptions): string;
|
|
394
|
+
/**
|
|
395
|
+
* Build transform query parameters
|
|
396
|
+
*/
|
|
397
|
+
private buildTransformQuery;
|
|
398
|
+
/**
|
|
399
|
+
* Find the nearest allowed width for optimal caching
|
|
400
|
+
*/
|
|
401
|
+
private getNearestWidth;
|
|
283
402
|
/**
|
|
284
403
|
* Get folder tree for navigation
|
|
285
404
|
*
|
|
@@ -317,6 +436,100 @@ declare class CDN {
|
|
|
317
436
|
}>;
|
|
318
437
|
private convertAssetDates;
|
|
319
438
|
private convertFolderDates;
|
|
439
|
+
/**
|
|
440
|
+
* Start a video transcoding job
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```typescript
|
|
444
|
+
* const job = await cdn.transcode({
|
|
445
|
+
* projectSlug: 'my-project',
|
|
446
|
+
* assetId: 'video-asset-id',
|
|
447
|
+
* outputFormat: 'hls',
|
|
448
|
+
* variants: [
|
|
449
|
+
* { quality: '720p', codec: 'h264' },
|
|
450
|
+
* { quality: '1080p', codec: 'h264' },
|
|
451
|
+
* ],
|
|
452
|
+
* webhookUrl: 'https://your-app.com/webhook',
|
|
453
|
+
* });
|
|
454
|
+
* console.log(`Job started: ${job.id}`);
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
transcode(request: TranscodeVideoRequest): Promise<TranscodeJob>;
|
|
458
|
+
/**
|
|
459
|
+
* Get a transcoding job by ID
|
|
460
|
+
*
|
|
461
|
+
* @example
|
|
462
|
+
* ```typescript
|
|
463
|
+
* const job = await cdn.getJob('job-id');
|
|
464
|
+
* console.log(`Status: ${job.status}, Progress: ${job.progress}%`);
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
getJob(jobId: string): Promise<TranscodeJob>;
|
|
468
|
+
/**
|
|
469
|
+
* List transcoding jobs with filters
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```typescript
|
|
473
|
+
* const { jobs, total } = await cdn.listJobs({
|
|
474
|
+
* projectSlug: 'my-project',
|
|
475
|
+
* status: 'processing',
|
|
476
|
+
* limit: 20,
|
|
477
|
+
* });
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
listJobs(request: ListJobsRequest): Promise<ListJobsResponse>;
|
|
481
|
+
/**
|
|
482
|
+
* Cancel a pending or processing transcoding job
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```typescript
|
|
486
|
+
* await cdn.cancelJob('job-id');
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
cancelJob(jobId: string): Promise<{
|
|
490
|
+
success: boolean;
|
|
491
|
+
}>;
|
|
492
|
+
/**
|
|
493
|
+
* Get streaming URLs for a transcoded video
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```typescript
|
|
497
|
+
* const urls = await cdn.getStreamingUrls('asset-id');
|
|
498
|
+
* console.log(`HLS URL: ${urls.hlsUrl}`);
|
|
499
|
+
* console.log(`MP4 720p: ${urls.mp4Urls.find(u => u.quality === '720p')?.url}`);
|
|
500
|
+
* ```
|
|
501
|
+
*/
|
|
502
|
+
getStreamingUrls(assetId: string): Promise<StreamingUrls>;
|
|
503
|
+
/**
|
|
504
|
+
* Generate a thumbnail from a video at a specific timestamp
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* const thumbnail = await cdn.getThumbnail({
|
|
509
|
+
* assetId: 'video-asset-id',
|
|
510
|
+
* timestamp: 10.5, // 10.5 seconds into the video
|
|
511
|
+
* width: 320,
|
|
512
|
+
* format: 'webp',
|
|
513
|
+
* });
|
|
514
|
+
* console.log(`Thumbnail URL: ${thumbnail.url}`);
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
getThumbnail(request: ThumbnailRequest): Promise<ThumbnailResponse>;
|
|
518
|
+
/**
|
|
519
|
+
* Extract audio from a video file
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
* ```typescript
|
|
523
|
+
* const { jobId } = await cdn.extractAudio({
|
|
524
|
+
* projectSlug: 'my-project',
|
|
525
|
+
* assetId: 'video-asset-id',
|
|
526
|
+
* format: 'mp3',
|
|
527
|
+
* bitrate: 192,
|
|
528
|
+
* });
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
extractAudio(request: ExtractAudioRequest): Promise<ExtractAudioResponse>;
|
|
532
|
+
private convertJobDates;
|
|
320
533
|
}
|
|
321
534
|
|
|
322
|
-
export { type Asset, type AssetStatus, type AssetType, CDN, type ConfirmUploadRequest, type ConfirmUploadResponse, type CreateFolderRequest, type DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type Folder, type FolderTreeNode, type GetAssetRequest, type GetFolderTreeRequest, type
|
|
535
|
+
export { type Asset, type AssetStatus, type AssetType, CDN, type ConfirmUploadRequest, type ConfirmUploadResponse, type CreateFolderRequest, type DeleteAssetRequest, type DeleteAssetsRequest, type DeleteAssetsResponse, type ExtractAudioRequest, type ExtractAudioResponse, type Folder, type FolderTreeNode, type GetAssetRequest, type GetFolderTreeRequest, type ListAssetsRequest, type ListAssetsResponse, type ListJobsRequest, type ListJobsResponse, type MoveAssetsRequest, type MoveAssetsResponse, type StreamingUrls, type ThumbnailRequest, type ThumbnailResponse, type TranscodeJob, type TranscodeVideoRequest, type TranscodingStatus, type TransformOptions, type TrimOptions, type UpdateAssetRequest, type UploadUrlRequest, type UploadUrlResponse, type VideoCodec, type VideoOutputFormat, type VideoQuality, type VideoVariant, type WatermarkOptions };
|