glitch-javascript-sdk 2.5.7 → 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 {
@@ -7163,11 +7191,20 @@ declare class Education {
7163
7191
  static submitQuiz<T>(uuid: string, answers: object): AxiosPromise<Response<T>>;
7164
7192
  static myQuizAttempts<T>(uuid: string): AxiosPromise<Response<T>>;
7165
7193
  static viewQuizAttempt<T>(uuid: string): AxiosPromise<Response<T>>;
7194
+ static createQuiz<T>(data: object): AxiosPromise<Response<T>>;
7195
+ static updateQuiz<T>(uuid: string, data: object): AxiosPromise<Response<T>>;
7196
+ static deleteQuiz<T>(uuid: string): AxiosPromise<Response<T>>;
7166
7197
  static listQuizQuestions<T>(quiz_id: string): AxiosPromise<Response<T>>;
7167
7198
  static createQuizQuestion<T>(quiz_id: string, data: object): AxiosPromise<Response<T>>;
7168
7199
  static reorderQuizQuestions<T>(quiz_id: string, question_ids: string[]): AxiosPromise<Response<T>>;
7169
7200
  static listQuizOptions<T>(question_id: string): AxiosPromise<Response<T>>;
7170
7201
  static createQuizOption<T>(question_id: string, data: object): AxiosPromise<Response<T>>;
7202
+ static viewQuizQuestion<T>(uuid: string): AxiosPromise<Response<T>>;
7203
+ static updateQuizQuestion<T>(uuid: string, data: object): AxiosPromise<Response<T>>;
7204
+ static deleteQuizQuestion<T>(uuid: string): AxiosPromise<Response<T>>;
7205
+ static viewQuizOption<T>(uuid: string): AxiosPromise<Response<T>>;
7206
+ static updateQuizOption<T>(uuid: string, data: object): AxiosPromise<Response<T>>;
7207
+ static deleteQuizOption<T>(uuid: string): AxiosPromise<Response<T>>;
7171
7208
  static syncProgress<T>(data: object): AxiosPromise<Response<T>>;
7172
7209
  static getMyProgressByContent<T>(content_id: string): AxiosPromise<Response<T>>;
7173
7210
  static listRegistrations<T>(params?: object): AxiosPromise<Response<T>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "2.5.7",
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",
@@ -100,6 +100,15 @@ class Education {
100
100
  public static viewQuizAttempt<T>(uuid: string): AxiosPromise<Response<T>> {
101
101
  return Requests.processRoute(EducationRoute.routes.viewQuizAttempt, undefined, { uuid });
102
102
  }
103
+ public static createQuiz<T>(data: object): AxiosPromise<Response<T>> {
104
+ return Requests.processRoute(EducationRoute.routes.createQuiz, data);
105
+ }
106
+ public static updateQuiz<T>(uuid: string, data: object): AxiosPromise<Response<T>> {
107
+ return Requests.processRoute(EducationRoute.routes.updateQuiz, data, { uuid });
108
+ }
109
+ public static deleteQuiz<T>(uuid: string): AxiosPromise<Response<T>> {
110
+ return Requests.processRoute(EducationRoute.routes.deleteQuiz, undefined, { uuid });
111
+ }
103
112
 
104
113
  // --- 6. QUIZ QUESTIONS & OPTIONS ---
105
114
  public static listQuizQuestions<T>(quiz_id: string): AxiosPromise<Response<T>> {
@@ -117,6 +126,27 @@ class Education {
117
126
  public static createQuizOption<T>(question_id: string, data: object): AxiosPromise<Response<T>> {
118
127
  return Requests.processRoute(EducationRoute.routes.createQuizOption, data, { question_id });
119
128
  }
129
+ public static viewQuizQuestion<T>(uuid: string): AxiosPromise<Response<T>> {
130
+ return Requests.processRoute(EducationRoute.routes.viewQuizQuestion, undefined, { uuid });
131
+ }
132
+ public static updateQuizQuestion<T>(uuid: string, data: object): AxiosPromise<Response<T>> {
133
+ return Requests.processRoute(EducationRoute.routes.updateQuizQuestion, data, { uuid });
134
+ }
135
+ public static deleteQuizQuestion<T>(uuid: string): AxiosPromise<Response<T>> {
136
+ return Requests.processRoute(EducationRoute.routes.deleteQuizQuestion, undefined, { uuid });
137
+ }
138
+
139
+ // --- QUIZ OPTIONS (CRUD) ---
140
+ public static viewQuizOption<T>(uuid: string): AxiosPromise<Response<T>> {
141
+ return Requests.processRoute(EducationRoute.routes.viewQuizOption, undefined, { uuid });
142
+ }
143
+ public static updateQuizOption<T>(uuid: string, data: object): AxiosPromise<Response<T>> {
144
+ return Requests.processRoute(EducationRoute.routes.updateQuizOption, data, { uuid });
145
+ }
146
+ public static deleteQuizOption<T>(uuid: string): AxiosPromise<Response<T>> {
147
+ return Requests.processRoute(EducationRoute.routes.deleteQuizOption, undefined, { uuid });
148
+ }
149
+
120
150
 
121
151
  // --- 7. PROGRESS & REGISTRATIONS ---
122
152
  public static syncProgress<T>(data: object): AxiosPromise<Response<T>> {
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;
@@ -137,6 +137,7 @@ class EducationRoute {
137
137
  updateBadge: { url: '/badges/{uuid}', method: HTTP_METHODS.PUT },
138
138
  revokeBadge: { url: '/badges/{uuid}', method: HTTP_METHODS.DELETE },
139
139
  listUserBadges: { url: '/users/{user_id}/badges', method: HTTP_METHODS.GET },
140
+
140
141
  };
141
142
  }
142
143
 
@@ -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