@pnp/cli-microsoft365 5.3.0-beta.1ed1aa2 → 5.3.0-beta.24cd8e4

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 (46) hide show
  1. package/.eslintrc.js +1 -0
  2. package/dist/m365/aad/commands/approleassignment/approleassignment-list.js +55 -22
  3. package/dist/m365/aad/commands.js +1 -1
  4. package/dist/m365/app/commands/app-open.js +64 -0
  5. package/dist/m365/app/commands.js +1 -0
  6. package/dist/m365/planner/commands/bucket/bucket-add.js +5 -0
  7. package/dist/m365/planner/commands/bucket/bucket-get.js +203 -0
  8. package/dist/m365/planner/commands/bucket/bucket-list.js +6 -1
  9. package/dist/m365/planner/commands/bucket/bucket-remove.js +219 -0
  10. package/dist/m365/planner/commands/bucket/bucket-set.js +6 -1
  11. package/dist/m365/planner/commands/plan/plan-add.js +6 -1
  12. package/dist/m365/planner/commands/plan/plan-details-get.js +6 -1
  13. package/dist/m365/planner/commands/plan/plan-get.js +6 -1
  14. package/dist/m365/planner/commands/plan/plan-list.js +6 -1
  15. package/dist/m365/planner/commands/task/task-add.js +5 -0
  16. package/dist/m365/planner/commands/task/task-details-get.js +6 -0
  17. package/dist/m365/planner/commands/task/task-get.js +156 -7
  18. package/dist/m365/planner/commands/task/task-list.js +6 -1
  19. package/dist/m365/planner/commands/task/task-set.js +6 -1
  20. package/dist/m365/planner/commands.js +2 -0
  21. package/dist/m365/spo/commands/field/field-list.js +84 -0
  22. package/dist/m365/spo/commands/list/list-roleinheritance-break.js +84 -0
  23. package/dist/m365/spo/commands/list/list-roleinheritance-reset.js +76 -0
  24. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-break.js +83 -0
  25. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-reset.js +79 -0
  26. package/dist/m365/spo/commands/roledefinition/roledefinition-list.js +49 -0
  27. package/dist/m365/spo/commands.js +6 -0
  28. package/dist/m365/tenant/commands/security/security-alerts-list.js +71 -0
  29. package/dist/m365/tenant/commands.js +1 -0
  30. package/dist/utils/accessToken.js +18 -0
  31. package/docs/docs/cmd/app/app-open.md +45 -0
  32. package/docs/docs/cmd/planner/bucket/bucket-get.md +57 -0
  33. package/docs/docs/cmd/planner/bucket/bucket-remove.md +60 -0
  34. package/docs/docs/cmd/planner/task/task-get.md +30 -3
  35. package/docs/docs/cmd/spo/field/field-list.md +51 -0
  36. package/docs/docs/cmd/spo/list/list-roleinheritance-break.md +55 -0
  37. package/docs/docs/cmd/spo/list/list-roleinheritance-reset.md +36 -0
  38. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-break.md +58 -0
  39. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-reset.md +39 -0
  40. package/docs/docs/cmd/spo/roledefinition/roledefinition-list.md +24 -0
  41. package/docs/docs/cmd/teams/channel/channel-member-list.md +4 -4
  42. package/docs/docs/cmd/teams/channel/channel-member-remove.md +2 -2
  43. package/docs/docs/cmd/teams/channel/channel-member-set.md +2 -2
  44. package/docs/docs/cmd/tenant/security/security-alerts-list.md +30 -0
  45. package/npm-shrinkwrap.json +1515 -1282
  46. package/package.json +24 -24
@@ -1,8 +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");
5
4
  const GraphCommand_1 = require("../../../base/GraphCommand");
5
+ const Auth_1 = require("../../../../Auth");
6
+ const request_1 = require("../../../../request");
6
7
  const commands_1 = require("../../commands");
