steamutils 1.5.36 → 1.5.37

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.
Files changed (2) hide show
  1. package/index.js +103 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -8020,6 +8020,56 @@ export default class SteamUser {
8020
8020
  } catch (e) {}
8021
8021
  }
8022
8022
 
8023
+ /**
8024
+ * Fetches information about one or more Steam apps by their app IDs using the Steam Community GetApps API.
8025
+ *
8026
+ * Each app object in the response may include fields such as:
8027
+ * - appid: {number} The Steam application ID
8028
+ * - name: {string} Name of the app
8029
+ * - icon: {string} App icon hash
8030
+ * - logo, logo_small: {string} App logo (if any)
8031
+ * - tool, demo, media: {boolean} App type flags
8032
+ * - community_visible_stats: {boolean} If the app has community stats visible
8033
+ * - friendly_name: {string} Optional, usually empty for event apps
8034
+ * - propagation: {string} Propagation mode
8035
+ * - has_adult_content: {boolean} If app contains adult content
8036
+ * - is_visible_in_steam_china: {boolean} Visibility on Steam China
8037
+ * - app_type: {number} App type code
8038
+ * - has_adult_content_sex: {boolean}
8039
+ * - has_adult_content_violence: {boolean}
8040
+ * - content_descriptorids: {Array<number>}
8041
+ *
8042
+ * @async
8043
+ * @static
8044
+ * @param {number|number[]} appIds - A single app ID or array of app IDs to request.
8045
+ * @returns {Promise<{
8046
+ * apps: Array<{
8047
+ * content_descriptorids: number[],
8048
+ * appid: number,
8049
+ * name: string,
8050
+ * icon: string,
8051
+ * logo: string,
8052
+ * logo_small: string,
8053
+ * tool: boolean,
8054
+ * demo: boolean,
8055
+ * media: boolean,
8056
+ * community_visible_stats: boolean,
8057
+ * friendly_name: string,
8058
+ * propagation: string,
8059
+ * has_adult_content: boolean,
8060
+ * is_visible_in_steam_china: boolean,
8061
+ * app_type: number,
8062
+ * has_adult_content_sex: boolean,
8063
+ * has_adult_content_violence: boolean
8064
+ * }>
8065
+ * }|ResponseError|undefined>} Returns an object containing an 'apps' array with the app data on success,
8066
+ * a ResponseError if the request fails, or undefined if no appIds are supplied.
8067
+ *
8068
+ * @example
8069
+ * const result = await SteamUser.cCommunityGetAppsRequest(3558910);
8070
+ * console.log(result);
8071
+ * // { apps: [ { appid: 3558910, name: '...', ... } ] }
8072
+ */
8023
8073
  static async cCommunityGetAppsRequest(appIds) {
8024
8074
  if (!appIds) {
8025
8075
  return;
@@ -8054,6 +8104,59 @@ export default class SteamUser {
8054
8104
  return response;
8055
8105
  }
8056
8106
 
8107
+ /**
8108
+ * @typedef {Object} EligibleEventApp
8109
+ * @property {number} appid The unique Steam app ID.
8110
+ * @property {number} has_items_anyone_can_purchase 1 if anyone can purchase items, 0 otherwise.
8111
+ * @property {number} event_app 1 if the app is considered an event app, 0 otherwise.
8112
+ * @property {string|null} hero_carousel_image The filename for the hero carousel image, or null if not present.
8113
+ * @property {null} owned Reserved, always null in current data.
8114
+ */
8115
+
8116
+ /**
8117
+ * Fetches the list of eligible event apps from the Steam Points Shop events store.
8118
+ * This function retrieves the event page's HTML, parses out the loyalty store data,
8119
+ * and returns all eligible apps that are marked as event apps.
8120
+ *
8121
+ * @returns {Promise<EligibleEventApp[]>} Array of eligible event app objects (empty array if an error occurs).
8122
+ */
8123
+ static async getEligibleEventApps() {
8124
+ let html;
8125
+ try {
8126
+ ({ data: html } = await axios.get("https://store.steampowered.com/points/shop/c/events"));
8127
+ } catch (e) {
8128
+ console.error("Failed to fetch Steam Points Shop events page:", e);
8129
+ return [];
8130
+ }
8131
+ if (!html) {
8132
+ console.error("No HTML received from the events page.");
8133
+ return [];
8134
+ }
8135
+
8136
+ const $ = cheerio.load(html);
8137
+ const loyaltyStr = $("#application_config").attr("data-loyaltystore");
8138
+ if (!loyaltyStr) {
8139
+ console.error("Loyalty store data not found in HTML.");
8140
+ return [];
8141
+ }
8142
+
8143
+ let loyaltyObj;
8144
+ try {
8145
+ loyaltyObj = JSON.parse(loyaltyStr);
8146
+ } catch (e) {
8147
+ console.error("Failed to parse loyalty store JSON:", e);
8148
+ return [];
8149
+ }
8150
+
8151
+ const apps = loyaltyObj?.eligible_apps?.apps;
8152
+ if (!Array.isArray(apps)) {
8153
+ console.error("No valid eligible_apps array found in loyalty store object.");
8154
+ return [];
8155
+ }
8156
+
8157
+ return apps.filter((app) => app.event_app);
8158
+ }
8159
+
8057
8160
  static async decodeQRImage(imageURL) {
8058
8161
  let response = null;
8059
8162
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "steamutils",
3
- "version": "1.5.36",
3
+ "version": "1.5.37",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "alpha-common-utils": "^1.0.6",