@pnp/cli-microsoft365 6.1.0-beta.3e0114a → 6.1.0-beta.539ef23

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 (93) hide show
  1. package/dist/m365/aad/commands/group/group-get.js +79 -0
  2. package/dist/m365/aad/commands/user/user-set.js +84 -11
  3. package/dist/m365/aad/commands.js +1 -0
  4. package/dist/m365/base/ContextCommand.js +33 -0
  5. package/dist/m365/context/commands/context-init.js +28 -0
  6. package/dist/m365/context/commands/context-remove.js +103 -0
  7. package/dist/m365/context/commands.js +8 -0
  8. package/dist/m365/pp/commands/dataverse/dataverse-table-row-remove.js +133 -0
  9. package/dist/m365/pp/commands/environment/environment-get.js +5 -13
  10. package/dist/m365/pp/commands.js +1 -0
  11. package/dist/m365/purview/commands/retentionlabel/retentionlabel-set.js +142 -0
  12. package/dist/m365/purview/commands.js +2 -1
  13. package/dist/m365/search/commands/externalconnection/externalconnection-schema-add.js +86 -0
  14. package/dist/m365/search/commands.js +2 -1
  15. package/dist/m365/spo/commands/group/group-member-add.js +68 -30
  16. package/dist/m365/spo/commands/group/group-member-remove.js +50 -7
  17. package/dist/m365/spo/commands/list/{list-label-set.js → list-retentionlabel-ensure.js} +25 -15
  18. package/dist/m365/spo/commands/list/{list-label-get.js → list-retentionlabel-get.js} +19 -15
  19. package/dist/m365/spo/commands/listitem/listitem-remove.js +1 -1
  20. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-remove.js +143 -0
  21. package/dist/m365/spo/commands/page/page-add.js +60 -63
  22. package/dist/m365/spo/commands/page/page-set.js +59 -70
  23. package/dist/m365/spo/commands/site/site-appcatalog-list.js +43 -0
  24. package/dist/m365/spo/commands/web/web-retentionlabel-list.js +63 -0
  25. package/dist/m365/spo/commands.js +5 -0
  26. package/dist/request.js +2 -1
  27. package/dist/utils/pid.js +31 -15
  28. package/docs/docs/cmd/aad/group/group-get.md +127 -0
  29. package/docs/docs/cmd/aad/user/user-set.md +31 -3
  30. package/docs/docs/cmd/context/context-init.md +25 -0
  31. package/docs/docs/cmd/context/context-remove.md +34 -0
  32. package/docs/docs/cmd/pp/dataverse/dataverse-table-row-remove.md +61 -0
  33. package/docs/docs/cmd/pp/environment/environment-get.md +9 -3
  34. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.md +63 -0
  35. package/docs/docs/cmd/search/externalconnection/externalconnection-schema-add.md +31 -0
  36. package/docs/docs/cmd/spo/group/group-member-add.md +58 -6
  37. package/docs/docs/cmd/spo/group/group-member-remove.md +24 -8
  38. package/docs/docs/cmd/spo/list/list-retentionlabel-ensure.md +65 -0
  39. package/docs/docs/cmd/spo/list/{list-label-get.md → list-retentionlabel-get.md} +17 -11
  40. package/docs/docs/cmd/spo/listitem/listitem-remove.md +6 -6
  41. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-remove.md +55 -0
  42. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-add.md +9 -5
  43. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-list.md +42 -0
  44. package/docs/docs/cmd/spo/orgassetslibrary/orgassetslibrary-remove.md +25 -3
  45. package/docs/docs/cmd/spo/orgnewssite/orgnewssite-list.md +22 -0
  46. package/docs/docs/cmd/spo/orgnewssite/orgnewssite-remove.md +6 -2
  47. package/docs/docs/cmd/spo/orgnewssite/orgnewssite-set.md +5 -1
  48. package/docs/docs/cmd/spo/page/page-add.md +13 -9
  49. package/docs/docs/cmd/spo/page/page-clientsidewebpart-add.md +6 -2
  50. package/docs/docs/cmd/spo/page/page-column-get.md +68 -5
  51. package/docs/docs/cmd/spo/page/page-column-list.md +36 -4
  52. package/docs/docs/cmd/spo/page/page-control-get.md +70 -3
  53. package/docs/docs/cmd/spo/page/page-control-list.md +69 -3
  54. package/docs/docs/cmd/spo/page/page-control-set.md +11 -7
  55. package/docs/docs/cmd/spo/page/page-copy.md +65 -4
  56. package/docs/docs/cmd/spo/page/page-get.md +100 -4
  57. package/docs/docs/cmd/spo/page/page-header-set.md +17 -13
  58. package/docs/docs/cmd/spo/page/page-list.md +122 -1
  59. package/docs/docs/cmd/spo/page/page-remove.md +9 -5
  60. package/docs/docs/cmd/spo/page/page-section-add.md +10 -6
  61. package/docs/docs/cmd/spo/page/page-section-get.md +36 -4
  62. package/docs/docs/cmd/spo/page/page-section-list.md +38 -3
  63. package/docs/docs/cmd/spo/page/page-set.md +10 -10
  64. package/docs/docs/cmd/spo/page/page-template-list.md +58 -1
  65. package/docs/docs/cmd/spo/page/page-text-add.md +9 -5
  66. package/docs/docs/cmd/spo/propertybag/propertybag-get.md +28 -8
  67. package/docs/docs/cmd/spo/propertybag/propertybag-list.md +35 -7
  68. package/docs/docs/cmd/spo/propertybag/propertybag-remove.md +13 -9
  69. package/docs/docs/cmd/spo/propertybag/propertybag-set.md +13 -5
  70. package/docs/docs/cmd/spo/report/report-activityfilecounts.md +34 -2
  71. package/docs/docs/cmd/spo/report/report-activitypages.md +31 -2
  72. package/docs/docs/cmd/spo/report/report-activityusercounts.md +35 -2
  73. package/docs/docs/cmd/spo/report/report-activityuserdetail.md +40 -3
  74. package/docs/docs/cmd/spo/report/report-siteusagedetail.md +43 -3
  75. package/docs/docs/cmd/spo/report/report-siteusagefilecounts.md +33 -2
  76. package/docs/docs/cmd/spo/report/report-siteusagepages.md +32 -2
  77. package/docs/docs/cmd/spo/report/report-siteusagesitecounts.md +33 -2
  78. package/docs/docs/cmd/spo/report/report-siteusagestorage.md +32 -2
  79. package/docs/docs/cmd/spo/roledefinition/roledefinition-add.md +10 -6
  80. package/docs/docs/cmd/spo/roledefinition/roledefinition-get.md +80 -2
  81. package/docs/docs/cmd/spo/roledefinition/roledefinition-list.md +76 -2
  82. package/docs/docs/cmd/spo/roledefinition/roledefinition-remove.md +9 -5
  83. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-add.md +39 -2
  84. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-list.md +32 -0
  85. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-grant-revoke.md +6 -2
  86. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-permissionrequest-approve.md +14 -74
  87. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-permissionrequest-deny.md +6 -2
  88. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-permissionrequest-list.md +30 -0
  89. package/docs/docs/cmd/spo/serviceprincipal/serviceprincipal-set.md +36 -2
  90. package/docs/docs/cmd/spo/site/site-appcatalog-list.md +55 -0
  91. package/docs/docs/cmd/spo/web/web-retentionlabel-list.md +74 -0
  92. package/package.json +1 -1
  93. package/docs/docs/cmd/spo/list/list-label-set.md +0 -55
