glitch-javascript-sdk 2.7.7 → 2.8.0

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
@@ -4263,6 +4263,32 @@ declare class Titles {
4263
4263
  * Delete a saved behavioral funnel definition.
4264
4264
  */
4265
4265
  static deleteBehavioralFunnel<T>(title_id: string, funnel_id: string): AxiosPromise<Response<T>>;
4266
+ /**
4267
+ * Generates a presigned S3 URL for uploading a game build ZIP.
4268
+ */
4269
+ static getDeploymentUploadUrl<T>(title_id: string): AxiosPromise<Response<T>>;
4270
+ /**
4271
+ * Confirms the upload and starts the automated deployment/extraction process.
4272
+ * @param data { file_path: string, version_string: string, entry_point?: string }
4273
+ */
4274
+ static confirmDeployment<T>(title_id: string, data: object): AxiosPromise<Response<T>>;
4275
+ /**
4276
+ * Initializes a play session. Handles age-gating and license verification.
4277
+ * Returns the CDN URL for WASM/iFrame or Signaling URL for Pixel Streaming.
4278
+ */
4279
+ static getPlaySession<T>(title_id: string): AxiosPromise<Response<T>>;
4280
+ /**
4281
+ * List all developer payouts for a title.
4282
+ */
4283
+ static listDeveloperPayouts<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
4284
+ /**
4285
+ * View a specific payout record.
4286
+ */
4287
+ static viewDeveloperPayout<T>(title_id: string, payout_id: string): AxiosPromise<Response<T>>;
4288
+ /**
4289
+ * Get the total earnings and playtime summary for a title.
4290
+ */
4291
+ static getDeveloperPayoutSummary<T>(title_id: string): AxiosPromise<Response<T>>;
4266
4292
  }
4267
4293
 
