1 | import { body } from "@pnp/queryable";
|
2 | import { spPost } from "../operations.js";
|
3 | import { _SPQueryable } from "../spqueryable.js";
|
4 | import { extractWebUrl } from "../utils/extract-web-url.js";
|
5 | import { escapeQueryStrValue } from "../utils/escape-query-str.js";
|
6 | import { combine } from "@pnp/core";
|
7 | export class _SiteScripts extends _SPQueryable {
|
8 | constructor(base, methodName = "") {
|
9 | super(base);
|
10 | this._url = combine(extractWebUrl(this._url), `_api/Microsoft.Sharepoint.Utilities.WebTemplateExtensions.SiteScriptUtility.${methodName}`);
|
11 | }
|
12 | run(props) {
|
13 | return spPost(this, body(props));
|
14 | }
|
15 | |
16 |
|
17 |
|
18 | getSiteScripts() {
|
19 | return SiteScriptsCloneFactory(this, "GetSiteScripts").run({});
|
20 | }
|
21 | |
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | createSiteScript(title, description, content) {
|
28 | return SiteScriptsCloneFactory(this, `CreateSiteScript(Title=@title,Description=@desc)?@title='${escapeQueryStrValue(title)}'&@desc='${escapeQueryStrValue(description)}'`)
|
29 | .run(content);
|
30 | }
|
31 | |
32 |
|
33 |
|
34 |
|
35 |
|
36 | getSiteScriptMetadata(id) {
|
37 | return SiteScriptsCloneFactory(this, "GetSiteScriptMetadata").run({ id });
|
38 | }
|
39 | |
40 |
|
41 |
|
42 |
|
43 |
|
44 | deleteSiteScript(id) {
|
45 | return SiteScriptsCloneFactory(this, "DeleteSiteScript").run({ id });
|
46 | }
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | updateSiteScript(updateInfo, content) {
|
55 | if (content) {
|
56 | updateInfo.Content = JSON.stringify(content);
|
57 | }
|
58 | return SiteScriptsCloneFactory(this, "UpdateSiteScript").run({ updateInfo });
|
59 | }
|
60 | |
61 |
|
62 |
|
63 |
|
64 | getSiteScriptFromList(listUrl) {
|
65 | return SiteScriptsCloneFactory(this, "GetSiteScriptFromList").run({ listUrl });
|
66 | }
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 | getSiteScriptFromWeb(webUrl, info) {
|
73 | return SiteScriptsCloneFactory(this, "getSiteScriptFromWeb").run({ webUrl, info });
|
74 | }
|
75 | |
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 | executeSiteScriptAction(actionDefinition) {
|
82 | return SiteScriptsCloneFactory(this, "executeSiteScriptAction").run({ actionDefinition });
|
83 | }
|
84 | }
|
85 | export const SiteScripts = (baseUrl, methodName) => new _SiteScripts(baseUrl, methodName);
|
86 | const SiteScriptsCloneFactory = (baseUrl, methodName = "") => SiteScripts(baseUrl, methodName);
|
87 | export var SiteScriptActionOutcome;
|
88 | (function (SiteScriptActionOutcome) {
|
89 | |
90 |
|
91 |
|
92 | SiteScriptActionOutcome[SiteScriptActionOutcome["Success"] = 0] = "Success";
|
93 | |
94 |
|
95 |
|
96 |
|
97 | SiteScriptActionOutcome[SiteScriptActionOutcome["Failure"] = 1] = "Failure";
|
98 | |
99 |
|
100 |
|
101 | SiteScriptActionOutcome[SiteScriptActionOutcome["NoOp"] = 2] = "NoOp";
|
102 | |
103 |
|
104 |
|
105 |
|
106 | SiteScriptActionOutcome[SiteScriptActionOutcome["SucceededWithException"] = 3] = "SucceededWithException";
|
107 | })(SiteScriptActionOutcome || (SiteScriptActionOutcome = {}));
|
108 |
|
\ | No newline at end of file |