@pnp/sp
Version:
pnp - provides a fluent api for working with SharePoint REST
134 lines • 6.14 kB
JavaScript
import { _SPQueryable } from "../spqueryable.js";
import { extractWebUrl } from "../utils/extract-web-url.js";
import { headers, body } from "@pnp/queryable";
import { spPost } from "../operations.js";
import { combine, hOP } from "@pnp/core";
export class _SiteDesigns extends _SPQueryable {
constructor(base, methodName = "") {
super(base);
this._url = combine(extractWebUrl(this._url), `_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.${methodName}`);
}
run(props) {
return spPost(this, body(props, headers({ "Content-Type": "application/json;charset=utf-8" })));
}
/**
* Creates a new site design available to users when they create a new site from the SharePoint home page.
*
* @param creationInfo A sitedesign creation information object
*/
createSiteDesign(creationInfo) {
return SiteDesignsCloneFactory(this, "CreateSiteDesign").run({ info: creationInfo });
}
/**
* Applies a site design to an existing site collection.
*
* @param siteDesignId The ID of the site design to apply.
* @param webUrl The URL of the site collection where you want to apply the site design.
*/
applySiteDesign(siteDesignId, webUrl) {
return SiteDesignsCloneFactory(this, "ApplySiteDesign").run({ siteDesignId: siteDesignId, "webUrl": webUrl });
}
/**
* Gets the list of available site designs
*/
getSiteDesigns() {
return SiteDesignsCloneFactory(this, "GetSiteDesigns").run({});
}
/**
* Gets information about a specific site design.
* @param id The ID of the site design to get information about.
*/
getSiteDesignMetadata(id) {
return SiteDesignsCloneFactory(this, "GetSiteDesignMetadata").run({ id: id });
}
/**
* Updates a site design with new values. In the REST call, all parameters are optional except the site script Id.
* 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).
* @param updateInfo A sitedesign update information object
*/
updateSiteDesign(updateInfo) {
return SiteDesignsCloneFactory(this, "UpdateSiteDesign").run({ updateInfo: updateInfo });
}
/**
* Deletes a site design.
* @param id The ID of the site design to delete.
*/
deleteSiteDesign(id) {
return SiteDesignsCloneFactory(this, "DeleteSiteDesign").run({ id: id });
}
/**
* Gets a list of principals that have access to a site design.
* @param id The ID of the site design to get rights information from.
*/
getSiteDesignRights(id) {
return SiteDesignsCloneFactory(this, "GetSiteDesignRights").run({ id: id });
}
/**
* Grants access to a site design for one or more principals.
* @param id The ID of the site design to grant rights on.
* @param principalNames An array of one or more principals to grant view rights.
* Principals can be users or mail-enabled security groups in the form of "alias" or "alias@<domain name>.com"
* @param grantedRights Always set to 1. This represents the View right.
*/
grantSiteDesignRights(id, principalNames, grantedRights = 1) {
return SiteDesignsCloneFactory(this, "GrantSiteDesignRights").run({
"grantedRights": grantedRights.toString(),
id,
principalNames,
});
}
/**
* Revokes access from a site design for one or more principals.
* @param id The ID of the site design to revoke rights from.
* @param principalNames An array of one or more principals to revoke view rights from.
* If all principals have rights revoked on the site design, the site design becomes viewable to everyone.
*/
revokeSiteDesignRights(id, principalNames) {
return SiteDesignsCloneFactory(this, "RevokeSiteDesignRights").run({
id,
principalNames,
});
}
/**
* Adds a site design task on the specified web url to be invoked asynchronously.
* @param webUrl The absolute url of the web on where to create the task
* @param siteDesignId The ID of the site design to create a task for
*/
addSiteDesignTask(webUrl, siteDesignId) {
return SiteDesignsCloneFactory(this, "AddSiteDesignTask").run({ webUrl, siteDesignId });
}
/**
* Adds a site design task on the current web to be invoked asynchronously.
* @param siteDesignId The ID of the site design to create a task for
*/
addSiteDesignTaskToCurrentWeb(siteDesignId) {
return SiteDesignsCloneFactory(this, "AddSiteDesignTaskToCurrentWeb").run({ siteDesignId });
}
/**
* Retrieves the site design task, if the task has finished running null will be returned
* @param id The ID of the site design task
*/
async getSiteDesignTask(id) {
const task = await SiteDesignsCloneFactory(this, "GetSiteDesignTask").run({ "taskId": id });
return hOP(task, "ID") ? task : null;
}
/**
* Retrieves a list of site design that have run on a specific web
* @param webUrl The url of the web where the site design was applied
* @param siteDesignId (Optional) the site design ID, if not provided will return all site design runs
*/
getSiteDesignRun(webUrl, siteDesignId) {
return SiteDesignsCloneFactory(this, "GetSiteDesignRun").run({ webUrl, siteDesignId });
}
/**
* Retrieves the status of a site design that has been run or is still running
* @param webUrl The url of the web where the site design was applied
* @param runId the run ID
*/
getSiteDesignRunStatus(webUrl, runId) {
return SiteDesignsCloneFactory(this, "GetSiteDesignRunStatus").run({ webUrl, runId });
}
}
export const SiteDesigns = (baseUrl, methodName) => new _SiteDesigns(baseUrl, methodName);
const SiteDesignsCloneFactory = (baseUrl, methodName = "") => SiteDesigns(baseUrl, methodName);
//# sourceMappingURL=types.js.map