Path: blob/master/src/packages/database/postgres/project/manage-users-owner-only.ts
5700 views
/*1* This file is part of CoCalc: Copyright © 2025 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45export function sanitizeManageUsersOwnerOnly(6value: unknown,7): boolean | undefined {8if (value === undefined || value === null) {9return undefined;10}11if (typeof value === "object") {12// Allow nested shape { manage_users_owner_only: boolean } from callers that wrap input.13const candidate = (value as any).manage_users_owner_only;14if (candidate !== undefined) {15return sanitizeManageUsersOwnerOnly(candidate);16}17// Allow Immutable.js style get("manage_users_owner_only")18const getter = (value as any).get;19if (typeof getter === "function") {20const maybe = getter.call(value, "manage_users_owner_only");21if (maybe !== undefined) {22return sanitizeManageUsersOwnerOnly(maybe);23}24}25}26if (typeof value !== "boolean") {27throw Error("manage_users_owner_only must be a boolean");28}29return value;30}313233