@pnp/cli-microsoft365 10.3.0-beta.cd20f0c → 10.3.0-beta.ea113b7

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 (41) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/README.md +11 -6
  3. package/allCommands.json +1 -1
  4. package/allCommandsFull.json +1 -1
  5. package/dist/m365/commands/login.js +6 -6
  6. package/dist/m365/entra/commands/approleassignment/approleassignment-remove.js +1 -1
  7. package/dist/m365/entra/commands/group/group-list.js +3 -2
  8. package/dist/m365/entra/commands/pim/pim-role-assignment-remove.js +186 -0
  9. package/dist/m365/entra/commands.js +1 -0
  10. package/dist/m365/exo/commands/approleassignment/approleassignment-add.js +235 -0
  11. package/dist/m365/exo/commands.js +5 -0
  12. package/dist/m365/pp/commands/website/website-get.js +60 -0
  13. package/dist/m365/pp/commands.js +2 -1
  14. package/dist/m365/spo/commands/file/file-roleassignment-add.js +26 -2
  15. package/dist/m365/spo/commands/file/file-roleassignment-remove.js +26 -2
  16. package/dist/m365/spo/commands/folder/folder-roleassignment-add.js +27 -24
  17. package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +24 -7
  18. package/dist/m365/spo/commands/list/list-defaultvalue-list.js +140 -0
  19. package/dist/m365/spo/commands/listitem/listitem-roleassignment-add.js +25 -7
  20. package/dist/m365/spo/commands/listitem/listitem-roleassignment-remove.js +22 -5
  21. package/dist/m365/spo/commands/web/web-roleassignment-add.js +22 -5
  22. package/dist/m365/spo/commands/web/web-roleassignment-remove.js +22 -5
  23. package/dist/m365/spo/commands.js +1 -0
  24. package/dist/utils/customAppScope.js +29 -0
  25. package/dist/utils/entraServicePrincipal.js +46 -0
  26. package/dist/utils/powerPlatform.js +38 -0
  27. package/dist/utils/roleDefinition.js +23 -0
  28. package/dist/utils/validation.js +4 -0
  29. package/docs/docs/cmd/entra/pim/pim-role-assignment-remove.mdx +197 -0
  30. package/docs/docs/cmd/exo/approleassignment/approleassignment-add.mdx +170 -0
  31. package/docs/docs/cmd/pp/website/website-get.mdx +153 -0
  32. package/docs/docs/cmd/spo/file/file-roleassignment-add.mdx +21 -4
  33. package/docs/docs/cmd/spo/file/file-roleassignment-remove.mdx +21 -3
  34. package/docs/docs/cmd/spo/folder/folder-roleassignment-add.mdx +15 -3
  35. package/docs/docs/cmd/spo/folder/folder-roleassignment-remove.mdx +15 -3
  36. package/docs/docs/cmd/spo/list/list-defaultvalue-list.mdx +110 -0
  37. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.mdx +15 -3
  38. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-remove.mdx +17 -5
  39. package/docs/docs/cmd/spo/web/web-roleassignment-add.mdx +15 -3
  40. package/docs/docs/cmd/spo/web/web-roleassignment-remove.mdx +15 -3
  41. package/package.json +1 -1
@@ -12,6 +12,7 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
12
12
  import { validation } from '../../../../utils/validation.js';
13
13
  import SpoCommand from '../../../base/SpoCommand.js';
14
14
  import commands from '../../commands.js';
15
+ import { entraGroup } from '../../../../utils/entraGroup.js';
15
16
  class SpoFileRoleAssignmentRemoveCommand extends SpoCommand {
16
17
  get name() {
17
18
  return commands.FILE_ROLEASSIGNMENT_REMOVE;
@@ -42,6 +43,20 @@ class SpoFileRoleAssignmentRemoveCommand extends SpoCommand {
42
43
  else if (args.options.upn) {
43
44
  principalId = await this.getUserPrincipalId(args.options, logger);
44
45
  }
46
+ else if (args.options.entraGroupId || args.options.entraGroupName) {
47
+ if (this.verbose) {
48
+ await logger.logToStderr('Retrieving group information...');
49
+ }
50
+ let group;
51
+ if (args.options.entraGroupId) {
52
+ group = await entraGroup.getGroupById(args.options.entraGroupId);
53
+ }
54
+ else {
55
+ group = await entraGroup.getGroupByDisplayName(args.options.entraGroupName);
56
+ }
57
+ const entraSiteUser = await spo.ensureEntraGroup(args.options.webUrl, group);
58
+ principalId = entraSiteUser.Id;
59
+ }
45
60
  else {
46
61
  principalId = args.options.principalId;
47
62
  }
@@ -93,6 +108,8 @@ _SpoFileRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFileRoleAssig
93
108
  principalId: typeof args.options.principalId !== 'undefined',
94
109
  upn: typeof args.options.upn !== 'undefined',
95
110
  groupName: typeof args.options.groupName !== 'undefined',
111
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
112
+ entraGroupName: typeof args.options.entraGroupName !== 'undefined',
96
113
  force: !!args.options.force
97
114
  });
98
115
  });
