@pnp/cli-microsoft365 6.1.0-beta.c68d208 → 6.1.0-beta.d3a109a

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 (32) hide show
  1. package/dist/m365/aad/commands/group/group-get.js +79 -0
  2. package/dist/m365/aad/commands.js +1 -0
  3. package/dist/m365/context/commands/context-remove.js +103 -0
  4. package/dist/m365/context/commands.js +2 -1
  5. package/dist/m365/pp/commands/environment/environment-get.js +5 -13
  6. package/dist/m365/purview/commands/retentionlabel/retentionlabel-set.js +142 -0
  7. package/dist/m365/purview/commands.js +2 -1
  8. package/dist/m365/search/commands/externalconnection/externalconnection-schema-add.js +86 -0
  9. package/dist/m365/search/commands.js +2 -1
  10. package/dist/m365/spo/commands/group/group-member-add.js +68 -30
  11. package/dist/m365/spo/commands/group/group-member-remove.js +50 -7
  12. package/dist/m365/spo/commands/list/{list-retentionlabel-set.js → list-retentionlabel-ensure.js} +21 -15
  13. package/dist/m365/spo/commands/listitem/listitem-remove.js +1 -1
  14. package/dist/m365/spo/commands/listitem/listitem-retentionlabel-remove.js +143 -0
  15. package/dist/m365/spo/commands/page/page-add.js +60 -63
  16. package/dist/m365/spo/commands/page/page-set.js +59 -70
  17. package/dist/m365/spo/commands/site/site-appcatalog-list.js +43 -0
  18. package/dist/m365/spo/commands.js +3 -1
  19. package/dist/request.js +2 -1
  20. package/docs/docs/cmd/aad/group/group-get.md +127 -0
  21. package/docs/docs/cmd/context/context-remove.md +34 -0
  22. package/docs/docs/cmd/pp/environment/environment-get.md +9 -3
  23. package/docs/docs/cmd/purview/retentionlabel/retentionlabel-set.md +63 -0
  24. package/docs/docs/cmd/search/externalconnection/externalconnection-schema-add.md +31 -0
  25. package/docs/docs/cmd/spo/group/group-member-add.md +58 -6
  26. package/docs/docs/cmd/spo/group/group-member-remove.md +24 -8
  27. package/docs/docs/cmd/spo/list/list-retentionlabel-ensure.md +65 -0
  28. package/docs/docs/cmd/spo/listitem/listitem-remove.md +6 -6
  29. package/docs/docs/cmd/spo/listitem/listitem-retentionlabel-remove.md +55 -0
  30. package/docs/docs/cmd/spo/site/site-appcatalog-list.md +55 -0
  31. package/package.json +1 -1
  32. package/docs/docs/cmd/spo/list/list-retentionlabel-set.md +0 -65
