@pnp/cli-microsoft365 5.2.0 → 5.3.0-beta.2a76d05

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 (112) hide show
  1. package/.eslintrc.js +1 -0
  2. package/dist/Auth.js +5 -0
  3. package/dist/m365/aad/commands/app/app-add.js +91 -35
  4. package/dist/m365/aad/commands/app/app-role-list.js +1 -1
  5. package/dist/m365/aad/commands/app/app-set.js +91 -0
  6. package/dist/m365/aad/commands/approleassignment/approleassignment-list.js +55 -22
  7. package/dist/m365/aad/commands/group/group-list.js +1 -1
  8. package/dist/m365/aad/commands/groupsetting/groupsetting-list.js +1 -1
  9. package/dist/m365/aad/commands/groupsettingtemplate/groupsettingtemplate-get.js +1 -1
  10. package/dist/m365/aad/commands/groupsettingtemplate/groupsettingtemplate-list.js +1 -1
  11. package/dist/m365/aad/commands/o365group/o365group-conversation-list.js +1 -1
  12. package/dist/m365/aad/commands/o365group/o365group-conversation-post-list.js +1 -1
  13. package/dist/m365/aad/commands/o365group/o365group-list.js +1 -1
  14. package/dist/m365/aad/commands/o365group/o365group-recyclebinitem-clear.js +3 -3
  15. package/dist/m365/aad/commands/o365group/o365group-recyclebinitem-list.js +1 -1
  16. package/dist/m365/aad/commands/o365group/o365group-user-list.js +2 -2
  17. package/dist/m365/aad/commands/o365group/o365group-user-set.js +2 -2
  18. package/dist/m365/aad/commands/user/user-list.js +1 -1
  19. package/dist/m365/aad/commands/user/user-signin-list.js +1 -1
  20. package/dist/m365/aad/commands.js +1 -1
  21. package/dist/m365/app/commands/app-open.js +64 -0
  22. package/dist/m365/app/commands.js +1 -0
  23. package/dist/m365/base/PowerBICommand.js +10 -0
  24. package/dist/m365/file/commands/file-list.js +1 -1
  25. package/dist/m365/outlook/commands/message/message-list.js +1 -1
  26. package/dist/m365/outlook/commands/room/room-list.js +1 -1
  27. package/dist/m365/outlook/commands/roomlist/roomlist-list.js +1 -1
  28. package/dist/m365/planner/commands/bucket/bucket-add.js +8 -16
  29. package/dist/m365/planner/commands/bucket/bucket-get.js +186 -0
  30. package/dist/m365/planner/commands/bucket/bucket-list.js +10 -19
  31. package/dist/m365/planner/commands/bucket/bucket-remove.js +202 -0
  32. package/dist/m365/planner/commands/bucket/bucket-set.js +9 -21
  33. package/dist/m365/planner/commands/plan/plan-add.js +6 -1
  34. package/dist/m365/planner/commands/plan/plan-details-get.js +12 -15
  35. package/dist/m365/planner/commands/plan/plan-get.js +13 -18
  36. package/dist/m365/planner/commands/plan/plan-list.js +10 -13
  37. package/dist/m365/planner/commands/task/task-add.js +8 -16
  38. package/dist/m365/planner/commands/task/task-details-get.js +6 -0
  39. package/dist/m365/planner/commands/task/task-get.js +138 -7
  40. package/dist/m365/planner/commands/task/task-list.js +15 -24
  41. package/dist/m365/planner/commands/task/task-reference-add.js +75 -0
  42. package/dist/m365/planner/commands/task/task-reference-list.js +45 -0
  43. package/dist/m365/planner/commands/task/task-set.js +9 -18
  44. package/dist/m365/planner/commands.js +5 -1
  45. package/dist/m365/pp/commands/gateway/gateway-list.js +36 -0
  46. package/dist/m365/pp/commands/managementapp/managementapp-list.js +1 -1
  47. package/dist/m365/pp/commands.js +1 -0
  48. package/dist/m365/search/commands/externalconnection/externalconnection-list.js +26 -0
  49. package/dist/m365/search/commands.js +2 -1
  50. package/dist/m365/spo/commands/eventreceiver/eventreceiver-get.js +119 -0
  51. package/dist/m365/spo/commands/field/field-list.js +84 -0
  52. package/dist/m365/spo/commands/list/list-roleinheritance-break.js +84 -0
  53. package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +76 -0
  54. package/dist/m365/spo/commands/list/list-view-add.js +113 -0
  55. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-break.js +83 -0
  56. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-reset.js +79 -0
  57. package/dist/m365/spo/commands/roledefinition/roledefinition-list.js +49 -0
  58. package/dist/m365/spo/commands.js +8 -0
  59. package/dist/m365/teams/commands/app/app-list.js +1 -1
  60. package/dist/m365/teams/commands/channel/channel-list.js +1 -1
  61. package/dist/m365/teams/commands/channel/channel-member-add.js +4 -1
  62. package/dist/m365/teams/commands/channel/channel-member-list.js +1 -1
  63. package/dist/m365/teams/commands/channel/channel-member-remove.js +3 -0
  64. package/dist/m365/teams/commands/channel/channel-member-set.js +3 -0
  65. package/dist/m365/teams/commands/chat/chat-get.js +8 -8
  66. package/dist/m365/teams/commands/chat/chat-list.js +1 -1
  67. package/dist/m365/teams/commands/chat/chat-member-list.js +1 -1
  68. package/dist/m365/teams/commands/chat/chat-message-list.js +1 -1
  69. package/dist/m365/teams/commands/chat/chat-message-send.js +6 -6
  70. package/dist/m365/teams/commands/chat/chatUtil.js +4 -4
  71. package/dist/m365/teams/commands/message/message-list.js +1 -1
  72. package/dist/m365/teams/commands/message/message-reply-list.js +1 -1
  73. package/dist/m365/teams/commands/tab/tab-list.js +1 -1
  74. package/dist/m365/teams/commands/team/team-list.js +1 -1
  75. package/dist/m365/teams/commands/user/user-app-list.js +1 -1
  76. package/dist/m365/teams/commands/user/user-list.js +2 -2
  77. package/dist/m365/tenant/commands/security/security-alerts-list.js +71 -0
  78. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-healthissue-list.js +1 -1
  79. package/dist/m365/tenant/commands/serviceannouncement/serviceannouncement-message-list.js +1 -1
  80. package/dist/m365/tenant/commands.js +1 -0
  81. package/dist/m365/todo/commands/list/list-list.js +1 -1
  82. package/dist/m365/todo/commands/task/task-list.js +1 -1
  83. package/dist/utils/accessToken.js +18 -0
  84. package/dist/utils/formatting.js +11 -2
  85. package/dist/utils/odata.js +2 -2
  86. package/dist/utils/planner.js +65 -0
  87. package/docs/docs/cmd/aad/app/app-add.md +15 -0
  88. package/docs/docs/cmd/aad/app/app-set.md +17 -0
  89. package/docs/docs/cmd/aad/approleassignment/approleassignment-remove.md +1 -1
  90. package/docs/docs/cmd/app/app-open.md +45 -0
  91. package/docs/docs/cmd/planner/bucket/bucket-get.md +57 -0
  92. package/docs/docs/cmd/planner/bucket/bucket-remove.md +60 -0
  93. package/docs/docs/cmd/planner/task/task-get.md +30 -3
  94. package/docs/docs/cmd/planner/task/task-reference-add.md +45 -0
  95. package/docs/docs/cmd/planner/task/task-reference-list.md +24 -0
  96. package/docs/docs/cmd/pp/gateway/gateway-list.md +21 -0
  97. package/docs/docs/cmd/search/externalconnection/externalconnection-list.md +21 -0
  98. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-get.md +70 -0
  99. package/docs/docs/cmd/spo/field/field-list.md +51 -0
  100. package/docs/docs/cmd/spo/list/list-roleinheritance-break.md +55 -0
  101. package/docs/docs/cmd/spo/list/list-roleinheritance-reset.md +36 -0
  102. package/docs/docs/cmd/spo/list/list-view-add.md +67 -0
  103. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-break.md +58 -0
  104. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-reset.md +39 -0
  105. package/docs/docs/cmd/spo/roledefinition/roledefinition-list.md +24 -0
  106. package/docs/docs/cmd/spo/userprofile/userprofile-get.md +1 -1
  107. package/docs/docs/cmd/teams/channel/channel-member-list.md +4 -4
  108. package/docs/docs/cmd/teams/channel/channel-member-remove.md +2 -2
  109. package/docs/docs/cmd/teams/channel/channel-member-set.md +2 -2
  110. package/docs/docs/cmd/tenant/security/security-alerts-list.md +30 -0
  111. package/npm-shrinkwrap.json +1517 -1284
  112. package/package.json +26 -25
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_1 = require("../../../../request");
4
3
  const utils_1 = require("../../../../utils");