@@ -0,0 +1,142 @@
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 _PurviewRetentionLabelSetCommand_instances, _PurviewRetentionLabelSetCommand_initTelemetry, _PurviewRetentionLabelSetCommand_initOptions, _PurviewRetentionLabelSetCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const validation_1 = require("../../../../utils/validation");
19
+ const request_1 = require("../../../../request");
20
+ const GraphCommand_1 = require("../../../base/GraphCommand");
21
+ const commands_1 = require("../../commands");
22
+ class PurviewRetentionLabelSetCommand extends GraphCommand_1.default {
23
+ get name() {
24
+ return commands_1.default.RETENTIONLABEL_SET;
25
+ }
26
+ get description() {
27
+ return 'Update a retention label';
28
+ }
29
+ constructor() {
30
+ super();
31
+ _PurviewRetentionLabelSetCommand_instances.add(this);
32
+ this.allowedBehaviorDuringRetentionPeriodValues = ['doNotRetain', 'retain', 'retainAsRecord', 'retainAsRegulatoryRecord'];
33
+ this.allowedActionAfterRetentionPeriodValues = ['none', 'delete', 'startDispositionReview'];
34
+ this.allowedRetentionTriggerValues = ['dateLabeled', 'dateCreated', 'dateModified', 'dateOfEvent'];
35
+ this.allowedDefaultRecordBehaviorValues = ['startLocked', 'startUnlocked'];
36
+ __classPrivateFieldGet(this, _PurviewRetentionLabelSetCommand_instances, "m", _PurviewRetentionLabelSetCommand_initTelemetry).call(this);
37
+ __classPrivateFieldGet(this, _PurviewRetentionLabelSetCommand_instances, "m", _PurviewRetentionLabelSetCommand_initOptions).call(this);
38
+ __classPrivateFieldGet(this, _PurviewRetentionLabelSetCommand_instances, "m", _PurviewRetentionLabelSetCommand_initValidators).call(this);
39
+ }
40
+ commandAction(logger, args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ if (this.verbose) {
43
+ logger.log(`Starting to update retention label with id ${args.options.id}`);
44
+ }
45
+ const requestBody = this.mapRequestBody(args.options);
46
+ const requestOptions = {
47
+ url: `${this.resource}/beta/security/labels/retentionLabels/${args.options.id}`,
48
+ headers: {
49
+ accept: 'application/json'
50
+ },
51
+ responseType: 'json',
52
+ data: requestBody
53
+ };
54
+ yield request_1.default.patch(requestOptions);
55
+ });
56
+ }
57
+ mapRequestBody(options) {
58
+ const requestBody = {};
59
+ const excludeOptions = [
60
+ 'debug',
61
+ 'verbose',
62
+ 'output',
63
+ 'id',
64
+ 'retentionDuration'
65
+ ];
66
+ Object.keys(options).forEach(key => {
67
+ if (excludeOptions.indexOf(key) === -1) {
68
+ requestBody[key] = `${options[key]}`;
69
+ }
70
+ });
71
+ if (options.retentionDuration) {
72
+ requestBody['retentionDuration'] = {
73
+ '@odata.type': 'microsoft.graph.security.retentionDurationInDays',
74
+ 'days': options.retentionDuration
75
+ };
76
+ }
77
+ return requestBody;
78
+ }
79
+ }
80
+ _PurviewRetentionLabelSetCommand_instances = new WeakSet(), _PurviewRetentionLabelSetCommand_initTelemetry = function _PurviewRetentionLabelSetCommand_initTelemetry() {
81
+ this.telemetry.push((args) => {
82
+ Object.assign(this.telemetryProperties, {
83
+ behaviorDuringRetentionPeriod: typeof args.options.behaviorDuringRetentionPeriod !== 'undefined',
84
+ actionAfterRetentionPeriod: typeof args.options.actionAfterRetentionPeriod !== 'undefined',
85
+ retentionDuration: typeof args.options.retentionDuration !== 'undefined',
86
+ retentionTrigger: typeof args.options.retentionTrigger !== 'undefined',
87
+ defaultRecordBehavior: typeof args.options.defaultRecordBehavior !== 'undefined',
88
+ descriptionForUsers: typeof args.options.descriptionForUsers !== 'undefined',
89
+ descriptionForAdmins: typeof args.options.descriptionForAdmins !== 'undefined',
90
+ labelToBeApplied: typeof args.options.labelToBeApplied !== 'undefined'
91
+ });
92
+ });
93
+ }, _PurviewRetentionLabelSetCommand_initOptions = function _PurviewRetentionLabelSetCommand_initOptions() {
94
+ this.options.unshift({
95
+ option: '-i, --id <id>'
96
+ }, {
97
+ option: '--behaviorDuringRetentionPeriod [behaviorDuringRetentionPeriod]',
98
+ autocomplete: this.allowedBehaviorDuringRetentionPeriodValues
99
+ }, {
100
+ option: '--actionAfterRetentionPeriod [actionAfterRetentionPeriod]',
101
+ autocomplete: this.allowedActionAfterRetentionPeriodValues
102
+ }, {
103
+ option: '--retentionDuration [retentionDuration]'
104
+ }, {
105
+ option: '-t, --retentionTrigger [retentionTrigger]',
106
+ autocomplete: this.allowedRetentionTriggerValues
107
+ }, {
108
+ option: '--defaultRecordBehavior [defaultRecordBehavior]',
109
+ autocomplete: this.allowedDefaultRecordBehaviorValues
110
+ }, {
111
+ option: '--descriptionForUsers [descriptionForUsers]'
112
+ }, {
113
+ option: '--descriptionForAdmins [descriptionForAdmins]'
114
+ }, {
115
+ option: '--labelToBeApplied [labelToBeApplied]'
116
+ });
117
+ }, _PurviewRetentionLabelSetCommand_initValidators = function _PurviewRetentionLabelSetCommand_initValidators() {
118
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
119
+ if (!validation_1.validation.isValidGuid(args.options.id)) {
120
+ return `'${args.options.id}' is not a valid GUID.`;
121
+ }
122
+ const { actionAfterRetentionPeriod, behaviorDuringRetentionPeriod, defaultRecordBehavior, descriptionForAdmins, descriptionForUsers, labelToBeApplied, retentionDuration, retentionTrigger } = args.options;
123
+ if ([actionAfterRetentionPeriod, behaviorDuringRetentionPeriod, defaultRecordBehavior, descriptionForAdmins, descriptionForUsers, labelToBeApplied, retentionDuration, retentionTrigger].every(i => typeof i === 'undefined')) {
124
+ return `Specify at least one property to update.`;
125
+ }
126
+ if (behaviorDuringRetentionPeriod && this.allowedBehaviorDuringRetentionPeriodValues.indexOf(behaviorDuringRetentionPeriod) === -1) {
127
+ return `'${behaviorDuringRetentionPeriod}' is not a valid value for the behaviorDuringRetentionPeriod option. Allowed values are ${this.allowedBehaviorDuringRetentionPeriodValues.join('|')}`;
128
+ }
129
+ if (actionAfterRetentionPeriod && this.allowedActionAfterRetentionPeriodValues.indexOf(actionAfterRetentionPeriod) === -1) {
130
+ return `'${actionAfterRetentionPeriod}' is not a valid value for the actionAfterRetentionPeriod option. Allowed values are ${this.allowedActionAfterRetentionPeriodValues.join('|')}`;
131
+ }
132
+ if (retentionTrigger && this.allowedRetentionTriggerValues.indexOf(retentionTrigger) === -1) {
133
+ return `'${retentionTrigger}' is not a valid value for the retentionTrigger option. Allowed values are ${this.allowedRetentionTriggerValues.join('|')}`;
134
+ }
135
+ if (defaultRecordBehavior && this.allowedDefaultRecordBehaviorValues.indexOf(defaultRecordBehavior) === -1) {
136
+ return `'${defaultRecordBehavior}' is not a valid value for the defaultRecordBehavior option. Allowed values are ${this.allowedDefaultRecordBehaviorValues.join('|')}`;
137
+ }
138
+ return true;
139
+ }));
140
+ };
141
+ module.exports = new PurviewRetentionLabelSetCommand();
142
+ //# sourceMappingURL=retentionlabel-set.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'purview';
4
4
  exports.default = {
5
5
  RETENTIONLABEL_LIST: `${prefix} retentionlabel list`,
6
- RETENTIONLABEL_REMOVE: `${prefix} retentionlabel remove`
6
+ RETENTIONLABEL_REMOVE: `${prefix} retentionlabel remove`,
7
+ RETENTIONLABEL_SET: `${prefix} retentionlabel set`
7
8
  };
