@pnp/cli-microsoft365 8.1.0-beta.3bc5759 → 8.1.0-beta.a4eba60

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 (54) hide show
  1. package/allCommands.json +1 -1
  2. package/allCommandsFull.json +1 -1
  3. package/dist/Auth.js +1 -1
  4. package/dist/m365/connection/commands/connection-remove.js +6 -2
  5. package/dist/m365/connection/commands/connection-set.js +4 -1
  6. package/dist/m365/connection/commands/connection-use.js +25 -4
  7. package/dist/m365/entra/commands/m365group/m365group-user-add.js +109 -32
  8. package/dist/m365/entra/commands/m365group/m365group-user-set.js +159 -84
  9. package/dist/m365/entra/commands/multitenant/multitenant-add.js +65 -0
  10. package/dist/m365/entra/commands/multitenant/multitenant-remove.js +118 -0
  11. package/dist/m365/entra/commands/multitenant/multitenant-set.js +72 -0
  12. package/dist/m365/entra/commands.js +3 -0
  13. package/dist/m365/spo/commands/file/file-roleassignment-add.js +1 -1
  14. package/dist/m365/spo/commands/file/file-roleinheritance-break.js +1 -1
  15. package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
  16. package/dist/m365/spo/commands/folder/folder-retentionlabel-ensure.js +1 -1
  17. package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +86 -0
  18. package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +110 -0
  19. package/dist/m365/spo/commands/list/ListInstance.js +6 -1
  20. package/dist/m365/spo/commands/list/list-get.js +9 -3
  21. package/dist/m365/spo/commands/list/list-roleassignment-add.js +46 -21
  22. package/dist/m365/spo/commands/list/list-roleassignment-remove.js +48 -46
  23. package/dist/m365/spo/commands.js +2 -0
  24. package/dist/utils/drive.js +61 -0
  25. package/dist/utils/spo.js +69 -6
  26. package/docs/docs/cmd/connection/connection-use.mdx +8 -2
  27. package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +28 -10
  28. package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +35 -11
  29. package/docs/docs/cmd/entra/multitenant/multitenant-add.mdx +107 -0
  30. package/docs/docs/cmd/entra/multitenant/multitenant-remove.mdx +58 -0
  31. package/docs/docs/cmd/entra/multitenant/multitenant-set.mdx +53 -0
  32. package/docs/docs/cmd/planner/plan/plan-remove.mdx +1 -1
  33. package/docs/docs/cmd/spe/containertype/containertype-list.mdx +24 -53
  34. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-get.mdx +4 -4
  35. package/docs/docs/cmd/spo/applicationcustomizer/applicationcustomizer-list.mdx +4 -4
  36. package/docs/docs/cmd/spo/file/file-retentionlabel-ensure.mdx +1 -1
  37. package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +2 -2
  38. package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +1 -1
  39. package/docs/docs/cmd/spo/file/file-roleinheritance-break.mdx +1 -1
  40. package/docs/docs/cmd/spo/file/file-roleinheritance-reset.mdx +1 -1
  41. package/docs/docs/cmd/spo/folder/folder-retentionlabel-ensure.mdx +2 -2
  42. package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +110 -0
  43. package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +114 -0
  44. package/docs/docs/cmd/spo/list/list-get.mdx +6 -0
  45. package/docs/docs/cmd/spo/list/list-roleassignment-add.mdx +15 -3
  46. package/docs/docs/cmd/spo/list/list-roleassignment-remove.mdx +15 -3
  47. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-ensure.mdx +4 -4
  48. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-remove.mdx +1 -1
  49. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.mdx +9 -9
  50. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-remove.mdx +7 -7
  51. package/docs/docs/cmd/spo/site/site-recyclebinitem-list.mdx +1 -1
  52. package/docs/docs/cmd/spo/web/web-roleassignment-add.mdx +1 -1
  53. package/docs/docs/cmd/spo/web/web-roleassignment-remove.mdx +1 -1
  54. package/package.json +1 -1
@@ -3,8 +3,9 @@ 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 _SpoListRoleAssignmentAddCommand_instances, _SpoListRoleAssignmentAddCommand_initTelemetry, _SpoListRoleAssignmentAddCommand_initOptions, _SpoListRoleAssignmentAddCommand_initValidators, _SpoListRoleAssignmentAddCommand_initOptionSets;
6
+ var _SpoListRoleAssignmentAddCommand_instances, _SpoListRoleAssignmentAddCommand_initTelemetry, _SpoListRoleAssignmentAddCommand_initOptions, _SpoListRoleAssignmentAddCommand_initValidators, _SpoListRoleAssignmentAddCommand_initOptionSets, _SpoListRoleAssignmentAddCommand_initTypes;
7
7
  import request from '../../../../request.js';
