@pnp/sp
Version: 
pnp - provides a fluent api for working with SharePoint REST
175 lines • 8.31 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);
export var TemplateDesignType;
(function (TemplateDesignType) {
    /// <summary>
    /// Represents the Site design type.
    /// </summary>
    TemplateDesignType[TemplateDesignType["Site"] = 0] = "Site";
    /// <summary>
    /// Represents the List design type.
    /// </summary>
    TemplateDesignType[TemplateDesignType["List"] = 1] = "List";
})(TemplateDesignType || (TemplateDesignType = {}));
export var ListDesignColor;
(function (ListDesignColor) {
    ListDesignColor[ListDesignColor["DarkRed"] = 0] = "DarkRed";
    ListDesignColor[ListDesignColor["Red"] = 1] = "Red";
    ListDesignColor[ListDesignColor["Orange"] = 2] = "Orange";
    ListDesignColor[ListDesignColor["Green"] = 3] = "Green";
    ListDesignColor[ListDesignColor["DarkGreen"] = 4] = "DarkGreen";
    ListDesignColor[ListDesignColor["Teal"] = 5] = "Teal";
    ListDesignColor[ListDesignColor["Blue"] = 6] = "Blue";
    ListDesignColor[ListDesignColor["NavyBlue"] = 7] = "NavyBlue";
    ListDesignColor[ListDesignColor["BluePurple"] = 8] = "BluePurple";
    ListDesignColor[ListDesignColor["DarkBlue"] = 9] = "DarkBlue";
    ListDesignColor[ListDesignColor["Lavendar"] = 10] = "Lavendar";
    ListDesignColor[ListDesignColor["Pink"] = 11] = "Pink";
})(ListDesignColor || (ListDesignColor = {}));
export var ListDesignIcon;
(function (ListDesignIcon) {
    ListDesignIcon[ListDesignIcon["Bug"] = 0] = "Bug";
    ListDesignIcon[ListDesignIcon["Calendar"] = 1] = "Calendar";
    ListDesignIcon[ListDesignIcon["BullseyeTarget"] = 2] = "BullseyeTarget";
    ListDesignIcon[ListDesignIcon["ClipboardList"] = 3] = "ClipboardList";
    ListDesignIcon[ListDesignIcon["Airplane"] = 4] = "Airplane";
    ListDesignIcon[ListDesignIcon["Rocket"] = 5] = "Rocket";
    ListDesignIcon[ListDesignIcon["Color"] = 6] = "Color";
    ListDesignIcon[ListDesignIcon["Insights"] = 7] = "Insights";
    ListDesignIcon[ListDesignIcon["CubeShape"] = 8] = "CubeShape";
    ListDesignIcon[ListDesignIcon["TestBeakerSolid"] = 9] = "TestBeakerSolid";
    ListDesignIcon[ListDesignIcon["Robot"] = 10] = "Robot";
    ListDesignIcon[ListDesignIcon["Savings"] = 11] = "Savings";
})(ListDesignIcon || (ListDesignIcon = {}));
//# sourceMappingURL=types.js.map