8
9
  //# sourceMappingURL=commands.js.map
@@ -0,0 +1,86 @@
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 _SearchExternalConnectionSchemaAddCommand_instances, _SearchExternalConnectionSchemaAddCommand_initOptions, _SearchExternalConnectionSchemaAddCommand_initValidators;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const GraphCommand_1 = require("../../../base/GraphCommand");
20
+ const commands_1 = require("../../commands");
21
+ class SearchExternalConnectionSchemaAddCommand extends GraphCommand_1.default {
22
+ get name() {
23
+ return commands_1.default.EXTERNALCONNECTION_SCHEMA_ADD;
24
+ }
25
+ get description() {
26
+ return 'This command allows the administrator to add a schema to a specific external connection for use in Microsoft Search.';
27
+ }
28
+ constructor() {
29
+ super();
30
+ _SearchExternalConnectionSchemaAddCommand_instances.add(this);
31
+ __classPrivateFieldGet(this, _SearchExternalConnectionSchemaAddCommand_instances, "m", _SearchExternalConnectionSchemaAddCommand_initOptions).call(this);
32
+ __classPrivateFieldGet(this, _SearchExternalConnectionSchemaAddCommand_instances, "m", _SearchExternalConnectionSchemaAddCommand_initValidators).call(this);
33
+ }
34
+ commandAction(logger, args) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ if (this.verbose) {
37
+ logger.logToStderr(`Adding schema to external connection with id ${args.options.externalConnectionId}`);
38
+ }
39
+ const requestOptions = {
40
+ url: `${this.resource}/v1.0/external/connections/${args.options.externalConnectionId}/schema`,
41
+ headers: {
42
+ accept: 'application/json;odata.metadata=none'
43
+ },
44
+ responseType: 'json',
45
+ data: args.options.schema
46
+ };
47
+ try {
48
+ yield request_1.default.post(requestOptions);
49
+ }
50
+ catch (err) {
51
+ this.handleRejectedODataJsonPromise(err);
52
+ }
53
+ });
54
+ }
55
+ }
56
+ _SearchExternalConnectionSchemaAddCommand_instances = new WeakSet(), _SearchExternalConnectionSchemaAddCommand_initOptions = function _SearchExternalConnectionSchemaAddCommand_initOptions() {
57
+ this.options.unshift({
58
+ option: '-i, --externalConnectionId <externalConnectionId>'
59
+ }, {
60
+ option: '-s, --schema <schema>'
61
+ });
62
+ }, _SearchExternalConnectionSchemaAddCommand_initValidators = function _SearchExternalConnectionSchemaAddCommand_initValidators() {
63
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
64
+ if (args.options.externalConnectionId.length < 3 || args.options.externalConnectionId.length > 32) {
65
+ return 'externalConnectionId must be between 3 and 32 characters in length.';
66
+ }
67
+ const alphaNumericRegEx = /[^\w]|_/g;
68
+ if (alphaNumericRegEx.test(args.options.externalConnectionId)) {
69
+ return 'externalConnectionId must only contain alphanumeric characters.';
70
+ }
71
+ if (args.options.externalConnectionId.length > 9 &&
72
+ args.options.externalConnectionId.startsWith('Microsoft')) {
73
+ return 'ID cannot begin with Microsoft';
74
+ }
75
+ const schemaObject = JSON.parse(args.options.schema);
76
+ if (schemaObject.baseType === undefined || schemaObject.baseType !== 'microsoft.graph.externalItem') {
77
+ return `The schema needs a required property 'baseType' with value 'microsoft.graph.externalItem'`;
78
+ }
79
+ if (!schemaObject.properties || schemaObject.properties.length > 128) {
80
+ return `We need atleast one property and a maximum of 128 properties in the schema object`;
81
+ }
82
+ return true;
83
+ }));
84
+ };
85
+ module.exports = new SearchExternalConnectionSchemaAddCommand();
86
+ //# sourceMappingURL=externalconnection-schema-add.js.map
@@ -5,6 +5,7 @@ exports.default = {
5
5
  EXTERNALCONNECTION_ADD: `${prefix} externalconnection add`,
6
6
  EXTERNALCONNECTION_GET: `${prefix} externalconnection get`,
7
7
  EXTERNALCONNECTION_LIST: `${prefix} externalconnection list`,
8
- EXTERNALCONNECTION_REMOVE: `${prefix} externalconnection remove`
8
+ EXTERNALCONNECTION_REMOVE: `${prefix} externalconnection remove`,
9
+ EXTERNALCONNECTION_SCHEMA_ADD: `${prefix} externalconnection schema add`
9
10
  };
