@stack0/sdk 0.2.9 → 0.3.0
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 +200 -0
- package/dist/cdn/index.d.mts +185 -2
- package/dist/cdn/index.d.ts +185 -2
- package/dist/cdn/index.js +138 -0
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +138 -0
- 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/http-client-DjrRWvXA.d.mts +24 -0
- package/dist/http-client-DjrRWvXA.d.ts +24 -0
- package/dist/index.d.mts +534 -3
- package/dist/index.d.ts +534 -3
- package/dist/index.js +449 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +449 -1
- 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/screenshots/index.d.mts +1 -1
- package/dist/screenshots/index.d.ts +1 -1
- package/dist/webdata/index.d.mts +1 -1
- package/dist/webdata/index.d.ts +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
|
@@ -208,6 +208,105 @@ await stack0.cdn.deleteFolder('folder-id');
|
|
|
208
208
|
await stack0.cdn.deleteFolder('folder-id', true); // Delete with contents
|
|
209
209
|
```
|
|
210
210
|
|
|
211
|
+
### Video Transcoding
|
|
212
|
+
|
|
213
|
+
Transcode videos into HLS adaptive streaming or MP4 formats for optimal playback.
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
// Start a transcoding job
|
|
217
|
+
const job = await stack0.cdn.transcode({
|
|
218
|
+
projectSlug: 'my-project',
|
|
219
|
+
assetId: 'video-asset-id',
|
|
220
|
+
outputFormat: 'hls', // 'hls' for adaptive streaming, 'mp4' for progressive download
|
|
221
|
+
variants: [
|
|
222
|
+
{ quality: '720p', codec: 'h264' },
|
|
223
|
+
{ quality: '1080p', codec: 'h264' },
|
|
224
|
+
],
|
|
225
|
+
webhookUrl: 'https://your-app.com/webhook', // Optional: get notified when complete
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
console.log(`Job started: ${job.id}, Status: ${job.status}`);
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Check Job Status
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
// Get job by ID
|
|
235
|
+
const job = await stack0.cdn.getJob('job-id');
|
|
236
|
+
console.log(`Status: ${job.status}, Progress: ${job.progress}%`);
|
|
237
|
+
|
|
238
|
+
// List all jobs
|
|
239
|
+
const { jobs, total } = await stack0.cdn.listJobs({
|
|
240
|
+
projectSlug: 'my-project',
|
|
241
|
+
status: 'processing', // Optional filter
|
|
242
|
+
limit: 20,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
// Cancel a pending/processing job
|
|
246
|
+
await stack0.cdn.cancelJob('job-id');
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Get Streaming URLs
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
const urls = await stack0.cdn.getStreamingUrls('asset-id');
|
|
253
|
+
|
|
254
|
+
// HLS URL for adaptive streaming (recommended)
|
|
255
|
+
console.log(`HLS Master Playlist: ${urls.hlsUrl}`);
|
|
256
|
+
|
|
257
|
+
// MP4 URLs for direct download
|
|
258
|
+
for (const mp4 of urls.mp4Urls) {
|
|
259
|
+
console.log(`${mp4.quality}: ${mp4.url}`);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Thumbnails
|
|
263
|
+
for (const thumb of urls.thumbnails) {
|
|
264
|
+
console.log(`Thumbnail at ${thumb.timestamp}s: ${thumb.url}`);
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Generate Thumbnails
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
const thumbnail = await stack0.cdn.getThumbnail({
|
|
272
|
+
assetId: 'video-asset-id',
|
|
273
|
+
timestamp: 10.5, // 10.5 seconds into the video
|
|
274
|
+
width: 320, // Optional: resize
|
|
275
|
+
format: 'webp', // 'jpg', 'png', 'webp'
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
console.log(`Thumbnail URL: ${thumbnail.url}`);
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Extract Audio
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
const { jobId, status } = await stack0.cdn.extractAudio({
|
|
285
|
+
projectSlug: 'my-project',
|
|
286
|
+
assetId: 'video-asset-id',
|
|
287
|
+
format: 'mp3', // 'mp3', 'aac', 'wav'
|
|
288
|
+
bitrate: 192, // Optional: kbps
|
|
289
|
+
});
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Video Playback with HLS.js
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
import Hls from 'hls.js';
|
|
296
|
+
|
|
297
|
+
const urls = await stack0.cdn.getStreamingUrls('asset-id');
|
|
298
|
+
|
|
299
|
+
const video = document.getElementById('video');
|
|
300
|
+
if (Hls.isSupported() && urls.hlsUrl) {
|
|
301
|
+
const hls = new Hls();
|
|
302
|
+
hls.loadSource(urls.hlsUrl);
|
|
303
|
+
hls.attachMedia(video);
|
|
304
|
+
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
|
305
|
+
// Safari native HLS support
|
|
306
|
+
video.src = urls.hlsUrl;
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
211
310
|
## Mail API
|
|
212
311
|
|
|
213
312
|
The Mail API is compatible with the Resend API for easy migration.
|
|
@@ -377,6 +476,107 @@ const stack0 = new Stack0({ apiKey: 'stack0_...' });
|
|
|
377
476
|
await stack0.mail.send({ ... });
|
|
378
477
|
```
|
|
379
478
|
|
|
479
|
+
## Screenshots API
|
|
480
|
+
|
|
481
|
+
Capture high-quality screenshots of any webpage.
|
|
482
|
+
|
|
483
|
+
### Basic Screenshot
|
|
484
|
+
|
|
485
|
+
```typescript
|
|
486
|
+
// Capture a screenshot and wait for completion
|
|
487
|
+
const screenshot = await stack0.screenshots.captureAndWait({
|
|
488
|
+
url: 'https://example.com',
|
|
489
|
+
format: 'png',
|
|
490
|
+
fullPage: true,
|
|
491
|
+
blockAds: true,
|
|
492
|
+
});
|
|
493
|
+
|
|
494
|
+
console.log(screenshot.imageUrl);
|
|
495
|
+
console.log(screenshot.imageWidth, screenshot.imageHeight);
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Screenshot Options
|
|
499
|
+
|
|
500
|
+
```typescript
|
|
501
|
+
const screenshot = await stack0.screenshots.captureAndWait({
|
|
502
|
+
url: 'https://example.com',
|
|
503
|
+
format: 'png', // 'png' | 'jpeg' | 'webp' | 'pdf'
|
|
504
|
+
quality: 90, // JPEG/WebP quality
|
|
505
|
+
fullPage: true,
|
|
506
|
+
deviceType: 'desktop', // 'desktop' | 'tablet' | 'mobile'
|
|
507
|
+
viewportWidth: 1280,
|
|
508
|
+
viewportHeight: 720,
|
|
509
|
+
// Block unwanted elements
|
|
510
|
+
blockAds: true,
|
|
511
|
+
blockCookieBanners: true,
|
|
512
|
+
blockChatWidgets: true,
|
|
513
|
+
// Wait for content
|
|
514
|
+
waitForSelector: '.main-content',
|
|
515
|
+
waitForTimeout: 2000,
|
|
516
|
+
// Custom headers/cookies for auth
|
|
517
|
+
headers: { 'Authorization': 'Bearer token' },
|
|
518
|
+
cookies: [{ name: 'session', value: 'abc123' }],
|
|
519
|
+
});
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
### Batch Screenshots
|
|
523
|
+
|
|
524
|
+
```typescript
|
|
525
|
+
const job = await stack0.screenshots.batchAndWait({
|
|
526
|
+
urls: ['https://example.com', 'https://example.org'],
|
|
527
|
+
config: { format: 'png', fullPage: true },
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
console.log(`Success: ${job.successfulUrls}, Failed: ${job.failedUrls}`);
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
## Extraction API
|
|
534
|
+
|
|
535
|
+
Extract structured data from any webpage using AI.
|
|
536
|
+
|
|
537
|
+
### Basic Extraction
|
|
538
|
+
|
|
539
|
+
```typescript
|
|
540
|
+
// Extract content as markdown
|
|
541
|
+
const extraction = await stack0.extraction.extractAndWait({
|
|
542
|
+
url: 'https://example.com/article',
|
|
543
|
+
mode: 'markdown',
|
|
544
|
+
includeMetadata: true,
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
console.log(extraction.markdown);
|
|
548
|
+
console.log(extraction.pageMetadata?.title);
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
### Schema-Based Extraction
|
|
552
|
+
|
|
553
|
+
```typescript
|
|
554
|
+
// Extract structured data using a JSON schema
|
|
555
|
+
const extraction = await stack0.extraction.extractAndWait({
|
|
556
|
+
url: 'https://example.com/product',
|
|
557
|
+
mode: 'schema',
|
|
558
|
+
schema: {
|
|
559
|
+
type: 'object',
|
|
560
|
+
properties: {
|
|
561
|
+
name: { type: 'string' },
|
|
562
|
+
price: { type: 'number' },
|
|
563
|
+
description: { type: 'string' },
|
|
564
|
+
},
|
|
565
|
+
required: ['name', 'price'],
|
|
566
|
+
},
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
console.log(extraction.extractedData);
|
|
570
|
+
// { name: 'Product Name', price: 29.99, description: '...' }
|
|
571
|
+
```
|
|
572
|
+
|
|
573
|
+
### Extraction Modes
|
|
574
|
+
|
|
575
|
+
- `markdown`: AI-cleaned markdown content
|
|
576
|
+
- `schema`: Structured data matching your schema
|
|
577
|
+
- `auto`: AI determines best extraction
|
|
578
|
+
- `raw`: Raw HTML content
|
|
579
|
+
|
|
380
580
|
## Support
|
|
381
581
|
|
|
382
582
|
- 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-DjrRWvXA.mjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Type definitions for Stack0 CDN API
|
|
@@ -135,6 +135,95 @@ interface Folder {
|
|
|
135
135
|
createdAt: Date;
|
|
136
136
|
updatedAt: Date | null;
|
|
137
137
|
}
|
|
138
|
+
type VideoQuality = "360p" | "480p" | "720p" | "1080p" | "1440p" | "2160p";
|
|
139
|
+
type VideoCodec = "h264" | "h265";
|
|
140
|
+
type VideoOutputFormat = "hls" | "mp4";
|
|
141
|
+
type TranscodingStatus = "pending" | "queued" | "processing" | "completed" | "failed" | "cancelled";
|
|
142
|
+
interface VideoVariant {
|
|
143
|
+
quality: VideoQuality;
|
|
144
|
+
codec?: VideoCodec;
|
|
145
|
+
bitrate?: number;
|
|
146
|
+
}
|
|
147
|
+
interface WatermarkOptions {
|
|
148
|
+
type: "image" | "text";
|
|
149
|
+
imageAssetId?: string;
|
|
150
|
+
text?: string;
|
|
151
|
+
position: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center";
|
|
152
|
+
opacity?: number;
|
|
153
|
+
}
|
|
154
|
+
interface TrimOptions {
|
|
155
|
+
start: number;
|
|
156
|
+
end: number;
|
|
157
|
+
}
|
|
158
|
+
interface TranscodeVideoRequest {
|
|
159
|
+
projectSlug: string;
|
|
160
|
+
assetId: string;
|
|
161
|
+
outputFormat: VideoOutputFormat;
|
|
162
|
+
variants: VideoVariant[];
|
|
163
|
+
watermark?: WatermarkOptions;
|
|
164
|
+
trim?: TrimOptions;
|
|
165
|
+
webhookUrl?: string;
|
|
166
|
+
}
|
|
167
|
+
interface TranscodeJob {
|
|
168
|
+
id: string;
|
|
169
|
+
assetId: string;
|
|
170
|
+
status: TranscodingStatus;
|
|
171
|
+
outputFormat: VideoOutputFormat;
|
|
172
|
+
variants: VideoVariant[];
|
|
173
|
+
progress: number | null;
|
|
174
|
+
error: string | null;
|
|
175
|
+
mediaConvertJobId: string | null;
|
|
176
|
+
createdAt: Date;
|
|
177
|
+
startedAt: Date | null;
|
|
178
|
+
completedAt: Date | null;
|
|
179
|
+
}
|
|
180
|
+
interface ListJobsRequest {
|
|
181
|
+
projectSlug: string;
|
|
182
|
+
assetId?: string;
|
|
183
|
+
status?: TranscodingStatus;
|
|
184
|
+
limit?: number;
|
|
185
|
+
offset?: number;
|
|
186
|
+
}
|
|
187
|
+
interface ListJobsResponse {
|
|
188
|
+
jobs: TranscodeJob[];
|
|
189
|
+
total: number;
|
|
190
|
+
hasMore: boolean;
|
|
191
|
+
}
|
|
192
|
+
interface StreamingUrls {
|
|
193
|
+
hlsUrl: string | null;
|
|
194
|
+
mp4Urls: Array<{
|
|
195
|
+
quality: VideoQuality;
|
|
196
|
+
url: string;
|
|
197
|
+
}>;
|
|
198
|
+
thumbnails: Array<{
|
|
199
|
+
url: string;
|
|
200
|
+
timestamp: number;
|
|
201
|
+
width: number;
|
|
202
|
+
height: number;
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
205
|
+
interface ThumbnailRequest {
|
|
206
|
+
assetId: string;
|
|
207
|
+
timestamp: number;
|
|
208
|
+
width?: number;
|
|
209
|
+
format?: "jpg" | "png" | "webp";
|
|
210
|
+
}
|
|
211
|
+
interface ThumbnailResponse {
|
|
212
|
+
url: string;
|
|
213
|
+
timestamp: number;
|
|
214
|
+
width: number;
|
|
215
|
+
height: number;
|
|
216
|
+
}
|
|
217
|
+
interface ExtractAudioRequest {
|
|
218
|
+
projectSlug: string;
|
|
219
|
+
assetId: string;
|
|
220
|
+
format: "mp3" | "aac" | "wav";
|
|
221
|
+
bitrate?: number;
|
|
222
|
+
}
|
|
223
|
+
interface ExtractAudioResponse {
|
|
224
|
+
jobId: string;
|
|
225
|
+
status: TranscodingStatus;
|
|
226
|
+
}
|
|
138
227
|
|
|
139
228
|
/**
|
|
140
229
|
* Stack0 CDN Client
|
|
@@ -317,6 +406,100 @@ declare class CDN {
|
|
|
317
406
|
}>;
|
|
318
407
|
private convertAssetDates;
|
|
319
408
|
private convertFolderDates;
|
|
409
|
+
/**
|
|
410
|
+
* Start a video transcoding job
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```typescript
|
|
414
|
+
* const job = await cdn.transcode({
|
|
415
|
+
* projectSlug: 'my-project',
|
|
416
|
+
* assetId: 'video-asset-id',
|
|
417
|
+
* outputFormat: 'hls',
|
|
418
|
+
* variants: [
|
|
419
|
+
* { quality: '720p', codec: 'h264' },
|
|
420
|
+
* { quality: '1080p', codec: 'h264' },
|
|
421
|
+
* ],
|
|
422
|
+
* webhookUrl: 'https://your-app.com/webhook',
|
|
423
|
+
* });
|
|
424
|
+
* console.log(`Job started: ${job.id}`);
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
transcode(request: TranscodeVideoRequest): Promise<TranscodeJob>;
|
|
428
|
+
/**
|
|
429
|
+
* Get a transcoding job by ID
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const job = await cdn.getJob('job-id');
|
|
434
|
+
* console.log(`Status: ${job.status}, Progress: ${job.progress}%`);
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
getJob(jobId: string): Promise<TranscodeJob>;
|
|
438
|
+
/**
|
|
439
|
+
* List transcoding jobs with filters
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* const { jobs, total } = await cdn.listJobs({
|
|
444
|
+
* projectSlug: 'my-project',
|
|
445
|
+
* status: 'processing',
|
|
446
|
+
* limit: 20,
|
|
447
|
+
* });
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
listJobs(request: ListJobsRequest): Promise<ListJobsResponse>;
|
|
451
|
+
/**
|
|
452
|
+
* Cancel a pending or processing transcoding job
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* await cdn.cancelJob('job-id');
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
cancelJob(jobId: string): Promise<{
|
|
460
|
+
success: boolean;
|
|
461
|
+
}>;
|
|
462
|
+
/**
|
|
463
|
+
* Get streaming URLs for a transcoded video
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* const urls = await cdn.getStreamingUrls('asset-id');
|
|
468
|
+
* console.log(`HLS URL: ${urls.hlsUrl}`);
|
|
469
|
+
* console.log(`MP4 720p: ${urls.mp4Urls.find(u => u.quality === '720p')?.url}`);
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
getStreamingUrls(assetId: string): Promise<StreamingUrls>;
|
|
473
|
+
/**
|
|
474
|
+
* Generate a thumbnail from a video at a specific timestamp
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* ```typescript
|
|
478
|
+
* const thumbnail = await cdn.getThumbnail({
|
|
479
|
+
* assetId: 'video-asset-id',
|
|
480
|
+
* timestamp: 10.5, // 10.5 seconds into the video
|
|
481
|
+
* width: 320,
|
|
482
|
+
* format: 'webp',
|
|
483
|
+
* });
|
|
484
|
+
* console.log(`Thumbnail URL: ${thumbnail.url}`);
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
getThumbnail(request: ThumbnailRequest): Promise<ThumbnailResponse>;
|
|
488
|
+
/**
|
|
489
|
+
* Extract audio from a video file
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* const { jobId } = await cdn.extractAudio({
|
|
494
|
+
* projectSlug: 'my-project',
|
|
495
|
+
* assetId: 'video-asset-id',
|
|
496
|
+
* format: 'mp3',
|
|
497
|
+
* bitrate: 192,
|
|
498
|
+
* });
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
extractAudio(request: ExtractAudioRequest): Promise<ExtractAudioResponse>;
|
|
502
|
+
private convertJobDates;
|
|
320
503
|
}
|
|
321
504
|
|
|
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 GetTransformUrlRequest, type GetTransformUrlResponse, type ListAssetsRequest, type ListAssetsResponse, type MoveAssetsRequest, type MoveAssetsResponse, type TransformOptions, type UpdateAssetRequest, type UploadUrlRequest, type UploadUrlResponse };
|
|
505
|
+
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 GetTransformUrlRequest, type GetTransformUrlResponse, 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 };
|
package/dist/cdn/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as HttpClientConfig } from '../http-client-DjrRWvXA.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Type definitions for Stack0 CDN API
|
|
@@ -135,6 +135,95 @@ interface Folder {
|
|
|
135
135
|
createdAt: Date;
|
|
136
136
|
updatedAt: Date | null;
|
|
137
137
|
}
|
|
138
|
+
type VideoQuality = "360p" | "480p" | "720p" | "1080p" | "1440p" | "2160p";
|
|
139
|
+
type VideoCodec = "h264" | "h265";
|
|
140
|
+
type VideoOutputFormat = "hls" | "mp4";
|
|
141
|
+
type TranscodingStatus = "pending" | "queued" | "processing" | "completed" | "failed" | "cancelled";
|
|
142
|
+
interface VideoVariant {
|
|
143
|
+
quality: VideoQuality;
|
|
144
|
+
codec?: VideoCodec;
|
|
145
|
+
bitrate?: number;
|
|
146
|
+
}
|
|
147
|
+
interface WatermarkOptions {
|
|
148
|
+
type: "image" | "text";
|
|
149
|
+
imageAssetId?: string;
|
|
150
|
+
text?: string;
|
|
151
|
+
position: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center";
|
|
152
|
+
opacity?: number;
|
|
153
|
+
}
|
|
154
|
+
interface TrimOptions {
|
|
155
|
+
start: number;
|
|
156
|
+
end: number;
|
|
157
|
+
}
|
|
158
|
+
interface TranscodeVideoRequest {
|
|
159
|
+
projectSlug: string;
|
|
160
|
+
assetId: string;
|
|
161
|
+
outputFormat: VideoOutputFormat;
|
|
162
|
+
variants: VideoVariant[];
|
|
163
|
+
watermark?: WatermarkOptions;
|
|
164
|
+
trim?: TrimOptions;
|
|
165
|
+
webhookUrl?: string;
|
|
166
|
+
}
|
|
167
|
+
interface TranscodeJob {
|
|
168
|
+
id: string;
|
|
169
|
+
assetId: string;
|
|
170
|
+
status: TranscodingStatus;
|
|
171
|
+
outputFormat: VideoOutputFormat;
|
|
172
|
+
variants: VideoVariant[];
|
|
173
|
+
progress: number | null;
|
|
174
|
+
error: string | null;
|
|
175
|
+
mediaConvertJobId: string | null;
|
|
176
|
+
createdAt: Date;
|
|
177
|
+
startedAt: Date | null;
|
|
178
|
+
completedAt: Date | null;
|
|
179
|
+
}
|
|
180
|
+
interface ListJobsRequest {
|
|
181
|
+
projectSlug: string;
|
|
182
|
+
assetId?: string;
|
|
183
|
+
status?: TranscodingStatus;
|
|
184
|
+
limit?: number;
|
|
185
|
+
offset?: number;
|
|
186
|
+
}
|
|
187
|
+
interface ListJobsResponse {
|
|
188
|
+
jobs: TranscodeJob[];
|
|
189
|
+
total: number;
|
|
190
|
+
hasMore: boolean;
|
|
191
|
+
}
|
|
192
|
+
interface StreamingUrls {
|
|
193
|
+
hlsUrl: string | null;
|
|
194
|
+
mp4Urls: Array<{
|
|
195
|
+
quality: VideoQuality;
|
|
196
|
+
url: string;
|
|
197
|
+
}>;
|
|
198
|
+
thumbnails: Array<{
|
|
199
|
+
url: string;
|
|
200
|
+
timestamp: number;
|
|
201
|
+
width: number;
|
|
202
|
+
height: number;
|
|
203
|
+
}>;
|
|
204
|
+
}
|
|
205
|
+
interface ThumbnailRequest {
|
|
206
|
+
assetId: string;
|
|
207
|
+
timestamp: number;
|
|
208
|
+
width?: number;
|
|
209
|
+
format?: "jpg" | "png" | "webp";
|
|
210
|
+
}
|
|
211
|
+
interface ThumbnailResponse {
|
|
212
|
+
url: string;
|
|
213
|
+
timestamp: number;
|
|
214
|
+
width: number;
|
|
215
|
+
height: number;
|
|
216
|
+
}
|
|
217
|
+
interface ExtractAudioRequest {
|
|
218
|
+
projectSlug: string;
|
|
219
|
+
assetId: string;
|
|
220
|
+
format: "mp3" | "aac" | "wav";
|
|
221
|
+
bitrate?: number;
|
|
222
|
+
}
|
|
223
|
+
interface ExtractAudioResponse {
|
|
224
|
+
jobId: string;
|
|
225
|
+
status: TranscodingStatus;
|
|
226
|
+
}
|
|
138
227
|
|
|
139
228
|
/**
|
|
140
229
|
* Stack0 CDN Client
|
|
@@ -317,6 +406,100 @@ declare class CDN {
|
|
|
317
406
|
}>;
|
|
318
407
|
private convertAssetDates;
|
|
319
408
|
private convertFolderDates;
|
|
409
|
+
/**
|
|
410
|
+
* Start a video transcoding job
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* ```typescript
|
|
414
|
+
* const job = await cdn.transcode({
|
|
415
|
+
* projectSlug: 'my-project',
|
|
416
|
+
* assetId: 'video-asset-id',
|
|
417
|
+
* outputFormat: 'hls',
|
|
418
|
+
* variants: [
|
|
419
|
+
* { quality: '720p', codec: 'h264' },
|
|
420
|
+
* { quality: '1080p', codec: 'h264' },
|
|
421
|
+
* ],
|
|
422
|
+
* webhookUrl: 'https://your-app.com/webhook',
|
|
423
|
+
* });
|
|
424
|
+
* console.log(`Job started: ${job.id}`);
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
transcode(request: TranscodeVideoRequest): Promise<TranscodeJob>;
|
|
428
|
+
/**
|
|
429
|
+
* Get a transcoding job by ID
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```typescript
|
|
433
|
+
* const job = await cdn.getJob('job-id');
|
|
434
|
+
* console.log(`Status: ${job.status}, Progress: ${job.progress}%`);
|
|
435
|
+
* ```
|
|
436
|
+
*/
|
|
437
|
+
getJob(jobId: string): Promise<TranscodeJob>;
|
|
438
|
+
/**
|
|
439
|
+
* List transcoding jobs with filters
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```typescript
|
|
443
|
+
* const { jobs, total } = await cdn.listJobs({
|
|
444
|
+
* projectSlug: 'my-project',
|
|
445
|
+
* status: 'processing',
|
|
446
|
+
* limit: 20,
|
|
447
|
+
* });
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
listJobs(request: ListJobsRequest): Promise<ListJobsResponse>;
|
|
451
|
+
/**
|
|
452
|
+
* Cancel a pending or processing transcoding job
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```typescript
|
|
456
|
+
* await cdn.cancelJob('job-id');
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
cancelJob(jobId: string): Promise<{
|
|
460
|
+
success: boolean;
|
|
461
|
+
}>;
|
|
462
|
+
/**
|
|
463
|
+
* Get streaming URLs for a transcoded video
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* ```typescript
|
|
467
|
+
* const urls = await cdn.getStreamingUrls('asset-id');
|
|
468
|
+
* console.log(`HLS URL: ${urls.hlsUrl}`);
|
|
469
|
+
* console.log(`MP4 720p: ${urls.mp4Urls.find(u => u.quality === '720p')?.url}`);
|
|
470
|
+
* ```
|
|
471
|
+
*/
|
|
472
|
+
getStreamingUrls(assetId: string): Promise<StreamingUrls>;
|
|
473
|
+
/**
|
|
474
|
+
* Generate a thumbnail from a video at a specific timestamp
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* ```typescript
|
|
478
|
+
* const thumbnail = await cdn.getThumbnail({
|
|
479
|
+
* assetId: 'video-asset-id',
|
|
480
|
+
* timestamp: 10.5, // 10.5 seconds into the video
|
|
481
|
+
* width: 320,
|
|
482
|
+
* format: 'webp',
|
|
483
|
+
* });
|
|
484
|
+
* console.log(`Thumbnail URL: ${thumbnail.url}`);
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
getThumbnail(request: ThumbnailRequest): Promise<ThumbnailResponse>;
|
|
488
|
+
/**
|
|
489
|
+
* Extract audio from a video file
|
|
490
|
+
*
|
|
491
|
+
* @example
|
|
492
|
+
* ```typescript
|
|
493
|
+
* const { jobId } = await cdn.extractAudio({
|
|
494
|
+
* projectSlug: 'my-project',
|
|
495
|
+
* assetId: 'video-asset-id',
|
|
496
|
+
* format: 'mp3',
|
|
497
|
+
* bitrate: 192,
|
|
498
|
+
* });
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
extractAudio(request: ExtractAudioRequest): Promise<ExtractAudioResponse>;
|
|
502
|
+
private convertJobDates;
|
|
320
503
|
}
|
|
321
504
|
|
|
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 GetTransformUrlRequest, type GetTransformUrlResponse, type ListAssetsRequest, type ListAssetsResponse, type MoveAssetsRequest, type MoveAssetsResponse, type TransformOptions, type UpdateAssetRequest, type UploadUrlRequest, type UploadUrlResponse };
|
|
505
|
+
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 GetTransformUrlRequest, type GetTransformUrlResponse, 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 };
|