@pnp/cli-microsoft365 6.4.0-beta.39e5130 → 6.4.0-beta.8c5ba0e

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.
@@ -0,0 +1,138 @@
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 _PurviewRetentionEventAddCommand_instances, _PurviewRetentionEventAddCommand_initOptions, _PurviewRetentionEventAddCommand_initValidators, _PurviewRetentionEventAddCommand_initTelemetry, _PurviewRetentionEventAddCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const GraphCommand_1 = require("../../../base/GraphCommand");
19
+ const commands_1 = require("../../commands");
20
+ const accessToken_1 = require("../../../../utils/accessToken");
21
+ const Auth_1 = require("../../../../Auth");
22
+ const request_1 = require("../../../../request");
23
+ const validation_1 = require("../../../../utils/validation");
24
+ const odata_1 = require("../../../../utils/odata");
25
+ class PurviewRetentionEventAddCommand extends GraphCommand_1.default {
26
+ get name() {
27
+ return commands_1.default.RETENTIONEVENT_ADD;
28
+ }
29
+ get description() {
30
+ return 'Create a retention event';
31
+ }
32
+ constructor() {
33
+ super();
34
+ _PurviewRetentionEventAddCommand_instances.add(this);
35
+ __classPrivateFieldGet(this, _PurviewRetentionEventAddCommand_instances, "m", _PurviewRetentionEventAddCommand_initTelemetry).call(this);
36
+ __classPrivateFieldGet(this, _PurviewRetentionEventAddCommand_instances, "m", _PurviewRetentionEventAddCommand_initOptions).call(this);
37
+ __classPrivateFieldGet(this, _PurviewRetentionEventAddCommand_instances, "m", _PurviewRetentionEventAddCommand_initValidators).call(this);
38
+ __classPrivateFieldGet(this, _PurviewRetentionEventAddCommand_instances, "m", _PurviewRetentionEventAddCommand_initOptionSets).call(this);
39
+ }
40
+ commandAction(logger, args) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ if (accessToken_1.accessToken.isAppOnlyAccessToken(Auth_1.default.service.accessTokens[this.resource].accessToken)) {
43
+ this.handleError('This command does not support application permissions.');
44
+ }
45
+ if (this.verbose) {
46
+ logger.logToStderr(`Creating retention event...`);
47
+ }
48
+ const eventQueries = [];
49
+ if (args.options.assetIds) {
50
+ eventQueries.push({ queryType: "files", query: args.options.assetIds });
51
+ }
52
+ if (args.options.keywords) {
53
+ eventQueries.push({ queryType: "messages", query: args.options.keywords });
54
+ }
55
+ const eventTypeId = yield this.getEventTypeId(logger, args);
56
+ const data = {
57
+ 'retentionEventType@odata.bind': `https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes/${eventTypeId}`,
58
+ displayName: args.options.displayName,
59
+ description: args.options.description,
60
+ eventQueries: eventQueries,
61
+ eventTriggerDateTime: args.options.triggerDateTime
62
+ };
63
+ try {
64
+ const requestOptions = {
65
+ url: `${this.resource}/beta/security/triggers/retentionEvents`,
66
+ headers: {
67
+ accept: 'application/json;odata.metadata=none'
68
+ },
69
+ responseType: 'json',
70
+ data: data
71
+ };
72
+ const res = yield request_1.default.post(requestOptions);
73
+ logger.log(res);
74
+ }
75
+ catch (err) {
76
+ this.handleRejectedODataJsonPromise(err);
77
+ }
78
+ });
79
+ }
80
+ getEventTypeId(logger, args) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ if (args.options.eventTypeId) {
83
+ return args.options.eventTypeId;
84
+ }
85
+ if (this.verbose) {
86
+ logger.logToStderr(`Retrieving the event type id for event type ${args.options.eventTypeName}`);
87
+ }
88
+ const items = yield odata_1.odata.getAllItems(`${this.resource}/beta/security/triggerTypes/retentionEventTypes`);
89
+ const eventTypes = items.filter((x) => x.displayName === args.options.eventTypeName);
90
+ if (eventTypes.length === 0) {
91
+ throw `The specified event type '${args.options.eventTypeName}' does not exist.`;
92
+ }
93
+ return eventTypes[0].id;
94
+ });
95
+ }
96
+ }
97
+ _PurviewRetentionEventAddCommand_instances = new WeakSet(), _PurviewRetentionEventAddCommand_initOptions = function _PurviewRetentionEventAddCommand_initOptions() {
98
+ this.options.unshift({
99
+ option: '-n, --displayName <displayName>'
100
+ }, {
101
+ option: '-i, --eventTypeId [eventTypeId]'
102
+ }, {
103
+ option: '-e, --eventTypeName [eventTypeName]'
104
+ }, {
105
+ option: '-d, --description [description]'
106
+ }, {
107
+ option: '--triggerDateTime [triggerDateTime]'
108
+ }, {
109
+ option: '-a, --assetIds [assetIds]'
110
+ }, {
111
+ option: '-k, --keywords [keywords]'
112
+ });
113
+ }, _PurviewRetentionEventAddCommand_initValidators = function _PurviewRetentionEventAddCommand_initValidators() {
114
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
115
+ if (args.options.triggerDateTime && !validation_1.validation.isValidISODateTime(args.options.triggerDateTime)) {
116
+ return 'The triggerDateTime is not a valid ISO date string';
117
+ }
118
+ if (!args.options.assetIds && !args.options.keywords) {
119
+ return 'Specify assetIds and/or keywords, but at least one.';
120
+ }
121
+ return true;
122
+ }));
123
+ }, _PurviewRetentionEventAddCommand_initTelemetry = function _PurviewRetentionEventAddCommand_initTelemetry() {
124
+ this.telemetry.push((args) => {
125
+ Object.assign(this.telemetryProperties, {
126
+ description: typeof args.options.description !== 'undefined',
127
+ triggerDateTime: typeof args.options.triggerDateTime !== 'undefined',
128
+ eventTypeId: typeof args.options.eventTypeId !== 'undefined',
129
+ eventTypeName: typeof args.options.eventTypeName !== 'undefined',
130
+ assetIds: typeof args.options.assetIds !== 'undefined',
131
+ keywords: typeof args.options.keywords !== 'undefined'
132
+ });
133
+ });
134
+ }, _PurviewRetentionEventAddCommand_initOptionSets = function _PurviewRetentionEventAddCommand_initOptionSets() {
135
+ this.optionSets.push({ options: ['eventTypeId', 'eventTypeName'] });
136
+ };
137
+ module.exports = new PurviewRetentionEventAddCommand();
138
+ //# sourceMappingURL=retentionevent-add.js.map
@@ -13,13 +13,14 @@ 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 _PurviewRetentionLabelAddCommand_instances, _PurviewRetentionLabelAddCommand_initTelemetry, _PurviewRetentionLabelAddCommand_initOptions, _PurviewRetentionLabelAddCommand_initValidators;
16
+ var _PurviewRetentionLabelAddCommand_instances, _PurviewRetentionLabelAddCommand_initTelemetry, _PurviewRetentionLabelAddCommand_initOptions, _PurviewRetentionLabelAddCommand_initValidators, _PurviewRetentionLabelAddCommand_initOptionSets;
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  const Auth_1 = require("../../../../Auth");
19
19
  const request_1 = require("../../../../request");