8
+ import { entraGroup } from '../../../../utils/entraGroup.js';
8
9
  import { formatting } from '../../../../utils/formatting.js';
9
10
  import { spo } from '../../../../utils/spo.js';
10
11
  import { urlUtil } from '../../../../utils/urlUtil.js';
@@ -25,6 +26,7 @@ class SpoListRoleAssignmentAddCommand extends SpoCommand {
25
26
  __classPrivateFieldGet(this, _SpoListRoleAssignmentAddCommand_instances, "m", _SpoListRoleAssignmentAddCommand_initOptions).call(this);
26
27
  __classPrivateFieldGet(this, _SpoListRoleAssignmentAddCommand_instances, "m", _SpoListRoleAssignmentAddCommand_initValidators).call(this);
27
28
  __classPrivateFieldGet(this, _SpoListRoleAssignmentAddCommand_instances, "m", _SpoListRoleAssignmentAddCommand_initOptionSets).call(this);
29
+ __classPrivateFieldGet(this, _SpoListRoleAssignmentAddCommand_instances, "m", _SpoListRoleAssignmentAddCommand_initTypes).call(this);
28
30
  }
29
31
  async commandAction(logger, args) {
30
32
  if (this.verbose) {
@@ -42,39 +44,48 @@ class SpoListRoleAssignmentAddCommand extends SpoCommand {
42
44
  const listServerRelativeUrl = urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
43
45
  requestUrl += `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
44
46
  }
45
- args.options.roleDefinitionId = await this.getRoleDefinitionId(args.options, logger);
47
+ const roleDefinitionId = await this.getRoleDefinitionId(args.options, logger);
48
+ let principalId = args.options.principalId;
46
49
  if (args.options.upn) {
47
- const user = await spo.getUserByEmail(args.options.webUrl, args.options.upn, logger, this.verbose);
48
- args.options.principalId = user.Id;
49
- await this.addRoleAssignment(requestUrl, logger, args.options);
50
+ const user = await spo.ensureUser(args.options.webUrl, args.options.upn);
51
+ principalId = user.Id;
50
52
  }
51
53
  else if (args.options.groupName) {
52
54
  const group = await spo.getGroupByName(args.options.webUrl, args.options.groupName, logger, this.verbose);
53
- args.options.principalId = group.Id;
54
- await this.addRoleAssignment(requestUrl, logger, args.options);
55
+ principalId = group.Id;
55
56
  }
56
- else {
57
- await this.addRoleAssignment(requestUrl, logger, args.options);
57
+ else if (args.options.entraGroupId || args.options.entraGroupName) {
58
+ if (this.verbose) {
59
+ await logger.logToStderr('Retrieving group information...');
60
+ }
61
+ let group;
62
+ if (args.options.entraGroupId) {
63
+ group = await entraGroup.getGroupById(args.options.entraGroupId);
64
+ }
65
+ else {
66
+ group = await entraGroup.getGroupByDisplayName(args.options.entraGroupName);
67
+ }
68
+ const siteUser = await spo.ensureEntraGroup(args.options.webUrl, group);
69
+ principalId = siteUser.Id;
58
70
  }
71
+ await this.addRoleAssignment(requestUrl, principalId, roleDefinitionId);
59
72
  }
60
73
  catch (err) {
61
74
  this.handleRejectedODataJsonPromise(err);
62
75
  }
63
76
  }
64
- async addRoleAssignment(requestUrl, logger, options) {
77
+ async addRoleAssignment(requestUrl, principalId, roleDefinitionId) {
65
78
  const requestOptions = {
66
- url: `${requestUrl}roleassignments/addroleassignment(principalid='${options.principalId}',roledefid='${options.roleDefinitionId}')`,
67
- method: 'POST',
79
+ url: `${requestUrl}roleassignments/addroleassignment(principalid='${principalId}',roledefid='${roleDefinitionId}')`,
68
80
  headers: {
69
- 'accept': 'application/json;odata=nometadata',
70
- 'content-type': 'application/json'
81
+ accept: 'application/json;odata=nometadata'
71
82
  },
72
83
  responseType: 'json'
73
84
  };
74
85
  return request.post(requestOptions);
75
86
  }
76
87
  async getRoleDefinitionId(options, logger) {
77
- if (!options.roleDefinitionName) {
88
+ if (options.roleDefinitionId) {
78
89
  return options.roleDefinitionId;
79
90
  }
80
91
  const roleDefinition = await spo.getRoleDefinitionByName(options.webUrl, options.roleDefinitionName, logger, this.verbose);
@@ -90,6 +101,8 @@ _SpoListRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListRoleAssignme
90
101
  principalId: typeof args.options.principalId !== 'undefined',
91
102
  upn: typeof args.options.upn !== 'undefined',
92
103
  groupName: typeof args.options.groupName !== 'undefined',
104
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
105
+ entraGroupName: typeof args.options.entraGroupName !== 'undefined',
93
106
  roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
94
107
  roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined'
95
108
  });
@@ -109,6 +122,10 @@ _SpoListRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListRoleAssignme
109
122
  option: '--upn [upn]'
110
123
  }, {
111
124
  option: '--groupName [groupName]'
125
+ }, {
126
+ option: '--entraGroupId [entraGroupId]'
127
+ }, {
128
+ option: '--entraGroupName [entraGroupName]'
112
129
  }, {
113
130
  option: '--roleDefinitionId [roleDefinitionId]'
114
131
  }, {
@@ -121,18 +138,26 @@ _SpoListRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListRoleAssignme
121
138
  return isValidSharePointUrl;
122
139
  }
123
140
  if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
124
- return `${args.options.listId} is not a valid GUID`;
141
+ return `'${args.options.listId}' is not a valid GUID for option listId.`;
142
+ }
143
+ if (args.options.upn && !validation.isValidUserPrincipalName(args.options.upn)) {
144
+ return `'${args.options.upn}' is not a valid user principal name for option upn.`;
145
+ }
146
+ if (args.options.principalId && !validation.isValidPositiveInteger(args.options.principalId)) {
147
+ return `Specified principalId '${args.options.principalId}' is not a valid number.`;
125
148
  }
126
- if (args.options.principalId && isNaN(args.options.principalId)) {
127
- return `Specified principalId ${args.options.principalId} is not a number`;
149
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
150
+ return `'${args.options.entraGroupId}' is not a valid GUID for option entraGroupId.`;
128
151
  }
129
- if (args.options.roleDefinitionId && isNaN(args.options.roleDefinitionId)) {
130
- return `Specified roleDefinitionId ${args.options.roleDefinitionId} is not a number`;
152
+ if (args.options.roleDefinitionId && !validation.isValidPositiveInteger(args.options.roleDefinitionId)) {
153
+ return `Specified roleDefinitionId '${args.options.roleDefinitionId}' is not a valid number.`;
131
154
  }
132
155
  return true;
133
156
  });
134
157
  }, _SpoListRoleAssignmentAddCommand_initOptionSets = function _SpoListRoleAssignmentAddCommand_initOptionSets() {
135
- this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] }, { options: ['principalId', 'upn', 'groupName'] }, { options: ['roleDefinitionId', 'roleDefinitionName'] });
158
+ this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] }, { options: ['principalId', 'upn', 'groupName', 'entraGroupId', 'entraGroupName'] }, { options: ['roleDefinitionId', 'roleDefinitionName'] });
159
+ }, _SpoListRoleAssignmentAddCommand_initTypes = function _SpoListRoleAssignmentAddCommand_initTypes() {
160
+ this.types.string.push('webUrl', 'listId', 'listTitle', 'listUrl', 'upn', 'groupName', 'entraGroupId', 'entraGroupName', 'roleDefinitionName');
136
161
  };
137
162
  export default new SpoListRoleAssignmentAddCommand();
138
163
  //# sourceMappingURL=list-roleassignment-add.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 _SpoListRoleAssignmentRemoveCommand_instances, _SpoListRoleAssignmentRemoveCommand_initTelemetry, _SpoListRoleAssignmentRemoveCommand_initOptions, _SpoListRoleAssignmentRemoveCommand_initValidators, _SpoListRoleAssignmentRemoveCommand_initOptionSets;
6
+ var _SpoListRoleAssignmentRemoveCommand_instances, _SpoListRoleAssignmentRemoveCommand_initTelemetry, _SpoListRoleAssignmentRemoveCommand_initOptions, _SpoListRoleAssignmentRemoveCommand_initValidators, _SpoListRoleAssignmentRemoveCommand_initOptionSets, _SpoListRoleAssignmentRemoveCommand_initTypes;
7
7
  import { cli } from '../../../../cli/cli.js';
8
8
  import request from '../../../../request.js';
9
9
  import { formatting } from '../../../../utils/formatting.js';
10
+ import { spo } from '../../../../utils/spo.js';
10
11
  import { urlUtil } from '../../../../utils/urlUtil.js';
11
12
  import { validation } from '../../../../utils/validation.js';
12
13
  import SpoCommand from '../../../base/SpoCommand.js';
13
14
  import commands from '../../commands.js';
14
- import spoGroupGetCommand from '../group/group-get.js';
15
- import spoUserGetCommand from '../user/user-get.js';
15
+ import { entraGroup } from '../../../../utils/entraGroup.js';
16
16
  class SpoListRoleAssignmentRemoveCommand extends SpoCommand {
17
17
  get name() {
18
18
  return commands.LIST_ROLEASSIGNMENT_REMOVE;
@@ -27,11 +27,12 @@ class SpoListRoleAssignmentRemoveCommand extends SpoCommand {
27
27
  __classPrivateFieldGet(this, _SpoListRoleAssignmentRemoveCommand_instances, "m", _SpoListRoleAssignmentRemoveCommand_initOptions).call(this);
28
28
  __classPrivateFieldGet(this, _SpoListRoleAssignmentRemoveCommand_instances, "m", _SpoListRoleAssignmentRemoveCommand_initValidators).call(this);
29
29
  __classPrivateFieldGet(this, _SpoListRoleAssignmentRemoveCommand_instances, "m", _SpoListRoleAssignmentRemoveCommand_initOptionSets).call(this);
30
+ __classPrivateFieldGet(this, _SpoListRoleAssignmentRemoveCommand_instances, "m", _SpoListRoleAssignmentRemoveCommand_initTypes).call(this);
30
31
  }
31
32
  async commandAction(logger, args) {
32
33
  const removeRoleAssignment = async () => {
33
34
  if (this.verbose) {
34
- await logger.logToStderr(`Removing role assignment from list in site at ${args.options.webUrl}...`);
35
+ await logger.logToStderr(`Removing role assignment from list '${args.options.listId || args.options.listTitle || args.options.listUrl}' of site ${args.options.webUrl}...`);
35
36
  }
36
37
  try {
37
38
  let requestUrl = `${args.options.webUrl}/_api/web/`;
@@ -45,17 +46,30 @@ class SpoListRoleAssignmentRemoveCommand extends SpoCommand {
45
46
  const listServerRelativeUrl = urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
46
47
  requestUrl += `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
47
48
  }
49
+ let principalId = args.options.principalId;
48
50
  if (args.options.upn) {
49
- args.options.principalId = await this.getUserPrincipalId(args.options);
50
- await this.removeRoleAssignment(requestUrl, logger, args.options);
51
+ const user = await spo.ensureUser(args.options.webUrl, args.options.upn);
52
+ principalId = user.Id;
51
53
  }
52
54
  else if (args.options.groupName) {
53
- args.options.principalId = await this.getGroupPrincipalId(args.options);
54
- await this.removeRoleAssignment(requestUrl, logger, args.options);
55
+ const spGroup = await spo.getGroupByName(args.options.webUrl, args.options.groupName, logger, this.verbose);
56
+ principalId = spGroup.Id;
55
57
  }
56
- else {
57
- await this.removeRoleAssignment(requestUrl, logger, args.options);
58
+ else if (args.options.entraGroupId || args.options.entraGroupName) {
59
+ if (this.verbose) {
60
+ await logger.logToStderr('Retrieving group information...');
61
+ }
62
+ let group;
63
+ if (args.options.entraGroupId) {
64
+ group = await entraGroup.getGroupById(args.options.entraGroupId);
65
+ }
66
+ else {
67
+ group = await entraGroup.getGroupByDisplayName(args.options.entraGroupName);
68
+ }
69
+ const siteUser = await spo.ensureEntraGroup(args.options.webUrl, group);
70
+ principalId = siteUser.Id;
58
71
  }
72
+ await this.removeRoleAssignment(requestUrl, principalId);
59
73
  }
60
74
  catch (err) {
61
75
  this.handleRejectedODataJsonPromise(err);
@@ -65,49 +79,22 @@ class SpoListRoleAssignmentRemoveCommand extends SpoCommand {
65
79
  await removeRoleAssignment();
66
80
  }
67
81
  else {
68
- const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove role assignment from list ${args.options.listId || args.options.listTitle} from site ${args.options.webUrl}?` });
82
+ const result = await cli.promptForConfirmation({ message: `Are you sure you want to remove role assignment from the specified user of list '${args.options.listId || args.options.listTitle || args.options.listUrl}'?` });
69
83
  if (result) {
70
84
  await removeRoleAssignment();
71
85
  }
72
86
  }
73
87
  }
74
- async removeRoleAssignment(requestUrl, logger, options) {
88
+ async removeRoleAssignment(requestUrl, principalId) {
75
89
  const requestOptions = {
76
- url: `${requestUrl}roleassignments/removeroleassignment(principalid='${options.principalId}')`,
77
- method: 'POST',
90
+ url: `${requestUrl}roleassignments/removeroleassignment(principalid='${principalId}')`,
78
91
  headers: {
79
- 'accept': 'application/json;odata=nometadata',
80
- 'content-type': 'application/json'
92
+ accept: 'application/json;odata=nometadata'
81
93
  },
82
94
  responseType: 'json'
83
95
  };
84
96
  return request.post(requestOptions);
85
97
  }
86
- async getGroupPrincipalId(options) {
87
- const groupGetCommandOptions = {
88
- webUrl: options.webUrl,
89
- name: options.groupName,
90
- output: 'json',
91
- debug: this.debug,
92
- verbose: this.verbose
93
- };
94
- const output = await cli.executeCommandWithOutput(spoGroupGetCommand, { options: { ...groupGetCommandOptions, _: [] } });
95
- const getGroupOutput = JSON.parse(output.stdout);
96
- return getGroupOutput.Id;
97
- }
98
- async getUserPrincipalId(options) {
99
- const userGetCommandOptions = {
100
- webUrl: options.webUrl,
101
- email: options.upn,
102
- id: undefined,
103
- output: 'json',
104
- debug: this.debug,
105
- verbose: this.verbose
106
- };
107
- const output = await cli.executeCommandWithOutput(spoUserGetCommand, { options: { ...userGetCommandOptions, _: [] } });
108
- const getUserOutput = JSON.parse(output.stdout);
109
- return getUserOutput.Id;
110
- }
111
98
  }
112
99
  _SpoListRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListRoleAssignmentRemoveCommand_initTelemetry = function _SpoListRoleAssignmentRemoveCommand_initTelemetry() {
113
100
  this.telemetry.push((args) => {
@@ -118,7 +105,9 @@ _SpoListRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListRoleAssig
118
105
  principalId: typeof args.options.principalId !== 'undefined',
119
106
  upn: typeof args.options.upn !== 'undefined',
120
107
  groupName: typeof args.options.groupName !== 'undefined',
121
- force: (!(!args.options.force)).toString()
108
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
109
+ entraGroupName: typeof args.options.entraGroupName !== 'undefined',
110
+ force: !!args.options.force
122
111
  });
123
112
  });
124
113
  }, _SpoListRoleAssignmentRemoveCommand_initOptions = function _SpoListRoleAssignmentRemoveCommand_initOptions() {
@@ -136,6 +125,10 @@ _SpoListRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListRoleAssig
136
125
  option: '--upn [upn]'
137
126
  }, {
138
127
  option: '--groupName [groupName]'
128
+ }, {
129
+ option: '--entraGroupId [entraGroupId]'
130
+ }, {
131
+ option: '--entraGroupName [entraGroupName]'
139
132
  }, {
140
133
  option: '-f, --force'
141
134
  });
@@ -146,15 +139,24 @@ _SpoListRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListRoleAssig
146
139
  return isValidSharePointUrl;
147
140
  }
148
141
  if (args.options.listId && !validation.isValidGuid(args.options.listId)) {
149
- return `${args.options.listId} is not a valid GUID`;
142
+ return `'${args.options.listId}' is not a valid GUID for option listId.`;
143
+ }
144
+ if (args.options.upn && !validation.isValidUserPrincipalName(args.options.upn)) {
145
+ return `'${args.options.upn}' is not a valid user principal name for option upn.`;
146
+ }
147
+ if (args.options.principalId && !validation.isValidPositiveInteger(args.options.principalId)) {
148
+ return `'${args.options.principalId}' is not a valid number for option principalId.`;
150
149
  }
151
- if (args.options.principalId && isNaN(args.options.principalId)) {
152
- return `Specified principalId ${args.options.principalId} is not a number`;
150
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
151
+ return `'${args.options.entraGroupId}' is not a valid GUID for option entraGroupId.`;
153
152
  }
154
153
  return true;
155
154
  });
156
155
  }, _SpoListRoleAssignmentRemoveCommand_initOptionSets = function _SpoListRoleAssignmentRemoveCommand_initOptionSets() {
157
- this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] }, { options: ['principalId', 'upn', 'groupName'] });
156
+ this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] }, { options: ['principalId', 'upn', 'groupName', 'entraGroupId', 'entraGroupName'] });
157
+ }, _SpoListRoleAssignmentRemoveCommand_initTypes = function _SpoListRoleAssignmentRemoveCommand_initTypes() {
158
+ this.types.string.push('webUrl', 'listId', 'listTitle', 'listUrl', 'upn', 'groupName', 'entraGroupId', 'entraGroupName');
159
+ this.types.boolean.push('force');
158
160
  };
159
161
  export default new SpoListRoleAssignmentRemoveCommand();
160
162
  //# sourceMappingURL=list-roleassignment-remove.js.map
@@ -100,6 +100,8 @@ export default {
100
100
  FOLDER_ROLEASSIGNMENT_ADD: `${prefix} folder roleassignment add`,
101
101
  FOLDER_ROLEINHERITANCE_BREAK: `${prefix} folder roleinheritance break`,
102
102
  FOLDER_ROLEINHERITANCE_RESET: `${prefix} folder roleinheritance reset`,
103
+ FOLDER_SHARINGLINK_GET: `${prefix} folder sharinglink get`,
104
+ FOLDER_SHARINGLINK_LIST: `${prefix} folder sharinglink list`,
103
105
  GET: `${prefix} get`,
104
106
  GROUP_ADD: `${prefix} group add`,
105
107
  GROUP_GET: `${prefix} group get`,
@@ -0,0 +1,61 @@
1
+ import request from "../request.js";
2
+ export const drive = {
3
+ /**
4
+ * Retrieves the Drive associated with the specified site and URL.
5
+ * @param siteId Site ID
6
+ * @param url Drive URL
7
+ * @param logger The logger object
8
+ * @param verbose Set for verbose logging
9
+ * @returns The Drive associated with the drive URL.
10
+ */
11
+ async getDriveByUrl(siteId, url, logger, verbose) {
12
+ if (verbose && logger) {
13
+ await logger.logToStderr(`Retrieving drive information for URL: ${url.href}`);
14
+ }
15
+ const requestOptions = {
16
+ url: `https://graph.microsoft.com/v1.0/sites/${siteId}/drives?$select=webUrl,id`,
17
+ headers: {
18
+ accept: 'application/json;odata.metadata=none'
19
+ },
20
+ responseType: 'json'
21
+ };
22
+ const drives = await request.get(requestOptions);
23
+ const lowerCaseFolderUrl = url.href.toLowerCase();
24
+ const drive = drives.value
25
+ .sort((a, b) => b.webUrl.localeCompare(a.webUrl))
26
+ .find((d) => {
27
+ const driveUrl = d.webUrl.toLowerCase();
28
+ return lowerCaseFolderUrl.startsWith(driveUrl) &&
29
+ (driveUrl.length === lowerCaseFolderUrl.length ||
30
+ lowerCaseFolderUrl[driveUrl.length] === '/');
31
+ });
32
+ if (!drive) {
33
+ throw new Error(`Drive '${url.href}' not found`);
34
+ }
35
+ return drive;
36
+ },
37
+ /**
38
+ * Retrieves the ID of a drive item (file, folder, etc.) associated with the given drive and item URL.
39
+ * @param drive The Drive object containing the item
40
+ * @param itemUrl Item URL
41
+ * @param logger The logger object
42
+ * @param verbose Set for verbose logging
43
+ * @returns Drive item ID
44
+ */
45
+ async getDriveItemId(drive, itemUrl, logger, verbose) {
46
+ const relativeItemUrl = itemUrl.href.replace(new RegExp(`${drive.webUrl}`, 'i'), '').replace(/\/+$/, '');
47
+ if (verbose && logger) {
48
+ await logger.logToStderr(`Retrieving drive item ID for URL: ${relativeItemUrl}`);
49
+ }
50
+ const requestOptions = {
51
+ url: `https://graph.microsoft.com/v1.0/drives/${drive.id}/root${relativeItemUrl ? `:${relativeItemUrl}` : ''}?$select=id`,
52
+ headers: {
53
+ accept: 'application/json;odata.metadata=none'
54
+ },
55
+ responseType: 'json'
56
+ };
57
+ const driveItem = await request.get(requestOptions);
58
+ return driveItem?.id;
59
+ }
60
+ };
61
+ //# sourceMappingURL=drive.js.map
package/dist/utils/spo.js CHANGED
@@ -454,15 +454,46 @@ export const spo = {
454
454
  const res = await request.get(requestOptions);
455
455
  return res.AadObjectId.NameId;
456
456
  },
457
+ /**
458
+ * Ensure a user exists on a specific SharePoint site.
459
+ * @param webUrl URL of the SharePoint site.
460
+ * @param logonName Logon name of the user to ensure on the SharePoint site.
461
+ * @returns SharePoint user object.
462
+ */
463
+ async ensureUser(webUrl, logonName) {
464
+ const requestOptions = {
465
+ url: `${webUrl}/_api/web/EnsureUser`,
466
+ headers: {
467
+ accept: 'application/json;odata=nometadata'
468
+ },
469
+ responseType: 'json',
470
+ data: {
471
+ logonName: logonName
472
+ }
473
+ };
474
+ return request.post(requestOptions);
475
+ },
476
+ /**
477
+ * Ensure a Microsoft Entra ID group exists on a specific SharePoint site.
478
+ * @param webUrl URL of the SharePoint site.
479
+ * @param group Microsoft Entra ID group.
480
+ * @returns SharePoint user object.
481
+ */
482
+ async ensureEntraGroup(webUrl, group) {
483
+ if (!group.securityEnabled) {
484
+ throw new Error('Cannot ensure a Microsoft Entra ID group that is not security enabled.');
485
+ }
486
+ return this.ensureUser(webUrl, group.mailEnabled ? `c:0o.c|federateddirectoryclaimprovider|${group.id}` : `c:0t.c|tenant|${group.id}`);
487
+ },
457
488
  /**
458
489
  * Retrieves the spo user by email.
459
490
  * @param webUrl Web url
460
491
  * @param email The email of the user
461
492
  * @param logger the Logger object
462
- * @param debug set if debug logging should be logged
493
+ * @param verbose set if verbose logging should be logged
463
494
  */
464
- async getUserByEmail(webUrl, email, logger, debug) {
465
- if (debug) {
495
+ async getUserByEmail(webUrl, email, logger, verbose) {
496
+ if (verbose) {
466
497
  await logger.logToStderr(`Retrieving the spo user by email ${email}`);
467
498
  }
468
499
  const requestUrl = `${webUrl}/_api/web/siteusers/GetByEmail('${formatting.encodeQueryParameter(email)}')`;
@@ -533,10 +564,10 @@ export const spo = {
533
564
  * @param webUrl Web url
534
565
  * @param name The name of the group
535
566
  * @param logger the Logger object
536
- * @param debug set if debug logging should be logged
567
+ * @param verbose set if verbose logging should be logged
537
568
  */
538
- async getGroupByName(webUrl, name, logger, debug) {
539
- if (debug) {
569
+ async getGroupByName(webUrl, name, logger, verbose) {
570
+ if (verbose) {
540
571
  await logger.logToStderr(`Retrieving the group by name ${name}`);
541
572
  }
542
573
  const requestUrl = `${webUrl}/_api/web/sitegroups/GetByName('${formatting.encodeQueryParameter(name)}')`;
@@ -1374,6 +1405,38 @@ export const spo = {
1374
1405
  const site = await request.get(requestOptions);
1375
1406
  return site.id;
1376
1407
  },
1408
+ /**
1409
+ * Retrieves the server-relative URL of a folder.
1410
+ * @param webUrl Web URL
1411
+ * @param folderUrl Folder URL
1412
+ * @param folderId Folder ID
1413
+ * @param logger The logger object
1414
+ * @param verbose Set for verbose logging
1415
+ * @returns The server-relative URL of the folder
1416
+ */
1417
+ async getFolderServerRelativeUrl(webUrl, folderUrl, folderId, logger, verbose) {
1418
+ if (verbose && logger) {
1419
+ await logger.logToStderr(`Retrieving server-relative URL for folder ${folderUrl ? `URL: ${folderUrl}` : `ID: ${folderId}`}`);
1420
+ }
1421
+ let requestUrl = `${webUrl}/_api/web/`;
1422
+ if (folderUrl) {
1423
+ const folderServerRelativeUrl = urlUtil.getServerRelativePath(webUrl, folderUrl);
1424
+ requestUrl += `GetFolderByServerRelativePath(decodedUrl='${formatting.encodeQueryParameter(folderServerRelativeUrl)}')`;
1425
+ }
1426
+ else {
1427
+ requestUrl += `GetFolderById('${folderId}')`;
1428
+ }
1429
+ requestUrl += '?$select=ServerRelativeUrl';
1430
+ const requestOptions = {
1431
+ url: requestUrl,
1432
+ headers: {
1433
+ accept: 'application/json;odata=nometadata'
1434
+ },
1435
+ responseType: 'json'
1436
+ };
1437
+ const res = await request.get(requestOptions);
1438
+ return res.ServerRelativeUrl;
1439
+ },
1377
1440
  /**
1378
1441
  * Retrieves the ObjectIdentity from a SharePoint site
1379
1442
  * @param webUrl web url
@@ -15,7 +15,7 @@ m365 connection use [options]
15
15
  ## Options
16
16
 
17
17
  ```md definition-list
18
- `-n, --name <name>`
18
+ `-n, --name [name]`
19
19
  : The name of the connection to switch to.
20
20
  ```
21
21
 
@@ -23,7 +23,13 @@ m365 connection use [options]
23
23
 
24
24
  ## Remarks
25
25
 
26
- The value for `--name` can be found by running [m365 connection list](connection-list.mdx). You can update the name of a connection by running [m365 connection set](connection-set.mdx).
26
+ :::tip
27
+
28
+ If you haven't disabled the "prompt" setting, running this command without options will show a list of available connections. You can then select the connection to activate it.
29
+
30
+ :::
31
+
32
+ You can update the name of a connection by running [m365 connection set](connection-set.mdx).
27
33
 
28
34
  ## Examples
29
35
 
@@ -26,13 +26,25 @@ m365 teams user add
26
26
 
27
27
  ```md definition-list
28
28
  `-i, --groupId [groupId]`
29
- : The ID of the Microsoft 365 Group to which to add the user
29
+ : The ID of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
30
+
31
+ `--groupName [groupName]`
32
+ : The display name of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
30
33
 
31
34
  `--teamId [teamId]`
32
- : The ID of the Teams team to which to add the user
35
+ : The ID of the Teams team. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
36
+
37
+ `--teamName [teamName]`
38
+ : The display name of the Microsoft Teams team. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.
39
+
40
+ `-n, --userName [userName]`
41
+ : (deprecated) User's UPN (User Principal Name), e.g. johndoe@example.com.
42
+
43
+ `--ids [ids]`
44
+ : Microsoft Entra IDs of users. You can also pass a comma-separated list of IDs. Specify either `ids` or `userNames` but not both.
33
45
 
34
- `-n, --userName <userName>`
35
- : User's UPN (user principal name, eg. johndoe@example.com)
46
+ `--userNames [userNames]`
47
+ : The user principal names of users. You can also pass a comma-separated list of UPNs. Specify either `ids` or `userNames` but not both.
36
48
 
37
49
  `-r, --role [role]`
38
50
  : The role to be assigned to the new user: `Owner,Member`. Default `Member`
@@ -42,22 +54,28 @@ m365 teams user add
42
54
 
43
55
  ## Examples
44
56
 
45
- Add a new member to the specified Microsoft 365 Group
57
+ Add a new member with the userNames parameter to the specified Microsoft 365 Group
58
+
59
+ ```sh
60
+ m365 entra m365group user add --groupId '00000000-0000-0000-0000-000000000000' --userNames 'anne.matthews@contoso.onmicrosoft.com'
61
+ ```
62
+
63
+ Add multiple new owners with the userNames parameter to the specified Microsoft 365 Group
46
64
 
47
65
  ```sh
48
- m365 entra m365group user add --groupId '00000000-0000-0000-0000-000000000000' --userName 'anne.matthews@contoso.onmicrosoft.com'
66
+ m365 entra m365group user add --groupName 'Contoso' --userNames 'anne.matthews@contoso.onmicrosoft.com, john.doe@contoso.onmicrosoft.com' --role Owner
49
67
  ```
50
68
 
51
- Add a new owner to the specified Microsoft 365 Group
69
+ Add a new member with the userNames parameter to the specified Microsoft Teams team
52
70
 
53
71
  ```sh
54
- m365 entra m365group user add --groupId '00000000-0000-0000-0000-000000000000' --userName 'anne.matthews@contoso.onmicrosoft.com' --role Owner
72
+ m365 entra m365group member add --teamId '00000000-0000-0000-0000-000000000000' --userNames 'anne.matthews@contoso.onmicrosoft.com' --role Member
55
73
  ```
56
74
 
57
- Add a new member to the specified Microsoft Teams team
75
+ Add multiple new members with the ids parameter to the specified Microsoft Teams team
58
76
 
59
77
  ```sh
60
- m365 teams user add --teamId '00000000-0000-0000-0000-000000000000' --userName 'anne.matthews@contoso.onmicrosoft.com'
78
+ m365 entra m365group user add --teamName 'Engineering' --ids '74a3b772-3122-447b-b9da-10895e238219,dd3d21e4-a142-46b9-8482-bca8fe9596b3' --role Member
61
79
  ```
62
80
 
63
81
  ## Response