@pnp/cli-microsoft365 5.9.0-beta.3de06bc → 5.9.0-beta.3f2d5b9

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 (27) hide show
  1. package/.eslintrc.js +2 -0
  2. package/README.md +5 -0
  3. package/dist/m365/pp/commands/dataverse/dataverse-table-list.js +75 -0
  4. package/dist/m365/pp/commands/solution/Solution.js +3 -0
  5. package/dist/m365/pp/commands/solution/solution-list.js +87 -0
  6. package/dist/m365/pp/commands.js +2 -0
  7. package/dist/m365/spfx/commands/project/project-upgrade/upgrade-1.14.0.js +0 -2
  8. package/dist/m365/spfx/commands/spfx-doctor.js +37 -7
  9. package/dist/m365/spo/commands/file/file-copy.js +25 -39
  10. package/dist/m365/spo/commands/file/file-move.js +24 -37
  11. package/dist/m365/spo/commands/file/file-rename.js +19 -16
  12. package/dist/m365/spo/commands/file/file-roleassignment-add.js +231 -0
  13. package/dist/m365/spo/commands/file/file-roleinheritance-reset.js +1 -1
  14. package/dist/m365/spo/commands/folder/folder-roleinheritance-break.js +94 -0
  15. package/dist/m365/spo/commands/folder/folder-roleinheritance-reset.js +1 -1
  16. package/dist/m365/spo/commands.js +2 -0
  17. package/dist/utils/powerPlatform.js +42 -0
  18. package/docs/docs/cmd/pp/dataverse/dataverse-table-list.md +33 -0
  19. package/docs/docs/cmd/pp/solution/solution-list.md +33 -0
  20. package/docs/docs/cmd/spfx/spfx-doctor.md +10 -1
  21. package/docs/docs/cmd/spo/file/file-roleassignment-add.md +57 -0
  22. package/docs/docs/cmd/spo/folder/folder-roleinheritance-break.md +39 -0
  23. package/docs/docs/cmd/spo/folder/folder-roleinheritance-reset.md +2 -2
  24. package/docs/docs/cmd/spo/hubsite/hubsite-disconnect.md +1 -1
  25. package/docs/docs/cmd/spo/hubsite/hubsite-get.md +3 -3
  26. package/package.json +1 -1
  27. package/dist/m365/spfx/commands/project/project-upgrade/rules/FN006006_CFG_PS_features.js +0 -60
package/.eslintrc.js CHANGED
@@ -17,6 +17,7 @@ const dictionary = [
17
17
  'content',
18
18
  'conversation',
19
19
  'custom',
20
+ 'dataverse',
20
21
  'default',
21
22
  'external',
22
23
  'externalize',
@@ -61,6 +62,7 @@ const dictionary = [
61
62
  'site',
62
63
  'status',
63
64
  'storage',
65
+ 'table',
64
66
  'teams',
65
67
  'token',
66
68
  'type',
package/README.md CHANGED
@@ -15,6 +15,11 @@
15
15
  alt="GitHub" />
16
16
  </a>
17
17
 
18
+ <a href="https://discord.com/invite/7rfW4kg6B5">
19
+ <img src="https://img.shields.io/badge/Discord-Join-7289da?style=flat-square"
20
+ alt="Discord" />
21
+ </a>
22
+
18
23
  <a href="https://twitter.com/climicrosoft365">
19
24
  <img src="https://img.shields.io/badge/Twitter-%40climicrosoft365-blue?style=flat-square"
20
25
  alt="Twitter" />
@@ -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 _PpDataverseTableListCommand_instances, _PpDataverseTableListCommand_initTelemetry, _PpDataverseTableListCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const powerPlatform_1 = require("../../../../utils/powerPlatform");
20
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
21
+ const commands_1 = require("../../commands");
22
+ class PpDataverseTableListCommand extends PowerPlatformCommand_1.default {
23
+ constructor() {
24
+ super();
25
+ _PpDataverseTableListCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _PpDataverseTableListCommand_instances, "m", _PpDataverseTableListCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _PpDataverseTableListCommand_instances, "m", _PpDataverseTableListCommand_initOptions).call(this);
28
+ }
29
+ get name() {
30
+ return commands_1.default.DATAVERSE_TABLE_LIST;
31
+ }
32
+ get description() {
33
+ return 'Lists dataverse tables in a given environment';
34
+ }
35
+ defaultProperties() {
36
+ return ['SchemaName', 'EntitySetName', 'IsManaged'];
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Retrieving list of tables for which the user is an admin...`);
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
+ try {
52
+ const res = yield request_1.default.get(requestOptions);
53
+ logger.log(res.value);
54
+ }
55
+ catch (err) {
56
+ this.handleRejectedODataJsonPromise(err);
57
+ }
58
+ });
59
+ }
60
+ }
61
+ _PpDataverseTableListCommand_instances = new WeakSet(), _PpDataverseTableListCommand_initTelemetry = function _PpDataverseTableListCommand_initTelemetry() {
62
+ this.telemetry.push((args) => {
63
+ Object.assign(this.telemetryProperties, {
64
+ asAdmin: !!args.options.asAdmin
65
+ });
66
+ });
67
+ }, _PpDataverseTableListCommand_initOptions = function _PpDataverseTableListCommand_initOptions() {
68
+ this.options.unshift({
69
+ option: '-e, --environment <environment>'
70
+ }, {
71
+ option: '-a, --asAdmin'
72
+ });
73
+ };
74
+ module.exports = new PpDataverseTableListCommand();
75
+ //# sourceMappingURL=dataverse-table-list.js.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=Solution.js.map
@@ -0,0 +1,87 @@
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 _PpSolutionListCommand_instances, _PpSolutionListCommand_initTelemetry, _PpSolutionListCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const powerPlatform_1 = require("../../../../utils/powerPlatform");
20
+ const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
21
+ const commands_1 = require("../../commands");
22
+ class PpSolutionListCommand extends PowerPlatformCommand_1.default {
23
+ constructor() {
24
+ super();
25
+ _PpSolutionListCommand_instances.add(this);
26
+ __classPrivateFieldGet(this, _PpSolutionListCommand_instances, "m", _PpSolutionListCommand_initTelemetry).call(this);
27
+ __classPrivateFieldGet(this, _PpSolutionListCommand_instances, "m", _PpSolutionListCommand_initOptions).call(this);
28
+ }
29
+ get name() {
30
+ return commands_1.default.SOLUTION_LIST;
31
+ }
32
+ get description() {
33
+ return 'Lists solutions in a given environment.';
34
+ }
35
+ defaultProperties() {
36
+ return ['uniquename', 'version', 'publisher'];
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Retrieving list of solutions for which the user is an admin...`);
42
+ }
43
+ try {
44
+ const dynamicsApiUrl = yield powerPlatform_1.powerPlatform.getDynamicsInstanceApiUrl(args.options.environment, args.options.asAdmin);
45
+ const requestOptions = {
46
+ url: `${dynamicsApiUrl}/api/data/v9.0/solutions?$filter=isvisible eq true&$expand=publisherid($select=friendlyname)&$select=solutionid,uniquename,version,publisherid,installedon,solutionpackageversion,friendlyname,versionnumber&api-version=9.1`,
47
+ headers: {
48
+ accept: 'application/json;odata.metadata=none'
49
+ },
50
+ responseType: 'json'
51
+ };
52
+ const res = yield request_1.default.get(requestOptions);
53
+ if (!args.options.output || args.options.output === 'json') {
54
+ logger.log(res.value);
55
+ }
56
+ else {
57
+ //converted to text friendly output
58
+ logger.log(res.value.map(i => {
59
+ return {
60
+ uniquename: i.uniquename,
61
+ version: i.version,
62
+ publisher: i.publisherid.friendlyname
63
+ };
64
+ }));
65
+ }
66
+ }
67
+ catch (err) {
68
+ this.handleRejectedODataJsonPromise(err);
69
+ }
70
+ });
71
+ }
72
+ }
73
+ _PpSolutionListCommand_instances = new WeakSet(), _PpSolutionListCommand_initTelemetry = function _PpSolutionListCommand_initTelemetry() {
74
+ this.telemetry.push((args) => {
75
+ Object.assign(this.telemetryProperties, {
76
+ asAdmin: !!args.options.asAdmin
77
+ });
78
+ });
79
+ }, _PpSolutionListCommand_initOptions = function _PpSolutionListCommand_initOptions() {
80
+ this.options.unshift({
81
+ option: '-e, --environment <environment>'
82
+ }, {
83
+ option: '-a, --asAdmin'
84
+ });
85
+ };
86
+ module.exports = new PpSolutionListCommand();
87
+ //# sourceMappingURL=solution-list.js.map
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'pp';
4
4
  exports.default = {
5
+ DATAVERSE_TABLE_LIST: `${prefix} dataverse table list`,
5
6
  ENVIRONMENT_LIST: `${prefix} environment list`,
6
7
  GATEWAY_LIST: `${prefix} gateway list`,
7
8
  MANAGEMENTAPP_ADD: `${prefix} managementapp add`,
8
9
  MANAGEMENTAPP_LIST: `${prefix} managementapp list`,
10
+ SOLUTION_LIST: `${prefix} solution list`,
9
11
  TENANT_SETTINGS_LIST: `${prefix} tenant settings list`
10
12
  };