20
20
  const accessToken_1 = require("../../../../utils/accessToken");
21
21
  const GraphCommand_1 = require("../../../base/GraphCommand");
22
22
  const commands_1 = require("../../commands");
23
+ const odata_1 = require("../../../../utils/odata");
23
24
  class PurviewRetentionLabelAddCommand extends GraphCommand_1.default {
24
25
  get name() {
25
26
  return commands_1.default.RETENTIONLABEL_ADD;
@@ -33,6 +34,7 @@ class PurviewRetentionLabelAddCommand extends GraphCommand_1.default {
33
34
  __classPrivateFieldGet(this, _PurviewRetentionLabelAddCommand_instances, "m", _PurviewRetentionLabelAddCommand_initTelemetry).call(this);
34
35
  __classPrivateFieldGet(this, _PurviewRetentionLabelAddCommand_instances, "m", _PurviewRetentionLabelAddCommand_initOptions).call(this);
35
36
  __classPrivateFieldGet(this, _PurviewRetentionLabelAddCommand_instances, "m", _PurviewRetentionLabelAddCommand_initValidators).call(this);
37
+ __classPrivateFieldGet(this, _PurviewRetentionLabelAddCommand_instances, "m", _PurviewRetentionLabelAddCommand_initOptionSets).call(this);
36
38
  }
37
39
  commandAction(logger, args) {
38
40
  return __awaiter(this, void 0, void 0, function* () {
@@ -52,6 +54,10 @@ class PurviewRetentionLabelAddCommand extends GraphCommand_1.default {
52
54
  },
53
55
  defaultRecordBehavior: defaultRecordBehavior
54
56
  };
57
+ if (args.options.retentionTrigger === 'dateOfEvent') {
58
+ const eventTypeId = yield this.getEventTypeId(args, logger);
59
+ requestBody['retentionEventType@odata.bind'] = `https://graph.microsoft.com/beta/security/triggerTypes/retentionEventTypes/${eventTypeId}`;
60
+ }
55
61
  if (args.options.descriptionForAdmins) {
56
62
  if (this.verbose) {
57
63
  logger.logToStderr(`Using '${args.options.descriptionForAdmins}' as descriptionForAdmins`);
@@ -87,6 +93,22 @@ class PurviewRetentionLabelAddCommand extends GraphCommand_1.default {
87
93
  }
88
94
  });
89
95
  }
96
+ getEventTypeId(args, logger) {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ if (args.options.eventTypeId) {
99
+ return args.options.eventTypeId;
100
+ }
101
+ if (this.verbose) {
102
+ logger.logToStderr(`Retrieving the event type id for event type ${args.options.eventTypeName}`);
103
+ }
104
+ const eventTypes = yield odata_1.odata.getAllItems(`${this.resource}/beta/security/triggerTypes/retentionEventTypes`);
105
+ const filteredEventTypes = eventTypes.filter((eventType) => eventType.displayName === args.options.eventTypeName);
106
+ if (filteredEventTypes.length === 0) {
107
+ throw `The specified retention event type '${args.options.eventTypeName}' does not exist.`;
108
+ }
109
+ return filteredEventTypes[0].id;
110
+ });
111
+ }
90
112
  }
