@pnp/cli-microsoft365 5.4.0 → 5.5.0-beta.10c7ae2

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.
Files changed (63) hide show
  1. package/dist/Auth.js +1 -1
  2. package/dist/Command.js +22 -0
  3. package/dist/m365/flow/commands/flow-export.js +3 -0
  4. package/dist/m365/planner/commands/bucket/bucket-add.js +17 -9
  5. package/dist/m365/planner/commands/bucket/bucket-get.js +19 -11
  6. package/dist/m365/planner/commands/bucket/bucket-list.js +17 -9
  7. package/dist/m365/planner/commands/bucket/bucket-remove.js +19 -11
  8. package/dist/m365/planner/commands/bucket/bucket-set.js +19 -11
  9. package/dist/m365/planner/commands/plan/plan-get.js +58 -17
  10. package/dist/m365/planner/commands/plan/plan-remove.js +141 -0
  11. package/dist/m365/planner/commands/task/task-add.js +16 -16
  12. package/dist/m365/planner/commands/task/task-get.js +14 -9
  13. package/dist/m365/planner/commands/task/task-list.js +19 -11
  14. package/dist/m365/planner/commands/task/task-reference-add.js +1 -7
  15. package/dist/m365/planner/commands/task/task-reference-remove.js +11 -14
  16. package/dist/m365/planner/commands/task/task-remove.js +4 -19
  17. package/dist/m365/planner/commands/task/task-set.js +17 -23
  18. package/dist/m365/planner/commands/tenant/tenant-settings-set.js +95 -0
  19. package/dist/m365/planner/commands.js +3 -1
  20. package/dist/m365/search/commands/externalconnection/externalconnection-get.js +69 -0
  21. package/dist/m365/search/commands.js +1 -0
  22. package/dist/m365/spfx/commands/project/project-doctor/doctor-1.15.0.js +23 -0
  23. package/dist/m365/spfx/commands/project/project-doctor.js +2 -1
  24. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015008_FILE_eslintrc_js.js +7 -0
  25. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.15.0.js +6 -4
  26. package/dist/m365/spfx/commands/spfx-doctor.js +15 -0
  27. package/dist/m365/spo/base-permissions.js +9 -0
  28. package/dist/m365/spo/commands/hubsite/hubsite-get.js +62 -12
  29. package/dist/m365/spo/commands/listitem/listitem-set.js +2 -2
  30. package/dist/m365/spo/commands/roledefinition/RoleDefinition.js +3 -0
  31. package/dist/m365/spo/commands/roledefinition/RoleType.js +16 -0
  32. package/dist/m365/spo/commands/roledefinition/roledefinition-get.js +59 -0
  33. package/dist/m365/spo/commands.js +1 -0
  34. package/dist/m365/teams/commands/cache/cache-remove.js +155 -0
  35. package/dist/m365/teams/commands.js +1 -0
  36. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-health-get.js +1 -9
  37. package/dist/utils/accessToken.js +18 -0
  38. package/dist/utils/planner.js +9 -8
  39. package/dist/utils/validation.js +5 -1
  40. package/docs/docs/cmd/aad/user/user-get.md +12 -0
  41. package/docs/docs/cmd/planner/bucket/bucket-add.md +9 -6
  42. package/docs/docs/cmd/planner/bucket/bucket-get.md +10 -7
  43. package/docs/docs/cmd/planner/bucket/bucket-list.md +8 -5
  44. package/docs/docs/cmd/planner/bucket/bucket-remove.md +8 -5
  45. package/docs/docs/cmd/planner/bucket/bucket-set.md +9 -6
  46. package/docs/docs/cmd/planner/plan/plan-get.md +14 -2
  47. package/docs/docs/cmd/planner/plan/plan-remove.md +48 -0
  48. package/docs/docs/cmd/planner/task/task-add.md +11 -8
  49. package/docs/docs/cmd/planner/task/task-get.md +11 -8
  50. package/docs/docs/cmd/planner/task/task-list.md +9 -6
  51. package/docs/docs/cmd/planner/task/task-set.md +9 -6
  52. package/docs/docs/cmd/planner/tenant/tenant-settings-set.md +56 -0
  53. package/docs/docs/cmd/search/externalconnection/externalconnection-get.md +33 -0
  54. package/docs/docs/cmd/spo/hubsite/hubsite-get.md +19 -8
  55. package/docs/docs/cmd/spo/roledefinition/roledefinition-get.md +27 -0
  56. package/docs/docs/cmd/teams/cache/cache-remove.md +46 -0
  57. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +1 -1
  58. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +1 -1
  59. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +1 -1
  60. package/npm-shrinkwrap.json +2 -2
  61. package/package.json +3 -3
  62. package/dist/m365/planner/commands/plan/plan-details-get.js +0 -116
  63. package/docs/docs/cmd/planner/plan/plan-details-get.md +0 -45
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const Auth_1 = require("../../../../Auth");
13
+ const cli_1 = require("../../../../cli");
14
+ const request_1 = require("../../../../request");
15
+ const utils_1 = require("../../../../utils");
16
+ const aadGroup_1 = require("../../../../utils/aadGroup");
17
+ const planner_1 = require("../../../../utils/planner");
18
+ const GraphCommand_1 = require("../../../base/GraphCommand");
19
+ const commands_1 = require("../../commands");
20
+ class PlannerPlanRemoveCommand extends GraphCommand_1.default {
21
+ get name() {
22
+ return commands_1.default.PLAN_REMOVE;
23
+ }
24
+ get description() {
25
+ return 'Removes the Microsoft Planner plan';
26
+ }
27
+ getTelemetryProperties(args) {
28
+ const telemetryProps = super.getTelemetryProperties(args);
29
+ telemetryProps.id = typeof args.options.id !== 'undefined';
30
+ telemetryProps.title = typeof args.options.title !== 'undefined';
31
+ telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
32
+ telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
33
+ telemetryProps.confirm = !!args.options.confirm;
34
+ return telemetryProps;
35
+ }
36
+ commandAction(logger, args, cb) {
37
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
38
+ this.handleError('This command does not support application permissions.', logger, cb);
39
+ return;
40
+ }
41
+ const removePlan = () => __awaiter(this, void 0, void 0, function* () {
42
+ try {
43
+ const plan = yield this.getPlan(args);
44
+ const requestOptions = {
45
+ url: `${this.resource}/v1.0/planner/plans/${plan.id}`,
46
+ headers: {
47
+ accept: 'application/json;odata.metadata=none',
48
+ 'if-match': plan['@odata.etag']
49
+ },
50
+ responseType: 'json'
51
+ };
52
+ yield request_1.default.delete(requestOptions);
53
+ cb();
54
+ }
55
+ catch (err) {
56
+ this.handleRejectedODataJsonPromise(err, logger, cb);
57
+ }
58
+ });
59
+ if (args.options.confirm) {
60
+ removePlan();
61
+ }
62
+ else {
63
+ cli_1.Cli.prompt({
64
+ type: 'confirm',
65
+ name: 'continue',
66
+ default: false,
67
+ message: `Are you sure you want to remove the plan ${args.options.id || args.options.title}?`
68
+ }, (result) => {
69
+ if (!result.continue) {
70
+ cb();
71
+ }
72
+ else {
73
+ removePlan();
74
+ }
75
+ });
76
+ }
77
+ }
78
+ getPlan(args) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const { id, title } = args.options;
81
+ if (id) {
82
+ return planner_1.planner.getPlanById(id, 'minimal');
83
+ }
84
+ const groupId = yield this.getGroupId(args);
85
+ return yield planner_1.planner.getPlanByTitle(title, groupId);
86
+ });
87
+ }
88
+ getGroupId(args) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ const { ownerGroupId, ownerGroupName } = args.options;
91
+ if (ownerGroupId) {
92
+ return ownerGroupId;
93
+ }
94
+ const group = yield aadGroup_1.aadGroup.getGroupByDisplayName(ownerGroupName);
95
+ return group.id;
96
+ });
97
+ }
98
+ optionSets() {
99
+ return [['id', 'title']];
100
+ }
101
+ options() {
102
+ const options = [
103
+ {
104
+ option: '-i, --id [id]'
105
+ },
106
+ {
107
+ option: '-t, --title [title]'
108
+ },
109
+ {
110
+ option: '--ownerGroupId [ownerGroupId]'
111
+ },
112
+ {
113
+ option: '--ownerGroupName [ownerGroupName]'
114
+ },
115
+ {
116
+ option: '--confirm'
117
+ }
118
+ ];
119
+ const parentOptions = super.options();
120
+ return options.concat(parentOptions);
121
+ }
122
+ validate(args) {
123
+ if (args.options.title) {
124
+ if (!args.options.ownerGroupId && !args.options.ownerGroupName) {
125
+ return 'Specify either ownerGroupId or ownerGroupName';
126
+ }
127
+ if (args.options.ownerGroupId && args.options.ownerGroupName) {
128
+ return 'Specify either ownerGroupId or ownerGroupName but not both';
129
+ }
130
+ if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
131
+ return `${args.options.ownerGroupId} is not a valid GUID`;
132
+ }
133
+ }
134
+ else if (args.options.ownerGroupId || args.options.ownerGroupName) {
135
+ return 'Don\'t specify ownerGroupId or ownerGroupName when using id';
136
+ }
137
+ return true;
138
+ }
139
+ }
140
+ module.exports = new PlannerPlanRemoveCommand();
141
+ //# sourceMappingURL=plan-remove.js.map
@@ -24,6 +24,7 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
24
24
  const telemetryProps = super.getTelemetryProperties(args);
