gd-sprest 9.7.2 → 9.7.4

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.
Files changed (100) hide show
  1. package/@types/utils/base.d.ts +0 -3
  2. package/build/helper/executor.js +10 -20
  3. package/build/helper/fieldSchemaXML.js +85 -89
  4. package/build/helper/index.js +12 -28
  5. package/build/helper/jslink.js +124 -128
  6. package/build/helper/listForm.js +109 -118
  7. package/build/helper/listFormField.js +62 -65
  8. package/build/helper/methods/addContentEditorWebPart.js +9 -17
  9. package/build/helper/methods/addPermissionLevel.js +12 -16
  10. package/build/helper/methods/addScriptEditorWebPart.js +9 -17
  11. package/build/helper/methods/copyPermissionLevel.js +22 -26
  12. package/build/helper/methods/createContentType.js +96 -19
  13. package/build/helper/methods/createDocSet.js +10 -14
  14. package/build/helper/methods/getCurrentTheme.js +26 -31
  15. package/build/helper/methods/hasPermissions.js +8 -13
  16. package/build/helper/methods/index.js +16 -32
  17. package/build/helper/methods/loadSPCore.js +13 -17
  18. package/build/helper/methods/parse.js +5 -9
  19. package/build/helper/methods/request.js +4 -8
  20. package/build/helper/methods/setContentTypeFields.js +71 -79
  21. package/build/helper/methods/setGroupOwner.js +6 -10
  22. package/build/helper/methods/setWebProperty.js +26 -30
  23. package/build/helper/methods/stringify.js +3 -7
  24. package/build/helper/methods/webWorker.js +40 -20
  25. package/build/helper/ribbonLink.js +10 -14
  26. package/build/helper/sbLink.js +11 -15
  27. package/build/helper/sp/calloutManager.js +22 -25
  28. package/build/helper/sp/index.js +13 -16
  29. package/build/helper/sp/modalDialog.js +32 -35
  30. package/build/helper/sp/notify.js +9 -12
  31. package/build/helper/sp/ribbon.js +1 -4
  32. package/build/helper/sp/sod.js +9 -18
  33. package/build/helper/sp/status.js +18 -21
  34. package/build/helper/spCfg.js +232 -259
  35. package/build/helper/spCfgTypes.js +2 -5
  36. package/build/helper/taxonomy.js +144 -182
  37. package/build/helper/webpart.js +110 -94
  38. package/build/index.js +6 -23
  39. package/build/lib/apps.js +4 -7
  40. package/build/lib/contextInfo.js +217 -781
  41. package/build/lib/directorySession.js +4 -7
  42. package/build/lib/graph.js +16 -19
  43. package/build/lib/groupService.js +4 -7
  44. package/build/lib/groupSiteManager.js +4 -7
  45. package/build/lib/hubSites.js +11 -25
  46. package/build/lib/hubSitesUtility.js +4 -7
  47. package/build/lib/index.js +27 -43
  48. package/build/lib/list.js +49 -53
  49. package/build/lib/navigation.js +4 -7
  50. package/build/lib/peopleManager.js +4 -7
  51. package/build/lib/peoplePicker.js +4 -7
  52. package/build/lib/profileLoader.js +4 -7
  53. package/build/lib/search.js +30 -33
  54. package/build/lib/sensitivityLabels.js +6 -9
  55. package/build/lib/site.js +20 -35
  56. package/build/lib/siteIconManager.js +4 -7
  57. package/build/lib/siteManager.js +4 -7
  58. package/build/lib/sitePages.js +37 -51
  59. package/build/lib/socialFeed.js +13 -16
  60. package/build/lib/themeManager.js +4 -7
  61. package/build/lib/userProfile.js +4 -7
  62. package/build/lib/utility.js +12 -17
  63. package/build/lib/web.js +34 -49
  64. package/build/lib/webTemplateExtensions.js +4 -7
  65. package/build/lib/wfInstanceService.js +4 -7
  66. package/build/lib/wfSubscriptionService.js +4 -7
  67. package/build/mapper/custom/audit.js +3 -6
  68. package/build/mapper/custom/graph.js +13 -16
  69. package/build/mapper/custom/index.js +8 -24
  70. package/build/mapper/custom/odata.js +3 -6
  71. package/build/mapper/custom/old.js +42 -45
  72. package/build/mapper/custom/peoplePicker.js +4 -7
  73. package/build/mapper/custom/propertyValues.js +3 -6
  74. package/build/mapper/custom/utility.js +17 -20
  75. package/build/mapper/custom/webTemplateExtensions.js +19 -22
  76. package/build/mapper/def.js +1032 -989
  77. package/build/mapper/index.js +4 -9
  78. package/build/mapper/v2.js +2629 -2632
  79. package/build/rest.js +16 -19
  80. package/build/sptypes/graphtypes.js +694 -710
  81. package/build/sptypes/index.js +3 -7
  82. package/build/sptypes/sptypes.js +49 -52
  83. package/build/utils/base.js +20 -37
  84. package/build/utils/batch.js +53 -63
  85. package/build/utils/helper.js +79 -83
  86. package/build/utils/index.js +9 -25
  87. package/build/utils/methodInfo.js +88 -141
  88. package/build/utils/oData.js +62 -112
  89. package/build/utils/request.js +137 -155
  90. package/build/utils/requestType.js +1 -4
  91. package/build/utils/targetInfo.js +39 -52
  92. package/build/utils/xhrRequest.js +59 -107
  93. package/build/v2/drive.js +9 -13
  94. package/build/v2/drives.js +8 -12
  95. package/build/v2/index.js +3 -19
  96. package/build/v2/sites.js +61 -65
  97. package/dist/gd-sprest.d.ts +0 -3
  98. package/dist/gd-sprest.js +1 -1
  99. package/dist/gd-sprest.min.js +1 -1
  100. package/package.json +2 -2