@@ -0,0 +1,79 @@
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 _AadGroupGetCommand_instances, _AadGroupGetCommand_initOptions, _AadGroupGetCommand_initValidators, _AadGroupGetCommand_initOptionSets, _AadGroupGetCommand_initTelemetry;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const validation_1 = require("../../../../utils/validation");
19
+ const aadGroup_1 = require("../../../../utils/aadGroup");
20
+ const GraphCommand_1 = require("../../../base/GraphCommand");
21
+ const commands_1 = require("../../commands");
22
+ class AadGroupGetCommand extends GraphCommand_1.default {
23
+ get name() {
24
+ return commands_1.default.GROUP_GET;
25
+ }
26
+ get description() {
27
+ return 'Gets information about the specified Azure AD Group';
28
+ }
29
+ constructor() {
30
+ super();
31
+ _AadGroupGetCommand_instances.add(this);
32
+ __classPrivateFieldGet(this, _AadGroupGetCommand_instances, "m", _AadGroupGetCommand_initOptions).call(this);
33
+ __classPrivateFieldGet(this, _AadGroupGetCommand_instances, "m", _AadGroupGetCommand_initValidators).call(this);
34
+ __classPrivateFieldGet(this, _AadGroupGetCommand_instances, "m", _AadGroupGetCommand_initOptionSets).call(this);
35
+ __classPrivateFieldGet(this, _AadGroupGetCommand_instances, "m", _AadGroupGetCommand_initTelemetry).call(this);
36
+ }
37
+ commandAction(logger, args) {
38
+ return __awaiter(this, void 0, void 0, function* () {
39
+ let group;
40
+ try {
41
+ if (args.options.id) {
42
+ group = yield aadGroup_1.aadGroup.getGroupById(args.options.id);
43
+ }
44
+ else {
45
+ group = yield aadGroup_1.aadGroup.getGroupByDisplayName(args.options.title);
46
+ }
47
+ logger.log(group);
48
+ }
49
+ catch (err) {
50
+ this.handleRejectedODataJsonPromise(err);
51
+ }
52
+ });
53
+ }
54
+ }
55
+ _AadGroupGetCommand_instances = new WeakSet(), _AadGroupGetCommand_initOptions = function _AadGroupGetCommand_initOptions() {
56
+ this.options.unshift({
57
+ option: '-i, --id [id]'
58
+ }, {
59
+ option: '-t, --title [title]'
60
+ });
61
+ }, _AadGroupGetCommand_initValidators = function _AadGroupGetCommand_initValidators() {
62
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
63
+ if (args.options.id && !validation_1.validation.isValidGuid(args.options.id)) {
64
+ return `${args.options.id} is not a valid GUID`;
65
+ }
66
+ return true;
67
+ }));
68
+ }, _AadGroupGetCommand_initOptionSets = function _AadGroupGetCommand_initOptionSets() {
69
+ this.optionSets.push({ options: ['id', 'title'] });
70
+ }, _AadGroupGetCommand_initTelemetry = function _AadGroupGetCommand_initTelemetry() {
71
+ this.telemetry.push((args) => {
72
+ Object.assign(this.telemetryProperties, {
73
+ id: typeof args.options.id !== 'undefined',
74
+ title: typeof args.options.title !== 'undefined'
75
+ });
76
+ });
77
+ };
78
+ module.exports = new AadGroupGetCommand();
79
+ //# sourceMappingURL=group-get.js.map
@@ -13,6 +13,7 @@ exports.default = {
13
13
  APPROLEASSIGNMENT_ADD: `${prefix} approleassignment add`,
14
14
  APPROLEASSIGNMENT_LIST: `${prefix} approleassignment list`,
15
15
  APPROLEASSIGNMENT_REMOVE: `${prefix} approleassignment remove`,
16
+ GROUP_GET: `${prefix} group get`,
16
17
  GROUP_LIST: `${prefix} group list`,
17
18
  GROUPSETTING_ADD: `${prefix} groupsetting add`,
18
19
  GROUPSETTING_GET: `${prefix} groupsetting get`,
@@ -0,0 +1,103 @@
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 _ContextRemoveCommand_instances, _ContextRemoveCommand_initTelemetry, _ContextRemoveCommand_initOptions;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const fs = require("fs");
19
+ const Cli_1 = require("../../../cli/Cli");
20
+ const Command_1 = require("../../../Command");
21
+ const AnonymousCommand_1 = require("../../base/AnonymousCommand");
22
+ const commands_1 = require("../commands");
23
+ class ContextRemoveCommand extends AnonymousCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.REMOVE;
26
+ }
27
+ get description() {
28
+ return 'Removes the CLI for Microsoft 365 context in the current working folder';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _ContextRemoveCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _ContextRemoveCommand_instances, "m", _ContextRemoveCommand_initOptions).call(this);
35
+ }
36
+ commandAction(logger, args) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ if (args.options.confirm) {
39
+ yield this.removeContext();
40
+ }
41
+ else {
42
+ const result = yield Cli_1.Cli.prompt({
43
+ type: 'confirm',
44
+ name: 'continue',
45
+ default: false,
46
+ message: `Are you sure you want to remove the context?`
47
+ });
48
+ if (result.continue) {
49
+ yield this.removeContext();
50
+ }
51
+ }
52
+ });
53
+ }
54
+ removeContext() {
55
+ const filePath = '.m365rc.json';
56
+ let m365rc = {};
57
+ if (fs.existsSync(filePath)) {
58
+ try {
59
+ const fileContents = fs.readFileSync(filePath, 'utf8');
60
+ if (fileContents) {
61
+ m365rc = JSON.parse(fileContents);
62
+ }
63
+ }
64
+ catch (e) {
65
+ throw new Command_1.CommandError(`Error reading ${filePath}: ${e}. Please remove context info from ${filePath} manually.`);
66
+ }
67
+ }
68
+ if (!m365rc.context) {
69
+ return;
70
+ }
71
+ const keys = Object.keys(m365rc);
72
+ if (keys.length === 1 && keys.indexOf('context') > -1) {
73
+ try {
74
+ fs.unlinkSync(filePath);
75
+ }
76
+ catch (e) {
77
+ throw new Command_1.CommandError(`Error removing ${filePath}: ${e}. Please remove ${filePath} manually.`);
78
+ }
79
+ }
80
+ else {
81
+ try {
82
+ delete m365rc.context;
83
+ fs.writeFileSync(filePath, JSON.stringify(m365rc, null, 2));
84
+ }
85
+ catch (e) {
86
+ throw new Command_1.CommandError(`Error writing ${filePath}: ${e}. Please remove context info from ${filePath} manually.`);
87
+ }
88
+ }
89
+ }
90
+ }
91
+ _ContextRemoveCommand_instances = new WeakSet(), _ContextRemoveCommand_initTelemetry = function _ContextRemoveCommand_initTelemetry() {
92
+ this.telemetry.push((args) => {
93
+ Object.assign(this.telemetryProperties, {
94
+ confirm: !!args.options.confirm
95
+ });
96
+ });
97
+ }, _ContextRemoveCommand_initOptions = function _ContextRemoveCommand_initOptions() {
98
+ this.options.unshift({
99
+ option: '--confirm'
100
+ });
101
+ };
102
+ module.exports = new ContextRemoveCommand();
103
+ //# sourceMappingURL=context-remove.js.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'context';
4
4
  exports.default = {
5
- INIT: `${prefix} init`
5
+ INIT: `${prefix} init`,
6
+ REMOVE: `${prefix} remove`
6
7
  };