@@ -109,6 +126,10 @@ _SpoFileRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFileRoleAssig
109
126
  option: '--upn [upn]'
110
127
  }, {
111
128
  option: '--groupName [groupName]'
129
+ }, {
130
+ option: '--entraGroupId [entraGroupId]'
131
+ }, {
132
+ option: '--entraGroupName [entraGroupName]'
112
133
  }, {
113
134
  option: '-f, --force'
114
135
  });
@@ -121,15 +142,18 @@ _SpoFileRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFileRoleAssig
121
142
  if (args.options.principalId && isNaN(args.options.principalId)) {
122
143
  return `Specified principalId ${args.options.principalId} is not a number`;
123
144
  }
145
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
146
+ return `'${args.options.entraGroupId}' is not a valid GUID for option entraGroupId`;
147
+ }
124
148
  if (args.options.fileId && !validation.isValidGuid(args.options.fileId)) {
125
149
  return `${args.options.fileId} is not a valid GUID`;
126
150
  }
127
151
  return true;
128
152
  });
129
153
  }, _SpoFileRoleAssignmentRemoveCommand_initOptionSets = function _SpoFileRoleAssignmentRemoveCommand_initOptionSets() {
130
- this.optionSets.push({ options: ['fileUrl', 'fileId'] }, { options: ['upn', 'groupName', 'principalId'] });
154
+ this.optionSets.push({ options: ['fileUrl', 'fileId'] }, { options: ['upn', 'groupName', 'principalId', 'entraGroupId', 'entraGroupName'] });
131
155
  }, _SpoFileRoleAssignmentRemoveCommand_initTypes = function _SpoFileRoleAssignmentRemoveCommand_initTypes() {
132
- this.types.string.push('webUrl', 'fileUrl', 'fileId', 'upn', 'groupName');
156
+ this.types.string.push('webUrl', 'fileUrl', 'fileId', 'upn', 'groupName', 'entraGroupId', 'entraGroupName');
133
157
  this.types.boolean.push('force');
134
158
  };
135
159
  export default new SpoFileRoleAssignmentRemoveCommand();
@@ -14,6 +14,8 @@ import commands from '../../commands.js';
14
14
  import spoGroupGetCommand from '../group/group-get.js';
15
15
  import spoRoleDefinitionFolderCommand from '../roledefinition/roledefinition-list.js';
16
16
  import spoUserGetCommand from '../user/user-get.js';
