glitch-javascript-sdk 2.9.8 → 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
@@ -2275,6 +2275,55 @@ declare class Users {
2275
2275
  title_id?: string;
2276
2276
  page?: number;
2277
2277
  }): AxiosPromise<Response<T>>;
2278
+ /**
2279
+ * List the authenticated user's media library (clips, screenshots, AI generated).
2280
+ *
2281
+ * @param params Optional filters: { type: 'clip'|'screenshot'|'ai_generated', title_id: string }
2282
+ */
2283
+ static listMedia<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
2284
+ /**
2285
+ * Add a Media record to the user's personal library.
2286
+ *
2287
+ * @param data { media_id: string, type: string, title_id?: string, label?: string, studio_metadata?: object }
2288
+ */
2289
+ static storeMedia<T>(data: object): AxiosPromise<Response<T>>;
2290
+ /**
2291
+ * Retrieve details for a specific library item.
2292
+ */
2293
+ static viewMedia<T>(id: string): AxiosPromise<Response<T>>;
2294
+ /**
2295
+ * Update a library item's label or metadata.
2296
+ */
2297
+ static updateMedia<T>(id: string, data: object): AxiosPromise<Response<T>>;
2298
+ /**
2299
+ * Remove an item from the user's library (Soft Delete).
2300
+ */
2301
+ static deleteMedia<T>(id: string): AxiosPromise<Response<T>>;
2302
+ /**
2303
+ * Apply AI transformations (Style Transfer/Upscale) to a library item.
2304
+ *
2305
+ * @param id The UUID of the UserMedia record.
2306
+ * @param data { prompt: string, tool: 'style_transfer'|'upscale' }
2307
+ */
2308
+ static modifyMedia<T>(id: string, data: {
2309
+ prompt: string;
2310
+ tool: string;
2311
+ }): AxiosPromise<Response<T>>;
2312
+ /**
2313
+ * Get AI-generated suggestions for the best 15-second window to trim a video.
2314
+ */
2315
+ static suggestSmartTrim<T>(id: string): AxiosPromise<Response<T>>;
2316
+ /**
2317
+ * Share a library item to social media as User Generated Content (UGC).
2318
+ *
2319
+ * @param id The UUID of the UserMedia record.
2320
+ * @param data { platform: string, title?: string, content: string }
2321
+ */
2322
+ static shareMedia<T>(id: string, data: {
2323
+ platform: string;
2324
+ title?: string;
2325
+ content: string;
2326
+ }): AxiosPromise<Response<T>>;
2278
2327
  }
2279
2328
 
