glitch-javascript-sdk 1.9.4 → 1.9.6

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,7 @@
1
+ import Route from "./interface";
2
+ declare class AIUsageRoute {
3
+ static routes: {
4
+ [key: string]: Route;
5
+ };
6
+ }
7
+ export default AIUsageRoute;
@@ -0,0 +1,7 @@
1
+ import Route from "./interface";
2
+ declare class ShortLinksRoute {
3
+ static routes: {
4
+ [key: string]: Route;
5
+ };
6
+ }
7
+ export default ShortLinksRoute;
package/dist/index.d.ts CHANGED
@@ -1016,6 +1016,49 @@ declare class Ads {
1016
1016
  * @returns Fully-hydrated AdCampaign resource
1017
1017
  */
1018
1018
  static syncSchedulerCampaigns<T>(scheduler_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
1019
+ /**
1020
+ * Get campaign performance summary.
1021
+ */
1022
+ static getPerformanceSummary<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
1023
+ /**
1024
+ * Get spend and delivery metrics over time.
1025
+ */
1026
+ static getSpendDeliveryReport<T>(params: {
1027
+ start_date: string;
1028
+ end_date: string;
1029
+ group_by?: 'day' | 'week' | 'month';
1030
+ community_id?: string;
1031
+ platform?: string;
1032
+ }): AxiosPromise<Response<T>>;
1033
+ /**
1034
+ * Compare performance across platforms.
1035
+ */
1036
+ static getPlatformComparisonReport<T>(params?: {
1037
+ start_date?: string;
1038
+ end_date?: string;
1039
+ community_id?: string;
1040
+ }): AxiosPromise<Response<T>>;
1041
+ /**
1042
+ * Get performance metrics for individual ad creatives.
1043
+ */
1044
+ static getCreativePerformanceReport<T>(params?: {
1045
+ community_id?: string;
1046
+ platform?: string;
1047
+ start_date?: string;
1048
+ end_date?: string;
1049
+ limit?: number;
1050
+ sort?: 'spend' | 'impressions' | 'clicks' | 'ctr' | 'cpm' | 'cpc';
1051
+ order?: 'asc' | 'desc';
1052
+ }): AxiosPromise<Response<T>>;
1053
+ /**
1054
+ * Get time-based performance metrics by hour and day of week.
1055
+ */
1056
+ static getTimePerformanceReport<T>(params: {
1057
+ start_date: string;
1058
+ end_date: string;
1059
+ community_id?: string;
1060
+ platform?: string;
1061
+ }): AxiosPromise<Response<T>>;
1019
1062
  }
1020
1063
 
1021
1064
  declare class Communities {
@@ -3566,6 +3609,22 @@ declare class Titles {
3566
3609
  * @returns AxiosPromise
3567
3610
  */
3568
3611
  static analyzeUtmAnalytics<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
3612
+ /**
3613
+ * List all chat sessions for a title.
3614
+ */
3615
+ static chatListSessions<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
3616
+ /**
3617
+ * Get a specific chat session and its messages.
3618
+ */
3619
+ static chatShowSession<T>(title_id: string, session_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
3620
+ /**
3621
+ * Search messages across all sessions of a title.
3622
+ */
3623
+ static chatListMessages<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
3624
+ /**
3625
+ * Update a specific chat message.
3626
+ */
3627
+ static chatUpdateMessage<T>(title_id: string, message_id: string, data: object): AxiosPromise<Response<T>>;
3569
3628
  }
3570
3629
 
3571
3630
  declare class Campaigns {
@@ -5449,6 +5508,46 @@ declare class WebsiteAnalytics {
5449
5508
  static utmPerformance<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
5450
5509
  }
5451
5510
 
5511
+ declare class ShortLinks {
5512
+ /**
5513
+ * List all short links with optional filters
5514
+ */
5515
+ static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
5516
+ /**
5517
+ * Create a new short link
5518
+ */
5519
+ static create<T>(data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5520
+ /**
5521
+ * Get a specific short link by ID
5522
+ */
5523
+ static view<T>(id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
5524
+ /**
5525
+ * Update a short link
5526
+ */
5527
+ static update<T>(id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5528
+ }
5529
+
5530
+ declare class AIUsage {
5531
+ /**
5532
+ * List all AI usage entries with optional filters (date range, service, model, etc.).
5533
+ *
5534
+ * @see https://api.glitch.fun/api/documentation#/AI%20Usage/getAIUsage
5535
+ *
5536
+ * @param params Query parameters for filtering and grouping
5537
+ * @returns AxiosPromise
5538
+ */
5539
+ static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
5540
+ /**
5541
+ * Get summarized AI usage statistics (token totals, cost, grouped by service/model).
5542
+ *
5543
+ * @see https://api.glitch.fun/api/documentation#/AI%20Usage/getAIUsageSummary
5544
+ *
5545
+ * @param params Query parameters for filtering by date range
5546
+ * @returns AxiosPromise
5547
+ */
5548
+ static summary<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
5549
+ }
5550
+
5452
5551
  interface Route {
5453
5552
  url: string;
5454
5553
  method: string;
@@ -5791,6 +5890,8 @@ declare class Glitch {
5791
5890
  SocialStats: typeof SocialStats;
5792
5891
  WebsiteAnalytics: typeof WebsiteAnalytics;
5793
5892
  Fingerprinting: typeof Fingerprinting;
5893
+ ShortLinks: typeof ShortLinks;
5894
+ AIUsage: typeof AIUsage;
5794
5895
  };
5795
5896
  static util: {
5796
5897
  Requests: typeof Requests;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "1.9.4",
3
+ "version": "1.9.6",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -0,0 +1,32 @@
1
+ import AIUsageRoute from "../routes/AIUsageRoute";
2
+ import Requests from "../util/Requests";
3
+ import Response from "../util/Response";
4
+ import { AxiosPromise } from "axios";
5
+
6
+ class AIUsage {
7
+ /**
8
+ * List all AI usage entries with optional filters (date range, service, model, etc.).
9
+ *
10
+ * @see https://api.glitch.fun/api/documentation#/AI%20Usage/getAIUsage
11
+ *
12
+ * @param params Query parameters for filtering and grouping
13
+ * @returns AxiosPromise
14
+ */
15
+ public static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
16
+ return Requests.processRoute(AIUsageRoute.routes.listUsage, undefined, undefined, params);
17
+ }
18
+
19
+ /**
20
+ * Get summarized AI usage statistics (token totals, cost, grouped by service/model).
21
+ *
22
+ * @see https://api.glitch.fun/api/documentation#/AI%20Usage/getAIUsageSummary
23
+ *
24
+ * @param params Query parameters for filtering by date range
25
+ * @returns AxiosPromise
26
+ */
27
+ public static summary<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
28
+ return Requests.processRoute(AIUsageRoute.routes.summaryUsage, undefined, undefined, params);
29
+ }
30
+ }
31
+
32
+ export default AIUsage;
package/src/api/Ads.ts CHANGED
@@ -1028,6 +1028,69 @@ class Ads {
1028
1028
  );
1029
1029
  }
1030
1030
 
1031
+ // ----------------------------------------------------------------------
1032
+ // AD REPORTS
1033
+ // ----------------------------------------------------------------------
1034
+
1035
+ /**
1036
+ * Get campaign performance summary.
1037
+ */
1038
+ public static getPerformanceSummary<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
1039
+ return Requests.processRoute(AdsRoute.routes.getPerformanceSummary, undefined, undefined, params);
1040
+ }
1041
+
1042
+ /**
1043
+ * Get spend and delivery metrics over time.
1044
+ */
1045
+ public static getSpendDeliveryReport<T>(params: {
1046
+ start_date: string;
1047
+ end_date: string;
1048
+ group_by?: 'day' | 'week' | 'month';
1049
+ community_id?: string;
1050
+ platform?: string;
1051
+ }): AxiosPromise<Response<T>> {
1052
+ return Requests.processRoute(AdsRoute.routes.getSpendDeliveryReport, undefined, undefined, params);
1053
+ }
1054
+
1055
+ /**
1056
+ * Compare performance across platforms.
1057
+ */
1058
+ public static getPlatformComparisonReport<T>(params?: {
1059
+ start_date?: string;
1060
+ end_date?: string;
1061
+ community_id?: string;
1062
+ }): AxiosPromise<Response<T>> {
1063
+ return Requests.processRoute(AdsRoute.routes.getPlatformComparisonReport, undefined, undefined, params);
1064
+ }
1065
+
1066
+ /**
1067
+ * Get performance metrics for individual ad creatives.
1068
+ */
1069
+ public static getCreativePerformanceReport<T>(params?: {
1070
+ community_id?: string;
1071
+ platform?: string;
1072
+ start_date?: string;
1073
+ end_date?: string;
1074
+ limit?: number;
1075
+ sort?: 'spend' | 'impressions' | 'clicks' | 'ctr' | 'cpm' | 'cpc';
1076
+ order?: 'asc' | 'desc';
1077
+ }): AxiosPromise<Response<T>> {
1078
+ return Requests.processRoute(AdsRoute.routes.getCreativePerformanceReport, undefined, undefined, params);
1079
+ }
1080
+
1081
+ /**
1082
+ * Get time-based performance metrics by hour and day of week.
1083
+ */
1084
+ public static getTimePerformanceReport<T>(params: {
1085
+ start_date: string;
1086
+ end_date: string;
1087
+ community_id?: string;
1088
+ platform?: string;
1089
+ }): AxiosPromise<Response<T>> {
1090
+ return Requests.processRoute(AdsRoute.routes.getTimePerformanceReport, undefined, undefined, params);
1091
+ }
1092
+
1093
+
1031
1094
 
1032
1095
  }
1033
1096
 
@@ -0,0 +1,41 @@
1
+ import ShortLinksRoute from "../routes/ShortLinksRoute";
2
+ import Requests from "../util/Requests";
3
+ import Response from "../util/Response";
4
+ import { AxiosPromise } from "axios";
5
+
6
+ class ShortLinks {
7
+ /**
8
+ * List all short links with optional filters
9
+ */
10
+ public static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
11
+ return Requests.processRoute(ShortLinksRoute.routes.listShortLinks, undefined, undefined, params);
12
+ }
13
+
14
+ /**
15
+ * Create a new short link
16
+ */
17
+ public static create<T>(data: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
18
+ return Requests.processRoute(ShortLinksRoute.routes.createShortLink, data, {}, params);
19
+ }
20
+
21
+ /**
22
+ * Get a specific short link by ID
23
+ */
24
+ public static view<T>(id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
25
+ return Requests.processRoute(ShortLinksRoute.routes.viewShortLink, {}, { id }, params);
26
+ }
27
+
28
+ /**
29
+ * Update a short link
30
+ */
31
+ public static update<T>(id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
32
+ return Requests.processRoute(ShortLinksRoute.routes.updateShortLink, data, { id }, params);
33
+ }
34
+
35
+ // Uncomment when delete is supported
36
+ // public static delete<T>(id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
37
+ // return Requests.processRoute(ShortLinksRoute.routes.deleteShortLink, {}, { id }, params);
38
+ // }
39
+ }
40
+
41
+ export default ShortLinks;
package/src/api/Titles.ts CHANGED
@@ -409,15 +409,15 @@ class Titles {
409
409
  );
410
410
  }
411
411
 
412
- /**
413
- * Upload a CSV/Excel file containing daily UTM analytics for a specific title.
414
- *
415
- * @param title_id The UUID of the title
416
- * @param file The CSV or Excel file
417
- * @param data Optional form fields (if needed)
418
- * @param params Optional query parameters
419
- * @returns AxiosPromise
420
- */
412
+ /**
413
+ * Upload a CSV/Excel file containing daily UTM analytics for a specific title.
414
+ *
415
+ * @param title_id The UUID of the title
416
+ * @param file The CSV or Excel file
417
+ * @param data Optional form fields (if needed)
418
+ * @param params Optional query parameters
419
+ * @returns AxiosPromise
420
+ */
421
421
  public static importUtmAnalytics<T>(
422
422
  title_id: string,
423
423
  file: File | Blob,
@@ -491,6 +491,68 @@ class Titles {
491
491
  );
492
492
  }
493
493
 
494
+ /**
495
+ * List all chat sessions for a title.
496
+ */
497
+ public static chatListSessions<T>(
498
+ title_id: string,
499
+ params?: Record<string, any>
500
+ ): AxiosPromise<Response<T>> {
501
+ return Requests.processRoute(
502
+ TitlesRoute.routes.chatListSessions,
503
+ {},
504
+ { title_id },
505
+ params
506
+ );
507
+ }
508
+
509
+ /**
510
+ * Get a specific chat session and its messages.
511
+ */
512
+ public static chatShowSession<T>(
513
+ title_id: string,
514
+ session_id: string,
515
+ params?: Record<string, any>
516
+ ): AxiosPromise<Response<T>> {
517
+ return Requests.processRoute(
518
+ TitlesRoute.routes.chatShowSession,
519
+ {},
520
+ { title_id, session_id },
521
+ params
522
+ );
523
+ }
524
+
525
+ /**
526
+ * Search messages across all sessions of a title.
527
+ */
528
+ public static chatListMessages<T>(
529
+ title_id: string,
530
+ params?: Record<string, any>
531
+ ): AxiosPromise<Response<T>> {
532
+ return Requests.processRoute(
533
+ TitlesRoute.routes.chatListMessages,
534
+ {},
535
+ { title_id },
536
+ params
537
+ );
538
+ }
539
+
540
+ /**
541
+ * Update a specific chat message.
542
+ */
543
+ public static chatUpdateMessage<T>(
544
+ title_id: string,
545
+ message_id: string,
546
+ data: object
547
+ ): AxiosPromise<Response<T>> {
548
+ return Requests.processRoute(
549
+ TitlesRoute.routes.chatUpdateMessage,
550
+ data,
551
+ { title_id, message_id }
552
+ );
553
+ }
554
+
555
+
494
556
 
495
557
  }
496
558
 
package/src/api/index.ts CHANGED
@@ -33,6 +33,8 @@ import Funnel from "./Funnel";
33
33
  import SocialStats from "./SocialStats";
34
34
  import Hashtags from "./Hashtags";
35
35
  import WebsiteAnalytics from "./WebsiteAnalytics";
36
+ import ShortLinks from "./ShortLinks";
37
+ import AIUsage from "./AIUsage";
36
38
 
37
39
  export {Ads};
38
40
  export {Auth};
@@ -68,4 +70,6 @@ export {Funnel};
68
70
  export {SocialStats};
69
71
  export {Hashtags};
70
72
  export {WebsiteAnalytics};
71
- export {Fingerprinting};
73
+ export {Fingerprinting};
74
+ export {ShortLinks};
75
+ export {AIUsage};
package/src/index.ts CHANGED
@@ -37,6 +37,8 @@ import {SocialStats} from "./api";
37
37
  import {Hashtags} from "./api";
38
38
  import {WebsiteAnalytics} from "./api";
39
39
  import {Fingerprinting} from "./api";
40
+ import {ShortLinks} from "./api";
41
+ import {AIUsage} from "./api";
40
42
 
41
43
  import Requests from "./util/Requests";
42
44
  import Parser from "./util/Parser";
@@ -102,7 +104,9 @@ class Glitch {
102
104
  Funnel: Funnel,
103
105
  SocialStats : SocialStats,
104
106
  WebsiteAnalytics: WebsiteAnalytics,
105
- Fingerprinting : Fingerprinting
107
+ Fingerprinting : Fingerprinting,
108
+ ShortLinks : ShortLinks,
109
+ AIUsage : AIUsage
106
110
  }
107
111
 
108
112
  public static util = {
@@ -0,0 +1,11 @@
1
+ import Route from "./interface";
2
+ import HTTP_METHODS from "../constants/HttpMethods";
3
+
4
+ class AIUsageRoute {
5
+ public static routes: { [key: string]: Route } = {
6
+ listUsage: { url: '/billing/ai-usage', method: HTTP_METHODS.GET },
7
+ summaryUsage: { url: '/billing/ai-usage/summary', method: HTTP_METHODS.GET }
8
+ };
9
+ }
10
+
11
+ export default AIUsageRoute;
@@ -373,6 +373,34 @@ class AdsRoute {
373
373
  url: "/ads/campaigns/scheduler/{scheduler_id}/syncAll",
374
374
  method: HTTP_METHODS.POST,
375
375
  },
376
+
377
+ // ----------------------------------------------------------------
378
+ // AD REPORTS
379
+ // ----------------------------------------------------------------
380
+ getPerformanceSummary: {
381
+ url: "/ads/reports/summary",
382
+ method: HTTP_METHODS.GET,
383
+ },
384
+
385
+ getSpendDeliveryReport: {
386
+ url: "/ads/reports/spend-delivery",
387
+ method: HTTP_METHODS.GET,
388
+ },
389
+
390
+ getPlatformComparisonReport: {
391
+ url: "/ads/reports/platform-comparison",
392
+ method: HTTP_METHODS.GET,
393
+ },
394
+
395
+ getCreativePerformanceReport: {
396
+ url: "/ads/reports/creative-performance",
397
+ method: HTTP_METHODS.GET,
398
+ },
399
+
400
+ getTimePerformanceReport: {
401
+ url: "/ads/reports/time-performance",
402
+ method: HTTP_METHODS.GET,
403
+ },
376
404
 
377
405
  };
378
406
  }
