@pnp/cli-microsoft365 5.3.0 → 5.4.0-beta.0f3627d

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 (127) hide show
  1. package/.devcontainer/Dockerfile +1 -1
  2. package/.eslintrc.js +1 -0
  3. package/dist/m365/aad/commands/app/app-set.js +4 -1
  4. package/dist/m365/aad/commands/o365group/o365group-conversation-post-list.js +4 -19
  5. package/dist/m365/aad/commands/o365group/o365group-get.js +3 -9
  6. package/dist/m365/base/PlannerCommand.js +10 -0
  7. package/dist/m365/flow/commands/flow-export.js +3 -3
  8. package/dist/m365/planner/commands/bucket/bucket-add.js +4 -16
  9. package/dist/m365/planner/commands/bucket/bucket-get.js +5 -19
  10. package/dist/m365/planner/commands/bucket/bucket-list.js +4 -17
  11. package/dist/m365/planner/commands/bucket/bucket-remove.js +6 -20
  12. package/dist/m365/planner/commands/bucket/bucket-set.js +5 -19
  13. package/dist/m365/planner/commands/plan/plan-add.js +4 -16
  14. package/dist/m365/planner/commands/plan/plan-details-get.js +4 -19
  15. package/dist/m365/planner/commands/plan/plan-get.js +4 -17
  16. package/dist/m365/planner/commands/plan/plan-list.js +4 -17
  17. package/dist/m365/planner/commands/task/task-add.js +4 -16
  18. package/dist/m365/planner/commands/task/task-checklistitem-add.js +89 -0
  19. package/dist/m365/planner/commands/task/{task-details-get.js → task-checklistitem-list.js} +21 -13
  20. package/dist/m365/planner/commands/task/task-checklistitem-remove.js +85 -0
  21. package/dist/m365/planner/commands/task/task-get.js +61 -34
  22. package/dist/m365/planner/commands/task/task-list.js +4 -16
  23. package/dist/m365/planner/commands/task/task-reference-remove.js +125 -0
  24. package/dist/m365/planner/commands/task/task-remove.js +201 -0
  25. package/dist/m365/planner/commands/task/task-set.js +4 -16
  26. package/dist/m365/planner/commands/tenant/tenant-settings-list.js +33 -0
  27. package/dist/m365/planner/commands.js +8 -2
  28. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002009_DEVDEP_microsoft_sp_tslint_rules.js +2 -2
  29. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002018_DEVDEP_microsoft_rush_stack_compiler_3_9.js +2 -2
  30. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002020_DEVDEP_microsoft_rush_stack_compiler_4_5.js +17 -0
  31. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002021_DEVDEP_rushstack_eslint_config.js +14 -0
  32. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002022_DEVDEP_microsoft_eslint_plugin_spfx.js +14 -0
  33. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002023_DEVDEP_microsoft_eslint_config_spfx.js +14 -0
  34. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002024_DEVDEP_eslint.js +14 -0
  35. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN002025_DEVDEP_eslint_plugin_react_hooks.js +18 -0
  36. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN015008_FILE_eslintrc_js.js +14 -0
  37. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.15.0-beta.6.js → upgrade-1.15.0-rc.0.js} +49 -25
  38. package/dist/m365/spfx/commands/project/project-upgrade.js +1 -1
  39. package/dist/m365/spo/commands/contenttype/contenttype-add.js +1 -1
  40. package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +1 -1
  41. package/dist/m365/spo/commands/contenttype/contenttype-get.js +1 -1
  42. package/dist/m365/spo/commands/eventreceiver/eventreceiver-get.js +3 -3
  43. package/dist/m365/spo/commands/eventreceiver/eventreceiver-list.js +102 -0
  44. package/dist/m365/spo/commands/field/field-add.js +1 -1
  45. package/dist/m365/spo/commands/field/field-get.js +5 -5
  46. package/dist/m365/spo/commands/field/field-list.js +3 -3
  47. package/dist/m365/spo/commands/field/field-remove.js +5 -5
  48. package/dist/m365/spo/commands/file/file-sharinginfo-get.js +1 -1
  49. package/dist/m365/spo/commands/list/list-contenttype-add.js +3 -3
  50. package/dist/m365/spo/commands/list/list-contenttype-default-set.js +2 -2
  51. package/dist/m365/spo/commands/list/list-contenttype-list.js +3 -3
  52. package/dist/m365/spo/commands/list/list-contenttype-remove.js +3 -3
  53. package/dist/m365/spo/commands/list/list-get.js +2 -2
  54. package/dist/m365/spo/commands/list/list-label-get.js +3 -3
  55. package/dist/m365/spo/commands/list/list-label-set.js +2 -2
  56. package/dist/m365/spo/commands/list/list-list.js +10 -1
  57. package/dist/m365/spo/commands/list/list-remove.js +2 -2
  58. package/dist/m365/spo/commands/list/list-roleinheritance-break.js +2 -2
  59. package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +2 -2
  60. package/dist/m365/spo/commands/list/list-sitescript-get.js +3 -3
  61. package/dist/m365/spo/commands/list/list-view-add.js +6 -3
  62. package/dist/m365/spo/commands/list/list-view-field-add.js +2 -2
  63. package/dist/m365/spo/commands/list/list-view-field-remove.js +2 -2
  64. package/dist/m365/spo/commands/list/list-view-field-set.js +2 -2
  65. package/dist/m365/spo/commands/list/list-view-get.js +4 -4
  66. package/dist/m365/spo/commands/list/list-view-list.js +3 -3
  67. package/dist/m365/spo/commands/list/list-view-remove.js +3 -3
  68. package/dist/m365/spo/commands/list/list-view-set.js +3 -3
  69. package/dist/m365/spo/commands/list/list-webhook-add.js +3 -3
  70. package/dist/m365/spo/commands/list/list-webhook-get.js +3 -3
  71. package/dist/m365/spo/commands/list/list-webhook-list.js +5 -5
  72. package/dist/m365/spo/commands/list/list-webhook-remove.js +4 -4
  73. package/dist/m365/spo/commands/list/list-webhook-set.js +3 -3
  74. package/dist/m365/spo/commands/listitem/listitem-add.js +2 -2
  75. package/dist/m365/spo/commands/listitem/listitem-attachment-list.js +2 -2
  76. package/dist/m365/spo/commands/listitem/listitem-get.js +2 -2
  77. package/dist/m365/spo/commands/listitem/listitem-isrecord.js +2 -2
  78. package/dist/m365/spo/commands/listitem/listitem-list.js +31 -11
  79. package/dist/m365/spo/commands/listitem/listitem-record-declare.js +2 -2
  80. package/dist/m365/spo/commands/listitem/listitem-record-undeclare.js +2 -2
  81. package/dist/m365/spo/commands/listitem/listitem-remove.js +2 -2
  82. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-break.js +2 -2
  83. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-reset.js +2 -2
  84. package/dist/m365/spo/commands/listitem/listitem-set.js +2 -2
  85. package/dist/m365/spo/commands/roledefinition/roledefinition-remove.js +82 -0
  86. package/dist/m365/spo/commands/site/site-remove.js +23 -37
  87. package/dist/m365/spo/commands.js +2 -0
  88. package/dist/m365/teams/commands/app/app-list.js +6 -20
  89. package/dist/m365/teams/commands/channel/channel-get.js +6 -19
  90. package/dist/m365/teams/commands/channel/channel-list.js +6 -18
  91. package/dist/m365/teams/commands/channel/channel-member-add.js +7 -18
  92. package/dist/m365/teams/commands/channel/channel-member-list.js +6 -19
  93. package/dist/m365/teams/commands/channel/channel-member-remove.js +6 -19
  94. package/dist/m365/teams/commands/channel/channel-member-set.js +6 -19
  95. package/dist/m365/teams/commands/tab/tab-get.js +6 -19
  96. package/dist/m365/teams/commands/team/team-add.js +2 -7
  97. package/dist/m365/teams/commands/team/team-get.js +6 -19
  98. package/dist/utils/aadGroup.js +57 -0
  99. package/dist/utils/index.js +2 -0
  100. package/dist/utils/validation.js +12 -2
  101. package/docs/docs/cmd/aad/app/app-set.md +1 -1
  102. package/docs/docs/cmd/file/file-list.md +4 -4
  103. package/docs/docs/cmd/planner/bucket/bucket-get.md +1 -1
  104. package/docs/docs/cmd/planner/bucket/bucket-remove.md +2 -2
  105. package/docs/docs/cmd/planner/bucket/bucket-set.md +5 -5
  106. package/docs/docs/cmd/planner/plan/plan-details-get.md +2 -2
  107. package/docs/docs/cmd/planner/plan/plan-get.md +4 -4
  108. package/docs/docs/cmd/planner/task/task-checklistitem-add.md +36 -0
  109. package/docs/docs/cmd/planner/task/task-checklistitem-list.md +24 -0
  110. package/docs/docs/cmd/planner/task/task-checklistitem-remove.md +36 -0
  111. package/docs/docs/cmd/planner/task/task-get.md +7 -9
  112. package/docs/docs/cmd/planner/task/task-list.md +2 -2
  113. package/docs/docs/cmd/planner/task/task-reference-remove.md +39 -0
  114. package/docs/docs/cmd/planner/task/task-remove.md +78 -0
  115. package/docs/docs/cmd/planner/task/task-set.md +2 -2
  116. package/docs/docs/cmd/planner/tenant/tenant-settings-list.md +28 -0
  117. package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
  118. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-list.md +64 -0
  119. package/docs/docs/cmd/spo/file/file-checkout.md +1 -1
  120. package/docs/docs/cmd/spo/list/list-list.md +3 -0
  121. package/docs/docs/cmd/spo/list/list-view-add.md +13 -4
  122. package/docs/docs/cmd/spo/listitem/listitem-list.md +16 -10
  123. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-break.md +2 -2
  124. package/docs/docs/cmd/spo/roledefinition/roledefinition-remove.md +36 -0
  125. package/npm-shrinkwrap.json +257 -1104
  126. package/package.json +25 -21
  127. package/docs/docs/cmd/planner/task/task-details-get.md +0 -24
