glitch-javascript-sdk 2.9.9 → 3.0.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/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.
@@ -6306,6 +6337,15 @@ declare class Media {
6306
6337
  * @returns AxiosPromise containing the created Media resource.
6307
6338
  */
6308
6339
  static confirmS3Upload<T>(data: S3ConfirmRequest): AxiosPromise<Response<T>>;
6340
+ /**
6341
+ * Submit a video for processing (Trim, Crop, Text, etc.)
6342
+ * This triggers a background job on the server.
6343
+ *
6344
+ * @param media_id The UUID of the source video.
6345
+ * @param data The edit manifest containing the array of transformations.
6346
+ * @returns Promise with the pending_media_id.
6347
+ */
6348
+ static process<T>(media_id: string, data: VideoProcessRequest): AxiosPromise<Response<T>>;
6309
6349
  }
6310
6350
 
6311
6351
  declare class Scheduler {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "2.9.9",
3
+ "version": "3.0.0",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
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.
@@ -378,6 +416,22 @@ class Media {
378
416
  public static confirmS3Upload<T>(data: S3ConfirmRequest): AxiosPromise<Response<T>> {
379
417
  return Requests.processRoute(MediaRoute.routes.confirmS3Upload, data);
380
418
  }
419
+
420
+ /**
421
+ * Submit a video for processing (Trim, Crop, Text, etc.)
422
+ * This triggers a background job on the server.
423
+ *
424
+ * @param media_id The UUID of the source video.
425
+ * @param data The edit manifest containing the array of transformations.
426
+ * @returns Promise with the pending_media_id.
427
+ */
428
+ public static process<T>(media_id: string, data: VideoProcessRequest): AxiosPromise<Response<T>> {
429
+ return Requests.processRoute(
430
+ MediaRoute.routes.processVideo,
431
+ data,
432
+ { media_id: media_id }
433
+ );
434
+ }
381
435
  }
382
436
 
383
437
  export default Media;
@@ -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