25
25
  telemetryProps.planId = typeof args.options.planId !== 'undefined';
26
26
  telemetryProps.planName = typeof args.options.planName !== 'undefined';
27
+ telemetryProps.planTitle = typeof args.options.planTitle !== 'undefined';
27
28
  telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
28
29
  telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
29
30
  telemetryProps.bucketId = typeof args.options.bucketId !== 'undefined';
@@ -42,6 +43,10 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
42
43
  return telemetryProps;
43
44
  }
44
45
  commandAction(logger, args, cb) {
46
+ if (args.options.planName) {
47
+ args.options.planTitle = args.options.planName;
48
+ this.warn(logger, `Option 'planName' is deprecated. Please use 'planTitle' instead`);
49
+ }
45
50
  if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
46
51
  this.handleError('This command does not support application permissions.', logger, cb);
47
52
  return;
@@ -96,13 +101,7 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
96
101
  };
97
102
  return request_1.default
98
103
  .get(requestOptions)
99
- .then((response) => {
100
- const etag = response ? response['@odata.etag'] : undefined;
101
- if (!etag) {
102
- return Promise.reject(`Error fetching task details`);
103
- }
104
- return Promise.resolve(etag);
105
- });
104
+ .then((response) => response['@odata.etag']);
106
105
  }