@@ -5,12 +5,15 @@ const Auth_1 = require("../../../../Auth");
5
5
  const request_1 = require("../../../../request");
6
6
  const GraphCommand_1 = require("../../../base/GraphCommand");
7
7
  const commands_1 = require("../../commands");
8
- class PlannerTaskDetailsGetCommand extends GraphCommand_1.default {
8
+ class PlannerTaskChecklistItemListCommand extends GraphCommand_1.default {
9
9
  get name() {
10
- return commands_1.default.TASK_DETAILS_GET;
10
+ return commands_1.default.TASK_CHECKLISTITEM_LIST;
11
11
  }
12
12
  get description() {
13
- return 'Retrieve the details of the specified planner task';
13
+ return "Lists the checklist items of a Planner task.";
14
+ }
15
+ defaultProperties() {
16
+ return ['id', 'title', 'isChecked'];
14
17
  }
15
18
  commandAction(logger, args, cb) {
16
19
  if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
@@ -18,28 +21,33 @@ class PlannerTaskDetailsGetCommand extends GraphCommand_1.default {
18
21
  return;
19
22
  }
20
23
  const requestOptions = {
21
- url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.taskId)}/details`,
24
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(args.options.taskId)}/details?$select=checklist`,
22
25
  headers: {
23
- accept: 'application/json;odata.metadata=none'
26
+ accept: "application/json;odata.metadata=none"
24
27
  },
25
- responseType: 'json'
28
+ responseType: "json"
26
29
  };
27
- request_1.default
28
- .get(requestOptions)
29
- .then((res) => {
30
- logger.log(res);
30
+ request_1.default.get(requestOptions).then((res) => {
31
+ if (!args.options.output || args.options.output === 'json') {
32
+ logger.log(res.checklist);
33
+ }
34
+ else {
35
+ //converted to text friendly output
36
+ const output = Object.getOwnPropertyNames(res.checklist).map(prop => (Object.assign({ id: prop }, res.checklist[prop])));
37
+ logger.log(output);
38
+ }
31
39
  cb();
32
40
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
33
41
  }
34
42
  options() {
35
43
  const options = [
36
44
  {
37
- option: '-i, --taskId <taskId>'
45
+ option: "-i, --taskId <taskId>"
38
46
  }
39
47
  ];
40
48
  const parentOptions = super.options();
41
49
  return options.concat(parentOptions);
42
50
  }
43
51
  }
44
- module.exports = new PlannerTaskDetailsGetCommand();
45
- //# sourceMappingURL=task-details-get.js.map
52
+ module.exports = new PlannerTaskChecklistItemListCommand();
53
+ //# sourceMappingURL=task-checklistitem-list.js.map
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("../../../../cli");
4
+ const request_1 = require("../../../../request");
5
+ const GraphCommand_1 = require("../../../base/GraphCommand");
6
+ const commands_1 = require("../../commands");
7
+ class PlannerTaskChecklistItemRemoveCommand extends GraphCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.TASK_CHECKLISTITEM_REMOVE;
10
+ }
11
+ get description() {
12
+ return 'Removes the checklist item from the planner task';
13
+ }
14
+ getTelemetryProperties(args) {
15
+ const telemetryProps = super.getTelemetryProperties(args);
16
+ telemetryProps.confirm = (!(!args.options.confirm)).toString();
17
+ return telemetryProps;
18
+ }
19
+ commandAction(logger, args, cb) {
20
+ if (args.options.confirm) {
21
+ this.removeChecklistitem(logger, args, cb);
22
+ }
23
+ else {
24
+ cli_1.Cli.prompt({
25
+ type: 'confirm',
26
+ name: 'continue',
27
+ default: false,
28
+ message: `Are you sure you want to remove the checklist item with id ${args.options.id} from the planner task?`
29
+ }, (result) => {
30
+ if (!result.continue) {
31
+ cb();
32
+ }
33
+ else {
34
+ this.removeChecklistitem(logger, args, cb);
35
+ }
36
+ });
37
+ }
38
+ }
39
+ removeChecklistitem(logger, args, cb) {
40
+ this
41
+ .getTaskDetails(args.options.taskId)
42
+ .then(task => {
43
+ if (!task.checklist || !task.checklist[args.options.id]) {
44
+ return Promise.reject(`The specified checklist item with id ${args.options.id} does not exist`);
45
+ }
46
+ const requestOptionsTaskDetails = {
47
+ url: `${this.resource}/v1.0/planner/tasks/${args.options.taskId}/details`,
48
+ headers: {
49
+ 'accept': 'application/json;odata.metadata=none',
50
+ 'If-Match': task['@odata.etag'],
51
+ 'Prefer': 'return=representation'
52
+ },
53
+ responseType: 'json',
54
+ data: {
55
+ checklist: {
56
+ [args.options.id]: null
57
+ }
58
+ }
59
+ };
60
+ return request_1.default.patch(requestOptionsTaskDetails);
61
+ })
62
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
63
+ }
64
+ getTaskDetails(taskId) {
65
+ const requestOptions = {
66
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(taskId)}/details?$select=checklist`,
67
+ headers: {
68
+ accept: 'application/json;odata.metadata=minimal'
69
+ },
70
+ responseType: 'json'
71
+ };
72
+ return request_1.default.get(requestOptions);
73
+ }
74
+ options() {
75
+ const options = [
76
+ { option: '-i, --id <id>' },
77
+ { option: '--taskId <taskId>' },
78
+ { option: '--confirm' }
79
+ ];
80
+ const parentOptions = super.options();
81
+ return options.concat(parentOptions);
82
+ }
83
+ }
84
+ module.exports = new PlannerTaskChecklistItemRemoveCommand();
85
+ //# sourceMappingURL=task-checklistitem-remove.js.map
@@ -1,41 +1,78 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const utils_1 = require("../../../../utils");
3
+ const Auth_1 = require("../../../../Auth");
4
4
  const request_1 = require("../../../../request");
5
- const utils_2 = require("../../../../utils");
5
+ const utils_1 = require("../../../../utils");
6
+ const aadGroup_1 = require("../../../../utils/aadGroup");
6
7
  const planner_1 = require("../../../../utils/planner");
7
8
  const GraphCommand_1 = require("../../../base/GraphCommand");
8
9
  const commands_1 = require("../../commands");
9
- const Auth_1 = require("../../../../Auth");
10
10
  class PlannerTaskGetCommand extends GraphCommand_1.default {
11
11
  get name() {
12
12
  return commands_1.default.TASK_GET;
13
13
  }
14
+ alias() {
15
+ return [commands_1.default.TASK_DETAILS_GET];
16
+ }
14
17
  get description() {
15
- return 'Retrieve the the specified planner task';
18
+ return 'Retrieve the specified planner task';
19
+ }
20
+ getTelemetryProperties(args) {
21
+ const telemetryProps = super.getTelemetryProperties(args);
22
+ telemetryProps.id = typeof args.options.id !== 'undefined';
23
+ telemetryProps.title = typeof args.options.title !== 'undefined';
24
+ telemetryProps.bucketId = typeof args.options.bucketId !== 'undefined';
25
+ telemetryProps.bucketName = typeof args.options.bucketName !== 'undefined';
26
+ telemetryProps.planId = typeof args.options.planId !== 'undefined';
27
+ telemetryProps.planName = typeof args.options.planName !== 'undefined';
28
+ telemetryProps.ownerGroupId = typeof args.options.ownerGroupId !== 'undefined';
29
+ telemetryProps.ownerGroupName = typeof args.options.ownerGroupName !== 'undefined';
30
+ return telemetryProps;
16
31
  }
17
32
  commandAction(logger, args, cb) {
33
+ this.showDeprecationWarning(logger, commands_1.default.TASK_DETAILS_GET, commands_1.default.TASK_GET);
18
34
  if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
19
35
  this.handleError('This command does not support application permissions.', logger, cb);
20
36
  return;
21
37
  }
38
+ // This check has been added to support task details get alias. Needs to be removed when deprecation is removed.
39
+ if (args.options.taskId) {
40
+ args.options.id = args.options.taskId;
41
+ }
22
42
  this
23
43
  .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
- })
44
+ .then(taskId => this.getTask(taskId))
45
+ .then(task => this.getTaskDetails(task))
34
46
  .then((res) => {
35
47
  logger.log(res);
36
48
  cb();
37
49
  }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
38
50
  }
51
+ getTask(taskId) {
52
+ const requestOptions = {
53
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(taskId)}`,
54
+ headers: {
55
+ accept: 'application/json;odata.metadata=none'
56
+ },
57
+ responseType: 'json'
58
+ };
59
+ return request_1.default.get(requestOptions);
60
+ }
61
+ getTaskDetails(task) {
62
+ const requestOptionsTaskDetails = {
63
+ url: `${this.resource}/v1.0/planner/tasks/${task.id}/details`,
64
+ headers: {
65
+ 'accept': 'application/json;odata.metadata=none',
66
+ 'Prefer': 'return=representation'
67
+ },
68
+ responseType: 'json'
69
+ };
70
+ return request_1.default
71
+ .get(requestOptionsTaskDetails)
72
+ .then(taskDetails => {
73
+ return Object.assign(Object.assign({}, task), taskDetails);
74
+ });
75
+ }
39
76
  getTaskId(options) {
40
77
  if (options.id) {
41
78
  return Promise.resolve(options.id);
@@ -105,28 +142,18 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
105
142
  if (options.ownerGroupId) {
106
143
  return Promise.resolve(options.ownerGroupId);
107
144
  }
108
- const requestOptions = {
109
- url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(options.ownerGroupName)}'&$select=id`,
110
- headers: {
111
- accept: 'application/json;odata.metadata=none'
112
- },
113
- responseType: 'json'
114
- };
115
- return request_1.default
116
- .get(requestOptions)
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
- });
145
+ return aadGroup_1.aadGroup
146
+ .getGroupByDisplayName(options.ownerGroupName)
147
+ .then(group => group.id);
148
+ }
149
+ optionSets() {
150
+ return [
151
+ ['id', 'title']
152
+ ];
127
153
  }
