glitch-javascript-sdk 1.3.9 → 1.4.1

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.
@@ -0,0 +1,66 @@
1
+ import Response from "../util/Response";
2
+ import { AxiosPromise } from "axios";
3
+ declare class Funnel {
4
+ /**
5
+ * Get funnel metrics.
6
+ *
7
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels
8
+ *
9
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
10
+ * @returns Promise with funnel metrics data
11
+ */
12
+ static index<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
13
+ /**
14
+ * Get funnel-optimized metrics.
15
+ *
16
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_funnel
17
+ *
18
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
19
+ * @returns Promise with funnel data optimized for visual funnels
20
+ */
21
+ static funnel<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
22
+ /**
23
+ * Get available metrics.
24
+ *
25
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_metrics
26
+ *
27
+ * @returns Promise with list of available metrics
28
+ */
29
+ static metrics<T>(): AxiosPromise<Response<T>>;
30
+ /**
31
+ * Get available stages.
32
+ *
33
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_stages
34
+ *
35
+ * @returns Promise with list of available stages
36
+ */
37
+ static stages<T>(): AxiosPromise<Response<T>>;
38
+ /**
39
+ * Get daily funnel metrics.
40
+ *
41
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_daily
42
+ *
43
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
44
+ * @returns Promise with daily funnel metrics data
45
+ */
46
+ static daily<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
47
+ /**
48
+ * Get monthly funnel metrics.
49
+ *
50
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_monthly
51
+ *
52
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
53
+ * @returns Promise with monthly funnel metrics data
54
+ */
55
+ static monthly<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
56
+ /**
57
+ * Get yearly funnel metrics.
58
+ *
59
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_yearly
60
+ *
61
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
62
+ * @returns Promise with yearly funnel metrics data
63
+ */
64
+ static yearly<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
65
+ }
66
+ export default Funnel;
@@ -1,5 +1,5 @@
1
1
  import Response from "../util/Response";