7
8
  //# sourceMappingURL=commands.js.map
@@ -15,7 +15,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
15
15
  };
16
16
  var _PpEnvironmentGetCommand_instances, _PpEnvironmentGetCommand_initTelemetry, _PpEnvironmentGetCommand_initOptions;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- const request_1 = require("../../../../request");
18
+ const odata_1 = require("../../../../utils/odata");
19
19
  const PowerPlatformCommand_1 = require("../../../base/PowerPlatformCommand");
20
20
  const commands_1 = require("../../commands");
21
21
  class PpEnvironmentGetCommand extends PowerPlatformCommand_1.default {
@@ -40,17 +40,8 @@ class PpEnvironmentGetCommand extends PowerPlatformCommand_1.default {
40
40
  if (args.options.asAdmin) {
41
41
  url = `${this.resource}/providers/Microsoft.BusinessAppPlatform/scopes/admin/environments`;
42
42
  }
43
- const requestOptions = {
44
- url: `${url}?api-version=2020-10-01`,
45
- headers: {
46
- accept: 'application/json'
47
- },
48
- responseType: 'json'
49
- };
50
- const res = yield request_1.default.get(requestOptions);
51
- const environmentItem = res.value.filter((env) => {
52
- return env.name === args.options.name;
53
- })[0];
43
+ const res = yield odata_1.odata.getAllItems(`${url}?api-version=2020-10-01`);
44
+ const environmentItem = res.filter((env) => args.options.name ? env.name === args.options.name : env.properties.isDefault === true)[0];
54
45
  if (!environmentItem) {
55
46
  throw `The specified Power Platform environment does not exist`;
56
47
  }
@@ -61,12 +52,13 @@ class PpEnvironmentGetCommand extends PowerPlatformCommand_1.default {
61
52
  _PpEnvironmentGetCommand_instances = new WeakSet(), _PpEnvironmentGetCommand_initTelemetry = function _PpEnvironmentGetCommand_initTelemetry() {
62
53
  this.telemetry.push((args) => {
63
54
  Object.assign(this.telemetryProperties, {
55
+ name: typeof args.options.name !== 'undefined',
64
56
  asAdmin: !!args.options.asAdmin
65
57
  });
66
58
  });
67
59
  }, _PpEnvironmentGetCommand_initOptions = function _PpEnvironmentGetCommand_initOptions() {
68
60
  this.options.unshift({
69
- option: '-n, --name <name>'
61
+ option: '-n, --name [name]'
70
62
  }, {
71
63
  option: '--asAdmin'
72
64
  });
@@ -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