@pnp/cli-microsoft365 10.1.0-beta.f17d225 → 10.2.0-beta.818fb50

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 (110) hide show
  1. package/README.md +2 -2
  2. package/allCommands.json +1 -1
  3. package/allCommandsFull.json +1 -1
  4. package/dist/AuthServer.js +1 -1
  5. package/dist/Command.js +2 -2
  6. package/dist/cli/cli.js +2 -2
  7. package/dist/m365/base/AppCommand.js +5 -2
  8. package/dist/m365/commands/login.js +3 -2
  9. package/dist/m365/entra/commands/administrativeunit/administrativeunit-get.js +18 -4
  10. package/dist/m365/entra/commands/administrativeunit/administrativeunit-list.js +34 -2
  11. package/dist/m365/entra/commands/app/app-get.js +17 -5
  12. package/dist/m365/entra/commands/app/app-list.js +34 -2
  13. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-add.js +3 -0
  14. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-get.js +3 -0
  15. package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-list.js +3 -0
  16. package/dist/m365/entra/commands/group/group-get.js +6 -3
  17. package/dist/m365/entra/commands/group/group-list.js +16 -1
  18. package/dist/m365/entra/commands/m365group/m365group-add.js +1 -1
  19. package/dist/m365/entra/commands/m365group/m365group-conversation-list.js +21 -6
  20. package/dist/m365/entra/commands/m365group/m365group-get.js +29 -7
  21. package/dist/m365/entra/commands/m365group/m365group-list.js +1 -1
  22. package/dist/m365/entra/commands/m365group/m365group-remove.js +21 -9
  23. package/dist/m365/entra/commands/m365group/m365group-renew.js +19 -7
  24. package/dist/m365/entra/commands/m365group/m365group-set.js +1 -1
  25. package/dist/m365/entra/commands/m365group/m365group-teamify.js +12 -21
  26. package/dist/m365/file/commands/convert/convert-pdf.js +3 -4
  27. package/dist/m365/file/commands/file-add.js +5 -6
  28. package/dist/m365/graph/commands/subscription/subscription-add.js +46 -5
  29. package/dist/m365/pp/commands/{chatbot/chatbot-get.js → copilot/copilot-get.js} +24 -20
  30. package/dist/m365/pp/commands/{chatbot/chatbot-list.js → copilot/copilot-list.js} +16 -12
  31. package/dist/m365/pp/commands/{chatbot/chatbot-remove.js → copilot/copilot-remove.js} +28 -24
  32. package/dist/m365/pp/commands.js +3 -0
  33. package/dist/m365/spe/ContainerProperties.js +2 -0
  34. package/dist/m365/spe/commands/container/container-list.js +87 -0
  35. package/dist/m365/spe/commands/containertype/containertype-get.js +103 -0
  36. package/dist/m365/spe/commands/containertype/containertype-list.js +2 -22
  37. package/dist/m365/spe/commands.js +2 -0
  38. package/dist/m365/spfx/commands/package/package-generate.js +1 -1
  39. package/dist/m365/spfx/commands/project/JsonRule.js +2 -2
  40. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN016004_TS_property_pane_property_import.js +2 -2
  41. package/dist/m365/spfx/commands/spfx-doctor.js +1 -1
  42. package/dist/m365/spo/commands/contenttype/contenttype-get.js +2 -2
  43. package/dist/m365/spo/commands/contenttype/contenttype-list.js +6 -3
  44. package/dist/m365/spo/commands/file/file-add.js +1 -1
  45. package/dist/m365/spo/commands/file/file-retentionlabel-ensure.js +1 -2
  46. package/dist/m365/spo/commands/file/file-retentionlabel-remove.js +1 -2
  47. package/dist/m365/spo/commands/folder/folder-retentionlabel-ensure.js +1 -2
  48. package/dist/m365/spo/commands/folder/folder-retentionlabel-remove.js +1 -2
  49. package/dist/m365/spo/commands/list/list-contenttype-list.js +5 -2
  50. package/dist/m365/spo/commands/listitem/listitem-batch-remove.js +10 -8
  51. package/dist/m365/spo/commands/listitem/listitem-batch-set.js +1 -1
  52. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-ensure.js +1 -2
  53. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-remove.js +1 -2
  54. package/dist/m365/spo/commands/page/page-add.js +1 -1
  55. package/dist/m365/spo/commands/site/site-admin-add.js +4 -12
  56. package/dist/m365/spo/commands/site/site-admin-list.js +3 -11
  57. package/dist/m365/spo/commands/site/site-admin-remove.js +4 -12
  58. package/dist/m365/spo/commands/site/site-set.js +1 -1
  59. package/dist/m365/spp/commands/model/model-remove.js +105 -0
  60. package/dist/m365/spp/commands.js +2 -1
  61. package/dist/m365/teams/commands/user/user-app-list.js +1 -1
  62. package/dist/m365/tenant/commands/report/report-office365activationcounts.js +2 -8
  63. package/dist/m365/tenant/commands/report/report-office365activationsusercounts.js +2 -8
  64. package/dist/m365/tenant/commands/report/report-office365activationsuserdetail.js +2 -8
  65. package/dist/m365/todo/commands/list/list-remove.js +2 -1
  66. package/dist/m365/todo/commands/list/list-set.js +2 -1
  67. package/dist/m365/todo/commands/task/task-add.js +2 -1
  68. package/dist/m365/todo/commands/task/task-get.js +2 -1
  69. package/dist/m365/todo/commands/task/task-list.js +2 -1
  70. package/dist/m365/todo/commands/task/task-remove.js +2 -1
  71. package/dist/m365/todo/commands/task/task-set.js +1 -1
  72. package/dist/m365/viva/commands/engage/engage-community-set.js +111 -0
  73. package/dist/m365/viva/commands.js +1 -0
  74. package/dist/utils/entraAdministrativeUnit.js +14 -2
  75. package/dist/utils/entraGroup.js +49 -6
  76. package/dist/utils/formatting.js +8 -20
  77. package/dist/utils/spo.js +23 -4
  78. package/dist/utils/spp.js +3 -3
  79. package/dist/utils/urlUtil.js +11 -14
  80. package/docs/docs/cmd/entra/administrativeunit/administrativeunit-get.mdx +10 -3
  81. package/docs/docs/cmd/entra/administrativeunit/administrativeunit-list.mdx +16 -1
  82. package/docs/docs/cmd/entra/app/app-get.mdx +13 -8
  83. package/docs/docs/cmd/entra/app/app-list.mdx +16 -1
  84. package/docs/docs/cmd/entra/group/group-get.mdx +10 -3
  85. package/docs/docs/cmd/entra/group/group-list.mdx +9 -2
  86. package/docs/docs/cmd/entra/m365group/m365group-conversation-list.mdx +12 -3
  87. package/docs/docs/cmd/entra/m365group/m365group-get.mdx +29 -5
  88. package/docs/docs/cmd/entra/m365group/m365group-remove.mdx +7 -4
  89. package/docs/docs/cmd/entra/m365group/m365group-renew.mdx +11 -2
  90. package/docs/docs/cmd/entra/m365group/m365group-teamify.mdx +12 -3
  91. package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +2 -2
  92. package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +6 -0
  93. package/docs/docs/cmd/entra/m365group/m365group-user-remove.mdx +1 -1
  94. package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +3 -3
  95. package/docs/docs/cmd/graph/subscription/subscription-add.mdx +30 -5
  96. package/docs/docs/cmd/login.mdx +45 -44
  97. package/docs/docs/cmd/pp/{chatbot/chatbot-get.mdx → copilot/copilot-get.mdx} +24 -18
  98. package/docs/docs/cmd/pp/{chatbot/chatbot-list.mdx → copilot/copilot-list.mdx} +20 -14
  99. package/docs/docs/cmd/pp/{chatbot/chatbot-remove.mdx → copilot/copilot-remove.mdx} +16 -10
  100. package/docs/docs/cmd/pp/managementapp/managementapp-add.mdx +1 -1
  101. package/docs/docs/cmd/spe/container/container-list.mdx +97 -0
  102. package/docs/docs/cmd/spe/containertype/containertype-get.mdx +114 -0
  103. package/docs/docs/cmd/spo/contenttype/contenttype-get.mdx +7 -1
  104. package/docs/docs/cmd/spo/contenttype/contenttype-list.mdx +7 -1
  105. package/docs/docs/cmd/spo/list/list-contenttype-list.mdx +7 -1
  106. package/docs/docs/cmd/spp/model/model-remove.mdx +57 -0
  107. package/docs/docs/cmd/viva/engage/engage-community-set.mdx +61 -0
  108. package/npm-shrinkwrap.json +8 -2
  109. package/package.json +4 -2
  110. package/dist/m365/spe/ContainerTypeProperties.js +0 -2