17
+ import { entraGroup } from '../../../../utils/entraGroup.js';
18
+ import { spo } from '../../../../utils/spo.js';
17
19
  class SpoFolderRoleAssignmentAddCommand extends SpoCommand {
18
20
  get name() {
19
21
  return commands.FOLDER_ROLEASSIGNMENT_ADD;
@@ -45,37 +47,29 @@ class SpoFolderRoleAssignmentAddCommand extends SpoCommand {
45
47
  requestUrl += `GetFolderByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(serverRelativeUrl)}')/ListItemAllFields`;
46
48
  }
47
49
  const roleDefinitionId = await this.getRoleDefinitionId(args.options);
50
+ let principalId = args.options.principalId;
48
51
  if (args.options.upn) {
49
- const upnPrincipalId = await this.getUserPrincipalId(args.options);
50
- await this.breakRoleAssignment(requestUrl);
51
- await this.addRoleAssignment(requestUrl, upnPrincipalId, roleDefinitionId);
52
+ principalId = await this.getUserPrincipalId(args.options);
52
53
  }
53
54
  else if (args.options.groupName) {
54
- const groupPrincipalId = await this.getGroupPrincipalId(args.options);
55
- await this.breakRoleAssignment(requestUrl);
56
- await this.addRoleAssignment(requestUrl, groupPrincipalId, roleDefinitionId);
55
+ principalId = await this.getGroupPrincipalId(args.options);
57
56
  }
58
- else {
59
- await this.breakRoleAssignment(requestUrl);
60
- await this.addRoleAssignment(requestUrl, args.options.principalId, roleDefinitionId);
57
+ else if (args.options.entraGroupId || args.options.entraGroupName) {
58
+ if (this.verbose) {
59
+ await logger.logToStderr('Retrieving group information...');
60
+ }
61
+ const group = args.options.entraGroupId
62
+ ? await entraGroup.getGroupById(args.options.entraGroupId)
63
+ : await entraGroup.getGroupByDisplayName(args.options.entraGroupName);
64
+ const siteUser = await spo.ensureEntraGroup(args.options.webUrl, group);
65
+ principalId = siteUser.Id;
61
66
  }
67
+ await this.addRoleAssignment(requestUrl, principalId, roleDefinitionId);
62
68
  }
63
69
  catch (err) {
64
70
  this.handleRejectedODataJsonPromise(err);
65
71
  }
66
72
  }
67
- async breakRoleAssignment(requestUrl) {
68
- const requestOptions = {
69
- url: `${requestUrl}/breakroleinheritance(true)`,
70
- method: 'POST',
71
- headers: {
72
- 'accept': 'application/json;odata=nometadata',
73
- 'content-type': 'application/json'
74
- },
75
- responseType: 'json'
76
- };
77
- return request.post(requestOptions);
78
- }
79
73
  async addRoleAssignment(requestUrl, principalId, roleDefinitionId) {
80
74
  const requestOptions = {
81
75
  url: `${requestUrl}/roleassignments/addroleassignment(principalid='${principalId}',roledefid='${roleDefinitionId}')`,
@@ -140,6 +134,8 @@ _SpoFolderRoleAssignmentAddCommand_instances = new WeakSet(), _SpoFolderRoleAssi
140
134
  principalId: typeof args.options.principalId !== 'undefined',
141
135
  upn: typeof args.options.upn !== 'undefined',
142
136
  groupName: typeof args.options.groupName !== 'undefined',
137
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
138
+ entraGroupName: typeof args.options.entraGroupName !== 'undefined',
143
139
  roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
144
140
  roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined'
145
141
  });
@@ -155,6 +151,10 @@ _SpoFolderRoleAssignmentAddCommand_instances = new WeakSet(), _SpoFolderRoleAssi
155
151
  option: '--upn [upn]'
156
152
  }, {
157
153
  option: '--groupName [groupName]'
154
+ }, {
155
+ option: '--entraGroupId [entraGroupId]'
156
+ }, {
157
+ option: '--entraGroupName [entraGroupName]'
158
158
  }, {
159
159
  option: '--roleDefinitionId [roleDefinitionId]'
160
160
  }, {
@@ -169,15 +169,18 @@ _SpoFolderRoleAssignmentAddCommand_instances = new WeakSet(), _SpoFolderRoleAssi
169
169
  if (args.options.principalId && isNaN(args.options.principalId)) {
170
170
  return `Specified principalId ${args.options.principalId} is not a number`;
171
171
  }
172
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
173
+ return `'${args.options.entraGroupId}' is not a valid GUID for option entraGroupId.`;
174
+ }
172
175
  if (args.options.roleDefinitionId && isNaN(args.options.roleDefinitionId)) {
173
176
  return `Specified roleDefinitionId ${args.options.roleDefinitionId} is not a number`;
174
177
  }
175
- const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
178
+ const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName, args.options.entraGroupId, args.options.entraGroupName];
176
179
  if (!principalOptions.some(item => item !== undefined)) {
177
- return `Specify either principalId, upn or groupName`;
180
+ return `Specify either principalId, upn, groupName, entraGroupId or entraGroupName`;
178
181
  }
179
182
  if (principalOptions.filter(item => item !== undefined).length > 1) {
180
- return `Specify either principalId, upn or groupName but not multiple`;
183
+ return `Specify either principalId, upn, groupName, entraGroupId or entraGroupName but not multiple`;
181
184
  }
182
185
  const roleDefinitionOptions = [args.options.roleDefinitionId, args.options.roleDefinitionName];
