UNPKG

openblox

Version:

Roblox API Wrapper For Both Classic And OpenCloud APIs.

65 lines (64 loc) 3.36 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 userRestrictions_exports = {}; __export(userRestrictions_exports, { listRestrictionLogs: () => listRestrictionLogs, listRestrictions: () => listRestrictions, restrictionForUser: () => restrictionForUser, updateRestrictionsForUser: () => updateRestrictionsForUser }); module.exports = __toCommonJS(userRestrictions_exports); var import_apiGroup = require("../../apiGroup"); var import_utils = require("../../../utils/utils"); const { createApiMethod } = (0, import_apiGroup.createApiGroup)({ name: "UserRestrictions", baseUrl: "https://apis.roblox.com/cloud" }); const listRestrictions = createApiMethod(async ({ universeId, placeId, userId }) => ({ method: "GET", path: placeId ? `/v2/universes/${universeId}/places/${placeId}/user-restrictions/${userId}` : `/v2/universes/${universeId}/user-restrictions/${userId}`, name: `listRestrictions` })); const restrictionForUser = createApiMethod(async ({ universeId, placeId, userId }) => ({ method: "GET", path: placeId ? `/v2/universes/${universeId}/places/${placeId}/user-restrictions/${userId}` : `/v2/universes/${universeId}/places/${placeId}/user-restrictions/${userId}`, name: `restrictionForUser` })); const updateRestrictionsForUser = createApiMethod(async ({ universeId, placeId, userId, updatedData, idempotencyKey, firstSent }) => ({ method: "PATCH", path: placeId ? `/v2/universes/${universeId}/places/${placeId}/user-restrictions/${userId}` : `/v2/universes/${universeId}/user-restrictions/${userId}`, searchParams: { "idempotencyKey.key": idempotencyKey, "idempotencyKey.firstSent": firstSent }, body: updatedData, name: `updateRestrictionsForUser` })); const listRestrictionLogs = createApiMethod(async ({ universeId, placeId, userId, limit, cursor }) => ({ method: "GET", path: `/v2/universes/${universeId}/user-restrictions:listLogs`, searchParams: { maxPageSize: limit, pageToken: cursor, filter: userId && placeId ? `user == 'users/${userId}' && place == 'places/${placeId}'` : userId ? `user == 'users/${userId}'` : placeId ? `place == 'places/${placeId}'` : void 0 }, name: `listRestrictionLogs`, formatRawDataFn: ({ logs }) => logs.map((log) => (0, import_utils.cloneAndMutateObject)(log, (obj) => { obj.createTime = new Date(obj.createTime); obj.startTime = new Date(obj.startTime); })), getCursorsFn: ({ nextPageToken }) => [null, nextPageToken] })); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { listRestrictionLogs, listRestrictions, restrictionForUser, updateRestrictionsForUser });