glitch-javascript-sdk 3.2.28 → 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.
- package/dist/cjs/index.js +85 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Crm.d.ts +10 -1
- package/dist/esm/api/TwitchReporting.d.ts +11 -0
- package/dist/esm/index.js +85 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/util/Requests.d.ts +1 -0
- package/dist/index.d.ts +21 -0
- package/package.json +1 -1
- package/src/api/Crm.ts +57 -1
- package/src/api/TwitchReporting.ts +15 -1
- package/src/routes/CrmRoute.ts +2 -0
- package/src/routes/TwitchReportingRoute.ts +5 -1
- 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
|
@@ -8101,6 +8101,17 @@ declare class TwitchReporting {
|
|
|
8101
8101
|
* @returns promise
|
|
8102
8102
|
*/
|
|
8103
8103
|
static getMostActiveGames<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
8104
|
+
/**
|
|
8105
|
+
* Discover the most active Twitch games with Steam/IGDB genre, category,
|
|
8106
|
+
* theme, live snapshot, and trend metrics.
|
|
8107
|
+
*
|
|
8108
|
+
* @see https://api.glitch.fun/api/documentation#/Twitch%20Reporting/discoverActiveTwitchGames
|
|
8109
|
+
*
|
|
8110
|
+
* @param params Optional query parameters (e.g., genres, categories, match_mode, trend_days, sort_by, limit).
|
|
8111
|
+
*
|
|
8112
|
+
* @returns promise
|
|
8113
|
+
*/
|
|
8114
|
+
static discoverActiveGames<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
8104
8115
|
/**
|
|
8105
8116
|
* Get top streamers by performance (average or peak CCV).
|
|
8106
8117
|
*
|
|
@@ -8518,6 +8529,14 @@ declare class Crm {
|
|
|
8518
8529
|
* Import external prospects into CRM leads and contacts for future campaigns.
|
|
8519
8530
|
*/
|
|
8520
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>>;
|
|
8521
8540
|
/**
|
|
8522
8541
|
* List provider-managed sender and reply-to addresses for CRM campaigns.
|
|
8523
8542
|
*/
|
|
@@ -8538,6 +8557,7 @@ declare class Crm {
|
|
|
8538
8557
|
* Deactivate a provider address while keeping the audit record.
|
|
8539
8558
|
*/
|
|
8540
8559
|
static deactivateEmailProviderAddress<T>(address_id: string): AxiosPromise<Response<T>>;
|
|
8560
|
+
private static festivalSubmissionFormData;
|
|
8541
8561
|
}
|
|
8542
8562
|
|
|
8543
8563
|
type MultiplayerLobbyType = 'public' | 'invisible' | 'friends_only' | 'private';
|
|
@@ -10359,6 +10379,7 @@ declare class Requests {
|
|
|
10359
10379
|
static patch<T>(url: string, data: any, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
10360
10380
|
static delete<T>(url: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
10361
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>>;
|
|
10362
10383
|
static uploadBlob<T>(url: string, filename: string, blob: Blob, data?: any, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
|
|
10363
10384
|
static uploadFileInChunks<T>(file: File, uploadUrl: string, onProgress?: (totalSize: number, amountUploaded: number) => void, data?: any, chunkSize?: number): Promise<void>;
|
|
10364
10385
|
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,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;
|
|
@@ -58,6 +58,20 @@ class TwitchReporting {
|
|
|
58
58
|
return Requests.processRoute(TwitchReportingRoute.routes.getMostActiveGames, undefined, undefined, params);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Discover the most active Twitch games with Steam/IGDB genre, category,
|
|
63
|
+
* theme, live snapshot, and trend metrics.
|
|
64
|
+
*
|
|
65
|
+
* @see https://api.glitch.fun/api/documentation#/Twitch%20Reporting/discoverActiveTwitchGames
|
|
66
|
+
*
|
|
67
|
+
* @param params Optional query parameters (e.g., genres, categories, match_mode, trend_days, sort_by, limit).
|
|
68
|
+
*
|
|
69
|
+
* @returns promise
|
|
70
|
+
*/
|
|
71
|
+
public static discoverActiveGames<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
|
|
72
|
+
return Requests.processRoute(TwitchReportingRoute.routes.discoverActiveGames, undefined, undefined, params);
|
|
73
|
+
}
|
|
74
|
+
|
|
61
75
|
/**
|
|
62
76
|
* Get top streamers by performance (average or peak CCV).
|
|
63
77
|
*
|
|
@@ -107,4 +121,4 @@ class TwitchReporting {
|
|
|
107
121
|
|
|
108
122
|
}
|
|
109
123
|
|
|
110
|
-
export default TwitchReporting;
|
|
124
|
+
export default TwitchReporting;
|
package/src/routes/CrmRoute.ts
CHANGED
|
@@ -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 },
|
|
@@ -20,6 +20,10 @@ class TwitchReportingRoute {
|
|
|
20
20
|
url: '/reporting/twitch/games/most-active',
|
|
21
21
|
method: HTTP_METHODS.GET
|
|
22
22
|
},
|
|
23
|
+
discoverActiveGames: {
|
|
24
|
+
url: '/reporting/twitch/games/discovery',
|
|
25
|
+
method: HTTP_METHODS.GET
|
|
26
|
+
},
|
|
23
27
|
getTopStreamers: {
|
|
24
28
|
url: '/reporting/twitch/streamers/top',
|
|
25
29
|
method: HTTP_METHODS.GET
|
|
@@ -40,4 +44,4 @@ class TwitchReportingRoute {
|
|
|
40
44
|
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
export default TwitchReportingRoute;
|
|
47
|
+
export default TwitchReportingRoute;
|
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,
|