107
106
  generateAppliedCategories(options) {
108
107
  if (!options.appliedCategories) {
@@ -181,7 +180,7 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
181
180
  }
182
181
  return this
183
182
  .getGroupId(args)
184
- .then((groupId) => planner_1.planner.getPlanByName(args.options.planName, groupId))
183
+ .then((groupId) => planner_1.planner.getPlanByTitle(args.options.planTitle, groupId))
185
184
  .then(plan => plan.id);
186
185
  }
187
186
  getGroupId(args) {
@@ -229,6 +228,7 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
229
228
  { option: '-t, --title <title>' },
230
229
  { option: '--planId [planId]' },
231
230
  { option: '--planName [planName]' },
231
+ { option: '--planTitle [planTitle]' },
232
232
  { option: '--ownerGroupId [ownerGroupId]' },
233
233
  { option: '--ownerGroupName [ownerGroupName]' },
234
234
  { option: '--bucketId [bucketId]' },
@@ -255,17 +255,17 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
255
255
  return options.concat(parentOptions);
256
256
  }
257
257
  validate(args) {
258
- if (!args.options.planId && !args.options.planName) {
259
- return 'Specify either planId or planName';
258
+ if (!args.options.planId && !args.options.planName && !args.options.planTitle) {
259
+ return 'Specify either planId or planTitle';
260
260
  }
261
- if (args.options.planId && args.options.planName) {
262
- return 'Specify either planId or planName but not both';
261
+ if (args.options.planId && (args.options.planName || args.options.planTitle)) {
262
+ return 'Specify either planId or planTitle but not both';
263
263
  }
264
- if (args.options.planName && !args.options.ownerGroupId && !args.options.ownerGroupName) {
265
- return 'Specify either ownerGroupId or ownerGroupName when using planName';
264
+ if ((args.options.planName || args.options.planTitle) && !args.options.ownerGroupId && !args.options.ownerGroupName) {
265
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle';
266
266
  }
267
- if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
268
- return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
267
+ if ((args.options.planName || args.options.planTitle) && args.options.ownerGroupId && args.options.ownerGroupName) {
268
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle but not both';
269
269
  }
270
270
  if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
271
271
  return `${args.options.ownerGroupId} is not a valid GUID`;
@@ -31,6 +31,10 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
31
31
  }
32
32
  commandAction(logger, args, cb) {
33
33
  this.showDeprecationWarning(logger, commands_1.default.TASK_DETAILS_GET, commands_1.default.TASK_GET);
34
+ if (args.options.planName) {
35
+ args.options.planTitle = args.options.planName;
36
+ this.warn(logger, `Option 'planName' is deprecated. Please use 'planTitle' instead`);
37
+ }
34
38
  if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
35
39
  this.handleError('This command does not support application permissions.', logger, cb);
36
40
  return;
@@ -135,7 +139,7 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
135
139
  }
136
140
  return this
137
141
  .getGroupId(options)
138
- .then(groupId => planner_1.planner.getPlanByName(options.planName, groupId))
142
+ .then(groupId => planner_1.planner.getPlanByTitle(options.planTitle, groupId))
139
143
  .then(plan => plan.id);
140
144
  }
141
145
  getGroupId(options) {
@@ -160,6 +164,7 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
160
164
  { option: '--bucketName [bucketName]' },
161
165
  { option: '--planId [planId]' },
162
166
  { option: '--planName [planName]' },
167
+ { option: '--planTitle [planTitle]' },
163
168
  { option: '--ownerGroupId [ownerGroupId]' },
164
169
  { option: '--ownerGroupName [ownerGroupName]' }
165
170
  ];
@@ -173,17 +178,17 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
173
178
  if (args.options.title && args.options.bucketId && args.options.bucketName) {
174
179
  return 'Specify either bucketId or bucketName when using title but not both';
175
180
  }
176
- if (args.options.bucketName && !args.options.planId && !args.options.planName) {
177
- return 'Specify either planId or planName when using bucketName';
181
+ if (args.options.bucketName && !args.options.planId && !args.options.planName && !args.options.planTitle) {
182
+ return 'Specify either planId or planTitle when using bucketName';
178
183
  }
179
- if (args.options.bucketName && args.options.planId && args.options.planName) {
180
- return 'Specify either planId or planName when using bucketName but not both';
184
+ if (args.options.bucketName && args.options.planId && (args.options.planName || args.options.planTitle)) {
185
+ return 'Specify either planId or planTitle when using bucketName but not both';
181
186
  }
182
- if (args.options.planName && !args.options.ownerGroupId && !args.options.ownerGroupName) {
183
- return 'Specify either ownerGroupId or ownerGroupName when using planName';
187
+ if ((args.options.planName || args.options.planTitle) && !args.options.ownerGroupId && !args.options.ownerGroupName) {
188
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle';
184
189
  }
185
- if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
186
- return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
190
+ if ((args.options.planName || args.options.planTitle) && args.options.ownerGroupId && args.options.ownerGroupName) {
191
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle but not both';
187
192
  }
188
193
  if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
189
194
  return `${args.options.ownerGroupId} is not a valid GUID`;
@@ -20,6 +20,7 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
20
20
  telemetryProps.bucketName = typeof args.options.bucketName !== 'undefined';
21
21
  telemetryProps.planId = typeof args.options.planId !== 'undefined';
22
22
  telemetryProps.planName = typeof args.options.planName !== 'undefined';
23
+ telemetryProps.planTitle = typeof args.options.planTitle !== 'undefined';
23
24
  telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
24
25
  telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
25
26
  return telemetryProps;
@@ -28,13 +29,17 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
28
29
  return ['id', 'title', 'startDateTime', 'dueDateTime', 'completedDateTime'];
29
30
  }
30
31
  commandAction(logger, args, cb) {
32
+ if (args.options.planName) {
33
+ args.options.planTitle = args.options.planName;
34
+ this.warn(logger, `Option 'planName' is deprecated. Please use 'planTitle' instead`);
35
+ }
31
36
  if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
32
37
  this.handleError('This command does not support application permissions.', logger, cb);
33
38
  return;
34
39
  }
35
40
  const bucketName = args.options.bucketName;
36
41
  let bucketId = args.options.bucketId;
37
- const planName = args.options.planName;
42
+ const planTitle = args.options.planTitle;
38
43
  let planId = args.options.planId;
39
44
  let taskItems = [];
40
45
  if (bucketId || bucketName) {
@@ -53,7 +58,7 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
53
58
  cb();
54
59
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
55
60
  }
56
- else if (planId || planName) {
61
+ else if (planId || planTitle) {
57
62
  this
58
63
  .getPlanId(args)
59
64
  .then((retrievedPlanId) => {
@@ -112,7 +117,7 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
112
117
  }
113
118
  return this
114
119
  .getGroupId(args)
115
- .then((groupId) => planner_1.planner.getPlanByName(args.options.planName, groupId))
120
+ .then((groupId) => planner_1.planner.getPlanByTitle(args.options.planTitle, groupId))
116
121
  .then(plan => plan.id);
117
122
  }
118
123
  getGroupId(args) {
@@ -148,6 +153,9 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
148
153
  {
149
154
  option: '--planName [planName]'
150
155
  },
156
+ {
157
+ option: '--planTitle [planTitle]'
158
+ },
151
159
  {
152
160
  option: '--ownerGroupId [ownerGroupId]'
153
161
  },
@@ -162,17 +170,17 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
162
170
  if (args.options.bucketId && args.options.bucketName) {
163
171
  return 'To retrieve tasks from a bucket, specify bucketId or bucketName, but not both';
164
172
  }
165
- if (args.options.bucketName && !args.options.planId && !args.options.planName) {
166
- return 'Specify either planId or planName when using bucketName';
173
+ if (args.options.bucketName && !args.options.planId && !args.options.planName && !args.options.planTitle) {
174
+ return 'Specify either planId or planTitle when using bucketName';
167
175
  }
168
- if (args.options.planId && args.options.planName) {
169
- return 'Specify either planId or planName but not both';
176
+ if (args.options.planId && (args.options.planName || args.options.planTitle)) {
177
+ return 'Specify either planId or planTitle but not both';
170
178
  }
171
- if (args.options.planName && !args.options.ownerGroupId && !args.options.ownerGroupName) {
172
- return 'Specify either ownerGroupId or ownerGroupName when using planName';
179
+ if ((args.options.planName || args.options.planTitle) && !args.options.ownerGroupId && !args.options.ownerGroupName) {
180
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle';
173
181
  }
174
- if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
175
- return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
182
+ if ((args.options.planName || args.options.planTitle) && args.options.ownerGroupId && args.options.ownerGroupName) {
183
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle but not both';
176
184
  }
177
185
  if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
178
186
  return `${args.options.ownerGroupId} is not a valid GUID`;
@@ -46,13 +46,7 @@ class PlannerTaskReferenceAddCommand extends GraphCommand_1.default {
46
46
  };
47
47
  return request_1.default
48
48
  .get(requestOptions)
49
- .then((response) => {
50
- const etag = response ? response['@odata.etag'] : undefined;
51
- if (!etag) {
52
- return Promise.reject(`Error fetching task details`);
53
- }
54
- return Promise.resolve(etag);
55
- });
49
+ .then((response) => response['@odata.etag']);
56
50
  }
57
51
  options() {
58
52
  const options = [
@@ -74,21 +74,18 @@ class PlannerTaskReferenceRemoveCommand extends GraphCommand_1.default {
74
74
  let url = options.url;
75
75
  return request_1.default
76
76
  .get(requestOptions)
77
- .then((response) => {
78
- const etag = response ? response['@odata.etag'] : undefined;
79
- if (!etag) {
80
- return Promise.reject(`Error fetching task details`);
81
- }
77
+ .then((taskDetails) => {
82
78
  if (options.alias) {
83
- const alias = options.alias;
84
79
  const urls = [];
85
- Object.entries(response.references).forEach((ref) => {
86
- var _a;
87
- if (((_a = ref[1].alias) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === alias.toLocaleLowerCase()) {
88
- urls.push(decodeURIComponent(ref[0]));
89
- }
90
- });
91
- if (!urls.length) {
80
+ if (taskDetails.references) {
81
+ Object.entries(taskDetails.references).forEach((ref) => {
82
+ var _a;
83
+ if (((_a = ref[1].alias) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === options.alias.toLocaleLowerCase()) {
84
+ urls.push(decodeURIComponent(ref[0]));
85
+ }
86
+ });
87
+ }
88
+ if (urls.length === 0) {
92
89
  return Promise.reject(`The specified reference with alias ${options.alias} does not exist`);
93
90
  }
94
91
  if (urls.length > 1) {
@@ -96,7 +93,7 @@ class PlannerTaskReferenceRemoveCommand extends GraphCommand_1.default {
96
93
  }
97
94
  url = urls[0];
98
95
  }
99
- return Promise.resolve({ etag, url });
96
+ return Promise.resolve({ etag: taskDetails['@odata.etag'], url });
100
97
  });
101
98
  }
102
99
  options() {
@@ -114,7 +114,7 @@ class PlannerTaskRemoveCommand extends GraphCommand_1.default {
114
114
  }
115
115
  return this
116
116
  .getGroupId(options)
117
- .then(groupId => planner_1.planner.getPlanByName(planTitle, groupId))
117
+ .then(groupId => planner_1.planner.getPlanByTitle(planTitle, groupId))
118
118
  .then(plan => plan.id);
119
119
  }
120
120
  getGroupId(options) {
@@ -122,24 +122,9 @@ class PlannerTaskRemoveCommand extends GraphCommand_1.default {
122
122
  if (ownerGroupId) {
123
123
  return Promise.resolve(ownerGroupId);
124
124
  }
125
- const requestOptions = {
126
- url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(ownerGroupName)}'`,
127
- headers: {
128
- accept: 'application/json;odata.metadata=none'
129
- },
130
- responseType: 'json'
131
- };
132
- return request_1.default
133
- .get(requestOptions)
134
- .then(response => {
135
- if (response.value.length === 0) {
136
- return Promise.reject(`The specified owner group ${ownerGroupName} does not exist`);
137
- }
138
- if (response.value.length > 1) {
139
- return Promise.reject(`Multiple owner groups with name ${ownerGroupName} found: ${response.value.map(x => x.id)}`);
140
- }
141
- return Promise.resolve(response.value[0].id);
142
- });
125
+ return utils_1.aadGroup
126
+ .getGroupByDisplayName(ownerGroupName)
127
+ .then(group => group.id);
143
128
  }
144
129
  options() {
145
130
  const options = [
@@ -24,6 +24,7 @@ class PlannerTaskSetCommand extends GraphCommand_1.default {
24
24
  telemetryProps.title = typeof args.options.title !== 'undefined';
25
25
  telemetryProps.planId = typeof args.options.planId !== 'undefined';
26
26
  telemetryProps.planName = typeof args.options.planName !== 'undefined';
27
+ telemetryProps.planTitle = typeof args.options.planTitle !== 'undefined';
27
28
  telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
28
29
  telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
29
30
  telemetryProps.bucketId = typeof args.options.bucketId !== 'undefined';
@@ -41,6 +42,10 @@ class PlannerTaskSetCommand extends GraphCommand_1.default {
41
42
  return telemetryProps;
42
43
  }
43
44
  commandAction(logger, args, cb) {
45
+ if (args.options.planName) {
46
+ args.options.planTitle = args.options.planName;
47
+ this.warn(logger, `Option 'planName' is deprecated. Please use 'planTitle' instead`);
48
+ }
44
49
  if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
45
50
  this.handleError('This command does not support application permissions.', logger, cb);
46
51
  return;
@@ -112,13 +117,7 @@ class PlannerTaskSetCommand extends GraphCommand_1.default {
112
117
  };
113
118
  return request_1.default
114
119
  .get(requestOptions)
115
- .then((response) => {
116
- const etag = response ? response['@odata.etag'] : undefined;
117
- if (!etag) {
118
- return Promise.reject(`Error fetching task details`);
119
- }
120
- return Promise.resolve(etag);
121
- });
120
+ .then((response) => response['@odata.etag']);
122
121
  }
123
122
  getTaskEtag(taskId) {
124
123
  const requestOptions = {
@@ -130,13 +129,7 @@ class PlannerTaskSetCommand extends GraphCommand_1.default {
130
129
  };
131
130
  return request_1.default
132
131
  .get(requestOptions)
133
- .then((response) => {
134
- const etag = response ? response['@odata.etag'] : undefined;
135
- if (!etag) {
136
- return Promise.reject(`Error fetching task`);
137
- }
138
- return Promise.resolve(etag);
139
- });
132
+ .then((response) => response['@odata.etag']);
140
133
  }
141
134
  generateAppliedCategories(options) {
142
135
  if (!options.appliedCategories) {
@@ -226,7 +219,7 @@ class PlannerTaskSetCommand extends GraphCommand_1.default {
226
219
  }
227
220
  return this
228
221
  .getGroupId(options)
229
- .then((groupId) => planner_1.planner.getPlanByName(options.planName, groupId))
222
+ .then((groupId) => planner_1.planner.getPlanByTitle(options.planTitle, groupId))
230
223
  .then(plan => plan.id);
231
224
  }
232
225
  getGroupId(options) {
@@ -277,6 +270,7 @@ class PlannerTaskSetCommand extends GraphCommand_1.default {
277
270
  { option: '-t, --title [title]' },
278
271
  { option: '--planId [planId]' },
279
272
  { option: '--planName [planName]' },
273
+ { option: '--planTitle [planTitle]' },
280
274
  { option: '--ownerGroupId [ownerGroupId]' },
281
275
  { option: '--ownerGroupName [ownerGroupName]' },
282
276
  { option: '--bucketId [bucketId]' },
@@ -299,17 +293,17 @@ class PlannerTaskSetCommand extends GraphCommand_1.default {
299
293
  if (args.options.bucketId && args.options.bucketName) {
300
294
  return 'Specify either bucketId or bucketName but not both';
301
295
  }
302
- if (args.options.bucketName && !args.options.planId && !args.options.planName) {
303
- return 'Specify either planId or planName when using bucketName';
296
+ if (args.options.bucketName && !args.options.planId && !args.options.planName && !args.options.planTitle) {
297
+ return 'Specify either planId or planTitle when using bucketName';
304
298
  }
305
- if (args.options.bucketName && args.options.planId && args.options.planName) {
306
- return 'Specify either planId or planName when using bucketName but not both';
299
+ if (args.options.bucketName && args.options.planId && (args.options.planName || args.options.planTitle)) {
300
+ return 'Specify either planId or planTitle when using bucketName but not both';
307
301
  }
308
- if (args.options.planName && !args.options.ownerGroupId && !args.options.ownerGroupName) {
309
- return 'Specify either ownerGroupId or ownerGroupName when using planName';
302
+ if ((args.options.planName || args.options.planTitle) && !args.options.ownerGroupId && !args.options.ownerGroupName) {
303
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle';
310
304
  }
311
- if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
312
- return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
305
+ if ((args.options.planName || args.options.planTitle) && args.options.ownerGroupId && args.options.ownerGroupName) {
306
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle but not both';
313
307
  }
314
308
  if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
315
309
  return `${args.options.ownerGroupId} is not a valid GUID`;
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../../../utils");
4
+ const request_1 = require("../../../../request");
5
+ const PlannerCommand_1 = require("../../../base/PlannerCommand");
6
+ const commands_1 = require("../../commands");
7
+ class PlannerTenantSettingsSetCommand extends PlannerCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.TENANT_SETTINGS_SET;
10
+ }
11
+ get description() {
12
+ return 'Sets Microsoft Planner configuration of the tenant';
13
+ }
14
+ getTelemetryProperties(args) {
15
+ const telemetryProps = super.getTelemetryProperties(args);
16
+ telemetryProps.isPlannerAllowed = typeof args.options.isPlannerAllowed !== 'undefined';
17
+ telemetryProps.allowCalendarSharing = typeof args.options.allowCalendarSharing !== 'undefined';
18
+ telemetryProps.allowTenantMoveWithDataLoss = typeof args.options.allowTenantMoveWithDataLoss !== 'undefined';
19
+ telemetryProps.allowTenantMoveWithDataMigration = typeof args.options.allowTenantMoveWithDataMigration !== 'undefined';
20
+ telemetryProps.allowRosterCreation = typeof args.options.allowRosterCreation !== 'undefined';
21
+ telemetryProps.allowPlannerMobilePushNotifications = typeof args.options.allowPlannerMobilePushNotifications !== 'undefined';
22
+ return telemetryProps;
23
+ }
24
+ commandAction(logger, args, cb) {
25
+ const requestOptions = {
26
+ url: `${this.resource}/taskAPI/tenantAdminSettings/Settings`,
27
+ headers: {
28
+ accept: 'application/json;odata.metadata=none',
29
+ prefer: 'return=representation'
30
+ },
31
+ responseType: 'json',
32
+ data: {
33
+ isPlannerAllowed: args.options.isPlannerAllowed,
34
+ allowCalendarSharing: args.options.allowCalendarSharing,
35
+ allowTenantMoveWithDataLoss: args.options.allowTenantMoveWithDataLoss,
36
+ allowTenantMoveWithDataMigration: args.options.allowTenantMoveWithDataMigration,
37
+ allowRosterCreation: args.options.allowRosterCreation,
38
+ allowPlannerMobilePushNotifications: args.options.allowPlannerMobilePushNotifications
39
+ }
40
+ };
41
+ request_1.default
42
+ .patch(requestOptions)
43
+ .then((result) => {
44
+ logger.log(result);
45
+ cb();
46
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
47
+ }
48
+ options() {
49
+ const options = [
50
+ {
51
+ option: '--isPlannerAllowed [isPlannerAllowed]',
52
+ autocomplete: ['true', 'false']
53
+ },
54
+ {
55
+ option: '--allowCalendarSharing [allowCalendarSharing]',
56
+ autocomplete: ['true', 'false']
57
+ },
58
+ {
59
+ option: '--allowTenantMoveWithDataLoss [allowTenantMoveWithDataLoss]',
60
+ autocomplete: ['true', 'false']
61
+ },
62
+ {
63
+ option: '--allowTenantMoveWithDataMigration [allowTenantMoveWithDataMigration]',
64
+ autocomplete: ['true', 'false']
65
+ },
66
+ {
67
+ option: '--allowRosterCreation [allowRosterCreation]',
68
+ autocomplete: ['true', 'false']
69
+ },
70
+ {
71
+ option: '--allowPlannerMobilePushNotifications [allowPlannerMobilePushNotifications]',
72
+ autocomplete: ['true', 'false']
73
+ }
74
+ ];
75
+ const parentOptions = super.options();
76
+ return options.concat(parentOptions);
77
+ }
78
+ validate(args) {
79
+ const optionsArray = [
80
+ args.options.isPlannerAllowed, args.options.allowCalendarSharing, args.options.allowTenantMoveWithDataLoss,
81
+ args.options.allowTenantMoveWithDataMigration, args.options.allowRosterCreation, args.options.allowPlannerMobilePushNotifications
82
+ ];
83
+ if (optionsArray.every(o => typeof o === 'undefined')) {
84
+ return 'You must specify at least one option';
85
+ }
86
+ for (const option of optionsArray) {
87
+ if (typeof option !== 'undefined' && !utils_1.validation.isValidBoolean(option)) {
88
+ return `Value '${option}' is not a valid boolean`;
89
+ }
90
+ }
91
+ return true;
92
+ }
93
+ }
94
+ module.exports = new PlannerTenantSettingsSetCommand();
95
+ //# sourceMappingURL=tenant-settings-set.js.map
@@ -11,6 +11,7 @@ exports.default = {
11
11
  PLAN_DETAILS_GET: `${prefix} plan details get`,
12
12
  PLAN_GET: `${prefix} plan get`,
13
13
  PLAN_LIST: `${prefix} plan list`,
14
+ PLAN_REMOVE: `${prefix} plan remove`,
14
15
  TASK_ADD: `${prefix} task add`,
15
16
  TASK_CHECKLISTITEM_ADD: `${prefix} task checklistitem add`,
16
17
  TASK_CHECKLISTITEM_LIST: `${prefix} task checklistitem list`,
@@ -23,6 +24,7 @@ exports.default = {
23
24
  TASK_REFERENCE_REMOVE: `${prefix} task reference remove`,
24
25
  TASK_REMOVE: `${prefix} task remove`,
25
26
  TASK_SET: `${prefix} task set`,
26
- TENANT_SETTINGS_LIST: `${prefix} tenant settings list`
27
+ TENANT_SETTINGS_LIST: `${prefix} tenant settings list`,
28
+ TENANT_SETTINGS_SET: `${prefix} tenant settings set`
27
29
  };
28
30
  //# sourceMappingURL=commands.js.map