91
113
  _PurviewRetentionLabelAddCommand_instances = new WeakSet(), _PurviewRetentionLabelAddCommand_initTelemetry = function _PurviewRetentionLabelAddCommand_initTelemetry() {
92
114
  this.telemetry.push((args) => {
@@ -95,7 +117,9 @@ _PurviewRetentionLabelAddCommand_instances = new WeakSet(), _PurviewRetentionLab
95
117
  defaultRecordBehavior: typeof args.options.defaultRecordBehavior !== 'undefined',
96
118
  descriptionForUsers: typeof args.options.descriptionForUsers !== 'undefined',
97
119
  descriptionForAdmins: typeof args.options.descriptionForAdmins !== 'undefined',
98
- labelToBeApplied: typeof args.options.labelToBeApplied !== 'undefined'
120
+ labelToBeApplied: typeof args.options.labelToBeApplied !== 'undefined',
121
+ eventTypeId: typeof args.options.eventTypeId !== 'undefined',
122
+ eventTypeName: typeof args.options.eventTypeName !== 'undefined'
99
123
  });
100
124
  });
101
125
  }, _PurviewRetentionLabelAddCommand_initOptions = function _PurviewRetentionLabelAddCommand_initOptions() {
@@ -103,46 +127,56 @@ _PurviewRetentionLabelAddCommand_instances = new WeakSet(), _PurviewRetentionLab
103
127
  option: '-n, --displayName <displayName>'
104
128
  }, {
105
129
  option: '--behaviorDuringRetentionPeriod <behaviorDuringRetentionPeriod>',
106
- autocomplete: ['doNotRetain', 'retain', 'retainAsRecord', 'retainAsRegulatoryRecord']
130
+ autocomplete: PurviewRetentionLabelAddCommand.behaviorDuringRetentionPeriods
107
131
  }, {
108
132
  option: '--actionAfterRetentionPeriod <actionAfterRetentionPeriod>',
109
- autocomplete: ['none', 'delete', 'startDispositionReview']
133
+ autocomplete: PurviewRetentionLabelAddCommand.actionAfterRetentionPeriods
110
134
  }, {
111
135
  option: '--retentionDuration <retentionDuration>'
112
136
  }, {
113
137
  option: '-t, --retentionTrigger [retentionTrigger]',
114
- autocomplete: ['dateLabeled', 'dateCreated', 'dateModified', 'dateOfEvent']
138
+ autocomplete: PurviewRetentionLabelAddCommand.retentionTriggers
115
139
  }, {
116
140
  option: '--defaultRecordBehavior [defaultRecordBehavior]',
117
- autocomplete: ['startLocked', 'startUnlocked']
141
+ autocomplete: PurviewRetentionLabelAddCommand.defaultRecordBehavior
118
142
  }, {
119
143
  option: '--descriptionForUsers [descriptionForUsers]'
120
144
  }, {
121
145
  option: '--descriptionForAdmins [descriptionForAdmins]'
122
146
  }, {
123
147
  option: '--labelToBeApplied [labelToBeApplied]'
148
+ }, {
149
+ option: '--eventTypeId [eventTypeId]'
150
+ }, {
151
+ option: '--eventTypeName [eventTypeName]'
124
152
  });