10
11
  //# sourceMappingURL=commands.js.map
@@ -20,6 +20,7 @@ const request_1 = require("../../../../request");
20
20
  const formatting_1 = require("../../../../utils/formatting");
21
21
  const validation_1 = require("../../../../utils/validation");
22
22
  const AadUserGetCommand = require("../../../aad/commands/user/user-get");
23
+ const SpoUserGetCommand = require("../user/user-get");
23
24
  const SpoCommand_1 = require("../../../base/SpoCommand");
24
25
  const commands_1 = require("../../commands");
25
26
  class SpoGroupMemberAddCommand extends SpoCommand_1.default {
@@ -43,10 +44,10 @@ class SpoGroupMemberAddCommand extends SpoCommand_1.default {
43
44
  commandAction(logger, args) {
44
45
  return __awaiter(this, void 0, void 0, function* () {
45
46
  try {
46
- const groupId = yield this.getGroupId(args);
47
+ const groupId = yield this.getGroupId(args, logger);
47
48
  const resolvedUsernameList = yield this.getValidUsers(args, logger);
48
49
  if (this.verbose) {
49
- logger.logToStderr(`Start adding Active user/s to SharePoint Group ${args.options.groupId ? args.options.groupId : args.options.groupName}`);
50
+ logger.logToStderr(`Adding user(s) to SharePoint Group ${args.options.groupId ? args.options.groupId : args.options.groupName}`);
50
51
  }
51
52
  const data = {
52
53
  url: args.options.webUrl,
@@ -73,7 +74,10 @@ class SpoGroupMemberAddCommand extends SpoCommand_1.default {
73
74
  }
74
75
  });
75
76
  }
76
- getGroupId(args) {
77
+ getGroupId(args, logger) {
78
+ if (this.verbose) {
79
+ logger.logToStderr(`Getting group Id for SharePoint Group ${args.options.groupId ? args.options.groupId : args.options.groupName}`);
80
+ }
77
81
  const getGroupMethod = args.options.groupName ?
78
82
  `GetByName('${formatting_1.formatting.encodeQueryParameter(args.options.groupName)}')` :
79
83
  `GetById('${args.options.groupId}')`;
@@ -100,34 +104,23 @@ class SpoGroupMemberAddCommand extends SpoCommand_1.default {
100
104
  }
101
105
  const validUserNames = [];
102
106
  const invalidUserNames = [];
103
- const userInfo = args.options.userName ? args.options.userName : args.options.email;
107
+ const userIdentifiers = args.options.userName || args.options.email || args.options.userId.toString();
104
108
  return Promise
105
- .all(userInfo.split(',').map(singleUserName => {
106
- const options = {
107
- output: 'json',
108
- debug: args.options.debug,
109
- verbose: args.options.verbose
110
- };
111
- if (args.options.userName) {
112
- options.userName = singleUserName.trim();
113
- }
114
- else {
115
- options.email = singleUserName.trim();
116
- }
117
- return Cli_1.Cli
118
- .executeCommandWithOutput(AadUserGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) })
119
- .then((getUserGetOutput) => {
120
- if (this.debug) {
121
- logger.logToStderr(getUserGetOutput.stderr);
109
+ .all(userIdentifiers.split(',').map((userIdentifier) => __awaiter(this, void 0, void 0, function* () {
110
+ try {
111
+ if (args.options.userId) {
112
+ yield this.spoUserGet(args.options, userIdentifier.trim(), logger, validUserNames);
122
113
  }
123
- validUserNames.push(JSON.parse(getUserGetOutput.stdout).userPrincipalName);
124
- }, (err) => {
125
- if (this.debug) {
126
- logger.logToStderr(err.stderr);
114
+ else {
115
+ yield this.aadUserGet(args.options, userIdentifier.trim(), logger, validUserNames);
127
116
  }
128
- invalidUserNames.push(singleUserName);
129
- });
130
- }))
117
+ }
118
+ catch (err) {
119
+ logger.logToStderr(err.stderr);
120
+ invalidUserNames.push(userIdentifier);
121
+ return err;
122
+ }
123
+ })))
131
124
  .then(() => {
132
125
  if (invalidUserNames.length > 0) {
133
126
  return Promise.reject(`Users not added to the group because the following users don't exist: ${invalidUserNames.join(', ')}`);
@@ -135,6 +128,38 @@ class SpoGroupMemberAddCommand extends SpoCommand_1.default {
135
128
  return Promise.resolve(validUserNames);
136
129
  });
137
130
  }
131
+ aadUserGet(options, userIdentifier, logger, validUserNames) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ if (this.verbose) {
134
+ logger.logToStderr(`Get UPN from Azure AD for user ${userIdentifier}`);
135
+ }
136
+ const aadUserGetCommandoptions = Object.assign(Object.assign(Object.assign({}, (options.userName && { userName: userIdentifier })), (options.email && { email: userIdentifier })), { output: 'json', debug: options.debug, verbose: options.verbose });
137
+ const aadUserGetOutput = yield Cli_1.Cli.executeCommandWithOutput(AadUserGetCommand, { options: Object.assign(Object.assign({}, aadUserGetCommandoptions), { _: [] }) });
138
+ if (this.debug) {
139
+ logger.logToStderr(aadUserGetOutput.stderr);
140
+ }
141
+ validUserNames.push(JSON.parse(aadUserGetOutput.stdout).userPrincipalName);
142
+ });
143
+ }
144
+ spoUserGet(options, userIdentifier, logger, validUserNames) {
145
+ return __awaiter(this, void 0, void 0, function* () {
146
+ if (this.verbose) {
147
+ logger.logToStderr(`Get UPN from SharePoint for user ${userIdentifier}`);
148
+ }
149
+ const spoUserGetCommandoptions = {
150
+ id: userIdentifier,
151
+ webUrl: options.webUrl,
152
+ output: 'json',
153
+ debug: options.debug,
154
+ verbose: options.verbose
155
+ };
156
+ const spoUserGetOutput = yield Cli_1.Cli.executeCommandWithOutput(SpoUserGetCommand, { options: Object.assign(Object.assign({}, spoUserGetCommandoptions), { _: [] }) });
157
+ if (this.debug) {
158
+ logger.logToStderr(spoUserGetOutput.stderr);
159
+ }
160
+ validUserNames.push(JSON.parse(spoUserGetOutput.stdout).UserPrincipalName);
161
+ });
162
+ }
138
163
  getFormattedUserList(activeUserList) {
139
164
  const generatedPeoplePicker = JSON.stringify(activeUserList.map(singleUsername => {
140
165
  return { Key: singleUsername.trim() };
@@ -148,7 +173,8 @@ _SpoGroupMemberAddCommand_instances = new WeakSet(), _SpoGroupMemberAddCommand_i
148
173
  groupId: typeof args.options.groupId !== 'undefined',
149
174
  groupName: typeof args.options.groupName !== 'undefined',
150
175
  userName: typeof args.options.userName !== 'undefined',
151
- email: typeof args.options.email !== 'undefined'
176
+ email: typeof args.options.email !== 'undefined',
177
+ userId: typeof args.options.userId !== 'undefined'
152
178
  });
153
179
  });
154
180
  }, _SpoGroupMemberAddCommand_initOptions = function _SpoGroupMemberAddCommand_initOptions() {
@@ -162,6 +188,8 @@ _SpoGroupMemberAddCommand_instances = new WeakSet(), _SpoGroupMemberAddCommand_i
162
188
  option: '--userName [userName]'
163
189
  }, {
164
190
  option: '--email [email]'
191
+ }, {
192
+ option: '--userId [userId]'
165
193
  });
166
194
  }, _SpoGroupMemberAddCommand_initValidators = function _SpoGroupMemberAddCommand_initValidators() {
167
195
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
@@ -172,10 +200,20 @@ _SpoGroupMemberAddCommand_instances = new WeakSet(), _SpoGroupMemberAddCommand_i
172
200
  if (args.options.groupId && isNaN(args.options.groupId)) {
173
201
  return `Specified groupId ${args.options.groupId} is not a number`;
174
202
  }
203
+ const userIdReg = new RegExp(/^[0-9,]*$/);
204
+ if (args.options.userId && !userIdReg.test(args.options.userId)) {
205
+ return `${args.options.userId} is not a number or a comma seperated value`;
206
+ }
207
+ if (args.options.userName && args.options.userName.split(',').some(e => !validation_1.validation.isValidUserPrincipalName(e))) {
208
+ return `${args.options.userName} contains one or more invalid usernames`;
209
+ }
210
+ if (args.options.email && args.options.email.split(',').some(e => !validation_1.validation.isValidUserPrincipalName(e))) {
211
+ return `${args.options.email} contains one or more invalid email addresses`;
212
+ }
175
213
  return true;
176
214
  }));
