UNPKG

8.31 kBJavaScriptView Raw
1import { _SPQueryable } from "../spqueryable.js";
2import { extractWebUrl } from "../utils/extract-web-url.js";
3import { headers, body } from "@pnp/queryable";
4import { spPost } from "../operations.js";
5import { combine, hOP } from "@pnp/core";
6export 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}
132export const SiteDesigns = (baseUrl, methodName) => new _SiteDesigns(baseUrl, methodName);
133const SiteDesignsCloneFactory = (baseUrl, methodName = "") => SiteDesigns(baseUrl, methodName);
134export var TemplateDesignType;
135(function (TemplateDesignType) {
136 /// <summary>
137 /// Represents the Site design type.
138 /// </summary>
139 TemplateDesignType[TemplateDesignType["Site"] = 0] = "Site";
140 /// <summary>
141 /// Represents the List design type.
142 /// </summary>
143 TemplateDesignType[TemplateDesignType["List"] = 1] = "List";
144})(TemplateDesignType || (TemplateDesignType = {}));
145export var ListDesignColor;
146(function (ListDesignColor) {
147 ListDesignColor[ListDesignColor["DarkRed"] = 0] = "DarkRed";
148 ListDesignColor[ListDesignColor["Red"] = 1] = "Red";
149 ListDesignColor[ListDesignColor["Orange"] = 2] = "Orange";
150 ListDesignColor[ListDesignColor["Green"] = 3] = "Green";
151 ListDesignColor[ListDesignColor["DarkGreen"] = 4] = "DarkGreen";
152 ListDesignColor[ListDesignColor["Teal"] = 5] = "Teal";
153 ListDesignColor[ListDesignColor["Blue"] = 6] = "Blue";
154 ListDesignColor[ListDesignColor["NavyBlue"] = 7] = "NavyBlue";
155 ListDesignColor[ListDesignColor["BluePurple"] = 8] = "BluePurple";
156 ListDesignColor[ListDesignColor["DarkBlue"] = 9] = "DarkBlue";
157 ListDesignColor[ListDesignColor["Lavendar"] = 10] = "Lavendar";
158 ListDesignColor[ListDesignColor["Pink"] = 11] = "Pink";
159})(ListDesignColor || (ListDesignColor = {}));
160export var ListDesignIcon;
161(function (ListDesignIcon) {
162 ListDesignIcon[ListDesignIcon["Bug"] = 0] = "Bug";
163 ListDesignIcon[ListDesignIcon["Calendar"] = 1] = "Calendar";
164 ListDesignIcon[ListDesignIcon["BullseyeTarget"] = 2] = "BullseyeTarget";
165 ListDesignIcon[ListDesignIcon["ClipboardList"] = 3] = "ClipboardList";
166 ListDesignIcon[ListDesignIcon["Airplane"] = 4] = "Airplane";
167 ListDesignIcon[ListDesignIcon["Rocket"] = 5] = "Rocket";
168 ListDesignIcon[ListDesignIcon["Color"] = 6] = "Color";
169 ListDesignIcon[ListDesignIcon["Insights"] = 7] = "Insights";
170 ListDesignIcon[ListDesignIcon["CubeShape"] = 8] = "CubeShape";
171 ListDesignIcon[ListDesignIcon["TestBeakerSolid"] = 9] = "TestBeakerSolid";
172 ListDesignIcon[ListDesignIcon["Robot"] = 10] = "Robot";
173 ListDesignIcon[ListDesignIcon["Savings"] = 11] = "Savings";
174})(ListDesignIcon || (ListDesignIcon = {}));
175//# sourceMappingURL=types.js.map
\No newline at end of file