@esri/hub-discussions
Advanced tools
Comparing version 25.0.0 to 25.1.0
@@ -5,2 +5,8 @@ import { SharingAccess } from "../../types"; | ||
import { isOrgAdmin } from "../platform"; | ||
/** | ||
* Utility to determine if User has privileges to create a channel with the defined permissions | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
export function canCreateChannel(channel, user = {}) { | ||
@@ -7,0 +13,0 @@ const { channelAcl, access, groups, orgs } = channel; |
@@ -12,2 +12,8 @@ import { Role, SharingAccess } from "../../types"; | ||
]); | ||
/** | ||
* Utility to determine if User has privileges to create a post in a channel | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
export function canPostToChannel(channel, user = {}) { | ||
@@ -14,0 +20,0 @@ const { channelAcl, access, groups, orgs, allowAnonymous } = channel; |
@@ -1,4 +0,5 @@ | ||
import { isOrgAdmin, reduceByGroupMembership } from "../platform"; | ||
import { reduceByGroupMembership } from "../platform"; | ||
export { canPostToChannel } from "./can-post-to-channel"; | ||
export { canCreateChannel } from "./can-create-channel"; | ||
export { canModifyChannel } from "./can-modify-channel"; | ||
function intersectGroups(membershipTypes) { | ||
@@ -17,5 +18,2 @@ return (user, channel) => { | ||
} | ||
function isChannelOrgAdmin(channel, user) { | ||
return isOrgAdmin(user) && channel.orgs.indexOf(user.orgId) > -1; | ||
} | ||
/** | ||
@@ -41,25 +39,2 @@ * Utility to determine whether User can view posts belonging to Channel | ||
} | ||
/** | ||
* Utility to determine whether User can modify channel settings and posts belonging to Channel | ||
* | ||
* @export | ||
* @param {IChannel} channel | ||
* @param {IUser} user | ||
* @return {*} {boolean} | ||
*/ | ||
export function canModifyChannel(channel, user = {}) { | ||
if (!user.username) { | ||
return false; | ||
} | ||
if (channel.creator === user.username) { | ||
return true; | ||
} | ||
if (channel.access === "private") { | ||
// ensure user is owner/admin of at least one group | ||
return intersectGroups(["owner", "admin"])(user, channel); | ||
} | ||
// org or public channel | ||
return (intersectGroups(["owner", "admin"])(user, channel) || | ||
isChannelOrgAdmin(channel, user)); | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -5,2 +5,8 @@ import { SharingAccess } from "../../types"; | ||
const ADMIN_GROUP_ROLES = Object.freeze(["owner", "admin"]); | ||
/** | ||
* Utility to determine if User has privileges to modify the status of a post | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
export function canModifyPostStatus(channel, user = {}) { | ||
@@ -15,3 +21,3 @@ const { channelAcl } = channel; | ||
function isAuthorizedToModifyStatusByLegacyPermissions(user, channel) { | ||
const { username, groups: userGroups = [], orgId: userOrgId } = user; | ||
const { username, groups: userGroups = [] } = user; | ||
const { access, groups: channelGroups = [], orgs: channelOrgs = [], creator: channelCreator, } = channel; | ||
@@ -18,0 +24,0 @@ if (!username) { |
import { SharingAccess } from "../../types"; | ||
import { CANNOT_DISCUSS } from "../constants"; | ||
/** | ||
* Determine if a user can modify an existing post | ||
* Utility to determine if User has privileges to modify a post | ||
* @param post | ||
* @param user | ||
* @param channel | ||
* @returns {boolean} | ||
*/ | ||
@@ -6,0 +10,0 @@ export function canModifyPost(post, user = {}, channel) { |
@@ -8,2 +8,8 @@ "use strict"; | ||
const platform_1 = require("../platform"); | ||
/** | ||
* Utility to determine if User has privileges to create a channel with the defined permissions | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
function canCreateChannel(channel, user = {}) { | ||
@@ -10,0 +16,0 @@ const { channelAcl, access, groups, orgs } = channel; |
@@ -15,2 +15,8 @@ "use strict"; | ||
]); | ||
/** | ||
* Utility to determine if User has privileges to create a post in a channel | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
function canPostToChannel(channel, user = {}) { | ||
@@ -17,0 +23,0 @@ const { channelAcl, access, groups, orgs, allowAnonymous } = channel; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.canModifyChannel = exports.canReadFromChannel = void 0; | ||
exports.canReadFromChannel = void 0; | ||
const platform_1 = require("../platform"); | ||
@@ -9,2 +9,4 @@ var can_post_to_channel_1 = require("./can-post-to-channel"); | ||
Object.defineProperty(exports, "canCreateChannel", { enumerable: true, get: function () { return can_create_channel_1.canCreateChannel; } }); | ||
var can_modify_channel_1 = require("./can-modify-channel"); | ||
Object.defineProperty(exports, "canModifyChannel", { enumerable: true, get: function () { return can_modify_channel_1.canModifyChannel; } }); | ||
function intersectGroups(membershipTypes) { | ||
@@ -23,5 +25,2 @@ return (user, channel) => { | ||
} | ||
function isChannelOrgAdmin(channel, user) { | ||
return platform_1.isOrgAdmin(user) && channel.orgs.indexOf(user.orgId) > -1; | ||
} | ||
/** | ||
@@ -48,26 +47,2 @@ * Utility to determine whether User can view posts belonging to Channel | ||
exports.canReadFromChannel = canReadFromChannel; | ||
/** | ||
* Utility to determine whether User can modify channel settings and posts belonging to Channel | ||
* | ||
* @export | ||
* @param {IChannel} channel | ||
* @param {IUser} user | ||
* @return {*} {boolean} | ||
*/ | ||
function canModifyChannel(channel, user = {}) { | ||
if (!user.username) { | ||
return false; | ||
} | ||
if (channel.creator === user.username) { | ||
return true; | ||
} | ||
if (channel.access === "private") { | ||
// ensure user is owner/admin of at least one group | ||
return intersectGroups(["owner", "admin"])(user, channel); | ||
} | ||
// org or public channel | ||
return (intersectGroups(["owner", "admin"])(user, channel) || | ||
isChannelOrgAdmin(channel, user)); | ||
} | ||
exports.canModifyChannel = canModifyChannel; | ||
//# sourceMappingURL=index.js.map |
@@ -8,2 +8,8 @@ "use strict"; | ||
const ADMIN_GROUP_ROLES = Object.freeze(["owner", "admin"]); | ||
/** | ||
* Utility to determine if User has privileges to modify the status of a post | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
function canModifyPostStatus(channel, user = {}) { | ||
@@ -19,3 +25,3 @@ const { channelAcl } = channel; | ||
function isAuthorizedToModifyStatusByLegacyPermissions(user, channel) { | ||
const { username, groups: userGroups = [], orgId: userOrgId } = user; | ||
const { username, groups: userGroups = [] } = user; | ||
const { access, groups: channelGroups = [], orgs: channelOrgs = [], creator: channelCreator, } = channel; | ||
@@ -22,0 +28,0 @@ if (!username) { |
@@ -7,3 +7,7 @@ "use strict"; | ||
/** | ||
* Determine if a user can modify an existing post | ||
* Utility to determine if User has privileges to modify a post | ||
* @param post | ||
* @param user | ||
* @param channel | ||
* @returns {boolean} | ||
*/ | ||
@@ -10,0 +14,0 @@ function canModifyPost(post, user = {}, channel) { |
import { IUser } from "@esri/arcgis-rest-types"; | ||
import { IChannel, IDiscussionsUser } from "../../types"; | ||
/** | ||
* Utility to determine if User has privileges to create a channel with the defined permissions | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
export declare function canCreateChannel(channel: IChannel, user?: IUser | IDiscussionsUser): boolean; |
import { IUser } from "@esri/arcgis-rest-types"; | ||
import { IChannel, IDiscussionsUser } from "../../types"; | ||
/** | ||
* Utility to determine if User has privileges to create a post in a channel | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
export declare function canPostToChannel(channel: IChannel, user?: IUser | IDiscussionsUser): boolean; |
@@ -5,2 +5,3 @@ import { IUser } from "@esri/arcgis-rest-auth"; | ||
export { canCreateChannel } from "./can-create-channel"; | ||
export { canModifyChannel } from "./can-modify-channel"; | ||
/** | ||
@@ -15,10 +16,1 @@ * Utility to determine whether User can view posts belonging to Channel | ||
export declare function canReadFromChannel(channel: IChannel, user?: IUser | IDiscussionsUser): boolean; | ||
/** | ||
* Utility to determine whether User can modify channel settings and posts belonging to Channel | ||
* | ||
* @export | ||
* @param {IChannel} channel | ||
* @param {IUser} user | ||
* @return {*} {boolean} | ||
*/ | ||
export declare function canModifyChannel(channel: IChannel, user?: IUser | IDiscussionsUser): boolean; |
import { IUser } from "@esri/arcgis-rest-types"; | ||
import { IChannel, IDiscussionsUser } from "../../types"; | ||
/** | ||
* Utility to determine if User has privileges to modify the status of a post | ||
* @param channel | ||
* @param user | ||
* @returns {boolean} | ||
*/ | ||
export declare function canModifyPostStatus(channel: IChannel, user?: IUser | IDiscussionsUser): boolean; |
import { IUser } from "@esri/arcgis-rest-types"; | ||
import { IChannel, IDiscussionsUser, IPost } from "../../types"; | ||
/** | ||
* Determine if a user can modify an existing post | ||
* Utility to determine if User has privileges to modify a post | ||
* @param post | ||
* @param user | ||
* @param channel | ||
* @returns {boolean} | ||
*/ | ||
export declare function canModifyPost(post: IPost, user: IUser | IDiscussionsUser, channel: IChannel): boolean; |
{ | ||
"name": "@esri/hub-discussions", | ||
"version": "25.0.0", | ||
"version": "25.1.0", | ||
"description": "Module to interact with ArcGIS Hub Discussions API in Node.js and modern browsers.", | ||
@@ -5,0 +5,0 @@ "main": "dist/node/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195007
107
3809