glitch-javascript-sdk 2.9.9 → 3.0.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/dist/cjs/index.js +21 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Media.d.ts +42 -3
- package/dist/esm/index.js +21 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +42 -3
- package/package.json +1 -1
- package/src/api/Media.ts +65 -4
- package/src/routes/MediaRoute.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -6154,6 +6154,37 @@ interface S3ConfirmRequest {
|
|
|
6154
6154
|
title?: string;
|
|
6155
6155
|
filename?: string;
|
|
6156
6156
|
}
|
|
6157
|
+
/**
|
|
6158
|
+
* Interfaces for the Video Editor Manifest
|
|
6159
|
+
*/
|
|
6160
|
+
interface VideoEdit {
|
|
6161
|
+
type: 'trim' | 'crop' | 'text' | 'speed' | 'overlay' | 'thumbnail';
|
|
6162
|
+
params: TrimParams | CropParams | TextParams | SpeedParams | any;
|
|
6163
|
+
}
|
|
6164
|
+
interface TrimParams {
|
|
6165
|
+
start: number;
|
|
6166
|
+
duration: number;
|
|
6167
|
+
}
|
|
6168
|
+
interface CropParams {
|
|
6169
|
+
x: number;
|
|
6170
|
+
y: number;
|
|
6171
|
+
width: number;
|
|
6172
|
+
height: number;
|
|
6173
|
+
}
|
|
6174
|
+
interface TextParams {
|
|
6175
|
+
text: string;
|
|
6176
|
+
x: string | number;
|
|
6177
|
+
y: string | number;
|
|
6178
|
+
fontSize: number;
|
|
6179
|
+
fontColor: string;
|
|
6180
|
+
}
|
|
6181
|
+
interface SpeedParams {
|
|
6182
|
+
multiplier: number;
|
|
6183
|
+
}
|
|
6184
|
+
interface VideoProcessRequest {
|
|
6185
|
+
edits: VideoEdit[];
|
|
6186
|
+
output_format?: 'mp4' | 'webm';
|
|
6187
|
+
}
|
|
6157
6188
|
declare class Media {
|
|
6158
6189
|
/**
|
|
6159
6190
|
* Upload media content using a File object.
|
|
@@ -6291,13 +6322,12 @@ declare class Media {
|
|
|
6291
6322
|
static uploadTikTokMusic<T>(file: File, scheduler_id: string): AxiosPromise<Response<T>>;
|
|
6292
6323
|
/**
|
|
6293
6324
|
* Generate an S3 Presigned URL for direct upload.
|
|
6294
|
-
* Use this for large files (up to 2GB) to bypass the Laravel server.
|
|
6295
6325
|
*
|
|
6296
6326
|
* @param filename The original name of the file.
|
|
6297
6327
|
* @param extension The file extension (e.g., 'mp4').
|
|
6298
|
-
* @
|
|
6328
|
+
* @param is_public Set to true if the file should be publicly accessible via URL.
|
|
6299
6329
|
*/
|
|
6300
|
-
static getPresignedUrl<T = PresignedUrlResponse>(filename: string, extension: string): AxiosPromise<Response<T>>;
|
|
6330
|
+
static getPresignedUrl<T = PresignedUrlResponse>(filename: string, extension: string, is_public?: boolean): AxiosPromise<Response<T>>;
|
|
6301
6331
|
/**
|
|
6302
6332
|
* Confirm a successful S3 upload and create the database record.
|
|
6303
6333
|
* Call this after the direct S3 upload is complete.
|
|
@@ -6306,6 +6336,15 @@ declare class Media {
|
|
|
6306
6336
|
* @returns AxiosPromise containing the created Media resource.
|
|
6307
6337
|
*/
|
|
6308
6338
|
static confirmS3Upload<T>(data: S3ConfirmRequest): AxiosPromise<Response<T>>;
|
|
6339
|
+
/**
|
|
6340
|
+
* Submit a video for processing (Trim, Crop, Text, etc.)
|
|
6341
|
+
* This triggers a background job on the server.
|
|
6342
|
+
*
|
|
6343
|
+
* @param media_id The UUID of the source video.
|
|
6344
|
+
* @param data The edit manifest containing the array of transformations.
|
|
6345
|
+
* @returns Promise with the pending_media_id.
|
|
6346
|
+
*/
|
|
6347
|
+
static process<T>(media_id: string, data: VideoProcessRequest): AxiosPromise<Response<T>>;
|
|
6309
6348
|
}
|
|
6310
6349
|
|
|
6311
6350
|
declare class Scheduler {
|
package/package.json
CHANGED
package/src/api/Media.ts
CHANGED
|
@@ -116,6 +116,44 @@ export interface S3ConfirmRequest {
|
|
|
116
116
|
filename?: string;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Interfaces for the Video Editor Manifest
|
|
121
|
+
*/
|
|
122
|
+
export interface VideoEdit {
|
|
123
|
+
type: 'trim' | 'crop' | 'text' | 'speed' | 'overlay' | 'thumbnail';
|
|
124
|
+
params: TrimParams | CropParams | TextParams | SpeedParams | any;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface TrimParams {
|
|
128
|
+
start: number; // Seconds
|
|
129
|
+
duration: number; // Seconds
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface CropParams {
|
|
133
|
+
x: number; // Pixels or Percentage based on backend implementation
|
|
134
|
+
y: number;
|
|
135
|
+
width: number;
|
|
136
|
+
height: number;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface TextParams {
|
|
140
|
+
text: string;
|
|
141
|
+
x: string | number; // e.g., 'center' or 100
|
|
142
|
+
y: string | number;
|
|
143
|
+
fontSize: number;
|
|
144
|
+
fontColor: string; // e.g., 'white' or '#ffffff'
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface SpeedParams {
|
|
148
|
+
multiplier: number; // 0.5 for slow-mo, 2.0 for fast-forward
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface VideoProcessRequest {
|
|
152
|
+
edits: VideoEdit[];
|
|
153
|
+
output_format?: 'mp4' | 'webm';
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
119
157
|
class Media {
|
|
120
158
|
/**
|
|
121
159
|
* Upload media content using a File object.
|
|
@@ -358,14 +396,21 @@ class Media {
|
|
|
358
396
|
|
|
359
397
|
/**
|
|
360
398
|
* Generate an S3 Presigned URL for direct upload.
|
|
361
|
-
* Use this for large files (up to 2GB) to bypass the Laravel server.
|
|
362
399
|
*
|
|
363
400
|
* @param filename The original name of the file.
|
|
364
401
|
* @param extension The file extension (e.g., 'mp4').
|
|
365
|
-
* @
|
|
402
|
+
* @param is_public Set to true if the file should be publicly accessible via URL.
|
|
366
403
|
*/
|
|
367
|
-
public static getPresignedUrl<T = PresignedUrlResponse>(
|
|
368
|
-
|
|
404
|
+
public static getPresignedUrl<T = PresignedUrlResponse>(
|
|
405
|
+
filename: string,
|
|
406
|
+
extension: string,
|
|
407
|
+
is_public: boolean = false // Added parameter
|
|
408
|
+
): AxiosPromise<Response<T>> {
|
|
409
|
+
return Requests.processRoute(MediaRoute.routes.getPresignedUrl, {
|
|
410
|
+
filename,
|
|
411
|
+
extension,
|
|
412
|
+
is_public // Pass to backend
|
|
413
|
+
});
|
|
369
414
|
}
|
|
370
415
|
|
|
371
416
|
/**
|
|
@@ -378,6 +423,22 @@ class Media {
|
|
|
378
423
|
public static confirmS3Upload<T>(data: S3ConfirmRequest): AxiosPromise<Response<T>> {
|
|
379
424
|
return Requests.processRoute(MediaRoute.routes.confirmS3Upload, data);
|
|
380
425
|
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Submit a video for processing (Trim, Crop, Text, etc.)
|
|
429
|
+
* This triggers a background job on the server.
|
|
430
|
+
*
|
|
431
|
+
* @param media_id The UUID of the source video.
|
|
432
|
+
* @param data The edit manifest containing the array of transformations.
|
|
433
|
+
* @returns Promise with the pending_media_id.
|
|
434
|
+
*/
|
|
435
|
+
public static process<T>(media_id: string, data: VideoProcessRequest): AxiosPromise<Response<T>> {
|
|
436
|
+
return Requests.processRoute(
|
|
437
|
+
MediaRoute.routes.processVideo,
|
|
438
|
+
data,
|
|
439
|
+
{ media_id: media_id }
|
|
440
|
+
);
|
|
441
|
+
}
|
|
381
442
|
}
|
|
382
443
|
|
|
383
444
|
export default Media;
|
package/src/routes/MediaRoute.ts
CHANGED
|
@@ -14,6 +14,7 @@ class MediaRoute {
|
|
|
14
14
|
uploadTikTokMusic: { url: '/media/tiktok/music', method: HTTP_METHODS.POST },
|
|
15
15
|
getPresignedUrl: { url: '/media/presigned-url', method: HTTP_METHODS.POST },
|
|
16
16
|
confirmS3Upload: { url: '/media/s3-confirm', method: HTTP_METHODS.POST },
|
|
17
|
+
processVideo: { url: '/media/{media_id}/process', method: HTTP_METHODS.POST },
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
|