183
186
  if (!roleDefinitionOptions.some(item => item !== undefined)) {
@@ -13,6 +13,8 @@ import SpoCommand from '../../../base/SpoCommand.js';
13
13
  import commands from '../../commands.js';
14
14
  import spoGroupGetCommand from '../group/group-get.js';
15
15
  import spoUserGetCommand from '../user/user-get.js';
16
+ import { entraGroup } from '../../../../utils/entraGroup.js';
17
+ import { spo } from '../../../../utils/spo.js';
16
18
  class SpoFolderRoleAssignmentRemoveCommand extends SpoCommand {
17
19
  get name() {
18
20
  return commands.FOLDER_ROLEASSIGNMENT_REMOVE;
@@ -38,15 +40,21 @@ class SpoFolderRoleAssignmentRemoveCommand extends SpoCommand {
38
40
  try {
39
41
  if (args.options.upn) {
40
42
  args.options.principalId = await this.getUserPrincipalId(args.options);
41
- await this.removeRoleAssignment(requestUrl, logger, args.options);
42
43
  }
43
44
  else if (args.options.groupName) {
44
45
  args.options.principalId = await this.getGroupPrincipalId(args.options);
45
- await this.removeRoleAssignment(requestUrl, logger, args.options);
46
46
  }
47
- else {
48
- await this.removeRoleAssignment(requestUrl, logger, args.options);
47
+ else if (args.options.entraGroupId || args.options.entraGroupName) {
48
+ if (this.verbose) {
49
+ await logger.logToStderr('Retrieving group information...');
50
+ }
51
+ const group = args.options.entraGroupId
52
+ ? await entraGroup.getGroupById(args.options.entraGroupId)
53
+ : await entraGroup.getGroupByDisplayName(args.options.entraGroupName);
54
+ const siteUser = await spo.ensureEntraGroup(args.options.webUrl, group);
55
+ args.options.principalId = siteUser.Id;
49
56
  }
57
+ await this.removeRoleAssignment(requestUrl, logger, args.options);
50
58
  }
51
59
  catch (err) {
52
60
  this.handleRejectedODataJsonPromise(err);
@@ -106,6 +114,8 @@ _SpoFolderRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFolderRoleA
106
114
  principalId: typeof args.options.principalId !== 'undefined',
107
115
  upn: typeof args.options.upn !== 'undefined',
108
116
  groupName: typeof args.options.groupName !== 'undefined',
117
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
118
+ entraGroupName: typeof args.options.entraGroupName !== 'undefined',
109
119
  force: !!args.options.force
110
120
  });
111
121
  });
@@ -120,6 +130,10 @@ _SpoFolderRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFolderRoleA
120
130
  option: '--upn [upn]'
121
131
  }, {
122
132
  option: '--groupName [groupName]'
133
+ }, {
134
+ option: '--entraGroupId [entraGroupId]'
135
+ }, {
136
+ option: '--entraGroupName [entraGroupName]'
123
137
  }, {
124
138
  option: '-f, --force'
125
139
  });
@@ -132,12 +146,15 @@ _SpoFolderRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFolderRoleA
132
146
  if (args.options.principalId && isNaN(args.options.principalId)) {
133
147
  return `Specified principalId ${args.options.principalId} is not a number`;
134
148
  }
135
- const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
149
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
150
+ return `'${args.options.entraGroupId}' is not a valid GUID for option entraGroupId.`;
151
+ }
152
+ const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName, args.options.entraGroupId, args.options.entraGroupName];
136
153
  if (principalOptions.some(item => item !== undefined) && principalOptions.filter(item => item !== undefined).length > 1) {
137
- return `Specify either principalId id, upn or groupName`;
154
+ return `Specify either principalId id, upn, groupName, entraGroupId or entraGroupName`;
138
155
  }
139
156
  if (principalOptions.filter(item => item !== undefined).length === 0) {
140
- return `Specify at least principalId id, upn or groupName`;
157
+ return `Specify at least principalId id, upn, groupName, entraGroupId or entraGroupName`;
141
158
  }
142
159
  return true;
143
160
  });