177
215
  }, _SpoGroupMemberAddCommand_initOptionSets = function _SpoGroupMemberAddCommand_initOptionSets() {
178
- this.optionSets.push({ options: ['groupId', 'groupName'] }, { options: ['userName', 'email'] });
216
+ this.optionSets.push({ options: ['groupId', 'groupName'] }, { options: ['userName', 'email', 'userId'] });
179
217
  };
180
218
  module.exports = new SpoGroupMemberAddCommand();
181
219
  //# sourceMappingURL=group-member-add.js.map
@@ -19,6 +19,7 @@ const Cli_1 = require("../../../../cli/Cli");
19
19
  const request_1 = require("../../../../request");
20
20
  const formatting_1 = require("../../../../utils/formatting");
21
21
  const validation_1 = require("../../../../utils/validation");
22
+ const AadUserGetCommand = require("../../../aad/commands/user/user-get");
22
23
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
24
  const commands_1 = require("../../commands");
24
25
  class SpoGroupMemberRemoveCommand extends SpoCommand_1.default {
@@ -36,16 +37,42 @@ class SpoGroupMemberRemoveCommand extends SpoCommand_1.default {
36
37
  __classPrivateFieldGet(this, _SpoGroupMemberRemoveCommand_instances, "m", _SpoGroupMemberRemoveCommand_initValidators).call(this);
37
38
  __classPrivateFieldGet(this, _SpoGroupMemberRemoveCommand_instances, "m", _SpoGroupMemberRemoveCommand_initOptionSets).call(this);
38
39
  }
40
+ getUserName(logger, args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ if (args.options.userName) {
43
+ return args.options.userName;
44
+ }
45
+ if (this.verbose) {
46
+ logger.logToStderr(`Retrieving information about the user ${args.options.email}`);
47
+ }
48
+ const options = {
49
+ email: args.options.email,
50
+ output: 'json',
51
+ debug: args.options.debug,
52
+ verbose: args.options.verbose
53
+ };
54
+ const userGetOutput = yield Cli_1.Cli.executeCommandWithOutput(AadUserGetCommand, { options: Object.assign(Object.assign({}, options), { _: [] }) });
55
+ const userOutput = JSON.parse(userGetOutput.stdout);
56
+ return userOutput.userPrincipalName;
57
+ });
58
+ }
39
59
  commandAction(logger, args) {
40
60
  return __awaiter(this, void 0, void 0, function* () {
41
61
  const removeUserfromSPGroup = () => __awaiter(this, void 0, void 0, function* () {
42
62
  if (this.verbose) {
43
- logger.logToStderr(`Removing User with Username ${args.options.userName} from Group: ${args.options.groupId ? args.options.groupId : args.options.groupName}`);
63
+ logger.logToStderr(`Removing User ${args.options.userName || args.options.email || args.options.userId} from Group: ${args.options.groupId ? args.options.groupId : args.options.groupName}`);
44
64
  }
45
- const loginName = `i:0#.f|membership|${args.options.userName}`;
46
- const requestUrl = `${args.options.webUrl}/_api/web/sitegroups/${args.options.groupId
65
+ let requestUrl = `${args.options.webUrl}/_api/web/sitegroups/${args.options.groupId
47
66
  ? `GetById('${args.options.groupId}')`
48
- : `GetByName('${formatting_1.formatting.encodeQueryParameter(args.options.groupName)}')`}/users/removeByLoginName(@LoginName)?@LoginName='${formatting_1.formatting.encodeQueryParameter(loginName)}'`;
67
+ : `GetByName('${formatting_1.formatting.encodeQueryParameter(args.options.groupName)}')`}`;
68
+ if (args.options.userId) {
69
+ requestUrl += `/users/removeById(${args.options.userId})`;
70
+ }
71
+ else {
72
+ const userName = yield this.getUserName(logger, args);
73
+ const loginName = `i:0#.f|membership|${userName}`;
74
+ requestUrl += `/users/removeByLoginName(@LoginName)?@LoginName='${formatting_1.formatting.encodeQueryParameter(loginName)}'`;
75
+ }
49
76
  const requestOptions = {
50
77
  url: requestUrl,
51
78
  headers: {
@@ -71,7 +98,7 @@ class SpoGroupMemberRemoveCommand extends SpoCommand_1.default {
71
98
  type: 'confirm',
72
99
  name: 'continue',
73
100
  default: false,
74
- message: `Are you sure you want to remove user User ${args.options.userName} from SharePoint group?`
101
+ message: `Are you sure you want to remove user ${args.options.userName || args.options.userId || args.options.email} from the SharePoint group?`
75
102
  });
76
103
  if (result.continue) {
77
104
  yield removeUserfromSPGroup();
@@ -85,6 +112,9 @@ _SpoGroupMemberRemoveCommand_instances = new WeakSet(), _SpoGroupMemberRemoveCom
85
112
  Object.assign(this.telemetryProperties, {
86
113
  groupId: (!(!args.options.groupId)).toString(),
87
114
  groupName: (!(!args.options.groupName)).toString(),
115
+ userName: (!(!args.options.userName)).toString(),
116
+ email: (!(!args.options.email)).toString(),
117
+ userId: (!(!args.options.userId)).toString(),
88
118
  confirm: (!(!args.options.confirm)).toString()
89
119
  });
90
120
  });
@@ -96,7 +126,11 @@ _SpoGroupMemberRemoveCommand_instances = new WeakSet(), _SpoGroupMemberRemoveCom
96
126
  }, {
97
127
  option: '--groupName [groupName]'
98
128
  }, {
99
- option: '--userName <userName>'
129
+ option: '--userName [userName]'
130
+ }, {
131
+ option: '--email [email]'
132
+ }, {
133
+ option: '--userId [userId]'
100
134
  }, {
101
135
  option: '--confirm'
102
136
  });
@@ -105,10 +139,19 @@ _SpoGroupMemberRemoveCommand_instances = new WeakSet(), _SpoGroupMemberRemoveCom
105
139
  if (args.options.groupId && isNaN(args.options.groupId)) {
106
140
  return `Specified "groupId" ${args.options.groupId} is not valid`;
107
141
  }
142
+ if (args.options.userId && isNaN(args.options.userId)) {
143
+ return `Specified "userId" ${args.options.userId} is not valid`;
144
+ }
145
+ if (args.options.userName && !validation_1.validation.isValidUserPrincipalName(args.options.userName)) {
146
+ return `${args.options.userName} is not a valid userName`;
147
+ }
148
+ if (args.options.email && !validation_1.validation.isValidUserPrincipalName(args.options.email)) {
149
+ return `${args.options.email} is not a valid email`;
150
+ }
108
151
  return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
109
152
  }));