4
+ const Auth_1 = require("../../../../Auth");
5
+ const request_1 = require("../../../../request");
5
6
  const GraphCommand_1 = require("../../../base/GraphCommand");
6
7
  const commands_1 = require("../../commands");
7
8
  class PlannerPlanAddCommand extends GraphCommand_1.default {
@@ -21,6 +22,10 @@ class PlannerPlanAddCommand extends GraphCommand_1.default {
21
22
  return ['id', 'title', 'createdDateTime', 'owner'];
22
23
  }
23
24
  commandAction(logger, args, cb) {
25
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
26
+ this.handleError('This command does not support application permissions.', logger, cb);
27
+ return;
28
+ }
24
29
  this
25
30
  .getGroupId(args)
26
31
  .then((groupId) => {
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_1 = require("../../../../request");
4
3
  const utils_1 = require("../../../../utils");
4
+ const Auth_1 = require("../../../../Auth");
5
+ const request_1 = require("../../../../request");
6
+ const planner_1 = require("../../../../utils/planner");
5
7
  const GraphCommand_1 = require("../../../base/GraphCommand");
6
8
  const commands_1 = require("../../commands");
7
9
  class PlannerPlanDetailsGetCommand extends GraphCommand_1.default {
@@ -24,11 +26,15 @@ class PlannerPlanDetailsGetCommand extends GraphCommand_1.default {
24
26
  return telemetryProps;
25
27
  }
26
28
  commandAction(logger, args, cb) {
29
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
30
+ this.handleError('This command does not support application permissions.', logger, cb);
31
+ return;
32
+ }
27
33
  this
28
34
  .getGroupId(args)
29
35
  .then((groupId) => {
30
36
  this.groupId = groupId;
31
- return this.getPlanId(args, logger);
37
+ return this.getPlanId(args);
32
38
  })
33
39
  .then((planId) => {
34
40
  args.options.planId = planId;
@@ -66,22 +72,13 @@ class PlannerPlanDetailsGetCommand extends GraphCommand_1.default {
66
72
  return Promise.resolve(groupItem.id);
67
73
  });
68
74
  }
69
- getPlanId(args, logger) {
75
+ getPlanId(args) {
70
76
  if (args.options.planId) {
71
77
  return Promise.resolve(args.options.planId);
72
78
  }
73
- return utils_1.odata
74
- .getAllItems(`${this.resource}/v1.0/groups/${this.groupId}/planner/plans`, logger)
75
- .then((plans) => {
76
- const plansMatchingName = plans.filter((plan) => plan.title === args.options.planTitle);
77
- if (plansMatchingName && plansMatchingName.length > 0) {
78
- if (plansMatchingName.length > 1) {
79
- return Promise.reject(`Multiple plans with name ${args.options.planTitle} found: ${plansMatchingName.map(x => x.id)}`);
80
- }
81
- return Promise.resolve(plansMatchingName[0].id);
82
- }
83
- return Promise.reject(`The specified plan title does not exist`);
84
- });
79
+ return planner_1.planner
80
+ .getPlanByName(args.options.planTitle, this.groupId)
81
+ .then(plan => plan.id);
85
82
  }
86
83
  getPlanDetails(args) {
87
84
  const requestOptions = {
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_1 = require("../../../../request");
4
3
  const utils_1 = require("../../../../utils");
4
+ const request_1 = require("../../../../request");
5
+ const planner_1 = require("../../../../utils/planner");
5
6
  const GraphCommand_1 = require("../../../base/GraphCommand");
6
7
  const commands_1 = require("../../commands");
8
+ const Auth_1 = require("../../../../Auth");
7
9
  class PlannerPlanGetCommand extends GraphCommand_1.default {
8
10
  get name() {
9
11
  return commands_1.default.PLAN_GET;
@@ -23,9 +25,13 @@ class PlannerPlanGetCommand extends GraphCommand_1.default {
23
25
  return ['id', 'title', 'createdDateTime', 'owner', '@odata.etag'];
24
26
  }
25
27
  commandAction(logger, args, cb) {
28
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
29
+ this.handleError('This command does not support application permissions.', logger, cb);
30
+ return;
31
+ }
26
32
  if (args.options.id) {
27
- this
28
- .getPlan(args)
33
+ planner_1.planner
34
+ .getPlanById(args.options.id)
29
35
  .then((res) => {
30
36
  logger.log(res);
31
37
  cb();
@@ -34,11 +40,10 @@ class PlannerPlanGetCommand extends GraphCommand_1.default {
34
40
  else {
35
41
  this
36
42
  .getGroupId(args)
37
- .then((groupId) => utils_1.odata.getAllItems(`${this.resource}/v1.0/groups/${groupId}/planner/plans`, logger, 'minimal'))
38
- .then((plans) => {
39
- const filteredPlan = plans.filter((plan) => plan.title === args.options.title);
40
- if (filteredPlan && filteredPlan.length > 0) {
41
- logger.log(filteredPlan);
43
+ .then(groupId => planner_1.planner.getPlanByName(args.options.title, groupId))
44
+ .then((plan) => {
45
+ if (plan) {
46
+ logger.log(plan);
42
47
  }
43
48
  cb();
44
49
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
@@ -65,16 +70,6 @@ class PlannerPlanGetCommand extends GraphCommand_1.default {
65
70
  return Promise.resolve(group.id);
66
71
  });
67
72
  }
68
- getPlan(args) {
69
- const requestOptions = {
70
- url: `${this.resource}/v1.0/planner/plans/${args.options.id}`,
71
- headers: {
72
- 'accept': 'application/json'
73
- },
74
- responseType: 'json'
75
- };
76
- return request_1.default.get(requestOptions);
77
- }
78
73
  options() {
79
74
  const options = [
80
75
  {
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_1 = require("../../../../request");
4
3
  const utils_1 = require("../../../../utils");
4
+ const Auth_1 = require("../../../../Auth");
5
+ const request_1 = require("../../../../request");
6
+ const planner_1 = require("../../../../utils/planner");
5
7
  const GraphCommand_1 = require("../../../base/GraphCommand");
6
8
  const commands_1 = require("../../commands");
7
9
  class PlannerPlanListCommand extends GraphCommand_1.default {
@@ -21,21 +23,16 @@ class PlannerPlanListCommand extends GraphCommand_1.default {
21
23
  return ['id', 'title', 'createdDateTime', 'owner'];
22
24
  }
23
25
  commandAction(logger, args, cb) {
26
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
27
+ this.handleError('This command does not support application permissions.', logger, cb);
28
+ return;
29
+ }
24
30
  this
25
31
  .getGroupId(args)
26
- .then((groupId) => {
27
- const requestOptions = {
28
- url: `${this.resource}/v1.0/groups/${groupId}/planner/plans`,
29
- headers: {
30
- 'accept': 'application/json;odata.metadata=none'
31
- },
32
- responseType: 'json'
33
- };
34
- return request_1.default.get(requestOptions);
35
- })
32
+ .then((groupId) => planner_1.planner.getPlansByGroupId(groupId))
36
33
  .then((res) => {
37
- if (res.value && res.value.length > 0) {
38
- logger.log(res.value);
34
+ if (res && res.length > 0) {
35
+ logger.log(res);
39
36
  }
40
37
  cb();
41
38
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Auth_1 = require("../../../../Auth");
3
4
  const request_1 = require("../../../../request");
5
+ const planner_1 = require("../../../../utils/planner");
4
6
  const utils_1 = require("../../../../utils");
5
7
  const GraphCommand_1 = require("../../../base/GraphCommand");
6
8
  const commands_1 = require("../../commands");
@@ -29,6 +31,10 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
29
31
  return telemetryProps;
30
32
  }
31
33
  commandAction(logger, args, cb) {
34
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
35
+ this.handleError('This command does not support application permissions.', logger, cb);
36
+ return;
37
+ }
32
38
  this
33
39
  .getPlanId(args)
34
40
  .then(planId => {
@@ -151,22 +157,8 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
151
157
  }
152
158
  return this
153
159
  .getGroupId(args)
154
- .then((groupId) => {
155
- const requestOptions = {
156
- url: `${this.resource}/v1.0/planner/plans?$filter=(owner eq '${groupId}')`,
157
- headers: {
158
- accept: 'application/json;odata.metadata=none'
159
- },
160
- responseType: 'json'
161
- };
162
- return request_1.default.get(requestOptions);
163
- }).then((response) => {
164
- const plan = response.value.find(val => val.title === args.options.planName);
165
- if (!plan) {
166
- return Promise.reject(`The specified plan does not exist`);
167
- }
168
- return Promise.resolve(plan.id);
169
- });
160
+ .then((groupId) => planner_1.planner.getPlanByName(args.options.planName, groupId))
161
+ .then(plan => plan.id);
170
162
  }
171
163
  getGroupId(args) {
172
164
  if (args.options.ownerGroupId) {
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../../../utils");
4
+ const Auth_1 = require("../../../../Auth");
3
5
  const request_1 = require("../../../../request");
4
6
  const GraphCommand_1 = require("../../../base/GraphCommand");
5
7
  const commands_1 = require("../../commands");
@@ -11,6 +13,10 @@ class PlannerTaskDetailsGetCommand extends GraphCommand_1.default {
11
13
  return 'Retrieve the details of the specified planner task';
12
14
  }
13
15
  commandAction(logger, args, cb) {
16
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
17
+ this.handleError('This command does not support application permissions.', logger, cb);
18
+ return;
19
+ }
14
20
  const requestOptions = {
15
21
  url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.taskId)}/details`,
16
22
  headers: {
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("../../../../utils");
3
4
  const request_1 = require("../../../../request");
5
+ const utils_2 = require("../../../../utils");
6
+ const planner_1 = require("../../../../utils/planner");
4
7
  const GraphCommand_1 = require("../../../base/GraphCommand");
5
8
  const commands_1 = require("../../commands");
9
+ const Auth_1 = require("../../../../Auth");
6
10
  class PlannerTaskGetCommand extends GraphCommand_1.default {
7
11
  get name() {
8
12
  return commands_1.default.TASK_GET;
@@ -11,27 +15,154 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
11
15
  return 'Retrieve the the specified planner task';
12
16
  }
13
17
  commandAction(logger, args, cb) {
18
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
19
+ this.handleError('This command does not support application permissions.', logger, cb);
20
+ return;
21
+ }
22
+ this
23
+ .getTaskId(args.options)
24
+ .then(taskId => {
25
+ const requestOptions = {
26
+ url: `${this.resource}/beta/planner/tasks/${encodeURIComponent(taskId)}`,
27
+ headers: {
28
+ accept: 'application/json;odata.metadata=none'
29
+ },
30
+ responseType: 'json'
31
+ };
32
+ return request_1.default.get(requestOptions);
33
+ })
34
+ .then((res) => {
35
+ logger.log(res);
36
+ cb();
37
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
38
+ }
39
+ getTaskId(options) {
40
+ if (options.id) {
41
+ return Promise.resolve(options.id);
42
+ }
43
+ return this
44
+ .getBucketId(options)
45
+ .then(bucketId => {
46
+ const requestOptions = {
47
+ url: `${this.resource}/v1.0/planner/buckets/${bucketId}/tasks?$select=id,title`,
48
+ headers: {
49
+ accept: 'application/json;odata.metadata=none'
50
+ },
51
+ responseType: 'json'
52
+ };
53
+ return request_1.default.get(requestOptions);
54
+ })
55
+ .then((response) => {
56
+ const title = options.title;
57
+ const tasks = response.value.filter(val => { var _a; return ((_a = val.title) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === title.toLocaleLowerCase(); });
58
+ if (!tasks.length) {
59
+ return Promise.reject(`The specified task ${options.title} does not exist`);
60
+ }
61
+ if (tasks.length > 1) {
62
+ return Promise.reject(`Multiple tasks with title ${options.title} found: ${tasks.map(x => x.id)}`);
63
+ }
64
+ return Promise.resolve(tasks[0].id);
65
+ });
66
+ }
67
+ getBucketId(options) {
68
+ if (options.bucketId) {
69
+ return Promise.resolve(options.bucketId);
70
+ }
71
+ return this
72
+ .getPlanId(options)
73
+ .then(planId => {
74
+ const requestOptions = {
75
+ url: `${this.resource}/v1.0/planner/plans/${planId}/buckets?$select=id,name`,
76
+ headers: {
77
+ accept: 'application/json;odata.metadata=none'
78
+ },
79
+ responseType: 'json'
80
+ };
81
+ return request_1.default.get(requestOptions);
82
+ })
83
+ .then((response) => {
84
+ const bucketName = options.bucketName;
85
+ const buckets = response.value.filter(val => { var _a; return ((_a = val.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === bucketName.toLocaleLowerCase(); });
86
+ if (!buckets.length) {
87
+ return Promise.reject(`The specified bucket ${options.bucketName} does not exist`);
88
+ }
89
+ if (buckets.length > 1) {
90
+ return Promise.reject(`Multiple buckets with name ${options.bucketName} found: ${buckets.map(x => x.id)}`);
91
+ }
92
+ return Promise.resolve(buckets[0].id);
93
+ });
94
+ }
95
+ getPlanId(options) {
96
+ if (options.planId) {
97
+ return Promise.resolve(options.planId);
98
+ }
99
+ return this
100
+ .getGroupId(options)
101
+ .then(groupId => planner_1.planner.getPlanByName(options.planName, groupId))
102
+ .then(plan => plan.id);
103
+ }
104
+ getGroupId(options) {
105
+ if (options.ownerGroupId) {
106
+ return Promise.resolve(options.ownerGroupId);
107
+ }
14
108
  const requestOptions = {
15
- url: `${this.resource}/beta/planner/tasks/${encodeURIComponent(args.options.id)}`,
109
+ url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(options.ownerGroupName)}'&$select=id`,
16
110
  headers: {
17
111
  accept: 'application/json;odata.metadata=none'
18
112
  },
19
113
  responseType: 'json'
20
114
  };
21
- request_1.default
115
+ return request_1.default
22
116
  .get(requestOptions)
23
- .then((res) => {
24
- logger.log(res);
25
- cb();
26
- }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
117
+ .then(response => {
118
+ const groups = response.value;
119
+ if (!groups.length) {
120
+ return Promise.reject(`The specified ownerGroup ${options.ownerGroupName} does not exist`);
121
+ }
122
+ if (groups.length > 1) {
123
+ return Promise.reject(`Multiple ownerGroups with name ${options.ownerGroupName} found: ${groups.map(x => x.id)}`);
124
+ }
125
+ return Promise.resolve(groups[0].id);
126
+ });
27
127
  }
28
128
  options() {
29
129
  const options = [
30
- { option: '-i, --id <id>' }
130
+ { option: '-i, --id [id]' },
131
+ { option: '-t, --title [title]' },
132
+ { option: '--bucketId [bucketId]' },
133
+ { option: '--bucketName [bucketName]' },
134
+ { option: '--planId [planId]' },
135
+ { option: '--planName [planName]' },
136
+ { option: '--ownerGroupId [ownerGroupId]' },
137
+ { option: '--ownerGroupName [ownerGroupName]' }
31
138
  ];
32
139
  const parentOptions = super.options();
33
140
  return options.concat(parentOptions);
34
141
  }
142
+ validate(args) {
143
+ if (args.options.title && !args.options.bucketId && !args.options.bucketName) {
144
+ return 'Specify either bucketId or bucketName when using title';
145
+ }
146
+ if (args.options.title && args.options.bucketId && args.options.bucketName) {
147
+ return 'Specify either bucketId or bucketName when using title but not both';
148
+ }
149
+ if (args.options.bucketName && !args.options.planId && !args.options.planName) {
150
+ return 'Specify either planId or planName when using bucketName';
151
+ }
152
+ if (args.options.bucketName && args.options.planId && args.options.planName) {
153
+ return 'Specify either planId or planName when using bucketName but not both';
154
+ }
155
+ if (args.options.planName && !args.options.ownerGroupId && !args.options.ownerGroupName) {
156
+ return 'Specify either ownerGroupId or ownerGroupName when using planName';
157
+ }
158
+ if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
159
+ return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
160
+ }
161
+ if (args.options.ownerGroupId && !utils_2.validation.isValidGuid(args.options.ownerGroupId)) {
162
+ return `${args.options.ownerGroupId} is not a valid GUID`;
163
+ }
164
+ return true;
165
+ }
35
166
  }
36
167
  module.exports = new PlannerTaskGetCommand();
37
168
  //# sourceMappingURL=task-get.js.map
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_1 = require("../../../../request");
4
3
  const utils_1 = require("../../../../utils");
4
+ const Auth_1 = require("../../../../Auth");
5
+ const request_1 = require("../../../../request");
6
+ const planner_1 = require("../../../../utils/planner");
5
7
  const GraphCommand_1 = require("../../../base/GraphCommand");
6
8
  const commands_1 = require("../../commands");
7
9
  class PlannerTaskListCommand extends GraphCommand_1.default {
@@ -25,6 +27,10 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
25
27
  return ['id', 'title', 'startDateTime', 'dueDateTime', 'completedDateTime'];
26
28
  }
27
29
  commandAction(logger, args, cb) {
30
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
31
+ this.handleError('This command does not support application permissions.', logger, cb);
32
+ return;
33
+ }
28
34
  const bucketName = args.options.bucketName;
29
35
  let bucketId = args.options.bucketId;
30
36
  const planName = args.options.planName;
@@ -35,11 +41,11 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
35
41
  .getBucketId(args)
36
42
  .then((retrievedBucketId) => {
37
43
  bucketId = retrievedBucketId;
38
- return utils_1.odata.getAllItems(`${this.resource}/v1.0/planner/buckets/${bucketId}/tasks`, logger);
44
+ return utils_1.odata.getAllItems(`${this.resource}/v1.0/planner/buckets/${bucketId}/tasks`);
39
45
  })
40
46
  .then((tasks) => {
41
47
  taskItems = tasks;
42
- return utils_1.odata.getAllItems(`${this.resource}/beta/planner/buckets/${bucketId}/tasks`, logger);
48
+ return utils_1.odata.getAllItems(`${this.resource}/beta/planner/buckets/${bucketId}/tasks`);
43
49
  })
44
50
  .then((betaTasks) => {
45
51
  logger.log(this.mergeTaskPriority(taskItems, betaTasks));
@@ -51,11 +57,11 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
51
57
  .getPlanId(args)
52
58
  .then((retrievedPlanId) => {
53
59
  planId = retrievedPlanId;
54
- return utils_1.odata.getAllItems(`${this.resource}/v1.0/planner/plans/${planId}/tasks`, logger);
60
+ return utils_1.odata.getAllItems(`${this.resource}/v1.0/planner/plans/${planId}/tasks`);
55
61
  })
56
62
  .then((tasks) => {
57
63
  taskItems = tasks;
58
- return utils_1.odata.getAllItems(`${this.resource}/beta/planner/plans/${planId}/tasks`, logger);
64
+ return utils_1.odata.getAllItems(`${this.resource}/beta/planner/plans/${planId}/tasks`);
59
65
  })
60
66
  .then((betaTasks) => {
61
67
  logger.log(this.mergeTaskPriority(taskItems, betaTasks));
@@ -64,10 +70,10 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
64
70
  }
65
71
  else {
66
72
  utils_1.odata
67
- .getAllItems(`${this.resource}/v1.0/me/planner/tasks`, logger)
73
+ .getAllItems(`${this.resource}/v1.0/me/planner/tasks`)
68
74
  .then((tasks) => {
69
75
  taskItems = tasks;
70
- return utils_1.odata.getAllItems(`${this.resource}/beta/me/planner/tasks`, logger);
76
+ return utils_1.odata.getAllItems(`${this.resource}/beta/me/planner/tasks`);
71
77
  })
72
78
  .then((betaTasks) => {
73
79
  logger.log(this.mergeTaskPriority(taskItems, betaTasks));
@@ -105,23 +111,8 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
105
111
  }
106
112
  return this
107
113
  .getGroupId(args)
108
- .then((groupId) => {
109
- const requestOptions = {
110
- url: `${this.resource}/v1.0/planner/plans?$filter=(owner eq '${groupId}')`,
111
- headers: {
112
- accept: 'application/json;odata.metadata=none'
113
- },
114
- responseType: 'json'
115
- };
116
- return request_1.default.get(requestOptions);
117
- })
118
- .then(response => {
119
- const plan = response.value.find(val => val.title === args.options.planName);
120
- if (!plan) {
121
- return Promise.reject(`The specified plan does not exist`);
122
- }
123
- return Promise.resolve(plan.id);
124
- });
114
+ .then((groupId) => planner_1.planner.getPlanByName(args.options.planName, groupId))
115
+ .then(plan => plan.id);
125
116
  }
126
117
  getGroupId(args) {
127
118
  if (args.options.ownerGroupId) {
@@ -0,0 +1,75 @@
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 PlannerTaskReferenceAddCommand extends GraphCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.TASK_REFERENCE_ADD;
10
+ }
11
+ get description() {
12
+ return 'Adds a new reference to a Planner task';
13
+ }
14
+ commandAction(logger, args, cb) {
15
+ this
16
+ .getTaskDetailsEtag(args.options.taskId)
17
+ .then(etag => {
18
+ const requestOptionsTaskDetails = {
19
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.taskId)}/details`,
20
+ headers: {
21
+ 'accept': 'application/json;odata.metadata=none',
22
+ 'If-Match': etag,
23
+ 'Prefer': 'return=representation'
24
+ },
25
+ responseType: 'json',
26
+ data: {
27
+ references: {
28
+ [utils_1.formatting.openTypesEncoder(args.options.url)]: Object.assign(Object.assign({ '@odata.type': 'microsoft.graph.plannerExternalReference', previewPriority: ' !' }, (args.options.alias && { alias: args.options.alias })), (args.options.type && { type: args.options.type }))
29
+ }
30
+ }
31
+ };
32
+ return request_1.default.patch(requestOptionsTaskDetails);
33
+ })
34
+ .then((res) => {
35
+ logger.log(res.references);
36
+ cb();
37
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
38
+ }
39
+ getTaskDetailsEtag(taskId) {
40
+ const requestOptions = {
41
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(taskId)}/details`,
42
+ headers: {
43
+ accept: 'application/json'
44
+ },
45
+ responseType: 'json'
46
+ };
47
+ return request_1.default
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
+ });
56
+ }
57
+ options() {
58
+ const options = [
59
+ { option: '-i, --taskId <taskId>' },
60
+ { option: '-u, --url <url>' },
61
+ { option: '--alias [alias]' },
62
+ { option: '--type [type]' }
63
+ ];
64
+ const parentOptions = super.options();
65
+ return options.concat(parentOptions);
66
+ }
67
+ validate(args) {
68
+ if (args.options.type && ['powerpoint', 'word', 'excel', 'other'].indexOf(args.options.type.toLocaleLowerCase()) === -1) {
69
+ return `${args.options.type} is not a valid type value. Allowed values PowerPoint|Word|Excel|Other`;
70
+ }
71
+ return true;
72
+ }
73
+ }
74
+ module.exports = new PlannerTaskReferenceAddCommand();
75
+ //# sourceMappingURL=task-reference-add.js.map
@@ -0,0 +1,45 @@
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
+ const utils_1 = require("../../../../utils");
7
+ const Auth_1 = require("../../../../Auth");
8
+ class PlannerTaskReferenceListCommand extends GraphCommand_1.default {
9
+ get name() {
10
+ return commands_1.default.TASK_REFERENCE_LIST;
11
+ }
12
+ get description() {
13
+ return 'Retrieve the references of the specified planner task';
14
+ }
15
+ commandAction(logger, args, cb) {
16
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
17
+ this.handleError('This command does not support application permissions.', logger, cb);
18
+ return;
19
+ }
20
+ const requestOptions = {
21
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.taskId)}/details?$select=references`,
22
+ headers: {
23
+ accept: 'application/json;odata.metadata=none'
24
+ },
25
+ responseType: 'json'
26
+ };
27
+ request_1.default
28
+ .get(requestOptions)
29
+ .then((res) => {
30
+ logger.log(res.references);
31
+ cb();
32
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
33
+ }
34
+ options() {
35
+ const options = [
36
+ {
37
+ option: '-i, --taskId <taskId>'
38
+ }
39
+ ];
40
+ const parentOptions = super.options();
41
+ return options.concat(parentOptions);
42
+ }
43
+ }
44
+ module.exports = new PlannerTaskReferenceListCommand();
45
+ //# sourceMappingURL=task-reference-list.js.map