UNPKG

@pnp/sp

Version:

pnp - provides a fluent api for working with SharePoint REST

32 lines 1.62 kB
import { _Web } from "../webs/types.js"; import { CreateClientsidePage, ClientsidePageFromFile, ClientsideWebpart, } from "./types.js"; import { SPCollection, SPInstance } from "../spqueryable.js"; import { spPost } from "../operations.js"; import { body } from "@pnp/queryable"; import { extractWebUrl } from "@pnp/sp"; _Web.prototype.getClientsideWebParts = function () { return SPCollection(this, "GetClientSideWebParts")(); }; _Web.prototype.addClientsidePage = function (pageName, title = pageName.replace(/\.[^/.]+$/, ""), layout, promotedState) { return CreateClientsidePage(this, pageName, title, layout, promotedState); }; _Web.prototype.loadClientsidePage = function (path) { return ClientsidePageFromFile(this.getFileByServerRelativePath(path)); }; _Web.prototype.addRepostPage = async function (details) { const query = SPInstance([this, extractWebUrl(this.toUrl())], "_api/sitepages/pages/reposts"); const r = await spPost(query, body(details)); return r.AbsoluteUrl; }; // eslint-disable-next-line max-len _Web.prototype.addFullPageApp = async function (pageName, title = pageName.replace(/\.[^/.]+$/, ""), componentId, promotedState) { const parts = await this.getClientsideWebParts(); const test = new RegExp(`{?${componentId}}?`, "i"); const partDef = parts.find(p => test.test(p.Id)); const part = ClientsideWebpart.fromComponentDef(partDef); const page = await this.addClientsidePage(pageName, title, "SingleWebPartAppPage", promotedState); page.addSection().addColumn(12).addControl(part); return page; }; //# sourceMappingURL=web.js.map