@pnp/cli-microsoft365 10.6.0-beta.55e3c97 → 10.6.0-beta.add4854
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.
- package/allCommands.json +1 -1
- package/allCommandsFull.json +1 -1
- package/dist/m365/pp/commands/card/card-clone.js +6 -16
- package/dist/m365/pp/commands/card/card-get.js +10 -19
- package/dist/m365/pp/commands/card/card-remove.js +7 -16
- package/dist/m365/spo/commands/folder/folder-roleassignment-add.js +12 -47
- package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +13 -31
- package/dist/m365/spo/commands/listitem/listitem-roleassignment-add.js +12 -43
- package/dist/m365/spo/commands/listitem/listitem-roleassignment-remove.js +8 -27
- package/dist/m365/spo/commands/web/web-roleassignment-add.js +22 -47
- package/dist/m365/spo/commands/web/web-roleassignment-remove.js +17 -32
- package/dist/utils/powerPlatform.js +30 -1
- package/dist/utils/spo.js +32 -3
- package/package.json +1 -1
|
@@ -4,15 +4,13 @@ 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 _SpoWebRoleAssignmentRemoveCommand_instances, _SpoWebRoleAssignmentRemoveCommand_initTelemetry, _SpoWebRoleAssignmentRemoveCommand_initOptions, _SpoWebRoleAssignmentRemoveCommand_initValidators, _SpoWebRoleAssignmentRemoveCommand_initOptionSets;
|
|
7
|
-
import { cli } from '../../../../cli/cli.js';
|
|
8
7
|
import request from '../../../../request.js';
|
|
9
8
|
import { validation } from '../../../../utils/validation.js';
|
|
10
9
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
11
10
|
import commands from '../../commands.js';
|
|
12
|
-
import spoGroupGetCommand from '../group/group-get.js';
|
|
13
|
-
import spoUserGetCommand from '../user/user-get.js';
|
|
14
11
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
15
12
|
import { spo } from '../../../../utils/spo.js';
|
|
13
|
+
import { cli } from '../../../../cli/cli.js';
|
|
16
14
|
class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
17
15
|
get name() {
|
|
18
16
|
return commands.WEB_ROLEASSIGNMENT_REMOVE;
|
|
@@ -45,10 +43,12 @@ class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
45
43
|
}
|
|
46
44
|
try {
|
|
47
45
|
if (options.upn) {
|
|
48
|
-
|
|
46
|
+
const principalId = await this.getUserPrincipalId(options, logger);
|
|
47
|
+
await this.removeRoleAssignmentWithOptions(options.webUrl, principalId, logger);
|
|
49
48
|
}
|
|
50
49
|
else if (options.groupName) {
|
|
51
|
-
|
|
50
|
+
const principalId = await this.getGroupPrincipalId(options, logger);
|
|
51
|
+
await this.removeRoleAssignmentWithOptions(options.webUrl, principalId, logger);
|
|
52
52
|
}
|
|
53
53
|
else if (options.entraGroupId || options.entraGroupName) {
|
|
54
54
|
if (this.verbose) {
|
|
@@ -58,17 +58,19 @@ class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
58
58
|
? await entraGroup.getGroupById(options.entraGroupId)
|
|
59
59
|
: await entraGroup.getGroupByDisplayName(options.entraGroupName);
|
|
60
60
|
const siteUser = await spo.ensureEntraGroup(options.webUrl, group);
|
|
61
|
-
options.
|
|
61
|
+
await this.removeRoleAssignmentWithOptions(options.webUrl, siteUser.Id, logger);
|
|
62
62
|
}
|
|
63
|
-
await this.removeRoleAssignmentWithOptions(logger, options);
|
|
64
63
|
}
|
|
65
64
|
catch (err) {
|
|
66
65
|
this.handleRejectedODataJsonPromise(err);
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
async removeRoleAssignmentWithOptions(
|
|
68
|
+
async removeRoleAssignmentWithOptions(webUrl, principalId, logger) {
|
|
69
|
+
if (this.verbose) {
|
|
70
|
+
await logger.logToStderr('Removing role assignment...');
|
|
71
|
+
}
|
|
70
72
|
const requestOptions = {
|
|
71
|
-
url: `${
|
|
73
|
+
url: `${webUrl}/_api/web/roleassignments/removeroleassignment(principalid='${principalId}')`,
|
|
72
74
|
method: 'POST',
|
|
73
75
|
headers: {
|
|
74
76
|
'accept': 'application/json;odata=nometadata',
|
|
@@ -78,30 +80,13 @@ class SpoWebRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
78
80
|
};
|
|
79
81
|
await request.post(requestOptions);
|
|
80
82
|
}
|
|
81
|
-
async getGroupPrincipalId(options) {
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
name: options.groupName,
|
|
85
|
-
output: 'json',
|
|
86
|
-
debug: this.debug,
|
|
87
|
-
verbose: this.verbose
|
|
88
|
-
};
|
|
89
|
-
const output = await cli.executeCommandWithOutput(spoGroupGetCommand, { options: { ...groupGetCommandOptions, _: [] } });
|
|
90
|
-
const getGroupOutput = JSON.parse(output.stdout);
|
|
91
|
-
return getGroupOutput.Id;
|
|
83
|
+
async getGroupPrincipalId(options, logger) {
|
|
84
|
+
const group = await spo.getGroupByName(options.webUrl, options.groupName, logger, this.verbose);
|
|
85
|
+
return group.Id;
|
|
92
86
|
}
|
|
93
|
-
async getUserPrincipalId(options) {
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
email: options.upn,
|
|
97
|
-
id: undefined,
|
|
98
|
-
output: 'json',
|
|
99
|
-
debug: this.debug,
|
|
100
|
-
verbose: this.verbose
|
|
101
|
-
};
|
|
102
|
-
const output = await cli.executeCommandWithOutput(spoUserGetCommand, { options: { ...userGetCommandOptions, _: [] } });
|
|
103
|
-
const getUserOutput = JSON.parse(output.stdout);
|
|
104
|
-
return getUserOutput.Id;
|
|
87
|
+
async getUserPrincipalId(options, logger) {
|
|
88
|
+
const user = await spo.getUserByEmail(options.webUrl, options.upn, logger, this.verbose);
|
|
89
|
+
return user.Id;
|
|
105
90
|
}
|
|
106
91
|
}
|
|
107
92
|
_SpoWebRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoWebRoleAssignmentRemoveCommand_initTelemetry = function _SpoWebRoleAssignmentRemoveCommand_initTelemetry() {
|
|
@@ -51,7 +51,7 @@ export const powerPlatform = {
|
|
|
51
51
|
}
|
|
52
52
|
if (items.length > 1) {
|
|
53
53
|
const resultAsKeyValuePair = formatting.convertArrayToHashTable('websiteUrl', items);
|
|
54
|
-
return cli.handleMultipleResultsFound(`Multiple Power Page websites with name '${websiteName}' found
|
|
54
|
+
return cli.handleMultipleResultsFound(`Multiple Power Page websites with name '${websiteName}' found.`, resultAsKeyValuePair);
|
|
55
55
|
}
|
|
56
56
|
return items[0];
|
|
57
57
|
},
|
|
@@ -62,6 +62,35 @@ export const powerPlatform = {
|
|
|
62
62
|
throw Error(`The specified Power Page website with url '${url}' does not exist.`);
|
|
63
63
|
}
|
|
64
64
|
return items[0];
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Get a card by name
|
|
68
|
+
* Returns a card object
|
|
69
|
+
* @param dynamicsApiUrl The dynamics api url of the environment
|
|
70
|
+
* @param name The name of the card
|
|
71
|
+
* @param logger The logger object
|
|
72
|
+
* @param verbose Set for verbose logging
|
|
73
|
+
*/
|
|
74
|
+
async getCardByName(dynamicsApiUrl, name, logger, verbose) {
|
|
75
|
+
if (verbose && logger) {
|
|
76
|
+
await logger.logToStderr(`Retrieving the card with name ${name}`);
|
|
77
|
+
}
|
|
78
|
+
const requestOptions = {
|
|
79
|
+
url: `${dynamicsApiUrl}/api/data/v9.1/cards?$filter=name eq '${name}'`,
|
|
80
|
+
headers: {
|
|
81
|
+
accept: 'application/json;odata.metadata=none'
|
|
82
|
+
},
|
|
83
|
+
responseType: 'json'
|
|
84
|
+
};
|
|
85
|
+
const result = await request.get(requestOptions);
|
|
86
|
+
if (result.value.length === 0) {
|
|
87
|
+
throw Error(`The specified card '${name}' does not exist.`);
|
|
88
|
+
}
|
|
89
|
+
if (result.value.length > 1) {
|
|
90
|
+
const resultAsKeyValuePair = formatting.convertArrayToHashTable('cardid', result.value);
|
|
91
|
+
return cli.handleMultipleResultsFound(`Multiple cards with name '${name}' found.`, resultAsKeyValuePair);
|
|
92
|
+
}
|
|
93
|
+
return result.value[0];
|
|
65
94
|
}
|
|
66
95
|
};
|
|
67
96
|
//# sourceMappingURL=powerPlatform.js.map
|
package/dist/utils/spo.js
CHANGED
|
@@ -519,10 +519,11 @@ export const spo = {
|
|
|
519
519
|
},
|
|
520
520
|
/**
|
|
521
521
|
* Retrieves the spo user by email.
|
|
522
|
+
* Returns a user object
|
|
522
523
|
* @param webUrl Web url
|
|
523
524
|
* @param email The email of the user
|
|
524
525
|
* @param logger the Logger object
|
|
525
|
-
* @param verbose
|
|
526
|
+
* @param verbose Set for verbose logging
|
|
526
527
|
*/
|
|
527
528
|
async getUserByEmail(webUrl, email, logger, verbose) {
|
|
528
529
|
if (verbose && logger) {
|
|
@@ -593,10 +594,11 @@ export const spo = {
|
|
|
593
594
|
},
|
|
594
595
|
/**
|
|
595
596
|
* Retrieves the spo group by name.
|
|
597
|
+
* Returns a group object
|
|
596
598
|
* @param webUrl Web url
|
|
597
599
|
* @param name The name of the group
|
|
598
600
|
* @param logger the Logger object
|
|
599
|
-
* @param verbose
|
|
601
|
+
* @param verbose Set for verbose logging
|
|
600
602
|
*/
|
|
601
603
|
async getGroupByName(webUrl, name, logger, verbose) {
|
|
602
604
|
if (verbose && logger) {
|
|
@@ -615,10 +617,13 @@ export const spo = {
|
|
|
615
617
|
},
|
|
616
618
|
/**
|
|
617
619
|
* Retrieves the role definition by name.
|
|
620
|
+
* Returns a RoleDefinition object
|
|
621
|
+
* Returns a RoleDefinition object
|
|
618
622
|
* @param webUrl Web url
|
|
619
623
|
* @param name the name of the role definition
|
|
620
624
|
* @param logger the Logger object
|
|
621
|
-
* @param verbose
|
|
625
|
+
* @param verbose Set for verbose logging
|
|
626
|
+
* @param verbose Set for verbose logging
|
|
622
627
|
*/
|
|
623
628
|
async getRoleDefinitionByName(webUrl, name, logger, verbose) {
|
|
624
629
|
if (verbose && logger) {
|
|
@@ -1753,6 +1758,30 @@ export const spo = {
|
|
|
1753
1758
|
responseType: 'json'
|
|
1754
1759
|
};
|
|
1755
1760
|
return request.post(requestOptions);
|
|
1761
|
+
},
|
|
1762
|
+
/**
|
|
1763
|
+
* Get a role definition by name
|
|
1764
|
+
* Returns a RoleDefinition object
|
|
1765
|
+
* @param webUrl The web url
|
|
1766
|
+
* @param name the name of the role definition
|
|
1767
|
+
* @param logger The logger object
|
|
1768
|
+
* @param verbose Set for verbose logging
|
|
1769
|
+
*/
|
|
1770
|
+
async getRoleDefintionByName(webUrl, name, logger, verbose) {
|
|
1771
|
+
if (verbose && logger) {
|
|
1772
|
+
await logger.logToStderr(`Retrieving the role definition by name ${name}`);
|
|
1773
|
+
}
|
|
1774
|
+
const response = await odata.getAllItems(`${webUrl}/_api/web/roledefinitions`);
|
|
1775
|
+
const roleDefinition = response.find((role) => role.Name === name);
|
|
1776
|
+
if (!roleDefinition) {
|
|
1777
|
+
throw new Error(`The specified role definition name '${name}' does not exist.`);
|
|
1778
|
+
}
|
|
1779
|
+
const permissions = new BasePermissions();
|
|
1780
|
+
permissions.high = roleDefinition.BasePermissions.High;
|
|
1781
|
+
permissions.low = roleDefinition.BasePermissions.Low;
|
|
1782
|
+
roleDefinition.BasePermissionsValue = permissions.parse();
|
|
1783
|
+
roleDefinition.RoleTypeKindValue = RoleType[roleDefinition.RoleTypeKind];
|
|
1784
|
+
return roleDefinition;
|
|
1756
1785
|
}
|
|
1757
1786
|
};
|
|
1758
1787
|
//# sourceMappingURL=spo.js.map
|
package/package.json
CHANGED