2
- import { AxiosPromise } from "axios";
2
+ import { AxiosProgressEvent, AxiosPromise } from "axios";
3
3
  declare class Media {
4
4
  /**
5
5
  * Upload media content using a File object.
@@ -11,7 +11,7 @@ declare class Media {
11
11
  *
12
12
  * @returns promise
13
13
  */
14
- static uploadFile<T>(file: File, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
14
+ static uploadFile<T>(file: File, data?: object, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
15
15
  /**
16
16
  * Upload media content using a Blob.
17
17
  *
@@ -22,7 +22,7 @@ declare class Media {
22
22
  *
23
23
  * @returns promise
24
24
  */
25
- static uploadBlob<T>(blob: Blob, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
25
+ static uploadBlob<T>(blob: Blob, data?: object, params?: Record<string, any>, onUploadProgress?: (progressEvent: AxiosProgressEvent) => void): AxiosPromise<Response<T>>;
26
26
  /**
27
27
  * Get media details.
28
28
  *
@@ -50,6 +50,17 @@ declare class Scheduler {
50
50
  * @returns promise
51
51
  */
52
52
  static deleteSchedule<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
53
+ /**
54
+ * Test the tone of the scheduler.
55
+ *
56
+ * @see https://api.glitch.fun/api/documentation#/Scheduler/updateTitlePromotionSchedule
57
+ *
58
+ * @param scheduler_id The ID of the promotion schedule.
59
+ * @param data The data to update.
60
+ *
61
+ * @returns promise
62
+ */
63
+ static testTone<T>(scheduler_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
53
64
  /**
54
65
  * Get social media posts related to a promotion schedule.
55
66
  *
@@ -133,5 +133,13 @@ declare class Titles {
133
133
  * @returns promise
134
134
  */
135
135
  static uploadBannerImageBlob<T>(title_id: string, blob: Blob, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
136
+ /**
137
+ * Add media to a title.
138
+ */
139
+ static addMedia<T>(title_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
140
+ /**
141
+ * Remove media from a title.
142
+ */
143
+ static removeMedia<T>(title_id: string, media_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
136
144
  }
137
145
  export default Titles;
@@ -27,6 +27,7 @@ import Newsletters from "./Newsletters";
27
27
  import PlayTests from "./PlayTests";
28
28
  import Media from "./Media";
29
29
  import Scheduler from "./Scheduler";
30
+ import Funnel from "./Funnel";
30
31
  export { Auth };
31
32
  export { Competitions };
32
33
  export { Communities };
@@ -56,3 +57,4 @@ export { Newsletters };
56
57
  export { PlayTests };
57
58
  export { Media };
58
59
  export { Scheduler };
60
+ export { Funnel };
@@ -27,6 +27,7 @@ import { Newsletters } from "./api";
27
27
  import { PlayTests } from "./api";
28
28
  import { Media } from "./api";
29
29
  import { Scheduler } from "./api";
30
+ import { Funnel } from "./api";
30
31
  import Requests from "./util/Requests";
31
32
  import Parser from "./util/Parser";
32
33
  import Session from "./util/Session";
@@ -75,6 +76,7 @@ declare class Glitch {
75
76
  PlayTests: typeof PlayTests;
76
77
  Media: typeof Media;
77
78
  Scheduler: typeof Scheduler;
79
+ Funnel: typeof Funnel;
78
80
  };
79
81
  static util: {
80
82
  Requests: typeof Requests;
package/dist/esm/index.js CHANGED
@@ -5410,7 +5410,8 @@ var Requests = /** @class */ (function () {
5410
5410
  }
5411
5411
  return Requests.request('DELETE', url);
5412
5412
  };
5413
- Requests.uploadFile = function (url, filename, file, data, params) {
5413
+ Requests.uploadFile = function (url, filename, file, data, params, onUploadProgress // Correct type here
5414
+ ) {
5414
5415
  if (params && Object.keys(params).length > 0) {
5415
5416
  var queryString = Object.entries(params)
5416
5417
  .map(function (_a) {
@@ -5428,9 +5429,18 @@ var Requests = /** @class */ (function () {
5428
5429
  for (var key in data) {
5429
5430
  formData.append(key, data[key]);
5430
5431
  }
5431
- return Requests.request('POST', url, data, formData);
5432
+ var config = {
5433
+ method: 'POST',
5434
+ url: url,
5435
+ data: formData,
5436
+ headers: __assign({ 'Content-Type': 'multipart/form-data' }, (Requests.authToken && { Authorization: "Bearer ".concat(Requests.authToken) })),
5437
+ onUploadProgress: onUploadProgress,
5438
+ };
5439
+ return axios$1(config);
5432
5440
  };
5433
- Requests.uploadBlob = function (url, filename, blob, data, params) {
5441
+ // Modify uploadBlob method
5442
+ Requests.uploadBlob = function (url, filename, blob, data, params, onUploadProgress // Corrected type
5443
+ ) {
5434
5444
  if (params && Object.keys(params).length > 0) {
5435
5445
  var queryString = Object.entries(params)
5436
5446
  .map(function (_a) {
@@ -5448,7 +5458,14 @@ var Requests = /** @class */ (function () {
5448
5458
  for (var key in data) {
5449
5459
  formData.append(key, data[key]);
5450
5460
  }
5451
- return Requests.request('POST', url, data, formData);
5461
+ var config = {
5462
+ method: 'POST',
5463
+ url: url,
5464
+ data: formData,
5465
+ headers: __assign({ 'Content-Type': 'multipart/form-data' }, (Requests.authToken && { Authorization: "Bearer ".concat(Requests.authToken) })),
5466
+ onUploadProgress: onUploadProgress,
5467
+ };
5468
+ return axios$1(config);
5452
5469
  };
5453
5470
  // Method adapted for browser environments
5454
5471
  Requests.uploadFileInChunks = function (file, uploadUrl, onProgress, data, chunkSize) {
@@ -9426,6 +9443,8 @@ var TitlesRoute = /** @class */ (function () {
9426
9443
  uploadBannerImage: { url: '/titles/{title_id}/uploadBannerImage', method: HTTP_METHODS.POST },
9427
9444
  addAdministrator: { url: '/titles/{title_id}/addAdministrator', method: HTTP_METHODS.POST },
9428
9445
  removeAdministrator: { url: '/titles/{title_id}/removeAdministrator/{user_id}', method: HTTP_METHODS.DELETE },
9446
+ addMedia: { url: '/titles/{title_id}/addMedia', method: HTTP_METHODS.POST },
9447
+ removeMedia: { url: '/titles/{title_id}/removeMedia/{media_id}', method: HTTP_METHODS.DELETE },
9429
9448
  };
9430
9449
  return TitlesRoute;
9431
9450
  }());
@@ -9595,6 +9614,18 @@ var Titles = /** @class */ (function () {
9595
9614
  var url = TitlesRoute.routes.uploadBannerImage.url.replace('{title_id}', title_id);
9596
9615
  return Requests.uploadBlob(url, 'image', blob, data);
9597
9616
  };
9617
+ /**
9618
+ * Add media to a title.
9619
+ */
9620
+ Titles.addMedia = function (title_id, data, params) {
9621
+ return Requests.processRoute(TitlesRoute.routes.addMedia, data, { title_id: title_id }, params);
9622
+ };
9623
+ /**
9624
+ * Remove media from a title.
9625
+ */
9626
+ Titles.removeMedia = function (title_id, media_id, params) {
9627
+ return Requests.processRoute(TitlesRoute.routes.removeMedia, {}, { title_id: title_id, media_id: media_id }, params);
9628
+ };
9598
9629
  return Titles;
9599
9630
  }());
9600
9631
 
@@ -11195,8 +11226,8 @@ var Media = /** @class */ (function () {
11195
11226
  *
11196
11227
  * @returns promise
11197
11228
  */
11198
- Media.uploadFile = function (file, data, params) {
11199
- return Requests.uploadFile(MediaRoute.routes.upload.url, 'media', file, data, params);
11229
+ Media.uploadFile = function (file, data, params, onUploadProgress) {
11230
+ return Requests.uploadFile(MediaRoute.routes.upload.url, 'media', file, data, params, onUploadProgress);
11200
11231
  };
11201
11232
  /**
11202
11233
  * Upload media content using a Blob.
@@ -11208,8 +11239,8 @@ var Media = /** @class */ (function () {
11208
11239
  *
11209
11240
  * @returns promise
11210
11241
  */
11211
- Media.uploadBlob = function (blob, data, params) {
11212
- return Requests.uploadBlob(MediaRoute.routes.upload.url, 'media', blob, data, params);
11242
+ Media.uploadBlob = function (blob, data, params, onUploadProgress) {
11243
+ return Requests.uploadBlob(MediaRoute.routes.upload.url, 'media', blob, data, params, onUploadProgress);
11213
11244
  };
11214
11245
  /**
11215
11246
  * Get media details.
@@ -11243,6 +11274,7 @@ var SchedulerRoute = /** @class */ (function () {
11243
11274
  getUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.GET },
11244
11275
  updateUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.PUT },
11245
11276
  deleteUpdate: { url: '/schedulers/{scheduler_id}/updates/{update_id}', method: HTTP_METHODS.DELETE },
11277
+ testTone: { url: '/schedulers/{scheduler_id}/tone', method: HTTP_METHODS.POST },
11246
11278
  // Clear OAuth Routes
11247
11279
  clearTwitterAuth: { url: '/schedulers/{scheduler_id}/clearTwitterAuth', method: HTTP_METHODS.DELETE },
11248
11280
  clearFacebookAuth: { url: '/schedulers/{scheduler_id}/clearFacebookAuth', method: HTTP_METHODS.DELETE },
@@ -11330,6 +11362,19 @@ var Scheduler = /** @class */ (function () {
11330
11362
  Scheduler.deleteSchedule = function (scheduler_id, params) {
11331
11363
  return Requests.processRoute(SchedulerRoute.routes.deleteSchedule, {}, { scheduler_id: scheduler_id }, params);
11332
11364
  };
11365
+ /**
11366
+ * Test the tone of the scheduler.
11367
+ *
11368
+ * @see https://api.glitch.fun/api/documentation#/Scheduler/updateTitlePromotionSchedule
11369
+ *
11370
+ * @param scheduler_id The ID of the promotion schedule.
11371
+ * @param data The data to update.
11372
+ *
11373
+ * @returns promise
11374
+ */
11375
+ Scheduler.testTone = function (scheduler_id, data, params) {
11376
+ return Requests.processRoute(SchedulerRoute.routes.testTone, data, { scheduler_id: scheduler_id }, params);
11377
+ };
11333
11378
  /**
11334
11379
  * Get social media posts related to a promotion schedule.
11335
11380
  *
@@ -11582,6 +11627,104 @@ var Scheduler = /** @class */ (function () {
11582
11627
  return Scheduler;
11583
11628
  }());
11584
11629
 
11630
+ // src/routes/FunnelRoutes.tsx
11631
+ var FunnelRoutes = /** @class */ (function () {
11632
+ function FunnelRoutes() {
11633
+ }
11634
+ FunnelRoutes.routes = {
11635
+ index: { url: '/funnels', method: HTTP_METHODS.GET },
11636
+ funnel: { url: '/funnels/funnel', method: HTTP_METHODS.GET },
11637
+ metrics: { url: '/funnels/metrics', method: HTTP_METHODS.GET },
11638
+ stages: { url: '/funnels/stages', method: HTTP_METHODS.GET },
11639
+ daily: { url: '/funnels/daily', method: HTTP_METHODS.GET },
11640
+ monthly: { url: '/funnels/monthly', method: HTTP_METHODS.GET },
11641
+ yearly: { url: '/funnels/yearly', method: HTTP_METHODS.GET },
11642
+ };
11643
+ return FunnelRoutes;
11644
+ }());
11645
+
11646
+ // src/controllers/Funnel.tsx
11647
+ var Funnel = /** @class */ (function () {
11648
+ function Funnel() {
11649
+ }
11650
+ /**
11651
+ * Get funnel metrics.
11652
+ *
11653
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels
11654
+ *
11655
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
11656
+ * @returns Promise with funnel metrics data
11657
+ */
11658
+ Funnel.index = function (params) {
11659
+ return Requests.processRoute(FunnelRoutes.routes.index, undefined, undefined, params);
11660
+ };
11661
+ /**
11662
+ * Get funnel-optimized metrics.
11663
+ *
11664
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_funnel
11665
+ *
11666
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
11667
+ * @returns Promise with funnel data optimized for visual funnels
11668
+ */
11669
+ Funnel.funnel = function (params) {
11670
+ return Requests.processRoute(FunnelRoutes.routes.funnel, undefined, undefined, params);
11671
+ };
11672
+ /**
11673
+ * Get available metrics.
11674
+ *
11675
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_metrics
11676
+ *
11677
+ * @returns Promise with list of available metrics
11678
+ */
11679
+ Funnel.metrics = function () {
11680
+ return Requests.processRoute(FunnelRoutes.routes.metrics);
11681
+ };
11682
+ /**
11683
+ * Get available stages.
11684
+ *
11685
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_stages
11686
+ *
11687
+ * @returns Promise with list of available stages
11688
+ */
11689
+ Funnel.stages = function () {
11690
+ return Requests.processRoute(FunnelRoutes.routes.stages);
11691
+ };
11692
+ /**
11693
+ * Get daily funnel metrics.
11694
+ *
11695
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_daily
11696
+ *
11697
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
11698
+ * @returns Promise with daily funnel metrics data
11699
+ */
11700
+ Funnel.daily = function (params) {
11701
+ return Requests.processRoute(FunnelRoutes.routes.daily, undefined, undefined, params);
11702
+ };
11703
+ /**
11704
+ * Get monthly funnel metrics.
11705
+ *
11706
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_monthly
11707
+ *
11708
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
11709
+ * @returns Promise with monthly funnel metrics data
11710
+ */
11711
+ Funnel.monthly = function (params) {
11712
+ return Requests.processRoute(FunnelRoutes.routes.monthly, undefined, undefined, params);
11713
+ };
11714
+ /**
11715
+ * Get yearly funnel metrics.
11716
+ *
11717
+ * @see https://api.glitch.fun/api/documentation#/Funnel%20Metrics/get_funnels_yearly
11718
+ *
11719
+ * @param params Query parameters for filtering (title_id, community_id, start_date, end_date)
11720
+ * @returns Promise with yearly funnel metrics data
11721
+ */
11722
+ Funnel.yearly = function (params) {
11723
+ return Requests.processRoute(FunnelRoutes.routes.yearly, undefined, undefined, params);
11724
+ };
11725
+ return Funnel;
11726
+ }());
11727
+
11585
11728
  var Parser = /** @class */ (function () {
11586
11729
  function Parser() {
11587
11730
  }
@@ -12008,6 +12151,7 @@ var Glitch = /** @class */ (function () {
12008
12151
  PlayTests: PlayTests,
12009
12152
  Media: Media,
12010
12153
  Scheduler: Scheduler,
12154
+ Funnel: Funnel,
12011
12155
  };
12012
12156
  Glitch.util = {
12013
12157
  Requests: Requests,