11
13
  //# sourceMappingURL=commands.js.map
@@ -25,7 +25,6 @@ const FN002009_DEVDEP_microsoft_sp_tslint_rules_1 = require("./rules/FN002009_DE
25
25
  const FN002019_DEVDEP_spfx_fast_serve_helpers_1 = require("./rules/FN002019_DEVDEP_spfx_fast_serve_helpers");
26
26
  const FN006004_CFG_PS_developer_1 = require("./rules/FN006004_CFG_PS_developer");
27
27
  const FN006005_CFG_PS_metadata_1 = require("./rules/FN006005_CFG_PS_metadata");
28
- const FN006006_CFG_PS_features_1 = require("./rules/FN006006_CFG_PS_features");
29
28
  const FN010001_YORC_version_1 = require("./rules/FN010001_YORC_version");
30
29
  const FN014008_CODE_launch_hostedWorkbench_type_1 = require("./rules/FN014008_CODE_launch_hostedWorkbench_type");
31
30
  module.exports = [
@@ -54,7 +53,6 @@ module.exports = [
54
53
  new FN002019_DEVDEP_spfx_fast_serve_helpers_1.FN002019_DEVDEP_spfx_fast_serve_helpers('1.14.0'),
55
54
  new FN006004_CFG_PS_developer_1.FN006004_CFG_PS_developer('1.14.0'),
56
55
  new FN006005_CFG_PS_metadata_1.FN006005_CFG_PS_metadata(),
57
- new FN006006_CFG_PS_features_1.FN006006_CFG_PS_features(),
58
56
  new FN010001_YORC_version_1.FN010001_YORC_version('1.14.0'),
59
57
  new FN014008_CODE_launch_hostedWorkbench_type_1.FN014008_CODE_launch_hostedWorkbench_type('pwa-chrome')
60
58
  ];
@@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
13
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
14
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
15
  };
16
- var _SpfxDoctorCommand_instances, _SpfxDoctorCommand_initTelemetry, _SpfxDoctorCommand_initOptions, _SpfxDoctorCommand_initValidators, _SpfxDoctorCommand_initTypes;
16
+ var _SpfxDoctorCommand_instances, _SpfxDoctorCommand_initTelemetry, _SpfxDoctorCommand_initOptions, _SpfxDoctorCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const chalk = require("chalk");
19
19
  const child_process = require("child_process");
@@ -448,7 +448,6 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
448
448
  __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initTelemetry).call(this);
449
449
  __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initOptions).call(this);
450
450
  __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initValidators).call(this);
451
- __classPrivateFieldGet(this, _SpfxDoctorCommand_instances, "m", _SpfxDoctorCommand_initTypes).call(this);
452
451
  }
453
452
  get name() {
454
453
  return commands_1.default.DOCTOR;
@@ -457,6 +456,7 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
457
456
  return 'Verifies environment configuration for using the specific version of the SharePoint Framework';
458
457
  }