7
8
  class PlannerBucketSetCommand extends GraphCommand_1.default {
8
9
  get name() {
@@ -24,6 +25,10 @@ class PlannerBucketSetCommand extends GraphCommand_1.default {
24
25
  return telemetryProps;
25
26
  }
26
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
+ }
27
32
  this
28
33
  .getBucket(args)
29
34
  .then(bucket => {
@@ -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,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 PlannerPlanDetailsGetCommand extends GraphCommand_1.default {
@@ -24,6 +25,10 @@ class PlannerPlanDetailsGetCommand extends GraphCommand_1.default {
24
25
  return telemetryProps;
25
26
  }
26
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
+ }
27
32
  this
28
33
  .getGroupId(args)
29
34
  .then((groupId) => {
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const request_1 = require("../../../../request");
3
+ const Auth_1 = require("../../../../Auth");
4
4
  const utils_1 = require("../../../../utils");
5
+ const request_1 = require("../../../../request");
5
6
  const GraphCommand_1 = require("../../../base/GraphCommand");
6
7
  const commands_1 = require("../../commands");
7
8
  class PlannerPlanGetCommand extends GraphCommand_1.default {
@@ -23,6 +24,10 @@ class PlannerPlanGetCommand extends GraphCommand_1.default {
23
24
  return ['id', 'title', 'createdDateTime', 'owner', '@odata.etag'];
24
25
  }
25
26
  commandAction(logger, args, cb) {
27
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
28
+ this.handleError('This command does not support application permissions.', logger, cb);
29
+ return;
30
+ }
26
31
  if (args.options.id) {
27
32
  this
28
33
  .getPlan(args)
@@ -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 PlannerPlanListCommand extends GraphCommand_1.default {
@@ -21,6 +22,10 @@ class PlannerPlanListCommand 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,5 +1,6 @@
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");
4
5
  const utils_1 = require("../../../../utils");
5
6
  const GraphCommand_1 = require("../../../base/GraphCommand");
@@ -29,6 +30,10 @@ class PlannerTaskAddCommand extends GraphCommand_1.default {
29
30
  return telemetryProps;
30
31
  }
31
32
  commandAction(logger, args, cb) {
33
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
34
+ this.handleError('This command does not support application permissions.', logger, cb);
35
+ return;
36
+ }
32
37
  this
33
38
  .getPlanId(args)
34
39
  .then(planId => {
@@ -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,11 @@
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");
4
6
  const GraphCommand_1 = require("../../../base/GraphCommand");
5
7
  const commands_1 = require("../../commands");
8
+ const Auth_1 = require("../../../../Auth");
6
9
  class PlannerTaskGetCommand extends GraphCommand_1.default {
7
10
  get name() {
8
11
  return commands_1.default.TASK_GET;
@@ -11,27 +14,173 @@ class PlannerTaskGetCommand extends GraphCommand_1.default {
11
14
  return 'Retrieve the the specified planner task';
12
15
  }
13
16
  commandAction(logger, args, cb) {
17
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
18
+ this.handleError('This command does not support application permissions.', logger, cb);
19
+ return;
20
+ }
21
+ this
22
+ .getTaskId(args.options)
23
+ .then(taskId => {
24
+ const requestOptions = {
25
+ url: `${this.resource}/beta/planner/tasks/${encodeURIComponent(taskId)}`,
26
+ headers: {
27
+ accept: 'application/json;odata.metadata=none'
28
+ },
29
+ responseType: 'json'
30
+ };
31
+ return request_1.default.get(requestOptions);
32
+ })
33
+ .then((res) => {
34
+ logger.log(res);
35
+ cb();
36
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
37
+ }
38
+ getTaskId(options) {
39
+ if (options.id) {
40
+ return Promise.resolve(options.id);
41
+ }
42
+ return this
43
+ .getBucketId(options)
44
+ .then(bucketId => {
45
+ const requestOptions = {
46
+ url: `${this.resource}/v1.0/planner/buckets/${bucketId}/tasks?$select=id,title`,
47
+ headers: {
48
+ accept: 'application/json;odata.metadata=none'
49
+ },
50
+ responseType: 'json'
51
+ };
52
+ return request_1.default.get(requestOptions);
53
+ })
54
+ .then((response) => {
55
+ const title = options.title;
56
+ const tasks = response.value.filter(val => { var _a; return ((_a = val.title) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === title.toLocaleLowerCase(); });
57
+ if (!tasks.length) {
58
+ return Promise.reject(`The specified task ${options.title} does not exist`);
59
+ }
60
+ if (tasks.length > 1) {
61
+ return Promise.reject(`Multiple tasks with title ${options.title} found: ${tasks.map(x => x.id)}`);
62
+ }
63
+ return Promise.resolve(tasks[0].id);
64
+ });
65
+ }
66
+ getBucketId(options) {
67
+ if (options.bucketId) {
68
+ return Promise.resolve(options.bucketId);
69
+ }
70
+ return this
71
+ .getPlanId(options)
72
+ .then(planId => {
73
+ const requestOptions = {
74
+ url: `${this.resource}/v1.0/planner/plans/${planId}/buckets?$select=id,name`,
75
+ headers: {
76
+ accept: 'application/json;odata.metadata=none'
77
+ },
78
+ responseType: 'json'
79
+ };
80
+ return request_1.default.get(requestOptions);
81
+ })
82
+ .then((response) => {
83
+ const bucketName = options.bucketName;
84
+ const buckets = response.value.filter(val => { var _a; return ((_a = val.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === bucketName.toLocaleLowerCase(); });
85
+ if (!buckets.length) {
86
+ return Promise.reject(`The specified bucket ${options.bucketName} does not exist`);
87
+ }
88
+ if (buckets.length > 1) {
89
+ return Promise.reject(`Multiple buckets with name ${options.bucketName} found: ${buckets.map(x => x.id)}`);
90
+ }
91
+ return Promise.resolve(buckets[0].id);
92
+ });
93
+ }
94
+ getPlanId(options) {
95
+ if (options.planId) {
96
+ return Promise.resolve(options.planId);
97
+ }
98
+ return this
99
+ .getGroupId(options)
100
+ .then((groupId) => {
101
+ const requestOptions = {
102
+ url: `${this.resource}/v1.0/planner/plans?$filter=owner eq '${groupId}'&$select=id,title`,
103
+ headers: {
104
+ accept: 'application/json;odata.metadata=none'
105
+ },
106
+ responseType: 'json'
107
+ };
108
+ return request_1.default.get(requestOptions);
109
+ })
110
+ .then((response) => {
111
+ const planName = options.planName;
112
+ const plans = response.value.filter(val => { var _a; return ((_a = val.title) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) === planName.toLocaleLowerCase(); });
113
+ if (!plans.length) {
114
+ return Promise.reject(`The specified plan ${options.planName} does not exist`);
115
+ }
116
+ if (plans.length > 1) {
117
+ return Promise.reject(`Multiple plans with name ${options.planName} found: ${plans.map(x => x.id)}`);
118
+ }
119
+ return Promise.resolve(plans[0].id);
120
+ });
121
+ }
122
+ getGroupId(options) {
123
+ if (options.ownerGroupId) {
124
+ return Promise.resolve(options.ownerGroupId);
125
+ }
14
126
  const requestOptions = {
15
- url: `${this.resource}/beta/planner/tasks/${encodeURIComponent(args.options.id)}`,
127
+ url: `${this.resource}/v1.0/groups?$filter=displayName eq '${encodeURIComponent(options.ownerGroupName)}'&$select=id`,
16
128
  headers: {
17
129
  accept: 'application/json;odata.metadata=none'
18
130
  },
19
131
  responseType: 'json'
20
132
  };
21
- request_1.default
133
+ return request_1.default
22
134
  .get(requestOptions)
23
- .then((res) => {
24
- logger.log(res);
25
- cb();
26
- }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
135
+ .then(response => {
136
+ const groups = response.value;
137
+ if (!groups.length) {
138
+ return Promise.reject(`The specified ownerGroup ${options.ownerGroupName} does not exist`);
139
+ }
140
+ if (groups.length > 1) {
141
+ return Promise.reject(`Multiple ownerGroups with name ${options.ownerGroupName} found: ${groups.map(x => x.id)}`);
142
+ }
143
+ return Promise.resolve(groups[0].id);
144
+ });
27
145
  }
28
146
  options() {
29
147
  const options = [
30
- { option: '-i, --id <id>' }
148
+ { option: '-i, --id [id]' },
149
+ { option: '-t, --title [title]' },
150
+ { option: '--bucketId [bucketId]' },
151
+ { option: '--bucketName [bucketName]' },
152
+ { option: '--planId [planId]' },
153
+ { option: '--planName [planName]' },
154
+ { option: '--ownerGroupId [ownerGroupId]' },
155
+ { option: '--ownerGroupName [ownerGroupName]' }
31
156
  ];
32
157
  const parentOptions = super.options();
33
158
  return options.concat(parentOptions);
34
159
  }
160
+ validate(args) {
161
+ if (args.options.title && !args.options.bucketId && !args.options.bucketName) {
162
+ return 'Specify either bucketId or bucketName when using title';
163
+ }
164
+ if (args.options.title && args.options.bucketId && args.options.bucketName) {
165
+ return 'Specify either bucketId or bucketName when using title but not both';
166
+ }
167
+ if (args.options.bucketName && !args.options.planId && !args.options.planName) {
168
+ return 'Specify either planId or planName when using bucketName';
169
+ }
170
+ if (args.options.bucketName && args.options.planId && args.options.planName) {
171
+ return 'Specify either planId or planName when using bucketName but not both';
172
+ }
173
+ if (args.options.planName && !args.options.ownerGroupId && !args.options.ownerGroupName) {
174
+ return 'Specify either ownerGroupId or ownerGroupName when using planName';
175
+ }
176
+ if (args.options.planName && args.options.ownerGroupId && args.options.ownerGroupName) {
177
+ return 'Specify either ownerGroupId or ownerGroupName when using planName but not both';
178
+ }
179
+ if (args.options.ownerGroupId && !utils_2.validation.isValidGuid(args.options.ownerGroupId)) {
180
+ return `${args.options.ownerGroupId} is not a valid GUID`;
181
+ }
182
+ return true;
183
+ }
35
184
  }
36
185
  module.exports = new PlannerTaskGetCommand();
37
186
  //# sourceMappingURL=task-get.js.map
@@ -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 PlannerTaskListCommand extends GraphCommand_1.default {
@@ -25,6 +26,10 @@ class PlannerTaskListCommand extends GraphCommand_1.default {
25
26
  return ['id', 'title', 'startDateTime', 'dueDateTime', 'completedDateTime'];
26
27
  }
27
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
+ }
28
33
  const bucketName = args.options.bucketName;
29
34
  let bucketId = args.options.bucketId;
30
35
  const planName = args.options.planName;
@@ -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 PlannerTaskSetCommand extends GraphCommand_1.default {
@@ -36,6 +37,10 @@ class PlannerTaskSetCommand extends GraphCommand_1.default {
36
37
  return telemetryProps;
37
38
  }
38
39
  commandAction(logger, args, cb) {
40
+ if (utils_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
41
+ this.handleError('This command does not support application permissions.', logger, cb);
42
+ return;
43
+ }
39
44
  this
40
45
  .getBucketId(args.options)
41
46
  .then(bucketId => {
@@ -5,6 +5,8 @@ exports.default = {
5
5
  BUCKET_ADD: `${prefix} bucket add`,
6
6
  BUCKET_LIST: `${prefix} bucket list`,
7
7
  BUCKET_SET: `${prefix} bucket set`,
8
+ BUCKET_REMOVE: `${prefix} bucket remove`,
9
+ BUCKET_GET: `${prefix} bucket get`,
8
10
  PLAN_ADD: `${prefix} plan add`,
9
11
  PLAN_GET: `${prefix} plan get`,
10
12
  PLAN_DETAILS_GET: `${prefix} plan details get`,
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const utils_1 = require("../../../../utils");
5
+ const SpoCommand_1 = require("../../../base/SpoCommand");
6
+ const commands_1 = require("../../commands");
7
+ class SpoFieldListCommand extends SpoCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.FIELD_LIST;
10
+ }
11
+ get description() {
12
+ return 'Retrieves columns for the specified list or site';
13
+ }
14
+ getTelemetryProperties(args) {
15
+ const telemetryProps = super.getTelemetryProperties(args);
16
+ telemetryProps.listId = typeof args.options.listId !== 'undefined';
17
+ telemetryProps.listTitle = typeof args.options.listTitle !== 'undefined';
18
+ telemetryProps.listUrl = typeof args.options.listUrl !== 'undefined';
19
+ return telemetryProps;
20
+ }
21
+ defaultProperties() {
22
+ return ['Id', 'Title', 'Group', 'Hidden'];
23
+ }
24
+ commandAction(logger, args, cb) {
25
+ let listUrl = '';
26
+ if (args.options.listId) {
27
+ listUrl = `lists(guid'${encodeURIComponent(args.options.listId)}')/`;
28
+ }
29
+ else if (args.options.listTitle) {
30
+ listUrl = `lists/getByTitle('${encodeURIComponent(args.options.listTitle)}')/`;
31
+ }
32
+ else if (args.options.listUrl) {
33
+ const listServerRelativeUrl = utils_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
34
+ listUrl = `GetList('${encodeURIComponent(listServerRelativeUrl)}')/`;
35
+ }
36
+ const requestOptions = {
37
+ url: `${args.options.webUrl}/_api/web/${listUrl}fields`,
38
+ headers: {
39
+ accept: 'application/json;odata=nometadata'
40
+ },
41
+ responseType: 'json'
42
+ };
43
+ request_1.default
44
+ .get(requestOptions)
45
+ .then((res) => {
46
+ logger.log(res.value);
47
+ cb();
48
+ }, (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
49
+ }
50
+ options() {
51
+ const options = [
52
+ {
53
+ option: '-u, --webUrl <webUrl>'
54
+ },
55
+ {
56
+ option: '-t, --listTitle [listTitle]'
57
+ },
58
+ {
59
+ option: '-i, --listId [listId]'
60
+ },
61
+ {
62
+ option: '--listUrl [listUrl]'
63
+ }
64
+ ];
65
+ const parentOptions = super.options();
66
+ return options.concat(parentOptions);
67
+ }
68
+ validate(args) {
69
+ const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
70
+ if (isValidSharePointUrl !== true) {
71
+ return isValidSharePointUrl;
72
+ }
73
+ if (args.options.listId && !utils_1.validation.isValidGuid(args.options.listId)) {
74
+ return `${args.options.listId} is not a valid GUID`;
75
+ }
76
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
77
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
78
+ return `Specify either list id or title or list url`;
79
+ }
80
+ return true;
81
+ }
82
+ }
83
+ module.exports = new SpoFieldListCommand();
84
+ //# sourceMappingURL=field-list.js.map
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const utils_1 = require("../../../../utils");
5
+ const SpoCommand_1 = require("../../../base/SpoCommand");
6
+ const commands_1 = require("../../commands");
7
+ class SpoListRoleInheritanceBreakCommand extends SpoCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.LIST_ROLEINHERITANCE_BREAK;
10
+ }
11
+ get description() {
12
+ return 'Breaks role inheritance on list or library';
13
+ }
14
+ optionSets() {
15
+ return [
16
+ ['listId', 'listTitle']
17
+ ];
18
+ }
19
+ getTelemetryProperties(args) {
20
+ const telemetryProps = super.getTelemetryProperties(args);
21
+ telemetryProps.listId = typeof args.options.listId !== 'undefined';
22
+ telemetryProps.listTitle = typeof args.options.listTitle !== 'undefined';
23
+ telemetryProps.clearExistingPermissions = args.options.clearExistingPermissions === true;
24
+ return telemetryProps;
25
+ }
26
+ commandAction(logger, args, cb) {
27
+ if (this.verbose) {
28
+ logger.logToStderr(`Breaking role inheritance of list in site at ${args.options.webUrl}...`);
29
+ }
30
+ let requestUrl = `${args.options.webUrl}/_api/web/lists`;
31
+ if (args.options.listId) {
32
+ requestUrl += `(guid'${encodeURIComponent(args.options.listId)}')`;
33
+ }
34
+ else {
35
+ requestUrl += `/getbytitle('${encodeURIComponent(args.options.listTitle)}')`;
36
+ }
37
+ let keepExistingPermissions = true;
38
+ if (args.options.clearExistingPermissions) {
39
+ keepExistingPermissions = !args.options.clearExistingPermissions;
40
+ }
41
+ const requestOptions = {
42
+ url: `${requestUrl}/breakroleinheritance(${keepExistingPermissions})`,
43
+ method: 'POST',
44
+ headers: {
45
+ 'accept': 'application/json;odata=nometadata',
46
+ 'content-type': 'application/json'
47
+ },
48
+ responseType: 'json'
49
+ };
50
+ request_1.default
51
+ .post(requestOptions)
52
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
53
+ }
54
+ options() {
55
+ const options = [
56
+ {
57
+ option: '-u, --webUrl <webUrl>'
58
+ },
59
+ {
60
+ option: '-i, --listId [listId]'
61
+ },
62
+ {
63
+ option: '-t, --listTitle [listTitle]'
64
+ },
65
+ {
66
+ option: '-c, --clearExistingPermissions'
67
+ }
68
+ ];
69
+ const parentOptions = super.options();
70
+ return options.concat(parentOptions);
71
+ }
72
+ validate(args) {
73
+ const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
74
+ if (isValidSharePointUrl !== true) {
75
+ return isValidSharePointUrl;
76
+ }
77
+ if (args.options.listId && !utils_1.validation.isValidGuid(args.options.listId)) {
78
+ return `${args.options.listId} is not a valid GUID`;
79
+ }
80
+ return true;
81
+ }
82
+ }
83
+ module.exports = new SpoListRoleInheritanceBreakCommand();
84
+ //# sourceMappingURL=list-roleinheritance-break.js.map
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const request_1 = require("../../../../request");
4
+ const utils_1 = require("../../../../utils");
5
+ const SpoCommand_1 = require("../../../base/SpoCommand");
6
+ const commands_1 = require("../../commands");
7
+ class SpoListRoleInheritanceResetCommand extends SpoCommand_1.default {
8
+ get name() {
9
+ return commands_1.default.LIST_ROLEINHERITANCE_RESET;
10
+ }
11
+ get description() {
12
+ return 'Restores role inheritance on list or library';
13
+ }
14
+ optionSets() {
15
+ return [
16
+ ['listId', 'listTitle']
17
+ ];
18
+ }
19
+ getTelemetryProperties(args) {
20
+ const telemetryProps = super.getTelemetryProperties(args);
21
+ telemetryProps.listId = typeof args.options.listId !== 'undefined';
22
+ telemetryProps.listTitle = typeof args.options.listTitle !== 'undefined';
23
+ return telemetryProps;
24
+ }
25
+ commandAction(logger, args, cb) {
26
+ if (this.verbose) {
27
+ logger.logToStderr(`Restore role inheritance of list in site at ${args.options.webUrl}...`);
28
+ }
29
+ let requestUrl = `${args.options.webUrl}/_api/web/lists`;
30
+ if (args.options.listId) {
31
+ requestUrl += `(guid'${encodeURIComponent(args.options.listId)}')`;
32
+ }
33
+ else {
34
+ requestUrl += `/getbytitle('${encodeURIComponent(args.options.listTitle)}')`;
35
+ }
36
+ const requestOptions = {
37
+ url: `${requestUrl}/resetroleinheritance`,
38
+ method: 'POST',
39
+ headers: {
40
+ 'accept': 'application/json;odata=nometadata',
41
+ 'content-type': 'application/json'
42
+ },
43
+ responseType: 'json'
44
+ };
45
+ request_1.default
46
+ .post(requestOptions)
47
+ .then(_ => cb(), (err) => this.handleRejectedODataJsonPromise(err, logger, cb));
48
+ }
49
+ options() {
50
+ const options = [
51
+ {
52
+ option: '-u, --webUrl <webUrl>'
53
+ },
54
+ {
55
+ option: '-i, --listId [listId]'
56
+ },
57
+ {
58
+ option: '-t, --listTitle [listTitle]'
59
+ }
60
+ ];
61
+ const parentOptions = super.options();
62
+ return options.concat(parentOptions);
63
+ }
64
+ validate(args) {
65
+ const isValidSharePointUrl = utils_1.validation.isValidSharePointUrl(args.options.webUrl);
66
+ if (isValidSharePointUrl !== true) {
67
+ return isValidSharePointUrl;
68
+ }
69
+ if (args.options.listId && !utils_1.validation.isValidGuid(args.options.listId)) {
70
+ return `${args.options.listId} is not a valid GUID`;
71
+ }
72
+ return true;
73
+ }
74
+ }
75
+ module.exports = new SpoListRoleInheritanceResetCommand();
76
+ //# sourceMappingURL=list-roleinheritance-reset.js.map