@@ -54,22 +54,14 @@ class SpoSiteAdminRemoveCommand extends SpoCommand {
54
54
  await logger.logToStderr('Removing site administrator as an administrator...');
55
55
  }
56
56
  const adminUrl = await spo.getSpoAdminUrl(logger, this.debug);
57
- const siteId = await this.getSiteId(args.options.siteUrl, logger);
58
- const primaryAdminLoginName = await spo.getPrimaryAdminLoginNameAsAdmin(adminUrl, siteId, logger, this.verbose);
57
+ const tenantSiteProperties = await spo.getSiteAdminPropertiesByUrl(args.options.siteUrl, false, logger, this.verbose);
58
+ const primaryAdminLoginName = await spo.getPrimaryAdminLoginNameAsAdmin(adminUrl, tenantSiteProperties.SiteId, logger, this.verbose);
59
59
  if (loginNameToRemove === primaryAdminLoginName) {
60
60
  throw 'You cannot remove the primary site collection administrator.';
61
61
  }
62
- const existingAdmins = await this.getSiteAdmins(adminUrl, siteId);
62
+ const existingAdmins = await this.getSiteAdmins(adminUrl, tenantSiteProperties.SiteId);
63
63
  const adminsToSet = existingAdmins.filter(u => u.loginName.toLowerCase() !== loginNameToRemove.toLowerCase());
64
- await this.setSiteAdminsAsAdmin(adminUrl, siteId, adminsToSet);
65
- }
66
- async getSiteId(siteUrl, logger) {
67
- const siteGraphId = await spo.getSiteId(siteUrl, logger, this.verbose);
68
- const match = siteGraphId.match(/,([a-f0-9\-]{36}),/i);
69
- if (!match) {
70
- throw `Site with URL ${siteUrl} not found`;
71
- }
72
- return match[1];
64
+ await this.setSiteAdminsAsAdmin(adminUrl, tenantSiteProperties.SiteId, adminsToSet);
73
65
  }
