gd-sprest 6.6.8 → 6.6.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.
@@ -34,7 +34,7 @@ export interface IBaseHelper {
34
34
  updateDataCollection(base: IBase, results: Array<IBase>);
35
35
 
36
36
  /** Updates the expanded data collection for odata query properties. */
37
- updateExpandedCollection(results: any[]);
37
+ updateExpandedCollection(base: IBase, results: any[]);
38
38
 
39
39
  /** Updates the expanded properties for odata queries. */
40
40
  updateExpandedProperties(base: IBase);
package/build/rest.js CHANGED
@@ -8,7 +8,7 @@ var sptypes_1 = require("./sptypes");
8
8
  * SharePoint REST Library
9
9
  */
10
10
  exports.$REST = {
11
- __ver: 6.68,
11
+ __ver: 6.69,
12
12
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
13
13
  Apps: Lib.Apps,
14
14
  ContextInfo: Lib.ContextInfo,
@@ -242,14 +242,14 @@ exports.Helper = {
242
242
  }
243
243
  },
244
244
  // Method to update the expanded collection property
245
- updateExpandedCollection: function (results) {
245
+ updateExpandedCollection: function (base, results) {
246
246
  // Parse the results
247
247
  for (var i = 0; i < results.length; i++) {
248
248
  var result = results[i];
249
249
  // See if this property was expanded
250
250
  if (result["__metadata"]) {
251
251
  // Add the base methods
252
- exports.Helper.addBaseMethods(result, result);
252
+ exports.Helper.addBaseMethods(base, result);
253
253
  // Update the metadata
254
254
  exports.Helper.updateMetadata(result, result);
255
255
  // Add the methods
@@ -274,7 +274,7 @@ exports.Helper = {
274
274
  // See if this is a collection
275
275
  if (prop["results"] && prop["results"].length > 0) {
276
276
  // Update the expanded collection
277
- exports.Helper.updateExpandedCollection(prop.results);
277
+ exports.Helper.updateExpandedCollection(base, prop.results);
278
278
  }
279
279
  // Else, see if this property was expanded
280
280
  else if (prop["__metadata"]) {
@@ -6211,7 +6211,7 @@ declare module 'gd-sprest/utils/helper' {
6211
6211
  updateDataCollection(base: IBase, results: Array<IBase>);
6212
6212
 
6213
6213
  /** Updates the expanded data collection for odata query properties. */
6214
- updateExpandedCollection(results: any[]);
6214
+ updateExpandedCollection(base: IBase, results: any[]);
6215
6215
 
6216
6216
  /** Updates the expanded properties for odata queries. */
6217
6217
  updateExpandedProperties(base: IBase);
package/dist/gd-sprest.js CHANGED
@@ -731,7 +731,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
731
731
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
732
732
 
733
733
  "use strict";
734
- eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.$REST = void 0;\n\nvar Helper = __webpack_require__(/*! ./helper */ \"./build/helper/index.js\");\n\nvar Lib = __webpack_require__(/*! ./lib */ \"./build/lib/index.js\");\n\nvar sptypes_1 = __webpack_require__(/*! ./sptypes */ \"./build/sptypes/index.js\");\n/**\r\n * SharePoint REST Library\r\n */\n\n\nexports.$REST = {\n __ver: 6.68,\n AppContext: function AppContext(siteUrl) {\n return Lib.Site.getAppContext(siteUrl);\n },\n Apps: Lib.Apps,\n ContextInfo: Lib.ContextInfo,\n DefaultRequestToHostFl: false,\n Graph: Lib.Graph,\n GroupService: Lib.GroupService,\n GroupSiteManager: Lib.GroupSiteManager,\n Helper: Helper,\n HubSites: Lib.HubSites,\n HubSitesUtility: Lib.HubSitesUtility,\n List: Lib.List,\n ListByEntityName: Lib.List.getByEntityName,\n ListDataAsStream: Lib.List.getDataAsStream,\n Navigation: Lib.Navigation,\n PeopleManager: Lib.PeopleManager,\n PeoplePicker: Lib.PeoplePicker,\n ProfileLoader: Lib.ProfileLoader,\n RemoteWeb: function RemoteWeb(requestUrl) {\n return Lib.Web.getRemoteWeb(requestUrl);\n },\n Search: Lib.Search,\n Site: Lib.Site,\n SiteManager: Lib.SiteManager,\n SiteExists: function SiteExists(url) {\n return Lib.Site.exists(url);\n },\n SiteUrl: function SiteUrl(id) {\n return Lib.Site.getUrlById(id);\n },\n SPTypes: sptypes_1.SPTypes,\n SocialFeed: Lib.SocialFeed,\n ThemeManager: Lib.ThemeManager,\n UserProfile: Lib.UserProfile,\n Utility: Lib.Utility,\n Web: Lib.Web,\n WebTemplateExtensions: Lib.WebTemplateExtensions,\n WorkflowInstanceService: Lib.WorkflowInstanceService,\n WorkflowSubscriptionService: Lib.WorkflowSubscriptionService\n}; // See if the library doesn't exist, or is an older version\n\nvar global = Lib.ContextInfo.window.$REST;\n\nif (global == null || global.__ver == null || global.__ver < exports.$REST.__ver) {\n // Set the global variable\n Lib.ContextInfo.window.$REST = exports.$REST; // Ensure the SP lib exists\n\n if (Lib.ContextInfo.window.SP) {\n // If MDS is turned on in a SP2013 environment, it may throw an error\n try {\n // Alert other scripts this library is loaded\n Lib.ContextInfo.window.SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs(\"gd-sprest\");\n Lib.ContextInfo.window.SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs(\"gd-sprest.js\");\n } catch (_a) {\n // Log\n console.error(\"[gd-sprest] Error notifying scripts using the SP SOD library.\");\n }\n }\n}\n\n//# sourceURL=webpack://gd-sprest/./build/rest.js?");
734
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.$REST = void 0;\n\nvar Helper = __webpack_require__(/*! ./helper */ \"./build/helper/index.js\");\n\nvar Lib = __webpack_require__(/*! ./lib */ \"./build/lib/index.js\");\n\nvar sptypes_1 = __webpack_require__(/*! ./sptypes */ \"./build/sptypes/index.js\");\n/**\r\n * SharePoint REST Library\r\n */\n\n\nexports.$REST = {\n __ver: 6.69,\n AppContext: function AppContext(siteUrl) {\n return Lib.Site.getAppContext(siteUrl);\n },\n Apps: Lib.Apps,\n ContextInfo: Lib.ContextInfo,\n DefaultRequestToHostFl: false,\n Graph: Lib.Graph,\n GroupService: Lib.GroupService,\n GroupSiteManager: Lib.GroupSiteManager,\n Helper: Helper,\n HubSites: Lib.HubSites,\n HubSitesUtility: Lib.HubSitesUtility,\n List: Lib.List,\n ListByEntityName: Lib.List.getByEntityName,\n ListDataAsStream: Lib.List.getDataAsStream,\n Navigation: Lib.Navigation,\n PeopleManager: Lib.PeopleManager,\n PeoplePicker: Lib.PeoplePicker,\n ProfileLoader: Lib.ProfileLoader,\n RemoteWeb: function RemoteWeb(requestUrl) {\n return Lib.Web.getRemoteWeb(requestUrl);\n },\n Search: Lib.Search,\n Site: Lib.Site,\n SiteManager: Lib.SiteManager,\n SiteExists: function SiteExists(url) {\n return Lib.Site.exists(url);\n },\n SiteUrl: function SiteUrl(id) {\n return Lib.Site.getUrlById(id);\n },\n SPTypes: sptypes_1.SPTypes,\n SocialFeed: Lib.SocialFeed,\n ThemeManager: Lib.ThemeManager,\n UserProfile: Lib.UserProfile,\n Utility: Lib.Utility,\n Web: Lib.Web,\n WebTemplateExtensions: Lib.WebTemplateExtensions,\n WorkflowInstanceService: Lib.WorkflowInstanceService,\n WorkflowSubscriptionService: Lib.WorkflowSubscriptionService\n}; // See if the library doesn't exist, or is an older version\n\nvar global = Lib.ContextInfo.window.$REST;\n\nif (global == null || global.__ver == null || global.__ver < exports.$REST.__ver) {\n // Set the global variable\n Lib.ContextInfo.window.$REST = exports.$REST; // Ensure the SP lib exists\n\n if (Lib.ContextInfo.window.SP) {\n // If MDS is turned on in a SP2013 environment, it may throw an error\n try {\n // Alert other scripts this library is loaded\n Lib.ContextInfo.window.SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs(\"gd-sprest\");\n Lib.ContextInfo.window.SP.SOD.notifyScriptLoadedAndExecuteWaitingJobs(\"gd-sprest.js\");\n } catch (_a) {\n // Log\n console.error(\"[gd-sprest] Error notifying scripts using the SP SOD library.\");\n }\n }\n}\n\n//# sourceURL=webpack://gd-sprest/./build/rest.js?");
735
735
 
736
736
  /***/ }),
737
737
 
@@ -786,7 +786,7 @@ eval("\n\nfunction _typeof(obj) { \"@babel/helpers - typeof\"; if (typeof Symbol
786
786
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
787
787
 
788
788
  "use strict";
789
- eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.Helper = void 0;\n\nvar lib_1 = __webpack_require__(/*! ../lib */ \"./build/lib/index.js\");\n\nvar _1 = __webpack_require__(/*! . */ \"./build/utils/index.js\");\n\nvar xhrRequest_1 = __webpack_require__(/*! ./xhrRequest */ \"./build/utils/xhrRequest.js\");\n/**\r\n * Request Helper\r\n */\n\n\nexports.Helper = {\n // Method to add the base references\n addBaseMethods: function addBaseMethods(base, obj) {\n // Add the base references\n obj[\"addMethods\"] = base.addMethods;\n obj[\"base\"] = base.base;\n obj[\"done\"] = base.done;\n obj[\"execute\"] = base.execute;\n obj[\"executeAndWait\"] = base.executeAndWait;\n obj[\"executeMethod\"] = base.executeMethod;\n obj[\"existsFl\"] = true;\n obj[\"getCollection\"] = base.getCollection;\n obj[\"getProperty\"] = base.getProperty;\n obj[\"parent\"] = base;\n obj[\"targetInfo\"] = base.targetInfo;\n obj[\"updateMetadataUri\"] = base.updateMetadataUri;\n obj[\"waitForRequestsToComplete\"] = base.waitForRequestsToComplete;\n },\n // Method to wait for all requests to complete, before resolving the request\n done: function done(base, resolve) {\n // Ensure the base is set\n base.base = base.base ? base.base : base; // Ensure the response index is set\n\n base.responseIndex = base.responseIndex >= 0 ? base.responseIndex : 0; // Wait for the responses to execute\n\n _1.Request.waitForRequestsToComplete(base, function () {\n var responses = base.base.responses; // Clear the responses\n\n base.base.responses = []; // Clear the wait flags\n\n base.base.waitFlags = []; // Resolve the request\n\n resolve ? resolve.apply(base, responses) : null;\n });\n },\n // Method to execute a method\n executeMethod: function executeMethod(base, methodName, methodConfig, args) {\n var targetInfo = null; // See if the metadata is defined for the base object\n\n var metadata = base[\"d\"] ? base[\"d\"].__metadata : base[\"__metadata\"];\n\n if (metadata && metadata.uri) {\n // Create the target information and use the url defined for the base object\n targetInfo = {\n url: metadata.uri\n }; // See if we are inheriting the metadata type\n\n if (methodConfig.inheritMetadataType && metadata.type) {\n // Copy the metadata type\n methodConfig.metadataType = metadata.type;\n } // Update the metadata uri\n\n\n exports.Helper.updateMetadataUri(base, metadata, targetInfo);\n } else {\n // Copy the target information\n targetInfo = Object.create(base.targetInfo);\n } // Get the method information\n\n\n var methodInfo = new _1.MethodInfo(methodName, methodConfig, args); // Update the target information\n\n targetInfo.bufferFl = methodConfig.requestType == _1.RequestType.GetBuffer;\n targetInfo.data = methodInfo.body;\n targetInfo.defaultToWebFl = typeof targetInfo.defaultToWebFl === \"undefined\" && base.base ? base.base.targetInfo.defaultToWebFl : targetInfo.defaultToWebFl;\n targetInfo.method = methodInfo.requestMethod;\n targetInfo.requestDigest = typeof targetInfo.requestDigest === \"undefined\" && base.base && base.base.targetInfo.requestDigest ? base.base.targetInfo.requestDigest : targetInfo.requestDigest;\n targetInfo.requestType = methodConfig.requestType; // See if we are appending the endpoint\n\n if (methodInfo.appendEndpointFl) {\n // Append to the endpoint\n targetInfo.endpoint += \".\" + methodInfo.url;\n } // Else, see if we are replacing the endpoint\n else if (methodInfo.replaceEndpointFl) {\n // Replace the endpoint\n targetInfo.endpoint = methodInfo.url;\n } // Else, ensure the method url exists\n else if (methodInfo.url && methodInfo.url.length > 0) {\n // Ensure the end point exists\n targetInfo.endpoint = targetInfo.endpoint ? targetInfo.endpoint : \"\"; // See if the endpoint exists, and the method is not a query string\n\n if (targetInfo.endpoint && methodInfo.url && methodInfo.url.indexOf(\"?\") != 0) {\n // Add a \"/\" separator to the url\n targetInfo.endpoint += \"/\";\n } // Append the url\n\n\n targetInfo.endpoint += methodInfo.url;\n } // Create a new object\n\n\n var obj = new _1.Base(targetInfo); // Set the properties\n\n obj.base = base.base ? base.base : base;\n obj.getAllItemsFl = methodInfo.getAllItemsFl;\n obj.parent = base;\n obj.requestType = methodConfig.requestType; // Ensure the return type exists\n\n if (methodConfig.returnType) {\n // Add the methods\n _1.Request.addMethods(obj, {\n __metadata: {\n type: methodConfig.returnType\n }\n });\n } // Return the object\n\n\n return obj;\n },\n // Method to return a collection\n getCollection: function getCollection(base, method, args) {\n // Copy the target information\n var targetInfo = Object.create(base.targetInfo); // Clear the target information properties from any previous requests\n\n targetInfo.data = null;\n targetInfo.method = null; // See if the metadata is defined for the base object\n\n var metadata = base[\"d\"] ? base[\"d\"].__metadata : base[\"__metadata\"];\n\n if (metadata && metadata.uri) {\n // Update the url of the target information\n targetInfo.url = metadata.uri; // Update the metadata uri\n\n exports.Helper.updateMetadataUri(base, metadata, targetInfo); // Set the endpoint\n\n targetInfo.endpoint = method;\n } else {\n // Append the method to the endpoint\n targetInfo.endpoint += \"/\" + method;\n } // Update the callback\n\n\n targetInfo.callback = args && typeof args[0] === \"function\" ? args[0] : null; // Create a new object\n\n var obj = new _1.Base(targetInfo); // Set the properties\n\n obj.base = base.base ? base.base : base;\n obj.parent = base; // Return the object\n\n return obj;\n },\n // Method to get the next set of results\n getNextSetOfResults: function getNextSetOfResults(base) {\n // Create the target information to query the next set of results\n var targetInfo = Object.create(base.targetInfo);\n targetInfo.endpoint = \"\";\n targetInfo.url = base[\"d\"].__next; // Create a new object\n\n var obj = new _1.Base(targetInfo); // Set the properties\n\n obj.base = base.base ? base.base : base;\n obj.parent = base; // Return the object\n\n return obj;\n },\n // Method to return a property of the base object\n getProperty: function getProperty(base, propertyName, requestType) {\n // Copy the target information\n var targetInfo = Object.create(base.targetInfo); // See if this is a graph request\n\n if (requestType.indexOf(\"graph\") == 0) {\n // Default the request type\n targetInfo.requestType = _1.RequestType.GraphGet;\n } // Clear the target information properties from any previous requests\n\n\n targetInfo.data = null;\n targetInfo.method = null; // See if the metadata is defined for the base object\n\n var metadata = base[\"d\"] ? base[\"d\"].__metadata : base[\"__metadata\"];\n\n if (metadata && metadata.uri) {\n // Update the url of the target information\n targetInfo.url = metadata.uri; // Update the metadata uri\n\n exports.Helper.updateMetadataUri(base, metadata, targetInfo); // Set the endpoint\n\n targetInfo.endpoint = propertyName;\n } else {\n // Append the property name to the endpoint\n targetInfo.endpoint += \"/\" + propertyName;\n } // Create a new object\n\n\n var obj = new _1.Base(targetInfo); // Set the properties\n\n obj.base = base.base ? base.base : base;\n obj.parent = base; // Add the methods\n\n requestType ? _1.Request.addMethods(obj, {\n __metadata: {\n type: requestType\n }\n }) : null; // Return the object\n\n return obj;\n },\n // Method to get the request information\n getRequestInfo: function getRequestInfo(base) {\n // Create the request, but don't execute it\n var xhr = new xhrRequest_1.XHRRequest(true, new _1.TargetInfo(base.targetInfo), null, false); // Return the request information\n\n return xhr.requestInfo;\n },\n // Method to stringify the object\n stringify: function stringify(base) {\n // Stringify the object\n return JSON.stringify({\n response: base.response,\n status: base.status,\n targetInfo: {\n accessToken: base.targetInfo.accessToken,\n bufferFl: base.targetInfo.bufferFl,\n defaultToWebFl: base.targetInfo.defaultToWebFl,\n endpoint: base.targetInfo.endpoint,\n method: base.targetInfo.method,\n overrideDefaultRequestToHostFl: base.targetInfo.overrideDefaultRequestToHostFl,\n requestDigest: base.targetInfo.requestDigest,\n requestHeader: base.targetInfo.requestHeader,\n requestInfo: base.targetInfo.requestInfo,\n requestType: base.targetInfo.requestType,\n url: base.targetInfo.url\n }\n });\n },\n // Method to update a collection object\n updateDataCollection: function updateDataCollection(obj, results) {\n // Ensure the base is a collection\n if (results) {\n // Save the results\n obj[\"results\"] = obj[\"results\"] ? obj[\"results\"].concat(results) : results; // See if only one object exists\n\n if (obj[\"results\"].length > 0) {\n var results_2 = obj[\"results\"]; // Parse the results\n\n for (var _i = 0, results_1 = results_2; _i < results_1.length; _i++) {\n var result = results_1[_i]; // Add the base methods\n\n exports.Helper.addBaseMethods(obj, result); // Update the metadata\n\n exports.Helper.updateMetadata(obj, result); // Add the methods\n\n _1.Request.addMethods(result, result);\n }\n }\n }\n },\n // Method to update the expanded collection property\n updateExpandedCollection: function updateExpandedCollection(results) {\n // Parse the results\n for (var i = 0; i < results.length; i++) {\n var result = results[i]; // See if this property was expanded\n\n if (result[\"__metadata\"]) {\n // Add the base methods\n exports.Helper.addBaseMethods(result, result); // Update the metadata\n\n exports.Helper.updateMetadata(result, result); // Add the methods\n\n _1.Request.addMethods(result, result);\n }\n }\n },\n // Method to update the expanded properties\n updateExpandedProperties: function updateExpandedProperties(base) {\n // Ensure this is an OData request\n if (base[\"results\"] == null || base.requestType != _1.RequestType.OData) {\n return;\n } // Parse the results\n\n\n for (var i = 0; i < base[\"results\"].length; i++) {\n var result = base[\"results\"][i]; // Parse the properties\n\n for (var key in result) {\n // Ensure the property exists\n var prop = result[key];\n\n if (prop) {\n // See if this is a collection\n if (prop[\"results\"] && prop[\"results\"].length > 0) {\n // Update the expanded collection\n exports.Helper.updateExpandedCollection(prop.results);\n } // Else, see if this property was expanded\n else if (prop[\"__metadata\"]) {\n // Add the base methods\n exports.Helper.addBaseMethods(result, prop); // Update the metadata\n\n exports.Helper.updateMetadata(result, prop); // Add the methods\n\n _1.Request.addMethods(prop, prop);\n }\n }\n }\n }\n },\n // Method to update the metadata\n updateMetadata: function updateMetadata(base, data) {\n // See if this is the app web\n if (lib_1.ContextInfo.isAppWeb) {\n // Get the url information\n var hostUrl = lib_1.ContextInfo.webAbsoluteUrl.toLowerCase();\n var requestUrl = data && data.__metadata && data.__metadata.uri ? data.__metadata.uri.toLowerCase() : null;\n var targetUrl = base.targetInfo && base.targetInfo.url ? base.targetInfo.url.toLowerCase() : null; // Ensure the urls exist\n\n if (hostUrl == null || requestUrl == null || targetUrl == null) {\n return;\n } // See if we need to make an update\n\n\n if (targetUrl.indexOf(hostUrl) == 0) {\n return;\n } // Update the metadata uri\n\n\n data.__metadata.uri = requestUrl.replace(hostUrl, targetUrl);\n } // See if this is a webpart definition\n\n\n if (data.__metadata && /SP.WebParts.WebPartDefinition/.test(data.__metadata.type)) {\n // Update the metadata uri\n data.__metadata.uri = data.__metadata.uri.replace(/SP.WebParts.WebPartDefinition/, base.targetInfo.endpoint + \"/getById('\") + \"')\";\n }\n },\n // Method to update the metadata uri\n updateMetadataUri: function updateMetadataUri(base, metadata, targetInfo) {\n // See if this is a field\n if (/^SP.Field/.test(metadata.type) || /^SP\\..*Field$/.test(metadata.type)) {\n // Fix the url reference\n targetInfo.url = targetInfo.url.replace(/AvailableFields/, \"fields\");\n } // Else, see if this is an event receiver\n else if (/SP.EventReceiverDefinition/.test(metadata.type)) {\n // Fix the url reference\n targetInfo.url = targetInfo.url.replace(/\\/EventReceiver\\//, \"/EventReceivers/\");\n } // Else, see if this is a tenant app\n else if (/Microsoft.SharePoint.Marketplace.CorporateCuratedGallery.CorporateCatalogAppMetadata/.test(targetInfo.url)) {\n // Fix the url reference\n targetInfo.url = targetInfo.url.split(\"Microsoft.SharePoint.Marketplace.CorporateCuratedGallery.CorporateCatalogAppMetadata\")[0] + \"web/tenantappcatalog/availableapps/getbyid('\" + base[\"ID\"] + \"')\";\n }\n }\n};\n\n//# sourceURL=webpack://gd-sprest/./build/utils/helper.js?");
789
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.Helper = void 0;\n\nvar lib_1 = __webpack_require__(/*! ../lib */ \"./build/lib/index.js\");\n\nvar _1 = __webpack_require__(/*! . */ \"./build/utils/index.js\");\n\nvar xhrRequest_1 = __webpack_require__(/*! ./xhrRequest */ \"./build/utils/xhrRequest.js\");\n/**\r\n * Request Helper\r\n */\n\n\nexports.Helper = {\n // Method to add the base references\n addBaseMethods: function addBaseMethods(base, obj) {\n // Add the base references\n obj[\"addMethods\"] = base.addMethods;\n obj[\"base\"] = base.base;\n obj[\"done\"] = base.done;\n obj[\"execute\"] = base.execute;\n obj[\"executeAndWait\"] = base.executeAndWait;\n obj[\"executeMethod\"] = base.executeMethod;\n obj[\"existsFl\"] = true;\n obj[\"getCollection\"] = base.getCollection;\n obj[\"getProperty\"] = base.getProperty;\n obj[\"parent\"] = base;\n obj[\"targetInfo\"] = base.targetInfo;\n obj[\"updateMetadataUri\"] = base.updateMetadataUri;\n obj[\"waitForRequestsToComplete\"] = base.waitForRequestsToComplete;\n },\n // Method to wait for all requests to complete, before resolving the request\n done: function done(base, resolve) {\n // Ensure the base is set\n base.base = base.base ? base.base : base; // Ensure the response index is set\n\n base.responseIndex = base.responseIndex >= 0 ? base.responseIndex : 0; // Wait for the responses to execute\n\n _1.Request.waitForRequestsToComplete(base, function () {\n var responses = base.base.responses; // Clear the responses\n\n base.base.responses = []; // Clear the wait flags\n\n base.base.waitFlags = []; // Resolve the request\n\n resolve ? resolve.apply(base, responses) : null;\n });\n },\n // Method to execute a method\n executeMethod: function executeMethod(base, methodName, methodConfig, args) {\n var targetInfo = null; // See if the metadata is defined for the base object\n\n var metadata = base[\"d\"] ? base[\"d\"].__metadata : base[\"__metadata\"];\n\n if (metadata && metadata.uri) {\n // Create the target information and use the url defined for the base object\n targetInfo = {\n url: metadata.uri\n }; // See if we are inheriting the metadata type\n\n if (methodConfig.inheritMetadataType && metadata.type) {\n // Copy the metadata type\n methodConfig.metadataType = metadata.type;\n } // Update the metadata uri\n\n\n exports.Helper.updateMetadataUri(base, metadata, targetInfo);\n } else {\n // Copy the target information\n targetInfo = Object.create(base.targetInfo);\n } // Get the method information\n\n\n var methodInfo = new _1.MethodInfo(methodName, methodConfig, args); // Update the target information\n\n targetInfo.bufferFl = methodConfig.requestType == _1.RequestType.GetBuffer;\n targetInfo.data = methodInfo.body;\n targetInfo.defaultToWebFl = typeof targetInfo.defaultToWebFl === \"undefined\" && base.base ? base.base.targetInfo.defaultToWebFl : targetInfo.defaultToWebFl;\n targetInfo.method = methodInfo.requestMethod;\n targetInfo.requestDigest = typeof targetInfo.requestDigest === \"undefined\" && base.base && base.base.targetInfo.requestDigest ? base.base.targetInfo.requestDigest : targetInfo.requestDigest;\n targetInfo.requestType = methodConfig.requestType; // See if we are appending the endpoint\n\n if (methodInfo.appendEndpointFl) {\n // Append to the endpoint\n targetInfo.endpoint += \".\" + methodInfo.url;\n } // Else, see if we are replacing the endpoint\n else if (methodInfo.replaceEndpointFl) {\n // Replace the endpoint\n targetInfo.endpoint = methodInfo.url;\n } // Else, ensure the method url exists\n else if (methodInfo.url && methodInfo.url.length > 0) {\n // Ensure the end point exists\n targetInfo.endpoint = targetInfo.endpoint ? targetInfo.endpoint : \"\"; // See if the endpoint exists, and the method is not a query string\n\n if (targetInfo.endpoint && methodInfo.url && methodInfo.url.indexOf(\"?\") != 0) {\n // Add a \"/\" separator to the url\n targetInfo.endpoint += \"/\";\n } // Append the url\n\n\n targetInfo.endpoint += methodInfo.url;\n } // Create a new object\n\n\n var obj = new _1.Base(targetInfo); // Set the properties\n\n obj.base = base.base ? base.base : base;\n obj.getAllItemsFl = methodInfo.getAllItemsFl;\n obj.parent = base;\n obj.requestType = methodConfig.requestType; // Ensure the return type exists\n\n if (methodConfig.returnType) {\n // Add the methods\n _1.Request.addMethods(obj, {\n __metadata: {\n type: methodConfig.returnType\n }\n });\n } // Return the object\n\n\n return obj;\n },\n // Method to return a collection\n getCollection: function getCollection(base, method, args) {\n // Copy the target information\n var targetInfo = Object.create(base.targetInfo); // Clear the target information properties from any previous requests\n\n targetInfo.data = null;\n targetInfo.method = null; // See if the metadata is defined for the base object\n\n var metadata = base[\"d\"] ? base[\"d\"].__metadata : base[\"__metadata\"];\n\n if (metadata && metadata.uri) {\n // Update the url of the target information\n targetInfo.url = metadata.uri; // Update the metadata uri\n\n exports.Helper.updateMetadataUri(base, metadata, targetInfo); // Set the endpoint\n\n targetInfo.endpoint = method;\n } else {\n // Append the method to the endpoint\n targetInfo.endpoint += \"/\" + method;\n } // Update the callback\n\n\n targetInfo.callback = args && typeof args[0] === \"function\" ? args[0] : null; // Create a new object\n\n var obj = new _1.Base(targetInfo); // Set the properties\n\n obj.base = base.base ? base.base : base;\n obj.parent = base; // Return the object\n\n return obj;\n },\n // Method to get the next set of results\n getNextSetOfResults: function getNextSetOfResults(base) {\n // Create the target information to query the next set of results\n var targetInfo = Object.create(base.targetInfo);\n targetInfo.endpoint = \"\";\n targetInfo.url = base[\"d\"].__next; // Create a new object\n\n var obj = new _1.Base(targetInfo); // Set the properties\n\n obj.base = base.base ? base.base : base;\n obj.parent = base; // Return the object\n\n return obj;\n },\n // Method to return a property of the base object\n getProperty: function getProperty(base, propertyName, requestType) {\n // Copy the target information\n var targetInfo = Object.create(base.targetInfo); // See if this is a graph request\n\n if (requestType.indexOf(\"graph\") == 0) {\n // Default the request type\n targetInfo.requestType = _1.RequestType.GraphGet;\n } // Clear the target information properties from any previous requests\n\n\n targetInfo.data = null;\n targetInfo.method = null; // See if the metadata is defined for the base object\n\n var metadata = base[\"d\"] ? base[\"d\"].__metadata : base[\"__metadata\"];\n\n if (metadata && metadata.uri) {\n // Update the url of the target information\n targetInfo.url = metadata.uri; // Update the metadata uri\n\n exports.Helper.updateMetadataUri(base, metadata, targetInfo); // Set the endpoint\n\n targetInfo.endpoint = propertyName;\n } else {\n // Append the property name to the endpoint\n targetInfo.endpoint += \"/\" + propertyName;\n } // Create a new object\n\n\n var obj = new _1.Base(targetInfo); // Set the properties\n\n obj.base = base.base ? base.base : base;\n obj.parent = base; // Add the methods\n\n requestType ? _1.Request.addMethods(obj, {\n __metadata: {\n type: requestType\n }\n }) : null; // Return the object\n\n return obj;\n },\n // Method to get the request information\n getRequestInfo: function getRequestInfo(base) {\n // Create the request, but don't execute it\n var xhr = new xhrRequest_1.XHRRequest(true, new _1.TargetInfo(base.targetInfo), null, false); // Return the request information\n\n return xhr.requestInfo;\n },\n // Method to stringify the object\n stringify: function stringify(base) {\n // Stringify the object\n return JSON.stringify({\n response: base.response,\n status: base.status,\n targetInfo: {\n accessToken: base.targetInfo.accessToken,\n bufferFl: base.targetInfo.bufferFl,\n defaultToWebFl: base.targetInfo.defaultToWebFl,\n endpoint: base.targetInfo.endpoint,\n method: base.targetInfo.method,\n overrideDefaultRequestToHostFl: base.targetInfo.overrideDefaultRequestToHostFl,\n requestDigest: base.targetInfo.requestDigest,\n requestHeader: base.targetInfo.requestHeader,\n requestInfo: base.targetInfo.requestInfo,\n requestType: base.targetInfo.requestType,\n url: base.targetInfo.url\n }\n });\n },\n // Method to update a collection object\n updateDataCollection: function updateDataCollection(obj, results) {\n // Ensure the base is a collection\n if (results) {\n // Save the results\n obj[\"results\"] = obj[\"results\"] ? obj[\"results\"].concat(results) : results; // See if only one object exists\n\n if (obj[\"results\"].length > 0) {\n var results_2 = obj[\"results\"]; // Parse the results\n\n for (var _i = 0, results_1 = results_2; _i < results_1.length; _i++) {\n var result = results_1[_i]; // Add the base methods\n\n exports.Helper.addBaseMethods(obj, result); // Update the metadata\n\n exports.Helper.updateMetadata(obj, result); // Add the methods\n\n _1.Request.addMethods(result, result);\n }\n }\n }\n },\n // Method to update the expanded collection property\n updateExpandedCollection: function updateExpandedCollection(base, results) {\n // Parse the results\n for (var i = 0; i < results.length; i++) {\n var result = results[i]; // See if this property was expanded\n\n if (result[\"__metadata\"]) {\n // Add the base methods\n exports.Helper.addBaseMethods(base, result); // Update the metadata\n\n exports.Helper.updateMetadata(result, result); // Add the methods\n\n _1.Request.addMethods(result, result);\n }\n }\n },\n // Method to update the expanded properties\n updateExpandedProperties: function updateExpandedProperties(base) {\n // Ensure this is an OData request\n if (base[\"results\"] == null || base.requestType != _1.RequestType.OData) {\n return;\n } // Parse the results\n\n\n for (var i = 0; i < base[\"results\"].length; i++) {\n var result = base[\"results\"][i]; // Parse the properties\n\n for (var key in result) {\n // Ensure the property exists\n var prop = result[key];\n\n if (prop) {\n // See if this is a collection\n if (prop[\"results\"] && prop[\"results\"].length > 0) {\n // Update the expanded collection\n exports.Helper.updateExpandedCollection(base, prop.results);\n } // Else, see if this property was expanded\n else if (prop[\"__metadata\"]) {\n // Add the base methods\n exports.Helper.addBaseMethods(result, prop); // Update the metadata\n\n exports.Helper.updateMetadata(result, prop); // Add the methods\n\n _1.Request.addMethods(prop, prop);\n }\n }\n }\n }\n },\n // Method to update the metadata\n updateMetadata: function updateMetadata(base, data) {\n // See if this is the app web\n if (lib_1.ContextInfo.isAppWeb) {\n // Get the url information\n var hostUrl = lib_1.ContextInfo.webAbsoluteUrl.toLowerCase();\n var requestUrl = data && data.__metadata && data.__metadata.uri ? data.__metadata.uri.toLowerCase() : null;\n var targetUrl = base.targetInfo && base.targetInfo.url ? base.targetInfo.url.toLowerCase() : null; // Ensure the urls exist\n\n if (hostUrl == null || requestUrl == null || targetUrl == null) {\n return;\n } // See if we need to make an update\n\n\n if (targetUrl.indexOf(hostUrl) == 0) {\n return;\n } // Update the metadata uri\n\n\n data.__metadata.uri = requestUrl.replace(hostUrl, targetUrl);\n } // See if this is a webpart definition\n\n\n if (data.__metadata && /SP.WebParts.WebPartDefinition/.test(data.__metadata.type)) {\n // Update the metadata uri\n data.__metadata.uri = data.__metadata.uri.replace(/SP.WebParts.WebPartDefinition/, base.targetInfo.endpoint + \"/getById('\") + \"')\";\n }\n },\n // Method to update the metadata uri\n updateMetadataUri: function updateMetadataUri(base, metadata, targetInfo) {\n // See if this is a field\n if (/^SP.Field/.test(metadata.type) || /^SP\\..*Field$/.test(metadata.type)) {\n // Fix the url reference\n targetInfo.url = targetInfo.url.replace(/AvailableFields/, \"fields\");\n } // Else, see if this is an event receiver\n else if (/SP.EventReceiverDefinition/.test(metadata.type)) {\n // Fix the url reference\n targetInfo.url = targetInfo.url.replace(/\\/EventReceiver\\//, \"/EventReceivers/\");\n } // Else, see if this is a tenant app\n else if (/Microsoft.SharePoint.Marketplace.CorporateCuratedGallery.CorporateCatalogAppMetadata/.test(targetInfo.url)) {\n // Fix the url reference\n targetInfo.url = targetInfo.url.split(\"Microsoft.SharePoint.Marketplace.CorporateCuratedGallery.CorporateCatalogAppMetadata\")[0] + \"web/tenantappcatalog/availableapps/getbyid('\" + base[\"ID\"] + \"')\";\n }\n }\n};\n\n//# sourceURL=webpack://gd-sprest/./build/utils/helper.js?");
790
790
 
791
791
  /***/ }),
792
792