@@ -0,0 +1,140 @@
1
+ import SpoCommand from '../../../base/SpoCommand.js';
2
+ import { globalOptionsZod } from '../../../../Command.js';
3
+ import { z } from 'zod';
4
+ import { zod } from '../../../../utils/zod.js';
5
+ import commands from '../../commands.js';
6
+ import { DOMParser } from '@xmldom/xmldom';
7
+ import { validation } from '../../../../utils/validation.js';
8
+ import { urlUtil } from '../../../../utils/urlUtil.js';
9
+ import request from '../../../../request.js';
10
+ import { formatting } from '../../../../utils/formatting.js';
11
+ const options = globalOptionsZod
12
+ .extend({
13
+ webUrl: zod.alias('u', z.string()
14
+ .refine(url => validation.isValidSharePointUrl(url) === true, url => ({
15
+ message: `'${url}' is not a valid SharePoint Online site URL.`
16
+ }))),
17
+ listId: zod.alias('i', z.string().optional()
18
+ .refine(id => id === undefined || validation.isValidGuid(id), id => ({
19
+ message: `'${id}' is not a valid GUID.`
20
+ }))),
21
+ listTitle: zod.alias('t', z.string().optional()),
22
+ listUrl: z.string().optional(),
23
+ folderUrl: z.string().optional()
24
+ })
25
+ .strict();
26
+ class SpoListDefaultValueListCommand extends SpoCommand {
27
+ get name() {
28
+ return commands.LIST_DEFAULTVALUE_LIST;
29
+ }
30
+ get description() {
31
+ return 'Retrieves default column values for a specific document library';
32
+ }
33
+ get schema() {
34
+ return options;
35
+ }
36
+ getRefinedSchema(schema) {
37
+ return schema
38
+ .refine(options => [options.listId, options.listTitle, options.listUrl].filter(o => o !== undefined).length === 1, {
39
+ message: 'Use one of the following options: listId, listTitle, listUrl.'
40
+ });
41
+ }
42
+ async commandAction(logger, args) {
43
+ try {
44
+ if (this.verbose) {
45
+ await logger.logToStderr(`Retrieving default column values for list '${args.options.listId || args.options.listTitle || args.options.listUrl}'...`);
46
+ await logger.logToStderr('Retrieving list information...');
47
+ }
48
+ const listServerRelUrl = await this.getServerRelativeListUrl(args.options);
49
+ if (this.verbose) {
50
+ await logger.logToStderr('Retrieving default column values...');
51
+ }
52
+ let defaultValues;
53
+ try {
54
+ const defaultValuesXml = await this.getDefaultColumnValuesXml(args.options.webUrl, listServerRelUrl);
55
+ defaultValues = this.convertXmlToJson(defaultValuesXml);
56
+ }
57
+ catch (err) {
58
+ if (err.status !== 404) {
59
+ throw err;
60
+ }
61
+ // For lists that have never had default column values set, the client_LocationBasedDefaults.html file does not exist.
62
+ defaultValues = [];
63
+ }
64
+ if (args.options.folderUrl) {
65
+ const serverRelFolderUrl = urlUtil.removeTrailingSlashes(urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl));
66
+ defaultValues = defaultValues.filter(d => d.folderUrl.toLowerCase() === serverRelFolderUrl.toLowerCase());
67
+ }
68
+ await logger.log(defaultValues);
69
+ }
70
+ catch (err) {
71
+ this.handleRejectedODataJsonPromise(err);
72
+ }
73
+ }
74
+ async getServerRelativeListUrl(options) {
75
+ const requestOptions = {
76
+ url: `${options.webUrl}/_api/Web`,
77
+ headers: {
78
+ accept: 'application/json;odata=nometadata'
79
+ },
80
+ responseType: 'json'
81
+ };
82
+ if (options.listUrl) {
83
+ const serverRelativeUrl = urlUtil.getServerRelativePath(options.webUrl, options.listUrl);
84
+ requestOptions.url += `/GetList('${serverRelativeUrl}')`;
85
+ }
86
+ else if (options.listId) {
87
+ requestOptions.url += `/Lists('${options.listId}')`;
88
+ }
89
+ else if (options.listTitle) {
90
+ requestOptions.url += `/Lists/GetByTitle('${formatting.encodeQueryParameter(options.listTitle)}')`;
91
+ }
92
+ requestOptions.url += '?$expand=RootFolder&$select=RootFolder/ServerRelativeUrl,BaseTemplate';
93
+ try {
94
+ const response = await request.get(requestOptions);
95
+ if (response.BaseTemplate !== 101) {
96
+ throw `List '${options.listId || options.listTitle || options.listUrl}' is not a document library.`;
97
+ }
98
+ return response.RootFolder.ServerRelativeUrl;
99
+ }
100
+ catch (error) {
101
+ if (error.status === 404) {
102
+ throw `List '${options.listId || options.listTitle || options.listUrl}' was not found.`;
103
+ }
104
+ throw error;
105
+ }
106
+ }
107
+ async getDefaultColumnValuesXml(webUrl, listServerRelUrl) {
108
+ const requestOptions = {
109
+ url: `${webUrl}/_api/Web/GetFileByServerRelativePath(decodedUrl='${formatting.encodeQueryParameter(listServerRelUrl + '/Forms/client_LocationBasedDefaults.html')}')/$value`,
110
+ headers: {
111
+ accept: 'application/json;odata=nometadata'
112
+ },
113
+ responseType: 'json'
114
+ };
115
+ const defaultValuesXml = await request.get(requestOptions);
116
+ return defaultValuesXml;
117
+ }
118
+ convertXmlToJson(xml) {
119
+ const results = [];
120
+ const parser = new DOMParser();
121
+ const doc = parser.parseFromString(xml, 'application/xml');
122
+ const folderLinks = doc.getElementsByTagName('a');
123
+ for (let i = 0; i < folderLinks.length; i++) {
124
+ const folderUrl = folderLinks[i].getAttribute('href');
125
+ const defaultValues = folderLinks[i].getElementsByTagName('DefaultValue');
126
+ for (let j = 0; j < defaultValues.length; j++) {
127
+ const fieldName = defaultValues[j].getAttribute('FieldName');
128
+ const fieldValue = defaultValues[j].textContent;
129
+ results.push({
130
+ fieldName: fieldName,
131
+ fieldValue: fieldValue,
132
+ folderUrl: decodeURIComponent(folderUrl)
133
+ });
134
+ }
135
+ }
136
+ return results;
137
+ }
138
+ }
139
+ export default new SpoListDefaultValueListCommand();
140
+ //# sourceMappingURL=list-defaultvalue-list.js.map
@@ -6,6 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  var _SpoListItemRoleAssignmentAddCommand_instances, _SpoListItemRoleAssignmentAddCommand_initTelemetry, _SpoListItemRoleAssignmentAddCommand_initOptions, _SpoListItemRoleAssignmentAddCommand_initValidators;
7
7
  import { cli } from '../../../../cli/cli.js';
