1 | import { _SPQueryable } from "../spqueryable.js";
|
2 | import { extractWebUrl } from "../utils/extract-web-url.js";
|
3 | import { headers, body } from "@pnp/queryable";
|
4 | import { spPost } from "../operations.js";
|
5 | import { combine, hOP } from "@pnp/core";
|
6 | export class _SiteDesigns extends _SPQueryable {
|
7 | constructor(base, methodName = "") {
|
8 | super(base);
|
9 | this._url = combine(extractWebUrl(this._url), `_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.${methodName}`);
|
10 | }
|
11 | run(props) {
|
12 | return spPost(this, body(props, headers({ "Content-Type": "application/json;charset=utf-8" })));
|
13 | }
|
14 | /**
|
15 | * Creates a new site design available to users when they create a new site from the SharePoint home page.
|
16 | *
|
17 | * @param creationInfo A sitedesign creation information object
|
18 | */
|
19 | createSiteDesign(creationInfo) {
|
20 | return SiteDesignsCloneFactory(this, "CreateSiteDesign").run({ info: creationInfo });
|
21 | }
|
22 | /**
|
23 | * Applies a site design to an existing site collection.
|
24 | *
|
25 | * @param siteDesignId The ID of the site design to apply.
|
26 | * @param webUrl The URL of the site collection where you want to apply the site design.
|
27 | */
|
28 | applySiteDesign(siteDesignId, webUrl) {
|
29 | return SiteDesignsCloneFactory(this, "ApplySiteDesign").run({ siteDesignId: siteDesignId, "webUrl": webUrl });
|
30 | }
|
31 | /**
|
32 | * Gets the list of available site designs
|
33 | */
|
34 | getSiteDesigns() {
|
35 | return SiteDesignsCloneFactory(this, "GetSiteDesigns").run({});
|
36 | }
|
37 | /**
|
38 | * Gets information about a specific site design.
|
39 | * @param id The ID of the site design to get information about.
|
40 | */
|
41 | getSiteDesignMetadata(id) {
|
42 | return SiteDesignsCloneFactory(this, "GetSiteDesignMetadata").run({ id: id });
|
43 | }
|
44 | /**
|
45 | * Updates a site design with new values. In the REST call, all parameters are optional except the site script Id.
|
46 | * If you had previously set the IsDefault parameter to TRUE and wish it to remain true, you must pass in this parameter again (otherwise it will be reset to FALSE).
|
47 | * @param updateInfo A sitedesign update information object
|
48 | */
|
49 | updateSiteDesign(updateInfo) {
|
50 | return SiteDesignsCloneFactory(this, "UpdateSiteDesign").run({ updateInfo: updateInfo });
|
51 | }
|
52 | /**
|
53 | * Deletes a site design.
|
54 | * @param id The ID of the site design to delete.
|
55 | */
|
56 | deleteSiteDesign(id) {
|
57 | return SiteDesignsCloneFactory(this, "DeleteSiteDesign").run({ id: id });
|
58 | }
|
59 | /**
|
60 | * Gets a list of principals that have access to a site design.
|
61 | * @param id The ID of the site design to get rights information from.
|
62 | */
|
63 | getSiteDesignRights(id) {
|
64 | return SiteDesignsCloneFactory(this, "GetSiteDesignRights").run({ id: id });
|
65 | }
|
66 | /**
|
67 | * Grants access to a site design for one or more principals.
|
68 | * @param id The ID of the site design to grant rights on.
|
69 | * @param principalNames An array of one or more principals to grant view rights.
|
70 | * Principals can be users or mail-enabled security groups in the form of "alias" or "alias@<domain name>.com"
|
71 | * @param grantedRights Always set to 1. This represents the View right.
|
72 | */
|
73 | grantSiteDesignRights(id, principalNames, grantedRights = 1) {
|
74 | return SiteDesignsCloneFactory(this, "GrantSiteDesignRights").run({
|
75 | "grantedRights": grantedRights.toString(),
|
76 | id,
|
77 | principalNames,
|
78 | });
|
79 | }
|
80 | /**
|
81 | * Revokes access from a site design for one or more principals.
|
82 | * @param id The ID of the site design to revoke rights from.
|
83 | * @param principalNames An array of one or more principals to revoke view rights from.
|
84 | * If all principals have rights revoked on the site design, the site design becomes viewable to everyone.
|
85 | */
|
86 | revokeSiteDesignRights(id, principalNames) {
|
87 | return SiteDesignsCloneFactory(this, "RevokeSiteDesignRights").run({
|
88 | id,
|
89 | principalNames,
|
90 | });
|
91 | }
|
92 | /**
|
93 | * Adds a site design task on the specified web url to be invoked asynchronously.
|
94 | * @param webUrl The absolute url of the web on where to create the task
|
95 | * @param siteDesignId The ID of the site design to create a task for
|
96 | */
|
97 | addSiteDesignTask(webUrl, siteDesignId) {
|
98 | return SiteDesignsCloneFactory(this, "AddSiteDesignTask").run({ webUrl, siteDesignId });
|
99 | }
|
100 | /**
|
101 | * Adds a site design task on the current web to be invoked asynchronously.
|
102 | * @param siteDesignId The ID of the site design to create a task for
|
103 | */
|
104 | addSiteDesignTaskToCurrentWeb(siteDesignId) {
|
105 | return SiteDesignsCloneFactory(this, "AddSiteDesignTaskToCurrentWeb").run({ siteDesignId });
|
106 | }
|
107 | /**
|
108 | * Retrieves the site design task, if the task has finished running null will be returned
|
109 | * @param id The ID of the site design task
|
110 | */
|
111 | async getSiteDesignTask(id) {
|
112 | const task = await SiteDesignsCloneFactory(this, "GetSiteDesignTask").run({ "taskId": id });
|
113 | return hOP(task, "ID") ? task : null;
|
114 | }
|
115 | /**
|
116 | * Retrieves a list of site design that have run on a specific web
|
117 | * @param webUrl The url of the web where the site design was applied
|
118 | * @param siteDesignId (Optional) the site design ID, if not provided will return all site design runs
|
119 | */
|
120 | getSiteDesignRun(webUrl, siteDesignId) {
|
121 | return SiteDesignsCloneFactory(this, "GetSiteDesignRun").run({ webUrl, siteDesignId });
|
122 | }
|
123 | /**
|
124 | * Retrieves the status of a site design that has been run or is still running
|
125 | * @param webUrl The url of the web where the site design was applied
|
126 | * @param runId the run ID
|
127 | */
|
128 | getSiteDesignRunStatus(webUrl, runId) {
|
129 | return SiteDesignsCloneFactory(this, "GetSiteDesignRunStatus").run({ webUrl, runId });
|
130 | }
|
131 | }
|
132 | export const SiteDesigns = (baseUrl, methodName) => new _SiteDesigns(baseUrl, methodName);
|
133 | const SiteDesignsCloneFactory = (baseUrl, methodName = "") => SiteDesigns(baseUrl, methodName);
|
134 | //# sourceMappingURL=types.js.map |
\ | No newline at end of file |