74
66
  async getSiteAdmins(adminUrl, siteId) {
75
67
  const requestOptions = {
@@ -373,7 +373,7 @@ class SpoSiteSetCommand extends SpoCommand {
373
373
  headers: {
374
374
  'X-RequestDigest': this.context.FormDigestValue
375
375
  },
376
- 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>${payload.join('')}<ObjectPath Id="14" ObjectPathId="13" /><ObjectIdentityQuery Id="15" ObjectPathId="5" /><Query Id="16" ObjectPathId="13"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Identity Id="5" Name="53d8499e-d0d2-5000-cb83-9ade5be42ca4|${this.tenantId.substr(pos, this.tenantId.indexOf('&') - pos)}&#xA;SiteProperties&#xA;${formatting.encodeQueryParameter(args.options.url)}" /><Method Id="13" ParentId="5" Name="Update" /></ObjectPaths></Request>`
376
+ 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>${payload.join('')}<ObjectPath Id="14" ObjectPathId="13" /><ObjectIdentityQuery Id="15" ObjectPathId="5" /><Query Id="16" ObjectPathId="13"><Query SelectAllProperties="false"><Properties><Property Name="IsComplete" ScalarProperty="true" /><Property Name="PollingInterval" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Identity Id="5" Name="53d8499e-d0d2-5000-cb83-9ade5be42ca4|${this.tenantId.substring(pos, this.tenantId.indexOf('&'))}&#xA;SiteProperties&#xA;${formatting.encodeQueryParameter(args.options.url)}" /><Method Id="13" ParentId="5" Name="Update" /></ObjectPaths></Request>`
377
377
  };
378
378
  response = await request.post(requestOptions);
379
379
  }
@@ -0,0 +1,105 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _SppModelRemoveCommand_instances, _SppModelRemoveCommand_initTelemetry, _SppModelRemoveCommand_initOptions, _SppModelRemoveCommand_initValidators, _SppModelRemoveCommand_initOptionSets, _SppModelRemoveCommand_initTypes;
7
+ import { cli } from '../../../../cli/cli.js';
8
+ import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
10
+ import { spp } from '../../../../utils/spp.js';
11
+ import { urlUtil } from '../../../../utils/urlUtil.js';
12
+ import { validation } from '../../../../utils/validation.js';
13
+ import SpoCommand from '../../../base/SpoCommand.js';
14
+ import commands from '../../commands.js';
15
+ class SppModelRemoveCommand extends SpoCommand {
16
+ get name() {
17
+ return commands.MODEL_REMOVE;
18
+ }
19
+ get description() {
20
+ return 'Deletes a document understanding model';
21
+ }
22
+ constructor() {
23
+ super();
24
+ _SppModelRemoveCommand_instances.add(this);
25
+ __classPrivateFieldGet(this, _SppModelRemoveCommand_instances, "m", _SppModelRemoveCommand_initTelemetry).call(this);
26
+ __classPrivateFieldGet(this, _SppModelRemoveCommand_instances, "m", _SppModelRemoveCommand_initOptions).call(this);
27
+ __classPrivateFieldGet(this, _SppModelRemoveCommand_instances, "m", _SppModelRemoveCommand_initValidators).call(this);
28
+ __classPrivateFieldGet(this, _SppModelRemoveCommand_instances, "m", _SppModelRemoveCommand_initOptionSets).call(this);
29
+ __classPrivateFieldGet(this, _SppModelRemoveCommand_instances, "m", _SppModelRemoveCommand_initTypes).call(this);
30
+ }
31
+ async commandAction(logger, args) {
32
+ try {
33
+ if (!args.options.force) {
34
+ const confirmationResult = await cli.promptForConfirmation({ message: `Are you sure you want to remove model '${args.options.title ?? args.options.id}'?` });
35
+ if (!confirmationResult) {
36
+ return;
37
+ }
38
+ }
39
+ if (this.verbose) {
40
+ await logger.log(`Removing model from ${args.options.siteUrl}...`);
41
+ }
42
+ const siteUrl = urlUtil.removeTrailingSlashes(args.options.siteUrl);
43
+ await spp.assertSiteIsContentCenter(siteUrl);
44
+ let requestUrl = `${siteUrl}/_api/machinelearning/models/`;
45
+ if (args.options.title) {
46
+ let requestTitle = args.options.title.toLowerCase();
47
+ if (!requestTitle.endsWith('.classifier')) {
48
+ requestTitle += '.classifier';
49
+ }
50
+ requestUrl += `getbytitle('${formatting.encodeQueryParameter(requestTitle)}')`;
51
+ }
52
+ else {
53
+ requestUrl += `getbyuniqueid('${args.options.id}')`;
54
+ }
55
+ const requestOptions = {
56
+ url: requestUrl,
57
+ headers: {
58
+ accept: 'application/json;odata=nometadata',
59
+ 'if-match': '*'
60
+ },
61
+ responseType: 'json'
62
+ };
63
+ const result = await request.delete(requestOptions);
64
+ if (result?.['odata.null'] === true) {
65
+ throw "Model not found.";
66
+ }
67
+ }
68
+ catch (err) {
69
+ this.handleRejectedODataJsonPromise(err);
70
+ }
71
+ }
72
+ }
73
+ _SppModelRemoveCommand_instances = new WeakSet(), _SppModelRemoveCommand_initTelemetry = function _SppModelRemoveCommand_initTelemetry() {
74
+ this.telemetry.push((args) => {
75
+ Object.assign(this.telemetryProperties, {
76
+ id: typeof args.options.id !== 'undefined',
77
+ title: typeof args.options.title !== 'undefined',
78
+ force: !!args.options.force
79
+ });
80
+ });
81
+ }, _SppModelRemoveCommand_initOptions = function _SppModelRemoveCommand_initOptions() {
82
+ this.options.unshift({
83
+ option: '-u, --siteUrl <siteUrl>'
84
+ }, {
85
+ option: '-i, --id [id]'
86
+ }, {
87
+ option: '-t, --title [title]'
88
+ }, {
89
+ option: '-f, --force'
90
+ });
91
+ }, _SppModelRemoveCommand_initValidators = function _SppModelRemoveCommand_initValidators() {
92
+ this.validators.push(async (args) => {
93
+ if (args.options.id && !validation.isValidGuid(args.options.id)) {
94
+ return `${args.options.id} is not a valid GUID for option 'id'.`;
95
+ }
96
+ return validation.isValidSharePointUrl(args.options.siteUrl);
97
+ });
98
+ }, _SppModelRemoveCommand_initOptionSets = function _SppModelRemoveCommand_initOptionSets() {
99
+ this.optionSets.push({ options: ['id', 'title'] });
100
+ }, _SppModelRemoveCommand_initTypes = function _SppModelRemoveCommand_initTypes() {
101
+ this.types.string.push('siteUrl', 'id', 'title');
102
+ this.types.boolean.push('force');
103
+ };
104
+ export default new SppModelRemoveCommand();
105
+ //# sourceMappingURL=model-remove.js.map
@@ -1,6 +1,7 @@
1
1
  const prefix = 'spp';
2
2
  export default {
3
3
  CONTENTCENTER_LIST: `${prefix} contentcenter list`,
4
- MODEL_LIST: `${prefix} model list`
4
+ MODEL_LIST: `${prefix} model list`,
5
+ MODEL_REMOVE: `${prefix} model remove`
5
6
  };
6
7
  //# sourceMappingURL=commands.js.map
@@ -33,7 +33,7 @@ class TeamsUserAppListCommand extends GraphCommand {
33
33
  const items = await odata.getAllItems(endpoint);
34
34
  items.forEach(i => {
35
35
  const userAppId = Buffer.from(i.id, 'base64').toString('ascii');
36
- const appId = userAppId.substr(userAppId.indexOf("##") + 2, userAppId.length - userId.length - 2);
36
+ const appId = userAppId.substring(userAppId.indexOf("##") + 2, userAppId.length);
37
37
  i.appId = appId;
38
38
  });
39
39
  if (!cli.shouldTrimOutput(args.options.output)) {
@@ -27,12 +27,11 @@ class TenantReportOffice365ActivationCountsCommand extends GraphCommand {
27
27
  try {
28
28
  const res = await request.get(requestOptions);
29
29
  let content = '';
30
- const cleanResponse = this.removeEmptyLines(res);
31
30
  if (output && output.toLowerCase() === 'json') {
32
- content = formatting.parseCsvToJson(cleanResponse);
31
+ content = formatting.parseCsvToJson(res);
33
32
  }
34
33
  else {
35
- content = cleanResponse;
34
+ content = res;
36
35
  }
37
36
  await logger.log(content);
38
37
  }
@@ -40,11 +39,6 @@ class TenantReportOffice365ActivationCountsCommand extends GraphCommand {
40
39
  this.handleRejectedODataJsonPromise(err);
41
40
  }
42
41
  }
43
- removeEmptyLines(input) {
44
- const rows = input.split('\n');
45
- const cleanRows = rows.filter(Boolean);
46
- return cleanRows.join('\n');
47
- }
48
42
  }
49
43
  export default new TenantReportOffice365ActivationCountsCommand();
50
44
  //# sourceMappingURL=report-office365activationcounts.js.map
@@ -27,12 +27,11 @@ class TenantReportOffice365ActivationsUserCountsCommand extends GraphCommand {
27
27
  try {
28
28
  const res = await request.get(requestOptions);
29
29
  let content = '';
30
- const cleanResponse = this.removeEmptyLines(res);
31
30
  if (output && output.toLowerCase() === 'json') {
32
- content = formatting.parseCsvToJson(cleanResponse);
31
+ content = formatting.parseCsvToJson(res);
33
32
  }
34
33
  else {
35
- content = cleanResponse;
34
+ content = res;
36
35
  }
37
36
  await logger.log(content);
38
37
  }
@@ -40,11 +39,6 @@ class TenantReportOffice365ActivationsUserCountsCommand extends GraphCommand {
40
39
  this.handleRejectedODataJsonPromise(err);
41
40
  }
42
41
  }
43
- removeEmptyLines(input) {
44
- const rows = input.split('\n');
45
- const cleanRows = rows.filter(Boolean);
46
- return cleanRows.join('\n');
47
- }
48
42
  }
49
43
  export default new TenantReportOffice365ActivationsUserCountsCommand();
50
44
  //# sourceMappingURL=report-office365activationsusercounts.js.map
@@ -27,12 +27,11 @@ class TenantReportOffice365ActivationsUserDetailCommand extends GraphCommand {
27
27
  try {
28
28
  const res = await request.get(requestOptions);
29
29
  let content = '';
30
- const cleanResponse = this.removeEmptyLines(res);
31
30
  if (output && output.toLowerCase() === 'json') {
32
- content = formatting.parseCsvToJson(cleanResponse);
31
+ content = formatting.parseCsvToJson(res);
33
32
  }
34
33
  else {
35
- content = cleanResponse;
34
+ content = res;
36
35
  }
37
36
  await logger.log(content);
38
37
  }
@@ -40,11 +39,6 @@ class TenantReportOffice365ActivationsUserDetailCommand extends GraphCommand {
40
39
  this.handleRejectedODataJsonPromise(err);
41
40
  }
42
41
  }
43
- removeEmptyLines(input) {
44
- const rows = input.split('\n');
45
- const cleanRows = rows.filter(Boolean);
46
- return cleanRows.join('\n');
47
- }
48
42
  }