8
8
  import request from '../../../../request.js';
9
+ import { entraGroup } from '../../../../utils/entraGroup.js';
9
10
  import { formatting } from '../../../../utils/formatting.js';
10
11
  import { urlUtil } from '../../../../utils/urlUtil.js';
11
12
  import { validation } from '../../../../utils/validation.js';
@@ -14,6 +15,7 @@ import commands from '../../commands.js';
14
15
  import spoGroupGetCommand from '../group/group-get.js';
15
16
  import spoRoleDefinitionListCommand from '../roledefinition/roledefinition-list.js';
16
17
  import spoUserGetCommand from '../user/user-get.js';
18
+ import { spo } from '../../../../utils/spo.js';
17
19
  class SpoListItemRoleAssignmentAddCommand extends SpoCommand {
18
20
  get name() {
19
21
  return commands.LISTITEM_ROLEASSIGNMENT_ADD;
@@ -46,7 +48,7 @@ class SpoListItemRoleAssignmentAddCommand extends SpoCommand {
46
48
  }
47
49
  requestUrl += `items(${args.options.listItemId})/`;
48
50
  const roleDefinitionId = await this.getRoleDefinitionId(args.options);
49
- let principalId = 0;
51
+ let principalId = args.options.principalId;
50
52
  if (args.options.upn) {
51
53
  principalId = await this.getUserPrincipalId(args.options);
52
54
  await this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
@@ -55,10 +57,17 @@ class SpoListItemRoleAssignmentAddCommand extends SpoCommand {
55
57
  principalId = await this.getGroupPrincipalId(args.options);
56
58
  await this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
57
59
  }
58
- else {
59
- principalId = args.options.principalId;
60
- await this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
60
+ else if (args.options.entraGroupId || args.options.entraGroupName) {
61
+ if (this.verbose) {
62
+ await logger.logToStderr('Retrieving group information...');
63
+ }
64
+ const group = args.options.entraGroupId
65
+ ? await entraGroup.getGroupById(args.options.entraGroupId)
66
+ : await entraGroup.getGroupByDisplayName(args.options.entraGroupName);
67
+ const siteUser = await spo.ensureEntraGroup(args.options.webUrl, group);
68
+ principalId = siteUser.Id;
61
69
  }
70
+ await this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
62
71
  }
63
72
  catch (err) {
64
73
  this.handleRejectedODataJsonPromise(err);
@@ -126,6 +135,8 @@ _SpoListItemRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListItemRole
126
135
  principalId: typeof args.options.principalId !== 'undefined',
127
136
  upn: typeof args.options.upn !== 'undefined',
128
137
  groupName: typeof args.options.groupName !== 'undefined',
138
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
139
+ entraGroupName: typeof args.options.entraGroupName !== 'undefined',
129
140
  roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
130
141
  roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined'
131
142
  });
@@ -147,6 +158,10 @@ _SpoListItemRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListItemRole
147
158
  option: '--upn [upn]'
148
159
  }, {
149
160
  option: '--groupName [groupName]'
161
+ }, {
162
+ option: '--entraGroupId [entraGroupId]'
163
+ }, {
164
+ option: '--entraGroupName [entraGroupName]'
150
165
  }, {
151
166
  option: '--roleDefinitionId [roleDefinitionId]'
152
167
  }, {
@@ -177,12 +192,15 @@ _SpoListItemRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListItemRole
177
192
  if (listOptions.filter(item => item !== undefined).length === 0) {
178
193
  return `Specify at least list id or title or list url`;
179
194
  }
180
- const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
195
+ const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName, args.options.entraGroupId, args.options.entraGroupName];
181
196
  if (!principalOptions.some(item => item !== undefined)) {
182
- return `Specify either principalId, upn or groupName`;
197
+ return `Specify either principalId, upn, groupName, entraGroupId or entraGroupName`;
183
198
  }
184
199
  if (principalOptions.filter(item => item !== undefined).length > 1) {
185
- return `Specify either principalId, upn or groupName but not multiple`;
200
+ return `Specify either principalId, upn, groupName, entraGroupId or entraGroupName but not multiple`;
201
+ }
202
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
203
+ return `'${args.options.entraGroupId}' is not a valid GUID for option entraGroupId.`;
186
204
  }
