@pnp/cli-microsoft365 5.9.0-beta.c14dbbc → 5.9.0-beta.e2c58c7

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 (38) hide show
  1. package/dist/m365/outlook/commands/mail/mail-send.js +1 -1
  2. package/dist/m365/pp/commands/Environment.js +3 -0
  3. package/dist/m365/pp/commands/card/card-list.js +68 -0
  4. package/dist/m365/pp/commands/dataverse/dataverse-table-list.js +6 -12
  5. package/dist/m365/pp/commands/environment/environment-get.js +75 -0
  6. package/dist/m365/pp/commands.js +2 -0
  7. package/dist/m365/spo/commands/file/file-roleinheritance-break.js +129 -0
  8. package/dist/m365/spo/commands/folder/folder-roleassignment-remove.js +168 -0
  9. package/dist/m365/spo/commands/list/list-contenttype-add.js +21 -18
  10. package/dist/m365/spo/commands/list/list-contenttype-default-set.js +59 -47
  11. package/dist/m365/spo/commands/list/list-contenttype-list.js +16 -8
  12. package/dist/m365/spo/commands/list/list-contenttype-remove.js +16 -8
  13. package/dist/m365/spo/commands/list/list-webhook-add.js +19 -11
  14. package/dist/m365/spo/commands/list/list-webhook-get.js +17 -9
  15. package/dist/m365/spo/commands/list/list-webhook-list.js +23 -24
  16. package/dist/m365/spo/commands/list/list-webhook-remove.js +19 -11
  17. package/dist/m365/spo/commands/list/list-webhook-set.js +18 -10
  18. package/dist/m365/spo/commands.js +2 -0
  19. package/dist/m365/teams/commands/channel/channel-add.js +9 -9
  20. package/dist/m365/todo/commands/task/task-set.js +53 -1
  21. package/docs/docs/cmd/pp/card/card-list.md +33 -0
  22. package/docs/docs/cmd/pp/environment/environment-get.md +38 -0
  23. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-get.md +2 -2
  24. package/docs/docs/cmd/spo/eventreceiver/eventreceiver-remove.md +2 -2
  25. package/docs/docs/cmd/spo/file/file-roleinheritance-break.md +54 -0
  26. package/docs/docs/cmd/spo/folder/folder-roleassignment-remove.md +57 -0
  27. package/docs/docs/cmd/spo/list/list-contenttype-add.md +16 -7
  28. package/docs/docs/cmd/spo/list/list-contenttype-default-set.md +16 -7
  29. package/docs/docs/cmd/spo/list/list-contenttype-list.md +15 -6
  30. package/docs/docs/cmd/spo/list/list-contenttype-remove.md +17 -8
  31. package/docs/docs/cmd/spo/list/list-webhook-add.md +15 -16
  32. package/docs/docs/cmd/spo/list/list-webhook-get.md +15 -6
  33. package/docs/docs/cmd/spo/list/list-webhook-list.md +16 -7
  34. package/docs/docs/cmd/spo/list/list-webhook-remove.md +12 -10
  35. package/docs/docs/cmd/spo/list/list-webhook-set.md +13 -11
  36. package/docs/docs/cmd/teams/channel/channel-add.md +4 -4
  37. package/docs/docs/cmd/todo/task/task-set.md +29 -2
  38. package/package.json +3 -1
@@ -132,7 +132,7 @@ _OutlookMailSendCommand_instances = new WeakSet(), _OutlookMailSendCommand_initT
132
132
  if (args.options.bodyContentType &&
133
133
  args.options.bodyContentType !== 'Text' &&
134
134
  args.options.bodyContentType !== 'HTML') {
135
- return `${args.options.bodyContents} is not a valid value for the bodyContents option. Allowed values are Text|HTML`;
135
+ return `${args.options.bodyContentType} is not a valid value for the bodyContentType option. Allowed values are Text|HTML`;
136
136
  }