4268
4294
  declare class Campaigns {
@@ -5117,6 +5143,12 @@ declare class Subscriptions {
5117
5143
  * @param data { priceId, paymentMethod, custom_name, limits: { posts, enrichments, invites, ads }, metered_prices: [] }
5118
5144
  */
5119
5145
  static createCustomCommunitySubscription<T>(community_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5146
+ /**
5147
+ * Purchase a permanent license or rent a game title.
5148
+ * If a rental was active in the last 7 days, the fee is automatically deducted from the premium price.
5149
+ * @param data { purchase_type: 'premium' | 'rental', payment_method_id: string }
5150
+ */
5151
+ static purchaseLicense<T>(title_id: string, data: object): AxiosPromise<Response<T>>;
5120
5152
  }
5121
5153
 
5122
5154
  declare class Messages {
@@ -5303,6 +5335,33 @@ declare class Influencers {
5303
5335
  static workbook<T>(data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5304
5336
  }
5305
5337
 
5338
+ /**
5339
+ * Interface for the Release Stats response to help developers
5340
+ * understand the data structure returned by the optimizer.
5341
+ */
5342
+ interface ReleaseStatEntry {
5343
+ date: string;
5344
+ count: number;
5345
+ intensity: 'low' | 'medium' | 'high' | 'extreme';
5346
+ is_danger_zone: boolean;
5347
+ recommendation: string;
5348
+ events: Array<{
5349
+ name: string;
5350
+ type: 'nextfest' | 'sale';
5351
+ start: string;
5352
+ end: string;
5353
+ }>;
5354
+ }
5355
+ interface ReleaseStatsResponse {
5356
+ data: ReleaseStatEntry[];
5357
+ meta: {
5358
+ user_status: 'authenticated' | 'guest';
5359
+ lookahead_days: number;
5360
+ start_date: string;
5361
+ end_date: string;
5362
+ global_events: any[];
5363
+ };
5364
+ }
5306
5365
  declare class Games {
5307
5366
  /**
5308
5367
  * Get a list of Games available on he platform.
@@ -5350,6 +5409,29 @@ declare class Games {
5350
5409
  * @returns promise
5351
5410
  */
5352
5411
  static createGameScheduler<T>(game_id: string, data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
5412
+ /**
5413
+ * Get release competition statistics and Steam danger zones.
5414
+ *
5415
+ * This tool analyzes the 'ExternalGames' database to show how many other games
5416
+ * are releasing around a specific date. It also overlays hard-coded Steam events
5417
+ * like NextFest and Seasonal Sales.
5418
+ *
5419
+ * @see https://api.glitch.fun/api/documentation#/ExternalGames/getReleaseStats
5420
+ *
5421
+ * @param params Filtering options:
5422
+ * - precision: 'day' | 'month' | 'year' (Default: 'day'). Use 'month' for long-term planning.
5423
+ * - start_date: 'YYYY-MM-DD'. The date to begin the analysis from.
5424
+ *
5425
+ * @returns AxiosPromise<Response<ReleaseStatsResponse>>
5426
+ *
5427
+ * @example
5428
+ * Games.getReleaseStats({ precision: 'day', start_date: '2025-06-01' })
5429
+ * .then(res => console.log(res.data.data));
5430
+ */
5431
+ static getReleaseStats<T = ReleaseStatsResponse>(params?: {
5432
+ precision?: 'day' | 'month' | 'year';
5433
+ start_date?: string;
5434
+ }): AxiosPromise<Response<T>>;
5353
5435
  }
5354
5436
 
5355
5437
  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.8.0",
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
  }
@@ -115,6 +115,15 @@ class Subscriptions {
115
115
  return Requests.processRoute(SubscriptionsRoute.routes.createCustomCommunitySubscription, data, { community_id }, params);
116
116
  }
117
117
 
118
+ /**
119
+ * Purchase a permanent license or rent a game title.
120
+ * If a rental was active in the last 7 days, the fee is automatically deducted from the premium price.
121
+ * @param data { purchase_type: 'premium' | 'rental', payment_method_id: string }
122
+ */
123
+ public static purchaseLicense<T>(title_id: string, data: object): AxiosPromise<Response<T>> {
124
+ return Requests.processRoute(SubscriptionsRoute.routes.purchaseLicense, data, { title_id });
125
+ }
126
+
118
127
 
119
128
  }
120
129
 
package/src/api/Titles.ts CHANGED
@@ -932,6 +932,50 @@ class Titles {
932
932
  public static deleteBehavioralFunnel<T>(title_id: string, funnel_id: string): AxiosPromise<Response<T>> {
933
933
  return Requests.processRoute(TitlesRoute.routes.deleteBehavioralFunnel, {}, { title_id, funnel_id });
934
934
  }
935
+
936
+ /**
937
+ * Generates a presigned S3 URL for uploading a game build ZIP.
938
+ */
939
+ public static getDeploymentUploadUrl<T>(title_id: string): AxiosPromise<Response<T>> {
940
+ return Requests.processRoute(TitlesRoute.routes.getDeploymentUploadUrl, {}, { title_id });
941
+ }
942
+
943
+ /**
944
+ * Confirms the upload and starts the automated deployment/extraction process.
945
+ * @param data { file_path: string, version_string: string, entry_point?: string }
946
+ */
947
+ public static confirmDeployment<T>(title_id: string, data: object): AxiosPromise<Response<T>> {
948
+ return Requests.processRoute(TitlesRoute.routes.confirmDeployment, data, { title_id });
949
+ }
950
+
951
+ /**
952
+ * Initializes a play session. Handles age-gating and license verification.
953
+ * Returns the CDN URL for WASM/iFrame or Signaling URL for Pixel Streaming.
954
+ */
955
+ public static getPlaySession<T>(title_id: string): AxiosPromise<Response<T>> {
956
+ return Requests.processRoute(TitlesRoute.routes.getPlaySession, {}, { title_id });
957
+ }
958
+
959
+ /**
960
+ * List all developer payouts for a title.
961
+ */
962
+ public static listDeveloperPayouts<T>(title_id: string, params?: Record<string, any>): AxiosPromise<Response<T>> {
963
+ return Requests.processRoute(TitlesRoute.routes.listDeveloperPayouts, undefined, { title_id }, params);
964
+ }
965
+
966
+ /**
967
+ * View a specific payout record.
968
+ */
969
+ public static viewDeveloperPayout<T>(title_id: string, payout_id: string): AxiosPromise<Response<T>> {
970
+ return Requests.processRoute(TitlesRoute.routes.viewDeveloperPayout, {}, { title_id, payout_id });
971
+ }
972
+
973
+ /**
974
+ * Get the total earnings and playtime summary for a title.
975
+ */
976
+ public static getDeveloperPayoutSummary<T>(title_id: string): AxiosPromise<Response<T>> {
977
+ return Requests.processRoute(TitlesRoute.routes.developerPayoutSummary, {}, { title_id });
978
+ }
935
979
  }
936
980
 
937
981
  export default Titles;
@@ -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
  }
@@ -19,6 +19,9 @@ class SubscriptionsRoute {
19
19
  url: '/subscriptions/communities/custom/{community_id}',
20
20
  method: HTTP_METHODS.POST
21
21
  },
22
+
23
+ purchaseLicense: { url: '/titles/{title_id}/purchase', method: HTTP_METHODS.POST },
24
+
22
25
  };
23
26
 
24
27
  }
@@ -180,6 +180,16 @@ class TitlesRoute {
180
180
  behavioralFunnelReport: { url: '/titles/{title_id}/behavioral-funnels/{funnel_id}/report', method: HTTP_METHODS.GET },
181
181
  deleteBehavioralFunnel: { url: '/titles/{title_id}/behavioral-funnels/{funnel_id}', method: HTTP_METHODS.DELETE },
182
182
 
183
+ // Aegis Deployment
184
+ getDeploymentUploadUrl: { url: '/titles/{title_id}/deployments/presigned-url', method: HTTP_METHODS.POST },
185
+ confirmDeployment: { url: '/titles/{title_id}/deployments/confirm', method: HTTP_METHODS.POST },
186
+ getPlaySession: { url: '/titles/{title_id}/play', method: HTTP_METHODS.GET },
187
+
188
+ // Aegis Payouts
189
+ listDeveloperPayouts: { url: '/titles/{title_id}/payouts', method: HTTP_METHODS.GET },
190
+ viewDeveloperPayout: { url: '/titles/{title_id}/payouts/{payout_id}', method: HTTP_METHODS.GET },
191
+ developerPayoutSummary: { url: '/titles/{title_id}/payouts/summary', method: HTTP_METHODS.GET },
192
+
183
193
  };
184
194
 
185
195
  }