glitch-javascript-sdk 2.5.8 → 2.5.9

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
@@ -5584,6 +5584,17 @@ interface ScreenshotValidationResponse {
5584
5584
  issues: string[];
5585
5585
  recommendations: string[];
5586
5586
  }
5587
+ interface PresignedUrlResponse {
5588
+ upload_url: string;
5589
+ file_path: string;
5590
+ }
5591
+ interface S3ConfirmRequest {
5592
+ file_path: string;
5593
+ size: number;
5594
+ mime_type: string;
5595
+ title?: string;
5596
+ filename?: string;
5597
+ }
5587
5598
  declare class Media {
5588
5599
  /**
5589
5600
  * Upload media content using a File object.
@@ -5719,6 +5730,23 @@ declare class Media {
5719
5730
  * @param scheduler_id The ID of the scheduler to provide OAuth context.
5720
5731
  */
5721
5732
  static uploadTikTokMusic<T>(file: File, scheduler_id: string): AxiosPromise<Response<T>>;
5733
+ /**
5734
+ * Generate an S3 Presigned URL for direct upload.
5735
+ * Use this for large files (up to 2GB) to bypass the Laravel server.
5736
+ *
5737
+ * @param filename The original name of the file.
5738
+ * @param extension The file extension (e.g., 'mp4').
5739
+ * @returns AxiosPromise containing upload_url and file_path.
5740
+ */
5741
+ static getPresignedUrl<T = PresignedUrlResponse>(filename: string, extension: string): AxiosPromise<Response<T>>;
5742
+ /**
5743
+ * Confirm a successful S3 upload and create the database record.
5744
+ * Call this after the direct S3 upload is complete.
5745
+ *
5746
+ * @param data The file metadata (path, size, mime_type).
5747
+ * @returns AxiosPromise containing the created Media resource.
5748
+ */
5749
+ static confirmS3Upload<T>(data: S3ConfirmRequest): AxiosPromise<Response<T>>;
5722
5750
  }
5723
5751
 
5724
5752
  declare class Scheduler {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "2.5.8",
3
+ "version": "2.5.9",
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
@@ -103,6 +103,19 @@ export interface ScreenshotValidationResponse {
103
103
  recommendations: string[];
104
104
  }
105
105
 
106
+ export interface PresignedUrlResponse {
107
+ upload_url: string;
108
+ file_path: string;
109
+ }
110
+
111
+ export interface S3ConfirmRequest {
112
+ file_path: string;
113
+ size: number;
114
+ mime_type: string;
115
+ title?: string;
116
+ filename?: string;
117
+ }
118
+
106
119
  class Media {
107
120
  /**
108
121
  * Upload media content using a File object.
@@ -342,6 +355,29 @@ class Media {
342
355
  // We use the raw URL here as it's a specialized upload path
343
356
  return Requests.uploadFile('/media/tiktok/music', 'audio', file, { scheduler_id });
344
357
  }
358
+
359
+ /**
360
+ * Generate an S3 Presigned URL for direct upload.
361
+ * Use this for large files (up to 2GB) to bypass the Laravel server.
362
+ *
363
+ * @param filename The original name of the file.
364
+ * @param extension The file extension (e.g., 'mp4').
365
+ * @returns AxiosPromise containing upload_url and file_path.
366
+ */
367
+ public static getPresignedUrl<T = PresignedUrlResponse>(filename: string, extension: string): AxiosPromise<Response<T>> {
368
+ return Requests.processRoute(MediaRoute.routes.getPresignedUrl, { filename, extension });
369
+ }
370
+
371
+ /**
372
+ * Confirm a successful S3 upload and create the database record.
373
+ * Call this after the direct S3 upload is complete.
374
+ *
375
+ * @param data The file metadata (path, size, mime_type).
376
+ * @returns AxiosPromise containing the created Media resource.
377
+ */
378
+ public static confirmS3Upload<T>(data: S3ConfirmRequest): AxiosPromise<Response<T>> {
379
+ return Requests.processRoute(MediaRoute.routes.confirmS3Upload, data);
380
+ }
345
381
  }
346
382
 
347
383
  export default Media;
@@ -12,6 +12,8 @@ class MediaRoute {
12
12
  createLibraryLogo: { url: '/media/create-library-logo', method: HTTP_METHODS.POST },
13
13
  validateScreenshot: { url: '/media/validate-screenshot', method: HTTP_METHODS.POST },
14
14
  uploadTikTokMusic: { url: '/media/tiktok/music', method: HTTP_METHODS.POST },
15
+ getPresignedUrl: { url: '/media/presigned-url', method: HTTP_METHODS.POST },
16
+ confirmS3Upload: { url: '/media/s3-confirm', method: HTTP_METHODS.POST },
15
17
  };
16
18
  }
17
19