@pnp/cli-microsoft365 11.0.0-beta.88d51e6 → 11.0.0

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 (107) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Command.js +4 -0
  4. package/dist/config.js +1 -0
  5. package/dist/m365/adaptivecard/commands/adaptivecard-send.js +1 -1
  6. package/dist/m365/entra/commands/administrativeunit/administrativeunit-add.js +13 -27
  7. package/dist/m365/entra/commands/administrativeunit/administrativeunit-get.js +18 -43
  8. package/dist/m365/entra/commands/administrativeunit/administrativeunit-list.js +10 -21
  9. package/dist/m365/entra/commands/administrativeunit/administrativeunit-remove.js +25 -49
  10. package/dist/m365/entra/commands/group/group-member-add.js +6 -27
  11. package/dist/m365/entra/commands/group/group-member-set.js +5 -26
  12. package/dist/m365/entra/commands/m365group/m365group-get.js +1 -7
  13. package/dist/m365/entra/commands/m365group/m365group-list.js +1 -7
  14. package/dist/m365/entra/commands/pim/pim-role-assignment-eligibility-list.js +1 -7
  15. package/dist/m365/entra/commands/pim/pim-role-assignment-list.js +1 -7
  16. package/dist/m365/entra/commands/pim/pim-role-request-list.js +1 -7
  17. package/dist/m365/entra/commands/roleassignment/roleassignment-add.js +146 -0
  18. package/dist/m365/entra/commands.js +1 -0
  19. package/dist/m365/flow/commands/flow-list.js +7 -14
  20. package/dist/m365/flow/commands/run/run-get.js +1 -7
  21. package/dist/m365/graph/commands/openextension/openextension-add.js +2 -2
  22. package/dist/m365/graph/commands/openextension/openextension-set.js +2 -6
  23. package/dist/m365/graph/commands/subscription/subscription-add.js +3 -10
  24. package/dist/m365/pp/commands/copilot/copilot-get.js +0 -4
  25. package/dist/m365/pp/commands/copilot/copilot-list.js +0 -4
  26. package/dist/m365/pp/commands/copilot/copilot-remove.js +0 -4
  27. package/dist/m365/pp/commands/solution/solution-publisher-list.js +1 -8
  28. package/dist/m365/pp/commands.js +0 -3
  29. package/dist/m365/purview/commands/threatassessment/threatassessment-get.js +1 -7
  30. package/dist/m365/spe/commands/container/container-add.js +1 -3
  31. package/dist/m365/spe/commands/container/container-list.js +1 -3
  32. package/dist/m365/spe/commands/container/container-recyclebinitem-list.js +1 -3
  33. package/dist/m365/spe/commands/container/container-recyclebinitem-restore.js +1 -3
  34. package/dist/m365/spe/commands/container/container-remove.js +1 -3
  35. package/dist/m365/spe/commands/containertype/containertype-add.js +67 -90
  36. package/dist/m365/spe/commands/containertype/containertype-get.js +53 -81
  37. package/dist/m365/spe/commands/containertype/containertype-list.js +8 -19
  38. package/dist/m365/spe/commands/containertype/containertype-remove.js +27 -5
  39. package/dist/m365/spfx/commands/project/project-upgrade.js +23 -66
  40. package/dist/m365/spo/commands/file/file-move.js +2 -8
  41. package/dist/m365/spo/commands/homesite/homesite-add.js +26 -2
  42. package/dist/m365/spo/commands/homesite/homesite-get.js +28 -14
  43. package/dist/m365/spo/commands/homesite/homesite-list.js +1 -12
  44. package/dist/m365/spo/commands/homesite/homesite-remove.js +6 -34
  45. package/dist/m365/spo/commands/hubsite/hubsite-get.js +4 -13
  46. package/dist/m365/spo/commands/hubsite/hubsite-list.js +1 -8
  47. package/dist/m365/spo/commands/serviceprincipal/serviceprincipal-grant-list.js +17 -25
  48. package/dist/m365/spo/commands/{tenant/tenant-site-archive.js → site/site-archive.js} +14 -14
  49. package/dist/m365/spo/commands/{tenant/tenant-site-list.js → site/site-list.js} +16 -27
  50. package/dist/m365/spo/commands/{tenant/tenant-site-membership-list.js → site/site-membership-list.js} +15 -15
  51. package/dist/m365/spo/commands/{tenant/tenant-site-rename.js → site/site-rename.js} +14 -14
  52. package/dist/m365/spo/commands/{tenant/tenant-site-unarchive.js → site/site-unarchive.js} +14 -14
  53. package/dist/m365/spo/commands/term/term-list.js +1 -7
  54. package/dist/m365/spo/commands.js +4 -6
  55. package/dist/m365/teams/commands/chat/chat-member-add.js +3 -9
  56. package/dist/m365/viva/commands/engage/engage-network-list.js +1 -7
  57. package/dist/utils/entraAdministrativeUnit.js +1 -1
  58. package/dist/utils/spe.js +5 -39
  59. package/docs/docs/cmd/entra/group/group-member-add.mdx +7 -26
  60. package/docs/docs/cmd/entra/group/group-member-set.mdx +5 -23
  61. package/docs/docs/cmd/entra/m365group/m365group-get.mdx +0 -3
  62. package/docs/docs/cmd/entra/m365group/m365group-list.mdx +0 -3
  63. package/docs/docs/cmd/entra/pim/pim-role-assignment-eligibility-list.mdx +0 -3
  64. package/docs/docs/cmd/entra/pim/pim-role-assignment-list.mdx +0 -3
  65. package/docs/docs/cmd/entra/pim/pim-role-request-list.mdx +0 -3
  66. package/docs/docs/cmd/entra/roleassignment/roleassignment-add.mdx +163 -0
  67. package/docs/docs/cmd/flow/flow-list.mdx +0 -3
  68. package/docs/docs/cmd/flow/run/run-get.mdx +0 -3
  69. package/docs/docs/cmd/graph/subscription/subscription-add.mdx +0 -3
  70. package/docs/docs/cmd/pp/copilot/copilot-get.mdx +0 -6
  71. package/docs/docs/cmd/pp/copilot/copilot-list.mdx +0 -6
  72. package/docs/docs/cmd/pp/copilot/copilot-remove.mdx +0 -6
  73. package/docs/docs/cmd/pp/solution/solution-publisher-list.mdx +0 -3
  74. package/docs/docs/cmd/purview/threatassessment/threatassessment-get.mdx +0 -3
  75. package/docs/docs/cmd/spe/container/container-activate.mdx +21 -0
  76. package/docs/docs/cmd/spe/container/container-add.mdx +29 -0
  77. package/docs/docs/cmd/spe/container/container-get.mdx +20 -1
  78. package/docs/docs/cmd/spe/container/container-list.mdx +29 -0
  79. package/docs/docs/cmd/spe/container/container-permission-list.mdx +19 -0
  80. package/docs/docs/cmd/spe/container/container-recyclebinitem-list.mdx +29 -0
  81. package/docs/docs/cmd/spe/container/container-recyclebinitem-restore.mdx +31 -0
  82. package/docs/docs/cmd/spe/container/container-remove.mdx +31 -0
  83. package/docs/docs/cmd/spe/containertype/containertype-add.mdx +111 -55
  84. package/docs/docs/cmd/spe/containertype/containertype-get.mdx +69 -38
  85. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +59 -31
  86. package/docs/docs/cmd/spe/containertype/containertype-remove.mdx +31 -4
  87. package/docs/docs/cmd/spfx/project/project-upgrade.mdx +18 -5
  88. package/docs/docs/cmd/spo/file/file-move.mdx +0 -3
  89. package/docs/docs/cmd/spo/homesite/homesite-add.mdx +13 -4
  90. package/docs/docs/cmd/spo/homesite/homesite-get.mdx +44 -23
  91. package/docs/docs/cmd/spo/homesite/homesite-list.mdx +0 -6
  92. package/docs/docs/cmd/spo/homesite/homesite-remove.mdx +10 -35
  93. package/docs/docs/cmd/spo/homesite/homesite-set.mdx +1 -1
  94. package/docs/docs/cmd/spo/hubsite/hubsite-get.mdx +0 -3
  95. package/docs/docs/cmd/spo/hubsite/hubsite-list.mdx +0 -3
  96. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-list.mdx +18 -18
  97. package/docs/docs/cmd/spo/{tenant/tenant-site-archive.mdx → site/site-archive.mdx} +4 -4
  98. package/docs/docs/cmd/spo/{tenant/tenant-site-list.mdx → site/site-list.mdx} +7 -16
  99. package/docs/docs/cmd/spo/{tenant/tenant-site-membership-list.mdx → site/site-membership-list.mdx} +5 -5
  100. package/docs/docs/cmd/spo/{tenant/tenant-site-rename.mdx → site/site-rename.mdx} +7 -7
  101. package/docs/docs/cmd/spo/{tenant/tenant-site-unarchive.mdx → site/site-unarchive.mdx} +4 -4
  102. package/docs/docs/cmd/spo/term/term-list.mdx +0 -3
  103. package/docs/docs/cmd/teams/chat/chat-member-add.mdx +2 -5
  104. package/docs/docs/cmd/viva/engage/engage-network-list.mdx +0 -3
  105. package/package.json +2 -2
  106. package/dist/m365/spo/commands/tenant/SPOTenantSitePropertiesEnumerable.js +0 -2
  107. package/dist/m365/spo/commands/tenant/TenantSiteProperties.js +0 -2
