@pnp/sp
Version:
pnp - provides a fluent api for working with SharePoint REST
108 lines • 4.73 kB
JavaScript
import { body } from "@pnp/queryable";
import { spPost } from "../operations.js";
import { _SPQueryable } from "../spqueryable.js";
import { extractWebUrl } from "../utils/extract-web-url.js";
import { combine } from "@pnp/core";
import { encodePath } from "../utils/encode-path-str.js";
export class _SiteScripts 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));
}
/**
* Gets a list of information on all existing site scripts.
*/
getSiteScripts() {
return SiteScriptsCloneFactory(this, "GetSiteScripts").run({});
}
/**
* Creates a new site script.
*
* @param title The display name of the site script.
* @param content JSON value that describes the script. For more information, see JSON reference.
*/
createSiteScript(title, description, content) {
return SiteScriptsCloneFactory(this, `CreateSiteScript(Title=@title,Description=@desc)?@title='${encodePath(title)}'&@desc='${encodePath(description)}'`)
.run(content);
}
/**
* Gets information about a specific site script. It also returns the JSON of the script.
*
* @param id The ID of the site script to get information about.
*/
getSiteScriptMetadata(id) {
return SiteScriptsCloneFactory(this, "GetSiteScriptMetadata").run({ id });
}
/**
* Deletes a site script.
*
* @param id The ID of the site script to delete.
*/
deleteSiteScript(id) {
return SiteScriptsCloneFactory(this, "DeleteSiteScript").run({ id });
}
/**
* Updates a site script with new values. In the REST call, all parameters are optional except the site script Id.
*
* @param siteScriptUpdateInfo Object that contains the information to update a site script.
* Make sure you stringify the content object or pass it in the second 'content' parameter
* @param content (Optional) A new JSON script defining the script actions. For more information, see Site design JSON schema.
*/
updateSiteScript(updateInfo, content) {
if (content) {
updateInfo.Content = JSON.stringify(content);
}
return SiteScriptsCloneFactory(this, "UpdateSiteScript").run({ updateInfo });
}
/**
* Gets the site script syntax (JSON) for a specific list
* @param listUrl The absolute url of the list to retrieve site script
*/
getSiteScriptFromList(listUrl) {
return SiteScriptsCloneFactory(this, "GetSiteScriptFromList").run({ listUrl });
}
/**
* Gets the site script syntax (JSON) for a specific web
* @param webUrl The absolute url of the web to retrieve site script
* @param extractInfo configuration object to specify what to extract
*/
getSiteScriptFromWeb(webUrl, info) {
return SiteScriptsCloneFactory(this, "getSiteScriptFromWeb").run({ webUrl, info });
}
/**
* Executes the indicated site design action on the indicated web.
*
* @param webUrl The absolute url of the web to retrieve site script
* @param extractInfo configuration object to specify what to extract
*/
executeSiteScriptAction(actionDefinition) {
return SiteScriptsCloneFactory(this, "executeSiteScriptAction").run({ actionDefinition });
}
}
export const SiteScripts = (baseUrl, methodName) => new _SiteScripts(baseUrl, methodName);
const SiteScriptsCloneFactory = (baseUrl, methodName = "") => SiteScripts(baseUrl, methodName);
export var SiteScriptActionOutcome;
(function (SiteScriptActionOutcome) {
/**
* The stage was deemed to have completed successfully.
*/
SiteScriptActionOutcome[SiteScriptActionOutcome["Success"] = 0] = "Success";
/**
* The stage was deemed to have failed to complete successfully (non-blocking, rest of recipe
* execution should still be able to proceed).
*/
SiteScriptActionOutcome[SiteScriptActionOutcome["Failure"] = 1] = "Failure";
/**
* No action was taken for this stage / this stage was skipped.
*/
SiteScriptActionOutcome[SiteScriptActionOutcome["NoOp"] = 2] = "NoOp";
/**
* There was an exception but the operation succeeded. This is analagous to the operation completing
* in a "yellow" state.
*/
SiteScriptActionOutcome[SiteScriptActionOutcome["SucceededWithException"] = 3] = "SucceededWithException";
})(SiteScriptActionOutcome || (SiteScriptActionOutcome = {}));
//# sourceMappingURL=types.js.map