187
205
  const roleDefinitionOptions = [args.options.roleDefinitionId, args.options.roleDefinitionName];
188
206
  if (!roleDefinitionOptions.some(item => item !== undefined)) {
@@ -13,6 +13,8 @@ import SpoCommand from '../../../base/SpoCommand.js';
13
13
  import commands from '../../commands.js';
14
14
  import spoGroupGetCommand from '../group/group-get.js';
15
15
  import spoUserGetCommand from '../user/user-get.js';
16
+ import { entraGroup } from '../../../../utils/entraGroup.js';
17
+ import { spo } from '../../../../utils/spo.js';
16
18
  class SpoListItemRoleAssignmentRemoveCommand extends SpoCommand {
17
19
  get name() {
18
20
  return commands.LISTITEM_ROLEASSIGNMENT_REMOVE;
@@ -58,15 +60,21 @@ class SpoListItemRoleAssignmentRemoveCommand extends SpoCommand {
58
60
  requestUrl += `items(${options.listItemId})/`;
59
61
  if (options.upn) {
60
62
  options.principalId = await this.getUserPrincipalId(options);
61
- await this.removeRoleAssignmentWithRequestUrl(requestUrl, logger, options);
62
63
  }
63
64
  else if (options.groupName) {
64
65
  options.principalId = await this.getGroupPrincipalId(options);
65
- await this.removeRoleAssignmentWithRequestUrl(requestUrl, logger, options);
66
66
  }
67
- else {
68
- await this.removeRoleAssignmentWithRequestUrl(requestUrl, logger, options);
67
+ else if (options.entraGroupId || options.entraGroupName) {
68
+ if (this.verbose) {
69
+ await logger.logToStderr('Retrieving group information...');
70
+ }
71
+ const group = options.entraGroupId
72
+ ? await entraGroup.getGroupById(options.entraGroupId)
73
+ : await entraGroup.getGroupByDisplayName(options.entraGroupName);
74
+ const siteUser = await spo.ensureEntraGroup(options.webUrl, group);
75
+ options.principalId = siteUser.Id;
69
76
  }
77
+ await this.removeRoleAssignmentWithRequestUrl(requestUrl, logger, options);
70
78
  }
71
79
  catch (err) {
72
80
  this.handleRejectedODataJsonPromise(err);
@@ -119,6 +127,8 @@ _SpoListItemRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListItemR
119
127
  principalId: typeof args.options.principalId !== 'undefined',
120
128
  upn: typeof args.options.upn !== 'undefined',
121
129
  groupName: typeof args.options.groupName !== 'undefined',
130
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
131
+ entraGroupName: typeof args.options.entraGroupName !== 'undefined',
122
132
  force: (!(!args.options.force)).toString()
123
133
  });
124
134
  });
@@ -139,6 +149,10 @@ _SpoListItemRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListItemR
139
149
  option: '--upn [upn]'
140
150
  }, {
141
151
  option: '--groupName [groupName]'
152
+ }, {
153
+ option: '--entraGroupId [entraGroupId]'
154
+ }, {
155
+ option: '--entraGroupName [entraGroupName]'
142
156
  }, {
143
157
  option: '-f, --force'
144
158
  });
@@ -157,10 +171,13 @@ _SpoListItemRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListItemR
157
171
  if (args.options.principalId && isNaN(args.options.principalId)) {
158
172
  return `Specified principalId ${args.options.principalId} is not a number`;
159
173
  }
174
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
175
+ return `'${args.options.entraGroupId}' is not a valid GUID for option entraGroupId.`;
176
+ }
160
177
  return true;
161
178
  });
162
179
  }, _SpoListItemRoleAssignmentRemoveCommand_initOptionSets = function _SpoListItemRoleAssignmentRemoveCommand_initOptionSets() {
163
- this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] }, { options: ['principalId', 'upn', 'groupName'] });
180
+ this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] }, { options: ['principalId', 'upn', 'groupName', 'entraGroupId', 'entraGroupName'] });
164
181
  };