110
153
  }, _SpoGroupMemberRemoveCommand_initOptionSets = function _SpoGroupMemberRemoveCommand_initOptionSets() {
111
- this.optionSets.push({ options: ['groupName', 'groupId'] });
154
+ this.optionSets.push({ options: ['groupName', 'groupId'] }, { options: ['userName', 'email', 'userId'] });
112
155
  };
113
156
  module.exports = new SpoGroupMemberRemoveCommand();
114
157
  //# sourceMappingURL=group-member-remove.js.map
@@ -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 _SpoListLabelSetCommand_instances, _SpoListLabelSetCommand_initTelemetry, _SpoListLabelSetCommand_initOptions, _SpoListLabelSetCommand_initValidators, _SpoListLabelSetCommand_initOptionSets;
16
+ var _SpoListRetentionLabelEnsureCommand_instances, _SpoListRetentionLabelEnsureCommand_initTelemetry, _SpoListRetentionLabelEnsureCommand_initOptions, _SpoListRetentionLabelEnsureCommand_initValidators, _SpoListRetentionLabelEnsureCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const request_1 = require("../../../../request");
19
19
  const formatting_1 = require("../../../../utils/formatting");
@@ -21,23 +21,33 @@ const urlUtil_1 = require("../../../../utils/urlUtil");
21
21
  const validation_1 = require("../../../../utils/validation");