125
153
  }, _PurviewRetentionLabelAddCommand_initValidators = function _PurviewRetentionLabelAddCommand_initValidators() {
126
154
  this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
127
155
  if (isNaN(args.options.retentionDuration)) {
128
156
  return `Specified retentionDuration ${args.options.retentionDuration} is not a number`;
129
157
  }
130
- if (['doNotRetain', 'retain', 'retainAsRecord', 'retainAsRegulatoryRecord'].indexOf(args.options.behaviorDuringRetentionPeriod) === -1) {
131
- return `${args.options.behaviorDuringRetentionPeriod} is not a valid behavior of a document with the label. Allowed values are doNotRetain|retain|retainAsRecord|retainAsRegulatoryRecord`;
158
+ if (PurviewRetentionLabelAddCommand.behaviorDuringRetentionPeriods.indexOf(args.options.behaviorDuringRetentionPeriod) === -1) {
159
+ return `${args.options.behaviorDuringRetentionPeriod} is not a valid behavior of a document with the label. Allowed values are ${PurviewRetentionLabelAddCommand.behaviorDuringRetentionPeriods.join(', ')}`;
132
160
  }
133
- if (['none', 'delete', 'startDispositionReview'].indexOf(args.options.actionAfterRetentionPeriod) === -1) {
134
- return `${args.options.actionAfterRetentionPeriod} is not a valid action to take on a document with the label. Allowed values are none|delete|startDispositionReview`;
161
+ if (PurviewRetentionLabelAddCommand.actionAfterRetentionPeriods.indexOf(args.options.actionAfterRetentionPeriod) === -1) {
162
+ return `${args.options.actionAfterRetentionPeriod} is not a valid action to take on a document with the label. Allowed values are ${PurviewRetentionLabelAddCommand.actionAfterRetentionPeriods.join(', ')}`;
135
163
  }
136
164
  if (args.options.retentionTrigger &&
137
- ['dateLabeled', 'dateCreated', 'dateModified', 'dateOfEvent'].indexOf(args.options.retentionTrigger) === -1) {
138
- return `${args.options.retentionTrigger} is not a valid action retention duration calculation. Allowed values are dateLabeled|dateCreated|dateModified|dateOfEvent`;
165
+ PurviewRetentionLabelAddCommand.retentionTriggers.indexOf(args.options.retentionTrigger) === -1) {
166
+ return `${args.options.retentionTrigger} is not a valid action retention duration calculation. Allowed values are ${PurviewRetentionLabelAddCommand.retentionTriggers.join(', ')}`;
139
167
  }
140
168
  if (args.options.defaultRecordBehavior &&
141
- ['startLocked', 'startUnlocked'].indexOf(args.options.defaultRecordBehavior) === -1) {
142
- return `${args.options.defaultRecordBehavior} is not a valid state of a record label. Allowed values are startLocked|startUnlocked`;
169
+ PurviewRetentionLabelAddCommand.defaultRecordBehavior.indexOf(args.options.defaultRecordBehavior) === -1) {
170
+ return `${args.options.defaultRecordBehavior} is not a valid state of a record label. Allowed values are ${PurviewRetentionLabelAddCommand.defaultRecordBehavior.join(', ')}`;
143
171
  }
144
172
  return true;
145
173
  }));
174
+ }, _PurviewRetentionLabelAddCommand_initOptionSets = function _PurviewRetentionLabelAddCommand_initOptionSets() {
175
+ this.optionSets.push({ options: ['eventTypeId', 'eventTypeName'], runsWhen(args) { return args.options.retentionTrigger === 'dateOfEvent'; } });
146
176
  };
177
+ PurviewRetentionLabelAddCommand.behaviorDuringRetentionPeriods = ['doNotRetain', 'retain', 'retainAsRecord', 'retainAsRegulatoryRecord'];
178
+ PurviewRetentionLabelAddCommand.actionAfterRetentionPeriods = ['none', 'delete', 'startDispositionReview'];
179
+ PurviewRetentionLabelAddCommand.retentionTriggers = ['dateLabeled', 'dateCreated', 'dateModified', 'dateOfEvent'];
180
+ PurviewRetentionLabelAddCommand.defaultRecordBehavior = ['startLocked', 'startUnlocked'];
147
181
  module.exports = new PurviewRetentionLabelAddCommand();
148
182
  //# sourceMappingURL=retentionlabel-add.js.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const prefix = 'purview';
