UNPKG

2.11 kBJavaScriptView Raw
1import { _Web, Web } from "../webs/types.js";
2import { SharingRole } from "./types.js";
3import { shareObject } from "./funcs.js";
4import { combine } from "@pnp/core";
5import { body } from "@pnp/queryable";
6import { spPost } from "../operations.js";
7/**
8 * Shares this web with the supplied users (not supported for batching)
9 * @param loginNames The resolved login names to share
10 * @param role The role to share this web
11 * @param emailData Optional email data
12 */
13_Web.prototype.shareWith = async function (loginNames, role = SharingRole.View, emailData) {
14 const url = await this.select("Url")();
15 return this.shareObject(combine(url.Url, "/_layouts/15/aclinv.aspx?forSharing=1&mbypass=1"), loginNames, role, emailData);
16};
17/**
18 * Provides direct access to the static web.ShareObject method
19 *
20 * @param url The url to share
21 * @param loginNames Resolved loginnames string[] of a single login name string
22 * @param roleValue Role value
23 * @param emailData Optional email data
24 * @param groupId Optional group id
25 * @param propagateAcl
26 * @param includeAnonymousLinkInEmail
27 * @param useSimplifiedRoles
28 */
29_Web.prototype.shareObject = function (url, loginNames, role, emailData, group, propagateAcl = false, includeAnonymousLinkInEmail = false, useSimplifiedRoles = true) {
30 return shareObject(this, {
31 emailData: emailData,
32 group: group,
33 includeAnonymousLinkInEmail: includeAnonymousLinkInEmail,
34 loginNames: loginNames,
35 propagateAcl: propagateAcl,
36 role: role,
37 url: url,
38 useSimplifiedRoles: useSimplifiedRoles,
39 });
40};
41/**
42 * Supplies a method to pass any set of arguments to ShareObject
43 *
44 * @param options The set of options to send to ShareObject
45 */
46_Web.prototype.shareObjectRaw = function (options) {
47 return shareObject(this, options, true);
48};
49/**
50 * Supplies a method to pass any set of arguments to ShareObject
51 *
52 * @param options The set of options to send to ShareObject
53 */
54_Web.prototype.unshareObject = function (url) {
55 return spPost(Web(this, "unshareObject"), body({ url }));
56};
57//# sourceMappingURL=web.js.map
\No newline at end of file