49
43
  export default new TenantReportOffice365ActivationsUserDetailCommand();
50
44
  //# sourceMappingURL=report-office365activationsuserdetail.js.map
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  var _TodoListRemoveCommand_instances, _TodoListRemoveCommand_initTelemetry, _TodoListRemoveCommand_initOptions, _TodoListRemoveCommand_initOptionSets;
7
7
  import { cli } from '../../../../cli/cli.js';
8
8
  import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
9
10
  import DelegatedGraphCommand from '../../../base/DelegatedGraphCommand.js';
10
11
  import commands from '../../commands.js';
11
12
  class TodoListRemoveCommand extends DelegatedGraphCommand {
@@ -38,7 +39,7 @@ class TodoListRemoveCommand extends DelegatedGraphCommand {
38
39
  return args.options.id;
39
40
  }
40
41
  const requestOptions = {
41
- url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${escape(args.options.name)}'`,
42
+ url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${formatting.encodeQueryParameter(args.options.name)}'`,
42
43
  headers: {
43
44
  accept: "application/json;odata.metadata=none"
44
45
  },
@@ -5,6 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
5
5
  };
6
6
  var _TodoListSetCommand_instances, _TodoListSetCommand_initTelemetry, _TodoListSetCommand_initOptions, _TodoListSetCommand_initOptionSets;
7
7
  import request from '../../../../request.js';
8
+ import { formatting } from '../../../../utils/formatting.js';
8
9
  import DelegatedGraphCommand from '../../../base/DelegatedGraphCommand.js';
9
10
  import commands from '../../commands.js';
10
11
  class TodoListSetCommand extends DelegatedGraphCommand {
@@ -52,7 +53,7 @@ class TodoListSetCommand extends DelegatedGraphCommand {
52
53
  return args.options.id;
53
54
  }
54
55
  const requestOptions = {
55
- url: `${endpoint}/me/todo/lists?$filter=displayName eq '${escape(args.options.name)}'`,
56
+ url: `${endpoint}/me/todo/lists?$filter=displayName eq '${formatting.encodeQueryParameter(args.options.name)}'`,
56
57
  headers: {
57
58
  accept: "application/json;odata.metadata=none"
58
59
  },
@@ -5,6 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
5
5
  };
6
6
  var _TodoTaskAddCommand_instances, _a, _TodoTaskAddCommand_initTelemetry, _TodoTaskAddCommand_initOptions, _TodoTaskAddCommand_initValidators, _TodoTaskAddCommand_initOptionSets;
7
7
  import request from '../../../../request.js';
8
+ import { formatting } from '../../../../utils/formatting.js';
8
9
  import { validation } from '../../../../utils/validation.js';
9
10
  import DelegatedGraphCommand from '../../../base/DelegatedGraphCommand.js';
10
11
  import commands from '../../commands.js';
@@ -71,7 +72,7 @@ class TodoTaskAddCommand extends DelegatedGraphCommand {
71
72
  return args.options.listId;
72
73
  }
73
74
  const requestOptions = {
74
- url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${escape(args.options.listName)}'`,
75
+ url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${formatting.encodeQueryParameter(args.options.listName)}'`,
75
76
  headers: {
76
77
  accept: 'application/json;odata.metadata=none'
77
78
  },
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  var _TodoTaskGetCommand_instances, _TodoTaskGetCommand_initTelemetry, _TodoTaskGetCommand_initOptions, _TodoTaskGetCommand_initOptionSets;
7
7
  import { cli } from '../../../../cli/cli.js';
8
8
  import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
9
10
  import DelegatedGraphCommand from '../../../base/DelegatedGraphCommand.js';
10
11
  import commands from '../../commands.js';
11
12
  class TodoTaskGetCommand extends DelegatedGraphCommand {
@@ -30,7 +31,7 @@ class TodoTaskGetCommand extends DelegatedGraphCommand {
30
31
  return args.options.listId;
31
32
  }
32
33
  const requestOptions = {
33
- url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${escape(args.options.listName)}'`,
34
+ url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${formatting.encodeQueryParameter(args.options.listName)}'`,
34
35
  headers: {
35
36
  accept: 'application/json;odata.metadata=none'
36
37
  },
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  var _TodoTaskListCommand_instances, _TodoTaskListCommand_initTelemetry, _TodoTaskListCommand_initOptions, _TodoTaskListCommand_initOptionSets;
7
7
  import { cli } from '../../../../cli/cli.js';
8
8
  import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
9
10
  import { odata } from '../../../../utils/odata.js';
10
11
  import DelegatedGraphCommand from '../../../base/DelegatedGraphCommand.js';
11
12
  import commands from '../../commands.js';
@@ -31,7 +32,7 @@ class TodoTaskListCommand extends DelegatedGraphCommand {
31
32
  return args.options.listId;
32
33
  }
33
34
  const requestOptions = {
34
- url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${escape(args.options.listName)}'`,
35
+ url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${formatting.encodeQueryParameter(args.options.listName)}'`,
35
36
  headers: {
36
37
  accept: 'application/json;odata.metadata=none'
37
38
  },
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  var _TodoTaskRemoveCommand_instances, _TodoTaskRemoveCommand_initTelemetry, _TodoTaskRemoveCommand_initOptions, _TodoTaskRemoveCommand_initOptionSets;
7
7
  import { cli } from '../../../../cli/cli.js';
8
8
  import request from '../../../../request.js';
9
+ import { formatting } from '../../../../utils/formatting.js';
9
10
  import DelegatedGraphCommand from '../../../base/DelegatedGraphCommand.js';
10
11
  import commands from '../../commands.js';
11
12
  class TodoTaskRemoveCommand extends DelegatedGraphCommand {
@@ -37,7 +38,7 @@ class TodoTaskRemoveCommand extends DelegatedGraphCommand {
37
38
  if (options.listName) {
38
39
  // Search list by its name
39
40
  const requestOptions = {
40
- url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${escape(options.listName)}'`,
41
+ url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${formatting.encodeQueryParameter(options.listName)}'`,
41
42
  headers: {
42
43
  accept: "application/json;odata.metadata=none"
43
44
  },
@@ -50,7 +50,7 @@ class TodoTaskSetCommand extends DelegatedGraphCommand {
50
50
  return options.listId;
51
51
  }
52
52
  const requestOptions = {
53
- url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${escape(options.listName)}'`,
53
+ url: `${this.resource}/v1.0/me/todo/lists?$filter=displayName eq '${formatting.encodeQueryParameter(options.listName)}'`,
54
54
  headers: {
55
55
  accept: 'application/json;odata.metadata=none'
56
56
  },
@@ -0,0 +1,111 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _VivaEngageCommunitySetCommand_instances, _VivaEngageCommunitySetCommand_initTelemetry, _VivaEngageCommunitySetCommand_initOptions, _VivaEngageCommunitySetCommand_initValidators, _VivaEngageCommunitySetCommand_initTypes, _VivaEngageCommunitySetCommand_initOptionSets;
7
+ import request from '../../../../request.js';
8
+ import { validation } from '../../../../utils/validation.js';
9
+ import { vivaEngage } from '../../../../utils/vivaEngage.js';
10
+ import GraphCommand from '../../../base/GraphCommand.js';
11
+ import commands from '../../commands.js';
12
+ class VivaEngageCommunitySetCommand extends GraphCommand {
13
+ get name() {
14
+ return commands.ENGAGE_COMMUNITY_SET;
15
+ }
16
+ get description() {
17
+ return 'Updates an existing Viva Engage community';
18
+ }
19
+ constructor() {
20
+ super();
21
+ _VivaEngageCommunitySetCommand_instances.add(this);
22
+ this.privacyOptions = ['public', 'private'];
23
+ __classPrivateFieldGet(this, _VivaEngageCommunitySetCommand_instances, "m", _VivaEngageCommunitySetCommand_initTelemetry).call(this);
24
+ __classPrivateFieldGet(this, _VivaEngageCommunitySetCommand_instances, "m", _VivaEngageCommunitySetCommand_initOptions).call(this);
25
+ __classPrivateFieldGet(this, _VivaEngageCommunitySetCommand_instances, "m", _VivaEngageCommunitySetCommand_initValidators).call(this);
26
+ __classPrivateFieldGet(this, _VivaEngageCommunitySetCommand_instances, "m", _VivaEngageCommunitySetCommand_initTypes).call(this);
27
+ __classPrivateFieldGet(this, _VivaEngageCommunitySetCommand_instances, "m", _VivaEngageCommunitySetCommand_initOptionSets).call(this);
28
+ }
29
+ async commandAction(logger, args) {
30
+ let communityId = args.options.id;
31
+ if (args.options.displayName) {
32
+ communityId = (await vivaEngage.getCommunityByDisplayName(args.options.displayName, ['id'])).id;
33
+ }
34
+ else if (args.options.entraGroupId) {
35
+ communityId = (await vivaEngage.getCommunityByEntraGroupId(args.options.entraGroupId, ['id'])).id;
36
+ }
37
+ if (this.verbose) {
38
+ await logger.logToStderr(`Updating Viva Engage community with ID ${communityId}...`);
39
+ }
40
+ const requestOptions = {
41
+ url: `${this.resource}/v1.0/employeeExperience/communities/${communityId}`,
42
+ headers: {
43
+ accept: 'application/json;odata.metadata=none'
44
+ },
45
+ responseType: 'json',
46
+ data: {
47
+ description: args.options.description,
48
+ displayName: args.options.newDisplayName,
49
+ privacy: args.options.privacy
50
+ }
51
+ };
52
+ try {
53
+ await request.patch(requestOptions);
54
+ }
55
+ catch (err) {
56
+ this.handleRejectedODataJsonPromise(err);
57
+ }
58
+ }
59
+ }
60
+ _VivaEngageCommunitySetCommand_instances = new WeakSet(), _VivaEngageCommunitySetCommand_initTelemetry = function _VivaEngageCommunitySetCommand_initTelemetry() {
61
+ this.telemetry.push((args) => {
62
+ Object.assign(this.telemetryProperties, {
63
+ id: typeof args.options.id !== 'undefined',
64
+ displayName: typeof args.options.displayName !== 'undefined',
65
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
66
+ newDisplayName: typeof args.options.newDisplayName !== 'undefined',
67
+ description: typeof args.options.description !== 'undefined',
68
+ privacy: typeof args.options.privacy !== 'undefined'
69
+ });
70
+ });
71
+ }, _VivaEngageCommunitySetCommand_initOptions = function _VivaEngageCommunitySetCommand_initOptions() {
72
+ this.options.unshift({
73
+ option: '-i, --id [id]'
74
+ }, {
75
+ option: '-d, --displayName [displayName]'
76
+ }, {
77
+ option: '--entraGroupId [entraGroupId]'
78
+ }, {
79
+ option: '--newDisplayName [newDisplayName]'
80
+ }, {
81
+ option: '--description [description]'
82
+ }, {
83
+ option: '--privacy [privacy]',
84
+ autocomplete: this.privacyOptions
85
+ });
86
+ }, _VivaEngageCommunitySetCommand_initValidators = function _VivaEngageCommunitySetCommand_initValidators() {
87
+ this.validators.push(async (args) => {
88
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
89
+ return `${args.options.entraGroupId} is not a valid GUID for the option 'entraGroupId'.`;
90
+ }
91
+ if (args.options.newDisplayName && args.options.newDisplayName.length > 255) {
92
+ return `The maximum amount of characters for 'newDisplayName' is 255.`;
93
+ }
94
+ if (args.options.description && args.options.description.length > 1024) {
95
+ return `The maximum amount of characters for 'description' is 1024.`;
96
+ }
97
+ if (args.options.privacy && this.privacyOptions.map(x => x.toLowerCase()).indexOf(args.options.privacy.toLowerCase()) === -1) {
98
+ return `${args.options.privacy} is not a valid privacy. Allowed values are ${this.privacyOptions.join(', ')}`;
99
+ }
100
+ if (!args.options.newDisplayName && !args.options.description && !args.options.privacy) {
101
+ return 'Specify at least newDisplayName, description, or privacy.';
102
+ }
103
+ return true;
104
+ });
105
+ }, _VivaEngageCommunitySetCommand_initTypes = function _VivaEngageCommunitySetCommand_initTypes() {
106
+ this.types.string.push('id', 'displayName', 'entraGroupId', 'newDisplayName', 'description', 'privacy');
107
+ }, _VivaEngageCommunitySetCommand_initOptionSets = function _VivaEngageCommunitySetCommand_initOptionSets() {
108
+ this.optionSets.push({ options: ['id', 'displayName', 'entraGroupId'] });
109
+ };
110
+ export default new VivaEngageCommunitySetCommand();
111
+ //# sourceMappingURL=engage-community-set.js.map
@@ -4,6 +4,7 @@ export default {
4
4
  ENGAGE_COMMUNITY_ADD: `${prefix} engage community add`,
5
5
  ENGAGE_COMMUNITY_GET: `${prefix} engage community get`,
6
6
  ENGAGE_COMMUNITY_LIST: `${prefix} engage community list`,
7
+ ENGAGE_COMMUNITY_SET: `${prefix} engage community set`,
7
8
  ENGAGE_COMMUNITY_USER_LIST: `${prefix} engage community user list`,
8
9
  ENGAGE_GROUP_LIST: `${prefix} engage group list`,
9
10
  ENGAGE_GROUP_USER_ADD: `${prefix} engage group user add`,
@@ -5,12 +5,24 @@ export const entraAdministrativeUnit = {
5
5
  /**
6
6
  * Get an administrative unit by its display name.
7
7
  * @param displayName Administrative unit display name.
8
+ * @param properties Properties to include in the response.
8
9
  * @returns The administrative unit.
9
10
  * @throws Error when administrative unit was not found.
10
11
  */
11
- async getAdministrativeUnitByDisplayName(displayName) {
12
+ async getAdministrativeUnitByDisplayName(displayName, properties) {
13
+ const queryParameters = [];
14
+ if (properties) {
15
+ const allProperties = properties.split(',');
16
+ const selectProperties = allProperties.filter(prop => !prop.includes('/'));
17
+ if (selectProperties.length > 0) {
18
+ queryParameters.push(`$select=${selectProperties}`);
19
+ }
20
+ }
21
+ const queryString = queryParameters.length > 0
22
+ ? `?${queryParameters.join('&')}`
23
+ : '';
12
24
  const graphResource = 'https://graph.microsoft.com';
13
- const administrativeUnits = await odata.getAllItems(`${graphResource}/v1.0/directory/administrativeUnits?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`);
25
+ const administrativeUnits = await odata.getAllItems(`${graphResource}/v1.0/directory/administrativeUnits?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'${queryString}`);
14
26
  if (administrativeUnits.length === 0) {
15
27
  throw `The specified administrative unit '${displayName}' does not exist.`;
16
28
  }
@@ -7,10 +7,22 @@ export const entraGroup = {
7
7
  /**
8
8
  * Retrieve a single group.
9
9
  * @param id Group ID.
10
+ * @param properties Properties to include in the response.
10
11
  */
11
- async getGroupById(id) {
12
+ async getGroupById(id, properties) {
13
+ const queryParameters = [];
14
+ if (properties) {
15
+ const allProperties = properties.split(',');
16
+ const selectProperties = allProperties.filter(prop => !prop.includes('/'));
17
+ if (selectProperties.length > 0) {
18
+ queryParameters.push(`$select=${selectProperties}`);
19
+ }
20
+ }
21
+ const queryString = queryParameters.length > 0
22
+ ? `?${queryParameters.join('&')}`
23
+ : '';
12
24
  const requestOptions = {
13
- url: `${graphResource}/v1.0/groups/${id}`,
25
+ url: `${graphResource}/v1.0/groups/${id}${queryString}`,
14
26
  headers: {
15
27
  accept: 'application/json;odata.metadata=none'
16
28
  },
@@ -21,18 +33,31 @@ export const entraGroup = {
21
33
  /**
22
34
  * Get a list of groups by display name.
23
35
  * @param displayName Group display name.
36
+ * @param properties Properties to include in the response.
24
37
  */
25
- async getGroupsByDisplayName(displayName) {
26
- return odata.getAllItems(`${graphResource}/v1.0/groups?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'`);
38
+ async getGroupsByDisplayName(displayName, properties) {
39
+ const queryParameters = [];
40
+ if (properties) {
41
+ const allProperties = properties.split(',');
42
+ const selectProperties = allProperties.filter(prop => !prop.includes('/'));
43
+ if (selectProperties.length > 0) {
44
+ queryParameters.push(`$select=${selectProperties}`);
45
+ }
46
+ }
47
+ const queryString = queryParameters.length > 0
48
+ ? `&${queryParameters.join('&')}`
49
+ : '';
50
+ return odata.getAllItems(`${graphResource}/v1.0/groups?$filter=displayName eq '${formatting.encodeQueryParameter(displayName)}'${queryString}`);
27
51
  },
28
52
  /**
29
53
  * Get a single group by its display name.
30
54
  * @param displayName Group display name.
55
+ * @param properties Properties to include in the response.
31
56
  * @throws Error when group was not found.
32
57
  * @throws Error when multiple groups with the same name were found.
33
58
  */
34
- async getGroupByDisplayName(displayName) {
35
- const groups = await this.getGroupsByDisplayName(displayName);
59
+ async getGroupByDisplayName(displayName, properties) {
60
+ const groups = await this.getGroupsByDisplayName(displayName, properties);
36
61
  if (!groups.length) {
37
62
  throw Error(`The specified group '${displayName}' does not exist.`);
38
63
  }
@@ -60,6 +85,24 @@ export const entraGroup = {
60
85
  }
61
86
  return groups[0].id;
62
87
  },
88
+ /**
89
+ * Get id of a group by its mail nickname.
90
+ * @param mailNickname Group mail nickname.
91
+ * @throws Error when group was not found.
92
+ * @throws Error when multiple groups with the same name were found.
93
+ */
94
+ async getGroupIdByMailNickname(mailNickname) {
95
+ const groups = await odata.getAllItems(`${graphResource}/v1.0/groups?$filter=mailNickname eq '${formatting.encodeQueryParameter(mailNickname)}'&$select=id`);
96
+ if (!groups.length) {
97
+ throw Error(`The specified group '${mailNickname}' does not exist.`);
98
+ }
99
+ if (groups.length > 1) {
100
+ const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', groups);
101
+ const result = await cli.handleMultipleResultsFound(`Multiple groups with mail nickname '${mailNickname}' found.`, resultAsKeyValuePair);
102
+ return result.id;
103
+ }
104
+ return groups[0].id;
105
+ },
63
106
  async setGroup(id, isPrivate, logger, verbose) {
64
107
  if (verbose && logger) {
65
108
  await logger.logToStderr(`Updating Microsoft 365 Group ${id}...`);
@@ -1,3 +1,4 @@
1
+ import { parse } from 'csv-parse/sync';
1
2
  import chalk from 'chalk';
2
3
  import stripJsonComments from 'strip-json-comments';
3
4
  import { BasePermissions } from '../m365/spo/base-permissions.js';
@@ -75,26 +76,13 @@ export const formatting = {
75
76
  return response;
76
77
  },
77
78
  parseCsvToJson(s, quoteChar = '"', delimiter = ',') {
78
- const regex = new RegExp(`\\s*(${quoteChar})?(.*?)\\1\\s*(?:${delimiter}|$)`, 'gs');
79
- const lines = s.split('\n');
80
- const match = (line) => [...line.matchAll(regex)]
81
- .map(m => m[2]); // we only want the second capture group
82
- const heads = match(lines[0]).slice(0, -1);
83
- return lines.slice(1)
84
- .filter(text => text.trim() !== '')
85
- .map(line => {
86
- const lineMatch = match(line);
87
- const obj = {};
88
- heads.forEach((key, index) => {
89
- const value = parseInt(lineMatch[index]);
90
- if (isNaN(value) || value.toString() !== lineMatch[index]) {
91
- obj[key] = lineMatch[index];
92
- }
93
- else {
94
- obj[key] = parseInt(lineMatch[index]);
95
- }
96
- });
97
- return obj;
79
+ return parse(s, {
80
+ quote: quoteChar,
81
+ delimiter: delimiter,
82
+ columns: true,
83
+ skipEmptyLines: true,
84
+ ltrim: true,
85
+ cast: true
98
86
  });
99
87
  },
100
88
  encodeQueryParameter(value) {