glitch-javascript-sdk 3.2.29 → 3.2.30

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.
@@ -26,6 +26,7 @@ declare class Requests {
26
26
  static patch<T>(url: string, data: any, params?: Record<string, any>): AxiosPromise<Response<T>>;
27
27
  static delete<T>(url: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
28
28
  static uploadFile<T>(url: string, filename: string, file: File | Blob, data?: any, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
29
+ static postFormData<T>(url: string, formData: FormData, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
29
30
  static uploadBlob<T>(url: string, filename: string, blob: Blob, data?: any, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
30
31
  static uploadFileInChunks<T>(file: File, uploadUrl: string, onProgress?: (totalSize: number, amountUploaded: number) => void, data?: any, chunkSize?: number): Promise<void>;
31
32
  static processRoute<T>(route: Route, data?: object, routeReplace?: {
package/dist/index.d.ts CHANGED
@@ -8529,6 +8529,14 @@ declare class Crm {
8529
8529
  * Import external prospects into CRM leads and contacts for future campaigns.
8530
8530
  */
8531
8531
  static importCampaignProspects<T>(prospects: object[], options?: Record<string, any>): AxiosPromise<Response<T>>;
8532
+ /**
8533
+ * Preview uploaded festival submission sheets without writing External Game or CRM records.
8534
+ */
8535
+ static previewFestivalSubmissionImport<T>(files: Array<File | Blob>, options?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
8536
+ /**
8537
+ * Import uploaded festival submission sheets into External Games and CRM leads/contacts.
8538
+ */
8539
+ static importFestivalSubmissions<T>(files: Array<File | Blob>, options?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
8532
8540
  /**
8533
8541
  * List provider-managed sender and reply-to addresses for CRM campaigns.
8534
8542
  */
@@ -8549,6 +8557,7 @@ declare class Crm {
8549
8557
  * Deactivate a provider address while keeping the audit record.
8550
8558
  */
8551
8559
  static deactivateEmailProviderAddress<T>(address_id: string): AxiosPromise<Response<T>>;
8560
+ private static festivalSubmissionFormData;
8552
8561
  }
8553
8562
 
8554
8563
  type MultiplayerLobbyType = 'public' | 'invisible' | 'friends_only' | 'private';
@@ -10370,6 +10379,7 @@ declare class Requests {
10370
10379
  static patch<T>(url: string, data: any, params?: Record<string, any>): AxiosPromise<Response<T>>;
10371
10380
  static delete<T>(url: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
10372
10381
  static uploadFile<T>(url: string, filename: string, file: File | Blob, data?: any, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
10382
+ static postFormData<T>(url: string, formData: FormData, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
10373
10383
  static uploadBlob<T>(url: string, filename: string, blob: Blob, data?: any, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
10374
10384
  static uploadFileInChunks<T>(file: File, uploadUrl: string, onProgress?: (totalSize: number, amountUploaded: number) => void, data?: any, chunkSize?: number): Promise<void>;
10375
10385
  static processRoute<T>(route: Route, data?: object, routeReplace?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "3.2.29",
3
+ "version": "3.2.30",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "publishConfig": {
6
6
  "access": "public"
package/src/api/Crm.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import CrmRoute from "../routes/CrmRoute";
2
2
  import Requests from "../util/Requests";
3
3
  import Response from "../util/Response";
4
- import { AxiosPromise } from "axios";
4
+ import { AxiosPromise, AxiosProgressEvent } from "axios";
5
5
 
6
6
  class Crm {
7
7
  /**
@@ -263,6 +263,38 @@ class Crm {
263
263
  return Requests.processRoute(CrmRoute.routes.importCampaignProspects, { prospects, ...options });
264
264
  }
265
265
 
266
+ /**
267
+ * Preview uploaded festival submission sheets without writing External Game or CRM records.
268
+ */
269
+ public static previewFestivalSubmissionImport<T>(
270
+ files: Array<File | Blob>,
271
+ options: Record<string, any> = {},
272
+ onUploadProgress?: (progressEvent: AxiosProgressEvent) => void
273
+ ): AxiosPromise<Response<T>> {
274
+ return Requests.postFormData(
275
+ CrmRoute.routes.previewFestivalSubmissionImport.url,
276
+ Crm.festivalSubmissionFormData(files, options),
277
+ undefined,
278
+ onUploadProgress
279
+ );
280
+ }
281
+
282
+ /**
283
+ * Import uploaded festival submission sheets into External Games and CRM leads/contacts.
284
+ */
285
+ public static importFestivalSubmissions<T>(
286
+ files: Array<File | Blob>,
287
+ options: Record<string, any> = {},
288
+ onUploadProgress?: (progressEvent: AxiosProgressEvent) => void
289
+ ): AxiosPromise<Response<T>> {
290
+ return Requests.postFormData(
291
+ CrmRoute.routes.importFestivalSubmissions.url,
292
+ Crm.festivalSubmissionFormData(files, options),
293
+ undefined,
294
+ onUploadProgress
295
+ );
296
+ }
297
+
266
298
  /**
267
299
  * List provider-managed sender and reply-to addresses for CRM campaigns.
268
300
  */
@@ -298,6 +330,30 @@ class Crm {
298
330
  return Requests.processRoute(CrmRoute.routes.deactivateEmailProviderAddress, {}, { address_id });
299
331
  }
300
332
 
333
+ private static festivalSubmissionFormData(files: Array<File | Blob>, options: Record<string, any>): FormData {
334
+ const formData = new FormData();
335
+
336
+ files.forEach((file, index) => {
337
+ const candidate = file as any;
338
+ formData.append('files[]', file as any, candidate?.name || `festival-submission-${index + 1}`);
339
+ });
340
+
341
+ Object.entries(options || {}).forEach(([key, value]) => {
342
+ if (value === undefined || value === null) {
343
+ return;
344
+ }
345
+
346
+ if (Array.isArray(value)) {
347
+ value.forEach((item) => formData.append(`${key}[]`, String(item)));
348
+ return;
349
+ }
350
+
351
+ formData.append(key, typeof value === 'boolean' ? (value ? '1' : '0') : String(value));
352
+ });
353
+
354
+ return formData;
355
+ }
356
+
301
357
  }
302
358
 
303
359
  export default Crm;
@@ -41,6 +41,8 @@ class CrmRoute {
41
41
  listCampaignRecipients: { url: '/admin/crm/campaigns/{campaign_id}/recipients', method: HTTP_METHODS.GET },
42
42
  previewCampaignProspectImport: { url: '/admin/crm/campaigns/import-prospects/preview', method: HTTP_METHODS.POST },
43
43
  importCampaignProspects: { url: '/admin/crm/campaigns/import-prospects', method: HTTP_METHODS.POST },
44
+ previewFestivalSubmissionImport: { url: '/admin/crm/imports/festival-submissions/preview', method: HTTP_METHODS.POST },
45
+ importFestivalSubmissions: { url: '/admin/crm/imports/festival-submissions', method: HTTP_METHODS.POST },
44
46
  listEmailProviderAddresses: { url: '/admin/crm/email-provider-addresses', method: HTTP_METHODS.GET },
45
47
  getEmailProviderAddressOptions: { url: '/admin/crm/email-provider-addresses/options', method: HTTP_METHODS.GET },
46
48
  createEmailProviderAddress: { url: '/admin/crm/email-provider-addresses', method: HTTP_METHODS.POST },
@@ -271,6 +271,46 @@ class Requests {
271
271
  });
272
272
  }
273
273
 
274
+ public static postFormData<T>(
275
+ url: string,
276
+ formData: FormData,
277
+ params?: Record<string, any>,
278
+ onUploadProgress?: (progressEvent: AxiosProgressEvent) => void
279
+ ): AxiosPromise<Response<T>> {
280
+ if (params && Object.keys(params).length > 0) {
281
+ const queryString = Object.entries(params)
282
+ .filter(([, value]) => value !== undefined && value !== null && value !== '')
283
+ .map(([key, value]) => {
284
+ if (Array.isArray(value)) {
285
+ return value.map((item) => `${key}[]=${encodeURIComponent(item)}`).join('&');
286
+ }
287
+ return `${key}=${encodeURIComponent(value)}`;
288
+ })
289
+ .filter(Boolean)
290
+ .join('&');
291
+
292
+ if (queryString) {
293
+ url = `${url}?${queryString}`;
294
+ }
295
+ }
296
+
297
+ let headers: { [key: string]: string } = {};
298
+
299
+ if (Requests.authToken) {
300
+ headers['Authorization'] = `Bearer ${Requests.authToken}`;
301
+ }
302
+
303
+ const uri = Requests.baseUrl.replace(/\/+$/, '') + '/' + url.replace(/^\/+/, '');
304
+
305
+ return axios({
306
+ method: 'POST',
307
+ url: uri,
308
+ data: formData,
309
+ headers,
310
+ onUploadProgress,
311
+ });
312
+ }
313
+
274
314
 
275
315
  public static uploadBlob<T>(
276
316
  url: string,