@pnp/cli-microsoft365 5.9.0-beta.1e08e6c → 5.9.0-beta.1f313f7

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 (89) hide show
  1. package/dist/Command.js +16 -2
  2. package/dist/m365/commands/status.js +6 -1
  3. package/dist/m365/spfx/commands/project/project-doctor.js +4 -1
  4. package/dist/m365/spfx/commands/project/project-externalize.js +4 -1
  5. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010001_YORC_version.js +2 -1
  6. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010002_YORC_isCreatingSolution.js +2 -1
  7. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010003_YORC_packageManager.js +2 -1
  8. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010004_YORC_componentType.js +2 -1
  9. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010005_YORC_environment.js +2 -1
  10. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010006_YORC_framework.js +3 -2
  11. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010007_YORC_isDomainIsolated.js +2 -1
  12. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010008_YORC_nodeVersion.js +2 -1
  13. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010009_YORC_sdkVersions_microsoft_graph_client.js +56 -0
  14. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN010010_YORC_sdkVersions_teams_js.js +56 -0
  15. package/dist/m365/spfx/commands/project/project-upgrade/{upgrade-1.16.0-beta.1.js → upgrade-1.16.0-beta.2.js} +44 -28
  16. package/dist/m365/spfx/commands/project/project-upgrade.js +1 -1
  17. package/dist/m365/spfx/commands/spfx-doctor.js +3 -3
  18. package/dist/m365/spo/commands/contenttype/contenttype-add.js +82 -43
  19. package/dist/m365/spo/commands/contenttype/contenttype-field-remove.js +53 -21
  20. package/dist/m365/spo/commands/contenttype/contenttype-get.js +35 -14
  21. package/dist/m365/spo/commands/field/field-add.js +26 -1
  22. package/dist/m365/spo/commands/field/field-set.js +23 -13
  23. package/dist/m365/spo/commands/list/list-roleassignment-add.js +1 -1
  24. package/dist/m365/spo/commands/list/list-webhook-get.js +2 -3
  25. package/dist/m365/spo/commands/listitem/listitem-add.js +24 -14
  26. package/dist/m365/spo/commands/listitem/listitem-attachment-list.js +18 -8
  27. package/dist/m365/spo/commands/listitem/listitem-get.js +18 -8
  28. package/dist/m365/spo/commands/listitem/listitem-isrecord.js +20 -10
  29. package/dist/m365/spo/commands/listitem/listitem-list.js +27 -11
  30. package/dist/m365/spo/commands/listitem/listitem-record-declare.js +19 -12
  31. package/dist/m365/spo/commands/listitem/listitem-record-undeclare.js +24 -21
  32. package/dist/m365/spo/commands/listitem/listitem-remove.js +19 -11
  33. package/dist/m365/spo/commands/listitem/listitem-roleassignment-add.js +239 -0
  34. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-break.js +13 -5
  35. package/dist/m365/spo/commands/listitem/listitem-roleinheritance-reset.js +14 -6
  36. package/dist/m365/spo/commands/listitem/listitem-set.js +52 -44
  37. package/dist/m365/spo/commands/web/web-roleinheritance-break.js +100 -0
  38. package/dist/m365/spo/commands.js +2 -0
  39. package/dist/m365/todo/commands/list/list-get.js +89 -0
  40. package/dist/m365/todo/commands/task/task-get.js +108 -0
  41. package/dist/m365/todo/commands.js +2 -0
  42. package/docs/docs/cmd/planner/bucket/bucket-add.md +29 -0
  43. package/docs/docs/cmd/planner/bucket/bucket-get.md +29 -0
  44. package/docs/docs/cmd/planner/bucket/bucket-list.md +30 -0
  45. package/docs/docs/cmd/planner/bucket/bucket-remove.md +4 -0
  46. package/docs/docs/cmd/planner/bucket/bucket-set.md +4 -0
  47. package/docs/docs/cmd/planner/plan/plan-add.md +123 -0
  48. package/docs/docs/cmd/planner/plan/plan-get.md +75 -0
  49. package/docs/docs/cmd/planner/plan/plan-list.md +45 -0
  50. package/docs/docs/cmd/planner/plan/plan-remove.md +4 -0
  51. package/docs/docs/cmd/spfx/project/project-rename.md +1 -14
  52. package/docs/docs/cmd/spfx/project/project-upgrade.md +1 -1
  53. package/docs/docs/cmd/spo/contenttype/contenttype-add.md +20 -2
  54. package/docs/docs/cmd/spo/contenttype/contenttype-field-remove.md +22 -4
  55. package/docs/docs/cmd/spo/contenttype/contenttype-get.md +21 -3
  56. package/docs/docs/cmd/spo/field/field-add.md +20 -2
  57. package/docs/docs/cmd/spo/field/field-set.md +11 -2
  58. package/docs/docs/cmd/spo/list/list-webhook-get.md +1 -1
  59. package/docs/docs/cmd/spo/list/list-webhook-set.md +2 -2
  60. package/docs/docs/cmd/spo/listitem/listitem-add.md +11 -2
  61. package/docs/docs/cmd/spo/listitem/listitem-attachment-list.md +11 -2
  62. package/docs/docs/cmd/spo/listitem/listitem-get.md +11 -2
  63. package/docs/docs/cmd/spo/listitem/listitem-isrecord.md +12 -2
  64. package/docs/docs/cmd/spo/listitem/listitem-list.md +12 -3
  65. package/docs/docs/cmd/spo/listitem/listitem-record-declare.md +7 -4
  66. package/docs/docs/cmd/spo/listitem/listitem-record-undeclare.md +11 -2
  67. package/docs/docs/cmd/spo/listitem/listitem-remove.md +11 -2
  68. package/docs/docs/cmd/spo/listitem/listitem-roleassignment-add.md +81 -0
  69. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-break.md +7 -4
  70. package/docs/docs/cmd/spo/listitem/listitem-roleinheritance-reset.md +11 -2
  71. package/docs/docs/cmd/spo/listitem/listitem-set.md +7 -4
  72. package/docs/docs/cmd/spo/web/web-roleinheritance-break.md +44 -0
  73. package/docs/docs/cmd/tenant/id/id-get.md +20 -0
  74. package/docs/docs/cmd/tenant/report/report-activeusercounts.md +35 -0
  75. package/docs/docs/cmd/tenant/report/report-activeuserdetail.md +49 -0
  76. package/docs/docs/cmd/tenant/report/report-office365activationcounts.md +32 -0
  77. package/docs/docs/cmd/tenant/report/report-office365activationsusercounts.md +30 -0
  78. package/docs/docs/cmd/tenant/report/report-office365activationsuserdetail.md +36 -0
  79. package/docs/docs/cmd/tenant/report/report-servicesusercounts.md +41 -0
  80. package/docs/docs/cmd/tenant/security/security-alerts-list.md +105 -0
  81. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-get.md +87 -0
  82. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-health-list.md +91 -0
  83. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-get.md +62 -0
  84. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-healthissue-list.md +51 -0
  85. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-get.md +64 -0
  86. package/docs/docs/cmd/tenant/serviceannouncement/serviceannouncement-message-list.md +52 -0
  87. package/docs/docs/cmd/todo/list/list-get.md +61 -0
  88. package/docs/docs/cmd/todo/task/task-get.md +75 -0
  89. package/package.json +9 -6