128
154
  options() {
129
155
  const options = [
156
+ { option: '--taskId [taskId]' },
130
157
  { option: '-i, --id [id]' },
131
158
  { option: '-t, --title [title]' },
132
159
  { option: '--bucketId [bucketId]' },
@@ -158,7 +185,7 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
158
185
  if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
159
186
  return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
160
187
  }
161
- if (args.options.ownerGroupId && !utils_2.validation.isValidGuid(args.options.ownerGroupId)) {
188
+ if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
162
189
  return `${args.options.ownerGroupId} is not a valid GUID`;
163
190
  }
164
191
  return true;
@@ -6,6 +6,7 @@ const request_1 = require("../../../../request");
6
6
  const planner_1 = require("../../../../utils/planner");
7
7
  const GraphCommand_1 = require("../../../base/GraphCommand");
8
8
  const commands_1 = require("../../commands");
9
+ const aadGroup_1 = require("../../../../utils/aadGroup");
9
10
  class PlannerTaskListCommand extends GraphCommand_1.default {
10
11
  get name() {
11
12
  return commands_1.default.TASK_LIST;
@@ -118,22 +119,9 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
118
119
  if (args.options.ownerGroupId) {
119
120
  return Promise.resolve(encodeURIComponent(args.options.ownerGroupId));
120
121
  }
121
- const requestOptions = {
122
- url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(args.options.ownerGroupName)}'`,
123
- headers: {
124
- accept: 'application/json;odata.metadata=none'
125
- },
126
- responseType: 'json'
127
- };
128
- return request_1.default
129
- .get(requestOptions)
130
- .then(response => {
131
- const group = response.value[0];
132
- if (!group) {
133
- return Promise.reject(`The specified owner group does not exist`);
134
- }
135
- return Promise.resolve(group.id);
136
- });
122
+ return aadGroup_1.aadGroup
123
+ .getGroupByDisplayName(args.options.ownerGroupName)
124
+ .then(group => group.id);
137
125
  }
138
126
  mergeTaskPriority(taskItems, betaTaskItems) {
139
127
  const findBetaTask = (id) => betaTaskItems.find(task => task.id === id);
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const cli_1 = require("../../../../cli");
4
+ const request_1 = require("../../../../request");
5
+ const utils_1 = require("../../../../utils");
6
+ const GraphCommand_1 = require("../../../base/GraphCommand");
7
+ const commands_1 = require("../../commands");
8
+ class PlannerTaskReferenceRemoveCommand extends GraphCommand_1.default {
9
+ get name() {
10
+ return commands_1.default.TASK_REFERENCE_REMOVE;
11
+ }
12
+ get description() {
13
+ return 'Removes the reference from the Planner task';
14
+ }
15
+ getTelemetryProperties(args) {
16
+ const telemetryProps = super.getTelemetryProperties(args);
17
+ telemetryProps.url = typeof args.options.url !== 'undefined';
18
+ telemetryProps.alias = typeof args.options.alias !== 'undefined';
19
+ telemetryProps.confirm = (!(!args.options.confirm)).toString();
20
+ return telemetryProps;
21
+ }
22
+ commandAction(logger, args, cb) {
23
+ if (args.options.confirm) {
24
+ this.removeReference(logger, args, cb);
25
+ }
26
+ else {
27
+ cli_1.Cli.prompt({
28
+ type: 'confirm',
29
+ name: 'continue',
30
+ default: false,
31
+ message: `Are you sure you want to remove the reference from the Planner task?`
32
+ }, (result) => {
33
+ if (!result.continue) {
34
+ cb();
35
+ }
36
+ else {
37
+ this.removeReference(logger, args, cb);
38
+ }
39
+ });
40
+ }
41
+ }
42
+ removeReference(logger, args, cb) {
43
+ this
44
+ .getTaskDetailsEtagAndUrl(args.options)
45
+ .then(({ etag, url }) => {
46
+ const requestOptionsTaskDetails = {
47
+ url: `${this.resource}/v1.0/planner/tasks/${args.options.taskId}/details`,
48
+ headers: {
49
+ 'accept': 'application/json;odata.metadata=none',
50
+ 'If-Match': etag,
51
+ 'Prefer': 'return=representation'
52
+ },
53
+ responseType: 'json',
54
+ data: {
55
+ references: {
56
+ [utils_1.formatting.openTypesEncoder(url)]: null
57
+ }
58
+ }
59
+ };
60
+ return request_1.default.patch(requestOptionsTaskDetails);
61
+ })
62
+ .then(() => {
63
+ cb();
64
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
65
+ }
66
+ getTaskDetailsEtagAndUrl(options) {
67
+ const requestOptions = {
68
+ url: `${this.resource}/v1.0/planner/tasks/${encodeURIComponent(options.taskId)}/details`,
69
+ headers: {
70
+ accept: 'application/json'
71
+ },
72
+ responseType: 'json'
73
+ };
74
+ let url = options.url;
75
+ return request_1.default
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
+ }
82
+ if (options.alias) {
83
+ const alias = options.alias;
84
+ 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) {
92
+ return Promise.reject(`The specified reference with alias ${options.alias} does not exist`);
93
+ }
94
+ if (urls.length > 1) {
95
+ return Promise.reject(`Multiple references with alias ${options.alias} found. Pass one of the following urls within the "--url" option : ${urls}`);
96
+ }
97
+ url = urls[0];
98
+ }
99
+ return Promise.resolve({ etag, url });
100
+ });
101
+ }
102
+ options() {
103
+ const options = [
104
+ { option: '-u, --url [url]' },
105
+ { option: '--alias [alias]' },
106
+ { option: '-i, --taskId <taskId>' },
107
+ { option: '--confirm' }
108
+ ];
109
+ const parentOptions = super.options();
110
+ return options.concat(parentOptions);
111
+ }
112
+ optionSets() {
113
+ return [
114
+ ['url', 'alias']
115
+ ];
116
+ }
117
+ validate(args) {
118
+ if (args.options.url && args.options.url.indexOf('https://') !== 0 && args.options.url.indexOf('http://') !== 0) {
119
+ return 'The url option should contain a valid URL. A valid URL starts with http(s)://';
120
+ }
121
+ return true;
122
+ }
123
+ }
124
+ module.exports = new PlannerTaskReferenceRemoveCommand();
125
+ //# sourceMappingURL=task-reference-remove.js.map
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const os = require("os");
4
+ const cli_1 = require("../../../../cli");
5
+ const request_1 = require("../../../../request");
6
+ const utils_1 = require("../../../../utils");
7
+ const planner_1 = require("../../../../utils/planner");
8
+ const GraphCommand_1 = require("../../../base/GraphCommand");
9
+ const commands_1 = require("../../commands");
10
+ class PlannerTaskRemoveCommand extends GraphCommand_1.default {
11
+ get name() {
12
+ return commands_1.default.TASK_REMOVE;
13
+ }
14
+ get description() {
15
+ return 'Removes the Microsoft Planner task from a plan';
16
+ }
17
+ commandAction(logger, args, cb) {
18
+ const removeTask = () => {
19
+ this
20
+ .getTask(args.options)
21
+ .then(task => {
22
+ const requestOptions = {
23
+ url: `${this.resource}/v1.0/planner/tasks/${task.id}`,
24
+ headers: {
25
+ accept: 'application/json;odata.metadata=none',
26
+ 'if-match': task['@odata.etag']
27
+ },
28
+ responseType: 'json'
29
+ };
30
+ return request_1.default.delete(requestOptions);
31
+ })
32
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
33
+ };
34
+ if (args.options.confirm) {
35
+ removeTask();
36
+ }
37
+ else {
38
+ cli_1.Cli.prompt({
39
+ type: 'confirm',
40
+ name: 'continue',
41
+ default: false,
42
+ message: `Are you sure you want to remove the task ${args.options.id || args.options.title}?`
43
+ }, (result) => {
44
+ if (!result.continue) {
45
+ cb();
46
+ }
47
+ else {
48
+ removeTask();
49
+ }
50
+ });
51
+ }
52
+ }
53
+ getTask(options) {
54
+ const { id, title } = options;
55
+ if (id) {
56
+ const requestOptions = {
57
+ url: `${this.resource}/v1.0/planner/tasks/${id}`,
58
+ headers: {
59
+ accept: 'application/json'
60
+ },
61
+ responseType: 'json'
62
+ };
63
+ return request_1.default.get(requestOptions);
64
+ }
65
+ return this
66
+ .getBucketId(options)
67
+ .then(bucketId => {
68
+ // $filter is not working on the buckets/{bucketId}/tasks endpoint, hence it is not being used.
69
+ return utils_1.odata.getAllItems(`${this.resource}/v1.0/planner/buckets/${bucketId}/tasks?$select=title,id`, 'minimal');
70
+ })
71
+ .then(tasks => {
72
+ const filteredtasks = tasks.filter(b => title.toLocaleLowerCase() === b.title.toLocaleLowerCase());
73
+ if (filteredtasks.length === 0) {
74
+ return Promise.reject(`The specified task ${title} does not exist`);
75
+ }
76
+ if (filteredtasks.length > 1) {
77
+ return Promise.reject(`Multiple tasks with title ${title} found: Please disambiguate: ${os.EOL}${filteredtasks.map(f => `- ${f.id}`).join(os.EOL)}`);
78
+ }
79
+ return Promise.resolve(filteredtasks[0]);
80
+ });
81
+ }
82
+ getBucketId(options) {
83
+ const { bucketId, bucketName } = options;
84
+ if (bucketId) {
85
+ return Promise.resolve(bucketId);
86
+ }
87
+ return this
88
+ .getPlanId(options)
89
+ .then(planId => {
90
+ const requestOptions = {
91
+ url: `${this.resource}/v1.0/planner/plans/${planId}/buckets?$select=id,name`,
92
+ headers: {
93
+ accept: 'application/json;odata.metadata=none'
94
+ },
95
+ responseType: 'json'
96
+ };
97
+ return request_1.default.get(requestOptions);
98
+ })
99
+ .then((buckets) => {
100
+ const filteredBuckets = buckets.value.filter(b => bucketName.toLocaleLowerCase() === b.name.toLocaleLowerCase());
101
+ if (filteredBuckets.length === 0) {
102
+ return Promise.reject(`The specified bucket ${bucketName} does not exist`);
103
+ }
104
+ if (filteredBuckets.length > 1) {
105
+ return Promise.reject(`Multiple buckets with name ${bucketName} found: Please disambiguate:${os.EOL}${filteredBuckets.map(f => `- ${f.id}`).join(os.EOL)}`);
106
+ }
107
+ return Promise.resolve(filteredBuckets[0].id);
108
+ });
109
+ }
110
+ getPlanId(options) {
111
+ const { planId, planTitle } = options;
112
+ if (planId) {
113
+ return Promise.resolve(planId);
114
+ }
115
+ return this
116
+ .getGroupId(options)
117
+ .then(groupId => planner_1.planner.getPlanByName(planTitle, groupId))
118
+ .then(plan => plan.id);
119
+ }
120
+ getGroupId(options) {
121
+ const { ownerGroupId, ownerGroupName } = options;
122
+ if (ownerGroupId) {
123
+ return Promise.resolve(ownerGroupId);
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
+ });
143
+ }
144
+ options() {
145
+ const options = [
146
+ { option: '-i, --id [id]' },
147
+ { option: '-t, --title [title]' },
148
+ { option: '--bucketId [bucketId]' },
149
+ { option: '--bucketName [bucketName]' },
150
+ { option: '--planId [planId]' },
151
+ { option: '--planTitle [planTitle]' },
152
+ { option: '--ownerGroupId [ownerGroupId]' },
153
+ { option: '--ownerGroupName [ownerGroupName]' },
154
+ { option: '--confirm' }
155
+ ];
156
+ const parentOptions = super.options();
157
+ return options.concat(parentOptions);
158
+ }
159
+ optionSets() {
160
+ return [
161
+ ['id', 'title']
162
+ ];
163
+ }
164
+ validate(args) {
165
+ if (args.options.id) {
166
+ if (args.options.bucketId || args.options.bucketName || args.options.planId || args.options.planTitle || args.options.ownerGroupId || args.options.ownerGroupName) {
167
+ return 'Don\'t specify bucketId,bucketName, planId, planTitle, ownerGroupId or ownerGroupName when using id';
168
+ }
169
+ }
170
+ if (args.options.title) {
171
+ if (!args.options.bucketId && !args.options.bucketName) {
172
+ return 'Specify either bucketId or bucketName when using title';
173
+ }
174
+ if (args.options.bucketId && args.options.bucketName) {
175
+ return 'Specify either bucketId or bucketName when using title but not both';
176
+ }
177
+ if (args.options.bucketName) {
178
+ if (!args.options.planId && !args.options.planTitle) {
179
+ return 'Specify either planId or planTitle when using bucketName';
180
+ }
181
+ if (args.options.planId && args.options.planTitle) {
182
+ return 'Specify either planId or planTitle when using bucketName but not both';
183
+ }
184
+ }
185
+ if (args.options.planTitle) {
186
+ if (!args.options.ownerGroupId && !args.options.ownerGroupName) {
187
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle';
188
+ }
189
+ if (args.options.ownerGroupId && args.options.ownerGroupName) {
190
+ return 'Specify either ownerGroupId or ownerGroupName when using planTitle but not both';
191
+ }
192
+ }
193
+ if (args.options.ownerGroupId && !utils_1.validation.isValidGuid(args.options.ownerGroupId)) {
194
+ return `${args.options.ownerGroupId} is not a valid GUID`;
195
+ }
196
+ }
197
+ return true;
198
+ }
199
+ }
200
+ module.exports = new PlannerTaskRemoveCommand();
201
+ //# sourceMappingURL=task-remove.js.map