@pnp/cli-microsoft365 10.6.0-beta.3f44c00 → 10.6.0-beta.3facb8f

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.
@@ -4,7 +4,6 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
6
  var _SpoListItemRoleAssignmentAddCommand_instances, _SpoListItemRoleAssignmentAddCommand_initTelemetry, _SpoListItemRoleAssignmentAddCommand_initOptions, _SpoListItemRoleAssignmentAddCommand_initValidators;
7
- import { cli } from '../../../../cli/cli.js';
8
7
  import request from '../../../../request.js';
9
8
  import { entraGroup } from '../../../../utils/entraGroup.js';
10
9
  import { formatting } from '../../../../utils/formatting.js';
@@ -12,9 +11,6 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
12
11
  import { validation } from '../../../../utils/validation.js';
13
12
  import SpoCommand from '../../../base/SpoCommand.js';
14
13
  import commands from '../../commands.js';
15
- import spoGroupGetCommand from '../group/group-get.js';
16
- import spoRoleDefinitionListCommand from '../roledefinition/roledefinition-list.js';
17
- import spoUserGetCommand from '../user/user-get.js';
18
14
  import { spo } from '../../../../utils/spo.js';
19
15
  class SpoListItemRoleAssignmentAddCommand extends SpoCommand {
20
16
  get name() {
@@ -47,15 +43,13 @@ class SpoListItemRoleAssignmentAddCommand extends SpoCommand {
47
43
  requestUrl += `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
48
44
  }
49
45
  requestUrl += `items(${args.options.listItemId})/`;
50
- const roleDefinitionId = await this.getRoleDefinitionId(args.options);
46
+ const roleDefinitionId = await this.getRoleDefinitionId(args.options, logger);
51
47
  let principalId = args.options.principalId;
52
48
  if (args.options.upn) {
53
- principalId = await this.getUserPrincipalId(args.options);
54
- await this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
49
+ principalId = await this.getUserPrincipalId(args.options, logger);
55
50
  }
56
51
  else if (args.options.groupName) {
57
- principalId = await this.getGroupPrincipalId(args.options);
58
- await this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
52
+ principalId = await this.getGroupPrincipalId(args.options, logger);
59
53
  }
60
54
  else if (args.options.entraGroupId || args.options.entraGroupName) {
61
55
  if (this.verbose) {
@@ -85,45 +79,20 @@ class SpoListItemRoleAssignmentAddCommand extends SpoCommand {
85
79
  };
86
80
  await request.post(requestOptions);
87
81
  }
88
- async getRoleDefinitionId(options) {
82
+ async getRoleDefinitionId(options, logger) {
89
83
  if (!options.roleDefinitionName) {
90
84
  return options.roleDefinitionId;
91
85
  }
92
- const roleDefinitionListCommandOptions = {
93
- webUrl: options.webUrl,
94
- output: 'json',
95
- debug: this.debug,
96
- verbose: this.verbose
97
- };
98
- const output = await cli.executeCommandWithOutput(spoRoleDefinitionListCommand, { options: { ...roleDefinitionListCommandOptions, _: [] } });
99
- const getRoleDefinitionListOutput = JSON.parse(output.stdout);
100
- const roleDefinitionId = getRoleDefinitionListOutput.find((role) => role.Name === options.roleDefinitionName).Id;
101
- return roleDefinitionId;
86
+ const roleDefintion = await spo.getRoleDefinitionByName(options.webUrl, options.roleDefinitionName, logger, this.verbose);
87
+ return roleDefintion.Id;
102
88
  }
103
- async getGroupPrincipalId(options) {
104
- const groupGetCommandOptions = {
105
- webUrl: options.webUrl,
106
- name: options.groupName,
107
- output: 'json',
108
- debug: this.debug,
109
- verbose: this.verbose
110
- };
111
- const output = await cli.executeCommandWithOutput(spoGroupGetCommand, { options: { ...groupGetCommandOptions, _: [] } });
112
- const getGroupOutput = JSON.parse(output.stdout);
113
- return getGroupOutput.Id;
89
+ async getGroupPrincipalId(options, logger) {
90
+ const group = await spo.getGroupByName(options.webUrl, options.groupName, logger, this.verbose);
91
+ return group.Id;
114
92
  }
115
- async getUserPrincipalId(options) {
116
- const userGetCommandOptions = {
117
- webUrl: options.webUrl,
118
- email: options.upn,
119
- id: undefined,
120
- output: 'json',
121
- debug: this.debug,
122
- verbose: this.verbose
123
- };
124
- const output = await cli.executeCommandWithOutput(spoUserGetCommand, { options: { ...userGetCommandOptions, _: [] } });
125
- const getUserOutput = JSON.parse(output.stdout);
126
- return getUserOutput.Id;
93
+ async getUserPrincipalId(options, logger) {
94
+ const user = await spo.getUserByEmail(options.webUrl, options.upn, logger, this.verbose);
95
+ return user.Id;
127
96
  }
128
97
  }
129
98
  _SpoListItemRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListItemRoleAssignmentAddCommand_initTelemetry = function _SpoListItemRoleAssignmentAddCommand_initTelemetry() {
@@ -11,8 +11,6 @@ import { urlUtil } from '../../../../utils/urlUtil.js';
11
11
  import { validation } from '../../../../utils/validation.js';
12
12
  import SpoCommand from '../../../base/SpoCommand.js';
13
13
  import commands from '../../commands.js';
14
- import spoGroupGetCommand from '../group/group-get.js';
15
- import spoUserGetCommand from '../user/user-get.js';
16
14
  import { entraGroup } from '../../../../utils/entraGroup.js';
17
15
  import { spo } from '../../../../utils/spo.js';
18
16
  class SpoListItemRoleAssignmentRemoveCommand extends SpoCommand {
@@ -59,10 +57,10 @@ class SpoListItemRoleAssignmentRemoveCommand extends SpoCommand {
59
57
  }
60
58
  requestUrl += `items(${options.listItemId})/`;
61
59
  if (options.upn) {
62
- options.principalId = await this.getUserPrincipalId(options);
60
+ options.principalId = await this.getUserPrincipalId(options, logger);
63
61
  }
64
62
  else if (options.groupName) {
65
- options.principalId = await this.getGroupPrincipalId(options);
63
+ options.principalId = await this.getGroupPrincipalId(options, logger);
66
64
  }
67
65
  else if (options.entraGroupId || options.entraGroupName) {
68
66
  if (this.verbose) {
@@ -92,30 +90,13 @@ class SpoListItemRoleAssignmentRemoveCommand extends SpoCommand {
92
90
  };
93
91
  await request.post(requestOptions);
94
92
  }
95
- async getGroupPrincipalId(options) {
96
- const groupGetCommandOptions = {
97
- webUrl: options.webUrl,
98
- name: options.groupName,
99
- output: 'json',
100
- debug: this.debug,
101
- verbose: this.verbose
102
- };
103
- const output = await cli.executeCommandWithOutput(spoGroupGetCommand, { options: { ...groupGetCommandOptions, _: [] } });
104
- const getGroupOutput = JSON.parse(output.stdout);
105
- return getGroupOutput.Id;
93
+ async getGroupPrincipalId(options, logger) {
94
+ const group = await spo.getGroupByName(options.webUrl, options.groupName, logger, this.verbose);
95
+ return group.Id;
106
96
  }
107
- async getUserPrincipalId(options) {
108
- const userGetCommandOptions = {
109
- webUrl: options.webUrl,
110
- email: options.upn,
111
- id: undefined,
112
- output: 'json',
113
- debug: this.debug,
114
- verbose: this.verbose
115
- };
116
- const output = await cli.executeCommandWithOutput(spoUserGetCommand, { options: { ...userGetCommandOptions, _: [] } });
117
- const getUserOutput = JSON.parse(output.stdout);
118
- return getUserOutput.Id;
97
+ async getUserPrincipalId(options, logger) {
98
+ const user = await spo.getUserByEmail(options.webUrl, options.upn, logger, this.verbose);
99
+ return user.Id;
119
100
  }
120
101
  }
121
102
  _SpoListItemRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoListItemRoleAssignmentRemoveCommand_initTelemetry = function _SpoListItemRoleAssignmentRemoveCommand_initTelemetry() {
package/dist/utils/spo.js CHANGED
@@ -618,10 +618,12 @@ export const spo = {
618
618
  /**
619
619
  * Retrieves the role definition by name.
620
620
  * Returns a RoleDefinition object
621
+ * Returns a RoleDefinition object
621
622
  * @param webUrl Web url
622
623
  * @param name the name of the role definition
623
624
  * @param logger the Logger object
624
625
  * @param verbose Set for verbose logging
626
+ * @param verbose Set for verbose logging
625
627
  */
626
628
  async getRoleDefinitionByName(webUrl, name, logger, verbose) {
627
629
  if (verbose && logger) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "10.6.0-beta.3f44c00",
3
+ "version": "10.6.0-beta.3facb8f",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",