@@ -18,6 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const Cli_1 = require("../../../../cli/Cli");
19
19
  const request_1 = require("../../../../request");
20
20
  const formatting_1 = require("../../../../utils/formatting");
21
+ const urlUtil_1 = require("../../../../utils/urlUtil");
21
22
  const validation_1 = require("../../../../utils/validation");
22
23
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
24
  const commands_1 = require("../../commands");
@@ -40,14 +41,18 @@ class SpoListItemRemoveCommand extends SpoCommand_1.default {
40
41
  return __awaiter(this, void 0, void 0, function* () {
41
42
  const removeListItem = () => __awaiter(this, void 0, void 0, function* () {
42
43
  if (this.verbose) {
43
- logger.logToStderr(`Removing list item in site at ${args.options.webUrl}...`);
44
+ logger.logToStderr(`Removing list from list ${args.options.listId || args.options.listTitle || args.options.listUrl} item in site at ${args.options.webUrl}...`);
44
45
  }
45
- let requestUrl = '';
46
+ let requestUrl = `${args.options.webUrl}/_api/web`;
46
47
  if (args.options.listId) {
47
- requestUrl = `${args.options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
48
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
48
49
  }
49
- else {
50
- requestUrl = `${args.options.webUrl}/_api/web/lists/GetByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
50
+ else if (args.options.listTitle) {
51
+ requestUrl += `/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
52
+ }
53
+ else if (args.options.listUrl) {
54
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
55
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
51
56
  }
52
57
  requestUrl += `/items(${args.options.id})`;
53
58
  if (args.options.recycle) {
@@ -79,7 +84,7 @@ class SpoListItemRemoveCommand extends SpoCommand_1.default {
79
84
  type: 'confirm',
80
85
  name: 'continue',
81
86
  default: false,
82
- message: `Are you sure you want to ${args.options.recycle ? "recycle" : "remove"} the list item ${args.options.id} from list ${args.options.listId || args.options.listTitle} located in site ${args.options.webUrl}?`
87
+ message: `Are you sure you want to ${args.options.recycle ? "recycle" : "remove"} the list item ${args.options.id} from list ${args.options.listId || args.options.listTitle || args.options.listUrl} located in site ${args.options.webUrl}?`
83
88
  });
84
89
  if (result.continue) {
85
90
  yield removeListItem();
@@ -91,10 +96,11 @@ class SpoListItemRemoveCommand extends SpoCommand_1.default {
91
96
  _SpoListItemRemoveCommand_instances = new WeakSet(), _SpoListItemRemoveCommand_initTelemetry = function _SpoListItemRemoveCommand_initTelemetry() {
92
97
  this.telemetry.push((args) => {
93
98
  Object.assign(this.telemetryProperties, {
94
- listId: (!(!args.options.listId)).toString(),
95
- listTitle: (!(!args.options.listTitle)).toString(),
96
- recycle: (!(!args.options.recycle)).toString(),
97
- confirm: (!(!args.options.confirm)).toString()
99
+ listId: typeof args.options.listId !== 'undefined',
100
+ listTitle: typeof args.options.listTitle !== 'undefined',
101
+ listUrl: typeof args.options.listUrl !== 'undefined',
102
+ recycle: !!args.options.recycle,
103
+ confirm: !!args.options.confirm
98
104
  });
99
105
  });
100
106
  }, _SpoListItemRemoveCommand_initOptions = function _SpoListItemRemoveCommand_initOptions() {
@@ -106,6 +112,8 @@ _SpoListItemRemoveCommand_instances = new WeakSet(), _SpoListItemRemoveCommand_i
106
112
  option: '-l, --listId [listId]'
107
113
  }, {
108
114
  option: '-t, --listTitle [listTitle]'
115
+ }, {
116
+ option: '--listUrl [listUrl]'
109
117
  }, {
110
118
  option: '--recycle'
111
119
  }, {
@@ -128,7 +136,7 @@ _SpoListItemRemoveCommand_instances = new WeakSet(), _SpoListItemRemoveCommand_i
128
136
  return true;
129
137
  }));
130
138
  }, _SpoListItemRemoveCommand_initOptionSets = function _SpoListItemRemoveCommand_initOptionSets() {
131
- this.optionSets.push(['listId', 'listTitle']);
139
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
132
140
  };
133
141
  module.exports = new SpoListItemRemoveCommand();
134
142
  //# sourceMappingURL=listitem-remove.js.map
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var _SpoListItemRoleAssignmentAddCommand_instances, _SpoListItemRoleAssignmentAddCommand_initTelemetry, _SpoListItemRoleAssignmentAddCommand_initOptions, _SpoListItemRoleAssignmentAddCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const SpoCommand_1 = require("../../../base/SpoCommand");
20
+ const commands_1 = require("../../commands");
21
+ const SpoUserGetCommand = require("../user/user-get");
22
+ const SpoGroupGetCommand = require("../group/group-get");
23
+ const SpoRoleDefinitionListCommand = require("../roledefinition/roledefinition-list");
24
+ const validation_1 = require("../../../../utils/validation");
25
+ const formatting_1 = require("../../../../utils/formatting");
26
+ const urlUtil_1 = require("../../../../utils/urlUtil");
27
+ const Cli_1 = require("../../../../cli/Cli");
28
+ class SpoListItemRoleAssignmentAddCommand extends SpoCommand_1.default {
29
+ constructor() {
30
+ super();
31
+ _SpoListItemRoleAssignmentAddCommand_instances.add(this);
32
+ __classPrivateFieldGet(this, _SpoListItemRoleAssignmentAddCommand_instances, "m", _SpoListItemRoleAssignmentAddCommand_initTelemetry).call(this);
33
+ __classPrivateFieldGet(this, _SpoListItemRoleAssignmentAddCommand_instances, "m", _SpoListItemRoleAssignmentAddCommand_initOptions).call(this);
34
+ __classPrivateFieldGet(this, _SpoListItemRoleAssignmentAddCommand_instances, "m", _SpoListItemRoleAssignmentAddCommand_initValidators).call(this);
35
+ }
36
+ get name() {
37
+ return commands_1.default.LISTITEM_ROLEASSIGNMENT_ADD;
38
+ }
39
+ get description() {
40
+ return 'Adds a role assignment to a listitem.';
41
+ }
42
+ commandAction(logger, args) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ if (this.verbose) {
45
+ logger.logToStderr(`Adding role assignment to listitem in site at ${args.options.webUrl}...`);
46
+ }
47
+ try {
48
+ let requestUrl = `${args.options.webUrl}/_api/web/`;
49
+ if (args.options.listId) {
50
+ requestUrl += `lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')/`;
51
+ }
52
+ else if (args.options.listTitle) {
53
+ requestUrl += `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')/`;
54
+ }
55
+ else if (args.options.listUrl) {
56
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
57
+ requestUrl += `GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
58
+ }
59
+ requestUrl += `items(${args.options.listItemId})/`;
60
+ const roleDefinitionId = yield this.getRoleDefinitionId(args.options);
61
+ let principalId = 0;
62
+ if (args.options.upn) {
63
+ principalId = yield this.getUserPrincipalId(args.options);
64
+ yield this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
65
+ }
66
+ else if (args.options.groupName) {
67
+ principalId = yield this.getGroupPrincipalId(args.options);
68
+ yield this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
69
+ }
70
+ else {
71
+ principalId = args.options.principalId;
72
+ yield this.addRoleAssignment(requestUrl, roleDefinitionId, principalId);
73
+ }
74
+ }
75
+ catch (err) {
76
+ this.handleRejectedODataJsonPromise(err);
77
+ }
78
+ });
79
+ }
80
+ addRoleAssignment(requestUrl, roleDefinitionId, principalId) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ try {
83
+ const requestOptions = {
84
+ url: `${requestUrl}roleassignments/addroleassignment(principalid='${principalId}',roledefid='${roleDefinitionId}')`,
85
+ method: 'POST',
86
+ headers: {
87
+ 'accept': 'application/json;odata=nometadata',
88
+ 'content-type': 'application/json'
89
+ },
90
+ responseType: 'json'
91
+ };
92
+ yield request_1.default.post(requestOptions);
93
+ }
94
+ catch (err) {
95
+ return Promise.reject(err);
96
+ }
97
+ });
98
+ }
99
+ getRoleDefinitionId(options) {
100
+ return __awaiter(this, void 0, void 0, function* () {
101
+ if (!options.roleDefinitionName) {
102
+ return options.roleDefinitionId;
103
+ }
104
+ try {
105
+ const roleDefinitionListCommandOptions = {
106
+ webUrl: options.webUrl,
107
+ output: 'json',
108
+ debug: this.debug,
109
+ verbose: this.verbose
110
+ };
111
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoRoleDefinitionListCommand, { options: Object.assign(Object.assign({}, roleDefinitionListCommandOptions), { _: [] }) });
112
+ const getRoleDefinitionListOutput = JSON.parse(output.stdout);
113
+ const roleDefinitionId = getRoleDefinitionListOutput.find((role) => role.Name === options.roleDefinitionName).Id;
114
+ return roleDefinitionId;
115
+ }
116
+ catch (err) {
117
+ return Promise.reject(err);
118
+ }
119
+ });
120
+ }
121
+ getGroupPrincipalId(options) {
122
+ return __awaiter(this, void 0, void 0, function* () {
123
+ try {
124
+ const groupGetCommandOptions = {
125
+ webUrl: options.webUrl,
126
+ name: options.groupName,
127
+ output: 'json',
128
+ debug: this.debug,
129
+ verbose: this.verbose
130
+ };
131
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoGroupGetCommand, { options: Object.assign(Object.assign({}, groupGetCommandOptions), { _: [] }) });
132
+ const getGroupOutput = JSON.parse(output.stdout);
133
+ return getGroupOutput.Id;
134
+ }
135
+ catch (err) {
136
+ return Promise.reject(err);
137
+ }
138
+ });
139
+ }
140
+ getUserPrincipalId(options) {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ try {
143
+ const userGetCommandOptions = {
144
+ webUrl: options.webUrl,
145
+ email: options.upn,
146
+ id: undefined,
147
+ output: 'json',
148
+ debug: this.debug,
149
+ verbose: this.verbose
150
+ };
151
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, userGetCommandOptions), { _: [] }) });
152
+ const getUserOutput = JSON.parse(output.stdout);
153
+ return getUserOutput.Id;
154
+ }
155
+ catch (err) {
156
+ return Promise.reject(err);
157
+ }
158
+ });
159
+ }
160
+ }
161
+ _SpoListItemRoleAssignmentAddCommand_instances = new WeakSet(), _SpoListItemRoleAssignmentAddCommand_initTelemetry = function _SpoListItemRoleAssignmentAddCommand_initTelemetry() {
162
+ this.telemetry.push((args) => {
163
+ Object.assign(this.telemetryProperties, {
164
+ listId: typeof args.options.listId !== 'undefined',
165
+ listTitle: typeof args.options.listTitle !== 'undefined',
166
+ listUrl: typeof args.options.listUrl !== 'undefined',
167
+ principalId: typeof args.options.principalId !== 'undefined',
168
+ upn: typeof args.options.upn !== 'undefined',
169
+ groupName: typeof args.options.groupName !== 'undefined',
170
+ roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
171
+ roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined'
172
+ });
173
+ });
174
+ }, _SpoListItemRoleAssignmentAddCommand_initOptions = function _SpoListItemRoleAssignmentAddCommand_initOptions() {
175
+ this.options.unshift({
176
+ option: '-u, --webUrl <webUrl>'
177
+ }, {
178
+ option: '--listItemId <listItemId>'
179
+ }, {
180
+ option: '--listId [listId]'
181
+ }, {
182
+ option: '--listTitle [listTitle]'
183
+ }, {
184
+ option: '--listUrl [listUrl]'
185
+ }, {
186
+ option: '--principalId [principalId]'
187
+ }, {
188
+ option: '--upn [upn]'
189
+ }, {
190
+ option: '--groupName [groupName]'
191
+ }, {
192
+ option: '--roleDefinitionId [roleDefinitionId]'
193
+ }, {
194
+ option: '--roleDefinitionName [roleDefinitionName]'
195
+ });
196
+ }, _SpoListItemRoleAssignmentAddCommand_initValidators = function _SpoListItemRoleAssignmentAddCommand_initValidators() {
197
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
198
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
199
+ if (isValidSharePointUrl !== true) {
200
+ return isValidSharePointUrl;
201
+ }
202
+ if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
203
+ return `${args.options.listId} is not a valid GUID`;
204
+ }
205
+ if (args.options.listItemId && isNaN(args.options.listItemId)) {
206
+ return `Specified listItemId ${args.options.listItemId} is not a number`;
207
+ }
208
+ if (args.options.principalId && isNaN(args.options.principalId)) {
209
+ return `Specified principalId ${args.options.principalId} is not a number`;
210
+ }
211
+ if (args.options.roleDefinitionId && isNaN(args.options.roleDefinitionId)) {
212
+ return `Specified roleDefinitionId ${args.options.roleDefinitionId} is not a number`;
213
+ }
214
+ const listOptions = [args.options.listId, args.options.listTitle, args.options.listUrl];
215
+ if (listOptions.some(item => item !== undefined) && listOptions.filter(item => item !== undefined).length > 1) {
216
+ return `Specify either list id or title or list url`;
217
+ }
218
+ if (listOptions.filter(item => item !== undefined).length === 0) {
219
+ return `Specify at least list id or title or list url`;
220
+ }
221
+ const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
222
+ if (!principalOptions.some(item => item !== undefined)) {
223
+ return `Specify either principalId, upn or groupName`;
224
+ }
225
+ if (principalOptions.filter(item => item !== undefined).length > 1) {
226
+ return `Specify either principalId, upn or groupName but not multiple`;
227
+ }
228
+ const roleDefinitionOptions = [args.options.roleDefinitionId, args.options.roleDefinitionName];
229
+ if (!roleDefinitionOptions.some(item => item !== undefined)) {
230
+ return `Specify either roleDefinitionId or roleDefinitionName`;
231
+ }
232
+ if (roleDefinitionOptions.filter(item => item !== undefined).length > 1) {
233
+ return `Specify either roleDefinitionId or roleDefinitionName but not multiple`;
234
+ }
235
+ return true;
236
+ }));
237
+ };
238
+ module.exports = new SpoListItemRoleAssignmentAddCommand();
239
+ //# sourceMappingURL=listitem-roleassignment-add.js.map
@@ -17,6 +17,7 @@ var _SpoListItemRoleInheritanceBreakCommand_instances, _SpoListItemRoleInheritan
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
20
21
  const validation_1 = require("../../../../utils/validation");
21
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
22
23
  const commands_1 = require("../../commands");
@@ -40,12 +41,16 @@ class SpoListItemRoleInheritanceBreakCommand extends SpoCommand_1.default {
40
41
  if (this.verbose) {
41
42
  logger.logToStderr(`Breaking role inheritance of list item in site at ${args.options.webUrl}...`);
42
43
  }
43
- let requestUrl = `${args.options.webUrl}/_api/web/lists`;
44
+ let requestUrl = `${args.options.webUrl}/_api/web`;
44
45
  if (args.options.listId) {
45
- requestUrl += `(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
46
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
46
47
  }
47
- else {
48
- requestUrl += `/getbytitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
48
+ else if (args.options.listTitle) {
49
+ requestUrl += `/lists/getbytitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
50
+ }
51
+ else if (args.options.listUrl) {
52
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
53
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
49
54
  }
50
55
  let keepExistingPermissions = true;
51
56
  if (args.options.clearExistingPermissions) {
@@ -74,6 +79,7 @@ _SpoListItemRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListItemR
74
79
  Object.assign(this.telemetryProperties, {
75
80
  listId: typeof args.options.listId !== 'undefined',
76
81
  listTitle: typeof args.options.listTitle !== 'undefined',
82
+ listUrl: typeof args.options.listUrl !== 'undefined',
77
83
  clearExistingPermissions: args.options.clearExistingPermissions === true
78
84
  });
79
85
  });
@@ -86,6 +92,8 @@ _SpoListItemRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListItemR
86
92
  option: '-l, --listId [listId]'
87
93
  }, {
88
94
  option: '-t, --listTitle [listTitle]'
95
+ }, {
96
+ option: '--listUrl [listUrl]'
89
97
  }, {
90
98
  option: '-c, --clearExistingPermissions'
91
99
  });
@@ -104,7 +112,7 @@ _SpoListItemRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoListItemR
104
112
  return true;
105
113
  }));
106
114
  }, _SpoListItemRoleInheritanceBreakCommand_initOptionSets = function _SpoListItemRoleInheritanceBreakCommand_initOptionSets() {
107
- this.optionSets.push(['listId', 'listTitle']);
115
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
108
116
  };
