glitch-javascript-sdk 1.9.5 → 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
@@ -3609,6 +3609,22 @@ declare class Titles {
3609
3609
  * @returns AxiosPromise
3610
3610
  */
3611
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>>;
3612
3628
  }
3613
3629
 
3614
3630
  declare class Campaigns {
@@ -5492,6 +5508,46 @@ declare class WebsiteAnalytics {
5492
5508
  static utmPerformance<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
5493
5509
  }
5494
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
+
5495
5551
  interface Route {
5496
5552
  url: string;
5497
5553
  method: string;
@@ -5834,6 +5890,8 @@ declare class Glitch {
5834
5890
  SocialStats: typeof SocialStats;
5835
5891
  WebsiteAnalytics: typeof WebsiteAnalytics;
5836
5892
  Fingerprinting: typeof Fingerprinting;
5893
+ ShortLinks: typeof ShortLinks;
5894
+ AIUsage: typeof AIUsage;
5837
5895
  };
5838
5896
  static util: {
5839
5897
  Requests: typeof Requests;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "1.9.5",
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;
@@ -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;
@@ -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
  }