22
22
  const SpoCommand_1 = require("../../../base/SpoCommand");
23
23
  const commands_1 = require("../../commands");
24
- class SpoListLabelSetCommand extends SpoCommand_1.default {
24
+ class SpoListRetentionLabelEnsureCommand extends SpoCommand_1.default {
25
25
  get name() {
26
- return commands_1.default.LIST_LABEL_SET;
26
+ return commands_1.default.LIST_RETENTIONLABEL_ENSURE;
27
+ }
28
+ alias() {
29
+ return [commands_1.default.LIST_LABEL_SET];
27
30
  }
28
31
  get description() {
29
- return 'Sets classification label on the specified list';
32
+ return 'Sets a default retention label on the specified list or library.';
30
33
  }
31
34
  constructor() {
32
35
  super();
33
- _SpoListLabelSetCommand_instances.add(this);
34
- __classPrivateFieldGet(this, _SpoListLabelSetCommand_instances, "m", _SpoListLabelSetCommand_initTelemetry).call(this);
35
- __classPrivateFieldGet(this, _SpoListLabelSetCommand_instances, "m", _SpoListLabelSetCommand_initOptions).call(this);
36
- __classPrivateFieldGet(this, _SpoListLabelSetCommand_instances, "m", _SpoListLabelSetCommand_initValidators).call(this);
37
- __classPrivateFieldGet(this, _SpoListLabelSetCommand_instances, "m", _SpoListLabelSetCommand_initOptionSets).call(this);
36
+ _SpoListRetentionLabelEnsureCommand_instances.add(this);
37
+ __classPrivateFieldGet(this, _SpoListRetentionLabelEnsureCommand_instances, "m", _SpoListRetentionLabelEnsureCommand_initTelemetry).call(this);
38
+ __classPrivateFieldGet(this, _SpoListRetentionLabelEnsureCommand_instances, "m", _SpoListRetentionLabelEnsureCommand_initOptions).call(this);
39
+ __classPrivateFieldGet(this, _SpoListRetentionLabelEnsureCommand_instances, "m", _SpoListRetentionLabelEnsureCommand_initValidators).call(this);
40
+ __classPrivateFieldGet(this, _SpoListRetentionLabelEnsureCommand_instances, "m", _SpoListRetentionLabelEnsureCommand_initOptionSets).call(this);
38
41
  }
39
42
  commandAction(logger, args) {
40
43
  return __awaiter(this, void 0, void 0, function* () {
44
+ this.showDeprecationWarning(logger, commands_1.default.LIST_LABEL_SET, commands_1.default.LIST_RETENTIONLABEL_ENSURE);
45
+ if (args.options.blockDelete) {
46
+ this.warn(logger, `Option 'blockDelete' is deprecated.`);
47
+ }
48
+ if (args.options.blockEdit) {
49
+ this.warn(logger, `Option 'blockEdit' is deprecated.`);
50
+ }
41
51
  try {
42
52
  let listRestUrl = '';
43
53
  let listServerRelativeUrl = '';
@@ -86,7 +96,7 @@ class SpoListLabelSetCommand extends SpoCommand_1.default {
86
96
  });
87
97
  }
88
98
  }
89
- _SpoListLabelSetCommand_instances = new WeakSet(), _SpoListLabelSetCommand_initTelemetry = function _SpoListLabelSetCommand_initTelemetry() {
99
+ _SpoListRetentionLabelEnsureCommand_instances = new WeakSet(), _SpoListRetentionLabelEnsureCommand_initTelemetry = function _SpoListRetentionLabelEnsureCommand_initTelemetry() {
90
100
  this.telemetry.push((args) => {
91
101
  Object.assign(this.telemetryProperties, {
92
102
  listId: (!(!args.options.listId)).toString(),
@@ -97,7 +107,7 @@ _SpoListLabelSetCommand_instances = new WeakSet(), _SpoListLabelSetCommand_initT
97
107
  blockEdit: args.options.blockEdit || false
98
108
  });
99
109
  });
100
- }, _SpoListLabelSetCommand_initOptions = function _SpoListLabelSetCommand_initOptions() {
110
+ }, _SpoListRetentionLabelEnsureCommand_initOptions = function _SpoListRetentionLabelEnsureCommand_initOptions() {
101
111
  this.options.unshift({
102
112
  option: '-u, --webUrl <webUrl>'
103
113
  }, {
@@ -115,15 +125,15 @@ _SpoListLabelSetCommand_instances = new WeakSet(), _SpoListLabelSetCommand_initT
115
125
  }, {
116
126
  option: '--blockEdit'
117
127
  });
118
- }, _SpoListLabelSetCommand_initValidators = function _SpoListLabelSetCommand_initValidators() {
128
+ }, _SpoListRetentionLabelEnsureCommand_initValidators = function _SpoListRetentionLabelEnsureCommand_initValidators() {
119
129
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
120
130
  if (args.options.listId && !validation_1.validation.isValidGuid(args.options.listId)) {
121
131
  return `${args.options.listId} is not a valid GUID`;
122
132
  }
123
133
  return validation_1.validation.isValidSharePointUrl(args.options.webUrl);
124
134
  }));
125
- }, _SpoListLabelSetCommand_initOptionSets = function _SpoListLabelSetCommand_initOptionSets() {
135
+ }, _SpoListRetentionLabelEnsureCommand_initOptionSets = function _SpoListRetentionLabelEnsureCommand_initOptionSets() {
126
136
  this.optionSets.push({ options: ['listId', 'listTitle', 'listUrl'] });
127
137
  };
128
- module.exports = new SpoListLabelSetCommand();
129
- //# sourceMappingURL=list-label-set.js.map
138
+ module.exports = new SpoListRetentionLabelEnsureCommand();
139
+ //# sourceMappingURL=list-retentionlabel-ensure.js.map