@pnp/cli-microsoft365 11.1.0-beta.5b5ee32 → 11.1.0-beta.734344f

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 (91) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +10 -7
  4. package/dist/Command.js +2 -2
  5. package/dist/auth/msalCachePlugin.js +6 -2
  6. package/dist/autocomplete.js +6 -2
  7. package/dist/chili/chili.js +2 -1
  8. package/dist/cli/cli.js +4 -2
  9. package/dist/config.js +0 -1
  10. package/dist/m365/adaptivecard/commands/adaptivecard-send.js +2 -2
  11. package/dist/m365/app/commands/permission/permission-list.js +4 -2
  12. package/dist/m365/commands/setup.js +6 -3
  13. package/dist/m365/entra/commands/app/app-role-add.js +1 -1
  14. package/dist/m365/entra/commands/group/group-add.js +1 -1
  15. package/dist/m365/entra/commands/group/group-set.js +1 -1
  16. package/dist/m365/entra/commands/m365group/m365group-add.js +0 -1
  17. package/dist/m365/file/commands/convert/convert-pdf.js +1 -6
  18. package/dist/m365/flow/commands/flow-export.js +8 -5
  19. package/dist/m365/flow/commands/run/run-get.js +3 -3
  20. package/dist/m365/graph/commands/schemaextension/schemaextension-set.js +1 -1
  21. package/dist/m365/pa/commands/app/app-export.js +1 -1
  22. package/dist/m365/pa/commands/app/app-get.js +1 -1
  23. package/dist/m365/planner/commands/tenant/tenant-settings-list.js +5 -0
  24. package/dist/m365/pp/commands/solution/solution-publisher-get.js +1 -1
  25. package/dist/m365/purview/commands/retentioneventtype/retentioneventtype-list.js +5 -0
  26. package/dist/m365/purview/commands/retentionlabel/retentionlabel-list.js +5 -0
  27. package/dist/m365/spfx/commands/package/package-generate.js +3 -1
  28. package/dist/m365/spfx/commands/project/base-project-command.js +13 -5
  29. package/dist/m365/spfx/commands/project/project-doctor/rules/FN021007_PKG_only_one_rush_stack_compiler_installed.js +1 -1
  30. package/dist/m365/spfx/commands/project/project-externalize/rules/PnPJsRule.js +6 -4
  31. package/dist/m365/spfx/commands/project/project-model/ScssFile.js +3 -1
  32. package/dist/m365/spfx/commands/project/project-model/TsFile.js +6 -2
  33. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.15.2.js +1 -1
  34. package/dist/m365/spfx/commands/spfx-doctor.js +5 -5
  35. package/dist/m365/spo/commands/file/file-add.js +4 -2
  36. package/dist/m365/spo/commands/file/file-rename.js +3 -4
  37. package/dist/m365/spo/commands/hubsite/hubsite-list.js +1 -1
  38. package/dist/m365/spo/commands/listitem/listitem-attachment-add.js +1 -1
  39. package/dist/m365/spo/commands/listitem/listitem-batch-set.js +9 -5
  40. package/dist/m365/spo/commands/page/clientsidepages.js +12 -12
  41. package/dist/m365/spo/commands/page/page-add.js +4 -2
  42. package/dist/m365/spo/commands/page/page-clientsidewebpart-add.js +1 -0
  43. package/dist/m365/spo/commands/page/page-set.js +4 -2
  44. package/dist/m365/spo/commands/page/page-text-add.js +1 -0
  45. package/dist/m365/spo/commands/propertybag/propertybag-base.js +34 -54
  46. package/dist/m365/spo/commands/theme/theme-apply.js +1 -1
  47. package/dist/m365/spo/commands/web/web-reindex.js +17 -27
  48. package/dist/m365/teams/commands/tab/tab-add.js +9 -3
  49. package/dist/m365/viva/commands/connections/connections-app-create.js +1 -1
  50. package/dist/m365/viva/commands/engage/engage-community-user-add.js +1 -1
  51. package/dist/m365/viva/commands/engage/engage-community-user-remove.js +1 -1
  52. package/dist/telemetry.js +3 -1
  53. package/dist/utils/accessToken.js +4 -0
  54. package/dist/utils/cache.js +3 -2
  55. package/dist/utils/customAppScope.js +1 -1
  56. package/dist/utils/directoryExtension.js +1 -1
  57. package/dist/utils/entraAdministrativeUnit.js +1 -1
  58. package/dist/utils/entraApp.js +2 -2
  59. package/dist/utils/entraDevice.js +1 -1
  60. package/dist/utils/entraServicePrincipal.js +2 -2
  61. package/dist/utils/formatting.js +1 -1
  62. package/dist/utils/md.js +2 -2
  63. package/dist/utils/odata.js +2 -0
  64. package/dist/utils/planner.js +1 -1
  65. package/dist/utils/powerPlatform.js +2 -2
  66. package/dist/utils/roleDefinition.js +2 -2
  67. package/dist/utils/spo.js +10 -11
  68. package/dist/utils/urlUtil.js +1 -1
  69. package/dist/utils/validation.js +1 -1
  70. package/dist/utils/vivaEngage.js +3 -3
  71. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-add.mdx +14 -0
  72. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-get.mdx +15 -0
  73. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-list.mdx +14 -0
  74. package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-remove.mdx +14 -0
  75. package/docs/docs/cmd/entra/groupsetting/groupsetting-add.mdx +19 -0
  76. package/docs/docs/cmd/entra/groupsetting/groupsetting-get.mdx +19 -0
  77. package/docs/docs/cmd/entra/groupsetting/groupsetting-list.mdx +19 -0
  78. package/docs/docs/cmd/entra/groupsetting/groupsetting-remove.mdx +21 -0
  79. package/docs/docs/cmd/entra/groupsetting/groupsetting-set.mdx +21 -0
  80. package/docs/docs/cmd/entra/m365group/m365group-add.mdx +19 -0
  81. package/docs/docs/cmd/entra/m365group/m365group-get.mdx +19 -0
  82. package/docs/docs/cmd/entra/m365group/m365group-list.mdx +19 -0
  83. package/docs/docs/cmd/entra/m365group/m365group-remove.mdx +21 -0
  84. package/docs/docs/cmd/entra/m365group/m365group-renew.mdx +21 -0
  85. package/docs/docs/cmd/entra/m365group/m365group-set.mdx +21 -0
  86. package/docs/docs/cmd/entra/m365group/m365group-teamify.mdx +19 -0
  87. package/eslint-rules/lib/rules/correct-command-class-name.js +18 -2
  88. package/eslint.config.mjs +270 -0
  89. package/npm-shrinkwrap.json +1117 -2277
  90. package/package.json +22 -21
  91. package/.eslintrc.cjs +0 -289