459
458
  commandAction(logger, args) {
459
+ var _a;
460
460
  return __awaiter(this, void 0, void 0, function* () {
461
461
  if (!args.options.output) {
462
462
  args.options.output = 'text';
@@ -469,7 +469,7 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
469
469
  let prerequisites;
470
470
  const fixes = [];
471
471
  try {
472
- spfxVersion = yield this.getSharePointFrameworkVersion(logger);
472
+ spfxVersion = (_a = args.options.spfxVersion) !== null && _a !== void 0 ? _a : yield this.getSharePointFrameworkVersion(logger);
473
473
  if (!spfxVersion) {
474
474
  logger.log(this.getStatus(CheckStatus.Failure, `SharePoint Framework`));
475
475
  throw `SharePoint Framework not found`;
@@ -479,7 +479,13 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
479
479
  logger.log(this.getStatus(CheckStatus.Failure, `SharePoint Framework v${spfxVersion}`));
480
480
  throw `spfx doctor doesn't support SPFx v${spfxVersion} at this moment`;
481
481
  }
482
- logger.log(this.getStatus(CheckStatus.Success, `SharePoint Framework v${spfxVersion}`));
482
+ if (args.options.spfxVersion) {
483
+ yield this.checkSharePointFrameworkVersion(args.options.spfxVersion, fixes, logger);
484
+ }
485
+ else {
486
+ // spfx was detected and if we are here, it means that we support it
487
+ logger.log(this.getStatus(CheckStatus.Success, `SharePoint Framework v${spfxVersion}`));
488
+ }
483
489
  yield this.checkSharePointCompatibility(spfxVersion, prerequisites, args, fixes, logger);
484
490
  yield this.checkNodeVersion(prerequisites, fixes, logger);
485
491
  yield this.checkYo(prerequisites, fixes, logger);
@@ -532,6 +538,23 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
532
538
  this.checkStatus('Node', nodeVersion, prerequisites.node, OptionalOrRequired.Required, fixes, logger);
533
539
  });
534
540
  }
541
+ checkSharePointFrameworkVersion(spfxVersionRequested, fixes, logger) {
542
+ return this
543
+ .getPackageVersion('@microsoft/generator-sharepoint', PackageSearchMode.GlobalOnly, HandlePromise.Continue, logger)
544
+ .then((spfxVersionDetected) => {
545
+ const versionCheck = {
546
+ range: spfxVersionRequested,
547
+ fix: `npm i -g @microsoft/generator-sharepoint@${spfxVersionRequested}`
548
+ };
549
+ if (spfxVersionDetected) {
550
+ this.checkStatus(`SharePoint Framework`, spfxVersionDetected, versionCheck, OptionalOrRequired.Required, fixes, logger);
551
+ }
552
+ else {
553
+ logger.log(this.getStatus(CheckStatus.Failure, `SharePoint Framework v${spfxVersionRequested} not found`));
554
+ fixes.push(versionCheck.fix);
555
+ }
556
+ });
557
+ }
535
558
  checkYo(prerequisites, fixes, logger) {
536
559
  return this
537
560
  .getPackageVersion('yo', PackageSearchMode.GlobalOnly, HandlePromise.Continue, logger)
@@ -710,13 +733,17 @@ class SpfxDoctorCommand extends AnonymousCommand_1.default {
710
733
  _SpfxDoctorCommand_instances = new WeakSet(), _SpfxDoctorCommand_initTelemetry = function _SpfxDoctorCommand_initTelemetry() {
711
734
  this.telemetry.push((args) => {
712
735
  Object.assign(this.telemetryProperties, {
713
- env: args.options.env
736
+ env: args.options.env,
737
+ spfxVersion: args.options.spfxVersion
714
738
  });
715
739
  });
716
740
  }, _SpfxDoctorCommand_initOptions = function _SpfxDoctorCommand_initOptions() {
717
741
  this.options.unshift({
718
742
  option: '-e, --env [env]',
719
743
  autocomplete: ['sp2016', 'sp2019', 'spo']
744
+ }, {
745
+ option: '-v, --spfxVersion [spfxVersion]',
746
+ autocomplete: Object.keys(this.versions)
720
747
  });
721
748
  }, _SpfxDoctorCommand_initValidators = function _SpfxDoctorCommand_initValidators() {
722
749
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -726,13 +753,16 @@ _SpfxDoctorCommand_instances = new WeakSet(), _SpfxDoctorCommand_initTelemetry =
726
753
  return `${args.options.env} is not a valid SharePoint version. Valid versions are sp2016, sp2019 or spo`;
727
754
  }
728
755
  }
756
+ if (args.options.spfxVersion) {
757
+ if (!this.versions[args.options.spfxVersion]) {
758
+ return `${args.options.spfxVersion} is not a supported SharePoint Framework version. Supported versions are ${Object.keys(this.versions).join(', ')}`;
759
+ }
760
+ }
729
761
  if (args.options.output && args.options.output !== 'text') {
730
762
  return `The output option only accepts the type 'text'`;
731
763
  }
732
764
  return true;
733
765
  }));
734
- }, _SpfxDoctorCommand_initTypes = function _SpfxDoctorCommand_initTypes() {
735
- this.types.string.push('e', 'env');
736
766
  };
737
767
  module.exports = new SpfxDoctorCommand();
738
768
  //# sourceMappingURL=spfx-doctor.js.map
@@ -16,12 +16,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
16
16
  var _SpoFileCopyCommand_instances, _SpoFileCopyCommand_initTelemetry, _SpoFileCopyCommand_initOptions, _SpoFileCopyCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const url = require("url");
19
+ const Cli_1 = require("../../../../cli/Cli");
19
20
  const request_1 = require("../../../../request");
20
21
  const spo_1 = require("../../../../utils/spo");