4
4
  exports.default = {
5
5
  AUDITLOG_LIST: `${prefix} auditlog list`,
6
+ RETENTIONEVENT_ADD: `${prefix} retentionevent add`,
6
7
  RETENTIONEVENT_GET: `${prefix} retentionevent get`,
7
8
  RETENTIONEVENT_LIST: `${prefix} retentionevent list`,
8
9
  RETENTIONEVENT_REMOVE: `${prefix} retentionevent remove`,
@@ -0,0 +1,105 @@
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 _SpoUserEnsureCommand_instances, _SpoUserEnsureCommand_initTelemetry, _SpoUserEnsureCommand_initOptions, _SpoUserEnsureCommand_initValidators, _SpoUserEnsureCommand_initOptionSets;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const request_1 = require("../../../../request");
19
+ const aadUser_1 = require("../../../../utils/aadUser");
20
+ const validation_1 = require("../../../../utils/validation");
21
+ const SpoCommand_1 = require("../../../base/SpoCommand");
22
+ const commands_1 = require("../../commands");
23
+ class SpoUserEnsureCommand extends SpoCommand_1.default {
24
+ get name() {
25
+ return commands_1.default.USER_ENSURE;
26
+ }
27
+ get description() {
28
+ return 'Ensures that a user is available on a specific site';
29
+ }
30
+ constructor() {
31
+ super();
32
+ _SpoUserEnsureCommand_instances.add(this);
33
+ __classPrivateFieldGet(this, _SpoUserEnsureCommand_instances, "m", _SpoUserEnsureCommand_initTelemetry).call(this);
34
+ __classPrivateFieldGet(this, _SpoUserEnsureCommand_instances, "m", _SpoUserEnsureCommand_initOptions).call(this);
35
+ __classPrivateFieldGet(this, _SpoUserEnsureCommand_instances, "m", _SpoUserEnsureCommand_initValidators).call(this);
36
+ __classPrivateFieldGet(this, _SpoUserEnsureCommand_instances, "m", _SpoUserEnsureCommand_initOptionSets).call(this);
37
+ }
38
+ commandAction(logger, args) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ if (this.verbose) {
41
+ logger.logToStderr(`Ensuring user ${args.options.aadId || args.options.userName} at site ${args.options.webUrl}`);
42
+ }
43
+ try {
44
+ const requestBody = {
45
+ logonName: args.options.userName || (yield this.getUpnByUserId(args.options.aadId, logger))
46
+ };
47
+ const requestOptions = {
48
+ url: `${args.options.webUrl}/_api/web/ensureuser`,
49
+ headers: {
50
+ accept: 'application/json;odata=nometadata'
51
+ },
52
+ data: requestBody,
53
+ responseType: 'json'
54
+ };
55
+ const response = yield request_1.default.post(requestOptions);
56
+ logger.log(response);
57
+ }
58
+ catch (err) {
59
+ this.handleRejectedODataJsonPromise(err);
60
+ }
61
+ });
62
+ }
63
+ getUpnByUserId(aadId, logger) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ if (this.verbose) {
66
+ logger.logToStderr(`Retrieving user principal name for user with id ${aadId}`);
67
+ }
68
+ return yield aadUser_1.aadUser.getUpnByUserId(aadId);
69
+ });
70
+ }
71
+ }
72
+ _SpoUserEnsureCommand_instances = new WeakSet(), _SpoUserEnsureCommand_initTelemetry = function _SpoUserEnsureCommand_initTelemetry() {
73
+ this.telemetry.push((args) => {
74
+ Object.assign(this.telemetryProperties, {
75
+ aadId: typeof args.options.aadId !== 'undefined',
76
+ userName: typeof args.options.userName !== 'undefined'
77
+ });
78
+ });
79
+ }, _SpoUserEnsureCommand_initOptions = function _SpoUserEnsureCommand_initOptions() {
80
+ this.options.unshift({
81
+ option: '-u, --webUrl <webUrl>'
82
+ }, {
83
+ option: '--aadId [aadId]'
84
+ }, {
85
+ option: '--userName [userName]'
86
+ });
87
+ }, _SpoUserEnsureCommand_initValidators = function _SpoUserEnsureCommand_initValidators() {
88
+ this.validators.push((args) => __awaiter(this, void 0, void 0, function* () {
89
+ const isValidSharePointUrl = validation_1.validation.isValidSharePointUrl(args.options.webUrl);
90
+ if (isValidSharePointUrl !== true) {
91
+ return isValidSharePointUrl;
92
+ }
93
+ if (args.options.aadId && !validation_1.validation.isValidGuid(args.options.aadId)) {
94
+ return `${args.options.aadId} is not a valid GUID.`;
95
+ }
96
+ if (args.options.userName && !validation_1.validation.isValidUserPrincipalName(args.options.userName)) {
97
+ return `${args.options.userName} is not a valid userName.`;
98
+ }
99
+ return true;
100
+ }));
101
+ }, _SpoUserEnsureCommand_initOptionSets = function _SpoUserEnsureCommand_initOptionSets() {
102
+ this.optionSets.push({ options: ['aadId', 'userName'] });
103
+ };
104
+ module.exports = new SpoUserEnsureCommand();
105
+ //# sourceMappingURL=user-ensure.js.map
@@ -299,6 +299,7 @@ exports.default = {
299
299
  THEME_LIST: `${prefix} theme list`,
300
300
  THEME_REMOVE: `${prefix} theme remove`,
301
301
  THEME_SET: `${prefix} theme set`,
302
+ USER_ENSURE: `${prefix} user ensure`,
302
303
  USER_GET: `${prefix} user get`,
303
304
  USER_LIST: `${prefix} user list`,
304
305
  USER_REMOVE: `${prefix} user remove`,
@@ -53,6 +53,23 @@ exports.aadUser = {
53
53
  }
54
54
  return res.value[0].id;
55
55
  });
56
+ },
57
+ /**
58
+ * Retrieve the UPN of a user by its ID.
59
+ * @param id User ID.
60
+ */
61
+ getUpnByUserId(id) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ const requestOptions = {
64
+ url: `${graphResource}/v1.0/users/${id}?$select=userPrincipalName`,
65
+ headers: {
66
+ accept: 'application/json;odata.metadata=none'
67
+ },
68
+ responseType: 'json'
69
+ };
70
+ const res = yield request_1.default.get(requestOptions);
71
+ return res.userPrincipalName;
72
+ });
56
73
  }
57
74
  };
58
75
  //# sourceMappingURL=aadUser.js.map