@@ -0,0 +1,15 @@
1
+ import Route from "./interface";
2
+ import HTTP_METHODS from "../constants/HttpMethods";
3
+
4
+ class ShortLinksRoute {
5
+ public static routes: { [key: string]: Route } = {
6
+ listShortLinks: { url: '/shortlinks', method: HTTP_METHODS.GET },
7
+ createShortLink: { url: '/shortlinks', method: HTTP_METHODS.POST },
8
+ viewShortLink: { url: '/shortlinks/{id}', method: HTTP_METHODS.GET },
9
+ updateShortLink: { url: '/shortlinks/{id}', method: HTTP_METHODS.PUT },
10
+ // Delete can be added if supported
11
+ // deleteShortLink: { url: '/shortlinks/{id}', method: HTTP_METHODS.DELETE }
12
+ };
13
+ }
14
+
15
+ export default ShortLinksRoute;
@@ -76,6 +76,23 @@ class TitlesRoute {
76
76
  method: HTTP_METHODS.GET,
77
77
  },
78
78
 
79
+ chatListSessions: {
80
+ url: '/titles/{title_id}/chat/sessions',
81
+ method: HTTP_METHODS.GET
82
+ },
83
+ chatShowSession: {
84
+ url: '/titles/{title_id}/chat/sessions/{session_id}',
85
+ method: HTTP_METHODS.GET
86
+ },
87
+ chatListMessages: {
88
+ url: '/titles/{title_id}/chat/messages',
89
+ method: HTTP_METHODS.GET
90
+ },
91
+ chatUpdateMessage: {
92
+ url: '/titles/{title_id}/chat/messages/{message_id}',
93
+ method: HTTP_METHODS.PUT
94
+ },
95
+
79
96
  };
80
97
 
81
98
  }