2280
2329
  declare class Events {
@@ -6105,6 +6154,37 @@ interface S3ConfirmRequest {
6105
6154
  title?: string;
6106
6155
  filename?: string;
6107
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
+ }
6108
6188
  declare class Media {
6109
6189
  /**
6110
6190
  * Upload media content using a File object.
@@ -6257,6 +6337,15 @@ declare class Media {
6257
6337
  * @returns AxiosPromise containing the created Media resource.
6258
6338
  */
6259
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>>;
6260
6349
  }
6261
6350
 
6262
6351
  declare class Scheduler {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "2.9.8",
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;
package/src/api/Users.ts CHANGED
@@ -593,6 +593,71 @@ class Users {
593
593
  return Requests.processRoute(UserRoutes.routes.userProgressionHistory, undefined, { user_id }, params);
594
594
  }
595
595
 
596
+ /**
597
+ * List the authenticated user's media library (clips, screenshots, AI generated).
598
+ *
599
+ * @param params Optional filters: { type: 'clip'|'screenshot'|'ai_generated', title_id: string }
600
+ */
601
+ public static listMedia<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
602
+ return Requests.processRoute(UserRoutes.routes.listMedia, undefined, undefined, params);
603
+ }
604
+
605
+ /**
606
+ * Add a Media record to the user's personal library.
607
+ *
608
+ * @param data { media_id: string, type: string, title_id?: string, label?: string, studio_metadata?: object }
609
+ */
610
+ public static storeMedia<T>(data: object): AxiosPromise<Response<T>> {
611
+ return Requests.processRoute(UserRoutes.routes.storeMedia, data);
612
+ }
613
+
614
+ /**
615
+ * Retrieve details for a specific library item.
616
+ */
617
+ public static viewMedia<T>(id: string): AxiosPromise<Response<T>> {
618
+ return Requests.processRoute(UserRoutes.routes.viewMedia, undefined, { id });
619
+ }
620
+
621
+ /**
622
+ * Update a library item's label or metadata.
623
+ */
624
+ public static updateMedia<T>(id: string, data: object): AxiosPromise<Response<T>> {
625
+ return Requests.processRoute(UserRoutes.routes.updateMedia, data, { id });
626
+ }
627
+
628
+ /**
629
+ * Remove an item from the user's library (Soft Delete).
630
+ */
631
+ public static deleteMedia<T>(id: string): AxiosPromise<Response<T>> {
632
+ return Requests.processRoute(UserRoutes.routes.deleteMedia, undefined, { id });
633
+ }
634
+
635
+ /**
636
+ * Apply AI transformations (Style Transfer/Upscale) to a library item.
637
+ *
638
+ * @param id The UUID of the UserMedia record.
639
+ * @param data { prompt: string, tool: 'style_transfer'|'upscale' }
640
+ */
641
+ public static modifyMedia<T>(id: string, data: { prompt: string, tool: string }): AxiosPromise<Response<T>> {
642
+ return Requests.processRoute(UserRoutes.routes.modifyMedia, data, { id });
643
+ }
644
+
645
+ /**
646
+ * Get AI-generated suggestions for the best 15-second window to trim a video.
647
+ */
648
+ public static suggestSmartTrim<T>(id: string): AxiosPromise<Response<T>> {
649
+ return Requests.processRoute(UserRoutes.routes.suggestSmartTrim, undefined, { id });
650
+ }
651
+
652
+ /**
653
+ * Share a library item to social media as User Generated Content (UGC).
654
+ *
655
+ * @param id The UUID of the UserMedia record.
656
+ * @param data { platform: string, title?: string, content: string }
657
+ */
658
+ public static shareMedia<T>(id: string, data: { platform: string, title?: string, content: string }): AxiosPromise<Response<T>> {
659
+ return Requests.processRoute(UserRoutes.routes.shareMedia, data, { id });
660
+ }
596
661
 
597
662
  }
598
663
 
@@ -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
 
@@ -57,7 +57,17 @@ class UserRoutes {
57
57
  userProgressionAchievements: { url: '/users/{user_id}/progression/achievements', method: HTTP_METHODS.GET },
58
58
  userProgressionHistory: { url: '/users/{user_id}/progression/history', method: HTTP_METHODS.GET },
59
59
 
60
-
60
+ // --- User Media Library (Viral Clip Studio) ---
61
+ listMedia: { url: '/users/me/media', method: HTTP_METHODS.GET },
62
+ storeMedia: { url: '/users/me/media', method: HTTP_METHODS.POST },
63
+ viewMedia: { url: '/users/me/media/{id}', method: HTTP_METHODS.GET },
64
+ updateMedia: { url: '/users/me/media/{id}', method: HTTP_METHODS.PUT },
65
+ deleteMedia: { url: '/users/me/media/{id}', method: HTTP_METHODS.DELETE },
66
+
67
+ // AI & Social Actions
68
+ modifyMedia: { url: '/users/me/media/{id}/modify', method: HTTP_METHODS.POST },
69
+ suggestSmartTrim: { url: '/users/me/media/{id}/smart-trim', method: HTTP_METHODS.GET },
70
+ shareMedia: { url: '/users/me/media/{id}/share', method: HTTP_METHODS.POST },
61
71
  };
62
72
 
63
73
  }