gd-sprest 7.8.7 → 7.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.SitePages = void 0;
4
15
  var web_1 = require("./web");
@@ -70,6 +81,19 @@ exports.SitePages.convertPage = function (pageUrl, layout, webUrl) {
70
81
  };
71
82
  // Static method to create a modern page
72
83
  exports.SitePages.createPage = (function (pageName, pageTitle, pageTemplate, url, targetInfo) {
84
+ var getContext = function () {
85
+ return new Promise(function (resolve) {
86
+ // See if the web url doesn't exists
87
+ if (url == null) {
88
+ resolve(null);
89
+ }
90
+ // Get the context of target web
91
+ contextInfo_1.ContextInfo.getWeb(url).execute(function (context) {
92
+ // Resolve the request
93
+ resolve(context.GetContextWebInformation.FormDigestValue);
94
+ });
95
+ });
96
+ };
73
97
  // Return a promise
74
98
  return new Promise(function (resolve, reject) {
75
99
  // Method called after the updates have completed
@@ -94,28 +118,33 @@ exports.SitePages.createPage = (function (pageName, pageTitle, pageTemplate, url
94
118
  }, reject);
95
119
  }, reject);
96
120
  };
97
- // Create the page
98
- exports.SitePages(url, targetInfo).Pages().createAppPage({
99
- Title: pageTitle,
100
- PageLayoutType: pageTemplate
101
- }).execute(function (page) {
102
- // Update the file name
103
- web_1.Web(url, targetInfo).Lists("Site Pages").Items(page.Id).update({
104
- FileLeafRef: pageName
105
- }).execute(
106
- // Updated the file name successfully
107
- function () {
108
- // Update the file url
109
- var idx = page.Url.lastIndexOf('/');
110
- var fileUrl = page.Url.substring(0, idx + 1) + pageName;
111
- // Complete the request
112
- onComplete(page.Id, fileUrl);
113
- },
114
- // Unable to update the file name, but still return the object
115
- function () {
116
- // Complete the request
117
- onComplete(page.Id, page.Url);
118
- });
119
- }, reject);
121
+ // Get the context information
122
+ getContext().then(function (requestDigest) {
123
+ // Set the target information
124
+ targetInfo = __assign({ requestDigest: requestDigest }, targetInfo);
125
+ // Create the page
126
+ exports.SitePages(url, targetInfo).Pages().createAppPage({
127
+ Title: pageTitle,
128
+ PageLayoutType: pageTemplate
129
+ }).execute(function (page) {
130
+ // Update the file name
131
+ web_1.Web(url, targetInfo).Lists("Site Pages").Items(page.Id).update({
132
+ FileLeafRef: pageName
133
+ }).execute(
134
+ // Updated the file name successfully
135
+ function () {
136
+ // Update the file url
137
+ var idx = page.Url.lastIndexOf('/');
138
+ var fileUrl = page.Url.substring(0, idx + 1) + pageName;
139
+ // Complete the request
140
+ onComplete(page.Id, fileUrl);
141
+ },
142
+ // Unable to update the file name, but still return the object
143
+ function () {
144
+ // Complete the request
145
+ onComplete(page.Id, page.Url);
146
+ });
147
+ }, reject);
148
+ });
120
149
  });
121
150
  });
package/build/rest.js CHANGED
@@ -9,7 +9,7 @@ var sptypes_1 = require("./sptypes");
9
9
  * SharePoint REST Library
10
10
  */
11
11
  exports.$REST = {
12
- __ver: 7.87,
12
+ __ver: 7.89,
13
13
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
14
14
  Apps: Lib.Apps,
15
15
  ContextInfo: Lib.ContextInfo,
@@ -143,7 +143,7 @@ exports.Request = {
143
143
  methodInfo.metadataType = methods[methodName].metadataType(obj);
144
144
  }
145
145
  // Add the method to the object
146
- obj[methodName] = new Function("return this.executeMethod('" + methodName + "', " + JSON.stringify(methodInfo) + ", arguments);");
146
+ obj[methodName] = obj[methodName] || new Function("return this.executeMethod('" + methodName + "', " + JSON.stringify(methodInfo) + ", arguments);");
147
147
  }
148
148
  }
149
149
  },