165
182
  export default new SpoListItemRoleAssignmentRemoveCommand();
166
183
  //# sourceMappingURL=listitem-roleassignment-remove.js.map
@@ -12,6 +12,8 @@ import commands from '../../commands.js';
12
12
  import spoGroupGetCommand from '../group/group-get.js';
13
13
  import spoRoleDefinitionListCommand from '../roledefinition/roledefinition-list.js';
14
14
  import spoUserGetCommand from '../user/user-get.js';
15
+ import { entraGroup } from '../../../../utils/entraGroup.js';
16
+ import { spo } from '../../../../utils/spo.js';
15
17
  class SpoWebRoleAssignmentAddCommand extends SpoCommand {
16
18
  get name() {
17
19
  return commands.WEB_ROLEASSIGNMENT_ADD;
@@ -35,15 +37,21 @@ class SpoWebRoleAssignmentAddCommand extends SpoCommand {
35
37
  args.options.roleDefinitionId = await this.getRoleDefinitionId(args.options);
36
38
  if (args.options.upn) {
37
39
  args.options.principalId = await this.getUserPrincipalId(args.options);
38
- await this.addRoleAssignment(logger, args.options);
39
40
  }
40
41
  else if (args.options.groupName) {
41
42
  args.options.principalId = await this.getGroupPrincipalId(args.options);
42
- await this.addRoleAssignment(logger, args.options);
43
43
  }
44
- else {
45
- await this.addRoleAssignment(logger, args.options);
44
+ else if (args.options.entraGroupId || args.options.entraGroupName) {
45
+ if (this.verbose) {
46
+ await logger.logToStderr('Retrieving group information...');
47
+ }
48
+ const group = args.options.entraGroupId
49
+ ? await entraGroup.getGroupById(args.options.entraGroupId)
50
+ : await entraGroup.getGroupByDisplayName(args.options.entraGroupName);
51
+ const siteUser = await spo.ensureEntraGroup(args.options.webUrl, group);
52
+ args.options.principalId = siteUser.Id;
46
53
  }
54
+ await this.addRoleAssignment(logger, args.options);
47
55
  }
48
56
  catch (err) {
49
57
  this.handleRejectedODataJsonPromise(err);
@@ -108,6 +116,8 @@ _SpoWebRoleAssignmentAddCommand_instances = new WeakSet(), _SpoWebRoleAssignment
108
116
  principalId: typeof args.options.principalId !== 'undefined',
109
117
  upn: typeof args.options.upn !== 'undefined',
110
118
  groupName: typeof args.options.groupName !== 'undefined',
119
+ entraGroupId: typeof args.options.entraGroupId !== 'undefined',
120
+ entraGroupName: typeof args.options.entraGroupName !== 'undefined',
111
121
  roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
112
122
  roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined'
113
123
  });
@@ -121,6 +131,10 @@ _SpoWebRoleAssignmentAddCommand_instances = new WeakSet(), _SpoWebRoleAssignment
121
131
  option: '--upn [upn]'
122
132
  }, {
123
133
  option: '--groupName [groupName]'
134
+ }, {
135
+ option: '--entraGroupId [entraGroupId]'
136
+ }, {
137
+ option: '--entraGroupName [entraGroupName]'
124
138
  }, {
125
139
  option: '--roleDefinitionId [roleDefinitionId]'
126
140
  }, {
@@ -138,10 +152,13 @@ _SpoWebRoleAssignmentAddCommand_instances = new WeakSet(), _SpoWebRoleAssignment
138
152
  if (args.options.roleDefinitionId && isNaN(args.options.roleDefinitionId)) {
139
153
  return `Specified roleDefinitionId ${args.options.roleDefinitionId} is not a number`;
140
154
  }
155
+ if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
156
+ return `'${args.options.entraGroupId}' is not a valid GUID for option entraGroupId.`;
157
+ }
141
158
  return true;
142
159
  });
143
160
  }, _SpoWebRoleAssignmentAddCommand_initOptionSets = function _SpoWebRoleAssignmentAddCommand_initOptionSets() {
144
- this.optionSets.push({ options: ['principalId', 'upn', 'groupName'] }, { options: ['roleDefinitionId', 'roleDefinitionName'] });
161
+ this.optionSets.push({ options: ['principalId', 'upn', 'groupName', 'entraGroupId', 'entraGroupName'] }, { options: ['roleDefinitionId', 'roleDefinitionName'] });
145
162
  };
146
163
  export default new SpoWebRoleAssignmentAddCommand();
147
164
  //# sourceMappingURL=web-roleassignment-add.js.map