glitch-javascript-sdk 2.7.7 → 2.7.8

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/index.d.ts CHANGED
@@ -5303,6 +5303,33 @@ declare class Influencers {
5303
5303
  static workbook<T>(data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5304
5304
  }
5305
5305
 
5306
+ /**
5307
+ * Interface for the Release Stats response to help developers
5308
+ * understand the data structure returned by the optimizer.
5309
+ */
5310
+ interface ReleaseStatEntry {
5311
+ date: string;
5312
+ count: number;
5313
+ intensity: 'low' | 'medium' | 'high' | 'extreme';
5314
+ is_danger_zone: boolean;
5315
+ recommendation: string;
5316
+ events: Array<{
5317
+ name: string;
5318
+ type: 'nextfest' | 'sale';
5319
+ start: string;
5320
+ end: string;
5321
+ }>;
5322
+ }
5323
+ interface ReleaseStatsResponse {
5324
+ data: ReleaseStatEntry[];
5325
+ meta: {
5326
+ user_status: 'authenticated' | 'guest';
5327
+ lookahead_days: number;
5328
+ start_date: string;
5329
+ end_date: string;
5330
+ global_events: any[];
5331
+ };
5332
+ }
5306
5333
  declare class Games {
5307
5334
  /**
5308
5335
  * Get a list of Games available on he platform.
@@ -5350,6 +5377,29 @@ declare class Games {
5350
5377
  * @returns promise
5351
5378
  */
5352
5379
  static createGameScheduler<T>(game_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5380
+ /**
5381
+ * Get release competition statistics and Steam danger zones.
5382
+ *
5383
+ * This tool analyzes the 'ExternalGames' database to show how many other games
5384
+ * are releasing around a specific date. It also overlays hard-coded Steam events
5385
+ * like NextFest and Seasonal Sales.
5386
+ *
5387
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/getReleaseStats
5388
+ *
5389
+ * @param params Filtering options:
5390
+ * - precision: 'day' | 'month' | 'year' (Default: 'day'). Use 'month' for long-term planning.
5391
+ * - start_date: 'YYYY-MM-DD'. The date to begin the analysis from.
5392
+ *
5393
+ * @returns AxiosPromise<Response<ReleaseStatsResponse>>
5394
+ *
5395
+ * @example
5396
+ * Games.getReleaseStats({ precision: 'day', start_date: '2025-06-01' })
5397
+ * .then(res => console.log(res.data.data));
5398
+ */
5399
+ static getReleaseStats<T = ReleaseStatsResponse>(params?: {
5400
+ precision?: 'day' | 'month' | 'year';
5401
+ start_date?: string;
5402
+ }): AxiosPromise<Response<T>>;
5353
5403
  }
5354
5404
 
5355
5405
  declare class Publications {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "glitch-javascript-sdk",
3
- "version": "2.7.7",
3
+ "version": "2.7.8",
4
4
  "description": "Javascript SDK for Glitch",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/api/Games.ts CHANGED
@@ -3,6 +3,35 @@ import Requests from "../util/Requests";
3
3
  import Response from "../util/Response";
4
4
  import { AxiosPromise } from "axios";
5
5
 
6
+ /**
7
+ * Interface for the Release Stats response to help developers
8
+ * understand the data structure returned by the optimizer.
9
+ */
10
+ export interface ReleaseStatEntry {
11
+ date: string;
12
+ count: number;
13
+ intensity: 'low' | 'medium' | 'high' | 'extreme';
14
+ is_danger_zone: boolean;
15
+ recommendation: string;
16
+ events: Array<{
17
+ name: string;
18
+ type: 'nextfest' | 'sale';
19
+ start: string;
20
+ end: string;
21
+ }>;
22
+ }
23
+
24
+ export interface ReleaseStatsResponse {
25
+ data: ReleaseStatEntry[];
26
+ meta: {
27
+ user_status: 'authenticated' | 'guest';
28
+ lookahead_days: number;
29
+ start_date: string;
30
+ end_date: string;
31
+ global_events: any[];
32
+ };
33
+ }
34
+
6
35
  class Games {
7
36
 
8
37
  /**
@@ -12,7 +41,7 @@ class Games {
12
41
  *
13
42
  * @returns promise
14
43
  */
15
- public static listGames<T>(params?: Record<string, any>) : AxiosPromise<Response<T>> {
44
+ public static listGames<T>(params?: Record<string, any>): AxiosPromise<Response<T>> {
16
45
  return Requests.processRoute(GamesRoutes.routes.listGames, undefined, undefined, params);
17
46
  }
18
47
 
@@ -23,8 +52,8 @@ class Games {
23
52
  *
24
53
  * @returns promise
25
54
  */
26
- public static viewGame<T>(game_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
27
- return Requests.processRoute(GamesRoutes.routes.viewGame, undefined, {game_id : game_id}, params);
55
+ public static viewGame<T>(game_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
56
+ return Requests.processRoute(GamesRoutes.routes.viewGame, undefined, { game_id: game_id }, params);
28
57
  }
29
58
 
30
59
  /**
@@ -34,8 +63,8 @@ class Games {
34
63
  *
35
64
  * @returns promise
36
65
  */
37
- public static createCampaignData<T>(game_id : string, data?: object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
38
- return Requests.processRoute(GamesRoutes.routes.createCampaignData, data, {game_id : game_id}, params);
66
+ public static createCampaignData<T>(game_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
67
+ return Requests.processRoute(GamesRoutes.routes.createCampaignData, data, { game_id: game_id }, params);
39
68
  }
40
69
 
41
70
  /**
@@ -43,8 +72,8 @@ class Games {
43
72
  *
44
73
  * @returns promise
45
74
  */
46
- public static createCampaignWithTitle<T>(game_id : string, data?: object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
47
- return Requests.processRoute(GamesRoutes.routes.createCampaignWithTitle, data, {game_id : game_id}, params);
75
+ public static createCampaignWithTitle<T>(game_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
76
+ return Requests.processRoute(GamesRoutes.routes.createCampaignWithTitle, data, { game_id: game_id }, params);
48
77
  }
49
78
 
50
79
  /**
@@ -54,8 +83,8 @@ class Games {
54
83
  *
55
84
  * @returns promise
56
85
  */
57
- public static createGameTitle<T>(game_id : string, data?: object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
58
- return Requests.processRoute(GamesRoutes.routes.createGameTitle, data, {game_id : game_id}, params);
86
+ public static createGameTitle<T>(game_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
87
+ return Requests.processRoute(GamesRoutes.routes.createGameTitle, data, { game_id: game_id }, params);
59
88
  }
60
89
 
61
90
  /**
@@ -65,8 +94,45 @@ class Games {
65
94
  *
66
95
  * @returns promise
67
96
  */
68
- public static createGameScheduler<T>(game_id : string, data?: object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
69
- return Requests.processRoute(GamesRoutes.routes.createGameScheduler, data, {game_id : game_id}, params);
97
+ public static createGameScheduler<T>(game_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>> {
98
+ return Requests.processRoute(GamesRoutes.routes.createGameScheduler, data, { game_id: game_id }, params);
99
+ }
100
+
101
+ /**
102
+ * Get release competition statistics and Steam danger zones.
103
+ *
104
+ * This tool analyzes the 'ExternalGames' database to show how many other games
105
+ * are releasing around a specific date. It also overlays hard-coded Steam events
106
+ * like NextFest and Seasonal Sales.
107
+ *
108
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/getReleaseStats
109
+ *
110
+ * @param params Filtering options:
111
+ * - precision: 'day' | 'month' | 'year' (Default: 'day'). Use 'month' for long-term planning.
112
+ * - start_date: 'YYYY-MM-DD'. The date to begin the analysis from.
113
+ *
114
+ * @returns AxiosPromise<Response<ReleaseStatsResponse>>
115
+ *
116
+ * @example
117
+ * Games.getReleaseStats({ precision: 'day', start_date: '2025-06-01' })
118
+ * .then(res => console.log(res.data.data));
119
+ */
120
+ public static getReleaseStats<T = ReleaseStatsResponse>(params?: {
121
+ precision?: 'day' | 'month' | 'year',
122
+ start_date?: string
123
+ }): AxiosPromise<Response<T>> {
124
+
125
+ // Defensive check: ensure precision is valid if provided
126
+ if (params?.precision && !['day', 'month', 'year'].includes(params.precision)) {
127
+ console.warn(`Invalid precision '${params.precision}' passed to getReleaseStats. Defaulting to 'day'.`);
128
+ }
129
+
130
+ return Requests.processRoute(
131
+ GamesRoutes.routes.releaseStats,
132
+ undefined,
133
+ undefined,
134
+ params
135
+ );
70
136
  }
71
137
 
72
138
  }
@@ -10,7 +10,7 @@ class GamesRoutes {
10
10
  createCampaignWithTitle: { url: '/games/{game_id}/generateCampaignWithTitle', method: HTTP_METHODS.POST },
11
11
  createGameTitle: { url: '/games/{game_id}/generateTitle', method: HTTP_METHODS.POST },
12
12
  createGameScheduler: { url: '/games/{game_id}/generateScheduler', method: HTTP_METHODS.POST },
13
-
13
+ releaseStats: { url: '/games/release-stats', method: HTTP_METHODS.GET },
14
14
  };
15
15
 
16
16
  }