@@ -1,28 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Taxonomy = void 0;
4
- var contextInfo_1 = require("../lib/contextInfo");
1
+ import { ContextInfo } from "../lib/contextInfo";
5
2
  /**
6
3
  * Taxonomy Helper Class
7
4
  */
8
- exports.Taxonomy = {
5
+ export const Taxonomy = {
9
6
  /**
10
7
  * Method to find a term by id
11
8
  */
12
- findById: function (term, termId) {
9
+ findById: (term, termId) => {
13
10
  // See if this is the root node
14
11
  if (term.info && term.info.id == termId) {
15
12
  // Return the root node
16
13
  return term;
17
14
  }
18
15
  // Parse the child nodes
19
- for (var prop in term) {
16
+ for (let prop in term) {
20
17
  // Skip the info and parent
21
18
  if (prop == "info" || prop == "parent") {
22
19
  continue;
23
20
  }
24
21
  // Find the term by id
25
- var childTerm = exports.Taxonomy.findById(term[prop], termId);
22
+ let childTerm = Taxonomy.findById(term[prop], termId);
26
23
  if (childTerm) {
27
24
  return childTerm;
28
25
  }
@@ -31,20 +28,20 @@ exports.Taxonomy = {
31
28
  /**
32
29
  * Method to find a term by name
33
30
  */
34
- findByName: function (term, termName) {
31
+ findByName: (term, termName) => {
35
32
  // See if this is the root node
36
33
  if (term.info && term.info.name == termName) {
37
34
  // Return the root node
38
35
  return term;
39
36
  }
40
37
  // Parse the child nodes
41
- for (var prop in term) {
38
+ for (let prop in term) {
42
39
  // Skip the info and parent
43
40
  if (prop == "info" || prop == "parent") {
44
41
  continue;
45
42
  }
46
43
  // Find the term by id
47
- var childTerm = exports.Taxonomy.findByName(term[prop], termName);
44
+ let childTerm = Taxonomy.findByName(term[prop], termName);
48
45
  if (childTerm) {
49
46
  return childTerm;
50
47
  }
@@ -53,8 +50,8 @@ exports.Taxonomy = {
53
50
  /**
54
51
  * Method to get the terms
55
52
  */
56
- getTerms: function (termSet, termSetTerms) {
57
- var terms = [];
53
+ getTerms: (termSet, termSetTerms) => {
54
+ let terms = [];
58
55
  // Add the root term
59
56
  terms.push({
60
57
  description: termSet.get_description(),
@@ -65,9 +62,9 @@ exports.Taxonomy = {
65
62
  props: termSet.get_customProperties()
66
63
  });
67
64
  // Parse the term sets terms
68
- var enumerator = termSetTerms.getEnumerator();
65
+ let enumerator = termSetTerms.getEnumerator();
69
66
  while (enumerator.moveNext()) {
70
- var term = enumerator.get_current();
67
+ let term = enumerator.get_current();
71
68
  // Create the terms
72
69
  terms.push({
73
70
  description: term.get_description(),
@@ -79,7 +76,7 @@ exports.Taxonomy = {
79
76
  });
80
77
  }
81
78
  // Sort the terms
82
- terms = terms.sort(function (a, b) {
79
+ terms = terms.sort((a, b) => {
83
80
  if (a.pathAsString < b.pathAsString) {
84
81
  return -1;
85
82
  }
@@ -94,50 +91,46 @@ exports.Taxonomy = {
94
91
  /**
95
92
  * Method to get the term group
96
93
  */
97
- getTermGroup: function (groupName) {
94
+ getTermGroup: (groupName) => {
98
95
  // Return a promise
99
- return new Promise(function (resolve, reject) {
96
+ return new Promise((resolve, reject) => {
100
97
  // Load the scripts
101
- exports.Taxonomy.loadScripts().then(function () {
98
+ Taxonomy.loadScripts().then(() => {
102
99
  // Get the taxonomy session
103
- var context = SP.ClientContext.get_current();
104
- var session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
100
+ let context = SP.ClientContext.get_current();
101
+ let session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
105
102
  // See if we are getting a specific group name
106
103
  if (groupName) {
107
104
  // Resolve the promise
108
- var termStores_1 = session.get_termStores();
109
- context.load(termStores_1, "Include(Groups)");
110
- context.executeQueryAsync(function () {
105
+ let termStores = session.get_termStores();
106
+ context.load(termStores, "Include(Groups)");
107
+ context.executeQueryAsync(() => {
111
108
  // Get the default store
112
- var enumerator = termStores_1.getEnumerator();
113
- var termStore = enumerator.moveNext() ? enumerator.get_current() : null;
109
+ let enumerator = termStores.getEnumerator();
110
+ let termStore = enumerator.moveNext() ? enumerator.get_current() : null;
114
111
  if (termStore) {
115
112
  // Get the term group
116
- var termGroup = termStore.get_groups().getByName(groupName);
113
+ let termGroup = termStore.get_groups().getByName(groupName);
117
114
  context.load(termGroup);
118
115
  // Resolve the promise
119
- resolve({ context: context, termGroup: termGroup });
116
+ resolve({ context, termGroup });
120
117
  }
121
118
  else {
122
119
  // Reject the promise
123
120
  reject("Unable to find the taxonomy store.");
124
121
  }
125
- }, function () {
126
- var args = [];
127
- for (var _i = 0; _i < arguments.length; _i++) {
128
- args[_i] = arguments[_i];
129
- }
122
+ }, (...args) => {
130
123
  // Reject the promise
131
124
  reject(args[1].get_message());
132
125
  });
133
126
  }
134
127
  else {
135
128
  // Get the default site collection group
136
- var termStore = session.getDefaultSiteCollectionTermStore();
137
- var termGroup = termStore.getSiteCollectionGroup(context.get_site());
129
+ let termStore = session.getDefaultSiteCollectionTermStore();
130
+ let termGroup = termStore.getSiteCollectionGroup(context.get_site());
138
131
  context.load(termGroup);
139
132
  // Resolve the promise
140
- resolve({ context: context, termGroup: termGroup });
133
+ resolve({ context, termGroup });
141
134
  }
142
135
  });
143
136
  });
@@ -145,34 +138,34 @@ exports.Taxonomy = {
145
138
  /**
146
139
  * Method to get the term groups
147
140
  */
148
- getTermGroups: function () {
141
+ getTermGroups: () => {
149
142
  // Return a promise
150
- return new Promise(function (resolve, reject) {
143
+ return new Promise((resolve, reject) => {
151
144
  // Load the scripts
152
- exports.Taxonomy.loadScripts().then(function () {
145
+ Taxonomy.loadScripts().then(() => {
153
146
  // Get the taxonomy session
154
- var context = SP.ClientContext.get_current();
155
- var session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
147
+ let context = SP.ClientContext.get_current();
148
+ let session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
156
149
  // Resolve the promise
157
- var termStores = session.get_termStores();
150
+ let termStores = session.get_termStores();
158
151
  context.load(termStores, "Include(Groups)");
159
- context.executeQueryAsync(function () {
152
+ context.executeQueryAsync(() => {
160
153
  // Get the default store
161
- var enumerator = termStores.getEnumerator();
162
- var termStore = enumerator.moveNext() ? enumerator.get_current() : null;
154
+ let enumerator = termStores.getEnumerator();
155
+ let termStore = enumerator.moveNext() ? enumerator.get_current() : null;
163
156
  if (termStore) {
164
157
  // Get the term groups
165
- var termGroups_1 = termStore.get_groups();
166
- context.load(termGroups_1, "Include(Description, Id, Name)");
158
+ let termGroups = termStore.get_groups();
159
+ context.load(termGroups, "Include(Description, Id, Name)");
167
160
  // Execute the request
168
161
  context.executeQueryAsync(
169
162
  // Success
170
- function () {
171
- var groups = [];
163
+ () => {
164
+ let groups = [];
172
165
  // Parse the groups
173
- var enumerator = termGroups_1.getEnumerator();
166
+ let enumerator = termGroups.getEnumerator();
174
167
  while (enumerator.moveNext()) {
175
- var group = enumerator.get_current();
168
+ let group = enumerator.get_current();
176
169
  // Add the group information
177
170
  groups.push({
178
171
  description: group.get_description(),
@@ -182,11 +175,7 @@ exports.Taxonomy = {
182
175
  }
183
176
  // Resolve the promise
184
177
  resolve(groups);
185
- }, function () {
186
- var args = [];
187
- for (var _i = 0; _i < arguments.length; _i++) {
188
- args[_i] = arguments[_i];
189
- }
178
+ }, (...args) => {
190
179
  // Reject the promise
191
180
  reject(args[1].get_message());
192
181
  });
@@ -195,11 +184,7 @@ exports.Taxonomy = {
195
184
  // Reject the promise
196
185
  reject("Unable to find the taxonomy store.");
197
186
  }
198
- }, function () {
199
- var args = [];
200
- for (var _i = 0; _i < arguments.length; _i++) {
201
- args[_i] = arguments[_i];
202
- }
187
+ }, (...args) => {
203
188
  // Reject the promise
204
189
  reject(args[1].get_message());
205
190
  });
@@ -209,24 +194,23 @@ exports.Taxonomy = {
209
194
  /**
210
195
  * Method to get the term sets for a group
211
196
  */
212
- getTermSets: function (groupName) {
197
+ getTermSets: (groupName) => {
213
198
  // Return a promise
214
- return new Promise(function (resolve, reject) {
199
+ return new Promise((resolve, reject) => {
215
200
  // Get the term gruop
216
- exports.Taxonomy.getTermGroup(groupName).then(
201
+ Taxonomy.getTermGroup(groupName).then(
217
202
  // Success
218
- function (_a) {
219
- var context = _a.context, termGroup = _a.termGroup;
203
+ ({ context, termGroup }) => {
220
204
  // Get the term group information
221
- var termGroupInfo = termGroup.get_termSets();
205
+ let termGroupInfo = termGroup.get_termSets();
222
206
  context.load(termGroupInfo, "Include(CustomProperties, Description, Id, Name)");
223
207
  // Execute the request
224
- context.executeQueryAsync(function () {
225
- var termSets = [];
208
+ context.executeQueryAsync(() => {
209
+ let termSets = [];
226
210
  // Parse the term group information
227
- var enumerator = termGroupInfo.getEnumerator();
211
+ let enumerator = termGroupInfo.getEnumerator();
228
212
  while (enumerator.moveNext()) {
229
- var termSet = enumerator.get_current();
213
+ let termSet = enumerator.get_current();
230
214
  // Add the group information
231
215
  termSets.push({
232
216
  description: termSet.get_description(),
@@ -237,17 +221,13 @@ exports.Taxonomy = {
237
221
  }
238
222
  // Resolve the promise
239
223
  resolve(termSets);
240
- }, function () {
241
- var args = [];
242
- for (var _i = 0; _i < arguments.length; _i++) {
243
- args[_i] = arguments[_i];
244
- }
224
+ }, (...args) => {
245
225
  // Reject the promise
246
226
  reject(args[1].get_message());
247
227
  });
248
228
  },
249
229
  // Error
250
- function (reason) {
230
+ reason => {
251
231
  // Reject the promise
252
232
  reject(reason);
253
233
  });
@@ -256,28 +236,28 @@ exports.Taxonomy = {
256
236
  /**
257
237
  * Method to get the term sets from the default site collection.
258
238
  */
259
- getTermSetsFromDefaultSC: function () {
239
+ getTermSetsFromDefaultSC: () => {
260
240
  // Return a promise
261
- return new Promise(function (resolve, reject) {
241
+ return new Promise((resolve, reject) => {
262
242
  // Load the scripts
263
- exports.Taxonomy.loadScripts().then(function () {
243
+ Taxonomy.loadScripts().then(() => {
264
244
  // Get the taxonomy session
265
- var context = SP.ClientContext.get_current();
266
- var session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
245
+ let context = SP.ClientContext.get_current();
246
+ let session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
267
247
  // Get the terms sets from the default site collection
268
- var termStore = session.getDefaultSiteCollectionTermStore();
269
- var termGroup = termStore.getSiteCollectionGroup(context.get_site());
270
- var termGroupInfo = termGroup.get_termSets();
248
+ let termStore = session.getDefaultSiteCollectionTermStore();
249
+ let termGroup = termStore.getSiteCollectionGroup(context.get_site());
250
+ let termGroupInfo = termGroup.get_termSets();
271
251
  context.load(termGroupInfo, "Include(CustomProperties, Description, Id, Name)");
272
252
  // Execute the request
273
253
  context.executeQueryAsync(
274
254
  // Success
275
- function () {
276
- var termSets = [];
255
+ () => {
256
+ let termSets = [];
277
257
  // Parse the term group information
278
- var enumerator = termGroupInfo.getEnumerator();
258
+ let enumerator = termGroupInfo.getEnumerator();
279
259
  while (enumerator.moveNext()) {
280
- var termSet = enumerator.get_current();
260
+ let termSet = enumerator.get_current();
281
261
  // Add the group information
282
262
  termSets.push({
283
263
  description: termSet.get_description(),
@@ -288,11 +268,7 @@ exports.Taxonomy = {
288
268
  }
289
269
  // Resolve the promise
290
270
  resolve(termSets);
291
- }, function () {
292
- var args = [];
293
- for (var _i = 0; _i < arguments.length; _i++) {
294
- args[_i] = arguments[_i];
295
- }
271
+ }, (...args) => {
296
272
  // Reject the promise
297
273
  reject(args[1].get_message());
298
274
  });
@@ -302,29 +278,25 @@ exports.Taxonomy = {
302
278
  /**
303
279
  * Method to get the terms by id
304
280
  */
305
- getTermsById: function (termStoreId, termSetId) {
281
+ getTermsById: (termStoreId, termSetId) => {
306
282
  // Return a promise
307
- return new Promise(function (resolve, reject) {
283
+ return new Promise((resolve, reject) => {
308
284
  // Load the scripts
309
- exports.Taxonomy.loadScripts().then(function () {
285
+ Taxonomy.loadScripts().then(() => {
310
286
  // Get the taxonomy session
311
- var context = SP.ClientContext.get_current();
312
- var session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
287
+ let context = SP.ClientContext.get_current();
288
+ let session = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
313
289
  // Get the term set terms
314
- var termStore = session.get_termStores().getById(termStoreId);
315
- var termSet = termStore.getTermSet(termSetId);
316
- var terms = termSet.getAllTerms();
290
+ let termStore = session.get_termStores().getById(termStoreId);
291
+ let termSet = termStore.getTermSet(termSetId);
292
+ let terms = termSet.getAllTerms();
317
293
  context.load(termSet);
318
294
  context.load(terms, "Include(CustomProperties, Description, Id, Name, PathOfTerm)");
319
295
  // Execute the request
320
- context.executeQueryAsync(function () {
296
+ context.executeQueryAsync(() => {
321
297
  // Resolve the promise
322
- resolve(exports.Taxonomy.getTerms(termSet, terms));
323
- }, function () {
324
- var args = [];
325
- for (var _i = 0; _i < arguments.length; _i++) {
326
- args[_i] = arguments[_i];
327
- }
298
+ resolve(Taxonomy.getTerms(termSet, terms));
299
+ }, (...args) => {
328
300
  // Reject the promise
329
301
  reject(args[1].get_message());
330
302
  });
@@ -334,18 +306,18 @@ exports.Taxonomy = {
334
306
  /**
335
307
  * Method to get the term set by id
336
308
  */
337
- getTermSetById: function (termStoreId, termSetId) {
309
+ getTermSetById: (termStoreId, termSetId) => {
338
310
  // Return a promise
339
- return new Promise(function (resolve, reject) {
311
+ return new Promise((resolve, reject) => {
340
312
  // Get the terms
341
- exports.Taxonomy.getTermsById(termStoreId, termSetId).then(
313
+ Taxonomy.getTermsById(termStoreId, termSetId).then(
342
314
  // Success
343
- function (terms) {
315
+ terms => {
344
316
  // Resolve the promise
345
- resolve(exports.Taxonomy.toObject(terms));
317
+ resolve(Taxonomy.toObject(terms));
346
318
  },
347
319
  // Error
348
- function (reason) {
320
+ reason => {
349
321
  // Reject the promise
350
322
  reject(reason);
351
323
  });
@@ -354,34 +326,29 @@ exports.Taxonomy = {
354
326
  /**
355
327
  * Method to get the terms from the default site collection
356
328
  */
357
- getTermsFromDefaultSC: function (termSetName) {
329
+ getTermsFromDefaultSC: (termSetName) => {
358
330
  // Return a promise
359
- return new Promise(function (resolve, reject) {
331
+ return new Promise((resolve, reject) => {
360
332
  // Get the term group
361
- exports.Taxonomy.getTermGroup().then(
333
+ Taxonomy.getTermGroup().then(
362
334
  // Success
363
- function (_a) {
364
- var context = _a.context, termGroup = _a.termGroup;
335
+ ({ context, termGroup }) => {
365
336
  // Get the term set terms
366
- var termSet = termGroup.get_termSets().getByName(termSetName);
367
- var terms = termSet.getAllTerms();
337
+ let termSet = termGroup.get_termSets().getByName(termSetName);
338
+ let terms = termSet.getAllTerms();
368
339
  context.load(termSet);
369
340
  context.load(terms, "Include(CustomProperties, Description, Id, Name, PathOfTerm)");
370
341
  // Execute the request
371
- context.executeQueryAsync(function () {
342
+ context.executeQueryAsync(() => {
372
343
  // Resolve the promise
373
- resolve(exports.Taxonomy.getTerms(termSet, terms));
374
- }, function () {
375
- var args = [];
376
- for (var _i = 0; _i < arguments.length; _i++) {
377
- args[_i] = arguments[_i];
378
- }
344
+ resolve(Taxonomy.getTerms(termSet, terms));
345
+ }, (...args) => {
379
346
  // Reject the promise
380
347
  reject(args[1].get_message());
381
348
  });
382
349
  },
383
350
  // Error
384
- function (reason) {
351
+ reason => {
385
352
  // Reject the promise
386
353
  reject(reason);
387
354
  });
@@ -390,18 +357,18 @@ exports.Taxonomy = {
390
357
  /**
391
358
  * Method to get the term set from the default site collection
392
359
  */
393
- getTermSetFromDefaultSC: function (termSetName) {
360
+ getTermSetFromDefaultSC: (termSetName) => {
394
361
  // Return a promise
395
- return new Promise(function (resolve, reject) {
362
+ return new Promise((resolve, reject) => {
396
363
  // Get the terms
397
- exports.Taxonomy.getTermsFromDefaultSC(termSetName).then(
364
+ Taxonomy.getTermsFromDefaultSC(termSetName).then(
398
365
  // Success
399
- function (terms) {
366
+ terms => {
400
367
  // Resolve the object
401
- resolve(exports.Taxonomy.toObject(terms));
368
+ resolve(Taxonomy.toObject(terms));
402
369
  },
403
370
  // Error
404
- function (reason) {
371
+ reason => {
405
372
  // Reject the promise
406
373
  reject(reason);
407
374
  });
@@ -410,26 +377,21 @@ exports.Taxonomy = {
410
377
  /**
411
378
  * Method to get a terms from a specified group
412
379
  */
413
- getTermsByGroupName: function (termSetName, groupName) {
380
+ getTermsByGroupName: (termSetName, groupName) => {
414
381
  // Return a promise
415
- return new Promise(function (resolve, reject) {
382
+ return new Promise((resolve, reject) => {
416
383
  // Get the term group
417
- exports.Taxonomy.getTermGroup(groupName).then(function (_a) {
418
- var context = _a.context, termGroup = _a.termGroup;
384
+ Taxonomy.getTermGroup(groupName).then(({ context, termGroup }) => {
419
385
  // Get the term set terms
420
- var termSet = termGroup.get_termSets().getByName(termSetName);
421
- var terms = termSet.getAllTerms();
386
+ let termSet = termGroup.get_termSets().getByName(termSetName);
387
+ let terms = termSet.getAllTerms();
422
388
  context.load(termSet);
423
389
  context.load(terms, "Include(CustomProperties, Description, Id, Name, PathOfTerm)");
424
390
  // Execute the request
425
- context.executeQueryAsync(function () {
391
+ context.executeQueryAsync(() => {
426
392
  // Resolve the promise
427
- resolve(exports.Taxonomy.getTerms(termSet, terms));
428
- }, function () {
429
- var args = [];
430
- for (var _i = 0; _i < arguments.length; _i++) {
431
- args[_i] = arguments[_i];
432
- }
393
+ resolve(Taxonomy.getTerms(termSet, terms));
394
+ }, (...args) => {
433
395
  // Reject the promise
434
396
  reject(args[1].get_message());
435
397
  });
@@ -439,18 +401,18 @@ exports.Taxonomy = {
439
401
  /**
440
402
  * Method to get the term set from the default site collection
441
403
  */
442
- getTermSetByGroupName: function (termSetName, groupName) {
404
+ getTermSetByGroupName: (termSetName, groupName) => {
443
405
  // Return a promise
444
- return new Promise(function (resolve, reject) {
406
+ return new Promise((resolve, reject) => {
445
407
  // Get the terms
446
- exports.Taxonomy.getTermsByGroupName(termSetName, groupName).then(
408
+ Taxonomy.getTermsByGroupName(termSetName, groupName).then(
447
409
  // Success
448
- function (terms) {
410
+ terms => {
449
411
  // Resolve the object
450
- resolve(exports.Taxonomy.toObject(terms));
412
+ resolve(Taxonomy.toObject(terms));
451
413
  },
452
414
  // Error
453
- function (reason) {
415
+ reason => {
454
416
  // Reject the promise
455
417
  reject(reason);
456
418
  });
@@ -459,14 +421,14 @@ exports.Taxonomy = {
459
421
  /**
460
422
  * Method to ensure the taxonomy script references are loaded.
461
423
  */
462
- loadScripts: function () {
424
+ loadScripts: () => {
463
425
  // Return a promise
464
- return new Promise(function (resolve, reject) {
426
+ return new Promise((resolve, reject) => {
465
427
  // Ensure the core script is loaded
466
- SP.SOD.executeFunc("sp.js", "SP.Utilities.Utility", function () {
428
+ SP.SOD.executeFunc("sp.js", "SP.Utilities.Utility", () => {
467
429
  // Ensure the taxonomy script is loaded
468
- SP.SOD.registerSod("sp.taxonomy.js", contextInfo_1.ContextInfo.webServerRelativeUrl + "/_layouts/15/sp.taxonomy.js");
469
- SP.SOD.executeFunc("sp.taxonomy.js", "SP.Taxonomy.TaxonomySession", function () {
430
+ SP.SOD.registerSod("sp.taxonomy.js", ContextInfo.webServerRelativeUrl + "/_layouts/15/sp.taxonomy.js");
431
+ SP.SOD.executeFunc("sp.taxonomy.js", "SP.Taxonomy.TaxonomySession", () => {
470
432
  // Resolve the promise
471
433
  resolve();
472
434
  });
@@ -476,18 +438,18 @@ exports.Taxonomy = {
476
438
  /**
477
439
  * Method to convert a term to an array of term information
478
440
  */
479
- toArray: function (term) {
480
- var terms = [];
441
+ toArray: (term) => {
442
+ let terms = [];
481
443
  // Recursive method to extract the child terms
482
- var getChildTerms = function (term, terms) {
444
+ let getChildTerms = (term, terms) => {
483
445
  // Parse the properties
484
- for (var prop in term) {
446
+ for (let prop in term) {
485
447
  // Skip the info and parent properties
486
448
  if (prop == "info" || prop == "parent") {
487
449
  continue;
488
450
  }
489
451
  // Add the child term
490
- var childTerm = term[prop];
452
+ let childTerm = term[prop];
491
453
  terms.push(childTerm.info);
492
454
  // Add the child terms
493
455
  getChildTerms(childTerm, terms);
@@ -509,8 +471,8 @@ exports.Taxonomy = {
509
471
  /**
510
472
  * Method to convert a term to a field value
511
473
  */
512
- toFieldValue: function (term) {
513
- var termInfo = term ? term["info"] || term : null;
474
+ toFieldValue: (term) => {
475
+ let termInfo = term ? term["info"] || term : null;
514
476
  // Ensure the term exists
515
477
  if (termInfo) {
516
478
  return {
@@ -526,13 +488,13 @@ exports.Taxonomy = {
526
488
  /**
527
489
  * Method to convert a collection of terms to a field value
528
490
  */
529
- toFieldMultiValue: function (terms) {
530
- var results = [];
491
+ toFieldMultiValue: (terms) => {
492
+ let results = [];
531
493
  // Ensure terms exist
532
494
  if (terms && terms.length > 0) {
533
495
  // Parse the terms
534
- for (var i = 0; i < terms.length; i++) {
535
- var termInfo = terms[i]["info"] || terms[i];
496
+ for (let i = 0; i < terms.length; i++) {
497
+ let termInfo = terms[i]["info"] || terms[i];
536
498
  // Add the term
537
499
  results.push(";#" + termInfo.name + "|" + termInfo.id);
538
500
  }
@@ -540,18 +502,18 @@ exports.Taxonomy = {
540
502
  // Return a blank array
541
503
  return {
542
504
  __metadata: { type: "Collection(SP.Taxonomy.TaxonomyFieldValue)" },
543
- results: results
505
+ results
544
506
  };
545
507
  },
546
508
  /**
547
509
  * Method to convert the terms to an object
548
510
  */
549
- toObject: function (terms) {
550
- var root = {};
511
+ toObject: (terms) => {
512
+ let root = {};
551
513
  // Recursive method to add terms
552
- var addTerm = function (node, info, path) {
553
- var term = node;
554
- var termName = "";
514
+ let addTerm = (node, info, path) => {
515
+ let term = node;
516
+ let termName = "";
555
517
  // Loop for each term
556
518
  while (path.length > 0) {
557
519
  // Ensure the term exists
@@ -561,10 +523,10 @@ exports.Taxonomy = {
561
523
  term[termName] = {};
562
524
  }
563
525
  // Set the term
564
- var parent_1 = term;
526
+ let parent = term;
565
527
  term = term[termName];
566
528
  // Set the parent
567
- term.parent = parent_1;
529
+ term.parent = parent;
568
530
  // Remove the term from the path
569
531
  path.splice(0, 1);
570
532
  }
@@ -574,8 +536,8 @@ exports.Taxonomy = {
574
536
  // Ensure the terms exist
575
537
  if (terms && terms.length > 0) {
576
538
  // Parse the terms
577
- for (var i = 0; i < terms.length; i++) {
578
- var term = terms[i];
539
+ for (let i = 0; i < terms.length; i++) {
540
+ let term = terms[i];
579
541
  // See if this is the root term
580
542
  if (term.pathAsString == "") {
581
543
  // Set the root information
@@ -587,7 +549,7 @@ exports.Taxonomy = {
587
549
  }
588
550
  }
589
551
  // Return the root term
590
- return exports.Taxonomy.findById(root, terms[0].id);
552
+ return Taxonomy.findById(root, terms[0].id);
591
553
  }
592
554
  // Return nothing
593
555
  return null;