137
137
  if (args.options.saveToSentItems &&
138
138
  args.options.saveToSentItems !== 'true' &&
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Environment.js.map
@@ -0,0 +1,68 @@
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 _PpCardListCommand_instances, _PpCardListCommand_initTelemetry, _PpCardListCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const odata_1 = require("../../../../utils/odata");
19
+ const powerPlatform_1 = require("../../../../utils/powerPlatform");
20
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
21
+ const commands_1 = require("../../commands");
22
+ class PpCardListCommand extends PowerPlatformCommand_1.default {
23
+ constructor() {
24
+ super();
25
+ _PpCardListCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _PpCardListCommand_instances, "m", _PpCardListCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _PpCardListCommand_instances, "m", _PpCardListCommand_initOptions).call(this);
28
+ }
29
+ get name() {
30
+ return commands_1.default.CARD_LIST;
31
+ }
32
+ get description() {
33
+ return 'Lists Microsoft Power Platform cards in the specified Power Platform environment.';
34
+ }
35
+ defaultProperties() {
36
+ return ['name', 'cardid', 'publishdate', 'createdon', 'modifiedon'];
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Retrieving list of cards`);
42
+ }
43
+ try {
44
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
45
+ const items = yield odata_1.odata.getAllItems(`${dynamicsApiUrl}/api/data/v9.1/cards?$expand=owninguser($select=azureactivedirectoryobjectid,fullname)`);
46
+ logger.log(items);
47
+ }
48
+ catch (err) {
49
+ this.handleRejectedODataJsonPromise(err);
50
+ }
51
+ });
52
+ }
53
+ }
54
+ _PpCardListCommand_instances = new WeakSet(), _PpCardListCommand_initTelemetry = function _PpCardListCommand_initTelemetry() {
55
+ this.telemetry.push((args) => {
56
+ Object.assign(this.telemetryProperties, {
57
+ asAdmin: !!args.options.asAdmin
58
+ });
59
+ });
60
+ }, _PpCardListCommand_initOptions = function _PpCardListCommand_initOptions() {
61
+ this.options.unshift({
62
+ option: '-e, --environment <environment>'
63
+ }, {
64
+ option: '-a, --asAdmin'
65
+ });
66
+ };
67
+ module.exports = new PpCardListCommand();
68
+ //# sourceMappingURL=card-list.js.map
@@ -15,7 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _PpDataverseTableListCommand_instances, _PpDataverseTableListCommand_initTelemetry, _PpDataverseTableListCommand_initOptions;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const request_1 = require("../../../../request");
18
+ const odata_1 = require("../../../../utils/odata");
19
19
  const powerPlatform_1 = require("../../../../utils/powerPlatform");
20
20
  const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
21
21
  const commands_1 = require("../../commands");
@@ -33,24 +33,18 @@ class PpDataverseTableListCommand extends PowerPlatformCommand_1.default {
33
33
  return 'Lists dataverse tables in a given environment';
34
34
  }
35
35
  defaultProperties() {
36
- return ['SchemaName', 'EntitySetName', 'IsManaged'];
36
+ return ['SchemaName', 'EntitySetName', 'LogicalName', 'IsManaged'];
37
37
  }
38
38
  commandAction(logger, args) {
39
39
  return __awaiter(this, void 0, void 0, function* () {
40
40
  if (this.verbose) {
41
41
  logger.logToStderr(`Retrieving list of tables for which the user is an admin...`);
42
42
  }
43
- const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
44
- const requestOptions = {
45
- url: `${dynamicsApiUrl}/api/data/v9.0/EntityDefinitions?$select=MetadataId,IsCustomEntity,IsManaged,SchemaName,IconVectorName,LogicalName,EntitySetName,IsActivity,DataProviderId,IsRenameable,IsCustomizable,CanCreateForms,CanCreateViews,CanCreateCharts,CanCreateAttributes,CanChangeTrackingBeEnabled,CanModifyAdditionalSettings,CanChangeHierarchicalRelationship,CanEnableSyncToExternalSearchIndex&$filter=(IsIntersect eq false and IsLogicalEntity eq false and%0APrimaryNameAttribute ne null and PrimaryNameAttribute ne %27%27 and ObjectTypeCode gt 0 and%0AObjectTypeCode ne 4712 and ObjectTypeCode ne 4724 and ObjectTypeCode ne 9933 and ObjectTypeCode ne 9934 and%0AObjectTypeCode ne 9935 and ObjectTypeCode ne 9947 and ObjectTypeCode ne 9945 and ObjectTypeCode ne 9944 and%0AObjectTypeCode ne 9942 and ObjectTypeCode ne 9951 and ObjectTypeCode ne 2016 and ObjectTypeCode ne 9949 and%0AObjectTypeCode ne 9866 and ObjectTypeCode ne 9867 and ObjectTypeCode ne 9868) and (IsCustomizable/Value eq true or IsCustomEntity eq true or IsManaged eq false or IsMappable/Value eq true or IsRenameable/Value eq true)&api-version=9.1`,
46
- headers: {
47
- accept: 'application/json;odata.metadata=none'
48
- },
49
- responseType: 'json'
50
- };
51
43
  try {
52
- const res = yield request_1.default.get(requestOptions);
53
- logger.log(res.value);
44
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
45
+ const endpoint = `${dynamicsApiUrl}/api/data/v9.0/EntityDefinitions?$select=MetadataId,IsCustomEntity,IsManaged,SchemaName,IconVectorName,LogicalName,EntitySetName,IsActivity,DataProviderId,IsRenameable,IsCustomizable,CanCreateForms,CanCreateViews,CanCreateCharts,CanCreateAttributes,CanChangeTrackingBeEnabled,CanModifyAdditionalSettings,CanChangeHierarchicalRelationship,CanEnableSyncToExternalSearchIndex&$filter=(IsIntersect eq false and IsLogicalEntity eq false and%0APrimaryNameAttribute ne null and PrimaryNameAttribute ne %27%27 and ObjectTypeCode gt 0 and%0AObjectTypeCode ne 4712 and ObjectTypeCode ne 4724 and ObjectTypeCode ne 9933 and ObjectTypeCode ne 9934 and%0AObjectTypeCode ne 9935 and ObjectTypeCode ne 9947 and ObjectTypeCode ne 9945 and ObjectTypeCode ne 9944 and%0AObjectTypeCode ne 9942 and ObjectTypeCode ne 9951 and ObjectTypeCode ne 2016 and ObjectTypeCode ne 9949 and%0AObjectTypeCode ne 9866 and ObjectTypeCode ne 9867 and ObjectTypeCode ne 9868) and (IsCustomizable/Value eq true or IsCustomEntity eq true or IsManaged eq false or IsMappable/Value eq true or IsRenameable/Value eq true)&api-version=9.1`;
46
+ const res = yield odata_1.odata.getAllItems(endpoint);
47
+ logger.log(res);
54
48
  }
55
49
  catch (err) {
56
50
  this.handleRejectedODataJsonPromise(err);
@@ -0,0 +1,75 @@
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 _PpEnvironmentGetCommand_instances, _PpEnvironmentGetCommand_initTelemetry, _PpEnvironmentGetCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
20
+ const commands_1 = require("../../commands");
21
+ class PpEnvironmentGetCommand extends PowerPlatformCommand_1.default {
22
+ constructor() {
23
+ super();
24
+ _PpEnvironmentGetCommand_instances.add(this);
25
+ __classPrivateFieldGet(this, _PpEnvironmentGetCommand_instances, "m", _PpEnvironmentGetCommand_initTelemetry).call(this);
26
+ __classPrivateFieldGet(this, _PpEnvironmentGetCommand_instances, "m", _PpEnvironmentGetCommand_initOptions).call(this);
27
+ }
28
+ get name() {
29
+ return commands_1.default.ENVIRONMENT_GET;
30
+ }
31
+ get description() {
32
+ return 'Gets information about the specified Power Platform environment';
33
+ }
34
+ defaultProperties() {
35
+ return ['name', 'id'];
36
+ }
37
+ commandAction(logger, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ let url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/environments`;
40
+ if (args.options.asAdmin) {
41
+ url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments`;
42
+ }
43
+ const requestOptions = {
44
+ url: `${url}?api-version=2020-10-01`,
45
+ headers: {
46
+ accept: 'application/json'
47
+ },
48
+ responseType: 'json'
49
+ };
50
+ const res = yield request_1.default.get(requestOptions);
51
+ const environmentItem = res.value.filter((env) => {
52
+ return env.name === args.options.name;
53
+ })[0];
54
+ if (!environmentItem) {
55
+ throw `The specified Power Platform environment does not exist`;
56
+ }
57
+ logger.log(environmentItem);
58
+ });
59
+ }
60
+ }
61
+ _PpEnvironmentGetCommand_instances = new WeakSet(), _PpEnvironmentGetCommand_initTelemetry = function _PpEnvironmentGetCommand_initTelemetry() {
62
+ this.telemetry.push((args) => {
63
+ Object.assign(this.telemetryProperties, {
64
+ asAdmin: !!args.options.asAdmin
65
+ });
66
+ });
67
+ }, _PpEnvironmentGetCommand_initOptions = function _PpEnvironmentGetCommand_initOptions() {
68
+ this.options.unshift({
69
+ option: '-n, --name <name>'
70
+ }, {
71
+ option: '-a, --asAdmin'
72
+ });
73
+ };
74
+ module.exports = new PpEnvironmentGetCommand();
75
+ //# sourceMappingURL=environment-get.js.map
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'pp';
4
4
  exports.default = {
5
+ CARD_LIST: `${prefix} card list`,
5
6
  DATAVERSE_TABLE_LIST: `${prefix} dataverse table list`,
7
+ ENVIRONMENT_GET: `${prefix} environment get`,
6
8
  ENVIRONMENT_LIST: `${prefix} environment list`,
7
9
  GATEWAY_LIST: `${prefix} gateway list`,
8
10
  MANAGEMENTAPP_ADD: `${prefix} managementapp add`,
@@ -0,0 +1,129 @@
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 _SpoFileRoleInheritanceBreakCommand_instances, _SpoFileRoleInheritanceBreakCommand_initTelemetry, _SpoFileRoleInheritanceBreakCommand_initOptions, _SpoFileRoleInheritanceBreakCommand_initValidators, _SpoFileRoleInheritanceBreakCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const formatting_1 = require("../../../../utils/formatting");
22
+ const SpoCommand_1 = require("../../../base/SpoCommand");
23
+ const commands_1 = require("../../commands");
24
+ const SpoFileGetCommand = require("./file-get");
25
+ class SpoFileRoleInheritanceBreakCommand extends SpoCommand_1.default {
26
+ constructor() {
27
+ super();
28
+ _SpoFileRoleInheritanceBreakCommand_instances.add(this);
29
+ __classPrivateFieldGet(this, _SpoFileRoleInheritanceBreakCommand_instances, "m", _SpoFileRoleInheritanceBreakCommand_initTelemetry).call(this);
30
+ __classPrivateFieldGet(this, _SpoFileRoleInheritanceBreakCommand_instances, "m", _SpoFileRoleInheritanceBreakCommand_initOptions).call(this);
31
+ __classPrivateFieldGet(this, _SpoFileRoleInheritanceBreakCommand_instances, "m", _SpoFileRoleInheritanceBreakCommand_initValidators).call(this);
32
+ __classPrivateFieldGet(this, _SpoFileRoleInheritanceBreakCommand_instances, "m", _SpoFileRoleInheritanceBreakCommand_initOptionSets).call(this);
33
+ }
34
+ get name() {
35
+ return commands_1.default.FILE_ROLEINHERITANCE_BREAK;
36
+ }
37
+ get description() {
38
+ return 'Breaks inheritance of a file. Keeping existing permissions is the default behavior.';
39
+ }
40
+ commandAction(logger, args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const breakFileRoleInheritance = () => __awaiter(this, void 0, void 0, function* () {
43
+ try {
44
+ const fileURL = yield this.getFileURL(args);
45
+ const keepExistingPermissions = !args.options.clearExistingPermissions;
46
+ const requestOptions = {
47
+ url: `${args.options.webUrl}/_api/web/GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(fileURL)}')/ListItemAllFields/breakroleinheritance(${keepExistingPermissions})`,
48
+ headers: {
49
+ accept: 'application/json;odata=nometadata'
50
+ },
51
+ responseType: 'json'
52
+ };
53
+ yield request_1.default.post(requestOptions);
54
+ }
55
+ catch (err) {
56
+ this.handleRejectedODataJsonPromise(err);
57
+ }
58
+ });
59
+ if (args.options.confirm) {
60
+ yield breakFileRoleInheritance();
61
+ }
62
+ else {
63
+ const result = yield Cli_1.Cli.prompt({
64
+ type: 'confirm',
65
+ name: 'continue',
66
+ default: false,
67
+ message: `Are you sure you want to break the role inheritance of file ${args.options.fileUrl || args.options.fileId} located in site ${args.options.webUrl}?`
68
+ });
69
+ if (result.continue) {
70
+ yield breakFileRoleInheritance();
71
+ }
72
+ }
73
+ });
74
+ }
75
+ getFileURL(args) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ if (args.options.fileUrl) {
78
+ return args.options.fileUrl;
79
+ }
80
+ const options = {
81
+ webUrl: args.options.webUrl,
82
+ id: args.options.fileId,
83
+ output: 'json',
84
+ debug: this.debug,
85
+ verbose: this.verbose
86
+ };
87
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoFileGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
88
+ const getFileOutput = JSON.parse(output.stdout);
89
+ return getFileOutput.ServerRelativeUrl;
90
+ });
91
+ }
92
+ }
93
+ _SpoFileRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoFileRoleInheritanceBreakCommand_initTelemetry = function _SpoFileRoleInheritanceBreakCommand_initTelemetry() {
94
+ this.telemetry.push((args) => {
95
+ Object.assign(this.telemetryProperties, {
96
+ fileUrl: typeof args.options.fileUrl !== 'undefined',
97
+ fileId: typeof args.options.fileId !== 'undefined',
98
+ clearExistingPermissions: !!args.options.clearExistingPermissions,
99
+ confirm: !!args.options.confirm
100
+ });
101
+ });
102
+ }, _SpoFileRoleInheritanceBreakCommand_initOptions = function _SpoFileRoleInheritanceBreakCommand_initOptions() {
103
+ this.options.unshift({
104
+ option: '-u, --webUrl <webUrl>'
105
+ }, {
106
+ option: '--fileUrl [fileUrl]'
107
+ }, {
108
+ option: 'i, --fileId [fileId]'
109
+ }, {
110
+ option: '-c, --clearExistingPermissions'
111
+ }, {
112
+ option: '--confirm'
113
+ });
114
+ }, _SpoFileRoleInheritanceBreakCommand_initValidators = function _SpoFileRoleInheritanceBreakCommand_initValidators() {
115
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
116
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
117
+ if (isValidSharePointUrl !== true) {
118
+ return isValidSharePointUrl;
119
+ }
120
+ if (args.options.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
121
+ return `${args.options.fileId} is not a valid GUID`;
122
+ }
123
+ return true;
124
+ }));
125
+ }, _SpoFileRoleInheritanceBreakCommand_initOptionSets = function _SpoFileRoleInheritanceBreakCommand_initOptionSets() {
126
+ this.optionSets.push(['fileId', 'fileUrl']);
127
+ };
128
+ module.exports = new SpoFileRoleInheritanceBreakCommand();
129
+ //# sourceMappingURL=file-roleinheritance-break.js.map
@@ -0,0 +1,168 @@
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 _SpoFolderRoleAssignmentRemoveCommand_instances, _SpoFolderRoleAssignmentRemoveCommand_initTelemetry, _SpoFolderRoleAssignmentRemoveCommand_initOptions, _SpoFolderRoleAssignmentRemoveCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const urlUtil_1 = require("../../../../utils/urlUtil");
21
+ const validation_1 = require("../../../../utils/validation");
22
+ const SpoCommand_1 = require("../../../base/SpoCommand");
23
+ const commands_1 = require("../../commands");
24
+ const SpoUserGetCommand = require("../user/user-get");
25
+ const SpoGroupGetCommand = require("../group/group-get");
26
+ class SpoFolderRoleAssignmentRemoveCommand extends SpoCommand_1.default {
27
+ constructor() {
28
+ super();
29
+ _SpoFolderRoleAssignmentRemoveCommand_instances.add(this);
30
+ __classPrivateFieldGet(this, _SpoFolderRoleAssignmentRemoveCommand_instances, "m", _SpoFolderRoleAssignmentRemoveCommand_initTelemetry).call(this);
31
+ __classPrivateFieldGet(this, _SpoFolderRoleAssignmentRemoveCommand_instances, "m", _SpoFolderRoleAssignmentRemoveCommand_initOptions).call(this);
32
+ __classPrivateFieldGet(this, _SpoFolderRoleAssignmentRemoveCommand_instances, "m", _SpoFolderRoleAssignmentRemoveCommand_initValidators).call(this);
33
+ }
34
+ get name() {
35
+ return commands_1.default.FOLDER_ROLEASSIGNMENT_REMOVE;
36
+ }
37
+ get description() {
38
+ return 'Removes a role assignment from the specified folder';
39
+ }
40
+ commandAction(logger, args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const removeRoleAssignment = () => __awaiter(this, void 0, void 0, function* () {
43
+ if (this.verbose) {
44
+ logger.logToStderr(`Removing role assignment from folder in site at ${args.options.webUrl}...`);
45
+ }
46
+ const serverRelativeUrl = urlUtil_1.urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl);
47
+ const requestUrl = `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl('${encodeURIComponent(serverRelativeUrl)}')/ListItemAllFields`;
48
+ try {
49
+ if (args.options.upn) {
50
+ args.options.principalId = yield this.getUserPrincipalId(args.options);
51
+ yield this.removeRoleAssignment(requestUrl, logger, args.options);
52
+ }
53
+ else if (args.options.groupName) {
54
+ args.options.principalId = yield this.getGroupPrincipalId(args.options);
55
+ yield this.removeRoleAssignment(requestUrl, logger, args.options);
56
+ }
57
+ else {
58
+ yield this.removeRoleAssignment(requestUrl, logger, args.options);
59
+ }
60
+ }
61
+ catch (err) {
62
+ this.handleRejectedODataJsonPromise(err);
63
+ }
64
+ });
65
+ if (args.options.confirm) {
66
+ yield removeRoleAssignment();
67
+ }
68
+ else {
69
+ const result = yield Cli_1.Cli.prompt({
70
+ type: 'confirm',
71
+ name: 'continue',
72
+ default: false,
73
+ message: `Are you sure you want to remove a role assignment from the folder with url '${args.options.folderUrl}'?`
74
+ });
75
+ if (result.continue) {
76
+ yield removeRoleAssignment();
77
+ }
78
+ }
79
+ });
80
+ }
81
+ removeRoleAssignment(requestUrl, logger, options) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const requestOptions = {
84
+ url: `${requestUrl}/roleassignments/removeroleassignment(principalid='${options.principalId}')`,
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
+ }
95
+ getGroupPrincipalId(options) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const groupGetCommandOptions = {
98
+ webUrl: options.webUrl,
99
+ name: options.groupName,
100
+ output: 'json',
101
+ debug: this.debug,
102
+ verbose: this.verbose
103
+ };
104
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoGroupGetCommand, { options: Object.assign(Object.assign({}, groupGetCommandOptions), { _: [] }) });
105
+ const getGroupOutput = JSON.parse(output.stdout);
106
+ return getGroupOutput.Id;
107
+ });
108
+ }
109
+ getUserPrincipalId(options) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ const userGetCommandOptions = {
112
+ webUrl: options.webUrl,
113
+ email: options.upn,
114
+ id: undefined,
115
+ output: 'json',
116
+ debug: this.debug,
117
+ verbose: this.verbose
118
+ };
119
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, userGetCommandOptions), { _: [] }) });
120
+ const getUserOutput = JSON.parse(output.stdout);
121
+ return getUserOutput.Id;
122
+ });
123
+ }
124
+ }
125
+ _SpoFolderRoleAssignmentRemoveCommand_instances = new WeakSet(), _SpoFolderRoleAssignmentRemoveCommand_initTelemetry = function _SpoFolderRoleAssignmentRemoveCommand_initTelemetry() {
126
+ this.telemetry.push((args) => {
127
+ Object.assign(this.telemetryProperties, {
128
+ principalId: typeof args.options.principalId !== 'undefined',
129
+ upn: typeof args.options.upn !== 'undefined',
130
+ groupName: typeof args.options.groupName !== 'undefined',
131
+ confirm: (!(!args.options.confirm)).toString()
132
+ });
133
+ });
134
+ }, _SpoFolderRoleAssignmentRemoveCommand_initOptions = function _SpoFolderRoleAssignmentRemoveCommand_initOptions() {
135
+ this.options.unshift({
136
+ option: '-u, --webUrl <webUrl>'
137
+ }, {
138
+ option: '-f, --folderUrl <folderUrl>'
139
+ }, {
140
+ option: '--principalId [principalId]'
141
+ }, {
142
+ option: '--upn [upn]'
143
+ }, {
144
+ option: '--groupName [groupName]'
145
+ }, {
146
+ option: '--confirm'
147
+ });
148
+ }, _SpoFolderRoleAssignmentRemoveCommand_initValidators = function _SpoFolderRoleAssignmentRemoveCommand_initValidators() {
149
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
150
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
151
+ if (isValidSharePointUrl !== true) {
152
+ return isValidSharePointUrl;
153
+ }
154
+ if (args.options.principalId && isNaN(args.options.principalId)) {
155
+ return `Specified principalId ${args.options.principalId} is not a number`;
156
+ }
157
+ const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
158
+ if (principalOptions.some(item => item !== undefined) && principalOptions.filter(item => item !== undefined).length > 1) {
159
+ return `Specify either principalId id, upn or groupName`;
160
+ }
161
+ if (principalOptions.filter(item => item !== undefined).length === 0) {
162
+ return `Specify at least principalId id, upn or groupName`;
163
+ }
164
+ return true;
165
+ }));
166
+ };
167
+ module.exports = new SpoFolderRoleAssignmentRemoveCommand();
168
+ //# sourceMappingURL=folder-roleassignment-remove.js.map
@@ -17,6 +17,7 @@ var _SpoListContentTypeAddCommand_instances, _SpoListContentTypeAddCommand_initT
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");
@@ -39,19 +40,25 @@ class SpoListContentTypeAddCommand extends SpoCommand_1.default {
39
40
  commandAction(logger, args) {
40
41
  return __awaiter(this, void 0, void 0, function* () {
41
42
  if (this.verbose) {
42
- const list = (args.options.listId ? args.options.listId : args.options.listTitle);
43
+ const list = (args.options.listId ? args.options.listId : args.options.listTitle ? args.options.listTitle : args.options.listUrl);
43
44
  logger.logToStderr(`Adding content type ${args.options.contentTypeId} to list ${list} 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)}')/ContentTypes/AddAvailableContentType`;
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)}')/ContentTypes/AddAvailableContentType`;
50
+ else if (args.options.listTitle) {
51
+ requestUrl += `lists/getByTitle('${formatting_1.formatting.encodeQueryParameter(args.options.listTitle)}')`;
51
52
  }
52
- const requestBody = this.mapRequestBody(args.options);
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)}')`;
56
+ }
57
+ const requestBody = {
58
+ contentTypeId: args.options.contentTypeId
59
+ };
53
60
  const requestOptions = {
54
- url: requestUrl,
61
+ url: `${requestUrl}/ContentTypes/AddAvailableContentType`,
55
62
  headers: {
56
63
  'accept': 'application/json;odata=nometadata'
57
64
  },
@@ -67,17 +74,13 @@ class SpoListContentTypeAddCommand extends SpoCommand_1.default {
67
74
  }
68
75
  });