109
117
  module.exports = new SpoListItemRoleInheritanceBreakCommand();
110
118
  //# sourceMappingURL=listitem-roleinheritance-break.js.map
@@ -17,6 +17,7 @@ var _SpoListItemRoleInheritanceResetCommand_instances, _SpoListItemRoleInheritan
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
20
21
  const validation_1 = require("../../../../utils/validation");
21
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
22
23
  const commands_1 = require("../../commands");
@@ -37,12 +38,16 @@ class SpoListItemRoleInheritanceResetCommand extends SpoCommand_1.default {
37
38
  }
38
39
  commandAction(logger, args) {
39
40
  return __awaiter(this, void 0, void 0, function* () {
40
- let requestUrl = `${args.options.webUrl}/_api/web/lists`;
41
+ let requestUrl = `${args.options.webUrl}/_api/web`;
41
42
  if (args.options.listId) {
42
- requestUrl += `(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
43
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
43
44
  }
44
- else {
45
- requestUrl += `/getbytitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
45
+ else if (args.options.listTitle) {
46
+ requestUrl += `/lists/getbytitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
47
+ }
48
+ else if (args.options.listUrl) {
49
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
50
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
46
51
  }
47
52
  const requestOptions = {
48
53
  url: `${requestUrl}/items(${args.options.listItemId})/resetroleinheritance`,
@@ -66,7 +71,8 @@ _SpoListItemRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListItemR
66
71
  this.telemetry.push((args) => {
67
72
  Object.assign(this.telemetryProperties, {
68
73
  listId: typeof args.options.listId !== 'undefined',
69
- listTitle: typeof args.options.listTitle !== 'undefined'
74
+ listTitle: typeof args.options.listTitle !== 'undefined',
75
+ listUrl: typeof args.options.listUrl !== 'undefined'
70
76
  });
71
77
  });
72
78
  }, _SpoListItemRoleInheritanceResetCommand_initOptions = function _SpoListItemRoleInheritanceResetCommand_initOptions() {
@@ -78,6 +84,8 @@ _SpoListItemRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListItemR
78
84
  option: '--listId [listId]'
79
85
  }, {
80
86
  option: '--listTitle [listTitle]'
87
+ }, {
88
+ option: '--listUrl [listUrl]'
81
89
  });
82
90
  }, _SpoListItemRoleInheritanceResetCommand_initValidators = function _SpoListItemRoleInheritanceResetCommand_initValidators() {
83
91
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -94,7 +102,7 @@ _SpoListItemRoleInheritanceResetCommand_instances = new WeakSet(), _SpoListItemR
94
102
  return true;
95
103
  }));
96
104
  }, _SpoListItemRoleInheritanceResetCommand_initOptionSets = function _SpoListItemRoleInheritanceResetCommand_initOptionSets() {
97
- this.optionSets.push(['listId', 'listTitle']);
105
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
98
106
  };
99
107
  module.exports = new SpoListItemRoleInheritanceResetCommand();
100
108
  //# sourceMappingURL=listitem-roleinheritance-reset.js.map
@@ -19,6 +19,7 @@ const config_1 = require("../../../../config");
19
19
  const request_1 = require("../../../../request");
20
20
  const formatting_1 = require("../../../../utils/formatting");
21
21
  const spo_1 = require("../../../../utils/spo");
22
+ const urlUtil_1 = require("../../../../utils/urlUtil");
22
23
  const validation_1 = require("../../../../utils/validation");
23
24
  const SpoCommand_1 = require("../../../base/SpoCommand");
24
25
  const commands_1 = require("../../commands");
@@ -43,35 +44,41 @@ class SpoListItemSetCommand extends SpoCommand_1.default {
43
44
  }
44
45
  commandAction(logger, args) {
45
46
  return __awaiter(this, void 0, void 0, function* () {
46
- const listIdArgument = args.options.listId || '';
47
- const listTitleArgument = args.options.listTitle || '';
48
- const listRestUrl = (args.options.listId ?
49
- `${args.options.webUrl}/_api/web/lists(guid'${formatting_1.formatting.encodeQueryParameter(listIdArgument)}')`
50
- : `${args.options.webUrl}/_api/web/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(listTitleArgument)}')`);
51
47
  let contentTypeName = '';
52
- let formDigestValue = '';
53
- let environmentListId = '';
48
+ let listId = '';
54
49
  try {
55
- if (args.options.systemUpdate) {
50
+ let requestUrl = `${args.options.webUrl}/_api/web`;
51
+ if (args.options.listId) {
52
+ listId = args.options.listId;
53
+ requestUrl += `/lists(guid'${formatting_1.formatting.encodeQueryParameter(args.options.listId)}')`;
54
+ }
55
+ else if (args.options.listTitle) {
56
+ requestUrl += `/lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
57
+ }
58
+ else if (args.options.listUrl) {
59
+ const listServerRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
60
+ requestUrl += `/GetList('${formatting_1.formatting.encodeQueryParameter(listServerRelativeUrl)}')`;
61
+ }
62
+ if (args.options.systemUpdate && !args.options.listId) {
56
63
  if (this.verbose) {
57
64
  logger.logToStderr(`Getting list id...`);
58
65
  }
59
66
  const listRequestOptions = {
60
- url: `${listRestUrl}/id`,
67
+ url: `${requestUrl}?$select=Id`,
61
68
  headers: {
62
69
  'accept': 'application/json;odata=nometadata'
63
70
  },
64
71
  responseType: 'json'
65
72
  };
66
- const dataReturned = yield request_1.default.get(listRequestOptions);
67
- environmentListId = dataReturned.value;
73
+ const list = yield request_1.default.get(listRequestOptions);
74
+ listId = list.Id;
68
75
  }
69
76
  if (args.options.contentType) {
70
77
  if (this.verbose) {
71
78
  logger.logToStderr(`Getting content types for list...`);
72
79
  }
73
80
  const requestOptions = {
74
- url: `${listRestUrl}/contenttypes?$select=Name,Id`,
81
+ url: `${requestUrl}/contenttypes?$select=Name,Id`,
75
82
  headers: {
76
83
  'accept': 'application/json;odata=nometadata'
77
84
  },
@@ -112,9 +119,9 @@ class SpoListItemSetCommand extends SpoCommand_1.default {
112
119
  res = yield spo_1.spo.getRequestDigest(args.options.webUrl);
113
120
  }
114
121
  if (this.verbose) {
115
- logger.logToStderr(`Updating item in list ${args.options.listId || args.options.listTitle} in site ${args.options.webUrl}...`);
122
+ logger.logToStderr(`Updating item in list ${args.options.listId || args.options.listTitle || args.options.listUrl} in site ${args.options.webUrl}...`);
116
123
  }
117
- formDigestValue = args.options.systemUpdate ? res['FormDigestValue'] : '';
124
+ const formDigestValue = args.options.systemUpdate ? res['FormDigestValue'] : '';
118
125
  let objectIdentity = '';
119
126
  if (args.options.systemUpdate) {
120
127
  objectIdentity = yield this.requestObjectIdentity(args.options.webUrl, logger, formDigestValue);
@@ -133,7 +140,7 @@ class SpoListItemSetCommand extends SpoCommand_1.default {
133
140
  <Method Name="SystemUpdate" Id="2" ObjectPathId="147" />
134
141
  </Actions>
135
142
  <ObjectPaths>
136
- <Identity Id="147" Name="${objectIdentity}:list:${environmentListId}:item:${args.options.id},1" />
143
+ <Identity Id="147" Name="${objectIdentity}:list:${listId}:item:${args.options.id},1" />
137
144
  </ObjectPaths>
138
145
  </Request>`
139
146
  : {
@@ -158,7 +165,7 @@ class SpoListItemSetCommand extends SpoCommand_1.default {
158
165
  data: requestBody
159
166
  } :
160
167
  {
161
- url: `${listRestUrl}/items(${args.options.id})/ValidateUpdateListItem()`,
168
+ url: `${requestUrl}/items(${args.options.id})/ValidateUpdateListItem()`,
162
169
  headers: {
163
170
  'accept': 'application/json;odata=nometadata'
164
171
  },
@@ -186,7 +193,7 @@ class SpoListItemSetCommand extends SpoCommand_1.default {
186
193
  }
187
194
  }
188
195
  const requestOptionsItems = {
189
- url: `${listRestUrl}/items(${itemId})`,
196
+ url: `${requestUrl}/items(${itemId})`,
190
197
  headers: {
191
198
  'accept': 'application/json;odata=nometadata'
192
199
  },
@@ -205,6 +212,7 @@ class SpoListItemSetCommand extends SpoCommand_1.default {
205
212
  const excludeOptions = [
206
213
  'listTitle',
207
214
  'listId',
215
+ 'listUrl',
208
216
  'webUrl',
209
217
  'id',
210
218
  'contentType',
@@ -247,31 +255,28 @@ class SpoListItemSetCommand extends SpoCommand_1.default {
247
255
  * @param cmd command cmd
248
256
  */
249
257
  requestObjectIdentity(webUrl, logger, formDigestValue) {
250
- const requestOptions = {
251
- url: `${webUrl}/_vti_bin/client.svc/ProcessQuery`,
252
- headers: {
253
- 'X-RequestDigest': formDigestValue
254
- },
255
- data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Query Id="1" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="ServerRelativeUrl" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /></ObjectPaths></Request>`
256
- };
257
- return new Promise((resolve, reject) => {
258
- request_1.default.post(requestOptions).then((res) => {
259
- if (this.debug) {
260
- logger.logToStderr('Attempt to get _ObjectIdentity_ key values');
261
- }
262
- const json = JSON.parse(res);
263
- const contents = json.find(x => { return x['ErrorInfo']; });
264
- if (contents && contents.ErrorInfo) {
265
- reject(contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error');
266
- }
267
- const identityObject = json.find(x => { return x['_ObjectIdentity_']; });
268
- if (identityObject) {
269
- resolve(identityObject['_ObjectIdentity_']);
270
- }
271
- reject('Cannot proceed. _ObjectIdentity_ not found'); // this is not supposed to happen
272
- }).catch((err) => {
273
- reject(err);
274
- });
258
+ return __awaiter(this, void 0, void 0, function* () {
259
+ const requestOptions = {
260
+ url: `${webUrl}/_vti_bin/client.svc/ProcessQuery`,
261
+ headers: {
262
+ 'X-RequestDigest': formDigestValue
263
+ },
264
+ data: `<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="${config_1.default.applicationName}" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"><Actions><Query Id="1" ObjectPathId="5"><Query SelectAllProperties="false"><Properties><Property Name="ServerRelativeUrl" ScalarProperty="true" /></Properties></Query></Query></Actions><ObjectPaths><Property Id="5" ParentId="3" Name="Web" /><StaticProperty Id="3" TypeId="{3747adcd-a3c3-41b9-bfab-4a64dd2f1e0a}" Name="Current" /></ObjectPaths></Request>`
265
+ };
266
+ const response = yield request_1.default.post(requestOptions);
267
+ if (this.debug) {
268
+ logger.logToStderr('Attempt to get _ObjectIdentity_ key values');
269
+ }
270
+ const json = JSON.parse(response);
271
+ const contents = json.find(x => { return x['ErrorInfo']; });
272
+ if (contents && contents.ErrorInfo) {
273
+ throw contents.ErrorInfo.ErrorMessage || 'ClientSvc unknown error';
274
+ }
275
+ const identityObject = json.find(x => { return x['_ObjectIdentity_']; });
276
+ if (identityObject) {
277
+ return identityObject['_ObjectIdentity_'];
278
+ }
279
+ throw 'Cannot proceed. _ObjectIdentity_ not found'; // this is not supposed to happen
275
280
  });
276
281
  }
277
282
  }
@@ -280,6 +285,7 @@ _SpoListItemSetCommand_instances = new WeakSet(), _SpoListItemSetCommand_initTel
280
285
  Object.assign(this.telemetryProperties, {
281
286
  listId: typeof args.options.listId !== 'undefined',
282
287
  listTitle: typeof args.options.listTitle !== 'undefined',
288
+ listUrl: typeof args.options.listUrl !== 'undefined',
283
289
  contentType: typeof args.options.contentType !== 'undefined',
284
290
  systemUpdate: typeof args.options.systemUpdate !== 'undefined'
285
291
  });
@@ -293,6 +299,8 @@ _SpoListItemSetCommand_instances = new WeakSet(), _SpoListItemSetCommand_initTel
293
299
  option: '-l, --listId [listId]'
294
300
  }, {
295
301
  option: '-t, --listTitle [listTitle]'
302
+ }, {
303
+ option: '--listUrl [listUrl]'
296
304
  }, {
297
305
  option: '-c, --contentType [contentType]'
298
306
  }, {
@@ -311,10 +319,10 @@ _SpoListItemSetCommand_instances = new WeakSet(), _SpoListItemSetCommand_initTel
311
319
  return true;
312
320
  }));
313
321
  }, _SpoListItemSetCommand_initTypes = function _SpoListItemSetCommand_initTypes() {
314
- this.types.string.push('webUrl', 'listId', 'listTitle', 'id', 'contentType');
322
+ this.types.string.push('webUrl', 'listId', 'listTitle', 'listUrl', 'id', 'contentType');
315
323
  this.types.boolean.push('systemUpdate');
316
324
  }, _SpoListItemSetCommand_initOptionSets = function _SpoListItemSetCommand_initOptionSets() {
317
- this.optionSets.push(['listId', 'listTitle']);
325
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
318
326
  };
319
327
  module.exports = new SpoListItemSetCommand();
320
328
  //# sourceMappingURL=listitem-set.js.map