@@ -81,11 +81,10 @@ class SpoFileRenameCommand extends SpoCommand {
81
81
  await cli.executeCommand(removeCommand, { options: { ...removeOptions, _: [] } });
82
82
  }
83
83
  catch (err) {
84
- if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) {
85
- }
86
- else {
87
- throw err;
84
+ if (err?.error?.message?.includes('does not exist')) {
85
+ return;
88
86
  }
87
+ throw err;
89
88
  }
90
89
  }
91
90
  }
@@ -86,7 +86,7 @@ class SpoHubSiteListCommand extends SpoCommand {
86
86
  await logger.logToStderr(res);
87
87
  await logger.logToStderr(`Retrieved ${res.Row.length} sites in batch ${batchNumber}`);
88
88
  }
89
- if (!!res.NextHref) {
89
+ if (res.NextHref) {
90
90
  reqOptions.url = nonPagedUrl + res.NextHref;
91
91
  if (this.debug) {
92
92
  await logger.logToStderr(`Url for next batch of sites: ${reqOptions.url}`);
@@ -57,7 +57,7 @@ class SpoListItemAttachmentAddCommand extends SpoCommand {
57
57
  }
58
58
  getFileName(filePath, fileName) {
59
59
  if (!fileName) {
60
- return filePath.replace(/^.*[\\\/]/, '');
60
+ return filePath.replace(/^.*[\\/]/, '');
61
61
  }
62
62
  const extension = filePath.split('.').pop();
63
63
  if (!fileName.endsWith(`.${extension}`)) {
@@ -37,7 +37,7 @@ class SpoListItemBatchSetCommand extends SpoCommand {
37
37
  const jsonContent = formatting.parseCsvToJson(csvContent);
38
38
  const amountOfRows = jsonContent.length;
39
39
  const idColumn = args.options.idColumn || 'ID';
40
- if (!jsonContent[0].hasOwnProperty(idColumn)) {
40
+ if (!Object.prototype.hasOwnProperty.call(jsonContent[0], idColumn)) {
41
41
  throw `The specified value for idColumn does not exist in the array. Specified idColumn is '${args.options.idColumn || 'ID'}'. Please specify the correct value.`;
42
42
  }
43
43
  const listId = args.options.listId ?
@@ -97,26 +97,30 @@ class SpoListItemBatchSetCommand extends SpoCommand {
97
97
  }
98
98
  else {
99
99
  switch (field.TypeAsString) {
100
- case 'User':
100
+ case 'User': {
101
101
  const userDetail = users.find(us => us.email === row[field.InternalName]);
102
102
  actionString += `<Method Name="ParseAndSetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="String">${userDetail.id}</Parameter></Parameters></Method>`;
103
103
  break;
104
- case 'UserMulti':
104
+ }
105
+ case 'UserMulti': {
105
106
  const userMultiString = row[field.InternalName].toString().split(';').map((element) => {
106
107
  const userDetail = users.find(us => us.email === element);
107
108
  return `<Object TypeId="{c956ab54-16bd-4c18-89d2-996f57282a6f}"><Property Name="Email" Type="Null" /><Property Name="LookupId" Type="Int32">${userDetail.id}</Property><Property Name="LookupValue" Type="Null" /></Object>`;
108
109
  });
109
110
  actionString += `<Method Name="SetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="Array">${userMultiString.join('')}</Parameter></Parameters></Method>`;
110
111
  break;
111
- case 'Lookup':
112
+ }
113
+ case 'Lookup': {
112
114
  actionString += `<Method Name="SetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter TypeId="{f1d34cc0-9b50-4a78-be78-d5facfcccfb7}"><Property Name="LookupId" Type="Int32">${row[field.InternalName]}</Property><Property Name="LookupValue" Type="Null"/></Parameter></Parameters></Method>`;
113
115
  break;
114
- case 'LookupMulti':
116
+ }
117
+ case 'LookupMulti': {
115
118
  const lookupMultiString = row[field.InternalName].toString().split(';').map((element) => {
116
119
  return `<Object TypeId="{f1d34cc0-9b50-4a78-be78-d5facfcccfb7}"><Property Name="LookupId" Type="Int32">${element}</Property><Property Name="LookupValue" Type="Null" /></Object>`;
117
120
  });
118
121
  actionString += `<Method Name="SetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="Array">${lookupMultiString.join('')}</Parameter></Parameters></Method>`;
119
122
  break;
123
+ }
120
124
  default:
121
125
  actionString += `<Method Name="ParseAndSetFieldValue" Id="${index += 1}" ObjectPathId="${objectPathId}"><Parameters><Parameter Type="String">${field.InternalName}</Parameter><Parameter Type="String">${formatting.escapeXml(row[field.InternalName].toString())}</Parameter></Parameters></Method>`;
122
126
  break;
@@ -238,11 +238,11 @@ export class ClientSidePage {
238
238
  .replace(/:/g, "&#58;")
239
239
  .replace(/{/g, "&#123;")
240
240
  .replace(/}/g, "&#125;")
241
- .replace(/\[/g, "\[")
242
- .replace(/\]/g, "\]")
243
- .replace(/\*/g, "\*")
244
- .replace(/\$/g, "\$")
245
- .replace(/\./g, "\.");
241
+ .replace(/\[/g, "[")
242
+ .replace(/\]/g, "]")
243
+ .replace(/\*/g, "*")
244
+ .replace(/\$/g, "$")
245
+ .replace(/\./g, ".");
246
246
  }
247
247
  /**
248
248
  * Converts an escaped string from a client-side control attribute to a json object
@@ -258,7 +258,7 @@ export class ClientSidePage {
258
258
  [/\\/g, "\\\\"], [/&quot;/g, "\""], [/&#58;/g, ":"], [/&#123;/g, "{"], [/&#125;/g, "}"],
259
259
  [/\\\\/g, "\\"], [/\\\?/g, "?"], [/\\\./g, "."], [/\\\[/g, "["], [/\\\]/g, "]"],
260
260
  [/\\\(/g, "("], [/\\\)/g, ")"], [/\\\|/g, "|"], [/\\\+/g, "+"], [/\\\*/g, "*"],
261
- [/\\\$/g, "$"],
261
+ [/\\\$/g, "$"]
262
262
  ];
263
263
  return mapDict.reduce((r, m) => r.replace(m[0], m[1]), escaped);
264
264
  };
@@ -298,7 +298,7 @@ export class ClientSidePage {
298
298
  // get the control type
299
299
  const ct = /controlType&quot;&#58;(\d*?)(,|&)/i.exec(markup);
300
300
  // if no control type is present this is a column which we give type 0 to let us process it
301
- const controlType = ct == null || ct.length < 0 ? -1 : parseInt(ct[1], 10);
301
+ const controlType = ct === null || ct.length < 0 ? -1 : parseInt(ct[1], 10);
302
302
  let control = null;
303
303
  switch (controlType) {
304
304
  case -1:
@@ -562,7 +562,7 @@ export class CanvasColumn extends CanvasControl {
562
562
  sectionIndex: this.order,
563
563
  zoneIndex: this.section?.order || 0,
564
564
  zoneId: this.section?.zoneId,
565
- layoutIndex: this.section?.layoutIndex,
565
+ layoutIndex: this.section?.layoutIndex
566
566
  },
567
567
  zoneGroupMetadata: this.section?.zoneGroupMetadata,
568
568
  emphasis: this.section?.emphasis
@@ -620,7 +620,7 @@ export class BackgroundSettings extends ClientSidePart {
620
620
  dataVersion: this.dataVersion,
621
621
  instanceId: this.id,
622
622
  properties: this.propertieJson,
623
- serverProcessedContent: this.serverProcessedContent,
623
+ serverProcessedContent: this.serverProcessedContent
624
624
  };
625
625
  const html = [];
626
626
  html.push(`<div data-sp-canvascontrol="" data-sp-canvasdataversion="${this.dataVersion}" data-sp-controldata="${this.jsonData}">`);
@@ -687,7 +687,7 @@ export class ClientSideText extends ClientSidePart {
687
687
  layoutIndex: this.column?.section?.layoutIndex
688
688
  },
689
689
  zoneGroupMetadata: this.column?.section?.zoneGroupMetadata,
690
- emphasis: this.column?.section?.emphasis,
690
+ emphasis: this.column?.section?.emphasis
691
691
  };
692
692
  if (this.column?.section?.isLayoutReflowOnTop !== undefined) {
693
693
  controlData.position.isLayoutReflowOnTop = this.column.section.isLayoutReflowOnTop;
@@ -806,11 +806,11 @@ export class ClientSideWebpart extends ClientSidePart {
806
806
  sectionIndex: this.column ? this.column.order : 0,
807
807
  zoneIndex: this.column && this.column.section ? this.column.section.order : 0,
808
808
  zoneId: this.column?.section?.zoneId,
809
- layoutIndex: this.column?.section?.layoutIndex,
809
+ layoutIndex: this.column?.section?.layoutIndex
810
810
  },
811
811
  webPartId: this.webPartId,
812
812
  zoneGroupMetadata: this.column?.section?.zoneGroupMetadata,
813
- emphasis: this.column?.section?.emphasis,
813
+ emphasis: this.column?.section?.emphasis
814
814
  };
815
815
  if (this.column?.section?.isLayoutReflowOnTop !== undefined) {
816
816
  controlData.position.isLayoutReflowOnTop = this.column.section.isLayoutReflowOnTop;
@@ -89,7 +89,7 @@ class SpoPageAddCommand extends SpoCommand {
89
89
  };
90
90
  await request.post(requestOptions);
91
91
  break;
92
- case 'NewsPage':
92
+ case 'NewsPage': {
93
93
  const listItemSetOptions = {
94
94
  FirstPublishedDate: new Date().toISOString()
95
95
  };
@@ -97,7 +97,8 @@ class SpoPageAddCommand extends SpoCommand {
97
97
  const requestUrl = `${args.options.webUrl}/_api/web/GetList('${formatting.encodeQueryParameter(listUrl)}')`;
98
98
  await spo.systemUpdateListItem(requestUrl, listItemId, logger, this.verbose, listItemSetOptions);
99
99
  break;
100
- case 'Template':
100
+ }
101
+ case 'Template': {
101
102
  requestOptions.url = `${args.options.webUrl}/_api/SitePages/Pages(${listItemId})/SavePageAsTemplate`;
102
103
  requestOptions.headers = {
103
104
  'X-RequestDigest': requestDigest,
@@ -119,6 +120,7 @@ class SpoPageAddCommand extends SpoCommand {
119
120
  };
120
121
  await request.post(requestOptions);
121
122
  break;
123
+ }
122
124
  }
123
125
  }
124
126
  requestOptions = {
@@ -233,6 +233,7 @@ class SpoPageClientSideWebPartAddCommand extends SpoCommand {
233
233
  webPart.webPartData.properties = this.extend(webPart.webPartData.properties, properties);
234
234
  }
235
235
  catch {
236
+ // Do nothing
236
237
  }
237
238
  }
238
239
  if (args.options.webPartData) {
@@ -94,7 +94,7 @@ class SpoPageSetCommand extends SpoCommand {
94
94
  };
95
95
  await request.post(requestOptions);
96
96
  break;
97
- case 'NewsPage':
97
+ case 'NewsPage': {
98
98
  const newsPageItem = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
99
99
  const newsPageItemId = newsPageItem.Id;
100
100
  const listItemSetOptions = {
@@ -103,7 +103,8 @@ class SpoPageSetCommand extends SpoCommand {
103
103
  };
104
104
  await spo.systemUpdateListItem(requestUrl, newsPageItemId, logger, this.verbose, listItemSetOptions);
105
105
  break;
106
- case 'Template':
106
+ }
107
+ case 'Template': {
107
108
  const templateItem = await spo.getFileAsListItemByUrl(args.options.webUrl, serverRelativeFileUrl, logger, this.verbose);
108
109
  const templateItemId = templateItem.Id;
109
110
  requestOptions.headers = {
@@ -132,6 +133,7 @@ class SpoPageSetCommand extends SpoCommand {
132
133
  }
133
134
  pageId = res.Id;
134
135
  break;
136
+ }
135
137
  }
136
138
  }
137
139
  if (args.options.promoteAs !== 'Template') {
@@ -49,6 +49,7 @@ class SpoPageTextAddCommand extends SpoCommand {
49
49
  // Add a new section when page does not contain any sections
50
50
  if (page.sections.length < 1) {
51
51
  const newSection = new CanvasSection(page, 1);
52
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
52
53
  newSection.defaultColumn;
53
54
  page.sections.push(newSection);
54
55
  }
@@ -25,28 +25,23 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
25
25
  },
26
26
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><ObjectPath Id="10" ObjectPathId="9" /><ObjectIdentityQuery Id="11" ObjectPathId="9" /><Query Id="12" ObjectPathId="9"><Query SelectAllProperties="false"><Properties><Property Name="Properties" SelectAll="true"><Query SelectAllProperties="false"><Properties /></Query></Property></Properties></Query></Query></Actions><ObjectPaths><Method Id="9" ParentId="5" Name="GetFolderByServerRelativeUrl"><Parameters><Parameter Type="String">${serverRelativeUrl}</Parameter></Parameters></Method><Identity Id="5" Name="${identityResp.objectIdentity}" /></ObjectPaths></Request>`
27
27
  };
28
- try {
29
- const res = await request.post(requestOptions);
30
- if (this.debug) {
31
- await logger.logToStderr('Attempt to get Properties key values');
32
- }
33
- const json = JSON.parse(res);
34
- const contents = json.find(x => { return x['ErrorInfo']; });
35
- if (contents && contents.ErrorInfo) {
36
- throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
37
- }
38
- const propertiesObj = json.find(x => { return x['Properties']; });
39
- if (propertiesObj) {
40
- return propertiesObj['Properties'];
41
- }
42
- throw 'Cannot proceed. Properties not found'; // this is not suppose to happen
28
+ const res = await request.post(requestOptions);
29
+ if (this.verbose) {
30
+ await logger.logToStderr('Attempt to get Properties key values');
31
+ }
32
+ const json = JSON.parse(res);
33
+ const contents = json.find(x => { return x['ErrorInfo']; });
34
+ if (contents && contents.ErrorInfo) {
35
+ throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
43
36
  }
44
- catch (err) {
45
- throw err;
37
+ const propertiesObj = json.find(x => { return x['Properties']; });
38
+ if (propertiesObj) {
39
+ return propertiesObj['Properties'];
46
40
  }
41
+ throw 'Cannot proceed. Properties not found'; // this is not suppose to happen
47
42
  }
48
43
  /**
49
- * Gets property bag for site or sitecollection where return type is "_ObjectType_\":\"SP.Web\".
44
+ * Gets property bag for site or site collection where return type is "_ObjectType_\":\"SP.Web\".
50
45
  * This method is executed when no folder specified. PnP PowerShell behaves the same way.
51
46
  */
52
47
  async getWebPropertyBag(identityResp, webUrl, logger) {
@@ -57,25 +52,20 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
57
52
  },
58
53
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Query Id="97" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="ServerRelativeUrl" ScalarProperty="true" /><Property Name="AllProperties" SelectAll="true"><Query SelectAllProperties="false"><Properties /></Query></Property></Properties></Query></Query></Actions><ObjectPaths><Identity Id="5" Name="${identityResp.objectIdentity}" /></ObjectPaths></Request>`
59
54
  };
60
- try {
61
- const res = await request.post(requestOptions);
62
- if (this.debug) {
63
- await logger.logToStderr('Attempt to get AllProperties key values');
64
- }
65
- const json = JSON.parse(res);
66
- const contents = json.find(x => { return x['ErrorInfo']; });
67
- if (contents && contents.ErrorInfo) {
68
- throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
69
- }
70
- const allPropertiesObj = json.find(x => { return x['AllProperties']; });
71
- if (allPropertiesObj) {
72
- return allPropertiesObj['AllProperties'];
73
- }
74
- throw 'Cannot proceed. AllProperties not found'; // this is not supposed to happen
55
+ const res = await request.post(requestOptions);
56
+ if (this.verbose) {
57
+ await logger.logToStderr('Attempt to get AllProperties key values');
75
58
  }
76
- catch (err) {
77
- throw err;
59
+ const json = JSON.parse(res);
60
+ const contents = json.find(x => { return x['ErrorInfo']; });
61
+ if (contents && contents.ErrorInfo) {
62
+ throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
78
63
  }
64
+ const allPropertiesObj = json.find(x => { return x['AllProperties']; });
65
+ if (allPropertiesObj) {
66
+ return allPropertiesObj['AllProperties'];
67
+ }
68
+ throw 'Cannot proceed. AllProperties not found'; // this is not supposed to happen
79
69
  }
80
70
  /**
81
71
  * The property bag item data returned from the client.svc/ProcessQuery response
@@ -122,19 +112,14 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
122
112
  },
123
113
  data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Method Name="SetFieldValue" Id="206" ObjectPathId="205"><Parameters><Parameter Type="String">${formatting.escapeXml(name)}</Parameter><Parameter Type="String">${formatting.escapeXml(value)}</Parameter></Parameters></Method><Method Name="Update" Id="207" ObjectPathId="198" /></Actions><ObjectPaths><Property Id="205" ParentId="198" Name="${objectType}" /><Identity Id="198" Name="${identityResp.objectIdentity}" /></ObjectPaths></Request>`
124
114
  };
125
- try {
126
- const res = await request.post(requestOptions);
127
- const json = JSON.parse(res);
128
- const contents = json.find(x => { return x['ErrorInfo']; });
129
- if (contents && contents.ErrorInfo) {
130
- throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
131
- }
132
- else {
133
- return res;
134
- }
115
+ const res = await request.post(requestOptions);
116
+ const json = JSON.parse(res);
117
+ const contents = json.find(x => { return x['ErrorInfo']; });
118
+ if (contents && contents.ErrorInfo) {
119
+ throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
135
120
  }
136
- catch (err) {
137
- throw err;
121
+ else {
122
+ return res;
138
123
  }
139
124
  }
140
125
  /**
@@ -146,13 +131,8 @@ export class SpoPropertyBagBaseCommand extends SpoCommand {
146
131
  * @param cmd command instance
147
132
  */
148
133
  static async isNoScriptSite(webUrl, formDigest, webIdentityResp, logger, debug) {
149
- try {
150
- const basePermissionsResp = await spo.getEffectiveBasePermissions(webIdentityResp.objectIdentity, webUrl, formDigest, logger, debug);
151
- return basePermissionsResp.has(PermissionKind.AddAndCustomizePages) === false;
152
- }
153
- catch (err) {
154
- throw err;
155
- }
134
+ const basePermissionsResp = await spo.getEffectiveBasePermissions(webIdentityResp.objectIdentity, webUrl, formDigest, logger, debug);
135
+ return basePermissionsResp.has(PermissionKind.AddAndCustomizePages) === false;
156
136
  }
157
137
  }
158
138
  //# sourceMappingURL=propertybag-base.js.map
@@ -125,7 +125,7 @@ class SpoThemeApplyCommand extends SpoCommand {
125
125
  }
126
126
  return `{
127
127
  'name': '${themeName}' ,
128
- 'themeJson': '{\"palette\": {${palette}}}'
128
+ 'themeJson': '{"palette": {${palette}}}'
129
129
  }`;
130
130
  }
131
131
  }
@@ -67,24 +67,19 @@ class SpoWebReindexCommand extends SpoCommand {
67
67
  }
68
68
  }
69
69
  async reindexLists(webUrl, requestDigest, logger, webIdentityResp) {
70
- try {
71
- if (this.debug) {
72
- await logger.logToStderr(`Retrieving information about lists...`);
73
- }
74
- const requestOptions = {
75
- url: `${webUrl}/_api/web/lists?$select=NoCrawl,Title,RootFolder/Properties,RootFolder/ServerRelativeUrl&$expand=RootFolder/Properties`,
76
- headers: {
77
- 'accept': 'application/json;odata=nometadata'
78
- },
79
- responseType: 'json'
80
- };
81
- const lists = await request.get(requestOptions);
82
- const promises = lists.value.map(l => this.reindexList(l, webUrl, requestDigest, webIdentityResp, logger));
83
- await Promise.all(promises);
84
- }
85
- catch (err) {
86
- throw err;
70
+ if (this.debug) {
71
+ await logger.logToStderr(`Retrieving information about lists...`);
87
72
  }
73
+ const requestOptions = {
74
+ url: `${webUrl}/_api/web/lists?$select=NoCrawl,Title,RootFolder/Properties,RootFolder/ServerRelativeUrl&$expand=RootFolder/Properties`,
75
+ headers: {
76
+ 'accept': 'application/json;odata=nometadata'
77
+ },
78
+ responseType: 'json'
79
+ };
80
+ const lists = await request.get(requestOptions);
81
+ const promises = lists.value.map(l => this.reindexList(l, webUrl, requestDigest, webIdentityResp, logger));
82
+ await Promise.all(promises);
88
83
  }
89
84
  async reindexList(list, webUrl, requestDigest, webIdentityResp, logger) {
90
85
  if (list.NoCrawl) {
@@ -93,16 +88,11 @@ class SpoWebReindexCommand extends SpoCommand {
93
88
  }
94
89
  return;
95
90
  }
96
- try {
97
- const folderIdentityResp = await spo.getFolderIdentity(webIdentityResp.objectIdentity, webUrl, list.RootFolder.ServerRelativeUrl, requestDigest);
98
- let searchversion = list.RootFolder.Properties.vti_x005f_searchversion || 0;
99
- searchversion++;
100
- await SpoPropertyBagBaseCommand.setProperty('vti_searchversion', searchversion.toString(), webUrl, requestDigest, folderIdentityResp, logger, this.debug, list.RootFolder.ServerRelativeUrl);
101
- return;
102
- }
103
- catch (err) {
104
- throw (err);
105
- }
91
+ const folderIdentityResp = await spo.getFolderIdentity(webIdentityResp.objectIdentity, webUrl, list.RootFolder.ServerRelativeUrl, requestDigest);
92
+ let searchversion = list.RootFolder.Properties.vti_x005f_searchversion || 0;
93
+ searchversion++;
94
+ await SpoPropertyBagBaseCommand.setProperty('vti_searchversion', searchversion.toString(), webUrl, requestDigest, folderIdentityResp, logger, this.debug, list.RootFolder.ServerRelativeUrl);
95
+ return;
106
96
  }
107
97
  }
108
98
  _SpoWebReindexCommand_instances = new WeakSet(), _SpoWebReindexCommand_initOptions = function _SpoWebReindexCommand_initOptions() {
@@ -70,9 +70,15 @@ class TeamsTabAddCommand extends GraphCommand {
70
70
  if (options.contentUrl) {
71
71
  requestBody.configuration.contentUrl = options.contentUrl;
72
72
  }
73
- options.entityId ? requestBody.configuration.entityId = options.entityId : null;
74
- options.removeUrl ? requestBody.configuration.removeUrl = options.removeUrl : null;
75
- options.websiteUrl ? requestBody.configuration.websiteUrl = options.websiteUrl : null;
73
+ if (options.entityId) {
74
+ requestBody.configuration.entityId = options.entityId;
75
+ }
76
+ if (options.removeUrl) {
77
+ requestBody.configuration.removeUrl = options.removeUrl;
78
+ }
79
+ if (options.websiteUrl) {
80
+ requestBody.configuration.websiteUrl = options.websiteUrl;
81
+ }
76
82
  Object.keys(options).forEach(key => {
77
83
  if (excludeOptions.indexOf(key) === -1) {
78
84
  requestBody.configuration[key] = `${options[key]}`;
@@ -44,7 +44,7 @@ class VivaConnectionsAppCreateCommand extends AnonymousCommand {
44
44
  const appPortalUrl = `${args.options.portalUrl}${args.options.portalUrl.indexOf('?') > -1 ? '&' : '?'}app=portals`;
45
45
  let searchUrlPath = portalUrl.hostname;
46
46
  if (portalUrl.pathname.indexOf('/teams') > -1 || portalUrl.pathname.indexOf('/sites') > -1) {
47
- const firstTwoUrlSegments = portalUrl.pathname.match(/^\/[^\/]+\/[^\/]+/);
47
+ const firstTwoUrlSegments = portalUrl.pathname.match(/^\/[^/]+\/[^/]+/);
48
48
  if (firstTwoUrlSegments) {
49
49
  searchUrlPath += firstTwoUrlSegments[0];
50
50
  }
@@ -48,7 +48,7 @@ class VivaEngageCommunityUserAddCommand extends GraphCommand {
48
48
  .refine(options => options.ids || options.userNames, {
49
49
  message: 'Specify either of ids or userNames.'
50
50
  })
51
- .refine(options => typeof options.userNames !== undefined && typeof options.ids !== undefined, {
51
+ .refine(options => options.userNames !== undefined || options.ids !== undefined, {
52
52
  message: 'Specify either ids or userNames, but not both.'
53
53
  });
54
54
  }
@@ -48,7 +48,7 @@ class VivaEngageCommunityUserRemoveCommand extends GraphCommand {
48
48
  .refine(options => options.id || options.userName, {
49
49
  message: 'Specify either of id or userName.'
50
50
  })
51
- .refine(options => typeof options.userName !== undefined && typeof options.id !== undefined, {
51
+ .refine(options => options.userName !== undefined || options.id !== undefined, {
52
52
  message: 'Specify either id or userName, but not both.'
53
53
  });
54
54
  }
package/dist/telemetry.js CHANGED
@@ -21,7 +21,9 @@ async function trackTelemetry(object) {
21
21
  }
22
22
  await appInsights.flush();
23
23
  }
24
- catch { }
24
+ catch {
25
+ // Do nothing
26
+ }
25
27
  }
26
28
  export const telemetry = {
27
29
  trackEvent: async (commandName, properties, exception) => {
@@ -16,6 +16,7 @@ export const accessToken = {
16
16
  isAppOnlyAccessToken = token.idtyp === 'app';
17
17
  }
18
18
  catch {
19
+ // Do nothing
19
20
  }
20
21
  return isAppOnlyAccessToken;
21
22
  },
@@ -34,6 +35,7 @@ export const accessToken = {
34
35
  tenantId = token.tid;
35
36
  }
36
37
  catch {
38
+ // Do nothing
37
39
  }
38
40
  return tenantId;
39
41
  },
@@ -54,6 +56,7 @@ export const accessToken = {
54
56
  userName = token.upn || token.app_displayname;
55
57
  }
56
58
  catch {
59
+ // Do nothing
57
60
  }
58
61
  return userName;
59
62
  },
@@ -72,6 +75,7 @@ export const accessToken = {
72
75
  userId = token.oid;
73
76
  }
74
77
  catch {
78
+ // Do nothing
75
79
  }
76
80
  return userId;
77
81
  },
@@ -28,7 +28,9 @@ export const cache = {
28
28
  // eslint-disable-next-line @typescript-eslint/no-empty-function
29
29
  fs.writeFile(cacheFilePath, value, () => { });
30
30
  }
31
- catch { }
31
+ catch {
32
+ // Do nothing
33
+ }
32
34
  },
33
35
  clearExpired(cb) {
34
36
  // we don't need to wait for this to complete
@@ -58,7 +60,6 @@ export const cache = {
58
60
  // remove files that haven't been accessed in the last 24 hours
59
61
  if (stats.atime.getTime() < Date.now() - 24 * 60 * 60 * 1000) {
60
62
  // we don't need to wait for the file to be deleted
61
- // eslint-disable-next-line @typescript-eslint/no-empty-function
62
63
  fs.unlink(path.join(cacheFolderPath, file), () => {
63
64
  if (cb && index === numFiles - 1) {
64
65
  cb();
@@ -16,7 +16,7 @@ export const customAppScope = {
16
16
  }
17
17
  const customAppScopes = await odata.getAllItems(url);
18
18
  if (customAppScopes.length === 0) {
19
- throw `The specified custom application scope '${displayName}' does not exist.`;
19
+ throw new Error(`The specified custom application scope '${displayName}' does not exist.`);
20
20
  }
21
21
  if (customAppScopes.length > 1) {
22
22
  const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', customAppScopes);
@@ -16,7 +16,7 @@ export const directoryExtension = {
16
16
  }
17
17
  const extensionProperties = await odata.getAllItems(url);
18
18
  if (extensionProperties.length === 0) {
19
- throw `The specified directory extension '${name}' does not exist.`;
19
+ throw new Error(`The specified directory extension '${name}' does not exist.`);
20
20
  }
21
21
  // there can be only one directory extension with a given name
22
22
  return extensionProperties[0];
@@ -24,7 +24,7 @@ export const entraAdministrativeUnit = {
24
24
  const graphResource = 'https://graph.microsoft.com';
25
25
  const administrativeUnits = await odata.getAllItems(`${graphResource}/v1.0/directory/administrativeUnits?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'${queryString}`);
26
26
  if (administrativeUnits.length === 0) {
27
- throw `The specified administrative unit '${displayName}' does not exist.`;
27
+ throw new Error(`The specified administrative unit '${displayName}' does not exist.`);
28
28
  }
29
29
  if (administrativeUnits.length > 1) {
30
30
  const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', administrativeUnits);
@@ -305,7 +305,7 @@ export const entraApp = {
305
305
  }
306
306
  const apps = await odata.getAllItems(url);
307
307
  if (apps.length === 0) {
308
- throw `App with appId '${appId}' not found in Microsoft Entra ID`;
308
+ throw new Error(`App with appId '${appId}' not found in Microsoft Entra ID.`);
309
309
  }
310
310
  return apps[0];
311
311
  },
@@ -316,7 +316,7 @@ export const entraApp = {
316
316
  }
317
317
  const apps = await odata.getAllItems(url);
318
318
  if (apps.length === 0) {
319
- throw `App with name '${appName}' not found in Microsoft Entra ID`;
319
+ throw new Error(`App with name '${appName}' not found in Microsoft Entra ID.`);
320
320
  }
321
321
  if (apps.length > 1) {
322
322
  const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', apps);
@@ -12,7 +12,7 @@ export const entraDevice = {
12
12
  async getDeviceByDisplayName(displayName) {
13
13
  const devices = await odata.getAllItems(`${graphResource}/v1.0/devices?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`);
14
14
  if (devices.length === 0) {
15
- throw `The specified device '${displayName}' does not exist.`;
15
+ throw new Error(`The specified device '${displayName}' does not exist.`);
16
16
  }
17
17
  if (devices.length > 1) {
18
18
  const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', devices);
@@ -17,7 +17,7 @@ export const entraServicePrincipal = {
17
17
  }
18
18
  const apps = await odata.getAllItems(url);
19
19
  if (apps.length === 0) {
20
- throw `Service principal with appId '${appId}' not found in Microsoft Entra ID`;
20
+ throw new Error(`Service principal with appId '${appId}' not found in Microsoft Entra ID.`);
21
21
  }
22
22
  return apps[0];
23
23
  },
@@ -35,7 +35,7 @@ export const entraServicePrincipal = {
35
35
  }
36
36
  const apps = await odata.getAllItems(url);
37
37
  if (apps.length === 0) {
38
- throw `Service principal with name '${appName}' not found in Microsoft Entra ID`;
38
+ throw new Error(`Service principal with name '${appName}' not found in Microsoft Entra ID.`);
39
39
  }
40
40
  if (apps.length > 1) {
41
41
  const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', apps);
@@ -99,7 +99,7 @@ export const formatting = {
99
99
  },
100
100
  openTypesEncoder(value) {
101
101
  return value
102
- .replace(/\%/g, '%25')
102
+ .replace(/%/g, '%25')
103
103
  .replace(/\./g, '%2E')
104
104
  .replace(/:/g, '%3A')
105
105
  .replace(/@/g, '%40')