UNPKG

openblox

Version:

Roblox API Wrapper For Both Classic And OpenCloud APIs.

232 lines (231 loc) 9.77 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var games_exports = {}; __export(games_exports, { authedUserCanUserBeInvitedToVipServer: () => authedUserCanUserBeInvitedToVipServer, authedUserGamesPlayabilityStatuses: () => authedUserGamesPlayabilityStatuses, authedUserPrivateServersForPlace: () => authedUserPrivateServersForPlace, authedUserSetUniverseUpvote: () => authedUserSetUniverseUpvote, authedUserSpotlightedGames: () => authedUserSpotlightedGames, authedUserUniverseIsFavorited: () => authedUserUniverseIsFavorited, authedUserUniverseSetFavorite: () => authedUserUniverseSetFavorite, authedUserUniverseVoteStatus: () => authedUserUniverseVoteStatus, groupGames: () => groupGames, placeServerList: () => placeServerList, placesInfo: () => placesInfo, recommendationsFromUniverse: () => recommendationsFromUniverse, universeFavoritesCount: () => universeFavoritesCount, universeGamePasses: () => universeGamePasses, universeMedia: () => universeMedia, universesInfo: () => universesInfo, universesProductInfo: () => universesProductInfo, universesVoteStatus: () => universesVoteStatus, updateVipServer: () => updateVipServer, updateVipServerVoiceSettings: () => updateVipServerVoiceSettings, userGames: () => userGames, vipServerInfo: () => vipServerInfo, vipServersAllowedForUniverse: () => vipServersAllowedForUniverse }); module.exports = __toCommonJS(games_exports); var import_apiGroup = require("../../apiGroup"); var import_utils = require("../../../utils/utils"); const { createApiMethod } = (0, import_apiGroup.createApiGroup)({ name: "ClassicGames", baseUrl: "https://games.roblox.com" }); const universesInfo = createApiMethod(async ({ universeIds }) => ({ method: "GET", path: `/v1/games`, searchParams: { universeIds }, name: "universesInfo", formatRawDataFn: ({ data }) => (0, import_utils.createObjectMapByKeyWithMiddleware)(data, "id", ({ id, ...gameInfo }) => { gameInfo.created = new Date(gameInfo.created); gameInfo.updated = new Date(gameInfo.updated); return gameInfo; }) })); const universesProductInfo = createApiMethod(async ({ universeIds }) => ({ method: "GET", path: `/v1/games/games-product-info`, searchParams: { universeIds }, name: `universesProductInfo`, formatRawDataFn: ({ data }) => (0, import_utils.createObjectMapByKeyWithMiddleware)(data, "universeId", ({ universeId, ...rest }) => rest) })); const authedUserSpotlightedGames = createApiMethod(async () => ({ method: "GET", path: `/v1/games/list-spotlight`, name: `authedUserSpotlightedGames`, formatRawDataFn: ({ data }) => data })); const placesInfo = createApiMethod(async ({ placeIds }) => ({ method: "GET", path: `/v1/games/multiget-place-details`, searchParams: { placeIds }, name: `placesInfo`, formatRawDataFn: (rawData) => (0, import_utils.createObjectMapByKeyWithMiddleware)(rawData, "placeId", ({ placeId, ...rest }) => rest) })); const authedUserGamesPlayabilityStatuses = createApiMethod(async ({ universeIds }) => ({ method: "GET", path: `/v1/games/multiget-playability-status`, searchParams: { universeIds }, name: `authedUserGamesPlayabilityStatuses`, formatRawDataFn: (rawData) => (0, import_utils.createObjectMapByKeyWithMiddleware)(rawData, "universeId", ({ universeId, ...rest }) => rest) })); const recommendationsFromUniverse = createApiMethod(async ({ universeId, truncatedResults, limit, cursor }) => ({ method: "GET", path: `/v1/games/recommendations/game/${universeId}`, searchParams: { IsTruncatedResultsEnabled: truncatedResults, MaxRows: limit, PaginationKey: cursor }, name: `recommendationsFromUniverse`, formatRawDataFn: ({ games }) => games, getCursorsFn: ({ nextPaginationKey }) => [null, nextPaginationKey] })); const authedUserPrivateServersForPlace = createApiMethod(async ({ placeId, limit, sortOrder, cursor }) => ({ method: "GET", path: `/v1/games/${placeId}/private-servers`, searchParams: { limit, sortOrder, cursor }, name: `authedUserPrivateServersForPlace`, formatRawDataFn: ({ data }) => data })); const placeServerList = createApiMethod(async ({ placeId, serverType, excludeFullGames, limit, sortOrder, cursor }) => ({ method: "GET", path: `/v1/games/${placeId}/servers/${serverType == "Public" ? 0 : 1}`, searchParams: { excludeFullGames, limit, sortOrder, cursor }, name: `placeServerList`, formatRawDataFn: ({ data }) => data })); const authedUserUniverseIsFavorited = createApiMethod(async ({ universeId }) => ({ method: "GET", path: `/v1/games/${universeId}/favorites`, name: `authedUserUniverseIsFavorited`, formatRawDataFn: ({ isFavorited }) => isFavorited })); const authedUserUniverseSetFavorite = createApiMethod(async ({ universeId, status }) => ({ method: "POST", path: `/v1/games/${universeId}/favorites`, name: `authedUserUniverseToggleFavorite`, body: { isFavorited: status }, formatRawDataFn: import_utils.dataIsSuccess })); const universeFavoritesCount = createApiMethod(async ({ universeId }) => ({ method: "GET", path: `/v1/games/${universeId}/favorites/count`, name: `universeFavoritesCount`, formatRawDataFn: ({ favoritesCount }) => favoritesCount })); const universeGamePasses = createApiMethod(async ({ universeId, limit = 100, sortOrder, cursor }) => ({ method: "GET", path: `/v1/games/${universeId}/game-passes`, searchParams: { limit, sortOrder, cursor }, name: `universeGamePasses`, formatRawDataFn: ({ data }) => data })); const authedUserUniverseVoteStatus = createApiMethod(async ({ universeId }) => ({ method: "GET", path: `/v1/games/${universeId}/votes/user`, name: `authedUserUniverseVoteStatus` })); const universesVoteStatus = createApiMethod(async ({ universeIds }) => ({ method: "GET", path: `/v1/games/votes`, searchParams: { universeIds }, name: `universesVoteStatus`, formatRawDataFn: ({ data }) => (0, import_utils.createObjectMapByKeyWithMiddleware)(data, "id", ({ id, ...rest }) => rest) })); const authedUserSetUniverseUpvote = createApiMethod(async ({ universeId, upvote }) => ({ method: "PATCH", path: `/v1/games/${universeId}/user-votes`, body: { vote: upvote }, name: `authedUserSetUniverseUpvote`, formatRawDataFn: import_utils.dataIsSuccess })); const vipServersAllowedForUniverse = createApiMethod(async ({ universeId }) => ({ method: "GET", path: `/v1/private-servers/enabled-in-universe/${universeId}`, name: `vipServersAllowedForUniverse`, formatRawDataFn: ({ privateServersEnabled }) => privateServersEnabled })); const authedUserCanUserBeInvitedToVipServer = createApiMethod(async ({ userId }) => ({ method: "GET", path: `/v1/vip-server/can-invite/${userId}`, name: `authedUserCanUserBeInvitedToVipServer` })); const vipServerInfo = createApiMethod(async ({ vipServerId }) => ({ method: "GET", path: `/v1/vip-servers/${vipServerId}`, name: `vipServerInfo` })); const updateVipServer = createApiMethod(async ({ vipServerId, name, newJoinCode, active }) => ({ method: "PATCH", path: `/v1/vip-servers/${vipServerId}`, body: { name, newJoinCode, active }, name: `updateVipServer` })); const updateVipServerVoiceSettings = createApiMethod(async ({ vipServerId, enabled }) => ({ method: "PATCH", path: `/v1/vip-servers/${vipServerId}/voicesettings`, body: { enabled }, name: `updateVipServerVoiceSettings` })); const universeMedia = createApiMethod(async ({ universeId }) => ({ method: "GET", path: `/v2/games/${universeId}/media`, name: `universeMedia`, formatRawDataFn: ({ data }) => data })); const groupGames = createApiMethod(async ({ groupId, accessFilter, limit, sortOrder, cursor }) => ({ method: "GET", path: `/v2/groups/${groupId}/games`, searchParams: { accessFilter, limit, sortOrder, cursor }, name: `groupGames`, formatRawDataFn: ({ data }) => data })); const userGames = createApiMethod(async ({ userId, limit, sortOrder, cursor }) => ({ path: `/v2/users/${userId}/games`, method: "GET", searchParams: { limit, sortOrder, cursor }, name: "userGames", formatRawDataFn: ({ data }) => data.map((gameData) => (0, import_utils.cloneAndMutateObject)(gameData, (obj) => { obj.created = new Date(obj.created); obj.updated = new Date(obj.updated); })), getCursorsFn: ({ previousPageCursor, nextPageCursor }) => [previousPageCursor, nextPageCursor] })); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { authedUserCanUserBeInvitedToVipServer, authedUserGamesPlayabilityStatuses, authedUserPrivateServersForPlace, authedUserSetUniverseUpvote, authedUserSpotlightedGames, authedUserUniverseIsFavorited, authedUserUniverseSetFavorite, authedUserUniverseVoteStatus, groupGames, placeServerList, placesInfo, recommendationsFromUniverse, universeFavoritesCount, universeGamePasses, universeMedia, universesInfo, universesProductInfo, universesVoteStatus, updateVipServer, updateVipServerVoiceSettings, userGames, vipServerInfo, vipServersAllowedForUniverse });