gd-sprest 6.9.4 → 6.9.7

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.
@@ -361,6 +361,9 @@ export interface ISPCfgListInfo {
361
361
  /** The title display name. */
362
362
  TitleFieldDisplayName?: string;
363
363
 
364
+ /** Flag to index the title field. */
365
+ TitleFieldIndexed?: boolean;
366
+
364
367
  /** The user custom actions. */
365
368
  UserCustomActions?: Array<UserCustomActionProps>;
366
369
 
@@ -216,7 +216,10 @@ exports.ListForm = {
216
216
  }, _reject);
217
217
  }, _reject);
218
218
  }
219
+ // Else, this is a new item
219
220
  else {
221
+ // Default the attachments
222
+ _info.attachments = _props.loadAttachments ? [] : _info.attachments;
220
223
  // Resolve the promise
221
224
  _resolve(_info);
222
225
  }
@@ -307,6 +310,10 @@ exports.ListForm = {
307
310
  // Parse the fields
308
311
  for (var fieldName in info.fields) {
309
312
  var field = info.fields[fieldName];
313
+ // Skip the attachments field
314
+ if (fieldName == "Attachments") {
315
+ continue;
316
+ }
310
317
  // See if this is the file leaf ref
311
318
  if (field.InternalName == "FileLeafRef") {
312
319
  // Ensure the field is included
@@ -936,12 +936,24 @@ exports.SPConfig = function (cfg, webUrl) {
936
936
  var updateListTitleField = function (list, cfgList) {
937
937
  // Return a promise
938
938
  return new Promise(function (resolve, reject) {
939
- // See if the title field is being updated
940
- if (cfgList.TitleFieldDisplayName) {
939
+ // Ensure an update is required
940
+ if (cfgList.TitleFieldDisplayName || cfgList.TitleFieldIndexed) {
941
+ var values = {};
942
+ // See if the title field is being updated
943
+ if (cfgList.TitleFieldDisplayName) {
944
+ // Update the values
945
+ values["Title"] = cfgList.TitleFieldDisplayName;
946
+ }
947
+ // See if we are indexing the field
948
+ if (cfgList.TitleFieldIndexed) {
949
+ // Update the values
950
+ values["Indexed"] = true;
951
+ }
941
952
  // Update the field name
942
- list.Fields.getByInternalNameOrTitle("Title").update({ Title: cfgList.TitleFieldDisplayName }).execute(function () {
953
+ list.Fields.getByInternalNameOrTitle("Title").update(values).execute(function () {
943
954
  // Log
944
- console.log("[gd-sprest][List] The 'Title' field's display name was updated to '" + cfgList.TitleFieldDisplayName + "'.");
955
+ cfgList.TitleFieldDisplayName ? console.log("[gd-sprest][List] The 'Title' field's display name was updated to '" + cfgList.TitleFieldDisplayName + "'.") : null;
956
+ cfgList.TitleFieldIndexed ? console.log("[gd-sprest][List] The 'Title' field's has been indexed.") : null;
945
957
  // Resolve the promise
946
958
  resolve();
947
959
  }, reject);
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.94,
11
+ __ver: 6.97,
12
12
  AppContext: function (siteUrl) { return Lib.Site.getAppContext(siteUrl); },
13
13
  Apps: Lib.Apps,
14
14
  ContextInfo: Lib.ContextInfo,
@@ -3311,6 +3311,9 @@ declare module 'gd-sprest/helper/spCfg' {
3311
3311
  /** The title display name. */
3312
3312
  TitleFieldDisplayName?: string;
3313
3313
 
3314
+ /** Flag to index the title field. */
3315
+ TitleFieldIndexed?: boolean;
3316
+
3314
3317
  /** The user custom actions. */
3315
3318
  UserCustomActions?: Array<UserCustomActionProps>;
3316
3319
 
package/dist/gd-sprest.js CHANGED
@@ -60,7 +60,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
60
60
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
61
61
 
62
62
  "use strict";
63
- eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.ListForm = void 0;\n\nvar __1 = __webpack_require__(/*! .. */ \"./build/index.js\");\n/**\r\n * List Form\r\n */\n\n\nexports.ListForm = {\n // Method to create an instance of the list form\n create: function create(props) {\n var _info = null;\n var _props = null;\n var _reject = null;\n var _resolve = null; // Save the properties\n\n _props = props || {};\n _props.fields = _props.fields; // Method to load the list data\n\n var load = function load() {\n // Clear the information\n _info = {\n item: _props.item,\n query: _props.query || {}\n }; // Load the list data\n\n loadListData().then( // Success\n function () {\n // See if the fields have been defined\n if (_props.fields) {\n // Process the fields\n processFields(); // Load the item data\n\n loadItem();\n } else {\n // Load the content type\n loadContentType();\n }\n }, // Reject\n _reject);\n }; // Method to load a content type for the associated fields\n\n\n var loadContentType = function loadContentType() {\n // Load the content types\n _info.list.ContentTypes() // Query for the default content type and expand the field links\n .query({\n Filter: _props.contentType ? \"Name eq '\" + _props.contentType + \"'\" : null,\n Expand: [\"FieldLinks\"],\n Select: [\"*\", \"FieldLinks/DisplayName\", \"FieldLinks/Hidden\", \"FieldLinks/Name\", \"FieldLinks/ReadOnly\", \"FieldLinks/Required\"],\n Top: 1\n }) // Execute the request, but wait for the previous one to be completed\n .execute(function (ct) {\n // Resolve the promise\n loadDefaultFields(ct.results[0]);\n }, _reject);\n }; // Method to load the default fields\n\n\n var loadDefaultFields = function loadDefaultFields(ct) {\n var fields = ct ? ct.FieldLinks.results : [];\n var formFields = {};\n var formLinks = {}; // Parse the field links\n\n for (var i = 0; i < fields.length; i++) {\n var fieldLink = fields[i]; // Get the field\n\n var field = _info.fields[fieldLink.Name];\n\n if (field) {\n // Skip the content type field\n if (field.InternalName == \"ContentType\") {\n continue;\n } // Skip hidden fields\n\n\n if (field.Hidden || fieldLink.Hidden) {\n continue;\n } // Save the form field and link\n\n\n formFields[field.InternalName] = field;\n formLinks[field.InternalName] = fieldLink;\n }\n } // Update the fields\n\n\n _info.contentType = ct;\n _info.fields = formFields;\n _info.fieldLinks = formLinks; // Load the item data\n\n loadItem();\n }; // Method to load the field data\n\n\n var loadFieldData = function loadFieldData(fields) {\n // Clear the fields\n _info.fields = {}; // Parse the fields\n\n for (var i = 0; i < fields.results.length; i++) {\n var field = fields.results[i]; // See if the exclude fields is defined\n\n if (_props.excludeFields) {\n var excludeField = false; // Parse the fields to exclude\n\n for (var j = 0; j < _props.excludeFields.length; j++) {\n // See if we are excluding this field\n if (_props.excludeFields[j] == field.InternalName) {\n // Set the flag\n excludeField = true;\n break;\n }\n } // See if we are excluding the field\n\n\n if (excludeField) {\n continue;\n }\n } // Save the field\n\n\n _info.fields[field.InternalName] = field;\n }\n }; // Method to load the item\n\n\n var loadItem = function loadItem() {\n var reloadItem = false; // See if the item already exist\n\n if (_info.item) {\n // Parse the fields\n for (var fieldName in _info.fields) {\n var field = _info.fields[fieldName]; // See what type of field this is\n\n switch (field.FieldTypeKind) {\n // Lookup or User Field\n case __1.SPTypes.FieldType.Lookup:\n case __1.SPTypes.FieldType.User:\n var fieldValue = _info.item[fieldName + \"Id\"]; // Ensure the value exists\n\n if (fieldValue) {\n // See if a value exists\n if (fieldValue.results ? fieldValue.results.length > 0 : fieldValue > 0) {\n // Ensure the field data has been loaded\n if (_info.item[fieldName] == null) {\n // Set the flag\n reloadItem = true;\n }\n }\n }\n\n break;\n // Default\n\n default:\n // See if this is an taxonomy field\n if (field.TypeAsString.indexOf(\"TaxonomyFieldType\") == 0) {\n var fieldValue_1 = _info.item[fieldName + \"Id\"]; // Ensure the value exists\n\n if (fieldValue_1) {\n // See if a field value exists\n if (fieldValue_1.results ? fieldValue_1.results.length > 0 : fieldValue_1 != null) {\n // Parse the fields\n for (var fieldName_1 in _info.fields) {\n var valueField = _info.fields[fieldName_1]; // See if this is the value field\n\n if (valueField.InternalName == field.InternalName + \"_0\" || valueField.Title == field.InternalName + \"_0\") {\n // Ensure the value field is loaded\n if (_info.item[valueField.InternalName] == null) {\n // Set the flag\n reloadItem = true;\n }\n\n break;\n }\n }\n }\n }\n }\n\n break;\n } // See if we are reloading the item\n\n\n if (reloadItem) {\n break;\n }\n }\n } // See if the item exists\n\n\n if (_info.item && !reloadItem) {\n // See if we are loading attachments\n if (_props.loadAttachments && _info.attachments == null) {\n // Load the attachments\n exports.ListForm.loadAttachments(_props).then(function (attachments) {\n // Set the attachments\n _info.attachments = attachments; // Resolve the promise\n\n _resolve(_info);\n }, _reject);\n } else {\n // Resolve the promise\n _resolve(_info);\n }\n } // Else, see if we are loading the list item\n else if (reloadItem || _props.itemId > 0) {\n // Update the item query\n _info.query = exports.ListForm.generateODataQuery(_info, _props.loadAttachments); // Get the list item\n\n _info.list.Items(reloadItem ? _props.item.Id : _props.itemId) // Set the query\n .query(_info.query) // Execute the request\n .execute(function (item) {\n // Save the attachments\n _info.attachments = item.AttachmentFiles.results; // Save the item\n\n _info.item = item; // Refresh the item\n\n exports.ListForm.refreshItem(_info).then(function (info) {\n // Update the info\n _info = info; // Resolve the promise\n\n _resolve(_info);\n }, _reject);\n }, _reject);\n } else {\n // Resolve the promise\n _resolve(_info);\n }\n }; // Method to load the list data\n\n\n var loadListData = function loadListData() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the list & fields already exist\n if (_info.list && _info.fields) {\n // Resolve the promise\n resolve();\n return;\n } // Get the web\n\n\n __1.Web(_props.webUrl, {\n disableCache: true\n }) // Get the list\n .Lists(_props.listName) // Execute the request\n .execute(function (list) {\n // Save the list and web url\n _info.list = list;\n _info.webUrl = _props.webUrl;\n }, reject) // Load the fields\n .Fields() // Execute the request\n .execute(function (fields) {\n // Load the field data\n loadFieldData(fields); // Resolve the promise\n\n resolve();\n }, reject, true);\n });\n }; // Method to process the fields\n\n\n var processFields = function processFields() {\n var formFields = {}; // Parse the fields provided\n\n for (var i = 0; i < _props.fields.length; i++) {\n var field = _info.fields[_props.fields[i]]; // Ensure the field exists\n\n if (field) {\n // Save the field\n formFields[field.InternalName] = field; // See if this is a taxonomy field\n\n if (field.TypeAsString.indexOf(\"TaxonomyFieldType\") == 0) {\n // Parse the list fields\n for (var fieldName in _info.fields) {\n var valueField = _info.fields[fieldName]; // See if this is a value field\n\n if (valueField.InternalName == field.InternalName + \"_0\" || valueField.Title == field.InternalName + \"_0\") {\n // Include this field\n formFields[valueField.InternalName] = valueField;\n break;\n }\n }\n }\n }\n } // Update the fields\n\n\n _info.fields = formFields;\n }; // Return a promise\n\n\n return new Promise(function (resolve, reject) {\n // Save the methods\n _reject = reject;\n _resolve = resolve; // Load the list data\n\n load();\n });\n },\n // Method to generate the odata query\n generateODataQuery: function generateODataQuery(info, loadAttachments) {\n if (loadAttachments === void 0) {\n loadAttachments = false;\n }\n\n var query = info.query || {}; // Default the select query to get all the fields by default\n\n query.Select = query.Select || [\"*\"];\n query.Expand = query.Expand || []; // See if we are loading the attachments\n\n if (loadAttachments) {\n // Expand the attachment files collection\n query.Expand.push(\"AttachmentFiles\"); // Select the attachment files\n\n query.Select.push(\"Attachments\");\n query.Select.push(\"AttachmentFiles\");\n } // Parse the fields\n\n\n for (var fieldName in info.fields) {\n var field = info.fields[fieldName]; // See if this is the file leaf ref\n\n if (field.InternalName == \"FileLeafRef\") {\n // Ensure the field is included\n query.Select.push(\"FileLeafRef\");\n continue;\n } // Update the query, based on the type\n\n\n switch (field.FieldTypeKind) {\n // Lookup Field\n case __1.SPTypes.FieldType.Lookup:\n var lookupField = field; // See if this is an associated lookup field\n\n if (lookupField.PrimaryFieldId) {\n // Parse the form fields to find the parent field\n for (var parentFieldName in info.fields) {\n var parentField = info.fields[parentFieldName]; // See if the parent field is being loaded\n\n if (parentField.Id == lookupField.PrimaryFieldId) {\n // Select the field\n query.Select.push(parentField.InternalName + \"/\" + lookupField.LookupField);\n break;\n }\n }\n } else {\n // Expand the field\n query.Expand.push(field.InternalName); // Select the fields\n\n query.Select.push(field.InternalName + \"/Id\");\n query.Select.push(field.InternalName + \"/\" + field.LookupField);\n }\n\n break;\n // User Field\n\n case __1.SPTypes.FieldType.User:\n // Expand the field\n query.Expand.push(field.InternalName); // Select the fields\n\n query.Select.push(field.InternalName + \"/Id\");\n query.Select.push(field.InternalName + \"/Title\");\n break;\n // Default\n\n default:\n // See if this is an taxonomy field\n if (field.TypeAsString.indexOf(\"TaxonomyFieldType\") == 0) {\n // Parse the fields\n for (var fieldName_2 in info.fields) {\n var valueField = info.fields[fieldName_2]; // See if this is the value field\n\n if (valueField.InternalName == field.InternalName + \"_0\" || valueField.Title == field.InternalName + \"_0\") {\n // Include the value field\n query.Select.push(valueField.InternalName);\n break;\n }\n }\n }\n\n break;\n }\n } // Return the query\n\n\n return query;\n },\n // Method to load the item attachments\n loadAttachments: function loadAttachments(info) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure the item id exists\n var itemId = info.item ? info.item.Id : info.itemId;\n\n if (itemId > 0) {\n // Get the web\n __1.Web(info.webUrl) // Get the list\n .Lists(info.listName) // Get the item\n .Items(itemId) // Get the attachment files\n .AttachmentFiles() // Execute the request\n .execute(function (attachments) {\n // Ensure the attachments exist\n if (!attachments.existsFl) {\n // Reject the promise\n reject(attachments.response);\n return;\n } // Resolve the promise\n\n\n resolve(attachments.results || []);\n }, reject);\n } else {\n // Resolve the promise\n resolve([]);\n }\n });\n },\n // Method to refresh an item\n refreshItem: function refreshItem(info) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Update the query\n info.query = exports.ListForm.generateODataQuery(info, info.attachments ? true : false); // Get the item\n\n info.list.Items(info.item.Id).query(info.query).execute(function (item) {\n // Update the item\n info.item = item; // Get the item values\n\n info.list.Items(item.Id).query({\n Expand: [\"FieldValuesAsText\", \"Folder\"]\n }).execute(function (item) {\n // Set the values\n info.itemFolder = item.Folder;\n info.fieldValuesAsText = item.FieldValuesAsText;\n }); // Get the html values for this item\n // This is needed for complex field values\n\n info.list.Items(item.Id).FieldValuesAsHtml().execute(function (values) {\n // Set the values\n info.fieldValuesAsHtml = values; // Resolve the promise\n\n resolve(info);\n }, true);\n }, reject);\n });\n },\n // Method to remove attachments from an item\n removeAttachment: function removeAttachment(info, fileName) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure attachments exist\n if (info.attachments) {\n // Parse the attachments\n for (var i = 0; i < info.attachments.length; i++) {\n // See if this is the target attachment\n var attachment = info.attachments[i];\n\n if (attachment.FileName == fileName) {\n // Get the web\n __1.Web(info.webUrl) // Get the file\n .getFileByServerRelativeUrl(attachment.ServerRelativeUrl) // Delete the file\n [\"delete\"]() // Execute the request\n .execute(function () {\n // Resolve the promise\n resolve(info);\n }, reject); // Attachment found\n\n\n return;\n } // Attachment not found\n\n\n reject(\"Attachment '\" + fileName + \"' was not found.\");\n }\n } else {\n // Attachments not loaded\n reject(\"Attachment '\" + fileName + \"' was not found.\");\n }\n });\n },\n // Method to save attachments to an existing item\n saveAttachments: function saveAttachments(info, attachmentInfo) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var itemId = info.item ? info.item.Id : info.itemId;\n\n if (itemId > 0) {\n // Get the web\n var attachments = __1.Web(info.webUrl) // Get the lists\n .Lists(info.listName) // Get the item\n .Items(itemId) // Get the attachment files\n .AttachmentFiles(); // Parse the attachment information\n\n\n for (var i = 0; i < attachmentInfo.length; i++) {\n var attachment = attachmentInfo[i]; // Add the attachment\n\n attachments.add(attachment.name, attachment.data).execute(true);\n } // Wait for the requests to complete\n\n\n attachments.done(function () {\n var args = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n } // Resolve the promise\n\n\n resolve.apply(args);\n });\n } else {\n // Resolve the promise\n resolve(null);\n }\n });\n },\n // Method to save a new or existing item\n saveItem: function saveItem(info, formValues) {\n if (formValues === void 0) {\n formValues = {};\n } // Return a promise\n\n\n return new Promise(function (resolve, reject) {\n // See if this is an existing item\n if (info.item && info.item.update) {\n // Update the item\n info.item.update(formValues).execute(function (response) {\n // Refresh the item\n exports.ListForm.refreshItem(info).then(function (info) {\n // Resolve the promise\n resolve(info);\n }, reject);\n });\n } else {\n // Set the metadata type\n formValues[\"__metadata\"] = {\n type: info.list.ListItemEntityTypeFullName\n }; // Add the item\n\n info.list.Items().add(formValues) // Execute the request\n .execute(function (item) {\n // Update the info\n info.item = item; // Refresh the item\n\n exports.ListForm.refreshItem(info).then(function (info) {\n // Resolve the promise\n resolve(info);\n });\n }, reject);\n }\n });\n },\n // Method to show a file dialog\n showFileDialog: function showFileDialog(info, onSave) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Method to add an attachment\n var addAttachment = function addAttachment(name, data) {\n // Call the save event\n onSave ? onSave({\n name: name,\n data: data\n }) : null; // Get the list\n\n info.list // Get the item\n .Items(info.item.Id) // Get the attachments\n .AttachmentFiles() // Add the file\n .add(name, data) // Execute the request\n .execute(function () {\n // Refresh the item\n exports.ListForm.refreshItem(info).then(function (info) {\n // Remove the element\n document.body.removeChild(el); // Resolve the promise\n\n resolve(info);\n });\n }, reject);\n }; // Method to read the file\n\n\n var readFile = function readFile(ev) {\n // Get the source file\n var srcFile = ev.target[\"files\"][0];\n\n if (srcFile) {\n var reader = new FileReader(); // Set the file loaded event\n\n reader.onloadend = function (ev) {\n var attachment = null;\n var ext = srcFile.name.split(\".\");\n ext = ext[ext.length - 1].toLowerCase(); // See if the info exists\n\n if (info) {\n // Add the attachment\n addAttachment(srcFile.name, ev.target.result);\n } else {\n // Remove the element\n document.body.removeChild(el); // Resolve the promise with the file information\n\n resolve({\n data: ev.target.result,\n name: srcFile.name\n });\n }\n }; // Set the error\n\n\n reader.onerror = function (ev) {\n // Remove the element\n document.body.removeChild(el); // Reject the promise\n\n reject(ev.target.error);\n }; // Read the file\n\n\n reader.readAsArrayBuffer(srcFile);\n }\n }; // Create the file element\n\n\n var el = document.body.querySelector(\"#listform-attachment\");\n\n if (el == null) {\n el = document.createElement(\"input\"); // Set the properties\n\n el.id = \"listform-attachment\";\n el.type = \"file\";\n el.hidden = true;\n el.onchange = readFile; // Add the element to the body\n\n document.body.appendChild(el);\n } // Show the dialog\n\n\n el.click();\n });\n }\n};\n\n//# sourceURL=webpack://gd-sprest/./build/helper/listForm.js?");
63
+ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.ListForm = void 0;\n\nvar __1 = __webpack_require__(/*! .. */ \"./build/index.js\");\n/**\r\n * List Form\r\n */\n\n\nexports.ListForm = {\n // Method to create an instance of the list form\n create: function create(props) {\n var _info = null;\n var _props = null;\n var _reject = null;\n var _resolve = null; // Save the properties\n\n _props = props || {};\n _props.fields = _props.fields; // Method to load the list data\n\n var load = function load() {\n // Clear the information\n _info = {\n item: _props.item,\n query: _props.query || {}\n }; // Load the list data\n\n loadListData().then( // Success\n function () {\n // See if the fields have been defined\n if (_props.fields) {\n // Process the fields\n processFields(); // Load the item data\n\n loadItem();\n } else {\n // Load the content type\n loadContentType();\n }\n }, // Reject\n _reject);\n }; // Method to load a content type for the associated fields\n\n\n var loadContentType = function loadContentType() {\n // Load the content types\n _info.list.ContentTypes() // Query for the default content type and expand the field links\n .query({\n Filter: _props.contentType ? \"Name eq '\" + _props.contentType + \"'\" : null,\n Expand: [\"FieldLinks\"],\n Select: [\"*\", \"FieldLinks/DisplayName\", \"FieldLinks/Hidden\", \"FieldLinks/Name\", \"FieldLinks/ReadOnly\", \"FieldLinks/Required\"],\n Top: 1\n }) // Execute the request, but wait for the previous one to be completed\n .execute(function (ct) {\n // Resolve the promise\n loadDefaultFields(ct.results[0]);\n }, _reject);\n }; // Method to load the default fields\n\n\n var loadDefaultFields = function loadDefaultFields(ct) {\n var fields = ct ? ct.FieldLinks.results : [];\n var formFields = {};\n var formLinks = {}; // Parse the field links\n\n for (var i = 0; i < fields.length; i++) {\n var fieldLink = fields[i]; // Get the field\n\n var field = _info.fields[fieldLink.Name];\n\n if (field) {\n // Skip the content type field\n if (field.InternalName == \"ContentType\") {\n continue;\n } // Skip hidden fields\n\n\n if (field.Hidden || fieldLink.Hidden) {\n continue;\n } // Save the form field and link\n\n\n formFields[field.InternalName] = field;\n formLinks[field.InternalName] = fieldLink;\n }\n } // Update the fields\n\n\n _info.contentType = ct;\n _info.fields = formFields;\n _info.fieldLinks = formLinks; // Load the item data\n\n loadItem();\n }; // Method to load the field data\n\n\n var loadFieldData = function loadFieldData(fields) {\n // Clear the fields\n _info.fields = {}; // Parse the fields\n\n for (var i = 0; i < fields.results.length; i++) {\n var field = fields.results[i]; // See if the exclude fields is defined\n\n if (_props.excludeFields) {\n var excludeField = false; // Parse the fields to exclude\n\n for (var j = 0; j < _props.excludeFields.length; j++) {\n // See if we are excluding this field\n if (_props.excludeFields[j] == field.InternalName) {\n // Set the flag\n excludeField = true;\n break;\n }\n } // See if we are excluding the field\n\n\n if (excludeField) {\n continue;\n }\n } // Save the field\n\n\n _info.fields[field.InternalName] = field;\n }\n }; // Method to load the item\n\n\n var loadItem = function loadItem() {\n var reloadItem = false; // See if the item already exist\n\n if (_info.item) {\n // Parse the fields\n for (var fieldName in _info.fields) {\n var field = _info.fields[fieldName]; // See what type of field this is\n\n switch (field.FieldTypeKind) {\n // Lookup or User Field\n case __1.SPTypes.FieldType.Lookup:\n case __1.SPTypes.FieldType.User:\n var fieldValue = _info.item[fieldName + \"Id\"]; // Ensure the value exists\n\n if (fieldValue) {\n // See if a value exists\n if (fieldValue.results ? fieldValue.results.length > 0 : fieldValue > 0) {\n // Ensure the field data has been loaded\n if (_info.item[fieldName] == null) {\n // Set the flag\n reloadItem = true;\n }\n }\n }\n\n break;\n // Default\n\n default:\n // See if this is an taxonomy field\n if (field.TypeAsString.indexOf(\"TaxonomyFieldType\") == 0) {\n var fieldValue_1 = _info.item[fieldName + \"Id\"]; // Ensure the value exists\n\n if (fieldValue_1) {\n // See if a field value exists\n if (fieldValue_1.results ? fieldValue_1.results.length > 0 : fieldValue_1 != null) {\n // Parse the fields\n for (var fieldName_1 in _info.fields) {\n var valueField = _info.fields[fieldName_1]; // See if this is the value field\n\n if (valueField.InternalName == field.InternalName + \"_0\" || valueField.Title == field.InternalName + \"_0\") {\n // Ensure the value field is loaded\n if (_info.item[valueField.InternalName] == null) {\n // Set the flag\n reloadItem = true;\n }\n\n break;\n }\n }\n }\n }\n }\n\n break;\n } // See if we are reloading the item\n\n\n if (reloadItem) {\n break;\n }\n }\n } // See if the item exists\n\n\n if (_info.item && !reloadItem) {\n // See if we are loading attachments\n if (_props.loadAttachments && _info.attachments == null) {\n // Load the attachments\n exports.ListForm.loadAttachments(_props).then(function (attachments) {\n // Set the attachments\n _info.attachments = attachments; // Resolve the promise\n\n _resolve(_info);\n }, _reject);\n } else {\n // Resolve the promise\n _resolve(_info);\n }\n } // Else, see if we are loading the list item\n else if (reloadItem || _props.itemId > 0) {\n // Update the item query\n _info.query = exports.ListForm.generateODataQuery(_info, _props.loadAttachments); // Get the list item\n\n _info.list.Items(reloadItem ? _props.item.Id : _props.itemId) // Set the query\n .query(_info.query) // Execute the request\n .execute(function (item) {\n // Save the attachments\n _info.attachments = item.AttachmentFiles.results; // Save the item\n\n _info.item = item; // Refresh the item\n\n exports.ListForm.refreshItem(_info).then(function (info) {\n // Update the info\n _info = info; // Resolve the promise\n\n _resolve(_info);\n }, _reject);\n }, _reject);\n } // Else, this is a new item\n else {\n // Default the attachments\n _info.attachments = _props.loadAttachments ? [] : _info.attachments; // Resolve the promise\n\n _resolve(_info);\n }\n }; // Method to load the list data\n\n\n var loadListData = function loadListData() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the list & fields already exist\n if (_info.list && _info.fields) {\n // Resolve the promise\n resolve();\n return;\n } // Get the web\n\n\n __1.Web(_props.webUrl, {\n disableCache: true\n }) // Get the list\n .Lists(_props.listName) // Execute the request\n .execute(function (list) {\n // Save the list and web url\n _info.list = list;\n _info.webUrl = _props.webUrl;\n }, reject) // Load the fields\n .Fields() // Execute the request\n .execute(function (fields) {\n // Load the field data\n loadFieldData(fields); // Resolve the promise\n\n resolve();\n }, reject, true);\n });\n }; // Method to process the fields\n\n\n var processFields = function processFields() {\n var formFields = {}; // Parse the fields provided\n\n for (var i = 0; i < _props.fields.length; i++) {\n var field = _info.fields[_props.fields[i]]; // Ensure the field exists\n\n if (field) {\n // Save the field\n formFields[field.InternalName] = field; // See if this is a taxonomy field\n\n if (field.TypeAsString.indexOf(\"TaxonomyFieldType\") == 0) {\n // Parse the list fields\n for (var fieldName in _info.fields) {\n var valueField = _info.fields[fieldName]; // See if this is a value field\n\n if (valueField.InternalName == field.InternalName + \"_0\" || valueField.Title == field.InternalName + \"_0\") {\n // Include this field\n formFields[valueField.InternalName] = valueField;\n break;\n }\n }\n }\n }\n } // Update the fields\n\n\n _info.fields = formFields;\n }; // Return a promise\n\n\n return new Promise(function (resolve, reject) {\n // Save the methods\n _reject = reject;\n _resolve = resolve; // Load the list data\n\n load();\n });\n },\n // Method to generate the odata query\n generateODataQuery: function generateODataQuery(info, loadAttachments) {\n if (loadAttachments === void 0) {\n loadAttachments = false;\n }\n\n var query = info.query || {}; // Default the select query to get all the fields by default\n\n query.Select = query.Select || [\"*\"];\n query.Expand = query.Expand || []; // See if we are loading the attachments\n\n if (loadAttachments) {\n // Expand the attachment files collection\n query.Expand.push(\"AttachmentFiles\"); // Select the attachment files\n\n query.Select.push(\"Attachments\");\n query.Select.push(\"AttachmentFiles\");\n } // Parse the fields\n\n\n for (var fieldName in info.fields) {\n var field = info.fields[fieldName]; // Skip the attachments field\n\n if (fieldName == \"Attachments\") {\n continue;\n } // See if this is the file leaf ref\n\n\n if (field.InternalName == \"FileLeafRef\") {\n // Ensure the field is included\n query.Select.push(\"FileLeafRef\");\n continue;\n } // Update the query, based on the type\n\n\n switch (field.FieldTypeKind) {\n // Lookup Field\n case __1.SPTypes.FieldType.Lookup:\n var lookupField = field; // See if this is an associated lookup field\n\n if (lookupField.PrimaryFieldId) {\n // Parse the form fields to find the parent field\n for (var parentFieldName in info.fields) {\n var parentField = info.fields[parentFieldName]; // See if the parent field is being loaded\n\n if (parentField.Id == lookupField.PrimaryFieldId) {\n // Select the field\n query.Select.push(parentField.InternalName + \"/\" + lookupField.LookupField);\n break;\n }\n }\n } else {\n // Expand the field\n query.Expand.push(field.InternalName); // Select the fields\n\n query.Select.push(field.InternalName + \"/Id\");\n query.Select.push(field.InternalName + \"/\" + field.LookupField);\n }\n\n break;\n // User Field\n\n case __1.SPTypes.FieldType.User:\n // Expand the field\n query.Expand.push(field.InternalName); // Select the fields\n\n query.Select.push(field.InternalName + \"/Id\");\n query.Select.push(field.InternalName + \"/Title\");\n break;\n // Default\n\n default:\n // See if this is an taxonomy field\n if (field.TypeAsString.indexOf(\"TaxonomyFieldType\") == 0) {\n // Parse the fields\n for (var fieldName_2 in info.fields) {\n var valueField = info.fields[fieldName_2]; // See if this is the value field\n\n if (valueField.InternalName == field.InternalName + \"_0\" || valueField.Title == field.InternalName + \"_0\") {\n // Include the value field\n query.Select.push(valueField.InternalName);\n break;\n }\n }\n }\n\n break;\n }\n } // Return the query\n\n\n return query;\n },\n // Method to load the item attachments\n loadAttachments: function loadAttachments(info) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure the item id exists\n var itemId = info.item ? info.item.Id : info.itemId;\n\n if (itemId > 0) {\n // Get the web\n __1.Web(info.webUrl) // Get the list\n .Lists(info.listName) // Get the item\n .Items(itemId) // Get the attachment files\n .AttachmentFiles() // Execute the request\n .execute(function (attachments) {\n // Ensure the attachments exist\n if (!attachments.existsFl) {\n // Reject the promise\n reject(attachments.response);\n return;\n } // Resolve the promise\n\n\n resolve(attachments.results || []);\n }, reject);\n } else {\n // Resolve the promise\n resolve([]);\n }\n });\n },\n // Method to refresh an item\n refreshItem: function refreshItem(info) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Update the query\n info.query = exports.ListForm.generateODataQuery(info, info.attachments ? true : false); // Get the item\n\n info.list.Items(info.item.Id).query(info.query).execute(function (item) {\n // Update the item\n info.item = item; // Get the item values\n\n info.list.Items(item.Id).query({\n Expand: [\"FieldValuesAsText\", \"Folder\"]\n }).execute(function (item) {\n // Set the values\n info.itemFolder = item.Folder;\n info.fieldValuesAsText = item.FieldValuesAsText;\n }); // Get the html values for this item\n // This is needed for complex field values\n\n info.list.Items(item.Id).FieldValuesAsHtml().execute(function (values) {\n // Set the values\n info.fieldValuesAsHtml = values; // Resolve the promise\n\n resolve(info);\n }, true);\n }, reject);\n });\n },\n // Method to remove attachments from an item\n removeAttachment: function removeAttachment(info, fileName) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure attachments exist\n if (info.attachments) {\n // Parse the attachments\n for (var i = 0; i < info.attachments.length; i++) {\n // See if this is the target attachment\n var attachment = info.attachments[i];\n\n if (attachment.FileName == fileName) {\n // Get the web\n __1.Web(info.webUrl) // Get the file\n .getFileByServerRelativeUrl(attachment.ServerRelativeUrl) // Delete the file\n [\"delete\"]() // Execute the request\n .execute(function () {\n // Resolve the promise\n resolve(info);\n }, reject); // Attachment found\n\n\n return;\n } // Attachment not found\n\n\n reject(\"Attachment '\" + fileName + \"' was not found.\");\n }\n } else {\n // Attachments not loaded\n reject(\"Attachment '\" + fileName + \"' was not found.\");\n }\n });\n },\n // Method to save attachments to an existing item\n saveAttachments: function saveAttachments(info, attachmentInfo) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var itemId = info.item ? info.item.Id : info.itemId;\n\n if (itemId > 0) {\n // Get the web\n var attachments = __1.Web(info.webUrl) // Get the lists\n .Lists(info.listName) // Get the item\n .Items(itemId) // Get the attachment files\n .AttachmentFiles(); // Parse the attachment information\n\n\n for (var i = 0; i < attachmentInfo.length; i++) {\n var attachment = attachmentInfo[i]; // Add the attachment\n\n attachments.add(attachment.name, attachment.data).execute(true);\n } // Wait for the requests to complete\n\n\n attachments.done(function () {\n var args = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n } // Resolve the promise\n\n\n resolve.apply(args);\n });\n } else {\n // Resolve the promise\n resolve(null);\n }\n });\n },\n // Method to save a new or existing item\n saveItem: function saveItem(info, formValues) {\n if (formValues === void 0) {\n formValues = {};\n } // Return a promise\n\n\n return new Promise(function (resolve, reject) {\n // See if this is an existing item\n if (info.item && info.item.update) {\n // Update the item\n info.item.update(formValues).execute(function (response) {\n // Refresh the item\n exports.ListForm.refreshItem(info).then(function (info) {\n // Resolve the promise\n resolve(info);\n }, reject);\n });\n } else {\n // Set the metadata type\n formValues[\"__metadata\"] = {\n type: info.list.ListItemEntityTypeFullName\n }; // Add the item\n\n info.list.Items().add(formValues) // Execute the request\n .execute(function (item) {\n // Update the info\n info.item = item; // Refresh the item\n\n exports.ListForm.refreshItem(info).then(function (info) {\n // Resolve the promise\n resolve(info);\n });\n }, reject);\n }\n });\n },\n // Method to show a file dialog\n showFileDialog: function showFileDialog(info, onSave) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Method to add an attachment\n var addAttachment = function addAttachment(name, data) {\n // Call the save event\n onSave ? onSave({\n name: name,\n data: data\n }) : null; // Get the list\n\n info.list // Get the item\n .Items(info.item.Id) // Get the attachments\n .AttachmentFiles() // Add the file\n .add(name, data) // Execute the request\n .execute(function () {\n // Refresh the item\n exports.ListForm.refreshItem(info).then(function (info) {\n // Remove the element\n document.body.removeChild(el); // Resolve the promise\n\n resolve(info);\n });\n }, reject);\n }; // Method to read the file\n\n\n var readFile = function readFile(ev) {\n // Get the source file\n var srcFile = ev.target[\"files\"][0];\n\n if (srcFile) {\n var reader = new FileReader(); // Set the file loaded event\n\n reader.onloadend = function (ev) {\n var attachment = null;\n var ext = srcFile.name.split(\".\");\n ext = ext[ext.length - 1].toLowerCase(); // See if the info exists\n\n if (info) {\n // Add the attachment\n addAttachment(srcFile.name, ev.target.result);\n } else {\n // Remove the element\n document.body.removeChild(el); // Resolve the promise with the file information\n\n resolve({\n data: ev.target.result,\n name: srcFile.name\n });\n }\n }; // Set the error\n\n\n reader.onerror = function (ev) {\n // Remove the element\n document.body.removeChild(el); // Reject the promise\n\n reject(ev.target.error);\n }; // Read the file\n\n\n reader.readAsArrayBuffer(srcFile);\n }\n }; // Create the file element\n\n\n var el = document.body.querySelector(\"#listform-attachment\");\n\n if (el == null) {\n el = document.createElement(\"input\"); // Set the properties\n\n el.id = \"listform-attachment\";\n el.type = \"file\";\n el.hidden = true;\n el.onchange = readFile; // Add the element to the body\n\n document.body.appendChild(el);\n } // Show the dialog\n\n\n el.click();\n });\n }\n};\n\n//# sourceURL=webpack://gd-sprest/./build/helper/listForm.js?");
64
64
 
65
65
  /***/ }),
66
66
 
@@ -247,7 +247,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
247
247
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
248
248
 
249
249
  "use strict";
250
- eval("\n\nvar __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, {\n enumerable: true,\n get: function get() {\n return m[k];\n }\n });\n} : function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nvar __exportStar = this && this.__exportStar || function (m, exports) {\n for (var p in m) {\n if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n }\n};\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.SPConfig = void 0;\n\nvar lib_1 = __webpack_require__(/*! ../lib */ \"./build/lib/index.js\");\n\nvar __1 = __webpack_require__(/*! .. */ \"./build/index.js\");\n\nvar _1 = __webpack_require__(/*! . */ \"./build/helper/index.js\");\n\n__exportStar(__webpack_require__(/*! ./spCfgTypes */ \"./build/helper/spCfgTypes.js\"), exports);\n/**\r\n * SharePoint Configuration\r\n */\n\n\nexports.SPConfig = function (cfg, webUrl) {\n // The selected configuration type to install\n var _cfgType; // The request digest\n\n\n var _requestDigest = null; // The target name to install/uninstall\n\n var _targetName;\n /**\r\n * Methods\r\n */\n // Method to create the content types\n\n\n var createContentTypes = function createContentTypes(contentTypes, cfgContentTypes, list) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure fields exist\n if (cfgContentTypes == null || cfgContentTypes.length == 0) {\n // Resolve the promise\n resolve();\n return;\n } // Method to get the parent content type\n\n\n var getParentCT = function getParentCT(ctName, url) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Get the web containing the parent content type\n lib_1.Web(url, {\n disableCache: true\n }) // Get the content types\n .ContentTypes() // Filter for the parent name\n .query({\n Filter: \"Name eq '\" + ctName + \"'\"\n }) // Execute the request\n .execute(function (cts) {\n // See if the parent exists\n if (cts.results[0]) {\n // Resolve the promise\n resolve({\n Id: cts.results[0].Id.StringValue,\n Url: url\n });\n } // Else, ensure this isn't the root web\n else if (url != lib_1.ContextInfo.siteServerRelativeUrl) {\n // Check the root web for the parent content type\n getParentCT(ctName, lib_1.ContextInfo.siteServerRelativeUrl).then(resolve, reject);\n } else {\n // Reject the promise\n reject();\n }\n }, reject);\n });\n }; // Parse the configuration\n\n\n _1.Executor(cfgContentTypes, function (cfg) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if this content type already exists\n var ct = isInCollection(\"Name\", cfg.Name, contentTypes.results);\n\n if (ct) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' already exists.\"); // Update the configuration\n\n cfg.ContentType = ct; // Resolve the promise and return\n\n resolve(cfg);\n return;\n } // Log\n\n\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] Creating the '\" + cfg.Name + \"' content type.\"); // See if the parent name exists\n\n if (cfg.ParentName) {\n getParentCT(cfg.ParentName, cfg.ParentWebUrl || webUrl).then( // Success\n function (parentInfo) {\n // Add the content type\n _1.createContentType({\n Description: cfg.Description,\n Group: cfg.Group,\n Name: cfg.Name\n }, parentInfo, webUrl, list ? list.Title : null).then( // Success\n function (ct) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' was created successfully.\"); // Update the configuration\n\n cfg.ContentType = ct; // Trigger the event\n\n cfg.onCreated ? cfg.onCreated(ct, list) : null; // Resolve the promise\n\n resolve(cfg);\n }, // Error\n function (error) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' failed to be created.\", error); // Reject the promise\n\n reject(error);\n });\n }, // Error\n function () {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The parent content type '\" + cfg.ParentName + \"' was not found.\"); // Reject the promise\n\n reject(ct.response);\n });\n } else {\n // Create the content type\n contentTypes.add({\n Description: cfg.Description,\n Group: cfg.Group,\n Name: cfg.Name,\n Id: {\n __metadata: {\n type: \"SP.ContentTypeId\"\n },\n StringValue: cfg.Id || \"0x0100\" + lib_1.ContextInfo.generateGUID().replace(/-/g, \"\")\n }\n }).execute( // Success\n function (ct) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' was created successfully.\"); // Update the configuration\n\n cfg.ContentType = ct; // Trigger the event\n\n cfg.onCreated ? cfg.onCreated(ct, list) : null; // Resolve the promise\n\n resolve(cfg);\n }, // Error\n function (error) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' failed to be created.\");\n console.error(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] Error: \" + error.response); // Reject the promise\n\n reject(error.response);\n });\n }\n });\n }).then(function () {\n // Parse the configuration\n _1.Executor(cfgContentTypes, function (cfgContentType) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var cfgUpdate = {};\n var updateFl = false; // Ensure the content type exists\n\n if (cfgContentType.ContentType == null) {\n // Skip this content type\n resolve(null);\n return;\n } // Log\n\n\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] Updating the field references for: \" + cfgContentType.Name); // Create the field refs\n\n _1.setContentTypeFields({\n fields: cfgContentType.FieldRefs,\n id: cfgContentType.ContentType.Id.StringValue,\n listName: list ? list.Title : null,\n webUrl: webUrl\n }).then(function () {\n /**\r\n * See if we need to update the properties\r\n */\n // Description\n if (cfgContentType.Description != null && cfgContentType.ContentType.Description != cfgContentType.Description) {\n // Update the configuration\n cfgUpdate.Description = cfgContentType.Description; // Set the flag\n\n updateFl = true;\n } // Group\n\n\n if (cfgContentType.Group != null && cfgContentType.ContentType.Group != cfgContentType.Group) {\n // Update the configuration\n cfgUpdate.Group = cfgContentType.Group; // Set the flag\n\n updateFl = true;\n } // JSLink\n\n\n if (cfgContentType.JSLink != null && cfgContentType.ContentType.JSLink != cfgContentType.JSLink) {\n // Update the configuration\n cfgUpdate.JSLink = cfgContentType.JSLink; // Set the flag\n\n updateFl = true;\n } // Name\n\n\n if (cfgContentType.Name != null && cfgContentType.ContentType.Name != cfgContentType.Name) {\n // Update the configuration\n cfgUpdate.Name = cfgContentType.Name; // Set the flag\n\n updateFl = true;\n } // See if an update is needed\n\n\n if (updateFl) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type][\" + cfgContentType.ContentType.Name + \"] Updating the content type.\"); // Update the content type\n\n cfgContentType.ContentType.update(cfgUpdate).execute(function () {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type][\" + cfgContentType.ContentType.Name + \"] Update request completed.\"); // Trigger the event\n\n cfgContentType.onUpdated ? cfgContentType.onUpdated(cfgContentType.ContentType) : null; // Resolve this request\n\n resolve(null);\n }, reject);\n } else {\n // Trigger the event\n cfgContentType.onUpdated ? cfgContentType.onUpdated(cfgContentType.ContentType) : null; // Resolve this request\n\n resolve(null);\n }\n }, reject);\n });\n }).then(resolve);\n }, reject);\n });\n }; // Method to create the fields`\n\n\n var createFields = function createFields(fields, cfgFields, list) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var newFields = []; // Ensure fields exist\n\n if (cfgFields == null || cfgFields.length == 0) {\n // Resolve the promise\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgFields, function (cfg) {\n return new Promise(function (resolve, reject) {\n // See if this field already exists\n var field = isInCollection(\"InternalName\", cfg.name, fields.results);\n\n if (field) {\n // Log\n console.log(\"[gd-sprest][Field] The field '\" + cfg.name + \"' already exists.\"); // Trigger the event\n\n cfg.onUpdated ? cfg.onUpdated(field, list) : null; // Resolve the promise\n\n resolve(null);\n } else {\n // Log\n console.log(\"[gd-sprest][Field] Creating the '\" + cfg.name + \"' field.\"); // See if this is an associated lookup field\n\n var cfgLookup = cfg;\n\n if (cfgLookup.type == _1.SPCfgFieldType.Lookup && cfgLookup.fieldRef) {\n // Get the field reference\n var fieldRef = isInCollection(\"InternalName\", cfgLookup.fieldRef, fields.results) || isInCollection(\"InternalName\", cfgLookup.fieldRef, newFields);\n\n if (fieldRef) {\n // Update the value to be the guid\n cfgLookup.fieldRef = fieldRef.Id;\n }\n } // Compute the schema xml\n\n\n _1.FieldSchemaXML(cfg).then(function (response) {\n var schemas = typeof response === \"string\" ? [response] : response; // Parse the fields to add\n\n for (var i = 0; i < schemas.length; i++) {\n // Add the field\n fields.createFieldAsXml(schemas[i]).execute(function (field) {\n // See if it was successful\n if (field.InternalName) {\n // Log\n console.log(\"[gd-sprest][Field] The field '\" + field.InternalName + \"' was created successfully.\"); // Save a reference to the field\n\n newFields.push(field); // Trigger the event\n\n cfg.onCreated ? cfg.onCreated(field, list) : null; // Resolve the promise\n\n resolve(null);\n } else {\n // Log\n console.log(\"[gd-sprest][Field] The field '\" + cfg.name + \"' failed to be created.\");\n console.error(\"[gd-sprest][Field] Error: \" + field.response); // Reject the promise\n\n reject();\n }\n });\n }\n });\n }\n });\n }).then(resolve);\n });\n }; // Method to create the lists\n\n\n var createLists = function createLists(lists, cfgLists) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Execute code against each list configuration\n _1.Executor(cfgLists, function (cfgList) {\n // Return a promise\n return new Promise(function (resolve) {\n // See if the target name exists and matches this list\n if (_cfgType && _targetName) {\n // Ensure it's for this list\n if (cfgList.ListInformation.Title.toLowerCase() != _targetName) {\n // Do nothing\n resolve(null);\n return;\n }\n } // See if this list already exists\n\n\n var list = isInCollection(\"Title\", cfgList.ListInformation.Title, lists.results);\n\n if (list) {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + cfgList.ListInformation.Title + \"' already exists.\"); // Resolve the promise and do nothing\n\n resolve(null);\n return;\n } // Log\n\n\n console.log(\"[gd-sprest][List] Creating the '\" + cfgList.ListInformation.Title + \"' list.\"); // Update the list name and remove spaces\n\n var listInfo = cfgList.ListInformation;\n var listName = listInfo.Title;\n listInfo.Title = listName.replace(/ /g, \"\"); // Add the list\n\n lists.add(listInfo) // Execute the request\n .execute(function (list) {\n // Restore the list name in the configuration\n listInfo.Title = listName; // See if the request was successful\n\n if (list.Id) {\n // See if we need to update the list\n if (list.Title != listName) {\n // Update the list\n list.update({\n Title: listName\n }).execute(function () {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + list.Title + \"' was created successfully.\"); // Resolve the promise\n\n resolve(null);\n });\n } else {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + list.Title + \"' was created successfully.\"); // Resolve the promise\n\n resolve(null);\n } // Trigger the event\n\n\n cfgList.onCreated ? cfgList.onCreated(list) : null;\n } else {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + listInfo.Title + \"' failed to be created.\");\n console.log(\"[gd-sprest][List] Error: '\" + list.response); // Resolve the promise\n\n resolve(null);\n }\n }, reject);\n });\n }).then(function () {\n // Update the lists\n updateLists(cfgLists).then(function () {\n // Resolve the promise\n resolve();\n });\n });\n });\n }; // Method to create the user custom actions\n\n\n var createUserCustomActions = function createUserCustomActions(customActions, cfgCustomActions) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the configuration type exists\n if (_cfgType) {\n // Ensure it's for this type\n if (_cfgType != _1.SPCfgType.SiteUserCustomActions || _cfgType != _1.SPCfgType.WebUserCustomActions) {\n // Resolve the promise\n resolve();\n return;\n }\n } // Ensure the lists exist\n\n\n if (cfgCustomActions == null || cfgCustomActions.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgCustomActions, function (cfg) {\n // See if the target name exists\n if (_cfgType && _targetName) {\n // Ensure it's for this custom action\n if (cfg.Name.toLowerCase() != _targetName || cfg.Title.toLowerCase() != _targetName) {\n // Skip this custom action\n return;\n }\n } // See if this custom action already exists\n\n\n if (isInCollection(\"Name\", cfg.Name, customActions.results)) {\n // Log\n console.log(\"[gd-sprest][Custom Action] The custom action '\" + cfg.Name + \"' already exists.\");\n } else {\n // See if rights exist\n if (cfg.Rights) {\n // Update the value\n cfg.Rights = updateBasePermissions(cfg.Rights);\n } // Add the custom action\n\n\n customActions.add(cfg).execute(function (ca) {\n // Ensure it exists\n if (ca.existsFl) {\n // Log\n console.log(\"[gd-sprest][Custom Action] The custom action '\" + ca.Name + \"' was created successfully.\");\n } else {\n // Log\n console.log(\"[gd-sprest][Custom Action] The custom action '\" + ca.Name + \"' failed to be created.\");\n console.log(\"[gd-sprest][Custom Action] Error: \" + ca.response);\n }\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to create the list views\n\n\n var createViews = function createViews(list, views, cfgViews) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure the list views exist\n if (cfgViews == null || cfgViews.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgViews, function (cfg) {\n // See if this view exists\n var view = isInCollection(\"Title\", cfg.ViewName, views.results);\n\n if (view) {\n // Log\n console.log(\"[gd-sprest][View] The view '\" + cfg.ViewName + \"' already exists.\");\n } else {\n // Add the view\n views.add({\n Title: cfg.ViewName,\n ViewQuery: cfg.ViewQuery\n }).execute(function (view) {\n // Ensure it exists\n if (view.existsFl) {\n // Log\n console.log(\"[gd-sprest][View] The view '\" + cfg.ViewName + \"' was created successfully.\"); // Trigger the event\n\n cfg.onCreated ? cfg.onCreated(view, list) : null;\n } else {\n // Log\n console.log(\"[gd-sprest][View] The view '\" + cfg.ViewName + \"' failed to be created.\");\n console.log(\"[gd-sprest][View] Error: \" + view.response);\n }\n }, reject, true);\n }\n }).then(function () {\n // Update the views\n updateViews(list, views, cfgViews).then(function () {\n // Resolve the promise\n resolve();\n });\n });\n });\n }; // Method to create the web parts\n\n\n var createWebParts = function createWebParts() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var cfgWebParts = cfg.WebPartCfg; // Ensure fields exist\n\n if (cfgWebParts == null || cfgWebParts.length == 0) {\n // Resolve the promise\n resolve();\n return;\n } // Log\n\n\n console.log(\"[gd-sprest][WebPart] Creating the web parts.\"); // Get the web\n\n lib_1.Web(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }) // Get the web part catalog\n .getCatalog(__1.SPTypes.ListTemplateType.WebPartCatalog) // Get the root folder\n .RootFolder() // Expand the files and items\n .query({\n Expand: [\"Files\"]\n }) // Execute the request\n .execute(function (folder) {\n var ctr = 0;\n\n var _loop_1 = function _loop_1(i) {\n var cfgWebPart = cfgWebParts[i]; // See if the target name exists\n\n if (_cfgType && _targetName) {\n // Ensure it's for this list\n if (cfgWebPart.FileName.toLowerCase() != _targetName) {\n return \"continue\";\n }\n } // The post execute method\n\n\n var postExecute = function postExecute() {\n // Increment the counter\n if (++ctr >= cfgWebParts.length) {\n // Resolve the promise\n resolve();\n }\n }; // See if this webpart exists\n\n\n var file = isInCollection(\"Name\", cfgWebPart.FileName, folder.Files.results);\n\n if (file.Name) {\n // Log\n console.log(\"[gd-sprest][WebPart] The webpart '\" + cfgWebPart.FileName + \"' already exists.\"); // Trigger the event\n\n cfgWebPart.onUpdated ? cfgWebPart.onUpdated(file) : null; // Execute the post event\n\n postExecute();\n } else {\n // Trim the xml\n var xml = cfgWebPart.XML.trim(); // Convert the string to an array buffer\n\n var buffer = new ArrayBuffer(xml.length * 2);\n var bufferView = new Uint16Array(buffer);\n\n for (var j = 0; j < xml.length; j++) {\n bufferView[j] = xml.charCodeAt(j);\n } // Create the webpart, but execute the requests one at a time\n\n\n folder.Files.add(cfgWebPart.FileName, true, buffer).execute( // Success\n function (file) {\n // See if group exists\n if (cfgWebPart.Group) {\n // Set the target to the root web\n lib_1.Web(lib_1.ContextInfo.siteServerRelativeUrl, {\n disableCache: true\n }) // Get the web part catalog\n .getCatalog(__1.SPTypes.ListTemplateType.WebPartCatalog) // Get the Items\n .Items() // Query for this webpart\n .query({\n Filter: \"FileLeafRef eq '\" + cfgWebPart.FileName + \"'\"\n }) // Execute the request\n .execute(function (items) {\n // Update the item\n items.results[0].update({\n Group: cfgWebPart.Group\n }).execute(postExecute);\n });\n } // Log\n\n\n console.log(\"[gd-sprest][WebPart] The '\" + file.Name + \"' webpart file was uploaded successfully.\"); // Trigger the event\n\n cfgWebPart.onCreated ? cfgWebPart.onCreated(file) : null;\n }, // Error\n function () {\n // Log\n console.log(\"[gd-sprest][WebPart] The '\" + file.Name + \"' webpart file upload failed.\"); // Skip this webpart\n\n resolve();\n });\n }\n }; // Parse the configuration\n\n\n for (var i = 0; i < cfgWebParts.length; i++) {\n _loop_1(i);\n }\n }, reject);\n });\n }; // Method to see if an object exists in a collection\n\n\n var isInCollection = function isInCollection(key, value, collection) {\n // Ensure a value exists\n if (value) {\n var valueLower = value ? value.toLowerCase() : \"\"; // Parse the collection\n\n for (var i = 0; i < collection.length; i++) {\n var keyValue = collection[i][key];\n keyValue = keyValue ? keyValue.toLowerCase() : \"\"; // See if the item exists\n\n if (valueLower == keyValue) {\n // Return true\n return collection[i];\n }\n }\n } // Not in the collection\n\n\n return false;\n }; // Method to remove the content type\n\n\n var removeContentTypes = function removeContentTypes(contentTypes, cfgContentTypes) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure the content types exist\n if (cfgContentTypes == null || cfgContentTypes.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgContentTypes, function (cfg) {\n // Get the field\n var ct = isInCollection(\"Name\", cfg.Name, contentTypes.results);\n\n if (ct) {\n // Remove the field\n ct[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][Content Type] The content type '\" + ct.Name + \"' was removed.\");\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to remove the fields\n\n\n var removeFields = function removeFields(fields, cfgFields) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure the fields exist\n if (cfgFields == null || cfgFields.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgFields, function (cfg) {\n // Get the field\n var field = isInCollection(\"InternalName\", cfg.name, fields.results);\n\n if (field) {\n // Remove the field\n field[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][Field] The field '\" + field.InternalName + \"' was removed.\");\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to remove the lists\n\n\n var removeLists = function removeLists(lists, cfgLists) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the configuration type exists\n if (_cfgType) {\n // Ensure it's for this type\n if (_cfgType != _1.SPCfgType.Lists) {\n // Resolve the promise\n resolve();\n return;\n }\n } // Ensure the lists exist\n\n\n if (cfgLists == null || cfgLists.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgLists, function (cfg) {\n // See if the target name exists\n if (_cfgType && _targetName) {\n // Ensure it's for this list\n if (cfg.ListInformation.Title.toLowerCase() != _targetName) {\n // Skip this list\n return;\n }\n } // Get the list\n\n\n var list = isInCollection(\"Title\", cfg.ListInformation.Title, lists.results);\n\n if (list) {\n // Remove the list\n list[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + list.Title + \"' was removed.\");\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to remove the user custom actions\n\n\n var removeUserCustomActions = function removeUserCustomActions(customActions, cfgCustomActions) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the configuration type exists\n if (_cfgType) {\n // Ensure it's for this type\n if (_cfgType != _1.SPCfgType.SiteUserCustomActions || _cfgType != _1.SPCfgType.WebUserCustomActions) {\n // Resolve the promise\n resolve();\n return;\n }\n } // Ensure the custom actions exist\n\n\n if (cfgCustomActions == null || cfgCustomActions.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgCustomActions, function (cfg) {\n // See if the target name exists\n if (_cfgType && _targetName) {\n // Ensure it's for this custom action\n if (cfg.Name.toLowerCase() != _targetName || cfg.Title.toLowerCase() != _targetName) {\n // Skip this custom action\n return;\n }\n } // Get the custom action\n\n\n var ca = isInCollection(\"Name\", cfg.Name, customActions.results);\n\n if (ca) {\n // Remove the custom action\n ca[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][Custom Action] The custom action '\" + ca.Name + \"' was removed.\");\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to remove the web parts\n\n\n var removeWebParts = function removeWebParts(site) {\n var cfgWebParts = cfg.WebPartCfg; // Return a promise\n\n return new Promise(function (resolve, reject) {\n // See if the configuration type exists\n if (_cfgType) {\n // Ensure it's for this type\n if (_cfgType != _1.SPCfgType.WebParts) {\n // Resolve the promise\n resolve();\n return;\n }\n } // Ensure the configuration exists\n\n\n if (cfgWebParts == null || cfgWebParts.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Log\n\n\n console.log(\"[gd-sprest][WebPart] Removing the web parts.\"); // Get the webpart gallery from the root web\n\n site.RootWeb().getCatalog(__1.SPTypes.ListTemplateType.WebPartCatalog) // Get the root folder\n .RootFolder() // Expand the files\n .Files() // Execute the request\n .execute(function (files) {\n var _loop_2 = function _loop_2(i) {\n var cfgWebPart = cfgWebParts[i]; // See if the target name exists\n\n if (_cfgType && _targetName) {\n // Ensure it's for this webpart\n if (cfgWebPart.FileName.toLowerCase() != _targetName) {\n return \"continue\";\n }\n } // Get the file\n\n\n var file = isInCollection(\"Name\", cfgWebPart.FileName, files.results);\n\n if (file) {\n // Remove the file\n file[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][WebPart] The webpart '\" + file.Name + \"' file was removed.\");\n }, true);\n }\n }; // Parse the configuration\n\n\n for (var i = 0; i < cfgWebParts.length; i++) {\n _loop_2(i);\n } // Resolve the promise\n\n\n resolve();\n }, reject);\n });\n }; // Method to get the web information\n\n\n var setRequestDigest = function setRequestDigest() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n if (webUrl) {\n // Get the web context information\n lib_1.ContextInfo.getWeb(webUrl).execute(function (webInfo) {\n _requestDigest = webInfo.GetContextWebInformation.FormDigestValue; // Resolve the promise\n\n resolve();\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Method to update the base permissions\n\n\n var updateBasePermissions = function updateBasePermissions(values) {\n var high = values.High;\n var low = values.Low; // See if this is an array\n\n for (var i = 0; i < values[\"length\"]; i++) {\n var value = values[i]; // See if this is the full mask\n\n if (value == 65) {\n // Set the values\n low = 65535;\n high = 32767; // Break from the loop\n\n break;\n } // Else, see if it's empty\n else if (value == 0) {\n // Clear the values\n low = 0;\n high = 0;\n } // Else, update the base permission\n else {\n var bit = value - 1;\n var bitValue = 1; // Validate the bit\n\n if (bit < 0) {\n continue;\n } // See if it's a low permission\n\n\n if (bit < 32) {\n // Compute the value\n bitValue = bitValue << bit; // Set the low value\n\n low |= bitValue;\n } // Else, it's a high permission\n else {\n // Compute the value\n bitValue = bitValue << bit - 32; // Set the high value\n\n high |= bitValue;\n }\n }\n } // Return the base permission\n\n\n return {\n Low: low.toString(),\n High: high.toString()\n };\n }; // Method to update the lists\n\n\n var updateLists = function updateLists(cfgLists) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var request = function request(idx, resolve) {\n // Get the list configuration\n var cfgList = cfgLists[idx]; // See if the target name exists\n\n if (_targetName) {\n // Ensure it's for this list\n if (cfgList.ListInformation.Title.toLowerCase() != _targetName) {\n // Update the next list\n request(idx + 1, resolve);\n return;\n }\n } // Ensure the configuration exists\n\n\n if (cfgList) {\n // Get the web\n lib_1.Web(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }) // Get the list\n .Lists(cfgList.ListInformation.Title) // Expand the content types, fields and views\n .query({\n Expand: [\"ContentTypes\", \"Fields\", \"UserCustomActions\", \"Views\"]\n }) // Execute the request\n .execute(function (list) {\n // Update the title field\n updateListTitleField(list, cfgList).then(function () {\n // Create the fields\n createFields(list.Fields, cfgList.CustomFields, list).then(function () {\n // Create the content types\n createContentTypes(list.ContentTypes, cfgList.ContentTypes, list).then(function () {\n // Update the views\n createViews(list, list.Views, cfgList.ViewInformation).then(function () {\n // Update the views\n createUserCustomActions(list.UserCustomActions, cfgList.UserCustomActions).then(function () {\n // Trigger the event\n cfgList.onUpdated ? cfgList.onUpdated(list) : null; // Update the next list\n\n request(idx + 1, resolve);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n }; // Execute the request\n\n\n request(0, resolve);\n });\n }; // Method to update the list title field\n\n\n var updateListTitleField = function updateListTitleField(list, cfgList) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the title field is being updated\n if (cfgList.TitleFieldDisplayName) {\n // Update the field name\n list.Fields.getByInternalNameOrTitle(\"Title\").update({\n Title: cfgList.TitleFieldDisplayName\n }).execute(function () {\n // Log\n console.log(\"[gd-sprest][List] The 'Title' field's display name was updated to '\" + cfgList.TitleFieldDisplayName + \"'.\"); // Resolve the promise\n\n resolve();\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Method to update the views\n\n\n var updateViews = function updateViews(list, views, cfgViews) {\n // Return a promise\n return new Promise(function (resolve) {\n // Parse the configuration\n _1.Executor(cfgViews, function (cfg) {\n // Return a promise\n return new Promise(function (resolve) {\n // Get the view\n var view = views.getByTitle(cfg.ViewName); // See if the view fields are defined\n\n if (cfg.ViewFields && cfg.ViewFields.length > 0) {\n // Log\n console.log(\"[gd-sprest][View] Updating the view fields for the '\" + cfg.ViewName + \"' view.\"); // Clear the view fields\n\n view.ViewFields().removeAllViewFields().execute(true); // Parse the view fields\n\n for (var i = 0; i < cfg.ViewFields.length; i++) {\n // Add the view field\n view.ViewFields().addViewField(cfg.ViewFields[i]).execute(true);\n }\n } // See if we are updating the view properties\n\n\n if (cfg.JSLink || cfg.ViewQuery) {\n var props = {}; // Log\n\n console.log(\"[gd-sprest][View] Updating the view properties for the '\" + cfg.ViewName + \"' view.\"); // Set the properties\n\n cfg.JSLink ? props[\"JSLink\"] = cfg.JSLink : null;\n cfg.ViewQuery ? props[\"ViewQuery\"] = cfg.ViewQuery : null; // Update the view\n\n view.update(props).execute(true);\n } // Wait for the requests to complete\n\n\n view.done(function () {\n var args = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n } // Log\n\n\n console.log(\"[gd-sprest][View] The updates for the '\" + cfg.ViewName + \"' view has completed.\"); // Trigger the event\n\n cfg.onUpdated ? cfg.onUpdated(view, list) : null; // Resolve the promise\n\n resolve(null);\n });\n });\n }).then(resolve);\n });\n }; // Method to uninstall the site components\n\n\n var uninstallSite = function uninstallSite() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure we need to complete this request\n if (cfg.CustomActionCfg != null && cfg.CustomActionCfg.Site != null || cfg.WebPartCfg != null) {\n // Log\n console.log(\"[gd-sprest][uninstall] Loading the site information...\"); // Get the site\n\n lib_1.Site(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }) // Expand the user custom actions\n .query({\n Expand: [\"UserCustomActions\"]\n }) // Execute the request\n .execute(function (site) {\n // Remove the user custom actions\n removeUserCustomActions(site.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Site : []).then(function () {\n // Remove the webpart\n removeWebParts(site).then(function () {\n // Resolve the promise\n resolve(site);\n }, reject);\n });\n }, reject);\n } else {\n // Resolve the promise\n resolve(null);\n }\n });\n }; // Method to uninstall the web components\n\n\n var uninstallWeb = function uninstallWeb() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var Expand = []; // Log\n\n console.log(\"[gd-sprest][uninstall] Loading the web information...\"); // Set the query\n\n if (cfg.ContentTypes) {\n Expand.push(\"ContentTypes\");\n }\n\n if (cfg.CustomActionCfg) {\n Expand.push(\"UserCustomActions\");\n }\n\n if (cfg.Fields) {\n Expand.push(\"Fields\");\n }\n\n if (cfg.ListCfg) {\n Expand.push(\"Lists\");\n } // Query the web\n\n\n lib_1.Web(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }).query({\n Expand: Expand\n }) // Execute the request\n .execute(function (web) {\n // Remove the web custom actions\n removeUserCustomActions(web.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Web : null).then(function () {\n // Remove the lists\n removeLists(web.Lists, cfg.ListCfg).then(function () {\n // Remove the content types\n removeContentTypes(web.ContentTypes, cfg.ContentTypes).then(function () {\n // Remove the fields\n removeFields(web.Fields, cfg.Fields).then(function () {\n // Resolve the promise\n resolve();\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n });\n };\n /**\r\n * Public Interface\r\n */\n\n\n return {\n // The configuration\n _configuration: cfg,\n // Method to install the configuration\n install: function install() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Set the request digest\n setRequestDigest().then(function () {\n // Log\n console.log(\"[gd-sprest] Installing the web assets...\"); // Get the web\n\n var web = lib_1.Web(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }); // Create the site fields\n\n var createSiteFields = function createSiteFields() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are creating fields\n if (cfg.Fields && cfg.Fields.length > 0) {\n // Log\n console.log(\"[gd-sprest][Fields] Starting the requests.\"); // Get the fields\n\n web.Fields().execute(function (fields) {\n // Create the fields\n createFields(fields, cfg.Fields).then(function () {\n // Log\n console.log(\"[gd-sprest][Fields] Completed the requests.\"); // Resolve the promise\n\n resolve(null);\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve(null);\n }\n });\n }; // Create the site content types\n\n\n var createSiteContentTypes = function createSiteContentTypes() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are creating the content types\n if (cfg.ContentTypes && cfg.ContentTypes.length > 0) {\n // Log\n console.log(\"[gd-sprest][Content Types] Starting the requests.\"); // Get the content types\n\n web.ContentTypes().execute(function (contentTypes) {\n // Create the content types\n createContentTypes(contentTypes, cfg.ContentTypes).then(function () {\n // Log\n console.log(\"[gd-sprest][Content Types] Completed the requests.\"); // Resolve the promise\n\n resolve();\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the site lists\n\n\n var createSiteLists = function createSiteLists() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are creating the lists\n if (cfg.ListCfg && cfg.ListCfg.length) {\n // Log\n console.log(\"[gd-sprest][Lists] Starting the requests.\"); // Get the lists\n\n web.Lists().execute(function (lists) {\n // Create the lists\n createLists(lists, cfg.ListCfg).then(function () {\n // Log\n console.log(\"[gd-sprest][Lists] Completed the requests.\"); // Resolve the promise\n\n resolve();\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the site webparts\n\n\n var createSiteWebParts = function createSiteWebParts() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are creating the webparts\n if (cfg.WebPartCfg && cfg.WebPartCfg.length > 0) {\n // Log\n console.log(\"[gd-sprest][WebParts] Starting the requests.\"); // Create the webparts\n\n createWebParts().then(function () {\n // Log\n console.log(\"[gd-sprest][WebParts] Completed the requests.\"); // Resolve the promise\n\n resolve();\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the custom actions\n\n\n var createSiteCollectionCustomActions = function createSiteCollectionCustomActions() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are targeting the site collection\n if (cfg.CustomActionCfg && cfg.CustomActionCfg.Site) {\n // Log\n console.log(\"[gd-sprest][Site Custom Actions] Starting the requests.\"); // Get the site\n\n lib_1.Site(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }) // Get the user custom actions\n .UserCustomActions().execute(function (customActions) {\n // Create the user custom actions\n createUserCustomActions(customActions, cfg.CustomActionCfg.Site).then(function () {\n // Log\n console.log(\"[gd-sprest][Site Custom Actions] Completed the requests.\"); // Resolve the promise\n\n resolve();\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the custom actions\n\n\n var createSiteCustomActions = function createSiteCustomActions() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are targeting the web\n if (cfg.CustomActionCfg && cfg.CustomActionCfg.Web) {\n // Log\n console.log(\"[gd-sprest][Web Custom Actions] Starting the requests.\"); // Get the user custom actions\n\n web.UserCustomActions().execute(function (customActions) {\n // Create the user custom actions\n createUserCustomActions(customActions, cfg.CustomActionCfg.Web).then(function () {\n // Log\n console.log(\"[gd-sprest][Web Custom Actions] Completed the requests.\"); // Resolve the promise\n\n resolve();\n });\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the site fields\n\n\n createSiteFields().then(function () {\n // Create the site content types\n createSiteContentTypes().then(function () {\n // Create the site lists\n createSiteLists().then(function () {\n // Create the webparts\n createSiteWebParts().then(function () {\n // Create the site collection custom actions\n createSiteCollectionCustomActions().then(function () {\n // Create the site custom actions\n createSiteCustomActions().then(function () {\n // Log\n console.log(\"[gd-sprest] The configuration script completed, but some requests may still be running.\"); // Resolve the request\n\n resolve();\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n });\n },\n // Method to update the web url to target\n setWebUrl: function setWebUrl(url) {\n webUrl = url;\n },\n // Method to uninstall the configuration\n uninstall: function uninstall() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Set the request digest\n setRequestDigest().then(function () {\n // Uninstall the web components\n uninstallWeb().then(function () {\n // Uninstall the site components\n uninstallSite().then(function () {\n // Log\n console.log(\"[gd-sprest] The configuration script completed, but some requests may still be running.\"); // Resolve the promise\n\n resolve();\n }, reject);\n }, reject);\n });\n });\n }\n };\n};\n\n//# sourceURL=webpack://gd-sprest/./build/helper/spCfg.js?");
250
+ eval("\n\nvar __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, {\n enumerable: true,\n get: function get() {\n return m[k];\n }\n });\n} : function (o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\n\nvar __exportStar = this && this.__exportStar || function (m, exports) {\n for (var p in m) {\n if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n }\n};\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));\nexports.SPConfig = void 0;\n\nvar lib_1 = __webpack_require__(/*! ../lib */ \"./build/lib/index.js\");\n\nvar __1 = __webpack_require__(/*! .. */ \"./build/index.js\");\n\nvar _1 = __webpack_require__(/*! . */ \"./build/helper/index.js\");\n\n__exportStar(__webpack_require__(/*! ./spCfgTypes */ \"./build/helper/spCfgTypes.js\"), exports);\n/**\r\n * SharePoint Configuration\r\n */\n\n\nexports.SPConfig = function (cfg, webUrl) {\n // The selected configuration type to install\n var _cfgType; // The request digest\n\n\n var _requestDigest = null; // The target name to install/uninstall\n\n var _targetName;\n /**\r\n * Methods\r\n */\n // Method to create the content types\n\n\n var createContentTypes = function createContentTypes(contentTypes, cfgContentTypes, list) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure fields exist\n if (cfgContentTypes == null || cfgContentTypes.length == 0) {\n // Resolve the promise\n resolve();\n return;\n } // Method to get the parent content type\n\n\n var getParentCT = function getParentCT(ctName, url) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Get the web containing the parent content type\n lib_1.Web(url, {\n disableCache: true\n }) // Get the content types\n .ContentTypes() // Filter for the parent name\n .query({\n Filter: \"Name eq '\" + ctName + \"'\"\n }) // Execute the request\n .execute(function (cts) {\n // See if the parent exists\n if (cts.results[0]) {\n // Resolve the promise\n resolve({\n Id: cts.results[0].Id.StringValue,\n Url: url\n });\n } // Else, ensure this isn't the root web\n else if (url != lib_1.ContextInfo.siteServerRelativeUrl) {\n // Check the root web for the parent content type\n getParentCT(ctName, lib_1.ContextInfo.siteServerRelativeUrl).then(resolve, reject);\n } else {\n // Reject the promise\n reject();\n }\n }, reject);\n });\n }; // Parse the configuration\n\n\n _1.Executor(cfgContentTypes, function (cfg) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if this content type already exists\n var ct = isInCollection(\"Name\", cfg.Name, contentTypes.results);\n\n if (ct) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' already exists.\"); // Update the configuration\n\n cfg.ContentType = ct; // Resolve the promise and return\n\n resolve(cfg);\n return;\n } // Log\n\n\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] Creating the '\" + cfg.Name + \"' content type.\"); // See if the parent name exists\n\n if (cfg.ParentName) {\n getParentCT(cfg.ParentName, cfg.ParentWebUrl || webUrl).then( // Success\n function (parentInfo) {\n // Add the content type\n _1.createContentType({\n Description: cfg.Description,\n Group: cfg.Group,\n Name: cfg.Name\n }, parentInfo, webUrl, list ? list.Title : null).then( // Success\n function (ct) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' was created successfully.\"); // Update the configuration\n\n cfg.ContentType = ct; // Trigger the event\n\n cfg.onCreated ? cfg.onCreated(ct, list) : null; // Resolve the promise\n\n resolve(cfg);\n }, // Error\n function (error) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' failed to be created.\", error); // Reject the promise\n\n reject(error);\n });\n }, // Error\n function () {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The parent content type '\" + cfg.ParentName + \"' was not found.\"); // Reject the promise\n\n reject(ct.response);\n });\n } else {\n // Create the content type\n contentTypes.add({\n Description: cfg.Description,\n Group: cfg.Group,\n Name: cfg.Name,\n Id: {\n __metadata: {\n type: \"SP.ContentTypeId\"\n },\n StringValue: cfg.Id || \"0x0100\" + lib_1.ContextInfo.generateGUID().replace(/-/g, \"\")\n }\n }).execute( // Success\n function (ct) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' was created successfully.\"); // Update the configuration\n\n cfg.ContentType = ct; // Trigger the event\n\n cfg.onCreated ? cfg.onCreated(ct, list) : null; // Resolve the promise\n\n resolve(cfg);\n }, // Error\n function (error) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] The content type '\" + cfg.Name + \"' failed to be created.\");\n console.error(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] Error: \" + error.response); // Reject the promise\n\n reject(error.response);\n });\n }\n });\n }).then(function () {\n // Parse the configuration\n _1.Executor(cfgContentTypes, function (cfgContentType) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var cfgUpdate = {};\n var updateFl = false; // Ensure the content type exists\n\n if (cfgContentType.ContentType == null) {\n // Skip this content type\n resolve(null);\n return;\n } // Log\n\n\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type] Updating the field references for: \" + cfgContentType.Name); // Create the field refs\n\n _1.setContentTypeFields({\n fields: cfgContentType.FieldRefs,\n id: cfgContentType.ContentType.Id.StringValue,\n listName: list ? list.Title : null,\n webUrl: webUrl\n }).then(function () {\n /**\r\n * See if we need to update the properties\r\n */\n // Description\n if (cfgContentType.Description != null && cfgContentType.ContentType.Description != cfgContentType.Description) {\n // Update the configuration\n cfgUpdate.Description = cfgContentType.Description; // Set the flag\n\n updateFl = true;\n } // Group\n\n\n if (cfgContentType.Group != null && cfgContentType.ContentType.Group != cfgContentType.Group) {\n // Update the configuration\n cfgUpdate.Group = cfgContentType.Group; // Set the flag\n\n updateFl = true;\n } // JSLink\n\n\n if (cfgContentType.JSLink != null && cfgContentType.ContentType.JSLink != cfgContentType.JSLink) {\n // Update the configuration\n cfgUpdate.JSLink = cfgContentType.JSLink; // Set the flag\n\n updateFl = true;\n } // Name\n\n\n if (cfgContentType.Name != null && cfgContentType.ContentType.Name != cfgContentType.Name) {\n // Update the configuration\n cfgUpdate.Name = cfgContentType.Name; // Set the flag\n\n updateFl = true;\n } // See if an update is needed\n\n\n if (updateFl) {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type][\" + cfgContentType.ContentType.Name + \"] Updating the content type.\"); // Update the content type\n\n cfgContentType.ContentType.update(cfgUpdate).execute(function () {\n // Log\n console.log(\"[gd-sprest]\" + (list ? \"[\" + list.Title + \" List]\" : \"\") + \"[Content Type][\" + cfgContentType.ContentType.Name + \"] Update request completed.\"); // Trigger the event\n\n cfgContentType.onUpdated ? cfgContentType.onUpdated(cfgContentType.ContentType) : null; // Resolve this request\n\n resolve(null);\n }, reject);\n } else {\n // Trigger the event\n cfgContentType.onUpdated ? cfgContentType.onUpdated(cfgContentType.ContentType) : null; // Resolve this request\n\n resolve(null);\n }\n }, reject);\n });\n }).then(resolve);\n }, reject);\n });\n }; // Method to create the fields`\n\n\n var createFields = function createFields(fields, cfgFields, list) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var newFields = []; // Ensure fields exist\n\n if (cfgFields == null || cfgFields.length == 0) {\n // Resolve the promise\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgFields, function (cfg) {\n return new Promise(function (resolve, reject) {\n // See if this field already exists\n var field = isInCollection(\"InternalName\", cfg.name, fields.results);\n\n if (field) {\n // Log\n console.log(\"[gd-sprest][Field] The field '\" + cfg.name + \"' already exists.\"); // Trigger the event\n\n cfg.onUpdated ? cfg.onUpdated(field, list) : null; // Resolve the promise\n\n resolve(null);\n } else {\n // Log\n console.log(\"[gd-sprest][Field] Creating the '\" + cfg.name + \"' field.\"); // See if this is an associated lookup field\n\n var cfgLookup = cfg;\n\n if (cfgLookup.type == _1.SPCfgFieldType.Lookup && cfgLookup.fieldRef) {\n // Get the field reference\n var fieldRef = isInCollection(\"InternalName\", cfgLookup.fieldRef, fields.results) || isInCollection(\"InternalName\", cfgLookup.fieldRef, newFields);\n\n if (fieldRef) {\n // Update the value to be the guid\n cfgLookup.fieldRef = fieldRef.Id;\n }\n } // Compute the schema xml\n\n\n _1.FieldSchemaXML(cfg).then(function (response) {\n var schemas = typeof response === \"string\" ? [response] : response; // Parse the fields to add\n\n for (var i = 0; i < schemas.length; i++) {\n // Add the field\n fields.createFieldAsXml(schemas[i]).execute(function (field) {\n // See if it was successful\n if (field.InternalName) {\n // Log\n console.log(\"[gd-sprest][Field] The field '\" + field.InternalName + \"' was created successfully.\"); // Save a reference to the field\n\n newFields.push(field); // Trigger the event\n\n cfg.onCreated ? cfg.onCreated(field, list) : null; // Resolve the promise\n\n resolve(null);\n } else {\n // Log\n console.log(\"[gd-sprest][Field] The field '\" + cfg.name + \"' failed to be created.\");\n console.error(\"[gd-sprest][Field] Error: \" + field.response); // Reject the promise\n\n reject();\n }\n });\n }\n });\n }\n });\n }).then(resolve);\n });\n }; // Method to create the lists\n\n\n var createLists = function createLists(lists, cfgLists) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Execute code against each list configuration\n _1.Executor(cfgLists, function (cfgList) {\n // Return a promise\n return new Promise(function (resolve) {\n // See if the target name exists and matches this list\n if (_cfgType && _targetName) {\n // Ensure it's for this list\n if (cfgList.ListInformation.Title.toLowerCase() != _targetName) {\n // Do nothing\n resolve(null);\n return;\n }\n } // See if this list already exists\n\n\n var list = isInCollection(\"Title\", cfgList.ListInformation.Title, lists.results);\n\n if (list) {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + cfgList.ListInformation.Title + \"' already exists.\"); // Resolve the promise and do nothing\n\n resolve(null);\n return;\n } // Log\n\n\n console.log(\"[gd-sprest][List] Creating the '\" + cfgList.ListInformation.Title + \"' list.\"); // Update the list name and remove spaces\n\n var listInfo = cfgList.ListInformation;\n var listName = listInfo.Title;\n listInfo.Title = listName.replace(/ /g, \"\"); // Add the list\n\n lists.add(listInfo) // Execute the request\n .execute(function (list) {\n // Restore the list name in the configuration\n listInfo.Title = listName; // See if the request was successful\n\n if (list.Id) {\n // See if we need to update the list\n if (list.Title != listName) {\n // Update the list\n list.update({\n Title: listName\n }).execute(function () {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + list.Title + \"' was created successfully.\"); // Resolve the promise\n\n resolve(null);\n });\n } else {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + list.Title + \"' was created successfully.\"); // Resolve the promise\n\n resolve(null);\n } // Trigger the event\n\n\n cfgList.onCreated ? cfgList.onCreated(list) : null;\n } else {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + listInfo.Title + \"' failed to be created.\");\n console.log(\"[gd-sprest][List] Error: '\" + list.response); // Resolve the promise\n\n resolve(null);\n }\n }, reject);\n });\n }).then(function () {\n // Update the lists\n updateLists(cfgLists).then(function () {\n // Resolve the promise\n resolve();\n });\n });\n });\n }; // Method to create the user custom actions\n\n\n var createUserCustomActions = function createUserCustomActions(customActions, cfgCustomActions) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the configuration type exists\n if (_cfgType) {\n // Ensure it's for this type\n if (_cfgType != _1.SPCfgType.SiteUserCustomActions || _cfgType != _1.SPCfgType.WebUserCustomActions) {\n // Resolve the promise\n resolve();\n return;\n }\n } // Ensure the lists exist\n\n\n if (cfgCustomActions == null || cfgCustomActions.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgCustomActions, function (cfg) {\n // See if the target name exists\n if (_cfgType && _targetName) {\n // Ensure it's for this custom action\n if (cfg.Name.toLowerCase() != _targetName || cfg.Title.toLowerCase() != _targetName) {\n // Skip this custom action\n return;\n }\n } // See if this custom action already exists\n\n\n if (isInCollection(\"Name\", cfg.Name, customActions.results)) {\n // Log\n console.log(\"[gd-sprest][Custom Action] The custom action '\" + cfg.Name + \"' already exists.\");\n } else {\n // See if rights exist\n if (cfg.Rights) {\n // Update the value\n cfg.Rights = updateBasePermissions(cfg.Rights);\n } // Add the custom action\n\n\n customActions.add(cfg).execute(function (ca) {\n // Ensure it exists\n if (ca.existsFl) {\n // Log\n console.log(\"[gd-sprest][Custom Action] The custom action '\" + ca.Name + \"' was created successfully.\");\n } else {\n // Log\n console.log(\"[gd-sprest][Custom Action] The custom action '\" + ca.Name + \"' failed to be created.\");\n console.log(\"[gd-sprest][Custom Action] Error: \" + ca.response);\n }\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to create the list views\n\n\n var createViews = function createViews(list, views, cfgViews) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure the list views exist\n if (cfgViews == null || cfgViews.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgViews, function (cfg) {\n // See if this view exists\n var view = isInCollection(\"Title\", cfg.ViewName, views.results);\n\n if (view) {\n // Log\n console.log(\"[gd-sprest][View] The view '\" + cfg.ViewName + \"' already exists.\");\n } else {\n // Add the view\n views.add({\n Title: cfg.ViewName,\n ViewQuery: cfg.ViewQuery\n }).execute(function (view) {\n // Ensure it exists\n if (view.existsFl) {\n // Log\n console.log(\"[gd-sprest][View] The view '\" + cfg.ViewName + \"' was created successfully.\"); // Trigger the event\n\n cfg.onCreated ? cfg.onCreated(view, list) : null;\n } else {\n // Log\n console.log(\"[gd-sprest][View] The view '\" + cfg.ViewName + \"' failed to be created.\");\n console.log(\"[gd-sprest][View] Error: \" + view.response);\n }\n }, reject, true);\n }\n }).then(function () {\n // Update the views\n updateViews(list, views, cfgViews).then(function () {\n // Resolve the promise\n resolve();\n });\n });\n });\n }; // Method to create the web parts\n\n\n var createWebParts = function createWebParts() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var cfgWebParts = cfg.WebPartCfg; // Ensure fields exist\n\n if (cfgWebParts == null || cfgWebParts.length == 0) {\n // Resolve the promise\n resolve();\n return;\n } // Log\n\n\n console.log(\"[gd-sprest][WebPart] Creating the web parts.\"); // Get the web\n\n lib_1.Web(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }) // Get the web part catalog\n .getCatalog(__1.SPTypes.ListTemplateType.WebPartCatalog) // Get the root folder\n .RootFolder() // Expand the files and items\n .query({\n Expand: [\"Files\"]\n }) // Execute the request\n .execute(function (folder) {\n var ctr = 0;\n\n var _loop_1 = function _loop_1(i) {\n var cfgWebPart = cfgWebParts[i]; // See if the target name exists\n\n if (_cfgType && _targetName) {\n // Ensure it's for this list\n if (cfgWebPart.FileName.toLowerCase() != _targetName) {\n return \"continue\";\n }\n } // The post execute method\n\n\n var postExecute = function postExecute() {\n // Increment the counter\n if (++ctr >= cfgWebParts.length) {\n // Resolve the promise\n resolve();\n }\n }; // See if this webpart exists\n\n\n var file = isInCollection(\"Name\", cfgWebPart.FileName, folder.Files.results);\n\n if (file.Name) {\n // Log\n console.log(\"[gd-sprest][WebPart] The webpart '\" + cfgWebPart.FileName + \"' already exists.\"); // Trigger the event\n\n cfgWebPart.onUpdated ? cfgWebPart.onUpdated(file) : null; // Execute the post event\n\n postExecute();\n } else {\n // Trim the xml\n var xml = cfgWebPart.XML.trim(); // Convert the string to an array buffer\n\n var buffer = new ArrayBuffer(xml.length * 2);\n var bufferView = new Uint16Array(buffer);\n\n for (var j = 0; j < xml.length; j++) {\n bufferView[j] = xml.charCodeAt(j);\n } // Create the webpart, but execute the requests one at a time\n\n\n folder.Files.add(cfgWebPart.FileName, true, buffer).execute( // Success\n function (file) {\n // See if group exists\n if (cfgWebPart.Group) {\n // Set the target to the root web\n lib_1.Web(lib_1.ContextInfo.siteServerRelativeUrl, {\n disableCache: true\n }) // Get the web part catalog\n .getCatalog(__1.SPTypes.ListTemplateType.WebPartCatalog) // Get the Items\n .Items() // Query for this webpart\n .query({\n Filter: \"FileLeafRef eq '\" + cfgWebPart.FileName + \"'\"\n }) // Execute the request\n .execute(function (items) {\n // Update the item\n items.results[0].update({\n Group: cfgWebPart.Group\n }).execute(postExecute);\n });\n } // Log\n\n\n console.log(\"[gd-sprest][WebPart] The '\" + file.Name + \"' webpart file was uploaded successfully.\"); // Trigger the event\n\n cfgWebPart.onCreated ? cfgWebPart.onCreated(file) : null;\n }, // Error\n function () {\n // Log\n console.log(\"[gd-sprest][WebPart] The '\" + file.Name + \"' webpart file upload failed.\"); // Skip this webpart\n\n resolve();\n });\n }\n }; // Parse the configuration\n\n\n for (var i = 0; i < cfgWebParts.length; i++) {\n _loop_1(i);\n }\n }, reject);\n });\n }; // Method to see if an object exists in a collection\n\n\n var isInCollection = function isInCollection(key, value, collection) {\n // Ensure a value exists\n if (value) {\n var valueLower = value ? value.toLowerCase() : \"\"; // Parse the collection\n\n for (var i = 0; i < collection.length; i++) {\n var keyValue = collection[i][key];\n keyValue = keyValue ? keyValue.toLowerCase() : \"\"; // See if the item exists\n\n if (valueLower == keyValue) {\n // Return true\n return collection[i];\n }\n }\n } // Not in the collection\n\n\n return false;\n }; // Method to remove the content type\n\n\n var removeContentTypes = function removeContentTypes(contentTypes, cfgContentTypes) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure the content types exist\n if (cfgContentTypes == null || cfgContentTypes.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgContentTypes, function (cfg) {\n // Get the field\n var ct = isInCollection(\"Name\", cfg.Name, contentTypes.results);\n\n if (ct) {\n // Remove the field\n ct[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][Content Type] The content type '\" + ct.Name + \"' was removed.\");\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to remove the fields\n\n\n var removeFields = function removeFields(fields, cfgFields) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure the fields exist\n if (cfgFields == null || cfgFields.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgFields, function (cfg) {\n // Get the field\n var field = isInCollection(\"InternalName\", cfg.name, fields.results);\n\n if (field) {\n // Remove the field\n field[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][Field] The field '\" + field.InternalName + \"' was removed.\");\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to remove the lists\n\n\n var removeLists = function removeLists(lists, cfgLists) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the configuration type exists\n if (_cfgType) {\n // Ensure it's for this type\n if (_cfgType != _1.SPCfgType.Lists) {\n // Resolve the promise\n resolve();\n return;\n }\n } // Ensure the lists exist\n\n\n if (cfgLists == null || cfgLists.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgLists, function (cfg) {\n // See if the target name exists\n if (_cfgType && _targetName) {\n // Ensure it's for this list\n if (cfg.ListInformation.Title.toLowerCase() != _targetName) {\n // Skip this list\n return;\n }\n } // Get the list\n\n\n var list = isInCollection(\"Title\", cfg.ListInformation.Title, lists.results);\n\n if (list) {\n // Remove the list\n list[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][List] The list '\" + list.Title + \"' was removed.\");\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to remove the user custom actions\n\n\n var removeUserCustomActions = function removeUserCustomActions(customActions, cfgCustomActions) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if the configuration type exists\n if (_cfgType) {\n // Ensure it's for this type\n if (_cfgType != _1.SPCfgType.SiteUserCustomActions || _cfgType != _1.SPCfgType.WebUserCustomActions) {\n // Resolve the promise\n resolve();\n return;\n }\n } // Ensure the custom actions exist\n\n\n if (cfgCustomActions == null || cfgCustomActions.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Parse the configuration\n\n\n _1.Executor(cfgCustomActions, function (cfg) {\n // See if the target name exists\n if (_cfgType && _targetName) {\n // Ensure it's for this custom action\n if (cfg.Name.toLowerCase() != _targetName || cfg.Title.toLowerCase() != _targetName) {\n // Skip this custom action\n return;\n }\n } // Get the custom action\n\n\n var ca = isInCollection(\"Name\", cfg.Name, customActions.results);\n\n if (ca) {\n // Remove the custom action\n ca[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][Custom Action] The custom action '\" + ca.Name + \"' was removed.\");\n }, reject, true);\n }\n }).then(resolve);\n });\n }; // Method to remove the web parts\n\n\n var removeWebParts = function removeWebParts(site) {\n var cfgWebParts = cfg.WebPartCfg; // Return a promise\n\n return new Promise(function (resolve, reject) {\n // See if the configuration type exists\n if (_cfgType) {\n // Ensure it's for this type\n if (_cfgType != _1.SPCfgType.WebParts) {\n // Resolve the promise\n resolve();\n return;\n }\n } // Ensure the configuration exists\n\n\n if (cfgWebParts == null || cfgWebParts.length == 0) {\n // Resolve the promise and return it\n resolve();\n return;\n } // Log\n\n\n console.log(\"[gd-sprest][WebPart] Removing the web parts.\"); // Get the webpart gallery from the root web\n\n site.RootWeb().getCatalog(__1.SPTypes.ListTemplateType.WebPartCatalog) // Get the root folder\n .RootFolder() // Expand the files\n .Files() // Execute the request\n .execute(function (files) {\n var _loop_2 = function _loop_2(i) {\n var cfgWebPart = cfgWebParts[i]; // See if the target name exists\n\n if (_cfgType && _targetName) {\n // Ensure it's for this webpart\n if (cfgWebPart.FileName.toLowerCase() != _targetName) {\n return \"continue\";\n }\n } // Get the file\n\n\n var file = isInCollection(\"Name\", cfgWebPart.FileName, files.results);\n\n if (file) {\n // Remove the file\n file[\"delete\"]().execute(function () {\n // Log\n console.log(\"[gd-sprest][WebPart] The webpart '\" + file.Name + \"' file was removed.\");\n }, true);\n }\n }; // Parse the configuration\n\n\n for (var i = 0; i < cfgWebParts.length; i++) {\n _loop_2(i);\n } // Resolve the promise\n\n\n resolve();\n }, reject);\n });\n }; // Method to get the web information\n\n\n var setRequestDigest = function setRequestDigest() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n if (webUrl) {\n // Get the web context information\n lib_1.ContextInfo.getWeb(webUrl).execute(function (webInfo) {\n _requestDigest = webInfo.GetContextWebInformation.FormDigestValue; // Resolve the promise\n\n resolve();\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Method to update the base permissions\n\n\n var updateBasePermissions = function updateBasePermissions(values) {\n var high = values.High;\n var low = values.Low; // See if this is an array\n\n for (var i = 0; i < values[\"length\"]; i++) {\n var value = values[i]; // See if this is the full mask\n\n if (value == 65) {\n // Set the values\n low = 65535;\n high = 32767; // Break from the loop\n\n break;\n } // Else, see if it's empty\n else if (value == 0) {\n // Clear the values\n low = 0;\n high = 0;\n } // Else, update the base permission\n else {\n var bit = value - 1;\n var bitValue = 1; // Validate the bit\n\n if (bit < 0) {\n continue;\n } // See if it's a low permission\n\n\n if (bit < 32) {\n // Compute the value\n bitValue = bitValue << bit; // Set the low value\n\n low |= bitValue;\n } // Else, it's a high permission\n else {\n // Compute the value\n bitValue = bitValue << bit - 32; // Set the high value\n\n high |= bitValue;\n }\n }\n } // Return the base permission\n\n\n return {\n Low: low.toString(),\n High: high.toString()\n };\n }; // Method to update the lists\n\n\n var updateLists = function updateLists(cfgLists) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var request = function request(idx, resolve) {\n // Get the list configuration\n var cfgList = cfgLists[idx]; // See if the target name exists\n\n if (_targetName) {\n // Ensure it's for this list\n if (cfgList.ListInformation.Title.toLowerCase() != _targetName) {\n // Update the next list\n request(idx + 1, resolve);\n return;\n }\n } // Ensure the configuration exists\n\n\n if (cfgList) {\n // Get the web\n lib_1.Web(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }) // Get the list\n .Lists(cfgList.ListInformation.Title) // Expand the content types, fields and views\n .query({\n Expand: [\"ContentTypes\", \"Fields\", \"UserCustomActions\", \"Views\"]\n }) // Execute the request\n .execute(function (list) {\n // Update the title field\n updateListTitleField(list, cfgList).then(function () {\n // Create the fields\n createFields(list.Fields, cfgList.CustomFields, list).then(function () {\n // Create the content types\n createContentTypes(list.ContentTypes, cfgList.ContentTypes, list).then(function () {\n // Update the views\n createViews(list, list.Views, cfgList.ViewInformation).then(function () {\n // Update the views\n createUserCustomActions(list.UserCustomActions, cfgList.UserCustomActions).then(function () {\n // Trigger the event\n cfgList.onUpdated ? cfgList.onUpdated(list) : null; // Update the next list\n\n request(idx + 1, resolve);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n }; // Execute the request\n\n\n request(0, resolve);\n });\n }; // Method to update the list title field\n\n\n var updateListTitleField = function updateListTitleField(list, cfgList) {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure an update is required\n if (cfgList.TitleFieldDisplayName || cfgList.TitleFieldIndexed) {\n var values = {}; // See if the title field is being updated\n\n if (cfgList.TitleFieldDisplayName) {\n // Update the values\n values[\"Title\"] = cfgList.TitleFieldDisplayName;\n } // See if we are indexing the field\n\n\n if (cfgList.TitleFieldIndexed) {\n // Update the values\n values[\"Indexed\"] = true;\n } // Update the field name\n\n\n list.Fields.getByInternalNameOrTitle(\"Title\").update(values).execute(function () {\n // Log\n cfgList.TitleFieldDisplayName ? console.log(\"[gd-sprest][List] The 'Title' field's display name was updated to '\" + cfgList.TitleFieldDisplayName + \"'.\") : null;\n cfgList.TitleFieldIndexed ? console.log(\"[gd-sprest][List] The 'Title' field's has been indexed.\") : null; // Resolve the promise\n\n resolve();\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Method to update the views\n\n\n var updateViews = function updateViews(list, views, cfgViews) {\n // Return a promise\n return new Promise(function (resolve) {\n // Parse the configuration\n _1.Executor(cfgViews, function (cfg) {\n // Return a promise\n return new Promise(function (resolve) {\n // Get the view\n var view = views.getByTitle(cfg.ViewName); // See if the view fields are defined\n\n if (cfg.ViewFields && cfg.ViewFields.length > 0) {\n // Log\n console.log(\"[gd-sprest][View] Updating the view fields for the '\" + cfg.ViewName + \"' view.\"); // Clear the view fields\n\n view.ViewFields().removeAllViewFields().execute(true); // Parse the view fields\n\n for (var i = 0; i < cfg.ViewFields.length; i++) {\n // Add the view field\n view.ViewFields().addViewField(cfg.ViewFields[i]).execute(true);\n }\n } // See if we are updating the view properties\n\n\n if (cfg.JSLink || cfg.ViewQuery) {\n var props = {}; // Log\n\n console.log(\"[gd-sprest][View] Updating the view properties for the '\" + cfg.ViewName + \"' view.\"); // Set the properties\n\n cfg.JSLink ? props[\"JSLink\"] = cfg.JSLink : null;\n cfg.ViewQuery ? props[\"ViewQuery\"] = cfg.ViewQuery : null; // Update the view\n\n view.update(props).execute(true);\n } // Wait for the requests to complete\n\n\n view.done(function () {\n var args = [];\n\n for (var _i = 0; _i < arguments.length; _i++) {\n args[_i] = arguments[_i];\n } // Log\n\n\n console.log(\"[gd-sprest][View] The updates for the '\" + cfg.ViewName + \"' view has completed.\"); // Trigger the event\n\n cfg.onUpdated ? cfg.onUpdated(view, list) : null; // Resolve the promise\n\n resolve(null);\n });\n });\n }).then(resolve);\n });\n }; // Method to uninstall the site components\n\n\n var uninstallSite = function uninstallSite() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Ensure we need to complete this request\n if (cfg.CustomActionCfg != null && cfg.CustomActionCfg.Site != null || cfg.WebPartCfg != null) {\n // Log\n console.log(\"[gd-sprest][uninstall] Loading the site information...\"); // Get the site\n\n lib_1.Site(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }) // Expand the user custom actions\n .query({\n Expand: [\"UserCustomActions\"]\n }) // Execute the request\n .execute(function (site) {\n // Remove the user custom actions\n removeUserCustomActions(site.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Site : []).then(function () {\n // Remove the webpart\n removeWebParts(site).then(function () {\n // Resolve the promise\n resolve(site);\n }, reject);\n });\n }, reject);\n } else {\n // Resolve the promise\n resolve(null);\n }\n });\n }; // Method to uninstall the web components\n\n\n var uninstallWeb = function uninstallWeb() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n var Expand = []; // Log\n\n console.log(\"[gd-sprest][uninstall] Loading the web information...\"); // Set the query\n\n if (cfg.ContentTypes) {\n Expand.push(\"ContentTypes\");\n }\n\n if (cfg.CustomActionCfg) {\n Expand.push(\"UserCustomActions\");\n }\n\n if (cfg.Fields) {\n Expand.push(\"Fields\");\n }\n\n if (cfg.ListCfg) {\n Expand.push(\"Lists\");\n } // Query the web\n\n\n lib_1.Web(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }).query({\n Expand: Expand\n }) // Execute the request\n .execute(function (web) {\n // Remove the web custom actions\n removeUserCustomActions(web.UserCustomActions, cfg.CustomActionCfg ? cfg.CustomActionCfg.Web : null).then(function () {\n // Remove the lists\n removeLists(web.Lists, cfg.ListCfg).then(function () {\n // Remove the content types\n removeContentTypes(web.ContentTypes, cfg.ContentTypes).then(function () {\n // Remove the fields\n removeFields(web.Fields, cfg.Fields).then(function () {\n // Resolve the promise\n resolve();\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n });\n };\n /**\r\n * Public Interface\r\n */\n\n\n return {\n // The configuration\n _configuration: cfg,\n // Method to install the configuration\n install: function install() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Set the request digest\n setRequestDigest().then(function () {\n // Log\n console.log(\"[gd-sprest] Installing the web assets...\"); // Get the web\n\n var web = lib_1.Web(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }); // Create the site fields\n\n var createSiteFields = function createSiteFields() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are creating fields\n if (cfg.Fields && cfg.Fields.length > 0) {\n // Log\n console.log(\"[gd-sprest][Fields] Starting the requests.\"); // Get the fields\n\n web.Fields().execute(function (fields) {\n // Create the fields\n createFields(fields, cfg.Fields).then(function () {\n // Log\n console.log(\"[gd-sprest][Fields] Completed the requests.\"); // Resolve the promise\n\n resolve(null);\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve(null);\n }\n });\n }; // Create the site content types\n\n\n var createSiteContentTypes = function createSiteContentTypes() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are creating the content types\n if (cfg.ContentTypes && cfg.ContentTypes.length > 0) {\n // Log\n console.log(\"[gd-sprest][Content Types] Starting the requests.\"); // Get the content types\n\n web.ContentTypes().execute(function (contentTypes) {\n // Create the content types\n createContentTypes(contentTypes, cfg.ContentTypes).then(function () {\n // Log\n console.log(\"[gd-sprest][Content Types] Completed the requests.\"); // Resolve the promise\n\n resolve();\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the site lists\n\n\n var createSiteLists = function createSiteLists() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are creating the lists\n if (cfg.ListCfg && cfg.ListCfg.length) {\n // Log\n console.log(\"[gd-sprest][Lists] Starting the requests.\"); // Get the lists\n\n web.Lists().execute(function (lists) {\n // Create the lists\n createLists(lists, cfg.ListCfg).then(function () {\n // Log\n console.log(\"[gd-sprest][Lists] Completed the requests.\"); // Resolve the promise\n\n resolve();\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the site webparts\n\n\n var createSiteWebParts = function createSiteWebParts() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are creating the webparts\n if (cfg.WebPartCfg && cfg.WebPartCfg.length > 0) {\n // Log\n console.log(\"[gd-sprest][WebParts] Starting the requests.\"); // Create the webparts\n\n createWebParts().then(function () {\n // Log\n console.log(\"[gd-sprest][WebParts] Completed the requests.\"); // Resolve the promise\n\n resolve();\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the custom actions\n\n\n var createSiteCollectionCustomActions = function createSiteCollectionCustomActions() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are targeting the site collection\n if (cfg.CustomActionCfg && cfg.CustomActionCfg.Site) {\n // Log\n console.log(\"[gd-sprest][Site Custom Actions] Starting the requests.\"); // Get the site\n\n lib_1.Site(webUrl, {\n disableCache: true,\n requestDigest: _requestDigest\n }) // Get the user custom actions\n .UserCustomActions().execute(function (customActions) {\n // Create the user custom actions\n createUserCustomActions(customActions, cfg.CustomActionCfg.Site).then(function () {\n // Log\n console.log(\"[gd-sprest][Site Custom Actions] Completed the requests.\"); // Resolve the promise\n\n resolve();\n }, reject);\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the custom actions\n\n\n var createSiteCustomActions = function createSiteCustomActions() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // See if we are targeting the web\n if (cfg.CustomActionCfg && cfg.CustomActionCfg.Web) {\n // Log\n console.log(\"[gd-sprest][Web Custom Actions] Starting the requests.\"); // Get the user custom actions\n\n web.UserCustomActions().execute(function (customActions) {\n // Create the user custom actions\n createUserCustomActions(customActions, cfg.CustomActionCfg.Web).then(function () {\n // Log\n console.log(\"[gd-sprest][Web Custom Actions] Completed the requests.\"); // Resolve the promise\n\n resolve();\n });\n }, reject);\n } else {\n // Resolve the promise\n resolve();\n }\n });\n }; // Create the site fields\n\n\n createSiteFields().then(function () {\n // Create the site content types\n createSiteContentTypes().then(function () {\n // Create the site lists\n createSiteLists().then(function () {\n // Create the webparts\n createSiteWebParts().then(function () {\n // Create the site collection custom actions\n createSiteCollectionCustomActions().then(function () {\n // Create the site custom actions\n createSiteCustomActions().then(function () {\n // Log\n console.log(\"[gd-sprest] The configuration script completed, but some requests may still be running.\"); // Resolve the request\n\n resolve();\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n }, reject);\n });\n },\n // Method to update the web url to target\n setWebUrl: function setWebUrl(url) {\n webUrl = url;\n },\n // Method to uninstall the configuration\n uninstall: function uninstall() {\n // Return a promise\n return new Promise(function (resolve, reject) {\n // Set the request digest\n setRequestDigest().then(function () {\n // Uninstall the web components\n uninstallWeb().then(function () {\n // Uninstall the site components\n uninstallSite().then(function () {\n // Log\n console.log(\"[gd-sprest] The configuration script completed, but some requests may still be running.\"); // Resolve the promise\n\n resolve();\n }, reject);\n }, reject);\n });\n });\n }\n };\n};\n\n//# sourceURL=webpack://gd-sprest/./build/helper/spCfg.js?");
251
251
 
252
252
  /***/ }),
253
253
 
@@ -742,7 +742,7 @@ eval("\n\nObject.defineProperty(exports, \"__esModule\", ({\n value: true\n}));
742
742
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
743
743
 
744
744
  "use strict";
745
- 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.94,\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?");
745
+ 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.97,\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?");
746
746
 
747
747
  /***/ }),
748
748