@@ -6,16 +6,18 @@ import { validation } from '../../../../utils/validation.js';
6
6
  import SpoCommand from '../../../base/SpoCommand.js';
7
7
  import commands from '../../commands.js';
8
8
  import request from '../../../../request.js';
9
+ import { entraGroup } from '../../../../utils/entraGroup.js';
9
10
  const options = globalOptionsZod
10
11
  .extend({
11
12
  url: zod.alias('u', z.string()
12
13
  .refine((url) => validation.isValidSharePointUrl(url) === true, url => ({
13
14
  message: `'${url}' is not a valid SharePoint Online site URL.`
14
15
  }))),
15
- audiences: z.string()
16
+ audienceIds: z.string()
16
17
  .refine(audiences => validation.isValidGuidArray(audiences) === true, audiences => ({
17
18
  message: `The following GUIDs are invalid: ${validation.isValidGuidArray(audiences)}.`
18
19
  })).optional(),
20
+ audienceNames: z.string().optional(),
19
21
  vivaConnectionsDefaultStart: z.boolean().optional(),
20
22
  isInDraftMode: z.boolean().optional(),
21
23
  order: z.number()
@@ -34,7 +36,20 @@ class SpoHomeSiteAddCommand extends SpoCommand {
34
36
  get schema() {
35
37
  return options;
36
38
  }
39
+ getRefinedSchema(schema) {
40
+ return schema
41
+ .refine((options) => [options.audienceIds, options.audienceNames].filter(o => o !== undefined).length <= 1, {
42
+ message: 'You must specify either audienceIds or audienceNames but not both.'
43
+ });
44
+ }
37
45
  async commandAction(logger, args) {
46
+ let audiences = [];
47
+ if (args.options.audienceIds) {
48
+ audiences = args.options.audienceIds.split(',').map(id => id.trim());
49
+ }
50
+ else if (args.options.audienceNames) {
51
+ audiences = await this.transformAudienceNamesToIds(args.options.audienceNames);
52
+ }
38
53
  try {
39
54
  const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
40
55
  const requestOptions = {
@@ -45,7 +60,7 @@ class SpoHomeSiteAddCommand extends SpoCommand {
45
60
  responseType: 'json',
46
61
  data: {
47
62
  siteUrl: args.options.url,
48
- audiences: args.options.audiences?.split(','),
63
+ audiences: audiences,
49
64
  vivaConnectionsDefaultStart: args.options.vivaConnectionsDefaultStart ?? true,
50
65
  isInDraftMode: args.options.isInDraftMode ?? false,
51
66
  order: args.options.order
@@ -61,6 +76,15 @@ class SpoHomeSiteAddCommand extends SpoCommand {
61
76
  this.handleRejectedODataJsonPromise(err);
62
77
  }
63
78
  }
79
+ async transformAudienceNamesToIds(audienceNames) {
80
+ const names = audienceNames.split(',');
81
+ const ids = [];
82
+ for (const name of names) {
83
+ const id = await entraGroup.getGroupIdByDisplayName(name.trim());
84
+ ids.push(id);
85
+ }
86
+ return ids;
87
+ }
64
88
  }
65
89
  export default new SpoHomeSiteAddCommand();
66
90
  //# sourceMappingURL=homesite-add.js.map
@@ -1,28 +1,42 @@
1
- import request from '../../../../request.js';
1
+ import { z } from 'zod';
2
+ import { zod } from '../../../../utils/zod.js';
3
+ import { globalOptionsZod } from '../../../../Command.js';
4
+ import { validation } from '../../../../utils/validation.js';
2
5
  import { spo } from '../../../../utils/spo.js';
3
6
  import SpoCommand from '../../../base/SpoCommand.js';
4
7
  import commands from '../../commands.js';
8
+ import { odata } from '../../../../utils/odata.js';
9
+ import { urlUtil } from '../../../../utils/urlUtil.js';
10
+ const options = globalOptionsZod
11
+ .extend({
12
+ url: zod.alias('u', z.string()
13
+ .refine(url => validation.isValidSharePointUrl(url) === true, url => ({
14
+ message: `'${url}' is not a valid SharePoint Online site URL.`
15
+ })))
16
+ })
17
+ .strict();
5
18
  class SpoHomeSiteGetCommand extends SpoCommand {
6
19
  get name() {
7
20
  return commands.HOMESITE_GET;
8
21
  }
9
22
  get description() {
10
- return 'Gets information about the Home Site';
23
+ return 'Gets information about a home site';
11
24
  }
12
- async commandAction(logger) {
25
+ get schema() {
26
+ return options;
27
+ }
28
+ async commandAction(logger, args) {
13
29
  try {
14
- const spoUrl = await spo.getSpoUrl(logger, this.debug);
15
- const requestOptions = {
16
- url: `${spoUrl}/_api/SP.SPHSite/Details`,
17
- headers: {
18
- accept: 'application/json;odata=nometadata'
19
- },
20
- responseType: 'json'
21
- };
22
- const res = await request.get(requestOptions);
23
- if (!res["odata.null"]) {
24
- await logger.log(res);
30
+ const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
31
+ if (this.verbose) {
32
+ await logger.log(`Retrieving home sites...`);
33
+ }
34
+ const homeSites = await odata.getAllItems(`${spoAdminUrl}/_api/SPO.Tenant/GetTargetedSitesDetails`);
35
+ const homeSite = homeSites.find(hs => urlUtil.removeTrailingSlashes(hs.Url).toLowerCase() === urlUtil.removeTrailingSlashes(args.options.url).toLowerCase());
36
+ if (homeSite === undefined) {
37
+ throw `Home site with URL '${args.options.url}' not found.`;
25
38
  }
39
+ await logger.log(homeSite);
26
40
  }
27
41
  catch (err) {
28
42
  this.handleRejectedODataJsonPromise(err);
@@ -9,27 +9,16 @@ class SpoHomeSiteListCommand extends SpoCommand {
9
9
  get description() {
10
10
  return 'Lists all home sites';
11
11
  }
12
- alias() {
13
- return [commands.TENANT_HOMESITE_LIST];
14
- }
15
12
  defaultProperties() {
16
13
  return ['Url', 'Title'];
17
14
  }
18
15
  async commandAction(logger) {
19
- await this.showDeprecationWarning(logger, commands.TENANT_HOMESITE_LIST, commands.HOMESITE_LIST);
20
16
  try {
21
17
  const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.verbose);
22
- const requestOptions = {
23
- url: `${spoAdminUrl}/_api/SPO.Tenant/GetTargetedSitesDetails`,
24
- headers: {
25
- accept: 'application/json;odata=nometadata'
26
- },
27
- responseType: 'json'
28
- };
29
18
  if (this.verbose) {
30
19
  await logger.logToStderr(`Retrieving all home sites...`);
31
20
  }
32
- const res = await odata.getAllItems(requestOptions);
21
+ const res = await odata.getAllItems(`${spoAdminUrl}/_api/SPO.Tenant/GetTargetedSitesDetails`);
33
22
  await logger.log(res);
34
23
  }
35
24
  catch (err) {
@@ -3,7 +3,6 @@ import { zod } from '../../../../utils/zod.js';
3
3
  import { globalOptionsZod } from '../../../../Command.js';
4
4
  import { validation } from '../../../../utils/validation.js';
5
5
  import { cli } from '../../../../cli/cli.js';
6
- import config from '../../../../config.js';
7
6
  import request from '../../../../request.js';
8
7
  import { spo } from '../../../../utils/spo.js';
9
8
  import SpoCommand from '../../../base/SpoCommand.js';
@@ -13,7 +12,7 @@ const options = globalOptionsZod
13
12
  url: zod.alias('u', z.string()
14
13
  .refine(url => validation.isValidSharePointUrl(url) === true, url => ({
15
14
  message: `'${url}' is not a valid SharePoint Online site URL.`
16
- })).optional()),
15
+ }))),
17
16
  force: zod.alias('f', z.boolean().optional())
18
17
  })
19
18
  .strict();
@@ -30,34 +29,8 @@ class SpoHomeSiteRemoveCommand extends SpoCommand {
30
29
  async commandAction(logger, args) {
31
30
  const removeHomeSite = async () => {
32
31
  try {
33
- if (this.verbose) {
34
- await logger.logToStderr(`Removing ${args.options.url ? `'${args.options.url}' as home site` : 'the current home site'}...`);
35
- }
36
32
  const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
37
- const reqDigest = await spo.getRequestDigest(spoAdminUrl);
38
- if (args.options.url) {
39
- await this.removeHomeSiteByUrl(args.options.url, spoAdminUrl, logger);
40
- await logger.log(`${args.options.url} has been removed as a Home Site. It may take some time for the change to apply. Check aka.ms/homesites for details.`);
41
- }
42
- else {
43
- await this.warn(logger, `The current way this command works is deprecated and will change in the next major release. The '--url' option will become required.`);
44
- const requestOptions = {
45
- url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
46
- headers: {
47
- 'X-RequestDigest': reqDigest.FormDigestValue
48
- },
49
- 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="28" ObjectPathId="27" /><Method Name="RemoveSPHSite" Id="29" ObjectPathId="27" /></Actions><ObjectPaths><Constructor Id="27" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /></ObjectPaths></Request>`
50
- };
51
- const res = await request.post(requestOptions);
52
- const json = JSON.parse(res);
53
- const response = json[0];
54
- if (response.ErrorInfo) {
55
- throw response.ErrorInfo.ErrorMessage;
56
- }
57
- else {
58
- await logger.log(json[json.length - 1]);
59
- }
60
- }
33
+ await this.removeHomeSiteByUrl(args.options.url, spoAdminUrl, logger);
61
34
  }
62
35
  catch (err) {
63
36
  this.handleRejectedODataJsonPromise(err);
@@ -67,11 +40,7 @@ class SpoHomeSiteRemoveCommand extends SpoCommand {
67
40
  await removeHomeSite();
68
41
  }
69
42
  else {
70
- const result = await cli.promptForConfirmation({
71
- message: args.options.url
72
- ? `Are you sure you want to remove '${args.options.url}' as home site?`
73
- : `Are you sure you want to remove the current home site?`
74
- });
43
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove '${args.options.url}' as home site?` });
75
44
  if (result) {
76
45
  await removeHomeSite();
77
46
  }
@@ -79,6 +48,9 @@ class SpoHomeSiteRemoveCommand extends SpoCommand {
79
48
  }
80
49
  async removeHomeSiteByUrl(siteUrl, spoAdminUrl, logger) {
81
50
  const siteAdminProperties = await spo.getSiteAdminPropertiesByUrl(siteUrl, false, logger, this.verbose);
51
+ if (this.verbose) {
52
+ await logger.logToStderr(`Removing '${siteUrl}' as home site...`);
53
+ }
82
54
  const requestOptions = {
83
55
  url: `${spoAdminUrl}/_api/SPO.Tenant/RemoveTargetedSite`,
84
56
  headers: {
@@ -29,20 +29,12 @@ class SpoHubSiteGetCommand extends SpoCommand {
29
29
  }
30
30
  async commandAction(logger, args) {
31
31
  try {
32
- if (args.options.includeAssociatedSites) {
33
- await this.warn(logger, `Parameter 'includeAssociatedSites' is deprecated. Please use 'withAssociatedSites' instead`);
34
- }
35
32
  const spoUrl = await spo.getSpoUrl(logger, this.debug);
36
33
  const hubSite = args.options.id ? await this.getHubSiteById(spoUrl, args.options) : await this.getHubSite(spoUrl, args.options);
37
- if ((args.options.includeAssociatedSites || args.options.withAssociatedSites) && (args.options.output && args.options.output !== 'json')) {
38
- if (args.options.includeAssociatedSites) {
39
- throw 'includeAssociatedSites option is only allowed with json output mode';
40
- }
41
- else {
42
- throw 'withAssociatedSites option is only allowed with json output mode';
43
- }
34
+ if (args.options.withAssociatedSites && (args.options.output && args.options.output !== 'json')) {
35
+ throw 'withAssociatedSites option is only allowed with json output mode';
44
36
  }
45
- if ((args.options.includeAssociatedSites === true || args.options.withAssociatedSites === true) && args.options.output && !cli.shouldTrimOutput(args.options.output)) {
37
+ if (args.options.withAssociatedSites === true && args.options.output && !cli.shouldTrimOutput(args.options.output)) {
46
38
  const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
47
39
  const associatedSitesCommandOutput = await this.getAssociatedSites(spoAdminUrl, hubSite.SiteId, logger, args);
48
40
  const associatedSites = JSON.parse(associatedSitesCommandOutput.stdout);
@@ -108,12 +100,11 @@ _SpoHubSiteGetCommand_instances = new WeakSet(), _SpoHubSiteGetCommand_initTelem
108
100
  id: typeof args.options.id !== 'undefined',
109
101
  title: typeof args.options.title !== 'undefined',
110
102
  url: typeof args.options.url !== 'undefined',
111
- includeAssociatedSites: args.options.includeAssociatedSites === true,
112
103
  withAssociatedSites: args.options.withAssociatedSites === true
113
104
  });
114
105
  });
115
106
  }, _SpoHubSiteGetCommand_initOptions = function _SpoHubSiteGetCommand_initOptions() {
116
- this.options.unshift({ option: '-i, --id [id]' }, { option: '-t, --title [title]' }, { option: '-u, --url [url]' }, { option: '--includeAssociatedSites' }, { option: '--withAssociatedSites' });
107
+ this.options.unshift({ option: '-i, --id [id]' }, { option: '-t, --title [title]' }, { option: '-u, --url [url]' }, { option: '--withAssociatedSites' });
117
108
  }, _SpoHubSiteGetCommand_initValidators = function _SpoHubSiteGetCommand_initValidators() {
118
109
  this.validators.push(async (args) => {
119
110
  if (args.options.id && !validation.isValidGuid(args.options.id)) {
@@ -29,14 +29,10 @@ class SpoHubSiteListCommand extends SpoCommand {
29
29
  }
30
30
  async commandAction(logger, args) {
31
31
  try {
32
- if (args.options.includeAssociatedSites) {
33
- await this.warn(logger, `Parameter 'includeAssociatedSites' is deprecated. Please use 'withAssociatedSites' instead`);
34
- }
35
32
  const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
36
33
  const hubSitesResult = await odata.getAllItems(`${spoAdminUrl}/_api/hubsites`);
37
34
  const hubSites = hubSitesResult;
38
- const shouldIncludeAssociatedSites = args.options.includeAssociatedSites || args.options.withAssociatedSites;
39
- if (!(shouldIncludeAssociatedSites !== true || args.options.output && args.options.output !== 'json')) {
35
+ if (!(args.options.withAssociatedSites !== true || args.options.output && args.options.output !== 'json')) {
40
36
  if (this.debug) {
41
37
  await logger.logToStderr('Retrieving associated sites...');
42
38
  await logger.logToStderr('');
@@ -108,14 +104,11 @@ class SpoHubSiteListCommand extends SpoCommand {
108
104
  _SpoHubSiteListCommand_instances = new WeakSet(), _SpoHubSiteListCommand_initTelemetry = function _SpoHubSiteListCommand_initTelemetry() {
109
105
  this.telemetry.push((args) => {
110
106
  Object.assign(this.telemetryProperties, {
111
- includeAssociatedSites: args.options.includeAssociatedSites === true,
112
107
  withAssociatedSites: args.options.withAssociatedSites === true
113
108
  });
114
109
  });
115
110
  }, _SpoHubSiteListCommand_initOptions = function _SpoHubSiteListCommand_initOptions() {
116
111
  this.options.unshift({
117
- option: '-i, --includeAssociatedSites'
118
- }, {
119
112
  option: '--withAssociatedSites'
120
113
  });
121
114
  };
@@ -1,9 +1,11 @@
1
- import config from '../../../../config.js';
2
1
  import request from '../../../../request.js';
3
- import { spo } from '../../../../utils/spo.js';
4
- import SpoCommand from '../../../base/SpoCommand.js';
2
+ import GraphCommand from '../../../base/GraphCommand.js';
5
3
  import commands from '../../commands.js';
6
- class SpoServicePrincipalGrantListCommand extends SpoCommand {
4
+ class SpoServicePrincipalGrantListCommand extends GraphCommand {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.spoServicePrincipalDisplayName = 'SharePoint Online Web Client Extensibility';
8
+ }
7
9
  get name() {
8
10
  return commands.SERVICEPRINCIPAL_GRANT_LIST;
9
11
  }
@@ -15,36 +17,26 @@ class SpoServicePrincipalGrantListCommand extends SpoCommand {
15
17
  }
16
18
  async commandAction(logger) {
17
19
  try {
18
- const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
19
20
  if (this.verbose) {
20
- await logger.logToStderr(`Retrieving request digest...`);
21
+ await logger.logToStderr(`Retrieving permissions granted to the service principal '${this.spoServicePrincipalDisplayName}'...`);
21
22
  }
22
- const reqDigest = await spo.getRequestDigest(spoAdminUrl);
23
23
  const requestOptions = {
24
- url: `${spoAdminUrl}/_vti_bin/client.svc/ProcessQuery`,
24
+ url: `${this.resource}/v1.0/servicePrincipals?$filter=displayName eq '${this.spoServicePrincipalDisplayName}'&$select=id`,
25
25
  headers: {
26
- 'X-RequestDigest': reqDigest.FormDigestValue
26
+ accept: 'application/json;odata.metadata=none'
27
27
  },
28
- 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="4" ObjectPathId="3" /><ObjectPath Id="6" ObjectPathId="5" /><Query Id="7" ObjectPathId="5"><Query SelectAllProperties="true"><Properties /></Query><ChildItemQuery SelectAllProperties="true"><Properties /></ChildItemQuery></Query></Actions><ObjectPaths><Constructor Id="3" TypeId="{104e8f06-1e00-4675-99c6-1b9b504ed8d8}" /><Property Id="5" ParentId="3" Name="PermissionGrants" /></ObjectPaths></Request>`
28
+ responseType: 'json'
29
29
  };
30
- const res = await request.post(requestOptions);
31
- const json = JSON.parse(res);
32
- const response = json[0];
33
- if (response.ErrorInfo) {
34
- throw response.ErrorInfo.ErrorMessage;
35
- }
36
- else {
37
- const result = json[json.length - 1]._Child_Items_;
38
- await logger.log(result.map(r => {
39
- delete r._ObjectType_;
40
- delete r.ClientId;
41
- delete r.ConsentType;
42
- return r;
43
- }));
30
+ const response = await request.get(requestOptions);
31
+ if (response.value.length === 0) {
32
+ throw `Service principal '${this.spoServicePrincipalDisplayName}' not found`;
44
33
  }
34
+ requestOptions.url = `${this.resource}/v1.0/servicePrincipals/${response.value[0].id}/oauth2PermissionGrants`;
35
+ const result = await request.get(requestOptions);
36
+ await logger.log(result.value);
45
37
  }
46
38
  catch (err) {
47
- this.handleRejectedPromise(err);
39
+ this.handleRejectedODataJsonPromise(err);
48
40
  }
49
41
  }
50
42
  }
@@ -3,7 +3,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
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
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _SpoTenantSiteArchiveCommand_instances, _SpoTenantSiteArchiveCommand_initTelemetry, _SpoTenantSiteArchiveCommand_initOptions, _SpoTenantSiteArchiveCommand_initValidators, _SpoTenantSiteArchiveCommand_initTypes;
6
+ var _SpoSiteArchiveCommand_instances, _SpoSiteArchiveCommand_initTelemetry, _SpoSiteArchiveCommand_initOptions, _SpoSiteArchiveCommand_initValidators, _SpoSiteArchiveCommand_initTypes;
7
7
  import { cli } from '../../../../cli/cli.js';
8
8
  import config from '../../../../config.js';
9
9
  import request from '../../../../request.js';
@@ -11,20 +11,20 @@ import { validation } from '../../../../utils/validation.js';
11
11
  import { spo } from '../../../../utils/spo.js';
12
12
  import SpoCommand from '../../../base/SpoCommand.js';
13
13
  import commands from '../../commands.js';
14
- class SpoTenantSiteArchiveCommand extends SpoCommand {
14
+ class SpoSiteArchiveCommand extends SpoCommand {
15
15
  get name() {
16
- return commands.TENANT_SITE_ARCHIVE;
16
+ return commands.SITE_ARCHIVE;
17
17
  }
18
18
  get description() {
19
19
  return 'Archives a site collection';
20
20
  }
21
21
  constructor() {
22
22
  super();
23
- _SpoTenantSiteArchiveCommand_instances.add(this);
24
- __classPrivateFieldGet(this, _SpoTenantSiteArchiveCommand_instances, "m", _SpoTenantSiteArchiveCommand_initTelemetry).call(this);
25
- __classPrivateFieldGet(this, _SpoTenantSiteArchiveCommand_instances, "m", _SpoTenantSiteArchiveCommand_initOptions).call(this);
26
- __classPrivateFieldGet(this, _SpoTenantSiteArchiveCommand_instances, "m", _SpoTenantSiteArchiveCommand_initValidators).call(this);
27
- __classPrivateFieldGet(this, _SpoTenantSiteArchiveCommand_instances, "m", _SpoTenantSiteArchiveCommand_initTypes).call(this);
23
+ _SpoSiteArchiveCommand_instances.add(this);
24
+ __classPrivateFieldGet(this, _SpoSiteArchiveCommand_instances, "m", _SpoSiteArchiveCommand_initTelemetry).call(this);
25
+ __classPrivateFieldGet(this, _SpoSiteArchiveCommand_instances, "m", _SpoSiteArchiveCommand_initOptions).call(this);
26
+ __classPrivateFieldGet(this, _SpoSiteArchiveCommand_instances, "m", _SpoSiteArchiveCommand_initValidators).call(this);
27
+ __classPrivateFieldGet(this, _SpoSiteArchiveCommand_instances, "m", _SpoSiteArchiveCommand_initTypes).call(this);
28
28
  }
29
29
  async commandAction(logger, args) {
30
30
  const archiveSite = async () => {
@@ -81,19 +81,19 @@ class SpoTenantSiteArchiveCommand extends SpoCommand {
81
81
  }
82
82
  }
83
83
  }
84
- _SpoTenantSiteArchiveCommand_instances = new WeakSet(), _SpoTenantSiteArchiveCommand_initTelemetry = function _SpoTenantSiteArchiveCommand_initTelemetry() {
84
+ _SpoSiteArchiveCommand_instances = new WeakSet(), _SpoSiteArchiveCommand_initTelemetry = function _SpoSiteArchiveCommand_initTelemetry() {
85
85
  this.telemetry.push((args) => {
86
86
  Object.assign(this.telemetryProperties, {
87
87
  force: !!args.options.force
88
88
  });
89
89
  });
90
- }, _SpoTenantSiteArchiveCommand_initOptions = function _SpoTenantSiteArchiveCommand_initOptions() {
90
+ }, _SpoSiteArchiveCommand_initOptions = function _SpoSiteArchiveCommand_initOptions() {
91
91
  this.options.unshift({ option: '-u, --url <url>' }, { option: '-f, --force' });
92
- }, _SpoTenantSiteArchiveCommand_initValidators = function _SpoTenantSiteArchiveCommand_initValidators() {
92
+ }, _SpoSiteArchiveCommand_initValidators = function _SpoSiteArchiveCommand_initValidators() {
93
93
  this.validators.push(async (args) => validation.isValidSharePointUrl(args.options.url));
94
- }, _SpoTenantSiteArchiveCommand_initTypes = function _SpoTenantSiteArchiveCommand_initTypes() {
94
+ }, _SpoSiteArchiveCommand_initTypes = function _SpoSiteArchiveCommand_initTypes() {
95
95
  this.types.string.push('url');
96
96
  this.types.boolean.push('force');
97
97
  };
98
- export default new SpoTenantSiteArchiveCommand();
99
- //# sourceMappingURL=tenant-site-archive.js.map
98
+ export default new SpoSiteArchiveCommand();
99
+ //# sourceMappingURL=site-archive.js.map
@@ -3,16 +3,16 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
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
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _SpoTenantSiteListCommand_instances, _SpoTenantSiteListCommand_initTelemetry, _SpoTenantSiteListCommand_initOptions, _SpoTenantSiteListCommand_initValidators;
6
+ var _SpoSiteListCommand_instances, _SpoSiteListCommand_initTelemetry, _SpoSiteListCommand_initOptions, _SpoSiteListCommand_initValidators;
7
7
  import config from '../../../../config.js';
8
8
  import request from '../../../../request.js';
9
9
  import { formatting } from '../../../../utils/formatting.js';
10
10
  import { spo } from '../../../../utils/spo.js';
11
11
  import SpoCommand from '../../../base/SpoCommand.js';
12
12
  import commands from '../../commands.js';
13
- class SpoTenantSiteListCommand extends SpoCommand {
13
+ class SpoSiteListCommand extends SpoCommand {
14
14
  get name() {
15
- return commands.TENANT_SITE_LIST;
15
+ return commands.SITE_LIST;
16
16
  }
17
17
  get description() {
18
18
  return 'Lists sites of the given type';
@@ -22,20 +22,17 @@ class SpoTenantSiteListCommand extends SpoCommand {
22
22
  }
23
23
  constructor() {
24
24
  super();
25
- _SpoTenantSiteListCommand_instances.add(this);
26
- __classPrivateFieldGet(this, _SpoTenantSiteListCommand_instances, "m", _SpoTenantSiteListCommand_initTelemetry).call(this);
27
- __classPrivateFieldGet(this, _SpoTenantSiteListCommand_instances, "m", _SpoTenantSiteListCommand_initOptions).call(this);
28
- __classPrivateFieldGet(this, _SpoTenantSiteListCommand_instances, "m", _SpoTenantSiteListCommand_initValidators).call(this);
25
+ _SpoSiteListCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _SpoSiteListCommand_instances, "m", _SpoSiteListCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _SpoSiteListCommand_instances, "m", _SpoSiteListCommand_initOptions).call(this);
28
+ __classPrivateFieldGet(this, _SpoSiteListCommand_instances, "m", _SpoSiteListCommand_initValidators).call(this);
29
29
  }
30
30
  alias() {
31
31
  return [commands.SITE_LIST];
32
32
  }
33
33
  async commandAction(logger, args) {
34
- if (args.options.includeOneDriveSites) {
35
- await this.warn(logger, `Parameter 'includeOneDriveSites' is deprecated. Please use 'withOneDriveSites' instead`);
36
- }
37
34
  const webTemplate = this.getWebTemplateId(args.options);
38
- const includeOneDriveSites = (args.options.includeOneDriveSites || args.options.withOneDriveSites) || false;
35
+ const includeOneDriveSites = args.options.withOneDriveSites || false;
39
36
  const personalSite = includeOneDriveSites === false ? '0' : '1';
40
37
  try {
41
38
  const spoAdminUrl = await spo.getSpoAdminUrl(logger, this.debug);
@@ -79,7 +76,7 @@ class SpoTenantSiteListCommand extends SpoCommand {
79
76
  if (options.webTemplate) {
80
77
  return options.webTemplate;
81
78
  }
82
- if (options.includeOneDriveSites || options.withOneDriveSites) {
79
+ if (options.withOneDriveSites) {
83
80
  return '';
84
81
  }
85
82
  switch (options.type) {
@@ -92,17 +89,16 @@ class SpoTenantSiteListCommand extends SpoCommand {
92
89
  }
93
90
  }
94
91
  }
95
- _SpoTenantSiteListCommand_instances = new WeakSet(), _SpoTenantSiteListCommand_initTelemetry = function _SpoTenantSiteListCommand_initTelemetry() {
92
+ _SpoSiteListCommand_instances = new WeakSet(), _SpoSiteListCommand_initTelemetry = function _SpoSiteListCommand_initTelemetry() {
96
93
  this.telemetry.push((args) => {
97
94
  Object.assign(this.telemetryProperties, {
98
95
  webTemplate: args.options.webTemplate,
99
96
  type: args.options.type,
100
97
  filter: (!(!args.options.filter)).toString(),
101
- includeOneDriveSites: typeof args.options.includeOneDriveSites !== 'undefined',
102
98
  withOneDriveSites: typeof args.options.withOneDriveSites !== 'undefined'
103
99
  });
104
100
  });
105
- }, _SpoTenantSiteListCommand_initOptions = function _SpoTenantSiteListCommand_initOptions() {
101
+ }, _SpoSiteListCommand_initOptions = function _SpoSiteListCommand_initOptions() {
106
102
  this.options.unshift({
107
103
  option: '-t, --type [type]',
108
104
  autocomplete: ['TeamSite', 'CommunicationSite']
@@ -110,12 +106,10 @@ _SpoTenantSiteListCommand_instances = new WeakSet(), _SpoTenantSiteListCommand_i
110
106
  option: '--webTemplate [webTemplate]'
111
107
  }, {
112
108
  option: '--filter [filter]'
113
- }, {
114
- option: '--includeOneDriveSites'
115
109
  }, {
116
110
  option: '--withOneDriveSites'
117
111
  });
118
- }, _SpoTenantSiteListCommand_initValidators = function _SpoTenantSiteListCommand_initValidators() {
112
+ }, _SpoSiteListCommand_initValidators = function _SpoSiteListCommand_initValidators() {
119
113
  this.validators.push(async (args) => {
120
114
  if (args.options.type && args.options.webTemplate) {
121
115
  return 'Specify either type or webTemplate, but not both';
@@ -125,17 +119,12 @@ _SpoTenantSiteListCommand_instances = new WeakSet(), _SpoTenantSiteListCommand_i
125
119
  typeValues.indexOf(args.options.type) < 0) {
126
120
  return `${args.options.type} is not a valid value for the type option. Allowed values are ${typeValues.join('|')}`;
127
121
  }
128
- if (args.options.includeOneDriveSites || args.options.withOneDriveSites
122
+ if (args.options.withOneDriveSites
129
123
  && (args.options.type || args.options.webTemplate)) {
130
- if (args.options.includeOneDriveSites) {
131
- return 'When using includeOneDriveSites, don\'t specify the type or webTemplate options';
132
- }
133
- else {
134
- return 'When using withOneDriveSites, don\'t specify the type or webTemplate options';
135
- }
124
+ return 'When using withOneDriveSites, don\'t specify the type or webTemplate options';
136
125
  }
137
126
  return true;
138
127
  });
139
128
  };
140
- export default new SpoTenantSiteListCommand();
141
- //# sourceMappingURL=tenant-site-list.js.map
129
+ export default new SpoSiteListCommand();
130
+ //# sourceMappingURL=site-list.js.map
@@ -3,15 +3,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
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
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _SpoTenantSiteMembershipListCommand_instances, _a, _SpoTenantSiteMembershipListCommand_initTelemetry, _SpoTenantSiteMembershipListCommand_initOptions, _SpoTenantSiteMembershipListCommand_initValidators, _SpoTenantSiteMembershipListCommand_initTypes;
6
+ var _SpoSiteMembershipListCommand_instances, _a, _SpoSiteMembershipListCommand_initTelemetry, _SpoSiteMembershipListCommand_initOptions, _SpoSiteMembershipListCommand_initValidators, _SpoSiteMembershipListCommand_initTypes;
7
7
  import { odata } from '../../../../utils/odata.js';
8
8
  import { spo } from '../../../../utils/spo.js';
9
9
  import { validation } from '../../../../utils/validation.js';
10
10
  import SpoCommand from '../../../base/SpoCommand.js';
11
11
  import commands from '../../commands.js';
12
- class SpoTenantSiteMembershipListCommand extends SpoCommand {
12
+ class SpoSiteMembershipListCommand extends SpoCommand {
13
13
  get name() {
14
- return commands.TENANT_SITE_MEMBERSHIP_LIST;
14
+ return commands.SITE_MEMBERSHIP_LIST;
15
15
  }
16
16
  get description() {
17
17
  return `Retrieves information about default site groups' membership`;
@@ -21,11 +21,11 @@ class SpoTenantSiteMembershipListCommand extends SpoCommand {
21
21
  }
22
22
  constructor() {
23
23
  super();
24
- _SpoTenantSiteMembershipListCommand_instances.add(this);
25
- __classPrivateFieldGet(this, _SpoTenantSiteMembershipListCommand_instances, "m", _SpoTenantSiteMembershipListCommand_initTelemetry).call(this);
26
- __classPrivateFieldGet(this, _SpoTenantSiteMembershipListCommand_instances, "m", _SpoTenantSiteMembershipListCommand_initOptions).call(this);
27
- __classPrivateFieldGet(this, _SpoTenantSiteMembershipListCommand_instances, "m", _SpoTenantSiteMembershipListCommand_initValidators).call(this);
28
- __classPrivateFieldGet(this, _SpoTenantSiteMembershipListCommand_instances, "m", _SpoTenantSiteMembershipListCommand_initTypes).call(this);
24
+ _SpoSiteMembershipListCommand_instances.add(this);
25
+ __classPrivateFieldGet(this, _SpoSiteMembershipListCommand_instances, "m", _SpoSiteMembershipListCommand_initTelemetry).call(this);
26
+ __classPrivateFieldGet(this, _SpoSiteMembershipListCommand_instances, "m", _SpoSiteMembershipListCommand_initOptions).call(this);
27
+ __classPrivateFieldGet(this, _SpoSiteMembershipListCommand_instances, "m", _SpoSiteMembershipListCommand_initValidators).call(this);
28
+ __classPrivateFieldGet(this, _SpoSiteMembershipListCommand_instances, "m", _SpoSiteMembershipListCommand_initTypes).call(this);
29
29
  }
30
30
  ;
31
31
  async commandAction(logger, args) {
@@ -90,29 +90,29 @@ class SpoTenantSiteMembershipListCommand extends SpoCommand {
90
90
  }
91
91
  }
92
92
  }
93
- _a = SpoTenantSiteMembershipListCommand, _SpoTenantSiteMembershipListCommand_instances = new WeakSet(), _SpoTenantSiteMembershipListCommand_initTelemetry = function _SpoTenantSiteMembershipListCommand_initTelemetry() {
93
+ _a = SpoSiteMembershipListCommand, _SpoSiteMembershipListCommand_instances = new WeakSet(), _SpoSiteMembershipListCommand_initTelemetry = function _SpoSiteMembershipListCommand_initTelemetry() {
94
94
  this.telemetry.push((args) => {
95
95
  Object.assign(this.telemetryProperties, {
96
96
  role: typeof args.options.role !== 'undefined'
97
97
  });
98
98
  });
99
- }, _SpoTenantSiteMembershipListCommand_initOptions = function _SpoTenantSiteMembershipListCommand_initOptions() {
99
+ }, _SpoSiteMembershipListCommand_initOptions = function _SpoSiteMembershipListCommand_initOptions() {
100
100
  this.options.unshift({
101
101
  option: '-u, --siteUrl <siteUrl>'
102
102
  }, {
103
103
  option: '-r, --role [role]',
104
104
  autocomplete: _a.RoleNames
105
105
  });
106
- }, _SpoTenantSiteMembershipListCommand_initValidators = function _SpoTenantSiteMembershipListCommand_initValidators() {
106
+ }, _SpoSiteMembershipListCommand_initValidators = function _SpoSiteMembershipListCommand_initValidators() {
107
107
  this.validators.push(async (args) => {
108
108
  if (args.options.role && !_a.RoleNames.some(roleName => roleName.toLocaleLowerCase() === args.options.role.toLocaleLowerCase())) {
109
109
  return `'${args.options.role}' is not a valid value for option 'role'. Valid values are: ${_a.RoleNames.join(', ')}`;
110
110
  }
111
111
  return validation.isValidSharePointUrl(args.options.siteUrl);
112
112
  });
113
- }, _SpoTenantSiteMembershipListCommand_initTypes = function _SpoTenantSiteMembershipListCommand_initTypes() {
113
+ }, _SpoSiteMembershipListCommand_initTypes = function _SpoSiteMembershipListCommand_initTypes() {
114
114
  this.types.string.push('role', 'siteUrl');
115
115
  };
116
- SpoTenantSiteMembershipListCommand.RoleNames = ['Owner', 'Member', 'Visitor'];
117
- export default new SpoTenantSiteMembershipListCommand();
118
- //# sourceMappingURL=tenant-site-membership-list.js.map
116
+ SpoSiteMembershipListCommand.RoleNames = ['Owner', 'Member', 'Visitor'];
117
+ export default new SpoSiteMembershipListCommand();
118
+ //# sourceMappingURL=site-membership-list.js.map