@pnp/cli-microsoft365 9.1.0-beta.4ee36d4 → 9.1.0-beta.8c76288
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/base/PowerAutomateCommand.js +1 -1
- package/dist/m365/flow/commands/environment/environment-get.js +1 -1
- package/dist/m365/flow/commands/environment/environment-list.js +1 -1
- package/dist/m365/flow/commands/flow-disable.js +1 -1
- package/dist/m365/flow/commands/flow-enable.js +1 -1
- package/dist/m365/flow/commands/flow-export.js +17 -16
- package/dist/m365/flow/commands/flow-get.js +1 -1
- package/dist/m365/flow/commands/flow-list.js +1 -1
- package/dist/m365/flow/commands/flow-remove.js +1 -1
- package/dist/m365/flow/commands/owner/owner-ensure.js +1 -1
- package/dist/m365/flow/commands/owner/owner-list.js +1 -1
- package/dist/m365/flow/commands/owner/owner-remove.js +1 -1
- package/dist/m365/flow/commands/run/run-cancel.js +1 -1
- package/dist/m365/flow/commands/run/run-get.js +1 -1
- package/dist/m365/flow/commands/run/run-list.js +1 -1
- package/dist/m365/flow/commands/run/run-resubmit.js +2 -2
- package/dist/m365/spo/commands/file/file-roleassignment-add.js +17 -54
- package/dist/m365/spo/commands/file/file-roleassignment-remove.js +13 -40
- package/dist/m365/spo/commands/file/file-roleinheritance-break.js +5 -13
- package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +5 -13
- package/dist/m365/spo/commands/list/list-get.js +17 -4
- package/dist/m365/spo/commands/page/page-section-add.js +185 -34
- package/dist/utils/spo.js +30 -7
- package/docs/docs/cmd/spo/page/page-section-add.mdx +57 -2
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import auth, { CloudType } from '../../Auth.js';
|
|
|
2
2
|
import Command, { CommandError } from '../../Command.js';
|
|
3
3
|
import { accessToken } from '../../utils/accessToken.js';
|
|
4
4
|
export default class PowerAutomateCommand extends Command {
|
|
5
|
-
get resource() {
|
|
5
|
+
static get resource() {
|
|
6
6
|
return 'https://api.flow.microsoft.com';
|
|
7
7
|
}
|
|
8
8
|
async initAction(args, logger) {
|
|
@@ -28,7 +28,7 @@ class FlowEnvironmentGetCommand extends PowerAutomateCommand {
|
|
|
28
28
|
if (this.verbose) {
|
|
29
29
|
await logger.logToStderr(`Retrieving information about Microsoft Flow environment ${args.options.name ?? ''}...`);
|
|
30
30
|
}
|
|
31
|
-
let requestUrl = `${
|
|
31
|
+
let requestUrl = `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/environments/`;
|
|
32
32
|
if (args.options.name) {
|
|
33
33
|
requestUrl += `${formatting.encodeQueryParameter(args.options.name)}`;
|
|
34
34
|
}
|
|
@@ -16,7 +16,7 @@ class FlowEnvironmentListCommand extends PowerAutomateCommand {
|
|
|
16
16
|
await logger.logToStderr(`Retrieving list of Microsoft Flow environments...`);
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
|
-
const res = await odata.getAllItems(`${
|
|
19
|
+
const res = await odata.getAllItems(`${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01`);
|
|
20
20
|
if (res.length > 0) {
|
|
21
21
|
if (args.options.output !== 'json') {
|
|
22
22
|
res.forEach(e => {
|
|
@@ -26,7 +26,7 @@ class FlowDisableCommand extends PowerAutomateCommand {
|
|
|
26
26
|
await logger.logToStderr(`Disables Microsoft Flow ${args.options.name}...`);
|
|
27
27
|
}
|
|
28
28
|
const requestOptions = {
|
|
29
|
-
url: `${
|
|
29
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}/stop?api-version=2016-11-01`,
|
|
30
30
|
headers: {
|
|
31
31
|
accept: 'application/json'
|
|
32
32
|
},
|
|
@@ -26,7 +26,7 @@ class FlowEnableCommand extends PowerAutomateCommand {
|
|
|
26
26
|
await logger.logToStderr(`Enables Microsoft Flow ${args.options.name}...`);
|
|
27
27
|
}
|
|
28
28
|
const requestOptions = {
|
|
29
|
-
url: `${
|
|
29
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}/start?api-version=2016-11-01`,
|
|
30
30
|
headers: {
|
|
31
31
|
accept: 'application/json'
|
|
32
32
|
},
|
|
@@ -11,6 +11,7 @@ import { formatting } from '../../../utils/formatting.js';
|
|
|
11
11
|
import { validation } from '../../../utils/validation.js';
|
|
12
12
|
import PowerPlatformCommand from '../../base/PowerPlatformCommand.js';
|
|
13
13
|
import commands from '../commands.js';
|
|
14
|
+
import PowerAutomateCommand from '../../base/PowerAutomateCommand.js';
|
|
14
15
|
class FlowExportCommand extends PowerPlatformCommand {
|
|
15
16
|
get name() {
|
|
16
17
|
return commands.EXPORT;
|
|
@@ -27,15 +28,15 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
27
28
|
}
|
|
28
29
|
async commandAction(logger, args) {
|
|
29
30
|
let filenameFromApi = '';
|
|
30
|
-
const formatArgument = args.options.format
|
|
31
|
+
const formatArgument = args.options.format?.toLowerCase() || '';
|
|
31
32
|
if (this.verbose) {
|
|
32
33
|
await logger.logToStderr(`Retrieving package resources for Microsoft Flow ${args.options.name}...`);
|
|
33
34
|
}
|
|
34
35
|
try {
|
|
35
36
|
let res;
|
|
36
37
|
if (formatArgument === 'json') {
|
|
37
|
-
if (this.
|
|
38
|
-
await logger.logToStderr('format = json, skipping listing package resources step');
|
|
38
|
+
if (this.verbose) {
|
|
39
|
+
await logger.logToStderr('format = json, skipping listing package resources step.');
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
else {
|
|
@@ -61,7 +62,7 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
61
62
|
}
|
|
62
63
|
let requestOptions = {
|
|
63
64
|
url: formatArgument === 'json' ?
|
|
64
|
-
|
|
65
|
+
`${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`
|
|
65
66
|
: `${this.resource}/providers/Microsoft.BusinessAppPlatform/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/exportPackage?api-version=2016-11-01`,
|
|
66
67
|
headers: {
|
|
67
68
|
accept: 'application/json'
|
|
@@ -76,17 +77,17 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
76
77
|
? res.resources[key].suggestedCreationType = 'Update'
|
|
77
78
|
: res.resources[key].suggestedCreationType = 'Existing';
|
|
78
79
|
});
|
|
79
|
-
requestOptions
|
|
80
|
-
|
|
80
|
+
requestOptions.data = {
|
|
81
|
+
includedResourceIds: [
|
|
81
82
|
`/providers/Microsoft.Flow/flows/${args.options.name}`
|
|
82
83
|
],
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
details: {
|
|
85
|
+
displayName: args.options.packageDisplayName,
|
|
86
|
+
description: args.options.packageDescription,
|
|
87
|
+
creator: args.options.packageCreatedBy,
|
|
88
|
+
sourceEnvironment: args.options.packageSourceEnvironment
|
|
88
89
|
},
|
|
89
|
-
|
|
90
|
+
resources: res.resources
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
93
|
res = formatArgument === 'json' ? await request.get(requestOptions) : await request.post(requestOptions);
|
|
@@ -99,13 +100,13 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
99
100
|
// Replace all illegal characters from the file name
|
|
100
101
|
const illegalCharsRegEx = /[\\\/:*?"<>|]/g;
|
|
101
102
|
filenameFromApi = filenameFromApi.replace(illegalCharsRegEx, '_');
|
|
102
|
-
if (this.
|
|
103
|
-
await logger.logToStderr(`Filename from PowerApps API: ${filenameFromApi}
|
|
103
|
+
if (this.verbose) {
|
|
104
|
+
await logger.logToStderr(`Filename from PowerApps API: ${filenameFromApi}.`);
|
|
104
105
|
await logger.logToStderr('');
|
|
105
106
|
}
|
|
106
107
|
requestOptions = {
|
|
107
108
|
url: formatArgument === 'json' ?
|
|
108
|
-
|
|
109
|
+
`${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}/exportToARMTemplate?api-version=2016-11-01`
|
|
109
110
|
: downloadFileUrl,
|
|
110
111
|
// Set responseType to arraybuffer, otherwise binary data will be encoded
|
|
111
112
|
// to utf8 and binary data is corrupt
|
|
@@ -124,7 +125,7 @@ class FlowExportCommand extends PowerPlatformCommand {
|
|
|
124
125
|
fs.writeFileSync(path, file, 'binary');
|
|
125
126
|
if (!args.options.path || this.verbose) {
|
|
126
127
|
if (this.verbose) {
|
|
127
|
-
await logger.logToStderr(`File saved to path '${path}'
|
|
128
|
+
await logger.logToStderr(`File saved to path '${path}'.`);
|
|
128
129
|
}
|
|
129
130
|
else {
|
|
130
131
|
await logger.log(path);
|
|
@@ -29,7 +29,7 @@ class FlowGetCommand extends PowerAutomateCommand {
|
|
|
29
29
|
await logger.logToStderr(`Retrieving information about Microsoft Flow ${args.options.name}...`);
|
|
30
30
|
}
|
|
31
31
|
const requestOptions = {
|
|
32
|
-
url: `${
|
|
32
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01&$expand=swagger,properties.connectionreferences.apidefinition,properties.definitionsummary.operations.apioperation,operationDefinition,plan,properties.throttleData,properties.estimatedsuspensiondata,properties.licenseData`,
|
|
33
33
|
headers: {
|
|
34
34
|
accept: 'application/json'
|
|
35
35
|
},
|
|
@@ -67,7 +67,7 @@ class FlowListCommand extends PowerAutomateCommand {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
getApiUrl(environmentName, asAdmin, includeSolutionFlows, filter) {
|
|
70
|
-
const baseEndpoint = `${
|
|
70
|
+
const baseEndpoint = `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple`;
|
|
71
71
|
const environmentSegment = `/environments/${formatting.encodeQueryParameter(environmentName)}`;
|
|
72
72
|
const adminSegment = `/scopes/admin${environmentSegment}/v2`;
|
|
73
73
|
const flowsEndpoint = '/flows?api-version=2016-11-01';
|
|
@@ -30,7 +30,7 @@ class FlowRemoveCommand extends PowerAutomateCommand {
|
|
|
30
30
|
}
|
|
31
31
|
const removeFlow = async () => {
|
|
32
32
|
const requestOptions = {
|
|
33
|
-
url: `${
|
|
33
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.name)}?api-version=2016-11-01`,
|
|
34
34
|
fullResponse: true,
|
|
35
35
|
headers: {
|
|
36
36
|
accept: 'application/json'
|
|
@@ -52,7 +52,7 @@ class FlowOwnerEnsureCommand extends PowerAutomateCommand {
|
|
|
52
52
|
type = 'Group';
|
|
53
53
|
}
|
|
54
54
|
const requestOptions = {
|
|
55
|
-
url: `${
|
|
55
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/modifyPermissions?api-version=2016-11-01`,
|
|
56
56
|
headers: {
|
|
57
57
|
accept: 'application/json'
|
|
58
58
|
},
|
|
@@ -32,7 +32,7 @@ class FlowOwnerListCommand extends PowerAutomateCommand {
|
|
|
32
32
|
if (this.verbose) {
|
|
33
33
|
await logger.logToStderr(`Listing owners for flow ${args.options.flowName} in environment ${args.options.environmentName}`);
|
|
34
34
|
}
|
|
35
|
-
const response = await odata.getAllItems(`${
|
|
35
|
+
const response = await odata.getAllItems(`${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/permissions?api-version=2016-11-01`);
|
|
36
36
|
if (!cli.shouldTrimOutput(args.options.output)) {
|
|
37
37
|
await logger.log(response);
|
|
38
38
|
}
|
|
@@ -47,7 +47,7 @@ class FlowOwnerRemoveCommand extends PowerAutomateCommand {
|
|
|
47
47
|
idToRemove = await entraGroup.getGroupIdByDisplayName(args.options.groupName);
|
|
48
48
|
}
|
|
49
49
|
const requestOptions = {
|
|
50
|
-
url: `${
|
|
50
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/modifyPermissions?api-version=2016-11-01`,
|
|
51
51
|
headers: {
|
|
52
52
|
accept: 'application/json'
|
|
53
53
|
},
|
|
@@ -30,7 +30,7 @@ class FlowRunCancelCommand extends PowerAutomateCommand {
|
|
|
30
30
|
}
|
|
31
31
|
const cancelFlow = async () => {
|
|
32
32
|
const requestOptions = {
|
|
33
|
-
url: `${
|
|
33
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs/${formatting.encodeQueryParameter(args.options.name)}/cancel?api-version=2016-11-01`,
|
|
34
34
|
headers: {
|
|
35
35
|
accept: 'application/json'
|
|
36
36
|
},
|
|
@@ -35,7 +35,7 @@ class FlowRunGetCommand extends PowerAutomateCommand {
|
|
|
35
35
|
}
|
|
36
36
|
const actionsParameter = args.options.withActions ? '$expand=properties%2Factions&' : '';
|
|
37
37
|
const requestOptions = {
|
|
38
|
-
url: `${
|
|
38
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs/${formatting.encodeQueryParameter(args.options.name)}?${actionsParameter}api-version=2016-11-01`,
|
|
39
39
|
headers: {
|
|
40
40
|
accept: 'application/json'
|
|
41
41
|
},
|
|
@@ -32,7 +32,7 @@ class FlowRunListCommand extends PowerAutomateCommand {
|
|
|
32
32
|
if (this.verbose) {
|
|
33
33
|
await logger.logToStderr(`Retrieving list of runs for Microsoft Flow ${args.options.flowName}...`);
|
|
34
34
|
}
|
|
35
|
-
let url = `${
|
|
35
|
+
let url = `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/${args.options.asAdmin ? 'scopes/admin/' : ''}environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/runs?api-version=2016-11-01`;
|
|
36
36
|
const filters = this.getFilters(args.options);
|
|
37
37
|
if (filters.length > 0) {
|
|
38
38
|
url += `&$filter=${filters.join(' and ')}`;
|
|
@@ -36,7 +36,7 @@ class FlowRunResubmitCommand extends PowerAutomateCommand {
|
|
|
36
36
|
await logger.logToStderr(chalk.yellow(`Retrieved trigger: ${triggerName}`));
|
|
37
37
|
}
|
|
38
38
|
const requestOptions = {
|
|
39
|
-
url: `${
|
|
39
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(args.options.environmentName)}/flows/${formatting.encodeQueryParameter(args.options.flowName)}/triggers/${formatting.encodeQueryParameter(triggerName)}/histories/${formatting.encodeQueryParameter(args.options.name)}/resubmit?api-version=2016-11-01`,
|
|
40
40
|
headers: {
|
|
41
41
|
accept: 'application/json'
|
|
42
42
|
},
|
|
@@ -60,7 +60,7 @@ class FlowRunResubmitCommand extends PowerAutomateCommand {
|
|
|
60
60
|
}
|
|
61
61
|
async getTriggerName(environment, flow) {
|
|
62
62
|
const requestOptions = {
|
|
63
|
-
url: `${
|
|
63
|
+
url: `${PowerAutomateCommand.resource}/providers/Microsoft.ProcessSimple/environments/${formatting.encodeQueryParameter(environment)}/flows/${formatting.encodeQueryParameter(flow)}/triggers?api-version=2016-11-01`,
|
|
64
64
|
headers: {
|
|
65
65
|
accept: 'application/json'
|
|
66
66
|
},
|
|
@@ -4,17 +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 _SpoFileRoleAssignmentAddCommand_instances, _SpoFileRoleAssignmentAddCommand_initTelemetry, _SpoFileRoleAssignmentAddCommand_initOptions, _SpoFileRoleAssignmentAddCommand_initValidators, _SpoFileRoleAssignmentAddCommand_initOptionSets, _SpoFileRoleAssignmentAddCommand_initTypes;
|
|
7
|
-
import { cli } from '../../../../cli/cli.js';
|
|
8
7
|
import request from '../../../../request.js';
|
|
9
8
|
import { formatting } from '../../../../utils/formatting.js';
|
|
9
|
+
import { spo } from '../../../../utils/spo.js';
|
|
10
10
|
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 spoRoleDefinitionListCommand from '../roledefinition/roledefinition-list.js';
|
|
16
|
-
import spoUserGetCommand from '../user/user-get.js';
|
|
17
|
-
import spoFileGetCommand from './file-get.js';
|
|
18
14
|
class SpoFileRoleAssignmentAddCommand extends SpoCommand {
|
|
19
15
|
get name() {
|
|
20
16
|
return commands.FILE_ROLEASSIGNMENT_ADD;
|
|
@@ -36,14 +32,14 @@ class SpoFileRoleAssignmentAddCommand extends SpoCommand {
|
|
|
36
32
|
await logger.logToStderr(`Adding role assignment to file in site at ${args.options.webUrl}...`);
|
|
37
33
|
}
|
|
38
34
|
try {
|
|
39
|
-
const fileUrl = await this.getFileURL(args);
|
|
40
|
-
const roleDefinitionId = await this.getRoleDefinitionId(args.options);
|
|
35
|
+
const fileUrl = await this.getFileURL(args, logger);
|
|
36
|
+
const roleDefinitionId = await this.getRoleDefinitionId(args.options, logger);
|
|
41
37
|
if (args.options.upn) {
|
|
42
|
-
const upnPrincipalId = await this.getUserPrincipalId(args.options);
|
|
38
|
+
const upnPrincipalId = await this.getUserPrincipalId(args.options, logger);
|
|
43
39
|
await this.addRoleAssignment(fileUrl, args.options.webUrl, upnPrincipalId, roleDefinitionId);
|
|
44
40
|
}
|
|
45
41
|
else if (args.options.groupName) {
|
|
46
|
-
const groupPrincipalId = await this.getGroupPrincipalId(args.options);
|
|
42
|
+
const groupPrincipalId = await this.getGroupPrincipalId(args.options, logger);
|
|
47
43
|
await this.addRoleAssignment(fileUrl, args.options.webUrl, groupPrincipalId, roleDefinitionId);
|
|
48
44
|
}
|
|
49
45
|
else {
|
|
@@ -66,60 +62,27 @@ class SpoFileRoleAssignmentAddCommand extends SpoCommand {
|
|
|
66
62
|
};
|
|
67
63
|
return request.post(requestOptions);
|
|
68
64
|
}
|
|
69
|
-
async getRoleDefinitionId(options) {
|
|
65
|
+
async getRoleDefinitionId(options, logger) {
|
|
70
66
|
if (!options.roleDefinitionName) {
|
|
71
67
|
return options.roleDefinitionId;
|
|
72
68
|
}
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
output: 'json',
|
|
76
|
-
debug: this.debug,
|
|
77
|
-
verbose: this.verbose
|
|
78
|
-
};
|
|
79
|
-
const output = await cli.executeCommandWithOutput(spoRoleDefinitionListCommand, { options: { ...roleDefinitionListCommandOptions, _: [] } });
|
|
80
|
-
const getRoleDefinitionListOutput = JSON.parse(output.stdout);
|
|
81
|
-
const roleDefinitionId = getRoleDefinitionListOutput.find((role) => role.Name === options.roleDefinitionName).Id;
|
|
82
|
-
return roleDefinitionId;
|
|
69
|
+
const roleDefinition = await spo.getRoleDefinitionByName(options.webUrl, options.roleDefinitionName, logger, this.verbose);
|
|
70
|
+
return roleDefinition.Id;
|
|
83
71
|
}
|
|
84
|
-
async getGroupPrincipalId(options) {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
name: options.groupName,
|
|
88
|
-
output: 'json',
|
|
89
|
-
debug: this.debug,
|
|
90
|
-
verbose: this.verbose
|
|
91
|
-
};
|
|
92
|
-
const output = await cli.executeCommandWithOutput(spoGroupGetCommand, { options: { ...groupGetCommandOptions, _: [] } });
|
|
93
|
-
const getGroupOutput = JSON.parse(output.stdout);
|
|
94
|
-
return getGroupOutput.Id;
|
|
72
|
+
async getGroupPrincipalId(options, logger) {
|
|
73
|
+
const group = await spo.getGroupByName(options.webUrl, options.groupName, logger, this.verbose);
|
|
74
|
+
return group.Id;
|
|
95
75
|
}
|
|
96
|
-
async getUserPrincipalId(options) {
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
email: options.upn,
|
|
100
|
-
id: undefined,
|
|
101
|
-
output: 'json',
|
|
102
|
-
debug: this.debug,
|
|
103
|
-
verbose: this.verbose
|
|
104
|
-
};
|
|
105
|
-
const output = await cli.executeCommandWithOutput(spoUserGetCommand, { options: { ...userGetCommandOptions, _: [] } });
|
|
106
|
-
const getUserOutput = JSON.parse(output.stdout);
|
|
107
|
-
return getUserOutput.Id;
|
|
76
|
+
async getUserPrincipalId(options, logger) {
|
|
77
|
+
const user = await spo.getUserByEmail(options.webUrl, options.upn, logger, this.verbose);
|
|
78
|
+
return user.Id;
|
|
108
79
|
}
|
|
109
|
-
async getFileURL(args) {
|
|
80
|
+
async getFileURL(args, logger) {
|
|
110
81
|
if (args.options.fileUrl) {
|
|
111
82
|
return urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
|
|
112
83
|
}
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
id: args.options.fileId,
|
|
116
|
-
output: 'json',
|
|
117
|
-
debug: this.debug,
|
|
118
|
-
verbose: this.verbose
|
|
119
|
-
};
|
|
120
|
-
const output = await cli.executeCommandWithOutput(spoFileGetCommand, { options: { ...options, _: [] } });
|
|
121
|
-
const getFileOutput = JSON.parse(output.stdout);
|
|
122
|
-
return getFileOutput.ServerRelativeUrl;
|
|
84
|
+
const file = await spo.getFileById(args.options.webUrl, args.options.fileId, logger, this.verbose);
|
|
85
|
+
return file.ServerRelativeUrl;
|
|
123
86
|
}
|
|
124
87
|
}
|
|
125
88
|
_SpoFileRoleAssignmentAddCommand_instances = new WeakSet(), _SpoFileRoleAssignmentAddCommand_initTelemetry = function _SpoFileRoleAssignmentAddCommand_initTelemetry() {
|
|
@@ -7,13 +7,11 @@ var _SpoFileRoleAssignmentRemoveCommand_instances, _SpoFileRoleAssignmentRemoveC
|
|
|
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';
|
|
16
|
-
import spoFileGetCommand from './file-get.js';
|
|
17
15
|
class SpoFileRoleAssignmentRemoveCommand extends SpoCommand {
|
|
18
16
|
get name() {
|
|
19
17
|
return commands.FILE_ROLEASSIGNMENT_REMOVE;
|
|
@@ -36,13 +34,13 @@ class SpoFileRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
36
34
|
await logger.logToStderr(`Removing role assignment for ${args.options.groupName || args.options.upn} from file ${args.options.fileUrl || args.options.fileId}`);
|
|
37
35
|
}
|
|
38
36
|
try {
|
|
39
|
-
const fileURL = await this.getFileURL(args);
|
|
37
|
+
const fileURL = await this.getFileURL(args, logger);
|
|
40
38
|
let principalId;
|
|
41
39
|
if (args.options.groupName) {
|
|
42
|
-
principalId = await this.getGroupPrincipalId(args.options);
|
|
40
|
+
principalId = await this.getGroupPrincipalId(args.options, logger);
|
|
43
41
|
}
|
|
44
42
|
else if (args.options.upn) {
|
|
45
|
-
principalId = await this.getUserPrincipalId(args.options);
|
|
43
|
+
principalId = await this.getUserPrincipalId(args.options, logger);
|
|
46
44
|
}
|
|
47
45
|
else {
|
|
48
46
|
principalId = args.options.principalId;
|
|
@@ -71,45 +69,20 @@ class SpoFileRoleAssignmentRemoveCommand extends SpoCommand {
|
|
|
71
69
|
}
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
|
-
async getFileURL(args) {
|
|
72
|
+
async getFileURL(args, logger) {
|
|
75
73
|
if (args.options.fileUrl) {
|
|
76
74
|
return urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
|
|
77
75
|
}
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
id: args.options.fileId,
|
|
81
|
-
output: 'json',
|
|
82
|
-
debug: this.debug,
|
|
83
|
-
verbose: this.verbose
|
|
84
|
-
};
|
|
85
|
-
const output = await cli.executeCommandWithOutput(spoFileGetCommand, { options: { ...options, _: [] } });
|
|
86
|
-
const getFileOutput = JSON.parse(output.stdout);
|
|
87
|
-
return getFileOutput.ServerRelativeUrl;
|
|
76
|
+
const file = await spo.getFileById(args.options.webUrl, args.options.fileId, logger, this.verbose);
|
|
77
|
+
return file.ServerRelativeUrl;
|
|
88
78
|
}
|
|
89
|
-
async getUserPrincipalId(options) {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
email: options.upn,
|
|
93
|
-
id: undefined,
|
|
94
|
-
output: 'json',
|
|
95
|
-
debug: this.debug,
|
|
96
|
-
verbose: this.verbose
|
|
97
|
-
};
|
|
98
|
-
const output = await cli.executeCommandWithOutput(spoUserGetCommand, { options: { ...userGetCommandOptions, _: [] } });
|
|
99
|
-
const getUserOutput = JSON.parse(output.stdout);
|
|
100
|
-
return getUserOutput.Id;
|
|
79
|
+
async getUserPrincipalId(options, logger) {
|
|
80
|
+
const user = await spo.getUserByEmail(options.webUrl, options.upn, logger, this.verbose);
|
|
81
|
+
return user.Id;
|
|
101
82
|
}
|
|
102
|
-
async getGroupPrincipalId(options) {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
name: options.groupName,
|
|
106
|
-
output: 'json',
|
|
107
|
-
debug: this.debug,
|
|
108
|
-
verbose: this.verbose
|
|
109
|
-
};
|
|
110
|
-
const output = await cli.executeCommandWithOutput(spoGroupGetCommand, { options: { ...groupGetCommandOptions, _: [] } });
|
|
111
|
-
const getGroupOutput = JSON.parse(output.stdout);
|
|
112
|
-
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;
|
|
113
86
|
}
|
|
114
87
|
}
|
|
115
88
|
_SpoFileRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFileRoleAssignmentRemoveCommand_initTelemetry = function _SpoFileRoleAssignmentRemoveCommand_initTelemetry() {
|
|
@@ -7,11 +7,11 @@ var _SpoFileRoleInheritanceBreakCommand_instances, _SpoFileRoleInheritanceBreakC
|
|
|
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 spoFileGetCommand from './file-get.js';
|
|
15
15
|
class SpoFileRoleInheritanceBreakCommand extends SpoCommand {
|
|
16
16
|
get name() {
|
|
17
17
|
return commands.FILE_ROLEINHERITANCE_BREAK;
|
|
@@ -34,7 +34,7 @@ class SpoFileRoleInheritanceBreakCommand extends SpoCommand {
|
|
|
34
34
|
await logger.logToStderr(`Breaking role inheritance for file ${args.options.fileId || args.options.fileUrl}`);
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
|
-
const fileURL = await this.getFileURL(args);
|
|
37
|
+
const fileURL = await this.getFileURL(args, logger);
|
|
38
38
|
const keepExistingPermissions = !args.options.clearExistingPermissions;
|
|
39
39
|
const requestOptions = {
|
|
40
40
|
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(fileURL)}')/ListItemAllFields/breakroleinheritance(${keepExistingPermissions})`,
|
|
@@ -59,20 +59,12 @@ class SpoFileRoleInheritanceBreakCommand extends SpoCommand {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
async getFileURL(args) {
|
|
62
|
+
async getFileURL(args, logger) {
|
|
63
63
|
if (args.options.fileUrl) {
|
|
64
64
|
return urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
id: args.options.fileId,
|
|
69
|
-
output: 'json',
|
|
70
|
-
debug: this.debug,
|
|
71
|
-
verbose: this.verbose
|
|
72
|
-
};
|
|
73
|
-
const output = await cli.executeCommandWithOutput(spoFileGetCommand, { options: { ...options, _: [] } });
|
|
74
|
-
const getFileOutput = JSON.parse(output.stdout);
|
|
75
|
-
return getFileOutput.ServerRelativeUrl;
|
|
66
|
+
const file = await spo.getFileById(args.options.webUrl, args.options.fileId, logger, this.verbose);
|
|
67
|
+
return file.ServerRelativeUrl;
|
|
76
68
|
}
|
|
77
69
|
}
|
|
78
70
|
_SpoFileRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoFileRoleInheritanceBreakCommand_initTelemetry = function _SpoFileRoleInheritanceBreakCommand_initTelemetry() {
|
|
@@ -7,11 +7,11 @@ var _SpoFileRoleInheritanceResetCommand_instances, _SpoFileRoleInheritanceResetC
|
|
|
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 spoFileGetCommand from './file-get.js';
|
|
15
15
|
class SpoFileRoleInheritanceResetCommand extends SpoCommand {
|
|
16
16
|
get name() {
|
|
17
17
|
return commands.FILE_ROLEINHERITANCE_RESET;
|
|
@@ -34,7 +34,7 @@ class SpoFileRoleInheritanceResetCommand extends SpoCommand {
|
|
|
34
34
|
await logger.logToStderr(`Resetting role inheritance for file ${args.options.fileId || args.options.fileUrl}`);
|
|
35
35
|
}
|
|
36
36
|
try {
|
|
37
|
-
const fileURL = await this.getFileURL(args);
|
|
37
|
+
const fileURL = await this.getFileURL(args, logger);
|
|
38
38
|
const requestOptions = {
|
|
39
39
|
url: `${args.options.webUrl}/_api/web/GetFileByServerRelativePath(DecodedUrl='${formatting.encodeQueryParameter(fileURL)}')/ListItemAllFields/resetroleinheritance`,
|
|
40
40
|
headers: {
|
|
@@ -58,20 +58,12 @@ class SpoFileRoleInheritanceResetCommand extends SpoCommand {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
async getFileURL(args) {
|
|
61
|
+
async getFileURL(args, logger) {
|
|
62
62
|
if (args.options.fileUrl) {
|
|
63
63
|
return urlUtil.getServerRelativePath(args.options.webUrl, args.options.fileUrl);
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
id: args.options.fileId,
|
|
68
|
-
output: 'json',
|
|
69
|
-
debug: this.debug,
|
|
70
|
-
verbose: this.verbose
|
|
71
|
-
};
|
|
72
|
-
const output = await cli.executeCommandWithOutput(spoFileGetCommand, { options: { ...options, _: [] } });
|
|
73
|
-
const getFileOutput = JSON.parse(output.stdout);
|
|
74
|
-
return getFileOutput.ServerRelativeUrl;
|
|
65
|
+
const file = await spo.getFileById(args.options.webUrl, args.options.fileId, logger, this.verbose);
|
|
66
|
+
return file.ServerRelativeUrl;
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
69
|
_SpoFileRoleInheritanceResetCommand_instances = new WeakSet(), _SpoFileRoleInheritanceResetCommand_initTelemetry = function _SpoFileRoleInheritanceResetCommand_initTelemetry() {
|
|
@@ -22,6 +22,7 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
22
22
|
constructor() {
|
|
23
23
|
super();
|
|
24
24
|
_SpoListGetCommand_instances.add(this);
|
|
25
|
+
this.supportedBaseTemplates = [101, 109, 110, 111, 113, 114, 115, 116, 117, 119, 121, 122, 123, 126, 130, 175];
|
|
25
26
|
__classPrivateFieldGet(this, _SpoListGetCommand_instances, "m", _SpoListGetCommand_initTelemetry).call(this);
|
|
26
27
|
__classPrivateFieldGet(this, _SpoListGetCommand_instances, "m", _SpoListGetCommand_initOptions).call(this);
|
|
27
28
|
__classPrivateFieldGet(this, _SpoListGetCommand_instances, "m", _SpoListGetCommand_initValidators).call(this);
|
|
@@ -50,11 +51,8 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
50
51
|
if (fieldsProperties.expandProperties.length > 0) {
|
|
51
52
|
queryParams.push(`$expand=${fieldsProperties.expandProperties.join(',')}`);
|
|
52
53
|
}
|
|
53
|
-
if (queryParams.length === 0) {
|
|
54
|
-
queryParams.push(`$expand=VersionPolicies`);
|
|
55
|
-
}
|
|
56
54
|
const requestOptions = {
|
|
57
|
-
url: `${requestUrl}
|
|
55
|
+
url: `${requestUrl}${queryParams.length > 0 ? `?${queryParams.join('&')}` : ''}`,
|
|
58
56
|
headers: {
|
|
59
57
|
'accept': 'application/json;odata=nometadata'
|
|
60
58
|
},
|
|
@@ -67,6 +65,9 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
67
65
|
r.Member.PrincipalTypeString = ListPrincipalType[r.Member.PrincipalType];
|
|
68
66
|
});
|
|
69
67
|
}
|
|
68
|
+
if (this.supportedBaseTemplates.some(template => template === listInstance.BaseTemplate)) {
|
|
69
|
+
await this.retrieveVersionPolicies(requestUrl, listInstance);
|
|
70
|
+
}
|
|
70
71
|
if (listInstance.VersionPolicies) {
|
|
71
72
|
listInstance.VersionPolicies.DefaultTrimModeValue = DefaultTrimModeType[listInstance.VersionPolicies.DefaultTrimMode];
|
|
72
73
|
}
|
|
@@ -96,6 +97,18 @@ class SpoListGetCommand extends SpoCommand {
|
|
|
96
97
|
expandProperties: [...new Set(expandProperties)]
|
|
97
98
|
};
|
|
98
99
|
}
|
|
100
|
+
async retrieveVersionPolicies(requestUrl, listInstance) {
|
|
101
|
+
const requestOptions = {
|
|
102
|
+
url: `${requestUrl}?$select=VersionPolicies&$expand=VersionPolicies`,
|
|
103
|
+
headers: {
|
|
104
|
+
'accept': 'application/json;odata=nometadata'
|
|
105
|
+
},
|
|
106
|
+
responseType: 'json'
|
|
107
|
+
};
|
|
108
|
+
const { VersionPolicies } = await request.get(requestOptions);
|
|
109
|
+
listInstance.VersionPolicies = VersionPolicies;
|
|
110
|
+
listInstance.VersionPolicies.DefaultTrimModeValue = DefaultTrimModeType[listInstance.VersionPolicies.DefaultTrimMode];
|
|
111
|
+
}
|
|
99
112
|
}
|
|
100
113
|
_SpoListGetCommand_instances = new WeakSet(), _SpoListGetCommand_initTelemetry = function _SpoListGetCommand_initTelemetry() {
|
|
101
114
|
this.telemetry.push((args) => {
|