glitch-javascript-sdk 3.2.29 → 3.2.31
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/cjs/index.js +96 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Crm.d.ts +26 -1
- package/dist/esm/index.js +96 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/util/Requests.d.ts +1 -0
- package/dist/index.d.ts +26 -0
- package/package.json +1 -1
- package/src/api/Crm.ts +85 -1
- package/src/routes/CrmRoute.ts +6 -0
- package/src/util/Requests.ts +40 -0
|
@@ -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,30 @@ 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>>;
|
|
8540
|
+
/**
|
|
8541
|
+
* List saved recurring Google Sheet sources for festival submission imports.
|
|
8542
|
+
*/
|
|
8543
|
+
static listFestivalSubmissionSources<T>(): AxiosPromise<Response<T>>;
|
|
8544
|
+
/**
|
|
8545
|
+
* Save a recurring Google Sheet source for festival submission imports.
|
|
8546
|
+
*/
|
|
8547
|
+
static createFestivalSubmissionSource<T>(data: object): AxiosPromise<Response<T>>;
|
|
8548
|
+
/**
|
|
8549
|
+
* Update a recurring Google Sheet source for festival submission imports.
|
|
8550
|
+
*/
|
|
8551
|
+
static updateFestivalSubmissionSource<T>(source_id: string, data: object): AxiosPromise<Response<T>>;
|
|
8552
|
+
/**
|
|
8553
|
+
* Delete a recurring Google Sheet source for festival submission imports.
|
|
8554
|
+
*/
|
|
8555
|
+
static deleteFestivalSubmissionSource<T>(source_id: string): AxiosPromise<Response<T>>;
|
|
8532
8556
|
/**
|
|
8533
8557
|
* List provider-managed sender and reply-to addresses for CRM campaigns.
|
|
8534
8558
|
*/
|
|
@@ -8549,6 +8573,7 @@ declare class Crm {
|
|
|
8549
8573
|
* Deactivate a provider address while keeping the audit record.
|
|
8550
8574
|
*/
|
|
8551
8575
|
static deactivateEmailProviderAddress<T>(address_id: string): AxiosPromise<Response<T>>;
|
|
8576
|
+
private static festivalSubmissionFormData;
|
|
8552
8577
|
}
|
|
8553
8578
|
|
|
8554
8579
|
type MultiplayerLobbyType = 'public' | 'invisible' | 'friends_only' | 'private';
|
|
@@ -10370,6 +10395,7 @@ declare class Requests {
|
|
|
10370
10395
|
static patch<T>(url: string, data: any, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
10371
10396
|
static delete<T>(url: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
10372
10397
|
static uploadFile<T>(url: string, filename: string, file: File | Blob, data?: any, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
|
|
10398
|
+
static postFormData<T>(url: string, formData: FormData, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
|
|
10373
10399
|
static uploadBlob<T>(url: string, filename: string, blob: Blob, data?: any, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
|
|
10374
10400
|
static uploadFileInChunks<T>(file: File, uploadUrl: string, onProgress?: (totalSize: number, amountUploaded: number) => void, data?: any, chunkSize?: number): Promise<void>;
|
|
10375
10401
|
static processRoute<T>(route: Route, data?: object, routeReplace?: {
|
package/package.json
CHANGED
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,66 @@ 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
|
+
|
|
298
|
+
/**
|
|
299
|
+
* List saved recurring Google Sheet sources for festival submission imports.
|
|
300
|
+
*/
|
|
301
|
+
public static listFestivalSubmissionSources<T>(): AxiosPromise<Response<T>> {
|
|
302
|
+
return Requests.processRoute(CrmRoute.routes.listFestivalSubmissionSources);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Save a recurring Google Sheet source for festival submission imports.
|
|
307
|
+
*/
|
|
308
|
+
public static createFestivalSubmissionSource<T>(data: object): AxiosPromise<Response<T>> {
|
|
309
|
+
return Requests.processRoute(CrmRoute.routes.createFestivalSubmissionSource, data);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Update a recurring Google Sheet source for festival submission imports.
|
|
314
|
+
*/
|
|
315
|
+
public static updateFestivalSubmissionSource<T>(source_id: string, data: object): AxiosPromise<Response<T>> {
|
|
316
|
+
return Requests.processRoute(CrmRoute.routes.updateFestivalSubmissionSource, data, { source_id });
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Delete a recurring Google Sheet source for festival submission imports.
|
|
321
|
+
*/
|
|
322
|
+
public static deleteFestivalSubmissionSource<T>(source_id: string): AxiosPromise<Response<T>> {
|
|
323
|
+
return Requests.processRoute(CrmRoute.routes.deleteFestivalSubmissionSource, {}, { source_id });
|
|
324
|
+
}
|
|
325
|
+
|
|
266
326
|
/**
|
|
267
327
|
* List provider-managed sender and reply-to addresses for CRM campaigns.
|
|
268
328
|
*/
|
|
@@ -298,6 +358,30 @@ class Crm {
|
|
|
298
358
|
return Requests.processRoute(CrmRoute.routes.deactivateEmailProviderAddress, {}, { address_id });
|
|
299
359
|
}
|
|
300
360
|
|
|
361
|
+
private static festivalSubmissionFormData(files: Array<File | Blob>, options: Record<string, any>): FormData {
|
|
362
|
+
const formData = new FormData();
|
|
363
|
+
|
|
364
|
+
files.forEach((file, index) => {
|
|
365
|
+
const candidate = file as any;
|
|
366
|
+
formData.append('files[]', file as any, candidate?.name || `festival-submission-${index + 1}`);
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
Object.entries(options || {}).forEach(([key, value]) => {
|
|
370
|
+
if (value === undefined || value === null) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (Array.isArray(value)) {
|
|
375
|
+
value.forEach((item) => formData.append(`${key}[]`, String(item)));
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
formData.append(key, typeof value === 'boolean' ? (value ? '1' : '0') : String(value));
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
return formData;
|
|
383
|
+
}
|
|
384
|
+
|
|
301
385
|
}
|
|
302
386
|
|
|
303
387
|
export default Crm;
|
package/src/routes/CrmRoute.ts
CHANGED
|
@@ -41,6 +41,12 @@ 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 },
|
|
46
|
+
listFestivalSubmissionSources: { url: '/admin/crm/imports/festival-submissions/sources', method: HTTP_METHODS.GET },
|
|
47
|
+
createFestivalSubmissionSource: { url: '/admin/crm/imports/festival-submissions/sources', method: HTTP_METHODS.POST },
|
|
48
|
+
updateFestivalSubmissionSource: { url: '/admin/crm/imports/festival-submissions/sources/{source_id}', method: HTTP_METHODS.PUT },
|
|
49
|
+
deleteFestivalSubmissionSource: { url: '/admin/crm/imports/festival-submissions/sources/{source_id}', method: HTTP_METHODS.DELETE },
|
|
44
50
|
listEmailProviderAddresses: { url: '/admin/crm/email-provider-addresses', method: HTTP_METHODS.GET },
|
|
45
51
|
getEmailProviderAddressOptions: { url: '/admin/crm/email-provider-addresses/options', method: HTTP_METHODS.GET },
|
|
46
52
|
createEmailProviderAddress: { url: '/admin/crm/email-provider-addresses', method: HTTP_METHODS.POST },
|
package/src/util/Requests.ts
CHANGED
|
@@ -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,
|