69
76
  }
70
- mapRequestBody(options) {
71
- return {
72
- contentTypeId: options.contentTypeId
73
- };
74
- }
75
77
  }
76
78
  _SpoListContentTypeAddCommand_instances = new WeakSet(), _SpoListContentTypeAddCommand_initTelemetry = function _SpoListContentTypeAddCommand_initTelemetry() {
77
79
  this.telemetry.push((args) => {
78
80
  Object.assign(this.telemetryProperties, {
79
81
  listId: typeof args.options.listId !== 'undefined',
80
- listTitle: typeof args.options.listTitle !== 'undefined'
82
+ listTitle: typeof args.options.listTitle !== 'undefined',
83
+ listUrl: typeof args.options.listUrl !== 'undefined'
81
84
  });
82
85
  });
83
86
  }, _SpoListContentTypeAddCommand_initOptions = function _SpoListContentTypeAddCommand_initOptions() {
@@ -87,6 +90,8 @@ _SpoListContentTypeAddCommand_instances = new WeakSet(), _SpoListContentTypeAddC
87
90
  option: '-l, --listId [listId]'
88
91
  }, {
89
92
  option: '-t, --listTitle [listTitle]'
93
+ }, {
94
+ option: '--listUrl [listUrl]'
90
95
  }, {
91
96
  option: '-c, --contentTypeId <contentTypeId>'
92
97
  });
@@ -96,17 +101,15 @@ _SpoListContentTypeAddCommand_instances = new WeakSet(), _SpoListContentTypeAddC
96
101
  if (isValidSharePointUrl !== true) {
97
102
  return isValidSharePointUrl;
98
103
  }
99
- if (args.options.listId) {
100
- if (!validation_1.validation.isValidGuid(args.options.listId)) {
101
- return `${args.options.listId} is not a valid GUID`;
102
- }
104
+ if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
105
+ return `${args.options.listId} is not a valid GUID`;
103
106
  }
104
107
  return true;
105
108
  }));
106
109
  }, _SpoListContentTypeAddCommand_initTypes = function _SpoListContentTypeAddCommand_initTypes() {
107
110
  this.types.string.push('contentTypeId', 'c');
108
111
  }, _SpoListContentTypeAddCommand_initOptionSets = function _SpoListContentTypeAddCommand_initOptionSets() {
109
- this.optionSets.push(['listId', 'listTitle']);
112
+ this.optionSets.push(['listId', 'listTitle', 'listUrl']);
110
113
  };
111
114
  module.exports = new SpoListContentTypeAddCommand();
112
115
  //# sourceMappingURL=list-contenttype-add.js.map