21
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");
26
+ const removeCommand = require('./file-remove');
25
27
  class SpoFileCopyCommand extends SpoCommand_1.default {
26
28
  constructor() {
27
29
  super();
@@ -123,50 +125,34 @@ class SpoFileCopyCommand extends SpoCommand_1.default {
123
125
  * Moves file in the site recycle bin
124
126
  */
125
127
  recycleFile(tenantUrl, targetUrl, filename, logger) {
126
- return new Promise((resolve, reject) => {
128
+ return __awaiter(this, void 0, void 0, function* () {
127
129
  const targetFolderAbsoluteUrl = urlUtil_1.urlUtil.urlCombine(tenantUrl, targetUrl);
128
- // since the target WebFullUrl is unknown we can use getRequestDigestForSite
130
+ // since the target WebFullUrl is unknown we can use getRequestDigest
129
131
  // to get it from target folder absolute url.
130
132
  // Similar approach used here Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect
131
- spo_1.spo
132
- .getRequestDigest(targetFolderAbsoluteUrl)
133
- .then((contextResponse) => {
134
- if (this.debug) {
135
- logger.logToStderr(`contextResponse.WebFullUrl: ${contextResponse.WebFullUrl}`);
136
- }
137
- if (targetUrl.charAt(0) !== '/') {
138
- targetUrl = `/${targetUrl}`;
133
+ const contextResponse = yield spo_1.spo.getRequestDigest(targetFolderAbsoluteUrl);
134
+ if (this.debug) {
135
+ logger.logToStderr(`contextResponse.WebFullUrl: ${contextResponse.WebFullUrl}`);
136
+ }
137
+ const targetFileServerRelativeUrl = `${urlUtil_1.urlUtil.getServerRelativePath(contextResponse.WebFullUrl, targetUrl)}/${filename}`;
138
+ const removeOptions = {
139
+ webUrl: contextResponse.WebFullUrl,
140
+ url: targetFileServerRelativeUrl,
141
+ recycle: true,
142
+ confirm: true,
143
+ debug: this.debug,
144
+ verbose: this.verbose
145
+ };
146
+ try {
147
+ yield Cli_1.Cli.executeCommand(removeCommand, { options: Object.assign(Object.assign({}, removeOptions), { _: [] }) });
148
+ }
149
+ catch (err) {
150
+ if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) {
139
151
  }
140
- if (targetUrl.lastIndexOf('/') !== targetUrl.length - 1) {
141
- targetUrl = `${targetUrl}/`;
152
+ else {
153
+ throw err;
142
154
  }
143
- const requestUrl = `${contextResponse.WebFullUrl}/_api/web/GetFileByServerRelativeUrl('${encodeURIComponent(`${targetUrl}${filename}`)}')/recycle()`;
144
- const requestOptions = {
145
- url: requestUrl,
146
- method: 'POST',
147
- headers: {
148
- 'X-HTTP-Method': 'DELETE',
149
- 'If-Match': '*',
150
- 'accept': 'application/json;odata=nometadata'
151
- },
152
- responseType: 'json'
153
- };
154
- request_1.default.post(requestOptions)
155
- .then(() => {
156
- resolve();
157
- })
158
- .catch((err) => {
159
- if (err.statusCode === 404) {
160
- // file does not exist so can proceed
161
- return resolve();
162
- }
163
- if (this.debug) {
164
- logger.logToStderr(`recycleFile error...`);
165
- logger.logToStderr(err);
166
- }
167
- reject(err);
168
- });
169
- }, (e) => reject(e));
155
+ }
170
156
  });
171
157
  }
172
158
  }
@@ -16,12 +16,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
16
16
  var _SpoFileMoveCommand_instances, _SpoFileMoveCommand_initTelemetry, _SpoFileMoveCommand_initOptions, _SpoFileMoveCommand_initValidators;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const url = require("url");
19
+ const Cli_1 = require("../../../../cli/Cli");
19
20
  const request_1 = require("../../../../request");
20
21
  const spo_1 = require("../../../../utils/spo");
21
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");
26
+ const removeCommand = require('./file-remove');
25
27
  class SpoFileMoveCommand extends SpoCommand_1.default {
26
28
  constructor() {
27
29
  super();
@@ -124,49 +126,34 @@ class SpoFileMoveCommand extends SpoCommand_1.default {
124
126
  * Moves file in the site recycle bin
125
127
  */
126
128
  recycleFile(tenantUrl, targetUrl, filename, logger) {
127
- return new Promise((resolve, reject) => {
129
+ return __awaiter(this, void 0, void 0, function* () {
128
130
  const targetFolderAbsoluteUrl = urlUtil_1.urlUtil.urlCombine(tenantUrl, targetUrl);
129
131
  // since the target WebFullUrl is unknown we can use getRequestDigest
130
132
  // to get it from target folder absolute url.
131
133
  // Similar approach used here Microsoft.SharePoint.Client.Web.WebUrlFromFolderUrlDirect
132
- spo_1.spo.getRequestDigest(targetFolderAbsoluteUrl)
133
- .then((contextResponse) => {
134
- if (this.debug) {
135
- logger.logToStderr(`contextResponse.WebFullUrl: ${contextResponse.WebFullUrl}`);
136
- }
137
- if (targetUrl.charAt(0) !== '/') {
138
- targetUrl = `/${targetUrl}`;
134
+ const contextResponse = yield spo_1.spo.getRequestDigest(targetFolderAbsoluteUrl);
135
+ if (this.debug) {
136
+ logger.logToStderr(`contextResponse.WebFullUrl: ${contextResponse.WebFullUrl}`);
137
+ }
138
+ const targetFileServerRelativeUrl = `${urlUtil_1.urlUtil.getServerRelativePath(contextResponse.WebFullUrl, targetUrl)}/${filename}`;
139
+ const removeOptions = {
140
+ webUrl: contextResponse.WebFullUrl,
141
+ url: targetFileServerRelativeUrl,
142
+ recycle: true,
143
+ confirm: true,
144
+ debug: this.debug,
145
+ verbose: this.verbose
146
+ };
147
+ try {
148
+ yield Cli_1.Cli.executeCommand(removeCommand, { options: Object.assign(Object.assign({}, removeOptions), { _: [] }) });
149
+ }
150
+ catch (err) {
151
+ if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) {
139
152
  }
140
- if (targetUrl.lastIndexOf('/') !== targetUrl.length - 1) {
141
- targetUrl = `${targetUrl}/`;
153
+ else {
154
+ throw err;
142
155
  }
143
- const requestUrl = `${contextResponse.WebFullUrl}/_api/web/GetFileByServerRelativeUrl('${encodeURIComponent(`${targetUrl}${filename}`)}')/recycle()`;
144
- const requestOptions = {
145
- url: requestUrl,
146
- method: 'POST',
147
- headers: {
148
- 'X-HTTP-Method': 'DELETE',
149
- 'If-Match': '*',
150
- 'accept': 'application/json;odata=nometadata'
151
- },
152
- responseType: 'json'
153
- };
154
- request_1.default.post(requestOptions)
155
- .then(() => {
156
- resolve();
157
- })
158
- .catch((err) => {
159
- if (err.statusCode === 404) {
160
- // file does not exist so can proceed
161
- return resolve();
162
- }
163
- if (this.debug) {
164
- logger.logToStderr(`recycleFile error...`);
165
- logger.logToStderr(err);
166
- }
167
- reject(err);
168
- });
169
- }, (e) => reject(e));
156
+ }
170
157
  });
171
158
  }
172
159
  }
@@ -79,23 +79,26 @@ class SpoFileRenameCommand extends SpoCommand_1.default {
79
79
  return request_1.default.get(requestOptions);
80
80
  }
81
81
  deleteFile(webUrl, sourceUrl, targetFileName) {
82
- const targetFileServerRelativeUrl = `${urlUtil_1.urlUtil.getServerRelativePath(webUrl, sourceUrl.substring(0, sourceUrl.lastIndexOf('/')))}/${targetFileName}`;
83
- const options = {
84
- webUrl: webUrl,
85
- url: targetFileServerRelativeUrl,
86
- recycle: true,
87
- confirm: true,
88
- debug: this.debug,
89
- verbose: this.verbose
90
- };
91
- return Cli_1.Cli.executeCommandWithOutput(removeCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) })
92
- .then(_ => {
93
- return Promise.resolve();
94
- }, (err) => {
95
- if (err.error !== null && err.error.message !== null && err.error.message.includes('does not exist')) {
96
- return Promise.resolve();
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const targetFileServerRelativeUrl = `${urlUtil_1.urlUtil.getServerRelativePath(webUrl, sourceUrl.substring(0, sourceUrl.lastIndexOf('/')))}/${targetFileName}`;
84
+ const removeOptions = {
85
+ webUrl: webUrl,
86
+ url: targetFileServerRelativeUrl,
87
+ recycle: true,
88
+ confirm: true,
89
+ debug: this.debug,
90
+ verbose: this.verbose
91
+ };
92
+ try {
93
+ yield Cli_1.Cli.executeCommand(removeCommand, { options: Object.assign(Object.assign({}, removeOptions), { _: [] }) });
94
+ }
95
+ catch (err) {
96
+ if (err.error !== undefined && err.error.message !== undefined && err.error.message.includes('does not exist')) {
97
+ }
98
+ else {
99
+ throw err;
100
+ }
97
101
  }
98
- return Promise.reject(err);
99
102
  });
100
103
  }
101
104
  }
@@ -0,0 +1,231 @@
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 _SpoFileRoleAssignmentAddCommand_instances, _SpoFileRoleAssignmentAddCommand_initTelemetry, _SpoFileRoleAssignmentAddCommand_initOptions, _SpoFileRoleAssignmentAddCommand_initValidators, _SpoFileRoleAssignmentAddCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const SpoUserGetCommand = require("../user/user-get");
20
+ const SpoGroupGetCommand = require("../group/group-get");
21
+ const SpoRoleDefinitionListCommand = require("../roledefinition/roledefinition-list");
22
+ const SpoFileGetCommand = require("./file-get");
23
+ const request_1 = require("../../../../request");
24
+ const validation_1 = require("../../../../utils/validation");
25
+ const formatting_1 = require("../../../../utils/formatting");
26
+ const SpoCommand_1 = require("../../../base/SpoCommand");
27
+ const commands_1 = require("../../commands");
28
+ class SpoFileRoleAssignmentAddCommand extends SpoCommand_1.default {
29
+ constructor() {
30
+ super();
31
+ _SpoFileRoleAssignmentAddCommand_instances.add(this);
32
+ __classPrivateFieldGet(this, _SpoFileRoleAssignmentAddCommand_instances, "m", _SpoFileRoleAssignmentAddCommand_initTelemetry).call(this);
33
+ __classPrivateFieldGet(this, _SpoFileRoleAssignmentAddCommand_instances, "m", _SpoFileRoleAssignmentAddCommand_initOptions).call(this);
34
+ __classPrivateFieldGet(this, _SpoFileRoleAssignmentAddCommand_instances, "m", _SpoFileRoleAssignmentAddCommand_initValidators).call(this);
35
+ __classPrivateFieldGet(this, _SpoFileRoleAssignmentAddCommand_instances, "m", _SpoFileRoleAssignmentAddCommand_initOptionSets).call(this);
36
+ }
37
+ get name() {
38
+ return commands_1.default.FILE_ROLEASSIGNMENT_ADD;
39
+ }
40
+ get description() {
41
+ return 'Adds a role assignment to the specified file.';
42
+ }
43
+ commandAction(logger, args) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ if (this.verbose) {
46
+ logger.logToStderr(`Adding role assignment to file in site at ${args.options.webUrl}...`);
47
+ }
48
+ try {
49
+ const fileUrl = yield this.getFileURL(args);
50
+ const roleDefinitionId = yield this.getRoleDefinitionId(args.options);
51
+ if (args.options.upn) {
52
+ const upnPrincipalId = yield this.getUserPrincipalId(args.options);
53
+ yield this.addRoleAssignment(fileUrl, args.options.webUrl, upnPrincipalId, roleDefinitionId);
54
+ }
55
+ else if (args.options.groupName) {
56
+ const groupPrincipalId = yield this.getGroupPrincipalId(args.options);
57
+ yield this.addRoleAssignment(fileUrl, args.options.webUrl, groupPrincipalId, roleDefinitionId);
58
+ }
59
+ else {
60
+ yield this.addRoleAssignment(fileUrl, args.options.webUrl, args.options.principalId, roleDefinitionId);
61
+ }
62
+ }
63
+ catch (err) {
64
+ this.handleRejectedODataJsonPromise(err);
65
+ }
66
+ });
67
+ }
68
+ addRoleAssignment(fileUrl, webUrl, principalId, roleDefinitionId) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ try {
71
+ const requestOptions = {
72
+ url: `${webUrl}/_api/web/GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(fileUrl)}')/ListItemAllFields/roleassignments/addroleassignment(principalid='${principalId}',roledefid='${roleDefinitionId}')`,
73
+ method: 'POST',
74
+ headers: {
75
+ 'accept': 'application/json;odata=nometadata',
76
+ 'content-type': 'application/json'
77
+ },
78
+ responseType: 'json'
79
+ };
80
+ yield request_1.default.post(requestOptions);
81
+ }
82
+ catch (err) {
83
+ return Promise.reject(err);
84
+ }
85
+ });
86
+ }
87
+ getRoleDefinitionId(options) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ if (!options.roleDefinitionName) {
90
+ return options.roleDefinitionId;
91
+ }
92
+ try {
93
+ const roleDefinitionListCommandOptions = {
94
+ webUrl: options.webUrl,
95
+ output: 'json',
96
+ debug: this.debug,
97
+ verbose: this.verbose
98
+ };
99
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoRoleDefinitionListCommand, { options: Object.assign(Object.assign({}, roleDefinitionListCommandOptions), { _: [] }) });
100
+ const getRoleDefinitionListOutput = JSON.parse(output.stdout);
101
+ const roleDefinitionId = getRoleDefinitionListOutput.find((role) => role.Name === options.roleDefinitionName).Id;
102
+ return roleDefinitionId;
103
+ }
104
+ catch (err) {
105
+ return Promise.reject(err);
106
+ }
107
+ });
108
+ }
109
+ getGroupPrincipalId(options) {
110
+ return __awaiter(this, void 0, void 0, function* () {
111
+ try {
112
+ const groupGetCommandOptions = {
113
+ webUrl: options.webUrl,
114
+ name: options.groupName,
115
+ output: 'json',
116
+ debug: this.debug,
117
+ verbose: this.verbose
118
+ };
119
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoGroupGetCommand, { options: Object.assign(Object.assign({}, groupGetCommandOptions), { _: [] }) });
120
+ const getGroupOutput = JSON.parse(output.stdout);
121
+ return getGroupOutput.Id;
122
+ }
123
+ catch (err) {
124
+ return Promise.reject(err);
125
+ }
126
+ });
127
+ }
128
+ getUserPrincipalId(options) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ try {
131
+ const userGetCommandOptions = {
132
+ webUrl: options.webUrl,
133
+ email: options.upn,
134
+ id: undefined,
135
+ output: 'json',
136
+ debug: this.debug,
137
+ verbose: this.verbose
138
+ };
139
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, userGetCommandOptions), { _: [] }) });
140
+ const getUserOutput = JSON.parse(output.stdout);
141
+ return getUserOutput.Id;
142
+ }
143
+ catch (err) {
144
+ return Promise.reject(err);
145
+ }
146
+ });
147
+ }
148
+ getFileURL(args) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ if (args.options.fileUrl) {
151
+ return args.options.fileUrl;
152
+ }
153
+ const options = {
154
+ webUrl: args.options.webUrl,
155
+ id: args.options.fileId,
156
+ output: 'json',
157
+ debug: this.debug,
158
+ verbose: this.verbose
159
+ };
160
+ const output = yield Cli_1.Cli.executeCommandWithOutput(SpoFileGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
161
+ const getFileOutput = JSON.parse(output.stdout);
162
+ return getFileOutput.ServerRelativeUrl;
163
+ });
164
+ }
165
+ }
166
+ _SpoFileRoleAssignmentAddCommand_instances = new WeakSet(), _SpoFileRoleAssignmentAddCommand_initTelemetry = function _SpoFileRoleAssignmentAddCommand_initTelemetry() {
167
+ this.telemetry.push((args) => {
168
+ Object.assign(this.telemetryProperties, {
169
+ fileUrl: typeof args.options.fileUrl !== 'undefined',
170
+ fileId: typeof args.options.fileId !== 'undefined',
171
+ principalId: typeof args.options.principalId !== 'undefined',
172
+ upn: typeof args.options.upn !== 'undefined',
173
+ groupName: typeof args.options.groupName !== 'undefined',
174
+ roleDefinitionId: typeof args.options.roleDefinitionId !== 'undefined',
175
+ roleDefinitionName: typeof args.options.roleDefinitionName !== 'undefined'
176
+ });
177
+ });
178
+ }, _SpoFileRoleAssignmentAddCommand_initOptions = function _SpoFileRoleAssignmentAddCommand_initOptions() {
179
+ this.options.unshift({
180
+ option: '-u, --webUrl <webUrl>'
181
+ }, {
182
+ option: '--fileUrl [fileUrl]'
183
+ }, {
184
+ option: 'i, --fileId [fileId]'
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
+ }, _SpoFileRoleAssignmentAddCommand_initValidators = function _SpoFileRoleAssignmentAddCommand_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.fileId && !validation_1.validation.isValidGuid(args.options.fileId)) {
203
+ return `${args.options.fileId} is not a valid GUID`;
204
+ }
205
+ if (args.options.principalId && isNaN(args.options.principalId)) {
206
+ return `Specified principalId ${args.options.principalId} is not a number`;
207
+ }
208
+ if (args.options.roleDefinitionId && isNaN(args.options.roleDefinitionId)) {
209
+ return `Specified roleDefinitionId ${args.options.roleDefinitionId} is not a number`;
210
+ }
211
+ const principalOptions = [args.options.principalId, args.options.upn, args.options.groupName];
212
+ if (!principalOptions.some(item => item !== undefined)) {
213
+ return `Specify either principalId, upn or groupName`;
214
+ }
215
+ if (principalOptions.filter(item => item !== undefined).length > 1) {
216
+ return `Specify either principalId, upn or groupName but not multiple`;
217
+ }
218
+ const roleDefinitionOptions = [args.options.roleDefinitionId, args.options.roleDefinitionName];
219
+ if (!roleDefinitionOptions.some(item => item !== undefined)) {
220
+ return `Specify either roleDefinitionId or roleDefinitionName`;
221
+ }
222
+ if (roleDefinitionOptions.filter(item => item !== undefined).length > 1) {
223
+ return `Specify either roleDefinitionId or roleDefinitionName but not multiple`;
224
+ }
225
+ return true;
226
+ }));
227
+ }, _SpoFileRoleAssignmentAddCommand_initOptionSets = function _SpoFileRoleAssignmentAddCommand_initOptionSets() {
228
+ this.optionSets.push(['fileId', 'fileUrl']);
229
+ };
230
+ module.exports = new SpoFileRoleAssignmentAddCommand();
231
+ //# sourceMappingURL=file-roleassignment-add.js.map
@@ -45,7 +45,7 @@ class SpoFileRoleInheritanceResetCommand extends SpoCommand_1.default {
45
45
  const requestOptions = {
46
46
  url: `${args.options.webUrl}/_api/web/GetFileByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(fileURL)}')/ListItemAllFields/resetroleinheritance`,
47
47
  headers: {
48
- accept: 'application/json;odata.metadata=none'
48
+ accept: 'application/json;odata=nometadata'
49
49
  },
50
50
  responseType: 'json'
51
51
  };
@@ -0,0 +1,94 @@
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 _SpoFolderRoleInheritanceBreakCommand_instances, _SpoFolderRoleInheritanceBreakCommand_initTelemetry, _SpoFolderRoleInheritanceBreakCommand_initOptions, _SpoFolderRoleInheritanceBreakCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const Cli_1 = require("../../../../cli/Cli");
19
+ const request_1 = require("../../../../request");
20
+ const formatting_1 = require("../../../../utils/formatting");
21
+ const validation_1 = require("../../../../utils/validation");
22
+ const SpoCommand_1 = require("../../../base/SpoCommand");
23
+ const commands_1 = require("../../commands");
24
+ class SpoFolderRoleInheritanceBreakCommand extends SpoCommand_1.default {
25
+ constructor() {
26
+ super();
27
+ _SpoFolderRoleInheritanceBreakCommand_instances.add(this);
28
+ __classPrivateFieldGet(this, _SpoFolderRoleInheritanceBreakCommand_instances, "m", _SpoFolderRoleInheritanceBreakCommand_initTelemetry).call(this);
29
+ __classPrivateFieldGet(this, _SpoFolderRoleInheritanceBreakCommand_instances, "m", _SpoFolderRoleInheritanceBreakCommand_initOptions).call(this);
30
+ __classPrivateFieldGet(this, _SpoFolderRoleInheritanceBreakCommand_instances, "m", _SpoFolderRoleInheritanceBreakCommand_initValidators).call(this);
31
+ }
32
+ get name() {
33
+ return commands_1.default.FOLDER_ROLEINHERITANCE_BREAK;
34
+ }
35
+ get description() {
36
+ return 'Breaks the role inheritance of a folder. Keeping existing permissions is the default behavior.';
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const keepExistingPermissions = !args.options.clearExistingPermissions;
41
+ const breakFolderRoleInheritance = () => __awaiter(this, void 0, void 0, function* () {
42
+ try {
43
+ const requestOptions = {
44
+ url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl('${formatting_1.formatting.encodeQueryParameter(args.options.folderUrl)}')/ListItemAllFields/breakroleinheritance(${keepExistingPermissions})`,
45
+ headers: {
46
+ accept: 'application/json'
47
+ },
48
+ responseType: 'json'
49
+ };
50
+ yield request_1.default.post(requestOptions);
51
+ }
52
+ catch (err) {
53
+ this.handleRejectedODataJsonPromise(err);
54
+ }
55
+ });
56
+ if (args.options.confirm) {
57
+ yield breakFolderRoleInheritance();
58
+ }
59
+ else {
60
+ const result = yield Cli_1.Cli.prompt({
61
+ type: 'confirm',
62
+ name: 'continue',
63
+ default: false,
64
+ message: `Are you sure you want to break the role inheritance of folder ${args.options.folderUrl} located in site ${args.options.webUrl}?`
65
+ });
66
+ if (result.continue) {
67
+ yield breakFolderRoleInheritance();
68
+ }
69
+ }
70
+ });
71
+ }
72
+ }
73
+ _SpoFolderRoleInheritanceBreakCommand_instances = new WeakSet(), _SpoFolderRoleInheritanceBreakCommand_initTelemetry = function _SpoFolderRoleInheritanceBreakCommand_initTelemetry() {
74
+ this.telemetry.push((args) => {
75
+ Object.assign(this.telemetryProperties, {
76
+ clearExistingPermissions: !!args.options.clearExistingPermissions,
77
+ confirm: !!args.options.confirm
78
+ });
79
+ });
80
+ }, _SpoFolderRoleInheritanceBreakCommand_initOptions = function _SpoFolderRoleInheritanceBreakCommand_initOptions() {
81
+ this.options.unshift({
82
+ option: '-u, --webUrl <webUrl>'
83
+ }, {
84
+ option: '-f, --folderUrl <folderUrl>'
85
+ }, {
86
+ option: '-c, --clearExistingPermissions'
87
+ }, {
88
+ option: '--confirm'
89
+ });
90
+ }, _SpoFolderRoleInheritanceBreakCommand_initValidators = function _SpoFolderRoleInheritanceBreakCommand_initValidators() {
91
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () { return validation_1.validation.isValidSharePointUrl(args.options.webUrl); }));
92
+ };
93
+ module.exports = new SpoFolderRoleInheritanceBreakCommand();
94
+ //# sourceMappingURL=folder-roleinheritance-break.js.map
@@ -41,7 +41,7 @@ class SpoFolderRoleInheritanceResetCommand extends SpoCommand_1.default {
41
41
  const requestOptions = {
42
42
  url: `${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl('${args.options.folderUrl}')/ListItemAllFields/resetroleinheritance`,
43
43
  headers: {
44
- accept: 'application/json;odata.metadata=none'
44
+ accept: 'application/json;odata=nometadata'
45
45
  },
46
46
  responseType: 'json'
47
47
  };
@@ -56,6 +56,7 @@ exports.default = {
56
56
  FILE_MOVE: `${prefix} file move`,
57
57
  FILE_REMOVE: `${prefix} file remove`,
58
58
  FILE_RENAME: `${prefix} file rename`,
59
+ FILE_ROLEASSIGNMENT_ADD: `${prefix} file roleassignment add`,
59
60
  FILE_ROLEASSIGNMENT_REMOVE: `${prefix} file roleassignment remove`,
60
61
  FILE_ROLEINHERITANCE_RESET: `${prefix} file roleinheritance reset`,
61
62
  FILE_SHARINGINFO_GET: `${prefix} file sharinginfo get`,
@@ -66,6 +67,7 @@ exports.default = {
66
67
  FOLDER_MOVE: `${prefix} folder move`,
67
68
  FOLDER_REMOVE: `${prefix} folder remove`,
68
69
  FOLDER_RENAME: `${prefix} folder rename`,
70
+ FOLDER_ROLEINHERITANCE_BREAK: `${prefix} folder roleinheritance break`,
69
71
  FOLDER_ROLEINHERITANCE_RESET: `${prefix} folder roleinheritance reset`,
70
72
  GET: `${prefix} get`,
71
73
  GROUP_ADD: `${prefix} group add`,
@@ -0,0 +1,42 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.powerPlatform = void 0;
13
+ const request_1 = require("../request");
14
+ const powerPlatformResource = 'https://api.bap.microsoft.com';
15
+ exports.powerPlatform = {
16
+ getDynamicsInstanceApiUrl(environment, asAdmin) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ let url = '';
19
+ if (asAdmin) {
20
+ url = `${powerPlatformResource}/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments/${encodeURIComponent(environment)}`;
21
+ }
22
+ else {
23
+ url = `${powerPlatformResource}/providers/Microsoft.BusinessAppPlatform/environments/${encodeURIComponent(environment)}`;
24
+ }
25
+ const requestOptions = {
26
+ url: `${url}?api-version=2020-10-01&$select=properties.linkedEnvironmentMetadata.instanceApiUrl`,
27
+ headers: {
28
+ accept: 'application/json;odata.metadata=none'
29
+ },
30
+ responseType: 'json'
31
+ };
32
+ try {
33
+ const response = yield request_1.default.get(requestOptions);
34
+ return Promise.resolve(response.properties.linkedEnvironmentMetadata.instanceApiUrl);
35
+ }
36
+ catch (ex) {
37
+ throw Error(`The environment '${environment}' could not be retrieved. See the inner exception for more details: ${ex.message}`);
38
+ }
39
+ });
40
+ }
41
+ };
42
+ //# sourceMappingURL=powerPlatform.js.map
@@ -0,0 +1,33 @@
1
+ # pp dataverse table list
2
+
3
+ Lists dataverse tables in a given environment
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ pp dataverse table list [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-e, --environment <environment>`
14
+ The name of the environment to list all tables for
15
+
16
+ `-a, --asAdmin`
17
+ Set, to retrieve the dataverse tables as admin for environments you are not a member of.
18
+
19
+ --8<-- "docs/cmd/_global.md"
20
+
21
+ ## Examples
22
+
23
+ List all tables for the given environment
24
+
25
+ ```sh
26
+ m365 pp dataverse table list -e "Default-2ca3eaa5-140f-4175-8261-3272edf9f339"
27
+ ```
28
+
29
+ List all tables for the given environment as Admin
30
+
31
+ ```sh
32
+ m365 pp dataverse table list -e "Default-2ca3eaa5-140f-4175-8261-3272edf9f339" --asAdmin
33
+ ```
@@ -0,0 +1,33 @@
1
+ # pp solution list
2
+
3
+ Lists solutions in a given environment.
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 pp solution list [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-e, --environment <environment>`
14
+ The name of the environment
15
+
16
+ `-a, --asAdmin`
17
+ Run the command as admin for environments you do not have explicitly assigned permissions to.
18
+
19
+ --8<-- "docs/cmd/_global.md"
20
+
21
+ ## Examples
22
+
23
+ List all solutions in a specific environment
24
+
25
+ ```sh
26
+ m365 pp solution list --environment "Default-2ca3eaa5-140f-4175-8261-3272edf9f339"
27
+ ```
28
+
29
+ List all solutions in a specific environment as Admin
30
+
31
+ ```sh
32
+ m365 pp solution list --environment "Default-2ca3eaa5-140f-4175-8261-3272edf9f339" --asAdmin
33
+ ```
@@ -13,6 +13,9 @@ m365 spfx doctor [options]
13
13
  `-e, --env [env]`
14
14
  : Version of SharePoint for which to check compatibility: `sp2016|sp2019|spo`
15
15
 
16
+ `-v, --spfxVersion [spfxVersion]`
17
+ : Version of the SharePoint Framework Yeoman generator to check compatibility for without `v`, eg. `1.11.0`
18
+
16
19
  `-h, --help`
17
20
  : output usage information
18
21
 
@@ -48,7 +51,7 @@ Next to verifying the readiness of your environment to use a particular version
48
51
 
49
52
  ## Examples
50
53
 
51
- Verify if your environment meets the requirements to work with the SharePoint Framework
54
+ Verify if your environment meets the requirements to work with SharePoint Framework based on the globally installed version of the SharePoint Framework Yeoman generator or the current project
52
55
 
53
56
  ```sh
54
57
  m365 spfx doctor --output text
@@ -59,3 +62,9 @@ Verify if your environment meets the requirements to work with the SharePoint Fr
59
62
  ```sh
60
63
  m365 spfx doctor --env sp2019 --output text
61
64
  ```
65
+
66
+ Verify if your environment meets the requirements to work with SharePoint Framework v1.11.0
67
+
68
+ ```sh
69
+ m365 spfx doctor --spfxVersion 1.11.0 --output text
70
+ ```
@@ -0,0 +1,57 @@
1
+ # spo file roleassignment add
2
+
3
+ Adds a role assignment to the specified file.
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo file roleassignment add [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : URL of the site where the file is located
15
+
16
+ `--fileUrl [fileUrl]`
17
+ : The server-relative URL of the file to retrieve. Specify either `fileUrl` or `fileId` but not both
18
+
19
+ `i, --fileId [fileId]`
20
+ : The UniqueId (GUID) of the file to retrieve. Specify either `fileUrl` or `fileId` but not both
21
+
22
+ `--principalId [principalId]`
23
+ : The SharePoint Id of the principal. It may be either a user id or group id to add a role assignment for. Specify either upn, groupName or principalId.
24
+
25
+ `--upn [upn]`
26
+ : upn/email of user to assign role to. Specify either upn, groupName or principalId.
27
+
28
+ `--groupName [groupName]`
29
+ : The group name of Azure AD or SharePoint group. Specify either upn, groupName or principalId.
30
+
31
+ `--roleDefinitionId [roleDefinitionId]`
32
+ : ID of role definition. Specify either roleDefinitionId or roleDefinitionName but not both
33
+
34
+ `--roleDefinitionName [roleDefinitionName]`
35
+ : Enter the name of a role definition, like 'Contribute', 'Read', etc. Specify either roleDefinitionId or roleDefinitionName but not both
36
+
37
+ --8<-- "docs/cmd/_global.md"
38
+
39
+ ## Examples
40
+
41
+ Adds a role assignment to a file with a specified id. It will use a principal id and a specific role definition id.
42
+
43
+ ```sh
44
+ m365 spo file roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --fileId "b2307a39-e878-458b-bc90-03bc578531d6" --principalId 11 --roleDefinitionId 1073741829
45
+ ```
46
+
47
+ Adds a role assignment to a file with a specified site-relative URL for a specific upn and a role definition name.
48
+
49
+ ```sh
50
+ m365 spo file roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --fileUrl "Shared Documents/Test1.docx" --upn "testuser@tenant.onmicrosoft.com" --roleDefinitionName "Full Control"
51
+ ```
52
+
53
+ Adds a role assignment to a file with a specified server-relative URL the for a specific group and a role definition name.
54
+
55
+ ```sh
56
+ m365 spo file roleassignment add --webUrl "https://contoso.sharepoint.com/sites/project-x" --fileUrl "/sites/project-x/documents/Test1.docx" --upn "testuser@tenant.onmicrosoft.com" --roleDefinitionName "Read"
57
+ ```
@@ -0,0 +1,39 @@
1
+ # spo folder roleinheritance break
2
+
3
+ Breaks the role inheritance of a folder.
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo folder roleinheritance break [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : URL of the site where the folder is located.
15
+
16
+ `-f, --folderUrl <folderUrl>`
17
+ : The site-relative URL or server-relative URL of the folder.
18
+
19
+ `-c, --clearExistingPermissions`
20
+ : Clear all existing permissions from the folder.
21
+
22
+ `--confirm`
23
+ : Don't prompt for confirmation to breaking role inheritance of the folder.
24
+
25
+ --8<-- "docs/cmd/_global.md"
26
+
27
+ ## Examples
28
+
29
+ Break the inheritance of a folder with a specified site-relative URL.
30
+
31
+ ```sh
32
+ m365 spo folder roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/project-x" --folderUrl "Shared Documents/TestFolder"
33
+ ```
34
+
35
+ Break the inheritance of a folder with a specified server-relative URL. It will clear the existing permissions of the folder. It will **not** prompt for confirmation before breaking the inheritance.
36
+
37
+ ```sh
38
+ m365 spo folder roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/project-x" --folderUrl "/sites/project-x/Shared Documents/TestFolder" --clearExistingPermissions --confirm
39
+ ```
@@ -29,8 +29,8 @@ Reset inheritance of folder with site-relative url _Shared Documents/TestFolder_
29
29
  m365 spo folder roleinheritance reset --webUrl "https://contoso.sharepoint.com/sites/project-x" --folderUrl "Shared Documents/TestFolder"
30
30
  ```
31
31
 
32
- Reset inheritance of folder with site-relative url _Shared Documents/TestFolder_ located in site _https://contoso.sharepoint.com/sites/project-x_. It will **not** prompt for confirmation before resetting.
32
+ Reset inheritance of folder with server-relative url _/sites/project-x/Shared Documents/TestFolder_ located in site _https://contoso.sharepoint.com/sites/project-x_. It will **not** prompt for confirmation before resetting.
33
33
 
34
34
  ```sh
35
- m365 spo folder roleinheritance reset --webUrl "https://contoso.sharepoint.com/sites/project-x" --folderUrl "Shared Documents/TestFolder" --confirm
35
+ m365 spo folder roleinheritance reset --webUrl "https://contoso.sharepoint.com/sites/project-x" --folderUrl "/sites/project-x/Shared Documents/TestFolder" --confirm
36
36
  ```
@@ -1,6 +1,6 @@
1
1
  # spo hubsite disconnect
2
2
 
3
- Disconnects the specifies site collection from its hub site
3
+ Disconnects the specified site collection from its hub site
4
4
 
5
5
  ## Usage
6
6
 
@@ -11,13 +11,13 @@ m365 spo hubsite get [options]
11
11
  ## Options
12
12
 
13
13
  `-i, --id [id]`
14
- : ID of the hubsite. Specify either `id`, `title` or `url` but not multiple.
14
+ : ID of the hub site. Specify either `id`, `title` or `url` but not multiple.
15
15
 
16
16
  `-t, --title [title]`
17
- : Title of the hubsite. Specify either `id`, `title` or `url` but not multiple.
17
+ : Title of the hub site. Specify either `id`, `title` or `url` but not multiple.
18
18
 
19
19
  `-u, --url [url]`
20
- : URL of the hubsite. Specify either `id`, `title` or `url` but not multiple.
20
+ : URL of the hub site. Specify either `id`, `title` or `url` but not multiple.
21
21
 
22
22
  `--includeAssociatedSites`
23
23
  : Include the associated sites in the result (only in JSON output)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "5.9.0-beta.3de06bc",
3
+ "version": "5.9.0-beta.3f2d5b9",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",
@@ -1,60 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FN006006_CFG_PS_features = void 0;
4
- const uuid_1 = require("uuid");
5
- const JsonRule_1 = require("../../JsonRule");
6
- class FN006006_CFG_PS_features extends JsonRule_1.JsonRule {
7
- constructor() {
8
- super();
9
- }
10
- get id() {
11
- return 'FN006006';
12
- }
13
- get title() {
14
- return 'package-solution.json features';
15
- }
16
- get description() {
17
- return `In package-solution.json add features section`;
18
- }
19
- get resolution() {
20
- return '';
21
- }
22
- get resolutionType() {
23
- return 'json';
24
- }
25
- get severity() {
26
- return 'Required';
27
- }
28
- get file() {
29
- return './config/package-solution.json';
30
- }
31
- visit(project, findings) {
32
- var _a, _b;
33
- if (!project.packageSolutionJson ||
34
- !project.packageSolutionJson.solution) {
35
- return;
36
- }
37
- if (!project.packageSolutionJson.solution.features) {
38
- const resolution = {
39
- solution: {
40
- features: [
41
- {
42
- title: `${(_a = project.packageJson) === null || _a === void 0 ? void 0 : _a.name} Feature`,
43
- description: `The feature that activates elements of the ${(_b = project.packageJson) === null || _b === void 0 ? void 0 : _b.name} solution.`,
44
- id: (0, uuid_1.v4)(),
45
- version: project.packageSolutionJson.solution.version
46
- }
47
- ]
48
- }
49
- };
50
- const node = this.getAstNodeFromFile(project.packageSolutionJson, 'solution');
51
- this.addFindingWithOccurrences([{
52
- file: this.file,
53
- resolution: JSON.stringify(resolution, null, 2),
54
- position: this.getPositionFromNode(node)
55
- }], findings);
56
- }
57
- }
58
- }
59
- exports.FN006006_CFG_PS_features = FN006006_CFG_PS_features;
60
- //# sourceMappingURL=FN006006_CFG_PS_features.js.map