@pnp/cli-microsoft365 5.0.0-beta.cdbc898 → 5.0.0-beta.d025005
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/.eslintrc.js +1 -0
- package/dist/api.d.ts +11 -0
- package/dist/api.js +17 -0
- package/dist/cli/Cli.js +19 -4
- package/dist/m365/aad/commands/app/app-add.js +43 -7
- package/dist/m365/aad/commands/user/user-list.js +7 -4
- package/dist/m365/flow/commands/flow-get.js +2 -2
- package/dist/m365/planner/AppliedCategories.js +3 -0
- package/dist/m365/planner/commands/task/task-details-get.js +39 -0
- package/dist/m365/planner/commands/task/task-get.js +37 -0
- package/dist/m365/planner/commands/task/task-set.js +357 -0
- package/dist/m365/planner/commands.js +4 -1
- package/dist/m365/spfx/commands/project/project-upgrade/rules/FN014008_CODE_launch_hostedWorkbench_type.js +62 -0
- package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.14.0-beta.4.js → upgrade-1.14.0-rc.2.js} +27 -25
- package/dist/m365/spfx/commands/project/project-upgrade.js +1 -1
- package/dist/m365/spo/commands/group/group-user-add.js +6 -6
- package/dist/m365/spo/commands/group/group-user-remove.js +100 -0
- package/dist/m365/spo/commands.js +1 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-get.js +57 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-list.js +56 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-get.js +39 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-list.js +38 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-get.js +51 -0
- package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-list.js +38 -0
- package/dist/m365/tenant/commands.js +6 -0
- package/docs/docs/cmd/aad/user/user-list.md +9 -0
- package/docs/docs/cmd/planner/task/task-details-get.md +24 -0
- package/docs/docs/cmd/planner/task/task-get.md +24 -0
- package/docs/docs/cmd/planner/task/task-set.md +99 -0
- package/docs/docs/cmd/search/externalconnection/externalconnection-add.md +3 -3
- package/docs/docs/cmd/spo/group/group-user-remove.md +39 -0
- package/docs/docs/cmd/teams/channel/channel-get.md +1 -1
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +33 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +30 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +24 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +34 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +28 -0
- package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +34 -0
- package/npm-shrinkwrap.json +808 -770
- package/package.json +19 -18
- package/dist/m365/base/AadCommand.js +0 -10
package/.eslintrc.js
CHANGED
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface CommandOutput {
|
|
2
|
+
error?: {
|
|
3
|
+
message: string;
|
|
4
|
+
code?: number;
|
|
5
|
+
}
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare function executeCommand(commandName: string, options: any): Promise<CommandOutput>;
|
|
11
|
+
export declare function on(eventName: string, listener: (...args: any[]) => void): void;
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeCommand = void 0;
|
|
4
|
+
const cli_1 = require("./cli");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
function executeCommand(commandName, options, listener) {
|
|
7
|
+
const cli = cli_1.Cli.getInstance();
|
|
8
|
+
cli.commandsFolder = path.join(__dirname, 'm365');
|
|
9
|
+
cli.commands = [];
|
|
10
|
+
cli.loadCommandFromArgs(commandName.split(' '));
|
|
11
|
+
if (cli.commands.length !== 1) {
|
|
12
|
+
return Promise.reject(`Command not found: ${commandName}`);
|
|
13
|
+
}
|
|
14
|
+
return cli_1.Cli.executeCommandWithOutput(cli.commands[0].command, { options: options !== null && options !== void 0 ? options : {} }, listener);
|
|
15
|
+
}
|
|
16
|
+
exports.executeCommand = executeCommand;
|
|
17
|
+
//# sourceMappingURL=api.js.map
|
package/dist/cli/Cli.js
CHANGED
|
@@ -189,23 +189,38 @@ class Cli {
|
|
|
189
189
|
});
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
|
-
static executeCommandWithOutput(command, args) {
|
|
192
|
+
static executeCommandWithOutput(command, args, listener) {
|
|
193
193
|
return new Promise((resolve, reject) => {
|
|
194
194
|
const log = [];
|
|
195
195
|
const logErr = [];
|
|
196
196
|
const logger = {
|
|
197
197
|
log: (message) => {
|
|
198
|
-
|
|
198
|
+
const formattedMessage = Cli.formatOutput(message, args.options);
|
|
199
|
+
if (listener && listener.stdout) {
|
|
200
|
+
listener.stdout(formattedMessage);
|
|
201
|
+
}
|
|
202
|
+
log.push(formattedMessage);
|
|
199
203
|
},
|
|
200
204
|
logRaw: (message) => {
|
|
201
|
-
|
|
205
|
+
const formattedMessage = Cli.formatOutput(message, args.options);
|
|
206
|
+
if (listener && listener.stdout) {
|
|
207
|
+
listener.stdout(formattedMessage);
|
|
208
|
+
}
|
|
209
|
+
log.push(formattedMessage);
|
|
202
210
|
},
|
|
203
211
|
logToStderr: (message) => {
|
|
212
|
+
if (listener && listener.stderr) {
|
|
213
|
+
listener.stderr(message);
|
|
214
|
+
}
|
|
204
215
|
logErr.push(message);
|
|
205
216
|
}
|
|
206
217
|
};
|
|
207
218
|
if (args.options.debug) {
|
|
208
|
-
|
|
219
|
+
const message = `Executing command ${command.name} with options ${JSON.stringify(args)}`;
|
|
220
|
+
if (listener && listener.stderr) {
|
|
221
|
+
listener.stderr(message);
|
|
222
|
+
}
|
|
223
|
+
logErr.push(message);
|
|
209
224
|
}
|
|
210
225
|
// store the current command name, if any and set the name to the name of
|
|
211
226
|
// the command to execute
|
|
@@ -105,21 +105,49 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
105
105
|
if (!args.options.manifest) {
|
|
106
106
|
return Promise.resolve(appInfo);
|
|
107
107
|
}
|
|
108
|
-
const
|
|
108
|
+
const v2Manifest = JSON.parse(args.options.manifest);
|
|
109
109
|
// remove properties that might be coming from the original app that was
|
|
110
110
|
// used to create the manifest and which can't be updated
|
|
111
|
-
delete
|
|
112
|
-
delete
|
|
113
|
-
delete
|
|
111
|
+
delete v2Manifest.id;
|
|
112
|
+
delete v2Manifest.appId;
|
|
113
|
+
delete v2Manifest.publisherDomain;
|
|
114
114
|
// Azure Portal returns v2 manifest whereas the Graph API expects a v1.6
|
|
115
|
-
const
|
|
115
|
+
const graphManifest = this.transformManifest(v2Manifest);
|
|
116
116
|
const updateAppRequestOptions = {
|
|
117
117
|
url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
|
|
118
118
|
headers: {
|
|
119
119
|
'content-type': 'application/json'
|
|
120
120
|
},
|
|
121
121
|
responseType: 'json',
|
|
122
|
-
data:
|
|
122
|
+
data: graphManifest
|
|
123
|
+
};
|
|
124
|
+
return request_1.default
|
|
125
|
+
.patch(updateAppRequestOptions)
|
|
126
|
+
.then(_ => this.updatePreAuthorizedAppsFromManifest(v2Manifest, appInfo))
|
|
127
|
+
.then(_ => Promise.resolve(appInfo));
|
|
128
|
+
}
|
|
129
|
+
updatePreAuthorizedAppsFromManifest(manifest, appInfo) {
|
|
130
|
+
if (!manifest ||
|
|
131
|
+
!manifest.preAuthorizedApplications ||
|
|
132
|
+
manifest.preAuthorizedApplications.length === 0) {
|
|
133
|
+
return Promise.resolve(appInfo);
|
|
134
|
+
}
|
|
135
|
+
const graphManifest = {
|
|
136
|
+
api: {
|
|
137
|
+
preAuthorizedApplications: manifest.preAuthorizedApplications
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
graphManifest.api.preAuthorizedApplications.forEach((p) => {
|
|
141
|
+
p.delegatedPermissionIds = p.permissionIds;
|
|
142
|
+
delete p.permissionIds;
|
|
143
|
+
});
|
|
144
|
+
const updateAppRequestOptions = {
|
|
145
|
+
url: `${this.resource}/v1.0/myorganization/applications/${appInfo.id}`,
|
|
146
|
+
headers: {
|
|
147
|
+
'content-type': 'application/json'
|
|
148
|
+
},
|
|
149
|
+
responseType: 'json',
|
|
150
|
+
data: graphManifest
|
|
123
151
|
};
|
|
124
152
|
return request_1.default
|
|
125
153
|
.patch(updateAppRequestOptions)
|
|
@@ -180,8 +208,16 @@ class AadAppAddCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
180
208
|
delete graphManifest.oauth2AllowIdTokenImplicitFlow;
|
|
181
209
|
graphManifest.api.oauth2PermissionScopes = v2Manifest.oauth2Permissions;
|
|
182
210
|
delete graphManifest.oauth2Permissions;
|
|
211
|
+
if (graphManifest.api.oauth2PermissionScopes) {
|
|
212
|
+
graphManifest.api.oauth2PermissionScopes.forEach((scope) => {
|
|
213
|
+
delete scope.lang;
|
|
214
|
+
delete scope.origin;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
183
217
|
delete graphManifest.oauth2RequiredPostResponse;
|
|
184
|
-
|
|
218
|
+
// MS Graph doesn't support creating OAuth2 permissions and pre-authorized
|
|
219
|
+
// apps in one request. This is why we need to remove it here and do it in
|
|
220
|
+
// the next request
|
|
185
221
|
delete graphManifest.preAuthorizedApplications;
|
|
186
222
|
if (v2Manifest.replyUrlsWithType) {
|
|
187
223
|
v2Manifest.replyUrlsWithType.forEach((urlWithType) => {
|
|
@@ -15,6 +15,7 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
15
15
|
getTelemetryProperties(args) {
|
|
16
16
|
const telemetryProps = super.getTelemetryProperties(args);
|
|
17
17
|
telemetryProps.properties = args.options.properties;
|
|
18
|
+
telemetryProps.deleted = typeof args.options.deleted !== 'undefined';
|
|
18
19
|
return telemetryProps;
|
|
19
20
|
}
|
|
20
21
|
commandAction(logger, args, cb) {
|
|
@@ -22,7 +23,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
22
23
|
args.options.properties.split(',').map(p => p.trim()) :
|
|
23
24
|
['userPrincipalName', 'displayName'];
|
|
24
25
|
const filter = this.getFilter(args.options);
|
|
25
|
-
const
|
|
26
|
+
const endpoint = args.options.deleted ? 'directory/deletedItems/microsoft.graph.user' : 'users';
|
|
27
|
+
const url = `${this.resource}/v1.0/${endpoint}?$select=${properties.join(',')}${(filter.length > 0 ? '&' + filter : '')}&$top=100`;
|
|
26
28
|
this
|
|
27
29
|
.getAllItems(url, logger, true)
|
|
28
30
|
.then(() => {
|
|
@@ -35,6 +37,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
35
37
|
const excludeOptions = [
|
|
36
38
|
'properties',
|
|
37
39
|
'p',
|
|
40
|
+
'deleted',
|
|
41
|
+
'd',
|
|
38
42
|
'debug',
|
|
39
43
|
'verbose',
|
|
40
44
|
'output',
|
|
@@ -55,9 +59,8 @@ class AadUserListCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
|
55
59
|
}
|
|
56
60
|
options() {
|
|
57
61
|
const options = [
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
}
|
|
62
|
+
{ option: '-p, --properties [properties]' },
|
|
63
|
+
{ option: '-d, --deleted' }
|
|
61
64
|
];
|
|
62
65
|
const parentOptions = super.options();
|
|
63
66
|
return options.concat(parentOptions);
|
|
@@ -29,8 +29,8 @@ class FlowGetCommand extends AzmgmtCommand_1.default {
|
|
|
29
29
|
.then((res) => {
|
|
30
30
|
res.displayName = res.properties.displayName;
|
|
31
31
|
res.description = res.properties.definitionSummary.description || '';
|
|
32
|
-
res.triggers =
|
|
33
|
-
res.actions =
|
|
32
|
+
res.triggers = res.properties.definitionSummary.triggers.map((t) => (t.type + (t.kind ? "-" + t.kind : ''))).join(', ');
|
|
33
|
+
res.actions = res.properties.definitionSummary.actions.map((a) => (a.type + (a.swaggerOperationId ? "-" + a.swaggerOperationId : ''))).join(', ');
|
|
34
34
|
logger.log(res);
|
|
35
35
|
cb();
|
|
36
36
|
}, (rawRes) => this.handleRejectedODataJsonPromise(rawRes, logger, cb));
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const request_1 = require("../../../../request");
|
|
4
|
+
const GraphItemsListCommand_1 = require("../../../base/GraphItemsListCommand");
|
|
5
|
+
const commands_1 = require("../../commands");
|
|
6
|
+
class PlannerTaskDetailsGetCommand extends GraphItemsListCommand_1.GraphItemsListCommand {
|
|
7
|
+
get name() {
|
|
8
|
+
return commands_1.default.TASK_DETAILS_GET;
|
|
9
|
+
}
|
|
10
|
+
get description() {
|
|
11
|
+
return 'Retrieve the details of the specified planner task';
|
|
12
|
+
}
|
|
13
|
+
commandAction(logger, args, cb) {
|
|
14
|
+
const requestOptions = {
|
|
15
|
+
url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.taskId)}/details`,
|
|
16
|
+
headers: {
|
|
17
|
+
accept: 'application/json;odata.metadata=none'
|
|
18
|
+
},
|
|
19
|
+
responseType: 'json'
|
|
20
|
+
};
|
|
21
|
+
request_1.default
|
|
22
|
+
.get(requestOptions)
|
|
23
|
+
.then((res) => {
|
|
24
|
+
logger.log(res);
|
|
25
|
+
cb();
|
|
26
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
27
|
+
}
|
|
28
|
+
options() {
|
|
29
|
+
const options = [
|
|
30
|
+
{
|
|
31
|
+
option: '-i, --taskId <taskId>'
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
const parentOptions = super.options();
|
|
35
|
+
return options.concat(parentOptions);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
module.exports = new PlannerTaskDetailsGetCommand();
|
|
39
|
+
//# sourceMappingURL=task-details-get.js.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const request_1 = require("../../../../request");
|
|
4
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
5
|
+
const commands_1 = require("../../commands");
|
|
6
|
+
class PlannerTaskGetCommand extends GraphCommand_1.default {
|
|
7
|
+
get name() {
|
|
8
|
+
return commands_1.default.TASK_GET;
|
|
9
|
+
}
|
|
10
|
+
get description() {
|
|
11
|
+
return 'Retrieve the the specified planner task';
|
|
12
|
+
}
|
|
13
|
+
commandAction(logger, args, cb) {
|
|
14
|
+
const requestOptions = {
|
|
15
|
+
url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.id)}`,
|
|
16
|
+
headers: {
|
|
17
|
+
accept: 'application/json;odata.metadata=none'
|
|
18
|
+
},
|
|
19
|
+
responseType: 'json'
|
|
20
|
+
};
|
|
21
|
+
request_1.default
|
|
22
|
+
.get(requestOptions)
|
|
23
|
+
.then((res) => {
|
|
24
|
+
logger.log(res);
|
|
25
|
+
cb();
|
|
26
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
27
|
+
}
|
|
28
|
+
options() {
|
|
29
|
+
const options = [
|
|
30
|
+
{ option: '-i, --id <id>' }
|
|
31
|
+
];
|
|
32
|
+
const parentOptions = super.options();
|
|
33
|
+
return options.concat(parentOptions);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
module.exports = new PlannerTaskGetCommand();
|
|
37
|
+
//# sourceMappingURL=task-get.js.map
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const request_1 = require("../../../../request");
|
|
4
|
+
const Utils_1 = require("../../../../Utils");
|
|
5
|
+
const GraphCommand_1 = require("../../../base/GraphCommand");
|
|
6
|
+
const commands_1 = require("../../commands");
|
|
7
|
+
class PlannerTaskSetCommand extends GraphCommand_1.default {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.allowedAppliedCategories = ['category1', 'category2', 'category3', 'category4', 'category5', 'category6'];
|
|
11
|
+
}
|
|
12
|
+
get name() {
|
|
13
|
+
return commands_1.default.TASK_SET;
|
|
14
|
+
}
|
|
15
|
+
get description() {
|
|
16
|
+
return 'Updates a Microsoft Planner Task';
|
|
17
|
+
}
|
|
18
|
+
getTelemetryProperties(args) {
|
|
19
|
+
const telemetryProps = super.getTelemetryProperties(args);
|
|
20
|
+
telemetryProps.title = typeof args.options.title !== 'undefined';
|
|
21
|
+
telemetryProps.planId = typeof args.options.planId !== 'undefined';
|
|
22
|
+
telemetryProps.planName = typeof args.options.planName !== 'undefined';
|
|
23
|
+
telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
|
|
24
|
+
telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
|
|
25
|
+
telemetryProps.bucketId = typeof args.options.bucketId !== 'undefined';
|
|
26
|
+
telemetryProps.bucketName = typeof args.options.bucketName !== 'undefined';
|
|
27
|
+
telemetryProps.startDateTime = typeof args.options.startDateTime !== 'undefined';
|
|
28
|
+
telemetryProps.dueDateTime = typeof args.options.dueDateTime !== 'undefined';
|
|
29
|
+
telemetryProps.percentComplete = typeof args.options.percentComplete !== 'undefined';
|
|
30
|
+
telemetryProps.assignedToUserIds = typeof args.options.assignedToUserIds !== 'undefined';
|
|
31
|
+
telemetryProps.assignedToUserNames = typeof args.options.assignedToUserNames !== 'undefined';
|
|
32
|
+
telemetryProps.assigneePriority = typeof args.options.assigneePriority !== 'undefined';
|
|
33
|
+
telemetryProps.description = typeof args.options.description !== 'undefined';
|
|
34
|
+
telemetryProps.appliedCategories = typeof args.options.appliedCategories !== 'undefined';
|
|
35
|
+
telemetryProps.orderHint = typeof args.options.orderHint !== 'undefined';
|
|
36
|
+
return telemetryProps;
|
|
37
|
+
}
|
|
38
|
+
commandAction(logger, args, cb) {
|
|
39
|
+
this
|
|
40
|
+
.getBucketId(args.options)
|
|
41
|
+
.then(bucketId => {
|
|
42
|
+
this.bucketId = bucketId;
|
|
43
|
+
return this.generateUserAssignments(args.options);
|
|
44
|
+
})
|
|
45
|
+
.then(resultAssignments => {
|
|
46
|
+
this.assignments = resultAssignments;
|
|
47
|
+
return this.getTaskEtag(args.options.id);
|
|
48
|
+
})
|
|
49
|
+
.then(etag => {
|
|
50
|
+
const appliedCategories = this.generateAppliedCategories(args.options);
|
|
51
|
+
const data = this.mapRequestBody(args.options, appliedCategories);
|
|
52
|
+
const requestOptions = {
|
|
53
|
+
url: `${this.resource}/v1.0/planner/tasks/${args.options.id}`,
|
|
54
|
+
headers: {
|
|
55
|
+
'accept': 'application/json;odata.metadata=none',
|
|
56
|
+
'If-Match': etag,
|
|
57
|
+
'Prefer': 'return=representation'
|
|
58
|
+
},
|
|
59
|
+
responseType: 'json',
|
|
60
|
+
data: data
|
|
61
|
+
};
|
|
62
|
+
return request_1.default.patch(requestOptions);
|
|
63
|
+
})
|
|
64
|
+
.then(newTask => this.updateTaskDetails(args.options, newTask))
|
|
65
|
+
.then((res) => {
|
|
66
|
+
logger.log(res);
|
|
67
|
+
cb();
|
|
68
|
+
}, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
|
|
69
|
+
}
|
|
70
|
+
updateTaskDetails(options, newTask) {
|
|
71
|
+
if (!options.description) {
|
|
72
|
+
return Promise.resolve(newTask);
|
|
73
|
+
}
|
|
74
|
+
const taskId = newTask.id;
|
|
75
|
+
return this
|
|
76
|
+
.getTaskDetailsEtag(taskId)
|
|
77
|
+
.then(etag => {
|
|
78
|
+
const requestOptionsTaskDetails = {
|
|
79
|
+
url: `${this.resource}/v1.0/planner/tasks/${taskId}/details`,
|
|
80
|
+
headers: {
|
|
81
|
+
'accept': 'application/json;odata.metadata=none',
|
|
82
|
+
'If-Match': etag,
|
|
83
|
+
'Prefer': 'return=representation'
|
|
84
|
+
},
|
|
85
|
+
responseType: 'json',
|
|
86
|
+
data: {
|
|
87
|
+
description: options.description
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return request_1.default.patch(requestOptionsTaskDetails);
|
|
91
|
+
})
|
|
92
|
+
.then(taskDetails => {
|
|
93
|
+
return Object.assign(Object.assign({}, newTask), taskDetails);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
getTaskDetailsEtag(taskId) {
|
|
97
|
+
const requestOptions = {
|
|
98
|
+
url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(taskId)}/details`,
|
|
99
|
+
headers: {
|
|
100
|
+
accept: 'application/json'
|
|
101
|
+
},
|
|
102
|
+
responseType: 'json'
|
|
103
|
+
};
|
|
104
|
+
return request_1.default
|
|
105
|
+
.get(requestOptions)
|
|
106
|
+
.then((response) => {
|
|
107
|
+
const etag = response ? response['@odata.etag'] : undefined;
|
|
108
|
+
if (!etag) {
|
|
109
|
+
return Promise.reject(`Error fetching task details`);
|
|
110
|
+
}
|
|
111
|
+
return Promise.resolve(etag);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
getTaskEtag(taskId) {
|
|
115
|
+
const requestOptions = {
|
|
116
|
+
url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(taskId)}`,
|
|
117
|
+
headers: {
|
|
118
|
+
accept: 'application/json'
|
|
119
|
+
},
|
|
120
|
+
responseType: 'json'
|
|
121
|
+
};
|
|
122
|
+
return request_1.default
|
|
123
|
+
.get(requestOptions)
|
|
124
|
+
.then((response) => {
|
|
125
|
+
const etag = response ? response['@odata.etag'] : undefined;
|
|
126
|
+
if (!etag) {
|
|
127
|
+
return Promise.reject(`Error fetching task`);
|
|
128
|
+
}
|
|
129
|
+
return Promise.resolve(etag);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
generateAppliedCategories(options) {
|
|
133
|
+
if (!options.appliedCategories) {
|
|
134
|
+
return {};
|
|
135
|
+
}
|
|
136
|
+
const categories = {};
|
|
137
|
+
options.appliedCategories.toLocaleLowerCase().split(',').forEach(x => categories[x] = true);
|
|
138
|
+
return categories;
|
|
139
|
+
}
|
|
140
|
+
generateUserAssignments(options) {
|
|
141
|
+
const assignments = {};
|
|
142
|
+
if (!options.assignedToUserIds && !options.assignedToUserNames) {
|
|
143
|
+
return Promise.resolve(assignments);
|
|
144
|
+
}
|
|
145
|
+
return this
|
|
146
|
+
.getUserIds(options)
|
|
147
|
+
.then((userIds) => {
|
|
148
|
+
userIds.forEach(x => assignments[x] = {
|
|
149
|
+
'@odata.type': '#microsoft.graph.plannerAssignment',
|
|
150
|
+
orderHint: ' !'
|
|
151
|
+
});
|
|
152
|
+
return Promise.resolve(assignments);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
getUserIds(options) {
|
|
156
|
+
if (options.assignedToUserIds) {
|
|
157
|
+
return Promise.resolve(options.assignedToUserIds.split(',').map(o => o.trim()));
|
|
158
|
+
}
|
|
159
|
+
// Hitting this section means assignedToUserNames won't be undefined
|
|
160
|
+
const userNames = options.assignedToUserNames;
|
|
161
|
+
const userArr = userNames.split(',').map(o => o.trim());
|
|
162
|
+
let userIds = [];
|
|
163
|
+
const promises = userArr.map(user => {
|
|
164
|
+
const requestOptions = {
|
|
165
|
+
url: `${this.resource}/v1.0/users?$filter=userPrincipalName eq '${Utils_1.default.encodeQueryParameter(user)}'&$select=id,userPrincipalName`,
|
|
166
|
+
headers: {
|
|
167
|
+
'accept ': 'application/json;odata.metadata=none'
|
|
168
|
+
},
|
|
169
|
+
responseType: 'json'
|
|
170
|
+
};
|
|
171
|
+
return request_1.default.get(requestOptions);
|
|
172
|
+
});
|
|
173
|
+
return Promise
|
|
174
|
+
.all(promises)
|
|
175
|
+
.then((usersRes) => {
|
|
176
|
+
let userUpns = [];
|
|
177
|
+
userUpns = usersRes.map(res => { var _a; return (_a = res.value[0]) === null || _a === void 0 ? void 0 : _a.userPrincipalName; });
|
|
178
|
+
userIds = usersRes.map(res => { var _a; return (_a = res.value[0]) === null || _a === void 0 ? void 0 : _a.id; });
|
|
179
|
+
// Find the members where no graph response was found
|
|
180
|
+
const invalidUsers = userArr.filter(user => !userUpns.some((upn) => (upn === null || upn === void 0 ? void 0 : upn.toLowerCase()) === user.toLowerCase()));
|
|
181
|
+
if (invalidUsers && invalidUsers.length > 0) {
|
|
182
|
+
return Promise.reject(`Cannot proceed with planner task update. The following users provided are invalid : ${invalidUsers.join(',')}`);
|
|
183
|
+
}
|
|
184
|
+
return Promise.resolve(userIds);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
getBucketId(options) {
|
|
188
|
+
if (options.bucketId) {
|
|
189
|
+
return Promise.resolve(options.bucketId);
|
|
190
|
+
}
|
|
191
|
+
if (!options.bucketName) {
|
|
192
|
+
return Promise.resolve(undefined);
|
|
193
|
+
}
|
|
194
|
+
return this
|
|
195
|
+
.getPlanId(options)
|
|
196
|
+
.then(planId => {
|
|
197
|
+
const requestOptions = {
|
|
198
|
+
url: `${this.resource}/v1.0/planner/plans/${planId}/buckets?$select=id,name`,
|
|
199
|
+
headers: {
|
|
200
|
+
accept: 'application/json;odata.metadata=none'
|
|
201
|
+
},
|
|
202
|
+
responseType: 'json'
|
|
203
|
+
};
|
|
204
|
+
return request_1.default.get(requestOptions);
|
|
205
|
+
})
|
|
206
|
+
.then((response) => {
|
|
207
|
+
const bucket = response.value.find(val => val.name === options.bucketName);
|
|
208
|
+
if (!bucket) {
|
|
209
|
+
return Promise.reject(`The specified bucket does not exist`);
|
|
210
|
+
}
|
|
211
|
+
return Promise.resolve(bucket.id);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
getPlanId(options) {
|
|
215
|
+
if (options.planId) {
|
|
216
|
+
return Promise.resolve(options.planId);
|
|
217
|
+
}
|
|
218
|
+
return this
|
|
219
|
+
.getGroupId(options)
|
|
220
|
+
.then((groupId) => {
|
|
221
|
+
const requestOptions = {
|
|
222
|
+
url: `${this.resource}/v1.0/planner/plans?$filter=(owner eq '${groupId}')&$select=id,title`,
|
|
223
|
+
headers: {
|
|
224
|
+
accept: 'application/json;odata.metadata=none'
|
|
225
|
+
},
|
|
226
|
+
responseType: 'json'
|
|
227
|
+
};
|
|
228
|
+
return request_1.default.get(requestOptions);
|
|
229
|
+
})
|
|
230
|
+
.then((response) => {
|
|
231
|
+
const plan = response.value.find(val => val.title === options.planName);
|
|
232
|
+
if (!plan) {
|
|
233
|
+
return Promise.reject(`The specified plan does not exist`);
|
|
234
|
+
}
|
|
235
|
+
return Promise.resolve(plan.id);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
getGroupId(options) {
|
|
239
|
+
if (options.ownerGroupId) {
|
|
240
|
+
return Promise.resolve(options.ownerGroupId);
|
|
241
|
+
}
|
|
242
|
+
const requestOptions = {
|
|
243
|
+
url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(options.ownerGroupName)}'&$select=id`,
|
|
244
|
+
headers: {
|
|
245
|
+
accept: 'application/json;odata.metadata=none'
|
|
246
|
+
},
|
|
247
|
+
responseType: 'json'
|
|
248
|
+
};
|
|
249
|
+
return request_1.default
|
|
250
|
+
.get(requestOptions)
|
|
251
|
+
.then(response => {
|
|
252
|
+
const group = response.value[0];
|
|
253
|
+
if (!group) {
|
|
254
|
+
return Promise.reject(`The specified owner group does not exist`);
|
|
255
|
+
}
|
|
256
|
+
return Promise.resolve(group.id);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
mapRequestBody(options, appliedCategories) {
|
|
260
|
+
const requestBody = {};
|
|
261
|
+
if (options.title) {
|
|
262
|
+
requestBody.title = options.title;
|
|
263
|
+
}
|
|
264
|
+
if (this.bucketId) {
|
|
265
|
+
requestBody.bucketId = this.bucketId;
|
|
266
|
+
}
|
|
267
|
+
if (options.startDateTime) {
|
|
268
|
+
requestBody.startDateTime = options.startDateTime;
|
|
269
|
+
}
|
|
270
|
+
if (options.dueDateTime) {
|
|
271
|
+
requestBody.dueDateTime = options.dueDateTime;
|
|
272
|
+
}
|
|
273
|
+
if (options.percentComplete) {
|
|
274
|
+
requestBody.percentComplete = options.percentComplete;
|
|
275
|
+
}
|
|
276
|
+
if (this.assignments && Object.keys(this.assignments).length > 0) {
|
|
277
|
+
requestBody.assignments = this.assignments;
|
|
278
|
+
}
|
|
279
|
+
if (options.assigneePriority) {
|
|
280
|
+
requestBody.assigneePriority = options.assigneePriority;
|
|
281
|
+
}
|
|
282
|
+
if (appliedCategories && Object.keys(appliedCategories).length > 0) {
|
|
283
|
+
requestBody.appliedCategories = appliedCategories;
|
|
284
|
+
}
|
|
285
|
+
if (options.orderHint) {
|
|
286
|
+
requestBody.orderHint = options.orderHint;
|
|
287
|
+
}
|
|
288
|
+
return requestBody;
|
|
289
|
+
}
|
|
290
|
+
options() {
|
|
291
|
+
const options = [
|
|
292
|
+
{ option: '-i, --id <id>' },
|
|
293
|
+
{ option: '-t, --title [title]' },
|
|
294
|
+
{ option: '--planId [planId]' },
|
|
295
|
+
{ option: '--planName [planName]' },
|
|
296
|
+
{ option: '--ownerGroupId [ownerGroupId]' },
|
|
297
|
+
{ option: '--ownerGroupName [ownerGroupName]' },
|
|
298
|
+
{ option: '--bucketId [bucketId]' },
|
|
299
|
+
{ option: '--bucketName [bucketName]' },
|
|
300
|
+
{ option: '--startDateTime [startDateTime]' },
|
|
301
|
+
{ option: '--dueDateTime [dueDateTime]' },
|
|
302
|
+
{ option: '--percentComplete [percentComplete]' },
|
|
303
|
+
{ option: '--assignedToUserIds [assignedToUserIds]' },
|
|
304
|
+
{ option: '--assignedToUserNames [assignedToUserNames]' },
|
|
305
|
+
{ option: '--assigneePriority [assigneePriority]' },
|
|
306
|
+
{ option: '--description [description]' },
|
|
307
|
+
{ option: '--appliedCategories [appliedCategories]' },
|
|
308
|
+
{ option: '--orderHint [orderHint]' }
|
|
309
|
+
];
|
|
310
|
+
const parentOptions = super.options();
|
|
311
|
+
return options.concat(parentOptions);
|
|
312
|
+
}
|
|
313
|
+
validate(args) {
|
|
314
|
+
if (args.options.bucketId && args.options.bucketName) {
|
|
315
|
+
return 'Specify either bucketId or bucketName but not both';
|
|
316
|
+
}
|
|
317
|
+
if (args.options.bucketName && !args.options.planId && !args.options.planName) {
|
|
318
|
+
return 'Specify either planId or planName when using bucketName';
|
|
319
|
+
}
|
|
320
|
+
if (args.options.bucketName && args.options.planId && args.options.planName) {
|
|
321
|
+
return 'Specify either planId or planName when using bucketName but not both';
|
|
322
|
+
}
|
|
323
|
+
if (args.options.planName && !args.options.ownerGroupId && !args.options.ownerGroupName) {
|
|
324
|
+
return 'Specify either ownerGroupId or ownerGroupName when using planName';
|
|
325
|
+
}
|
|
326
|
+
if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
|
|
327
|
+
return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
|
|
328
|
+
}
|
|
329
|
+
if (args.options.ownerGroupId && !Utils_1.default.isValidGuid(args.options.ownerGroupId)) {
|
|
330
|
+
return `${args.options.ownerGroupId} is not a valid GUID`;
|
|
331
|
+
}
|
|
332
|
+
if (args.options.startDateTime && !Utils_1.default.isValidISODateTime(args.options.startDateTime)) {
|
|
333
|
+
return 'The startDateTime is not a valid ISO date string';
|
|
334
|
+
}
|
|
335
|
+
if (args.options.dueDateTime && !Utils_1.default.isValidISODateTime(args.options.dueDateTime)) {
|
|
336
|
+
return 'The dueDateTime is not a valid ISO date string';
|
|
337
|
+
}
|
|
338
|
+
if (args.options.percentComplete && isNaN(args.options.percentComplete)) {
|
|
339
|
+
return `percentComplete is not a number`;
|
|
340
|
+
}
|
|
341
|
+
if (args.options.percentComplete && (args.options.percentComplete < 0 || args.options.percentComplete > 100)) {
|
|
342
|
+
return `percentComplete should be between 0 and 100`;
|
|
343
|
+
}
|
|
344
|
+
if (args.options.assignedToUserIds && !Utils_1.default.isValidGuidArray(args.options.assignedToUserIds.split(','))) {
|
|
345
|
+
return 'assignedToUserIds contains invalid GUID';
|
|
346
|
+
}
|
|
347
|
+
if (args.options.assignedToUserIds && args.options.assignedToUserNames) {
|
|
348
|
+
return 'Specify either assignedToUserIds or assignedToUserNames but not both';
|
|
349
|
+
}
|
|
350
|
+
if (args.options.appliedCategories && args.options.appliedCategories.split(',').filter(category => this.allowedAppliedCategories.indexOf(category.toLocaleLowerCase()) < 0).length !== 0) {
|
|
351
|
+
return 'The appliedCategories contains invalid value. Specify either category1, category2, category3, category4, category5 and/or category6 as properties';
|
|
352
|
+
}
|
|
353
|
+
return true;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
module.exports = new PlannerTaskSetCommand();
|
|
357
|
+
//# sourceMappingURL=task-set.js.map
|
|
@@ -8,6 +8,9 @@ exports.default = {
|
|
|
8
8
|
PLAN_GET: `${prefix} plan get`,
|
|
9
9
|
PLAN_LIST: `${prefix} plan list`,
|
|
10
10
|
TASK_ADD: `${prefix} task add`,
|
|
11
|
-
|
|
11
|
+
TASK_DETAILS_GET: `${prefix} task details get`,
|
|
12
|
+
TASK_GET: `${prefix} task get`,
|
|
13
|
+
TASK_LIST: `${prefix} task list`,
|
|
14
|
+
TASK_SET: `${prefix} task set`
|
|
12
15
|
};
|
|
13
16
|
//# sourceMappingURL=commands.js.map
|