@pnp/cli-microsoft365 9.0.0-beta.e16d09c → 9.0.0-beta.e69e8d0
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/config.js +1 -1
- package/dist/m365/app/commands/permission/permission-add.js +9 -9
- package/dist/m365/commands/status.js +2 -2
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-add.js +13 -13
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-get.js +18 -18
- package/dist/m365/entra/commands/enterpriseapp/enterpriseapp-list.js +1 -1
- package/dist/m365/entra/commands/group/group-user-list.js +4 -4
- package/dist/m365/entra/commands/m365group/m365group-conversation-post-list.js +4 -4
- package/dist/m365/entra/commands/m365group/m365group-recyclebinitem-list.js +3 -3
- package/dist/m365/entra/commands/m365group/m365group-user-add.js +109 -32
- package/dist/m365/entra/commands/m365group/m365group-user-list.js +6 -9
- package/dist/m365/entra/commands/m365group/m365group-user-set.js +159 -84
- package/dist/m365/flow/commands/flow-get.js +1 -1
- package/dist/m365/outlook/commands/message/message-get.js +11 -11
- package/dist/m365/pa/commands/app/app-export.js +13 -7
- package/dist/m365/spfx/commands/project/DeployWorkflow.js +1 -1
- package/dist/m365/spfx/commands/project/project-github-workflow-add.js +1 -10
- package/dist/m365/spo/commands/file/file-copy.js +55 -34
- package/dist/m365/spo/commands/folder/folder-set.js +0 -4
- package/dist/m365/spo/commands/folder/folder-sharinglink-get.js +86 -0
- package/dist/m365/spo/commands/folder/folder-sharinglink-list.js +110 -0
- package/dist/m365/spo/commands/list/ListInstance.js +6 -1
- package/dist/m365/spo/commands/list/list-get.js +9 -3
- package/dist/m365/spo/commands/list/list-list.js +1 -4
- package/dist/m365/spo/commands/site/site-appcatalog-remove.js +48 -24
- package/dist/m365/spo/commands/site/site-remove.js +1 -7
- package/dist/m365/spo/commands/tenant/tenant-recyclebinitem-restore.js +2 -22
- package/dist/m365/spo/commands.js +2 -1
- package/dist/utils/drive.js +61 -0
- package/dist/utils/spo.js +106 -0
- package/docs/docs/cmd/app/permission/permission-add.mdx +5 -5
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-add.mdx +12 -12
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-get.mdx +14 -14
- package/docs/docs/cmd/entra/enterpriseapp/enterpriseapp-list.mdx +5 -5
- package/docs/docs/cmd/entra/group/group-user-list.mdx +7 -7
- package/docs/docs/cmd/entra/m365group/m365group-conversation-post-list.mdx +5 -5
- package/docs/docs/cmd/entra/m365group/m365group-recyclebinitem-list.mdx +3 -3
- package/docs/docs/cmd/entra/m365group/m365group-user-add.mdx +28 -10
- package/docs/docs/cmd/entra/m365group/m365group-user-list.mdx +1 -1
- package/docs/docs/cmd/entra/m365group/m365group-user-set.mdx +35 -11
- package/docs/docs/cmd/flow/flow-get.mdx +149 -283
- package/docs/docs/cmd/outlook/message/message-get.mdx +5 -5
- package/docs/docs/cmd/pa/app/app-export.mdx +15 -9
- package/docs/docs/cmd/spfx/project/project-github-workflow-add.mdx +11 -12
- package/docs/docs/cmd/spo/app/app-uninstall.mdx +1 -1
- package/docs/docs/cmd/spo/file/file-copy.mdx +119 -12
- package/docs/docs/cmd/spo/folder/folder-set.mdx +0 -6
- package/docs/docs/cmd/spo/folder/folder-sharinglink-get.mdx +110 -0
- package/docs/docs/cmd/spo/folder/folder-sharinglink-list.mdx +114 -0
- package/docs/docs/cmd/spo/list/list-get.mdx +6 -0
- package/docs/docs/cmd/spo/list/list-list.mdx +5 -7
- package/docs/docs/cmd/spo/site/site-appcatalog-remove.mdx +11 -2
- package/docs/docs/cmd/spo/site/site-remove.mdx +0 -3
- package/docs/docs/cmd/spo/tenant/tenant-recyclebinitem-restore.mdx +2 -49
- package/npm-shrinkwrap.json +572 -477
- package/package.json +22 -22
|
@@ -3,14 +3,15 @@ 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 _EntraM365GroupUserSetCommand_instances, _EntraM365GroupUserSetCommand_initTelemetry, _EntraM365GroupUserSetCommand_initOptions, _EntraM365GroupUserSetCommand_initValidators, _EntraM365GroupUserSetCommand_initOptionSets;
|
|
6
|
+
var _EntraM365GroupUserSetCommand_instances, _EntraM365GroupUserSetCommand_initTelemetry, _EntraM365GroupUserSetCommand_initOptions, _EntraM365GroupUserSetCommand_initValidators, _EntraM365GroupUserSetCommand_initOptionSets, _EntraM365GroupUserSetCommand_initTypes;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
-
import { odata } from '../../../../utils/odata.js';
|
|
9
8
|
import { validation } from '../../../../utils/validation.js';
|
|
9
|
+
import { formatting } from '../../../../utils/formatting.js';
|
|
10
10
|
import GraphCommand from '../../../base/GraphCommand.js';
|
|
11
11
|
import teamsCommands from '../../../teams/commands.js';
|
|
12
12
|
import commands from '../../commands.js';
|
|
13
13
|
import { entraGroup } from '../../../../utils/entraGroup.js';
|
|
14
|
+
import { entraUser } from '../../../../utils/entraUser.js';
|
|
14
15
|
import aadCommands from '../../aadCommands.js';
|
|
15
16
|
class EntraM365GroupUserSetCommand extends GraphCommand {
|
|
16
17
|
get name() {
|
|
@@ -25,135 +26,209 @@ class EntraM365GroupUserSetCommand extends GraphCommand {
|
|
|
25
26
|
constructor() {
|
|
26
27
|
super();
|
|
27
28
|
_EntraM365GroupUserSetCommand_instances.add(this);
|
|
29
|
+
this.allowedRoles = ['owner', 'member'];
|
|
28
30
|
__classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initTelemetry).call(this);
|
|
29
31
|
__classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initOptions).call(this);
|
|
30
32
|
__classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initValidators).call(this);
|
|
31
33
|
__classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initOptionSets).call(this);
|
|
34
|
+
__classPrivateFieldGet(this, _EntraM365GroupUserSetCommand_instances, "m", _EntraM365GroupUserSetCommand_initTypes).call(this);
|
|
32
35
|
}
|
|
33
36
|
async commandAction(logger, args) {
|
|
34
37
|
await this.showDeprecationWarning(logger, aadCommands.M365GROUP_USER_SET, commands.M365GROUP_USER_SET);
|
|
38
|
+
if (args.options.userName) {
|
|
39
|
+
await this.warn(logger, `Option 'userName' is deprecated. Please use 'ids' or 'userNames' instead.`);
|
|
40
|
+
}
|
|
35
41
|
try {
|
|
36
|
-
const
|
|
42
|
+
const userNames = args.options.userNames || args.options.userName;
|
|
43
|
+
const groupId = await this.getGroupId(logger, args);
|
|
37
44
|
const isUnifiedGroup = await entraGroup.isUnifiedGroup(groupId);
|
|
38
45
|
if (!isUnifiedGroup) {
|
|
39
46
|
throw Error(`Specified group with id '${groupId}' is not a Microsoft 365 group.`);
|
|
40
47
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
users
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
await logger.logToStderr((typeof args.options.groupId !== 'undefined') ? 'Group owners and members:' : 'Team owners and members:');
|
|
48
|
-
await logger.logToStderr(users);
|
|
49
|
-
await logger.logToStderr('');
|
|
50
|
-
}
|
|
51
|
-
if (users.filter(i => args.options.userName.toUpperCase() === i.userPrincipalName.toUpperCase()).length <= 0) {
|
|
52
|
-
const userNotInGroup = (typeof args.options.groupId !== 'undefined') ?
|
|
53
|
-
'The specified user does not belong to the given Microsoft 365 Group. Please use the \'m365group user add\' command to add new users.' :
|
|
54
|
-
'The specified user does not belong to the given Microsoft Teams team. Please use the \'graph teams user add\' command to add new users.';
|
|
55
|
-
throw new Error(userNotInGroup);
|
|
56
|
-
}
|
|
57
|
-
if (args.options.role === "Owner") {
|
|
58
|
-
const foundMember = users.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Member');
|
|
59
|
-
if (foundMember !== undefined) {
|
|
60
|
-
const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/$ref`;
|
|
61
|
-
const requestOptions = {
|
|
62
|
-
url: endpoint,
|
|
63
|
-
headers: {
|
|
64
|
-
'accept': 'application/json;odata.metadata=none'
|
|
65
|
-
},
|
|
66
|
-
responseType: 'json',
|
|
67
|
-
data: { "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/" + foundMember.id }
|
|
68
|
-
};
|
|
69
|
-
await request.post(requestOptions);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
const userAlreadyOwner = (typeof args.options.groupId !== 'undefined') ?
|
|
73
|
-
'The specified user is already an owner in the specified Microsoft 365 group, and thus cannot be promoted.' :
|
|
74
|
-
'The specified user is already an owner in the specified Microsoft Teams team, and thus cannot be promoted.';
|
|
75
|
-
throw new Error(userAlreadyOwner);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
const foundOwner = users.find(e => args.options.userName.toUpperCase() === e.userPrincipalName.toUpperCase() && e.userType === 'Owner');
|
|
80
|
-
if (foundOwner !== undefined) {
|
|
81
|
-
const endpoint = `${this.resource}/v1.0/groups/${groupId}/owners/${foundOwner.id}/$ref`;
|
|
82
|
-
const requestOptions = {
|
|
83
|
-
url: endpoint,
|
|
84
|
-
headers: {
|
|
85
|
-
'accept': 'application/json;odata.metadata=none'
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
await request.delete(requestOptions);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
const userAlreadyMember = (typeof args.options.groupId !== 'undefined') ?
|
|
92
|
-
'The specified user is already a member in the specified Microsoft 365 group, and thus cannot be demoted.' :
|
|
93
|
-
'The specified user is already a member in the specified Microsoft Teams team, and thus cannot be demoted.';
|
|
94
|
-
throw new Error(userAlreadyMember);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
48
|
+
const userIds = await this.getUserIds(logger, args.options.ids, userNames);
|
|
49
|
+
// we can't simply switch the role
|
|
50
|
+
// first add users to the new role
|
|
51
|
+
await this.addUsers(groupId, userIds, args.options.role);
|
|
52
|
+
// remove users from the old role
|
|
53
|
+
await this.removeUsersFromRole(logger, groupId, userIds, args.options.role);
|
|
97
54
|
}
|
|
98
55
|
catch (err) {
|
|
99
56
|
this.handleRejectedODataJsonPromise(err);
|
|
100
57
|
}
|
|
101
58
|
}
|
|
102
|
-
async
|
|
59
|
+
async getGroupId(logger, args) {
|
|
60
|
+
if (args.options.groupId) {
|
|
61
|
+
return args.options.groupId;
|
|
62
|
+
}
|
|
63
|
+
if (args.options.teamId) {
|
|
64
|
+
return args.options.teamId;
|
|
65
|
+
}
|
|
66
|
+
const name = args.options.groupName || args.options.teamName;
|
|
103
67
|
if (this.verbose) {
|
|
104
|
-
await logger.logToStderr(
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
68
|
+
await logger.logToStderr('Retrieving Group ID by display name...');
|
|
69
|
+
}
|
|
70
|
+
return entraGroup.getGroupIdByDisplayName(name);
|
|
71
|
+
}
|
|
72
|
+
async getUserIds(logger, userIds, userNames) {
|
|
73
|
+
if (userIds) {
|
|
74
|
+
return formatting.splitAndTrim(userIds);
|
|
75
|
+
}
|
|
76
|
+
if (this.verbose) {
|
|
77
|
+
await logger.logToStderr('Retrieving user ID(s) by username(s)...');
|
|
78
|
+
}
|
|
79
|
+
return entraUser.getUserIdsByUpns(formatting.splitAndTrim(userNames));
|
|
114
80
|
}
|
|
115
|
-
async
|
|
81
|
+
async removeUsersFromRole(logger, groupId, userIds, role) {
|
|
82
|
+
const userIdsToRemove = [];
|
|
83
|
+
const currentRole = (role.toLowerCase() === 'member') ? 'owners' : 'members';
|
|
116
84
|
if (this.verbose) {
|
|
117
|
-
await logger.logToStderr(`
|
|
85
|
+
await logger.logToStderr(`Removing users from the old role '${currentRole}'.`);
|
|
86
|
+
}
|
|
87
|
+
for (let i = 0; i < userIds.length; i += 20) {
|
|
88
|
+
const userIdsBatch = userIds.slice(i, i + 20);
|
|
89
|
+
const requestOptions = this.getRequestOptions();
|
|
90
|
+
userIdsBatch.map(userId => {
|
|
91
|
+
requestOptions.data.requests.push({
|
|
92
|
+
id: userId,
|
|
93
|
+
method: 'GET',
|
|
94
|
+
url: `/groups/${groupId}/${currentRole}/$count?$filter=id eq '${userId}'`,
|
|
95
|
+
headers: {
|
|
96
|
+
'ConsistencyLevel': 'eventual'
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
// send batch request
|
|
101
|
+
const res = await request.post(requestOptions);
|
|
102
|
+
for (const response of res.responses) {
|
|
103
|
+
if (response.status === 200) {
|
|
104
|
+
if (response.body === 1) {
|
|
105
|
+
// user can be removed from current role
|
|
106
|
+
userIdsToRemove.push(response.id);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
throw response.body;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (let i = 0; i < userIdsToRemove.length; i += 20) {
|
|
115
|
+
const userIdsBatch = userIds.slice(i, i + 20);
|
|
116
|
+
const requestOptions = this.getRequestOptions();
|
|
117
|
+
userIdsBatch.map(userId => {
|
|
118
|
+
requestOptions.data.requests.push({
|
|
119
|
+
id: userId,
|
|
120
|
+
method: 'DELETE',
|
|
121
|
+
url: `/groups/${groupId}/${currentRole}/${userId}/$ref`
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
const res = await request.post(requestOptions);
|
|
125
|
+
for (const response of res.responses) {
|
|
126
|
+
if (response.status !== 204) {
|
|
127
|
+
throw response.body;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async addUsers(groupId, userIds, role) {
|
|
133
|
+
for (let i = 0; i < userIds.length; i += 400) {
|
|
134
|
+
const userIdsBatch = userIds.slice(i, i + 400);
|
|
135
|
+
const requestOptions = this.getRequestOptions();
|
|
136
|
+
for (let j = 0; j < userIdsBatch.length; j += 20) {
|
|
137
|
+
const userIdsChunk = userIdsBatch.slice(j, j + 20);
|
|
138
|
+
requestOptions.data.requests.push({
|
|
139
|
+
id: j + 1,
|
|
140
|
+
method: 'PATCH',
|
|
141
|
+
url: `/groups/${groupId}`,
|
|
142
|
+
headers: {
|
|
143
|
+
'content-type': 'application/json;odata.metadata=none'
|
|
144
|
+
},
|
|
145
|
+
body: {
|
|
146
|
+
[`${role.toLowerCase() === 'member' ? 'members' : 'owners'}@odata.bind`]: userIdsChunk.map(u => `${this.resource}/v1.0/directoryObjects/${u}`)
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const res = await request.post(requestOptions);
|
|
151
|
+
for (const response of res.responses) {
|
|
152
|
+
if (response.status !== 204) {
|
|
153
|
+
throw response.body;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
118
156
|
}
|
|
119
|
-
|
|
120
|
-
|
|
157
|
+
}
|
|
158
|
+
getRequestOptions() {
|
|
159
|
+
const requestOptions = {
|
|
160
|
+
url: `${this.resource}/v1.0/$batch`,
|
|
161
|
+
headers: {
|
|
162
|
+
'content-type': 'application/json;odata.metadata=none'
|
|
163
|
+
},
|
|
164
|
+
responseType: 'json',
|
|
165
|
+
data: {
|
|
166
|
+
requests: []
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return requestOptions;
|
|
121
170
|
}
|
|
122
171
|
}
|
|
123
172
|
_EntraM365GroupUserSetCommand_instances = new WeakSet(), _EntraM365GroupUserSetCommand_initTelemetry = function _EntraM365GroupUserSetCommand_initTelemetry() {
|
|
124
173
|
this.telemetry.push((args) => {
|
|
125
174
|
Object.assign(this.telemetryProperties, {
|
|
126
175
|
teamId: typeof args.options.teamId !== 'undefined',
|
|
176
|
+
teamName: typeof args.options.teamName !== 'undefined',
|
|
127
177
|
groupId: typeof args.options.groupId !== 'undefined',
|
|
128
|
-
|
|
178
|
+
groupName: typeof args.options.groupName !== 'undefined',
|
|
179
|
+
ids: typeof args.options.ids !== 'undefined',
|
|
180
|
+
userNames: typeof args.options.userNames !== 'undefined'
|
|
129
181
|
});
|
|
130
182
|
});
|
|
131
183
|
}, _EntraM365GroupUserSetCommand_initOptions = function _EntraM365GroupUserSetCommand_initOptions() {
|
|
132
184
|
this.options.unshift({
|
|
133
|
-
option:
|
|
185
|
+
option: '-n, --userName [userName]'
|
|
186
|
+
}, {
|
|
187
|
+
option: '--ids [ids]'
|
|
188
|
+
}, {
|
|
189
|
+
option: '--userNames [userNames]'
|
|
190
|
+
}, {
|
|
191
|
+
option: '-i, --groupId [groupId]'
|
|
134
192
|
}, {
|
|
135
|
-
option:
|
|
193
|
+
option: '--groupName [groupName]'
|
|
136
194
|
}, {
|
|
137
|
-
option: '
|
|
195
|
+
option: '--teamId [teamId]'
|
|
196
|
+
}, {
|
|
197
|
+
option: '--teamName [teamName]'
|
|
138
198
|
}, {
|
|
139
199
|
option: '-r, --role <role>',
|
|
140
|
-
autocomplete:
|
|
200
|
+
autocomplete: this.allowedRoles
|
|
141
201
|
});
|
|
142
202
|
}, _EntraM365GroupUserSetCommand_initValidators = function _EntraM365GroupUserSetCommand_initValidators() {
|
|
143
203
|
this.validators.push(async (args) => {
|
|
144
204
|
if (args.options.teamId && !validation.isValidGuid(args.options.teamId)) {
|
|
145
|
-
return
|
|
205
|
+
return `'${args.options.teamId}' is not a valid GUID for option 'teamId'.`;
|
|
146
206
|
}
|
|
147
207
|
if (args.options.groupId && !validation.isValidGuid(args.options.groupId)) {
|
|
148
|
-
return
|
|
208
|
+
return `'${args.options.groupId}' is not a valid GUID for option 'groupId'.`;
|
|
209
|
+
}
|
|
210
|
+
if (args.options.ids) {
|
|
211
|
+
const isValidGUIDArrayResult = validation.isValidGuidArray(args.options.ids);
|
|
212
|
+
if (isValidGUIDArrayResult !== true) {
|
|
213
|
+
return `The following GUIDs are invalid for the option 'ids': ${isValidGUIDArrayResult}.`;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (args.options.userNames) {
|
|
217
|
+
const isValidUPNArrayResult = validation.isValidUserPrincipalNameArray(args.options.userNames);
|
|
218
|
+
if (isValidUPNArrayResult !== true) {
|
|
219
|
+
return `The following user principal names are invalid for the option 'userNames': ${isValidUPNArrayResult}.`;
|
|
220
|
+
}
|
|
149
221
|
}
|
|
150
|
-
if (
|
|
151
|
-
return
|
|
222
|
+
if (args.options.role && !this.allowedRoles.some(role => role.toLowerCase() === args.options.role.toLowerCase())) {
|
|
223
|
+
return `'${args.options.role}' is not a valid role. Allowed values are: ${this.allowedRoles.join(',')}`;
|
|
152
224
|
}
|
|
153
225
|
return true;
|
|
154
226
|
});
|
|
155
227
|
}, _EntraM365GroupUserSetCommand_initOptionSets = function _EntraM365GroupUserSetCommand_initOptionSets() {
|
|
156
|
-
this.optionSets.push({ options: ['groupId', 'teamId'] });
|
|
228
|
+
this.optionSets.push({ options: ['groupId', 'groupName', 'teamId', 'teamName'] });
|
|
229
|
+
this.optionSets.push({ options: ['userName', 'ids', 'userNames'] });
|
|
230
|
+
}, _EntraM365GroupUserSetCommand_initTypes = function _EntraM365GroupUserSetCommand_initTypes() {
|
|
231
|
+
this.types.string.push('userName', 'ids', 'userNames', 'groupId', 'groupName', 'teamId', 'teamName', 'role');
|
|
157
232
|
};
|
|
158
233
|
export default new EntraM365GroupUserSetCommand();
|
|
159
234
|
//# sourceMappingURL=m365group-user-set.js.map
|
|
@@ -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: `${this.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`,
|
|
32
|
+
url: `${this.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
|
},
|
|
@@ -30,20 +30,20 @@ class OutlookMessageGetCommand extends GraphCommand {
|
|
|
30
30
|
}
|
|
31
31
|
let requestUrl = '';
|
|
32
32
|
if (isAppOnlyAccessToken) {
|
|
33
|
-
if (!args.options.userId && !args.options.
|
|
34
|
-
throw `The option 'userId' or '
|
|
33
|
+
if (!args.options.userId && !args.options.userName) {
|
|
34
|
+
throw `The option 'userId' or 'userName' is required when retrieving an email using app only credentials`;
|
|
35
35
|
}
|
|
36
|
-
if (args.options.userId && args.options.
|
|
37
|
-
throw `Both options 'userId' and '
|
|
36
|
+
if (args.options.userId && args.options.userName) {
|
|
37
|
+
throw `Both options 'userId' and 'userName' cannot be set when retrieving an email using app only credentials`;
|
|
38
38
|
}
|
|
39
|
-
requestUrl += `users/${args.options.userId ? args.options.userId : args.options.
|
|
39
|
+
requestUrl += `users/${args.options.userId ? args.options.userId : args.options.userName}`;
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
|
-
if (args.options.userId && args.options.
|
|
43
|
-
throw `Both options 'userId' and '
|
|
42
|
+
if (args.options.userId && args.options.userName) {
|
|
43
|
+
throw `Both options 'userId' and 'userName' cannot be set when retrieving an email using delegated credentials`;
|
|
44
44
|
}
|
|
45
|
-
if (args.options.userId || args.options.
|
|
46
|
-
requestUrl += `users/${args.options.userId ? args.options.userId : args.options.
|
|
45
|
+
if (args.options.userId || args.options.userName) {
|
|
46
|
+
requestUrl += `users/${args.options.userId ? args.options.userId : args.options.userName}`;
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
requestUrl += 'me';
|
|
@@ -69,7 +69,7 @@ _OutlookMessageGetCommand_instances = new WeakSet(), _OutlookMessageGetCommand_i
|
|
|
69
69
|
this.telemetry.push((args) => {
|
|
70
70
|
Object.assign(this.telemetryProperties, {
|
|
71
71
|
userId: typeof args.options.userId !== 'undefined',
|
|
72
|
-
|
|
72
|
+
userName: typeof args.options.userName !== 'undefined'
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
75
|
}, _OutlookMessageGetCommand_initOptions = function _OutlookMessageGetCommand_initOptions() {
|
|
@@ -78,7 +78,7 @@ _OutlookMessageGetCommand_instances = new WeakSet(), _OutlookMessageGetCommand_i
|
|
|
78
78
|
}, {
|
|
79
79
|
option: '--userId [userId]'
|
|
80
80
|
}, {
|
|
81
|
-
option: '--
|
|
81
|
+
option: '--userName [userName]'
|
|
82
82
|
});
|
|
83
83
|
};
|
|
84
84
|
export default new OutlookMessageGetCommand();
|
|
@@ -3,7 +3,7 @@ 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 _PaAppExportCommand_instances, _PaAppExportCommand_initTelemetry, _PaAppExportCommand_initOptions, _PaAppExportCommand_initValidators;
|
|
6
|
+
var _PaAppExportCommand_instances, _PaAppExportCommand_initTelemetry, _PaAppExportCommand_initOptions, _PaAppExportCommand_initValidators, _PaAppExportCommand_initTypes;
|
|
7
7
|
import fs from 'fs';
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import { setTimeout } from 'timers/promises';
|
|
@@ -26,14 +26,18 @@ class PaAppExportCommand extends PowerPlatformCommand {
|
|
|
26
26
|
__classPrivateFieldGet(this, _PaAppExportCommand_instances, "m", _PaAppExportCommand_initTelemetry).call(this);
|
|
27
27
|
__classPrivateFieldGet(this, _PaAppExportCommand_instances, "m", _PaAppExportCommand_initOptions).call(this);
|
|
28
28
|
__classPrivateFieldGet(this, _PaAppExportCommand_instances, "m", _PaAppExportCommand_initValidators).call(this);
|
|
29
|
+
__classPrivateFieldGet(this, _PaAppExportCommand_instances, "m", _PaAppExportCommand_initTypes).call(this);
|
|
29
30
|
}
|
|
30
31
|
async commandAction(logger, args) {
|
|
31
32
|
try {
|
|
32
33
|
const location = await this.exportPackage(args, logger);
|
|
33
|
-
const packageLink = await this.getPackageLink(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
const packageLink = await this.getPackageLink(logger, location);
|
|
35
|
+
let filename = args.options.name;
|
|
36
|
+
if (args.options.packageDisplayName) {
|
|
37
|
+
//Replace all illegal characters from the file name
|
|
38
|
+
const illegalCharsRegEx = /[\\\/:*?"<>|]/g;
|
|
39
|
+
filename = args.options.packageDisplayName.replace(illegalCharsRegEx, '_');
|
|
40
|
+
}
|
|
37
41
|
const requestOptions = {
|
|
38
42
|
url: packageLink,
|
|
39
43
|
// Set responseType to arraybuffer, otherwise binary data will be encoded
|
|
@@ -98,7 +102,7 @@ class PaAppExportCommand extends PowerPlatformCommand {
|
|
|
98
102
|
details: {
|
|
99
103
|
creator: args.options.packageCreatedBy,
|
|
100
104
|
description: args.options.packageDescription,
|
|
101
|
-
displayName: args.options.packageDisplayName,
|
|
105
|
+
displayName: args.options.packageDisplayName || args.options.name,
|
|
102
106
|
sourceEnvironment: args.options.packageSourceEnvironment
|
|
103
107
|
},
|
|
104
108
|
resources: resources
|
|
@@ -108,7 +112,7 @@ class PaAppExportCommand extends PowerPlatformCommand {
|
|
|
108
112
|
const response = await request.post(requestOptions);
|
|
109
113
|
return response.headers.location;
|
|
110
114
|
}
|
|
111
|
-
async getPackageLink(
|
|
115
|
+
async getPackageLink(logger, location) {
|
|
112
116
|
if (this.verbose) {
|
|
113
117
|
await logger.logToStderr('Retrieving the package link and waiting on the exported package.');
|
|
114
118
|
}
|
|
@@ -172,6 +176,8 @@ _PaAppExportCommand_instances = new WeakSet(), _PaAppExportCommand_initTelemetry
|
|
|
172
176
|
}
|
|
173
177
|
return true;
|
|
174
178
|
});
|
|
179
|
+
}, _PaAppExportCommand_initTypes = function _PaAppExportCommand_initTypes() {
|
|
180
|
+
this.types.string.push('name', 'environmentName', 'packageDisplayName', 'packageDescription', 'packageCreatedBy', 'packageSourceEnvironment', 'path');
|
|
175
181
|
};
|
|
176
182
|
export default new PaAppExportCommand();
|
|
177
183
|
//# sourceMappingURL=app-export.js.map
|
|
@@ -33,9 +33,6 @@ class SpfxProjectGithubWorkflowAddCommand extends BaseProjectCommand {
|
|
|
33
33
|
if (this.projectRootPath === null) {
|
|
34
34
|
throw new CommandError(`Couldn't find project root folder`, _a.ERROR_NO_PROJECT_ROOT_FOLDER);
|
|
35
35
|
}
|
|
36
|
-
if (!args.options.overwrite) {
|
|
37
|
-
await this.warn(logger, `We recommend always using the --overwrite option and it will become the default behavior in next major release. Overwriting your sppkg file on every deployment is required to make continuous delivery of the latest version of your app which is the aim of the continuous delivery pipeline.`);
|
|
38
|
-
}
|
|
39
36
|
const solutionPackageJsonFile = path.join(this.projectRootPath, 'package.json');
|
|
40
37
|
const packageJson = fs.readFileSync(solutionPackageJsonFile, 'utf-8');
|
|
41
38
|
const solutionName = JSON.parse(packageJson).name;
|
|
@@ -81,9 +78,6 @@ class SpfxProjectGithubWorkflowAddCommand extends BaseProjectCommand {
|
|
|
81
78
|
if (options.skipFeatureDeployment) {
|
|
82
79
|
this.getDeployAction(workflow).with.SKIP_FEATURE_DEPLOYMENT = true;
|
|
83
80
|
}
|
|
84
|
-
if (options.overwrite) {
|
|
85
|
-
this.getDeployAction(workflow).with.OVERWRITE = true;
|
|
86
|
-
}
|
|
87
81
|
if (options.loginMethod === 'user') {
|
|
88
82
|
const loginAction = this.getLoginAction(workflow);
|
|
89
83
|
loginAction.with = {
|
|
@@ -125,8 +119,7 @@ _a = SpfxProjectGithubWorkflowAddCommand, _SpfxProjectGithubWorkflowAddCommand_i
|
|
|
125
119
|
manuallyTrigger: !!args.options.manuallyTrigger,
|
|
126
120
|
loginMethod: typeof args.options.loginMethod !== 'undefined',
|
|
127
121
|
scope: typeof args.options.scope !== 'undefined',
|
|
128
|
-
skipFeatureDeployment: !!args.options.skipFeatureDeployment
|
|
129
|
-
overwrite: !!args.options.overwrite
|
|
122
|
+
skipFeatureDeployment: !!args.options.skipFeatureDeployment
|
|
130
123
|
});
|
|
131
124
|
});
|
|
132
125
|
}, _SpfxProjectGithubWorkflowAddCommand_initOptions = function _SpfxProjectGithubWorkflowAddCommand_initOptions() {
|
|
@@ -146,8 +139,6 @@ _a = SpfxProjectGithubWorkflowAddCommand, _SpfxProjectGithubWorkflowAddCommand_i
|
|
|
146
139
|
option: '-u, --siteUrl [siteUrl]'
|
|
147
140
|
}, {
|
|
148
141
|
option: '--skipFeatureDeployment'
|
|
149
|
-
}, {
|
|
150
|
-
option: '--overwrite'
|
|
151
142
|
});
|
|
152
143
|
}, _SpfxProjectGithubWorkflowAddCommand_initValidators = function _SpfxProjectGithubWorkflowAddCommand_initValidators() {
|
|
153
144
|
this.validators.push(async (args) => {
|
|
@@ -5,6 +5,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
5
5
|
};
|
|
6
6
|
var _SpoFileCopyCommand_instances, _SpoFileCopyCommand_initTelemetry, _SpoFileCopyCommand_initOptions, _SpoFileCopyCommand_initValidators, _SpoFileCopyCommand_initOptionSets, _SpoFileCopyCommand_initTypes;
|
|
7
7
|
import request from '../../../../request.js';
|
|
8
|
+
import { CreateCopyJobsNameConflictBehavior, spo } from '../../../../utils/spo.js';
|
|
8
9
|
import { urlUtil } from '../../../../utils/urlUtil.js';
|
|
9
10
|
import { validation } from '../../../../utils/validation.js';
|
|
10
11
|
import SpoCommand from '../../../base/SpoCommand.js';
|
|
@@ -30,39 +31,43 @@ class SpoFileCopyCommand extends SpoCommand {
|
|
|
30
31
|
try {
|
|
31
32
|
const sourceServerRelativePath = await this.getSourcePath(logger, args.options);
|
|
32
33
|
const sourcePath = this.getAbsoluteUrl(args.options.webUrl, sourceServerRelativePath);
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
|
|
34
|
+
const destinationPath = this.getAbsoluteUrl(args.options.webUrl, args.options.targetUrl);
|
|
35
|
+
if (this.verbose) {
|
|
36
|
+
await logger.logToStderr(`Copying file '${sourceServerRelativePath}' to '${args.options.targetUrl}'...`);
|
|
37
|
+
}
|
|
38
|
+
let newName = args.options.newName;
|
|
39
|
+
// Add original file extension if not provided
|
|
40
|
+
if (newName && !newName.includes('.')) {
|
|
41
|
+
newName += sourceServerRelativePath.substring(sourceServerRelativePath.lastIndexOf('.'));
|
|
36
42
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
const copyJobResponse = await spo.createCopyJob(args.options.webUrl, sourcePath, destinationPath, {
|
|
44
|
+
nameConflictBehavior: this.getNameConflictBehaviorValue(args.options.nameConflictBehavior),
|
|
45
|
+
bypassSharedLock: !!args.options.bypassSharedLock,
|
|
46
|
+
ignoreVersionHistory: !!args.options.ignoreVersionHistory,
|
|
47
|
+
newName: newName
|
|
48
|
+
});
|
|
49
|
+
if (args.options.skipWait) {
|
|
50
|
+
return;
|
|
40
51
|
}
|
|
41
52
|
if (this.verbose) {
|
|
42
|
-
await logger.logToStderr(
|
|
53
|
+
await logger.logToStderr('Waiting for the copy job to complete...');
|
|
43
54
|
}
|
|
55
|
+
const copyJobResult = await spo.getCopyJobResult(args.options.webUrl, copyJobResponse);
|
|
56
|
+
if (this.verbose) {
|
|
57
|
+
await logger.logToStderr('Getting information about the destination file...');
|
|
58
|
+
}
|
|
59
|
+
// Get destination file data
|
|
60
|
+
const siteRelativeDestinationFolder = '/' + copyJobResult.TargetObjectSiteRelativeUrl.substring(0, copyJobResult.TargetObjectSiteRelativeUrl.lastIndexOf('/'));
|
|
61
|
+
const absoluteWebUrl = destinationPath.substring(0, destinationPath.toLowerCase().lastIndexOf(siteRelativeDestinationFolder.toLowerCase()));
|
|
44
62
|
const requestOptions = {
|
|
45
|
-
url: `${
|
|
63
|
+
url: `${absoluteWebUrl}/_api/Web/GetFileById('${copyJobResult.TargetObjectUniqueId}')`,
|
|
46
64
|
headers: {
|
|
47
65
|
accept: 'application/json;odata=nometadata'
|
|
48
66
|
},
|
|
49
|
-
responseType: 'json'
|
|
50
|
-
data: {
|
|
51
|
-
srcPath: {
|
|
52
|
-
DecodedUrl: sourcePath
|
|
53
|
-
},
|
|
54
|
-
destPath: {
|
|
55
|
-
DecodedUrl: destinationPath
|
|
56
|
-
},
|
|
57
|
-
overwrite: args.options.nameConflictBehavior === 'replace',
|
|
58
|
-
options: {
|
|
59
|
-
KeepBoth: args.options.nameConflictBehavior === 'rename',
|
|
60
|
-
ResetAuthorAndCreatedOnCopy: !!args.options.resetAuthorAndCreated,
|
|
61
|
-
ShouldBypassSharedLocks: !!args.options.bypassSharedLock
|
|
62
|
-
}
|
|
63
|
-
}
|
|
67
|
+
responseType: 'json'
|
|
64
68
|
};
|
|
65
|
-
await request.
|
|
69
|
+
const destinationFile = await request.get(requestOptions);
|
|
70
|
+
await logger.log(destinationFile);
|
|
66
71
|
}
|
|
67
72
|
catch (err) {
|
|
68
73
|
this.handleRejectedODataJsonPromise(err);
|
|
@@ -76,17 +81,30 @@ class SpoFileCopyCommand extends SpoCommand {
|
|
|
76
81
|
await logger.logToStderr(`Retrieving server-relative path for file with ID '${options.sourceId}'...`);
|
|
77
82
|
}
|
|
78
83
|
const requestOptions = {
|
|
79
|
-
url: `${options.webUrl}/_api/Web/GetFileById('${options.sourceId}')
|
|
84
|
+
url: `${options.webUrl}/_api/Web/GetFileById('${options.sourceId}')/ServerRelativePath`,
|
|
80
85
|
headers: {
|
|
81
86
|
accept: 'application/json;odata=nometadata'
|
|
82
87
|
},
|
|
83
88
|
responseType: 'json'
|
|
84
89
|
};
|
|
85
90
|
const file = await request.get(requestOptions);
|
|
86
|
-
return file.
|
|
91
|
+
return file.DecodedUrl;
|
|
92
|
+
}
|
|
93
|
+
getNameConflictBehaviorValue(nameConflictBehavior) {
|
|
94
|
+
switch (nameConflictBehavior?.toLowerCase()) {
|
|
95
|
+
case 'fail':
|
|
96
|
+
return CreateCopyJobsNameConflictBehavior.Fail;
|
|
97
|
+
case 'replace':
|
|
98
|
+
return CreateCopyJobsNameConflictBehavior.Replace;
|
|
99
|
+
case 'rename':
|
|
100
|
+
return CreateCopyJobsNameConflictBehavior.Rename;
|
|
101
|
+
default:
|
|
102
|
+
return CreateCopyJobsNameConflictBehavior.Fail;
|
|
103
|
+
}
|
|
87
104
|
}
|
|
88
105
|
getAbsoluteUrl(webUrl, url) {
|
|
89
|
-
|
|
106
|
+
const result = url.startsWith('https://') ? url : urlUtil.getAbsoluteUrl(webUrl, url);
|
|
107
|
+
return urlUtil.removeTrailingSlashes(result);
|
|
90
108
|
}
|
|
91
109
|
}
|
|
92
110
|
_SpoFileCopyCommand_instances = new WeakSet(), _SpoFileCopyCommand_initTelemetry = function _SpoFileCopyCommand_initTelemetry() {
|
|
@@ -95,9 +113,10 @@ _SpoFileCopyCommand_instances = new WeakSet(), _SpoFileCopyCommand_initTelemetry
|
|
|
95
113
|
sourceUrl: typeof args.options.sourceUrl !== 'undefined',
|
|
96
114
|
sourceId: typeof args.options.sourceId !== 'undefined',
|
|
97
115
|
newName: typeof args.options.newName !== 'undefined',
|
|
98
|
-
nameConflictBehavior: args.options.nameConflictBehavior
|
|
99
|
-
|
|
100
|
-
bypassSharedLock: !!args.options.bypassSharedLock
|
|
116
|
+
nameConflictBehavior: typeof args.options.nameConflictBehavior !== 'undefined',
|
|
117
|
+
ignoreVersionHistory: !!args.options.ignoreVersionHistory,
|
|
118
|
+
bypassSharedLock: !!args.options.bypassSharedLock,
|
|
119
|
+
skipWait: !!args.options.skipWait
|
|
101
120
|
});
|
|
102
121
|
});
|
|
103
122
|
}, _SpoFileCopyCommand_initOptions = function _SpoFileCopyCommand_initOptions() {
|
|
@@ -114,10 +133,12 @@ _SpoFileCopyCommand_instances = new WeakSet(), _SpoFileCopyCommand_initTelemetry
|
|
|
114
133
|
}, {
|
|
115
134
|
option: '--nameConflictBehavior [nameConflictBehavior]',
|
|
116
135
|
autocomplete: this.nameConflictBehaviorOptions
|
|
117
|
-
}, {
|
|
118
|
-
option: '--resetAuthorAndCreated'
|
|
119
136
|
}, {
|
|
120
137
|
option: '--bypassSharedLock'
|
|
138
|
+
}, {
|
|
139
|
+
option: '--ignoreVersionHistory'
|
|
140
|
+
}, {
|
|
141
|
+
option: '--skipWait'
|
|
121
142
|
});
|
|
122
143
|
}, _SpoFileCopyCommand_initValidators = function _SpoFileCopyCommand_initValidators() {
|
|
123
144
|
this.validators.push(async (args) => {
|
|
@@ -128,7 +149,7 @@ _SpoFileCopyCommand_instances = new WeakSet(), _SpoFileCopyCommand_initTelemetry
|
|
|
128
149
|
if (args.options.sourceId && !validation.isValidGuid(args.options.sourceId)) {
|
|
129
150
|
return `${args.options.sourceId} is not a valid GUID for sourceId.`;
|
|
130
151
|
}
|
|
131
|
-
if (args.options.nameConflictBehavior && this.nameConflictBehaviorOptions.
|
|
152
|
+
if (args.options.nameConflictBehavior && !this.nameConflictBehaviorOptions.includes(args.options.nameConflictBehavior.toLowerCase())) {
|
|
132
153
|
return `${args.options.nameConflictBehavior} is not a valid nameConflictBehavior value. Allowed values: ${this.nameConflictBehaviorOptions.join(', ')}.`;
|
|
133
154
|
}
|
|
134
155
|
return true;
|
|
@@ -137,7 +158,7 @@ _SpoFileCopyCommand_instances = new WeakSet(), _SpoFileCopyCommand_initTelemetry
|
|
|
137
158
|
this.optionSets.push({ options: ['sourceUrl', 'sourceId'] });
|
|
138
159
|
}, _SpoFileCopyCommand_initTypes = function _SpoFileCopyCommand_initTypes() {
|
|
139
160
|
this.types.string.push('webUrl', 'sourceUrl', 'sourceId', 'targetUrl', 'newName', 'nameConflictBehavior');
|
|
140
|
-
this.types.boolean.push('
|
|
161
|
+
this.types.boolean.push('bypassSharedLock', 'ignoreVersionHistory', 'skipWait');
|
|
141
162
|
};
|
|
142
163
|
export default new SpoFileCopyCommand();
|
|
143
164
|
//# sourceMappingURL=file-copy.js.map
|