@pnp/sp
Version:
pnp - provides a fluent api for working with SharePoint REST
57 lines • 2.11 kB
JavaScript
import { _Web, Web } from "../webs/types.js";
import { SharingRole } from "./types.js";
import { shareObject } from "./funcs.js";
import { combine } from "@pnp/core";
import { body } from "@pnp/queryable";
import { spPost } from "../operations.js";
/**
* Shares this web with the supplied users (not supported for batching)
* @param loginNames The resolved login names to share
* @param role The role to share this web
* @param emailData Optional email data
*/
_Web.prototype.shareWith = async function (loginNames, role = SharingRole.View, emailData) {
const url = await this.select("Url")();
return this.shareObject(combine(url.Url, "/_layouts/15/aclinv.aspx?forSharing=1&mbypass=1"), loginNames, role, emailData);
};
/**
* Provides direct access to the static web.ShareObject method
*
* @param url The url to share
* @param loginNames Resolved loginnames string[] of a single login name string
* @param roleValue Role value
* @param emailData Optional email data
* @param groupId Optional group id
* @param propagateAcl
* @param includeAnonymousLinkInEmail
* @param useSimplifiedRoles
*/
_Web.prototype.shareObject = function (url, loginNames, role, emailData, group, propagateAcl = false, includeAnonymousLinkInEmail = false, useSimplifiedRoles = true) {
return shareObject(this, {
emailData: emailData,
group: group,
includeAnonymousLinkInEmail: includeAnonymousLinkInEmail,
loginNames: loginNames,
propagateAcl: propagateAcl,
role: role,
url: url,
useSimplifiedRoles: useSimplifiedRoles,
});
};
/**
* Supplies a method to pass any set of arguments to ShareObject
*
* @param options The set of options to send to ShareObject
*/
_Web.prototype.shareObjectRaw = function (options) {
return shareObject(this, options, true);
};
/**
* Supplies a method to pass any set of arguments to ShareObject
*
* @param options The set of options to send to ShareObject
*/
_Web.prototype.unshareObject = function (url) {
return spPost(Web(this, "unshareObject"), body({ url }));
};
//# sourceMappingURL=web.js.map