@@ -0,0 +1,149 @@
1
+ # purview retentionevent add
2
+
3
+ Create a retention event
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 purview retentionevent add [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-n, --displayName <displayName>`
14
+ : The display name of the event
15
+
16
+ `-e, --eventTypeName [eventTypeName]`
17
+ : Name of the event type associated with the event. Specify either `eventTypeId` or `eventTypeName` but not both.
18
+
19
+ `-i, --eventTypeId [eventTypeId]`
20
+ : Id of the event type associated with the event. Specify either `eventTypeId` or `eventTypeName` but not both.
21
+
22
+ `-d, --description [description]`
23
+ : A description for the event
24
+
25
+ `--triggerDateTime [triggerDateTime]`
26
+ : Optional time when the event should be triggered.
27
+
28
+ `-a, --assetIds [assetIds]`
29
+ : The Asset IDs for items in SharePoint and OneDrive that are related to this event. Only items that have labels associated with the event type you chose will be retained. Specify `assetIds` and/or `keywords`, but at least one.
30
+
31
+ `-k, --keywords [keywords]`
32
+ : The keywords for items in Exchange that are related to this event. Only items that have labels associated with the event type you chose will be retained. Specify `assetIds` and/or `keywords`, but at least one.
33
+
34
+ --8<-- "docs/cmd/_global.md"
35
+
36
+ ## Remarks
37
+
38
+ !!! attention
39
+ This command is based on an API that is currently in preview and is subject to change once the API reached general availability.
40
+
41
+ !!! attention
42
+ This command currently only supports delegated permissions.
43
+
44
+ ## Examples
45
+
46
+ Create a retention event to start retention at the end of 2022 for all employee documents that have been labeled and have the Asset ID _EmployeeNr1234_
47
+
48
+ ```sh
49
+ m365 purview retentionevent add --displayName 'Employee information expiration' --description 'Employee documents expired due to offboarding' --eventTypeName 'CustomRetentionTime' --triggerDateTime '2022-12-31' --assetIds 'ComplianceAssetId:EmployeeNr1234'
50
+ ```
51
+
52
+ ## More information
53
+
54
+ This command is part of a series of commands that have to do with event-based retention. Event-based retention is about starting a retention period when a specific event occurs, instead of the moment a document was labeled or created.
55
+
56
+ [Read more on event-based retention here](https://learn.microsoft.com/en-us/microsoft-365/compliance/event-driven-retention?view=o365-worldwide)
57
+
58
+
59
+ ## Response
60
+
61
+ === "JSON"
62
+
63
+ ```json
64
+ {
65
+ "displayName": "Event display name",
66
+ "description": "Event description",
67
+ "eventTriggerDateTime": "2023-04-02T15:47:54Z",
68
+ "lastStatusUpdateDateTime": "0001-01-01T00:00:00Z",
69
+ "createdDateTime": "2023-02-20T18:53:05Z",
70
+ "lastModifiedDateTime": "2023-02-20T18:53:05Z",
71
+ "id": "9f5c1a04-8f7a-4bff-e400-08db1373b324",
72
+ "eventQueries": [
73
+ {
74
+ "queryType": "files",
75
+ "query": "filesQuery,filesQuery1"
76
+ },
77
+ {
78
+ "queryType": "messages",
79
+ "query": "messagesQuery,messagesQuery1"
80
+ }
81
+ ],
82
+ "eventStatus": {
83
+ "error": null,
84
+ "status": "pending"
85
+ },
86
+ "eventPropagationResults": [],
87
+ "createdBy": {
88
+ "user": {
89
+ "id": null,
90
+ "displayName": "John Doe"
91
+ }
92
+ },
93
+ "lastModifiedBy": {
94
+ "user": {
95
+ "id": null,
96
+ "displayName": "John Doe"
97
+ }
98
+ }
99
+ }
100
+ ```
101
+
102
+ === "Text"
103
+
104
+ ```text
105
+ createdBy : {"user":{"id":null,"displayName":"John Doe"}}
106
+ createdDateTime : 2023-02-20T18:53:05Z
107
+ description : Event description
108
+ displayName : Event display name
109
+ eventPropagationResults : []
110
+ eventQueries : [{"queryType":"files","query":"filesQuery,filesQuery1"},{"queryType":"messages","query":"messagesQuery,messagesQuery1"}]
111
+ eventStatus : {"error":null,"status":"pending"}
112
+ eventTriggerDateTime : 2023-04-02T15:47:54Z
113
+ id : 9f5c1a04-8f7a-4bff-e400-08db1373b324
114
+ lastModifiedBy : {"user":{"id":null,"displayName":"John Doe"}}
115
+ lastModifiedDateTime : 2023-02-20T18:53:05Z
116
+ lastStatusUpdateDateTime: 0001-01-01T00:00:00Z
117
+ ```
118
+
119
+ === "CSV"
120
+
121
+ ```csv
122
+ displayName,description,eventTriggerDateTime,lastStatusUpdateDateTime,createdDateTime,lastModifiedDateTime,id,eventQueries,eventStatus,eventPropagationResults,createdBy,lastModifiedBy
123
+ Event display name,Event description,2023-04-02T15:47:54Z,0001-01-01T00:00:00Z,2023-02-20T18:53:05Z,2023-02-20T18:53:05Z,9f5c1a04-8f7a-4bff-e400-08db1373b324,"[{""queryType"":""files"",""query"":""filesQuery,filesQuery1""},{""queryType"":""messages"",""query"":""messagesQuery,messagesQuery1""}]","{""error"":null,""status"":""pending""}",[],"{""user"":{""id"":null,""displayName"":""John Doe""}}","{""user"":{""id"":null,""displayName"":""John Doe""}}"
124
+ ```
125
+
126
+ === "Markdown"
127
+
128
+ ```md
129
+ # purview retentionevent add --displayName "Event display name" --eventType "Event Type" --description "Event description" --triggerDateTime "2023-04-02T15:47:54Z" --assetIds "filesQuery,filesQuery1" --keywords "messagesQuery,messagesQuery1"
130
+
131
+ Date: 20/2/2023
132
+
133
+ ## Event display name (9f5c1a04-8f7a-4bff-e400-08db1373b324)
134
+
135
+ Property | Value
136
+ ---------|-------
137
+ displayName | Event display name
138
+ description | Event description
139
+ eventTriggerDateTime | 2023-04-02T15:47:54Z
140
+ lastStatusUpdateDateTime | 0001-01-01T00:00:00Z
141
+ createdDateTime | 2023-02-20T18:53:05Z
142
+ lastModifiedDateTime | 2023-02-20T18:53:05Z
143
+ id | 9f5c1a04-8f7a-4bff-e400-08db1373b324
144
+ eventQueries | [{"queryType":"files","query":"filesQuery,filesQuery1"},{"queryType":"messages","query":"messagesQuery,messagesQuery1"}]
145
+ eventStatus | {"error":null,"status":"pending"}
146
+ eventPropagationResults | []
147
+ createdBy | {"user":{"id":null,"displayName":"John Doe"}}
148
+ lastModifiedBy | {"user":{"id":null,"displayName":"John Doe"}}
149
+ ```
@@ -37,6 +37,12 @@ m365 purview retentionlabel add [options]
37
37
  `--labelToBeApplied [labelToBeApplied]`
38
38
  : Specifies the replacement label to be applied automatically after the retention period of the current label ends.
39
39
 
40
+ `--eventTypeId [eventTypeId]`
41
+ : The Id of the event type that is used to in case of an event-based label. Specify when using retentionTrigger with the value `dateOfEvent`. Specify either `eventTypeId` or `eventTypeName`, but not both.
42
+
43
+ `--eventTypeName [eventTypeName]`
44
+ : The display name of the event type that is used to in case of an event-based label. Specify when using retentionTrigger with the value `dateOfEvent`. Specify either `eventTypeId` or `eventTypeName`, but not both.
45
+
40
46
  --8<-- "docs/cmd/_global.md"
41
47
 
42
48
  ## Examples
@@ -53,6 +59,12 @@ Create a retention label that retains documents as records and does not take any
53
59
  m365 purview retentionlabel add --displayName 'some label' --behaviorDuringRetentionPeriod retainAsRecord --actionAfterRetentionPeriod none --retentionDuration 365 --retentionTrigger dateModified
54
60
  ```
55
61
 
62
+ Create an event-based retention label that retains documents as records and deletes them one year after a _Contract Expiry_ event date.
63
+
64
+ ```sh
65
+ m365 purview retentionlabel add --displayName 'some label' --behaviorDuringRetentionPeriod retain --actionAfterRetentionPeriod delete --retentionDuration 365 --retentionTrigger dateOfEvent --eventTypeName "Contract Expiry"
66
+ ```
67
+
56
68
  ## Remarks
57
69
 
58
70
  !!! attention
@@ -63,3 +63,24 @@ m365 spfx project permissions grant
63
63
  ClientId,ConsentType,IsDomainIsolated,ObjectId,PackageName,Resource,ResourceId,Scope
64
64
  6004a642-185c-479a-992a-15d1c23e2229,AllPrincipals,,QqYEYFwYmkeZKhXRwj4iKRcAa6TiIbFNvGnKY1dqONY,,Microsoft Graph,a46b0017-21e2-4db1-bc69-ca63576a38d6,Mail.Read
65
65
  ```
66
+
67
+ === "Markdown"
68
+
69
+ ```md
70
+ # spfx project permissions grant
71
+
72
+ Date: 2/17/2023
73
+
74
+ ## QqYEYFwYmkeZKhXRwj4iKRcAa6TiIbFNvGnKY1dqONY
75
+
76
+ Property | Value
77
+ ---------|-------
78
+ ClientId | 6004a642-185c-479a-992a-15d1c23e2229
79
+ ConsentType | AllPrincipals
80
+ IsDomainIsolated | false
81
+ ObjectId | QqYEYFwYmkeZKhXRwj4iKRcAa6TiIbFNvGnKY1dqONY
82
+ PackageName | null
83
+ Resource | Microsoft Graph
84
+ ResourceId | a46b0017-21e2-4db1-bc69-ca63576a38d6
85
+ Scope | Mail.Read
86
+ ```
@@ -0,0 +1,109 @@
1
+ # spo user ensure
2
+
3
+ Ensures that a user is available on a specific site
4
+
5
+ ## Usage
6
+
7
+ ```sh
8
+ m365 spo user ensure [options]
9
+ ```
10
+
11
+ ## Options
12
+
13
+ `-u, --webUrl <webUrl>`
14
+ : Absolute URL of the site.
15
+
16
+ `--aadId [--aadId]`
17
+ : Id of the user in Azure AD. Specify either `aadId` or `userName` but not both.
18
+
19
+ `--userName [userName]`
20
+ : User's UPN (user principal name, e.g. john@contoso.com). Specify either `aadId` or `userName` but not both.
21
+
22
+ --8<-- "docs/cmd/_global.md"
23
+
24
+ ## Examples
25
+
26
+ Ensures a user by its Azure AD Id
27
+
28
+ ```sh
29
+ m365 spo user ensure --webUrl https://contoso.sharepoint.com/sites/project --aadId e254750a-eaa4-44f6-9517-b74f65cdb747
30
+ ```
31
+
32
+ Ensures a user by its user principal name
33
+
34
+ ```sh
35
+ m365 spo user ensure --webUrl https://contoso.sharepoint.com/sites/project --userName john@contoso.com
36
+ ```
37
+
38
+ ## Response
39
+
40
+ === "JSON"
41
+
42
+ ```json
43
+ {
44
+ "Id": 35,
45
+ "IsHiddenInUI": false,
46
+ "LoginName": "i:0#.f|membership|john@contoso.com",
47
+ "Title": "John Doe",
48
+ "PrincipalType": 1,
49
+ "Email": "john@contoso.com",
50
+ "Expiration": "",
51
+ "IsEmailAuthenticationGuestUser": false,
52
+ "IsShareByEmailGuestUser": false,
53
+ "IsSiteAdmin": false,
54
+ "UserId": {
55
+ "NameId": "1003200274f51d2d",
56
+ "NameIdIssuer": "urn:federation:microsoftonline"
57
+ },
58
+ "UserPrincipalName": "john@contoso.com"
59
+ }
60
+ ```
61
+
62
+ === "Text"
63
+
64
+ ```text
65
+ Email : john@contoso.com
66
+ Expiration :
67
+ Id : 35
68
+ IsEmailAuthenticationGuestUser: false
69
+ IsHiddenInUI : false
70
+ IsShareByEmailGuestUser : false
71
+ IsSiteAdmin : false
72
+ LoginName : i:0#.f|membership|john@contoso.com
73
+ PrincipalType : 1
74
+ Title : John Doe
75
+ UserId : {"NameId":"1003200274f51d2d","NameIdIssuer":"urn:federation:microsoftonline"}
76
+ UserPrincipalName : john@contoso.com
77
+ ```
78
+
79
+ === "CSV"
80
+
81
+ ```csv
82
+ Id,IsHiddenInUI,LoginName,Title,PrincipalType,Email,Expiration,IsEmailAuthenticationGuestUser,IsShareByEmailGuestUser,IsSiteAdmin,UserId,UserPrincipalName
83
+ 35,,i:0#.f|membership|john@contoso.com,John Doe,1,john@contoso.com,,,,,"{""NameId"":""100320009d80e5de"",""NameIdIssuer"":""urn:federation:microsoftonline""}",john@contoso.com
84
+ ```
85
+
86
+ === "Markdown"
87
+
88
+ ```md
89
+ # spo user ensure --webUrl "https://mathijsdev2.sharepoint.com" --userName "john@contoso.com"
90
+
91
+ Date: 18/02/2023
92
+
93
+ ## John Doe (35)
94
+
95
+ Property | Value
96
+ ---------|-------
97
+ Id | 35
98
+ IsHiddenInUI | false
99
+ LoginName | i:0#.f\|membership\|john@contoso.com
100
+ Title | John Doe
101
+ PrincipalType | 1
102
+ Email | john@contoso.com
103
+ Expiration |
104
+ IsEmailAuthenticationGuestUser | false
105
+ IsShareByEmailGuestUser | false
106
+ IsSiteAdmin | false
107
+ UserId | {"NameId":"100320009d80e5de","NameIdIssuer":"urn:federation:microsoftonline"}
108
+ UserPrincipalName | john@contoso.com
109
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pnp/cli-microsoft365",
3
- "version": "6.4.0-beta.39e5130",
3
+ "version": "6.4.0-beta.8c5ba0e",
4
4
  "description": "Manage Microsoft 365 and SharePoint Framework projects on any platform",
5
5
  "license": "MIT",
6
6
  "main": "./dist/api.js",